annotate doc/manual/callconvs/callconv_arm32.tex @ 277:703d102cb580

- doc fix in callconv appendix
author Tassilo Philipp
date Sun, 04 Mar 2018 17:18:38 +0100
parents 8402121e1737
children 276eb8c87aa0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
1 %
117
4a64b733dc76 - doc, added first version of mips64 callconv page
cslag
parents: 95
diff changeset
2 % Copyright (c) 2007,2010 Daniel Adler <dadler@uni-goettingen.de>,
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
3 % Tassilo Philipp <tphilipp@potion-studios.com>
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
4 %
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
5 % Permission to use, copy, modify, and distribute this software for any
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
6 % purpose with or without fee is hereby granted, provided that the above
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
7 % copyright notice and this permission notice appear in all copies.
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
8 %
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
9 % THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
10 % WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
11 % MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
12 % ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
13 % WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
14 % ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
15 % OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
16 %
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
17
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
18 % ==================================================
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
19 % ARM32
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
20 % ==================================================
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
21 \subsection{ARM32 Calling Convention}
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
22
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
23 \paragraph{Overview}
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
24
117
4a64b733dc76 - doc, added first version of mips64 callconv page
cslag
parents: 95
diff changeset
25 The ARM32 family of processors is based on the Advanced RISC Machines (ARM)
4a64b733dc76 - doc, added first version of mips64 callconv page
cslag
parents: 95
diff changeset
26 processor architecture (32 bit RISC).
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
27 The word size is 32 bits (and the programming model is LLP64).\\
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
28 Basically, this family of microprocessors can be run in 2 major modes:\\
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
29 \\
77
e441ef3ec782 - manual layout tweaks
cslag
parents: 76
diff changeset
30 \begin{tabular*}{0.95\textwidth}{2 B}
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
31 Mode & Description\\
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
32 \hline
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
33 {\bf ARM} & 32bit instruction set\\
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
34 {\bf THUMB} & compressed instruction set using 16bit wide instruction encoding\\
76
7ca46969e0ad - tweaks in manual, mainly for html generation
cslag
parents: 51
diff changeset
35 \end{tabular*}
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
36 \\
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
37 \\
95
9e99918065e6 - doc fixes (mainly for html output)
cslag
parents: 92
diff changeset
38 For more details, take a look at the ARM-THUMB Procedure Call Standard (ATPCS) \cite{ATPCS}, the Procedure Call Standard for the ARM Architecture (AAPCS) \cite{AAPCS}, as well as the Debian ARM EABI port wiki \cite{armeabi}.\\
173
8402121e1737 - doc tweaks
cslag
parents: 148
diff changeset
39 \\
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
40 \paragraph{\product{dyncall} support}
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
41
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
42 Currently, the \product{dyncall} library supports the ARM and THUMB mode of the ARM32 family (ATPCS \cite{ATPCS} and EABI \cite{armeabi}), excluding manually triggered ARM-THUMB interworking calls. Although it's quite possible that the current implementation runs on other ARM processor families as well, please note that only the ARMv4t family has been thoroughly tested at the time of writing. Please report if the code runs on other ARM families, too.\\
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
43 It is important to note, that dyncall supports the ARM architecture calling convention variant {\bf with floating point hardware disabled} (meaning that the FPA and the VFP (scalar mode) procedure call standards are not supported).
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
44 This processor family features some instruction sets accelerating DSP and multimedia application like the ARM Jazelle Technology (direct Java bytecode execution, providing acceleration for some bytecodes while calling software code for others), etc. that are not supported by the dyncall library.\\
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
45
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
46
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
47 \subsubsection{ATPCS ARM mode}
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
48
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
49
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
50 \paragraph{Registers and register usage}
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
51
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
52 In ARM mode, the ARM32 processor has sixteen 32 bit general purpose registers, namely r0-r15:\\
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
53 \\
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
54 \begin{table}[h]
77
e441ef3ec782 - manual layout tweaks
cslag
parents: 76
diff changeset
55 \begin{tabular*}{0.95\textwidth}{3 B}
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
56 Name & Brief description\\
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
57 \hline
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
58 {\bf r0} & parameter 0, scratch, return value\\
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
59 {\bf r1} & parameter 1, scratch, return value\\
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
60 {\bf r2-r3} & parameters 2 and 3, scratch\\
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
61 {\bf r4-r10} & permanent\\
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
62 {\bf r11} & frame pointer, permanent\\
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
63 {\bf r12} & scratch\\
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
64 {\bf r13} & stack pointer, permanent\\
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
65 {\bf r14} & link register, permanent\\
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
66 {\bf r15} & program counter (note: due to pipeline, r15 points to 2 instructions ahead)\\
76
7ca46969e0ad - tweaks in manual, mainly for html generation
cslag
parents: 51
diff changeset
67 \end{tabular*}
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
68 \caption{Register usage on arm32}
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
69 \end{table}
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
70
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
71 \paragraph{Parameter passing}
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
72
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
73 \begin{itemize}
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
74 \item stack parameter order: right-to-left
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
75 \item caller cleans up the stack
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
76 \item first four words are passed using r0-r3
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
77 \item subsequent parameters are pushed onto the stack (in right to left order, such that the stack pointer points to the first of the remaining parameters)
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
78 \item if the callee takes the address of one of the parameters and uses it to address other parameters (e.g. varargs) it has to copy - in its prolog - the first four words to a reserved stack area adjacent to the other parameters on the stack
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
79 \item parameters \textless=\ 32 bits are passed as 32 bit words
35
61edd9cf8026 - armhf doc update
cslag
parents: 34
diff changeset
80 \item 64 bit parameters are passed as two 32 bit parts (even partly via the register and partly via the stack, although this doesn't seem to be specified in the ATPCS), with the loword coming first
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
81 \item structures and unions are passed by value, with the first four words of the parameters in r0-r3
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
82 \item if return value is a structure, a pointer pointing to the return value's space is passed in r0, the first parameter in r1, etc... (see {\bf return values})
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
83 \item keeping the stack eight-byte aligned can improve memory access performance and is required by LDRD and STRD on ARMv5TE processors which are part of the ARM32 family, so, in order to avoid problems one should always align the stack (tests have shown, that GCC does care about the alignment when using the ellipsis)
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
84 \end{itemize}
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
85
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
86 \paragraph{Return values}
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
87 \begin{itemize}
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
88 \item return values \textless=\ 32 bits use r0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
89 \item 64 bit return values use r0 and r1
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
90 \item if return value is a structure, the caller allocates space for the return value on the stack in its frame and passes a pointer to it in r0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
91 \end{itemize}
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
92
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
93 \paragraph{Stack layout}
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
94
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
95 Stack directly after function prolog:\\
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
96
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
97 \begin{figure}[h]
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
98 \begin{tabular}{5|3|1 1}
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
99 \hhline{~-~~}
92
5c3fa8897e0e - manual work
cslag
parents: 90
diff changeset
100 & \vdots & & \\
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
101 \hhline{~=~~}
92
5c3fa8897e0e - manual work
cslag
parents: 90
diff changeset
102 register save area & \hspace{4cm} & & \mrrbrace{5}{caller's frame} \\
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
103 \hhline{~-~~}
92
5c3fa8897e0e - manual work
cslag
parents: 90
diff changeset
104 local data & & & \\
117
4a64b733dc76 - doc, added first version of mips64 callconv page
cslag
parents: 95
diff changeset
105 \hhline{~-~~}
92
5c3fa8897e0e - manual work
cslag
parents: 90
diff changeset
106 \mrlbrace{7}{parameter area} & \ldots & \mrrbrace{3}{stack parameters} & \\
5c3fa8897e0e - manual work
cslag
parents: 90
diff changeset
107 & \ldots & & \\
5c3fa8897e0e - manual work
cslag
parents: 90
diff changeset
108 & \ldots & & \\
117
4a64b733dc76 - doc, added first version of mips64 callconv page
cslag
parents: 95
diff changeset
109 \hhline{~=~~}
92
5c3fa8897e0e - manual work
cslag
parents: 90
diff changeset
110 & r3 & \mrrbrace{4}{spill area (if needed)} & \mrrbrace{7}{current frame} \\
5c3fa8897e0e - manual work
cslag
parents: 90
diff changeset
111 & r2 & & \\
5c3fa8897e0e - manual work
cslag
parents: 90
diff changeset
112 & r1 & & \\
5c3fa8897e0e - manual work
cslag
parents: 90
diff changeset
113 & r0 & & \\
117
4a64b733dc76 - doc, added first version of mips64 callconv page
cslag
parents: 95
diff changeset
114 \hhline{~-~~}
92
5c3fa8897e0e - manual work
cslag
parents: 90
diff changeset
115 register save area (with return address) & & & \\
117
4a64b733dc76 - doc, added first version of mips64 callconv page
cslag
parents: 95
diff changeset
116 \hhline{~-~~}
92
5c3fa8897e0e - manual work
cslag
parents: 90
diff changeset
117 local data & & & \\
117
4a64b733dc76 - doc, added first version of mips64 callconv page
cslag
parents: 95
diff changeset
118 \hhline{~-~~}
92
5c3fa8897e0e - manual work
cslag
parents: 90
diff changeset
119 parameter area & \vdots & & \\
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
120 \hhline{~-~~}
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
121 \end{tabular}
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
122 \caption{Stack layout on arm32}
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
123 \end{figure}
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
124
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
125
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
126 \newpage
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
127
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
128 \subsubsection{ATPCS THUMB mode}
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
129
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
130
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
131 \paragraph{Status}
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
132
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
133 \begin{itemize}
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
134 \item The ATPCS THUMB mode is untested.
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
135 \item Ellipse calls may not work.
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
136 \item C++ this calls do not work.
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
137 \end{itemize}
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
138
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
139 \paragraph{Registers and register usage}
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
140
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
141 In THUMB mode, the ARM32 processor family supports eight 32 bit general purpose registers r0-r7 and access to high order registers r8-r15:\\
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
142 \\
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
143 \begin{table}[h]
77
e441ef3ec782 - manual layout tweaks
cslag
parents: 76
diff changeset
144 \begin{tabular*}{0.95\textwidth}{3 B}
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
145 Name & Brief description\\
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
146 \hline
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
147 {\bf r0} & parameter 0, scratch, return value\\
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
148 {\bf r1} & parameter 1, scratch, return value\\
35
61edd9cf8026 - armhf doc update
cslag
parents: 34
diff changeset
149 {\bf r2,r3} & parameters 2 and 3, scratch\\
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
150 {\bf r4-r6} & permanent\\
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
151 {\bf r7} & frame pointer, permanent\\
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
152 {\bf r8-r11} & permanent\\
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
153 {\bf r12} & scratch\\
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
154 {\bf r13} & stack pointer, permanent\\
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
155 {\bf r14} & link register, permanent\\
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
156 {\bf r15} & program counter (note: due to pipeline, r15 points to 2 instructions ahead)\\
76
7ca46969e0ad - tweaks in manual, mainly for html generation
cslag
parents: 51
diff changeset
157 \end{tabular*}
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
158 \caption{Register usage on arm32 thumb mode}
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
159 \end{table}
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
160
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
161 \paragraph{Parameter passing}
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
162
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
163 \begin{itemize}
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
164 \item stack parameter order: right-to-left
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
165 \item caller cleans up the stack
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
166 \item first four words are passed using r0-r3
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
167 \item subsequent parameters are pushed onto the stack (in right to left order, such that the stack pointer points to the first of the remaining parameters)
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
168 \item if the callee takes the address of one of the parameters and uses it to address other parameters (e.g. varargs) it has to copy - in its prolog - the first four words to a reserved stack area adjacent to the other parameters on the stack
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
169 \item parameters \textless=\ 32 bits are passed as 32 bit words
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
170 \item 64 bit parameters are passed as two 32 bit parts (even partly via the register and partly via the stack), although this doesn't seem to be specified in the ATPCS), with the loword coming first
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
171 \item structures and unions are passed by value, with the first four words of the parameters in r0-r3
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
172 \item if return value is a structure, a pointer pointing to the return value's space is passed in r0, the first parameter in r1, etc. (see {\bf return values})
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
173 \item keeping the stack eight-byte aligned can improve memory access performance and is required by LDRD and STRD on ARMv5TE processors which are part of the ARM32 family, so, in order to avoid problems one should always align the stack (tests have shown, that GCC does care about the alignment when using the ellipsis)
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
174 \end{itemize}
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
175
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
176 \paragraph{Return values}
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
177 \begin{itemize}
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
178 \item return values \textless=\ 32 bits use r0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
179 \item 64 bit return values use r0 and r1
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
180 \item if return value is a structure, the caller allocates space for the return value on the stack in its frame and passes a pointer to it in r0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
181 \end{itemize}
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
182
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
183 \paragraph{Stack layout}
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
184
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
185 Stack directly after function prolog:\\
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
186
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
187 \begin{figure}[h]
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
188 \begin{tabular}{5|3|1 1}
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
189 \hhline{~-~~}
92
5c3fa8897e0e - manual work
cslag
parents: 90
diff changeset
190 & \vdots & & \\
117
4a64b733dc76 - doc, added first version of mips64 callconv page
cslag
parents: 95
diff changeset
191 \hhline{~=~~}
92
5c3fa8897e0e - manual work
cslag
parents: 90
diff changeset
192 register save area & \hspace{4cm} & & \mrrbrace{5}{caller's frame} \\
117
4a64b733dc76 - doc, added first version of mips64 callconv page
cslag
parents: 95
diff changeset
193 \hhline{~-~~}
92
5c3fa8897e0e - manual work
cslag
parents: 90
diff changeset
194 local data & & & \\
117
4a64b733dc76 - doc, added first version of mips64 callconv page
cslag
parents: 95
diff changeset
195 \hhline{~-~~}
92
5c3fa8897e0e - manual work
cslag
parents: 90
diff changeset
196 \mrlbrace{7}{parameter area} & \ldots & \mrrbrace{3}{stack parameters} & \\
5c3fa8897e0e - manual work
cslag
parents: 90
diff changeset
197 & \ldots & & \\
5c3fa8897e0e - manual work
cslag
parents: 90
diff changeset
198 & \ldots & & \\
117
4a64b733dc76 - doc, added first version of mips64 callconv page
cslag
parents: 95
diff changeset
199 \hhline{~=~~}
92
5c3fa8897e0e - manual work
cslag
parents: 90
diff changeset
200 & r3 & \mrrbrace{4}{spill area (if needed)} & \mrrbrace{7}{current frame} \\
5c3fa8897e0e - manual work
cslag
parents: 90
diff changeset
201 & r2 & & \\
5c3fa8897e0e - manual work
cslag
parents: 90
diff changeset
202 & r1 & & \\
5c3fa8897e0e - manual work
cslag
parents: 90
diff changeset
203 & r0 & & \\
117
4a64b733dc76 - doc, added first version of mips64 callconv page
cslag
parents: 95
diff changeset
204 \hhline{~-~~}
92
5c3fa8897e0e - manual work
cslag
parents: 90
diff changeset
205 register save area (with return address) & & & \\
117
4a64b733dc76 - doc, added first version of mips64 callconv page
cslag
parents: 95
diff changeset
206 \hhline{~-~~}
92
5c3fa8897e0e - manual work
cslag
parents: 90
diff changeset
207 local data & & & \\
117
4a64b733dc76 - doc, added first version of mips64 callconv page
cslag
parents: 95
diff changeset
208 \hhline{~-~~}
92
5c3fa8897e0e - manual work
cslag
parents: 90
diff changeset
209 parameter area & \vdots & & \\
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
210 \hhline{~-~~}
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
211 \end{tabular}
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
212 \caption{Stack layout on arm32 thumb mode}
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
213 \end{figure}
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
214
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
215
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
216
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
217 \newpage
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
218
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
219 \subsubsection{EABI (ARM and THUMB mode)}
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
220
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
221
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
222 The ARM EABI is very similar to the ABI outlined in ARM-THUMB procedure call
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
223 standard (ATPCS) \cite{ATPCS} - however, the EABI requires the stack to be
41
cslag
parents: 35
diff changeset
224 8-byte aligned at function entries, as well as for 64 bit parameters. The latter
cslag
parents: 35
diff changeset
225 are aligned on 8-byte boundaries on the stack and 2-registers for a parameter
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
226 passed via register. In order to achieve such an alignment, a register might
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
227 have to be skipped for parameters passed via registers, or 4-bytes on the stack
35
61edd9cf8026 - armhf doc update
cslag
parents: 34
diff changeset
228 for parameters passed via the stack. Refer to the Debian ARM EABI port wiki
173
8402121e1737 - doc tweaks
cslag
parents: 148
diff changeset
229 for more information \cite{armeabi}.\\
8402121e1737 - doc tweaks
cslag
parents: 148
diff changeset
230 \\
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
231 \paragraph{Status}
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
232
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
233 \begin{itemize}
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
234 \item The EABI THUMB mode is tested and works fine (contrary to the ATPCS).
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
235 \item Ellipse calls do not work.
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
236 \item C++ this calls do not work.
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
237 \end{itemize}
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
238
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
239 \newpage
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
240
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
241 \subsubsection{ARM on Apple's iOS (Darwin) Platform}
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
242
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
243
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
244 The iOS runs on ARMv6 (iOS 2.0) and ARMv7 (iOS 3.0) architectures.
173
8402121e1737 - doc tweaks
cslag
parents: 148
diff changeset
245 Typically code is compiled in Thumb mode.\\
8402121e1737 - doc tweaks
cslag
parents: 148
diff changeset
246 \\
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
247 \paragraph{Register usage}
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
248
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
249 \begin{table}[h]
77
e441ef3ec782 - manual layout tweaks
cslag
parents: 76
diff changeset
250 \begin{tabular*}{0.95\textwidth}{3 B}
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
251 Name & Brief description\\
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
252 \hline
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
253 {\bf R0} & parameter 0, scratch, return value\\
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
254 {\bf R1} & parameter 1, scratch, return value\\
35
61edd9cf8026 - armhf doc update
cslag
parents: 34
diff changeset
255 {\bf R2,R3} & parameters 2 and 3, scratch\\
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
256 {\bf R4-R6} & permanent\\
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
257 {\bf R7} & frame pointer, permanent\\
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
258 {\bf R8} & permanent\\
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
259 {\bf R9} & permanent(iOS 2.0) and scratch (since iOS 3.0)\\
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
260 {\bf R10-R11}& permanent\\
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
261 {\bf R12} & scratch, intra-procedure scratch register (IP) used by dynamic linker\\
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
262 {\bf R13} & stack pointer, permanent\\
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
263 {\bf R14} & link register, permanent\\
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
264 {\bf R15} & program counter (note: due to pipeline, r15 points to 2 instructions ahead)\\
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
265 {\bf CPSR} & Program status register\\
35
61edd9cf8026 - armhf doc update
cslag
parents: 34
diff changeset
266 {\bf D0-D7} & scratch. aliases S0-S15, on ARMv7 also as Q0-Q3. Not accessible from Thumb mode on ARMv6.\\
61edd9cf8026 - armhf doc update
cslag
parents: 34
diff changeset
267 {\bf D8-D15} & permanent, aliases S16-S31, on ARMv7 also as Q4-A7. Not accesible from Thumb mode on ARMv6.\\
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
268 {\bf D16-D31}& Only available in ARMv7, aliases Q8-Q15.\\
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
269 {\bf FPSCR} & VFP status register.\\
76
7ca46969e0ad - tweaks in manual, mainly for html generation
cslag
parents: 51
diff changeset
270 \end{tabular*}
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
271 \caption{Register usage on ARM Apple iOS}
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
272 \end{table}
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
273
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
274 The ABI is based on the AAPCS but with some important differences listed below:
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
275
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
276 \begin{itemize}
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
277 \item R7 instead of R11 is used as frame pointer
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
278 \item R9 is scratch since iOS 3.0, was preserved before.
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
279 \end{itemize}
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
280
34
645307d37731 - started section for armhf in doc
cslag
parents: 0
diff changeset
281
645307d37731 - started section for armhf in doc
cslag
parents: 0
diff changeset
282 \subsubsection{ARM hard float (armhf)}
645307d37731 - started section for armhf in doc
cslag
parents: 0
diff changeset
283
645307d37731 - started section for armhf in doc
cslag
parents: 0
diff changeset
284
35
61edd9cf8026 - armhf doc update
cslag
parents: 34
diff changeset
285 Most debian-based Linux systems on ARMv7 (or ARMv6 with FPU) platforms use a calling convention referred to
41
cslag
parents: 35
diff changeset
286 as armhf, using 16 32-bit floating point registers of the FPU of the VFPv3-D16 extension to the ARM architecture.
35
61edd9cf8026 - armhf doc update
cslag
parents: 34
diff changeset
287 The instruction set used for armhf is Thumb-2. Refer to the debian wiki for more information \cite{armhf}.
61edd9cf8026 - armhf doc update
cslag
parents: 34
diff changeset
288
173
8402121e1737 - doc tweaks
cslag
parents: 148
diff changeset
289 Code is little-endian, rest is similar to EABI with an 8-byte aligned stack, etc..\\
8402121e1737 - doc tweaks
cslag
parents: 148
diff changeset
290 \\
34
645307d37731 - started section for armhf in doc
cslag
parents: 0
diff changeset
291 \paragraph{Register usage}
645307d37731 - started section for armhf in doc
cslag
parents: 0
diff changeset
292
645307d37731 - started section for armhf in doc
cslag
parents: 0
diff changeset
293 \begin{table}[h]
77
e441ef3ec782 - manual layout tweaks
cslag
parents: 76
diff changeset
294 \begin{tabular*}{0.95\textwidth}{3 B}
34
645307d37731 - started section for armhf in doc
cslag
parents: 0
diff changeset
295 Name & Brief description\\
645307d37731 - started section for armhf in doc
cslag
parents: 0
diff changeset
296 \hline
42
ecc9403e214a - final touch for complete armhf callback support, yay
cslag
parents: 41
diff changeset
297 {\bf R0} & parameter 0, scratch, non floating point return value\\
ecc9403e214a - final touch for complete armhf callback support, yay
cslag
parents: 41
diff changeset
298 {\bf R1} & parameter 1, scratch, non floating point return value\\
35
61edd9cf8026 - armhf doc update
cslag
parents: 34
diff changeset
299 {\bf R2,R3} & parameters 2 and 3, scratch\\
61edd9cf8026 - armhf doc update
cslag
parents: 34
diff changeset
300 {\bf R4,R5} & permanent\\
61edd9cf8026 - armhf doc update
cslag
parents: 34
diff changeset
301 {\bf R6} & scratch\\
61edd9cf8026 - armhf doc update
cslag
parents: 34
diff changeset
302 {\bf R7} & frame pointer, permanent\\
61edd9cf8026 - armhf doc update
cslag
parents: 34
diff changeset
303 {\bf R8} & permanent\\
61edd9cf8026 - armhf doc update
cslag
parents: 34
diff changeset
304 {\bf R9,R10} & scratch\\
61edd9cf8026 - armhf doc update
cslag
parents: 34
diff changeset
305 {\bf R11} & permanent\\
61edd9cf8026 - armhf doc update
cslag
parents: 34
diff changeset
306 {\bf R12} & scratch, intra-procedure scratch register (IP) used by dynamic linker\\
61edd9cf8026 - armhf doc update
cslag
parents: 34
diff changeset
307 {\bf R13} & stack pointer, permanent\\
61edd9cf8026 - armhf doc update
cslag
parents: 34
diff changeset
308 {\bf R14} & link register, permanent\\
61edd9cf8026 - armhf doc update
cslag
parents: 34
diff changeset
309 {\bf R15} & program counter (note: due to pipeline, r15 points to 2 instructions ahead)\\
61edd9cf8026 - armhf doc update
cslag
parents: 34
diff changeset
310 {\bf CPSR} & Program status register\\
42
ecc9403e214a - final touch for complete armhf callback support, yay
cslag
parents: 41
diff changeset
311 {\bf S0} & floating point argument, floating point return value, single precision\\
ecc9403e214a - final touch for complete armhf callback support, yay
cslag
parents: 41
diff changeset
312 {\bf D0} & floating point argument, floating point return value, double precision, aliases S0-S1, \\
ecc9403e214a - final touch for complete armhf callback support, yay
cslag
parents: 41
diff changeset
313 {\bf S1-S15} & floating point arguments, single precision\\
ecc9403e214a - final touch for complete armhf callback support, yay
cslag
parents: 41
diff changeset
314 {\bf D1-D7} & aliases S2-S15, floating point arguments, double precision\\
35
61edd9cf8026 - armhf doc update
cslag
parents: 34
diff changeset
315 {\bf FPSCR} & VFP status register.\\
76
7ca46969e0ad - tweaks in manual, mainly for html generation
cslag
parents: 51
diff changeset
316 \end{tabular*}
34
645307d37731 - started section for armhf in doc
cslag
parents: 0
diff changeset
317 \caption{Register usage on armhf}
645307d37731 - started section for armhf in doc
cslag
parents: 0
diff changeset
318 \end{table}
645307d37731 - started section for armhf in doc
cslag
parents: 0
diff changeset
319
35
61edd9cf8026 - armhf doc update
cslag
parents: 34
diff changeset
320 \paragraph{Parameter passing}
61edd9cf8026 - armhf doc update
cslag
parents: 34
diff changeset
321
61edd9cf8026 - armhf doc update
cslag
parents: 34
diff changeset
322 \begin{itemize}
61edd9cf8026 - armhf doc update
cslag
parents: 34
diff changeset
323 \item stack parameter order: right-to-left
61edd9cf8026 - armhf doc update
cslag
parents: 34
diff changeset
324 \item caller cleans up the stack
61edd9cf8026 - armhf doc update
cslag
parents: 34
diff changeset
325 \item first four non-floating-point words are passed using r0-r3
51
9e9d6a90492a - armhf experimental vararg call support
cslag
parents: 50
diff changeset
326 \item out of those, 64bit parameters use 2 registers, either r0,r1 or r2,r3 (skipped registers are left unused)
41
cslag
parents: 35
diff changeset
327 \item first 16 single-precision, or 8 double-precision arguments are passed via s0-s15 or d0-d7, respectively (note that since s and d registers are aliased, already used ones are skipped)
35
61edd9cf8026 - armhf doc update
cslag
parents: 34
diff changeset
328 \item subsequent parameters are pushed onto the stack (in right to left order, such that the stack pointer points to the first of the remaining parameters)
47
c4de113dc1e9 - some armhf comments, doc clarification, cleanup
cslag
parents: 45
diff changeset
329 \item note that as soon one floating point parameter is passed via the stack, subsequent single precision floating point parameters are also pushed onto the stack even if there are still free S* registers
51
9e9d6a90492a - armhf experimental vararg call support
cslag
parents: 50
diff changeset
330 \item float and double vararg function parameters (no matter if in ellipsis part of function, or not) are passed like int or long long parameters, vfp registers aren't used
50
9bd3c5219505 - minor test code fix
cslag
parents: 47
diff changeset
331 \item if the callee takes the address of one of the parameters and uses it to address other parameters (e.g. varargs) it has to copy - in its prolog - the first four words (for first 4 integer arguments) to a reserved stack area adjacent to the other parameters on the stack
35
61edd9cf8026 - armhf doc update
cslag
parents: 34
diff changeset
332 \item parameters \textless=\ 32 bits are passed as 32 bit words
61edd9cf8026 - armhf doc update
cslag
parents: 34
diff changeset
333 \item structures and unions are passed by value, with the first four words of the parameters in r0-r3 @@@?check doc
61edd9cf8026 - armhf doc update
cslag
parents: 34
diff changeset
334 \item if return value is a structure, a pointer pointing to the return value's space is passed in r0, the first parameter in r1, etc. (see {\bf return values})
148
12729fd52ab7 - performance improvement and more correct handling of arm32 armhf calls, not copying bogus data just to reserve spill area space
cslag
parents: 117
diff changeset
335 \item callee spills, caller reserves spill area space, though
35
61edd9cf8026 - armhf doc update
cslag
parents: 34
diff changeset
336 \end{itemize}
61edd9cf8026 - armhf doc update
cslag
parents: 34
diff changeset
337
61edd9cf8026 - armhf doc update
cslag
parents: 34
diff changeset
338 \paragraph{Return values}
61edd9cf8026 - armhf doc update
cslag
parents: 34
diff changeset
339 \begin{itemize}
42
ecc9403e214a - final touch for complete armhf callback support, yay
cslag
parents: 41
diff changeset
340 \item non floating point return values \textless=\ 32 bits use r0
ecc9403e214a - final touch for complete armhf callback support, yay
cslag
parents: 41
diff changeset
341 \item non floating point 64-bit return values use r0 and r1
ecc9403e214a - final touch for complete armhf callback support, yay
cslag
parents: 41
diff changeset
342 \item single precision floating point return value uses s0
ecc9403e214a - final touch for complete armhf callback support, yay
cslag
parents: 41
diff changeset
343 \item double precision floating point return value uses d0
35
61edd9cf8026 - armhf doc update
cslag
parents: 34
diff changeset
344 \item if return value is a structure, the caller allocates space for the return value on the stack in its frame and passes a pointer to it in r0
61edd9cf8026 - armhf doc update
cslag
parents: 34
diff changeset
345 \end{itemize}
61edd9cf8026 - armhf doc update
cslag
parents: 34
diff changeset
346
148
12729fd52ab7 - performance improvement and more correct handling of arm32 armhf calls, not copying bogus data just to reserve spill area space
cslag
parents: 117
diff changeset
347 \paragraph{Stack layout}
35
61edd9cf8026 - armhf doc update
cslag
parents: 34
diff changeset
348
148
12729fd52ab7 - performance improvement and more correct handling of arm32 armhf calls, not copying bogus data just to reserve spill area space
cslag
parents: 117
diff changeset
349 Stack directly after function prolog:\\
12729fd52ab7 - performance improvement and more correct handling of arm32 armhf calls, not copying bogus data just to reserve spill area space
cslag
parents: 117
diff changeset
350
12729fd52ab7 - performance improvement and more correct handling of arm32 armhf calls, not copying bogus data just to reserve spill area space
cslag
parents: 117
diff changeset
351 \begin{figure}[h]
12729fd52ab7 - performance improvement and more correct handling of arm32 armhf calls, not copying bogus data just to reserve spill area space
cslag
parents: 117
diff changeset
352 \begin{tabular}{5|3|1 1}
12729fd52ab7 - performance improvement and more correct handling of arm32 armhf calls, not copying bogus data just to reserve spill area space
cslag
parents: 117
diff changeset
353 \hhline{~-~~}
12729fd52ab7 - performance improvement and more correct handling of arm32 armhf calls, not copying bogus data just to reserve spill area space
cslag
parents: 117
diff changeset
354 & \vdots & & \\
12729fd52ab7 - performance improvement and more correct handling of arm32 armhf calls, not copying bogus data just to reserve spill area space
cslag
parents: 117
diff changeset
355 \hhline{~=~~}
12729fd52ab7 - performance improvement and more correct handling of arm32 armhf calls, not copying bogus data just to reserve spill area space
cslag
parents: 117
diff changeset
356 register save area & \hspace{4cm} & & \mrrbrace{6}{caller's frame} \\
12729fd52ab7 - performance improvement and more correct handling of arm32 armhf calls, not copying bogus data just to reserve spill area space
cslag
parents: 117
diff changeset
357 \hhline{~-~~}
12729fd52ab7 - performance improvement and more correct handling of arm32 armhf calls, not copying bogus data just to reserve spill area space
cslag
parents: 117
diff changeset
358 local data & & & \\
12729fd52ab7 - performance improvement and more correct handling of arm32 armhf calls, not copying bogus data just to reserve spill area space
cslag
parents: 117
diff changeset
359 \hhline{~-~~}
277
703d102cb580 - doc fix in callconv appendix
Tassilo Philipp
parents: 173
diff changeset
360 \mrlbrace{4}{parameter area} & r0-r3 & \mrrbrace{1}{spill area (if needed)} & \\
148
12729fd52ab7 - performance improvement and more correct handling of arm32 armhf calls, not copying bogus data just to reserve spill area space
cslag
parents: 117
diff changeset
361 \hhline{~-~~}
12729fd52ab7 - performance improvement and more correct handling of arm32 armhf calls, not copying bogus data just to reserve spill area space
cslag
parents: 117
diff changeset
362 & \ldots & \mrrbrace{3}{stack parameters} & \\
12729fd52ab7 - performance improvement and more correct handling of arm32 armhf calls, not copying bogus data just to reserve spill area space
cslag
parents: 117
diff changeset
363 & \ldots & & \\
12729fd52ab7 - performance improvement and more correct handling of arm32 armhf calls, not copying bogus data just to reserve spill area space
cslag
parents: 117
diff changeset
364 & \ldots & & \\
12729fd52ab7 - performance improvement and more correct handling of arm32 armhf calls, not copying bogus data just to reserve spill area space
cslag
parents: 117
diff changeset
365 \hhline{~=~~}
12729fd52ab7 - performance improvement and more correct handling of arm32 armhf calls, not copying bogus data just to reserve spill area space
cslag
parents: 117
diff changeset
366 register save area (with return address) & & & \mrrbrace{3}{current frame} \\
12729fd52ab7 - performance improvement and more correct handling of arm32 armhf calls, not copying bogus data just to reserve spill area space
cslag
parents: 117
diff changeset
367 \hhline{~-~~}
12729fd52ab7 - performance improvement and more correct handling of arm32 armhf calls, not copying bogus data just to reserve spill area space
cslag
parents: 117
diff changeset
368 local data & & & \\
12729fd52ab7 - performance improvement and more correct handling of arm32 armhf calls, not copying bogus data just to reserve spill area space
cslag
parents: 117
diff changeset
369 \hhline{~-~~}
12729fd52ab7 - performance improvement and more correct handling of arm32 armhf calls, not copying bogus data just to reserve spill area space
cslag
parents: 117
diff changeset
370 parameter area & \vdots & & \\
12729fd52ab7 - performance improvement and more correct handling of arm32 armhf calls, not copying bogus data just to reserve spill area space
cslag
parents: 117
diff changeset
371 \hhline{~-~~}
12729fd52ab7 - performance improvement and more correct handling of arm32 armhf calls, not copying bogus data just to reserve spill area space
cslag
parents: 117
diff changeset
372 \end{tabular}
12729fd52ab7 - performance improvement and more correct handling of arm32 armhf calls, not copying bogus data just to reserve spill area space
cslag
parents: 117
diff changeset
373 \caption{Stack layout on arm32 armhf}
12729fd52ab7 - performance improvement and more correct handling of arm32 armhf calls, not copying bogus data just to reserve spill area space
cslag
parents: 117
diff changeset
374 \end{figure}
12729fd52ab7 - performance improvement and more correct handling of arm32 armhf calls, not copying bogus data just to reserve spill area space
cslag
parents: 117
diff changeset
375
12729fd52ab7 - performance improvement and more correct handling of arm32 armhf calls, not copying bogus data just to reserve spill area space
cslag
parents: 117
diff changeset
376
12729fd52ab7 - performance improvement and more correct handling of arm32 armhf calls, not copying bogus data just to reserve spill area space
cslag
parents: 117
diff changeset
377 \newpage
35
61edd9cf8026 - armhf doc update
cslag
parents: 34
diff changeset
378
34
645307d37731 - started section for armhf in doc
cslag
parents: 0
diff changeset
379
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
380 \subsubsection{Architectures}
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
381
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
382 The ARM architecture family contains several revisions with capabilities and
117
4a64b733dc76 - doc, added first version of mips64 callconv page
cslag
parents: 95
diff changeset
383 extensions (such as thumb-interworking, more vector registers, ...)
4a64b733dc76 - doc, added first version of mips64 callconv page
cslag
parents: 95
diff changeset
384 The following table sums up the most important properties of the various
34
645307d37731 - started section for armhf in doc
cslag
parents: 0
diff changeset
385 architecture standards, from a calling convention perspective.
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
386
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
387 % iPhone 3GS : ARM Cortex-A8
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
388 % Nintendo DS: ARM 7 and ARM 9
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
389 % ARM 7: ARMv4T
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
390 % ARM 9: ARMv4T, HTC Wizard
34
645307d37731 - started section for armhf in doc
cslag
parents: 0
diff changeset
391 % Cortex-*: ARMv7, Raspberry Pi 2, ...
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
392
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
393 \begin{table}[h]
77
e441ef3ec782 - manual layout tweaks
cslag
parents: 76
diff changeset
394 \begin{tabular*}{0.95\textwidth}{lll}
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
395 Arch & Platforms & Details \\
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
396 \hline
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
397 ARMv4 & & \\
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
398 ARMv4T & ARM 7, ARM 9, Neo FreeRunner (OpenMoko) & \\
34
645307d37731 - started section for armhf in doc
cslag
parents: 0
diff changeset
399 ARMv5 & ARM 9E & BLX instruction available \\
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
400 ARMv6 & & No vector registers available in thumb \\
117
4a64b733dc76 - doc, added first version of mips64 callconv page
cslag
parents: 95
diff changeset
401 ARMv7 & iPod touch, iPhone 3GS/4, Raspberry Pi 2 & VFP throughout available, armhf calling convention on some platforms \\
4a64b733dc76 - doc, added first version of mips64 callconv page
cslag
parents: 95
diff changeset
402 ARMv8 & iPhone 6 and higher & 64bit support \\
76
7ca46969e0ad - tweaks in manual, mainly for html generation
cslag
parents: 51
diff changeset
403 \end{tabular*}
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
404 \caption{Overview of ARM Architecture, Platforms and Details}
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
405 \end{table}
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
406
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
407 \newpage
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
408