diff options
| author | Tianhao Wang <shrik3@mailbox.org> | 2024-06-05 03:34:07 +0200 |
|---|---|---|
| committer | Tianhao Wang <shrik3@mailbox.org> | 2024-06-11 15:17:13 +0200 |
| commit | bd6a21a61e456539a04bc5474091104ff4eb8e9b (patch) | |
| tree | 6a23958e1a6e3c91e34407c21a29a8694ec08481 | |
| parent | 724cf846344333efc1f4ddbd2b05fa328e328276 (diff) | |
docs: add notes on calling conv
| -rw-r--r-- | docs/calling_convention.txt | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/docs/calling_convention.txt b/docs/calling_convention.txt new file mode 100644 index 0000000..87731ba --- /dev/null +++ b/docs/calling_convention.txt @@ -0,0 +1,53 @@ +x86_64 (SysV) calling convention +https://uclibc.org/docs/psABI-x86_64.pdf + +not including vector and FP registers + + register usage +----------------------------------------------------------------------- +register Usage preserved across calls +----------------------------------------------------------------------- +rax 1th return value No + temp (scratch) reg +----------------------------------------------------------------------- +rbx callee saved Yes +----------------------------------------------------------------------- +rdi fn parameter 1 No +----------------------------------------------------------------------- +rsi fn parameter 2 No +----------------------------------------------------------------------- +rdx fn parameter 3 No +----------------------------------------------------------------------- +rcx fn parameter 4 No +----------------------------------------------------------------------- +r8 fn parameter 5 No +----------------------------------------------------------------------- +r9 fn parameter 6 No +----------------------------------------------------------------------- +r10 function static chain ptr No + temp (scratch) reg +----------------------------------------------------------------------- +r11 temp (scratch) reg No +----------------------------------------------------------------------- +r12~r14 callee saved Yes +----------------------------------------------------------------------- +r15 callee saved Yes + optionally GOT base pointer +----------------------------------------------------------------------- +rsp stack pointer Yes +----------------------------------------------------------------------- +rbp callee saved + optionally frame pointer Yes +----------------------------------------------------------------------- + + + parameter passing (integer class only) +----------------------------------------------------------------------- +the first 6 parameters (left to right) are passed though register +rdi, rsi, rdx, rcx, r8, r9 + +further paramters are pushed to stack (right-to-left order) + ^^^^^^^^^^^^^ +----------------------------------------------------------------------- + +TODO returning value |
