This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Printing an integer to stdout with printf in 64-bit NASM (Linux) | |
While doing some debugging, I found myself wanting to print an address to the screen, and it | |
took me forever to piece together how to do it from several tutorials. | |
The main things you need to know are | |
1) use 'main:' as a label and not '_start:' - because you are calling libc, it won't work without main. | |
2) compile or link with -lc (that's short for libc). | |
3) declare printf as extern | |
4) zero the vector registers (put 0 into rax). I don't know why, but apparently you are supposed to. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/home/sblip/article.2 | |
using the getdents(2) Linux syscall to read directory entries from disk. | |
This article assumes basic knowledge of at&t syntax assembly, and basic | |
understanding of how to make system calls in linux through int 0x80h. |