diff options
Diffstat (limited to 'src/arch')
-rw-r--r-- | src/arch/x86_64.md | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/src/arch/x86_64.md b/src/arch/x86_64.md index e2bb527..63bea81 100644 --- a/src/arch/x86_64.md +++ b/src/arch/x86_64.md @@ -93,7 +93,7 @@ mov qword ptr [rax], 0xff // save 8 byte(s) at [rax] ----------- xmm0 1 .. .. - xmm7 7 + xmm7 8 ``` - Additional arguments are passed on the stack. Arguments are pushed right-to-left (RTL), meaning next arguments are closer to current `rsp`. @@ -136,7 +136,7 @@ must must save these registers in case they are used. - grows downwards - frames aligned on 16 byte boundary ```text - HI ADDR + Hi ADDR | +------------+ | | prev frame | | +------------+ <--- 16 byte aligned (X & ~0xf) @@ -145,9 +145,22 @@ must must save these registers in case they are used. | [rbp-8] | func stack | | | ... | v +------------+ - LO ADDR + Lo ADDR ``` +### Function prologue & epilogue +- prologue + ```x86asm + push rbp // save caller base pointer + mov rbp, rsp // save caller stack pointer + ``` +- epilogue + ```x86asm + mov rsp, rbp // restore caller stack pointer + pop rbp // restore caller base pointer + ``` + > Equivalent to `leave` instruction. + ## ASM skeleton Small assembler skeleton, ready to use with following properties: - use raw Linux syscalls (`man 2 syscall` for ABI) |