Every ABI convention requires register usage that is in line with said convention, the C compiler you're using may force ad-hoc register allocation so it's important to suffix with __volatile__
when intending to escape user space.
arch | instr | syscall no reg | arg reg | sysret reg | clobbered regs |
---|---|---|---|---|---|
x86-64 (Linux) | syscall |
rax |
rdi , rsi , rdx , r10 , r8 , r9 |
rax |
rax , rcx , r11 |
x86 (Linux) | int 0x80 |
eax |
ebx , ecx , edx , esi , edi , ebp |
eax |
eax , ebx , ecx , edx |
ARM aarch32 |
svc 0 |
r7 |
r0 , r1 , r2 , r3 , r4 , r5 , r6 |
r0 |
r0 -r3 , r7 |
ARM aarch64 |
`s |