README 1.23 KB
Newer Older
Niels Möller's avatar
Niels Möller committed
1
2
3
ABI, according to http://www.x86-64.org/documentation/abi-0.99.pdf:

Up to 6 integer and pointer arguments are passed in registers. Nine
Niels Möller's avatar
Niels Möller committed
4
registers, %rax, %rcx, %rdx, %rsi, %rdi and %r8-%r11 can be used
Niels Möller's avatar
Niels Möller committed
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
freely. Integers and pointers are returned in %rax.

Registers	May be		Argument
		clobbered	number

%rax 		Y
%rbx		
%rcx		Y		4
%rdx		Y		3
%rbp		
%rsi		Y		2
%rdi		Y		1 
%rsp		(SP)
%r8		Y		5
%r9		Y		6
%r10		Y
%r11		Y
%r12		
%r13		
%r14		
%r15		
26

27
W64 ABI, according to
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
http://msdn.microsoft.com/en-us/library/9z1stfyw.aspx:

Registers	May be		Argument
		clobbered	number

%rax 		Y
%rbx		
%rcx		Y		1
%rdx		Y		2
%rbp		
%rsi
%rdi
%rsp		(SP)
%r8		Y		3
%r9		Y		4
%r10		Y
%r11		Y
%r12		
%r13		
%r14		
%r15		

Additional arguments are passed on the stack. "backing store" on the
Martin Storsjö's avatar
Martin Storsjö committed
51
stack for the four register arguments is also required. %xmm6 to
Niels Möller's avatar
Niels Möller committed
52
%xmm15 are callee-saved. The "long" type is just 32 bits.
53
54
55
56
57
58
59
60
61
62
63
64

If we have five arguments, and push the additional callee-save
registers %rdi and %rsi on the stack, we get a stack frame like

56(%rsp): Fifth argument
48(%rsp): Space for fourth argument
40(%rsp): Space for third argument
32(%rsp): Space for second argument
24(%rsp): Space for first argument
16(%rsp): Return address
8(%rsp): Saved %rsi
(%rsp) : Saved %rdi