Status: Tags: #cards/cmpt295/assembly Links: x86-64 Assembly
Caller vs Callee
Principles
When a caller calls a callee? (Control, data, memory) ?
- Control is passed to beginning of callee function
- Once callee has executed, control is passed to…
- caller function right after the callee function
- Once callee has executed, control is passed to…
- Data is passed to …
- callee function via function params
- Memory is …
- allocated when callee function starts executing
- deallocated when callee function stops executing
Registers
Callee Saved
?
- For local data, we can use unused registers
- Must preserve values of registers before using them, then restore before control is passed back to caller function
List of callee saved ?
- rbx, r12, r13, r14, r15, rbp, rsp
Caller Saved
?
- Means that caller function must preserve values of registers before setting up callee’s arguments into the appropriate registers
- call callee
- once caller has control, restore values again

List of caller saved ?
%r10,%r11,%rax- paramsrdi, rsi, rdx, rcx, r8, r9
How to preserve %r10
?
- before calling callee,
pushq %r10 - call callee
- upon return,
popq %r10ddd
References:
Created:: 2022-02-12 15:51
Stack
Over 6 Arguments
Procedure for when over 6 function arguments ?
- Subtract %rsp to allocate memory in stack
mov*values onto stacklea*any addresses into stack if >6 or into registermov*values into stack if >6 or into register- call function



