From bd6a21a61e456539a04bc5474091104ff4eb8e9b Mon Sep 17 00:00:00 2001 From: Tianhao Wang Date: Wed, 5 Jun 2024 03:34:07 +0200 Subject: docs: add notes on calling conv --- docs/calling_convention.txt | 53 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 docs/calling_convention.txt 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 -- cgit v1.2.3-70-g09d2