X86-64 Reference Sheet I
https://www.cs.cmu.edu/afs/cs/academic/class/15213-s20/www/recitations/x86-cheat-sheet.pdf
X86-64 Reference Sheet II
Registers
Register |
Purpose |
Saved across calls |
%rax |
temp register; return value |
No |
%rbx |
callee-saved |
Yes |
%rcx |
used to pass 4th argument to functions |
No |
%rdx |
used to pass 3rd argument to functions |
No |
%rsp |
stack pointer |
Yes |
%rbp |
callee-saved; base pointer |
Yes |
%rsi |
used to pass 2nd argument to functions |
No |
%rdi |
used to pass 1st argument to functions |
No |
%r8 |
used to pass 5th argument to functions |
No |
%r9 |
used to pass 6th argument to functions |
No |
%r10-r11 |
temporary |
No |
%r12-r15 |
callee-saved registers |
Yes |
Stack Organization
Position |
Contents |
Frame |
8n+16(%rbp) |
argument n |
Previous |
... |
... |
|
16(%rbp) |
argument 7 |
|
8(%rbp) |
return address |
Current |
0(%rbp) |
previous %rbp value |
|
-8(%rbp) |
locals and temps |
|
... |
||
0(%rsp) |
Prologue:
// call -> pushs %rip onto stack
push %ebp
mov %esp, %ebp
Epilogue:
mov %ebp, %esp
pop %ebp
// ret -> pops %rip from stack
SIMD: MMX, SSE, AVX
512-bit |
256-bit |
128-bit |
Preserved |
Usage |
zmm0 |
ymm0 |
xmm0 |
arg1, return |
|
zmm1 |
ymm1 |
xmm1 |
arg2 |
|
⋮ |
⋮ |
|||
zmm7 |
ymm7 |
xmm7 |
arg8 |
|
zmm8 |
ymm8 |
xmm8 |
||
⋮ |
||||
zmm15 |
ymm15 |
xmm15 |
Example:
double foo(double x, int y) {
return x + (double) y;
}
_Z3foodi:
cvtsi2sd %edi, %xmm1
addsd %xmm1, %xmm0
ret
标签:functions,used,Sheet,X86,No,argument,rbp,64,pass From: https://www.cnblogs.com/william-cheung/p/18365863