What Registers Are The Caller-saved Registers
文章目录
- 1. Prerequisite
- 2. Definition
- ii.one Caller-saved registers
- 2.2 Callee-saved registers
- 3. Linux x86-64 function telephone call
- iii.1 Callee-saved registers
- 3.2 Caller-saved registers
- 4. Example
- 4.ane setjmp
- four.ii arch_switch_to
The introduction to caller-saved registers and callee-saved registers.
i. Prerequisite
Introduction to Organization Five ABI
2. Definition
two.1 Caller-saved registers
Caller-saved registers (AKA volatile registers, or call-clobbered) are used to hold temporary quantities that need non be preserved across calls.
For that reason, it is the caller's responsibility to push these registers onto the stack or copy them somewhere else if it wants to restore this value after a procedure call.
Information technology's normal to let a phone call
destroy temporary values in these registers, though.
2.2 Callee-saved registers
Callee-saved registers (AKA non-volatile registers, or call-preserved) are used to concur long-lived values that should be preserved beyond calls.
When the caller makes a procedure call, it can expect that those registers volition hold the aforementioned value after the callee returns, making it the responsibleness of the callee to salve them and restore them before returning to the caller. Or to not touch them.
iii. Linux x86-64 part call
spec
iii.1 Callee-saved registers
r12
, r13
, r14
, r15
, rbx
, rsp
, rbp
are the callee-saved registers - they take a "Yes" in the "Preserved across part calls" column.
3.2 Caller-saved registers
4. Example
4.1 setjmp
https://gitlab.com/kvm-unit of measurement-tests/kvm-unit-tests/-/blob/master/lib/x86/setjmp64.Southward
1 | .globl setjmp |
4.2 arch_switch_to
https://github.com/projectacrn/acrn-hypervisor/blob/release_2.7/hypervisor/curvation/x86/sched.Due south
1 | .text |
参考资料:
- What are callee and caller saved registers?
- What registers are preserved through a linux x86-64 part call
- x86 Assembly Guide
What Registers Are The Caller-saved Registers,
Source: http://liujunming.top/2022/01/11/What-is-callee-saved-registers/
Posted by: damicopriout37.blogspot.com
0 Response to "What Registers Are The Caller-saved Registers"
Post a Comment