32-bit vs 64-bit
| Registers | |
| Syscall interface | |
| Calling conventions |
Registers
32-bit x86 has eight general-purpose registers (EAX through EDI); x86-64 has sixteen (RAX through R15). The extra registers are the biggest single reason 64-bit code runs faster: fewer memory spills.
mov eax, 1 ; 32-bit: 8 registers
mov rax, 1 ; 64-bit: 16 registers
Syscall interface
32-bit Linux uses INT 80h with the call number in EAX and arguments in EBX, ECX, EDX, ESI, EDI, EBP. 64-bit Linux uses SYSCALL with RAX and RDI, RSI, RDX, R10, R8, R9. The numbers differ too: exit is 1 in 32-bit, 60 in 64-bit.
Calling conventions
32-bit C pushed all arguments on the stack (cdecl). 64-bit System V passes the first six in registers. So a 64-bit call is faster, and an argument list that fit fine in 32-bit registers can spill to the stack in either world.
Next: The System V ABI
Article author: Arthur Isaev