In this video tutorial, I talk about the general layout of an NASM assembly program. I discus what the .data, .text, and .bss sections are. Then we write a practical assembly program that calls c functions. Then we compile the program using nasm and gcc
http://http://soliduscode.blogspot.com/
Amazon Auto Links: No products found.
I’m just curios but could you explain further how that could cause a stack overflow?
This looks huge when spread on a 4k monitor on fullscreen! 😀
I see the text fine, make sure you are watching it in 720p.
Do you have a video on how to do this on 64 bit machine?
Thanks, for a super quick intro into assembly. It tells me1) what application to use 2) how it combines with gcc and how to link 3) how it combines with externally compiled functions 4) how it compares to a c program body. All this in less than 8 minutes!. Super.
thank you for tutorial you are good Professor
I’m thinking if you used cygwin you could get it to work.
its blurg, i cant see it clearly
how can I port this to a 64 bit machine? I’d like to learn more ASM rather than just reading it for RE, but I want to compile this on a 64 bit Arch linux machine.
hey wtf it doesn’t work on windows
Why do you have to restore the stack pointer (esp) before to pop ebp? Thanks in advance
awesome!
I NEED NASM , NOT GCC
So, does the ‘printf’ subroutine use an OS based interrupt(80h) or bios based interrupt(10h)? If OS then wouldn’t it be OS limited(not to mention longer in using vectored interrupts). The OS simply catches the interrupt(80h for Linux, 21h for Windows) and sends it to the bios(10h in the example provided). I find that if you limit the OS wired int usage as much as possible that it is much more transportable across OS types. A Util.asm file that holds all the utility to call bios int would be in order, sorta like how C uses the Util.C file for basically the same reason. On longer programs, do you have to insert NOP operations to allow the other interrupts that goes on inside a time-sharing multitasker to take place?
It is unfortunate that some of you can see the text of the video.
Two suggestions:
(1)try viewing the video in 720p mode
(2)visit soliduscode.blogspot.com as some of this information is repeated there
“Error : binary output format does not support external references”
Wat.
Why do I get “unidenfitied refrence to WinMain@16” and “unidentified refrence to printf?”
Yeah, I really would like to do it my computer but I cannot see what you are typing. Sounds like a good video.
Why you use:
push ebp
mov ebp,esp
;…
mov esp,ebp
pop ebp
ret?
I used only “ret” and worked for me, why?
Thank you, and sry my worst english.
you need MASM bro not NASM
Becuase you have not got ld installed. ld is a linker and gcc uses it to make object files into executable binaries
I have bad eyes and am close to needing a screen reader just to be able to use a computer. Some people need the larger font size. That video could be in 1080p and it wouldn’t matter because the text is too small.
lol is this assembly or c?
Is your system 32 bit or is it a problem with the code? to me it looks like its trying to link as 64 bit code but i may be wrong.
Assembly programs are specific to the architecure. This guy is on linux which has a different architecture and will use different system calls.
I keep getting the error “unable to open input file asm1.asm” why is this?
And could you increase the font size on your editor next time to maybe 16-20 point font? I can barely see it.
If you’re getting a error like this: i386 architecture of input file `asm1.o’ is incompatible with i386:x86-64 output, when attepting to make: gcc -o asm1 asm1.o – You only need to type this instead: gcc -m32 -o asm1 asm1.o – The error I think is because the first one is trying to combine 64bit elements to 32bit elements, or some intelectual cybernetic shit like that!
я нихера не понял 🙁
32 or 64 bit linux?
gcc wont compile my code. it keeps saying: gcc -o test1 test1.o
ld: warning: ignoring file test1.o, file was built for unsupported file format ( 0x7F 0x45 0x4C 0x46 0x01 0x01 0x01 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 ) which is not the architecture being linked (x86_64): test1.o
Undefined symbols for architecture x86_64:
“_main”, referenced from:
implicit entry/start for main executable
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Here is a stupid question but I had to ask it:
Normally printf in C has an argument or more to deal with. when you call ‘push msg’ and printf afterwards, where from does printf find your message? is it a the top of the stack?
This might be a very stupid question, but can I convert this NASM assembly code to z80 assembly?
Font too small to see. This is common to all youtube videos. Is there any solution ?
For anyone having issues with assembling! I made a small tutorial below explaining how to assemble using NASM in the terminal on either Linux or Windows (warning I don’t have Linux so it may not work correctly, though it should):- On WindowsIt should be global _main at the beginning.nasm -f win32 hello.asm
gcc -o hello hello.obj
If you want a 32 bit application then make it win32, if you want a 64 bit application then make it win64.
– On LinuxIt should be global _start at the beginning. You should compile with:nasm -f elf32 hello.asmgcc -o hello hello.oIf you want a 32 bit application then make it elf32, if you want a 64 bit application then make it elf64.- Notessection .data, section .bss, section .text can also be defined as segment .data, segment .bss, segment .text.If you are creating an .asm file that does not have anything to do with the C library. So that mean’s things like printf. You should use lb -o hello hello.o or lb -o hello hello.obj instead. Your program will assemble fine with gcc however if it doesn’t use anything from the C library like printf then it will be better if you assemble it using lb.