x86_64 Assembly Linux System Call Confusion

You’re running into one surprising difference between i386 and x86_64: they don’t use the same system call mechanism. The correct code is:

movq $60, %rax
movq $2,  %rdi   ; not %rbx!
syscall

Interrupt 0x80 always invokes 32-bit system calls. It’s used to allow 32-bit applications to run on 64-bit systems.

For the purposes of learning, you should probably try to follow the tutorial exactly, rather than translating on the fly to 64-bit — there are a few other significant behavioral differences that you’re likely to run into. Once you’re familiar with i386, then you can pick up x86_64 separately.

Leave a Comment