AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |
Back to Blog
Dosbox command line syntax12/3/2023 ![]() And when accessing named variables, a rel prefix is required. The call stack must be aligned on a 16-byte boundary (more on this later). In macOS land, C functions (or any function that is exported from one module to another, really) must be prefixed with underscores. $ nasm -fmacho64 hola.asm & gcc hola.o &. Message: db "Hola, mundo", 0 C strings need a zero byte at the end Lea rdi, First argument is address of message _main: push rbx Call stack must be aligned This is an macOS console program that writes "Hola, mundo" on one line and then exits. Remember how in C execution “starts” at the function main? That’s because the C library actually has the _start label inside itself! The code at _start does some initialization, then it calls main, then it does some clean up, then it issues the system call for exit. We would like to use the good stuff in the C library. Writing standalone programs with just system calls is cool, but rare. It simply defines an abbreviation for the assembler itself to use.
0 Comments
Read More
Leave a Reply. |