I believe I understand how the linux x86-64 ABI uses registers and stack to pass parameters to a function (cf. previous ABI discussion). What I'm confused about is if/what registers are expected to be preserved across a function call. That is, what registers are guarenteed not to get clobbered?
“Preserved across procedure calls” means that the value stored in the register will not be changed by a pro- cedure. It is safe to assume that the value in the register after the procedure call is the same as the value in the register before the call.
On x86-64 Linux, the first six function arguments are passed in registers %rdi , %rsi , %rdx , %rcx , %r8 , and %r9 , respectively. The seventh and subsequent arguments are passed on the stack, about which more below. The return value is passed in register %rax .
The main tools to write programs in x86 assembly are the processor registers. The registers are like variables built in the processor. Using registers instead of memory to store values makes the process faster and cleaner.
Here's the complete table of registers and their use from the documentation [PDF Link]:
r12
, r13
, r14
, r15
, rbx
, rsp
, rbp
are the callee-saved registers - they have a "Yes" in the "Preserved across function calls" column.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With