aboutsummaryrefslogtreecommitdiff
path: root/docs/calling_convention.txt
blob: 87731ba621650d1c541d410165dd50ff20e1c8c9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
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