3 ms·
Back in uni I took a class on Intel x86 assembly, and I ended up writing a small program that would take two numbers as arguments to the program and add them an
by X-Istence 15y ago
Back in uni I took a class on Intel x86 assembly, and I ended up writing a small program that would take two numbers as arguments to the program and add them and then spit out the result.
It would convert from c-style strings to actual numbers, do 32 bit addition on them, and then convert the number back to a c-style string before printing it to the screen.
For anyone getting started this may be worth a look, as I commented every single last line:
http://personal.x-istence.com/post/2008/02/03/addnumbersasm-updated http://personal.x-istence.com/post/2008/02/03/addnumbersasm-...
(Do note, I also set up various stack frames, mainly so that I could do debugging of my assembly code in gdb)
Edit: This will only compile and run on FreeBSD and or Mac OS X due to the use of FreeBSD syscall numbers and calling convention by pushing parameters to the stack unlike Linux which wants stuff in register (see http://www.freebsd.org/doc/en/books/developers-handbook/x86-system-calls.html http://www.freebsd.org/doc/en/books/developers-handbook/x86-...)