Segmentation fault caused by the wrong use of %ebx register ----------------------------------------------------------- If your compiler seems to work well, assembly code looks right and even the compiled program does the job correctly but segfaults instead of exiting cleanly, you should check if you use the EBX register. It might segfault on some systems and work well on others. The segfaulting behaviour has been seen at least in a Pentinkulma workstation but it's appearance seems to be quite flaky. If you happen to trace the program with gdb, you'll notice the segfault occurs after exiting your own code, in the C-library function _dl_pagesize() which is called from __libc_start_main(). At least this was the case in the observed situation. YMMV. The EBX register is mentioned to be callee-saved [1]. This means that it's value should be reset to original value before exiting a function that uses it. The specification is propably GCC and glibc specific. A simple example of full function framework: main: pushl %ebp movl %esp, %ebp pushl %ebx ; user code here popl %ebx movl %ebp, %esp popl %ebp leave ret Notice the operations with %ebx. This is the GCC way of doing things. Remember to keep the stack pointer (%esp) on the right track so the right values are popped. There are other registers that too have to be reset to original values if they are changed. See [1]. On the other hand these registers can be assumed to hold their values across function calls. [1] http://en.tldp.org/HOWTO/Assembly-HOWTO/linux.html