Mercurial > pub > dyncall > dyncall
annotate doc/manual/callconvs/callconv_ppc32.tex @ 473:ead041d93e36
- ppc doc and disas examples related to aggregates
author | Tassilo Philipp |
---|---|
date | Wed, 16 Feb 2022 16:44:11 +0100 |
parents | b47168dacba6 |
children | 6c72cb768099 |
rev | line source |
---|---|
0 | 1 %////////////////////////////////////////////////////////////////////////////// |
2 % | |
328
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
241
diff
changeset
|
3 % Copyright (c) 2007-2019 Daniel Adler <dadler@uni-goettingen.de>, |
0 | 4 % Tassilo Philipp <tphilipp@potion-studios.com> |
5 % | |
6 % Permission to use, copy, modify, and distribute this software for any | |
7 % purpose with or without fee is hereby granted, provided that the above | |
8 % copyright notice and this permission notice appear in all copies. | |
9 % | |
10 % THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | |
11 % WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | |
12 % MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | |
13 % ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | |
14 % WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | |
15 % ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | |
16 % OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |
17 % | |
18 %////////////////////////////////////////////////////////////////////////////// | |
19 | |
20 % ================================================== | |
21 % PowerPC 32 | |
22 % ================================================== | |
328
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
241
diff
changeset
|
23 \subsection{PowerPC (32bit) Calling Conventions} |
0 | 24 |
25 \paragraph{Overview} | |
26 | |
27 \begin{itemize} | |
28 \item Word size is 32 bits | |
29 \item Big endian (MSB) and litte endian (LSB) operating modes. | |
30 \item Processor operates on floats in double precision floating point arithmetc (IEEE-754) values directly (single precision is converted on the fly) | |
331 | 31 \item Apple macos/Mac OS X/Darwin PPC is specified in "Mac OS X ABI Function Call Guide"\cite{ppcMacOSX}. It uses Big Endian (MSB) |
32 \item Linux PPC 32-bit ABI is specified in "LSB for PPC"\cite{ppc32LSB} which is based on "System V ABI". It uses Big Endian (MSB) | |
33 \item PowerPC EABI is defined in the "PowerPC Embedded Application Binary Interface 32-Bit Implementation"\cite{ppceabi} | |
34 \item There is also the "PowerOpen ABI"\cite{poabi}, a nearly identical version of it is used in AIX % more info: http://www.ingallegri.com/public/ppc.html | |
0 | 35 \end{itemize} |
36 | |
37 \paragraph{\product{dyncall} support} | |
38 | |
345
c607d67cd6b8
- doc: added syscall info to appendix, fixed broken literature link
Tassilo Philipp
parents:
331
diff
changeset
|
39 \product{Dyncall} and \product{dyncallback} are supported for PowerPC (32bit) |
c607d67cd6b8
- doc: added syscall info to appendix, fixed broken literature link
Tassilo Philipp
parents:
331
diff
changeset
|
40 Big Endian (MSB), for Darwin's and System V's calling convention.\\ |
c607d67cd6b8
- doc: added syscall info to appendix, fixed broken literature link
Tassilo Philipp
parents:
331
diff
changeset
|
41 \product{Dyncall} can also be used to issue syscalls by using the syscall |
c607d67cd6b8
- doc: added syscall info to appendix, fixed broken literature link
Tassilo Philipp
parents:
331
diff
changeset
|
42 number as target parameter and selecting the correct mode. |
0 | 43 |
44 | |
45 \subsubsection{Mac OS X/Darwin} | |
46 | |
47 \paragraph{Registers and register usage} | |
48 | |
49 \begin{table}[h] | |
77 | 50 \begin{tabular*}{0.95\textwidth}{3 B} |
0 | 51 Name & Brief description\\ |
52 \hline | |
53 {\bf gpr0} & scratch\\ | |
54 {\bf gpr1} & stack pointer\\ | |
55 {\bf gpr2} & scratch\\ | |
328
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
241
diff
changeset
|
56 {\bf gpr3,gpr4} & return value, parameter 0 and 1 for integer or pointer, scratch\\ |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
241
diff
changeset
|
57 {\bf gpr5-gpr10} & parameter 2-7 for integer or pointer parameters, scratch\\ |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
241
diff
changeset
|
58 {\bf gpr11} & preserve\\ |
0 | 59 {\bf gpr12} & branch target for dynamic code generation\\ |
328
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
241
diff
changeset
|
60 {\bf gpr13-31} & preserve\\ |
0 | 61 {\bf fpr0} & scratch\\ |
238 | 62 {\bf fpr1} & floating point return value, floating point parameter 0 (always double precision)\\ |
63 {\bf fpr2-fpr13} & floating point parameters 1-12 (always double precision)\\ | |
328
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
241
diff
changeset
|
64 {\bf fpr14-fpr31} & preserve\\ |
0 | 65 {\bf v0-v1} & scratch\\ |
66 {\bf v2-v13} & vector parameters\\ | |
67 {\bf v14-v19} & scratch\\ | |
328
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
241
diff
changeset
|
68 {\bf v20-v31} & preserve\\ |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
241
diff
changeset
|
69 {\bf lr} & link-register, scratch\\ |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
241
diff
changeset
|
70 {\bf ctr} & count-register, scratch\\ |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
241
diff
changeset
|
71 {\bf cr0-cr7} & conditional register fields, each 4-bit wide (cr0-cr1 and cr5-cr7 are scratch)\\ |
76 | 72 \end{tabular*} |
0 | 73 \caption{Register usage on Darwin PowerPC 32-Bit} |
74 \end{table} | |
75 | |
76 \paragraph{Parameter passing} | |
77 | |
78 \begin{itemize} | |
328
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
241
diff
changeset
|
79 \item stack grows down |
238 | 80 \item stack parameter order: right-to-left |
81 \item caller cleans up the stack | |
0 | 82 \item the first 8 integer parameters are passed in registers gpr3-gpr10 |
331 | 83 \item the first 13 floating point parameters are passed in registers fpr1-fpr13 |
328
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
241
diff
changeset
|
84 \item 64 bit arguments are passed as if they were two 32 bit arguments, without skipping registers for alignment (this means passing half via a register and half via the stack is allowed) |
0 | 85 \item if a float parameter is passed via a register, gpr registers are skipped for subsequent integer parameters (based on the size of |
86 the float - 1 register for single precision and 2 for double precision floating point values) | |
87 \item the caller pushes subsequent parameters onto the stack | |
88 \item for every parameter passed via a register, space is reserved in the stack parameter area (in order to spill the parameters if | |
89 needed - e.g. varargs) | |
331 | 90 \item ellipsis calls take floating point values in int and float registers (single precision floats are promoted to double precision as |
91 required by ellipsis calls) | |
0 | 92 \item all nonvector parameters are aligned on 4-byte boundaries |
93 \item vector parameters are aligned on 16-byte boundaries | |
94 \item composite parameters with size of 1 or 2 bytes occupy low-order bytes of their 4-byte area. INCONSISTENT with other 32-bit PPC | |
331 | 95 binary interfaces. In AIX and mac OS 9, padding bytes always follow the data structure |
0 | 96 \item composite parameters 3 bytes or larger in size occupy high-order bytes |
125 | 97 \item integer parameters \textless\ 32 bit are right-justified (meaning occupy higher-address bytes) in their 4-byte slot on the stack, requiring extra-care for big-endian targets |
473
ead041d93e36
- ppc doc and disas examples related to aggregates
Tassilo Philipp
parents:
467
diff
changeset
|
98 \item aggregates (struct, union) with only one (non-aggregate / non-array) field are passed as if the field itself would be passed |
ead041d93e36
- ppc doc and disas examples related to aggregates
Tassilo Philipp
parents:
467
diff
changeset
|
99 \item all other aggregates are passed as a sequence of words (like integer parameters) |
0 | 100 \end{itemize} |
101 | |
102 | |
103 \paragraph{Return values} | |
104 | |
105 \begin{itemize} | |
106 \item return values of integer \textless=\ 32bit or pointer type use gpr3 | |
107 \item 64 bit integers use gpr3 and gpr4 (hiword in gpr3, loword in gpr4) | |
108 \item floating point values are returned via fpr1 | |
473
ead041d93e36
- ppc doc and disas examples related to aggregates
Tassilo Philipp
parents:
467
diff
changeset
|
109 \item aggregates (struct, union) \textless=\ 64 bits use gpr3 and gpr4 |
ead041d93e36
- ppc doc and disas examples related to aggregates
Tassilo Philipp
parents:
467
diff
changeset
|
110 \item for all other aggregates and types \textgreater\ 64 bits, a secret first parameter with an address to a caller allocated space is passed to the function (in gpr3), which is written to by the callee |
0 | 111 \end{itemize} |
112 | |
113 | |
114 \paragraph{Stack layout} | |
115 | |
328
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
241
diff
changeset
|
116 % verified/amended: TP nov 2019 (see also doc/disas_examples/ppc.darwin.disas) |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
241
diff
changeset
|
117 Stack frame is always 16-byte aligned. Prolog opens frame with additional, fixed space for a linkage area, to hold a number of values (not all of them are required to be saved, though). Stack directly after function prolog:\\ |
0 | 118 |
119 \begin{figure}[h] | |
120 \begin{tabular}{5|3|1 1} | |
328
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
241
diff
changeset
|
121 & \vdots & & \\ |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
241
diff
changeset
|
122 \hhline{~=~~} |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
241
diff
changeset
|
123 register save area & \hspace{4cm} & & \mrrbrace{14}{caller's frame} \\ |
0 | 124 \hhline{~-~~} |
328
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
241
diff
changeset
|
125 local data & & & \\ |
0 | 126 \hhline{~-~~} |
328
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
241
diff
changeset
|
127 \mrlbrace{6}{parameter area} & last arg & \mrrbrace{3}{stack parameters} & \\ |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
241
diff
changeset
|
128 & \ldots & & \\ |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
241
diff
changeset
|
129 & 9th word of arg data & & \\ |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
241
diff
changeset
|
130 & gpr10 & \mrrbrace{3}{spill area (as needed)} & \\ |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
241
diff
changeset
|
131 & \ldots & & \\ |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
241
diff
changeset
|
132 & gpr3 & & \\ |
0 | 133 \hhline{~-~~} |
328
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
241
diff
changeset
|
134 \mrlbrace{6}{linkage area} & reserved & & \\ |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
241
diff
changeset
|
135 & reserved & & \\ |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
241
diff
changeset
|
136 & reserved & & \\ |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
241
diff
changeset
|
137 & return address (callee saved) & & \\ |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
241
diff
changeset
|
138 & condition reg (callee saved) & & \\ |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
241
diff
changeset
|
139 & parent stack frame pointer & & \\ |
0 | 140 \hhline{~=~~} |
328
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
241
diff
changeset
|
141 register save area & & & \mrrbrace{4}{current frame} \\ |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
241
diff
changeset
|
142 \hhline{~-~~} |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
241
diff
changeset
|
143 local data & & & \\ |
0 | 144 \hhline{~-~~} |
328
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
241
diff
changeset
|
145 parameter area & & & \\ |
0 | 146 \hhline{~-~~} |
328
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
241
diff
changeset
|
147 linkage area & \vdots & & \\ |
0 | 148 \end{tabular} |
149 \caption{Stack layout on ppc32 Darwin} | |
150 \end{figure} | |
151 | |
328
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
241
diff
changeset
|
152 |
467 | 153 \clearpage |
328
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
241
diff
changeset
|
154 |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
241
diff
changeset
|
155 |
0 | 156 \subsubsection{System V PPC 32-bit} |
157 | |
158 \paragraph{Status} | |
159 | |
160 \paragraph{Registers and register usage} | |
161 | |
162 \begin{table}[h] | |
77 | 163 \begin{tabular*}{0.95\textwidth}{3 B} |
76 | 164 Name & Brief description\\ |
0 | 165 \hline |
166 {\bf r0} & scratch\\ | |
328
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
241
diff
changeset
|
167 {\bf r1} & stack pointer, preserve\\ |
0 | 168 {\bf r2} & system-reserved\\ |
328
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
241
diff
changeset
|
169 {\bf r3-r4} & parameter passing and return value, scratch\\ |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
241
diff
changeset
|
170 {\bf r5-r10} & parameter passing, scratch\\ |
0 | 171 {\bf r11-r12} & scratch\\ |
328
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
241
diff
changeset
|
172 {\bf r13} & small data area pointer register\\ |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
241
diff
changeset
|
173 {\bf r14-r30} & local variables, preserve\\ |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
241
diff
changeset
|
174 {\bf r31} & used for local variables or \emph{environment pointer}, preserve\\ |
0 | 175 {\bf f0} & scratch\\ |
328
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
241
diff
changeset
|
176 {\bf f1} & parameter passing and return value, scratch\\ |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
241
diff
changeset
|
177 {\bf f2-f8} & parameter passing, scratch\\ |
0 | 178 {\bf f9-13} & scratch\\ |
328
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
241
diff
changeset
|
179 {\bf f14-f31} & local variables, preserve\\ |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
241
diff
changeset
|
180 {\bf cr0-cr7} & conditional register fields, each 4-bit wide (cr0-cr1 and cr5-cr7 are scratch)\\ |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
241
diff
changeset
|
181 {\bf lr} & link register, scratch\\ |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
241
diff
changeset
|
182 {\bf ctr} & count register, scratch \\ |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
241
diff
changeset
|
183 {\bf xer} & fixed-point exception register, scratch\\ |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
241
diff
changeset
|
184 {\bf fpscr} & floating-point Status and Control Register\\ |
0 | 185 % {\bf v0-v1} & scratch\\ |
186 % {\bf v2-v13} & vector parameters\\ | |
187 % {\bf v14-v19} & scratch\\ | |
188 % {\bf v20-v31} & permanent\\ | |
189 % {\bf lr} & scratch, link-register\\ | |
190 % {\bf ctr} & scratch, count-register\\ | |
191 % {\bf cr0-cr1} & scratch\\ | |
192 % {\bf cr2-cr4} & permanent\\ | |
193 % {\bf cr5-cr7} & scratch\\ | |
76 | 194 \end{tabular*} |
0 | 195 \caption{Register usage on System V ABI PowerPC Processor} |
196 \end{table} | |
197 | |
198 \paragraph{Parameter passing} | |
199 | |
200 \begin{itemize} | |
473
ead041d93e36
- ppc doc and disas examples related to aggregates
Tassilo Philipp
parents:
467
diff
changeset
|
201 \item Stack pointer (r1) is always 16-byte aligned. The EABI differs here - it is 8-byte alignment |
ead041d93e36
- ppc doc and disas examples related to aggregates
Tassilo Philipp
parents:
467
diff
changeset
|
202 \item 8 general-purpose registers (r3-r10) for integer and pointer types |
ead041d93e36
- ppc doc and disas examples related to aggregates
Tassilo Philipp
parents:
467
diff
changeset
|
203 \item 8 floating-pointer registers (f1-f8) for float (promoted to double) and double types |
ead041d93e36
- ppc doc and disas examples related to aggregates
Tassilo Philipp
parents:
467
diff
changeset
|
204 \item Additional arguments are passed on the stack directly after the back-chain and saved return address (8 bytes structure) on the callers stack frame |
0 | 205 \item 64-bit integer data types are passed in general-purpose registers as a whole in two |
328
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
241
diff
changeset
|
206 32-bit general purpose registers (an odd and an even e.g. r3 and r4), skipping an even integer register |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
241
diff
changeset
|
207 or passed on the stack; they are never splitted into a register and stack part |
361 | 208 \item Ellipsis calls set CR bit 6 |
123 | 209 \item integer parameters \textless\ 32 bit are right-justified (meaning occupy high-order bytes) in their 4-byte area, requiring extra-care for big-endian targets |
328
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
241
diff
changeset
|
210 \item no spill area is used on stack, iterating over varargs requires a specific va\_list implementation |
473
ead041d93e36
- ppc doc and disas examples related to aggregates
Tassilo Philipp
parents:
467
diff
changeset
|
211 \item aggregates (struct, union) and types \textgreater\ 64 bits are passed indirectly, as a pointer to the data (or a copy of it, if necessary to avoid modification) |
0 | 212 \end{itemize} |
213 | |
214 \paragraph{Return values} | |
215 | |
216 \begin{itemize} | |
473
ead041d93e36
- ppc doc and disas examples related to aggregates
Tassilo Philipp
parents:
467
diff
changeset
|
217 \item 32-bit integers use register r3, 64-bit use registers r3 and r4 (hiword in r3, loword in r4) |
ead041d93e36
- ppc doc and disas examples related to aggregates
Tassilo Philipp
parents:
467
diff
changeset
|
218 \item floating-point values are returned using register f1 |
ead041d93e36
- ppc doc and disas examples related to aggregates
Tassilo Philipp
parents:
467
diff
changeset
|
219 \item aggregates (struct, union) \textless=\ 64 bits use gpr3 and gpr4 |
ead041d93e36
- ppc doc and disas examples related to aggregates
Tassilo Philipp
parents:
467
diff
changeset
|
220 \item for all other aggregates and types \textgreater\ 64 bits, a secret first parameter with an address to a caller allocated space is passed to the function (in gpr3), which is written to by the callee |
0 | 221 \end{itemize} |
222 | |
223 | |
224 \paragraph{Stack layout} | |
225 | |
328
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
241
diff
changeset
|
226 % verified/amended: TP nov 2019 (see also doc/disas_examples/ppc.sysv.disas) |
0 | 227 Stack frame is always 16-byte aligned. Stack directly after function prolog:\\ |
228 | |
229 \begin{figure}[h] | |
230 \begin{tabular}{5|3|1 1} | |
328
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
241
diff
changeset
|
231 & \vdots & & \\ |
0 | 232 \hhline{~=~~} |
328
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
241
diff
changeset
|
233 register save area & \hspace{4cm} & & \mrrbrace{7}{caller's frame} \\ |
0 | 234 \hhline{~-~~} |
328
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
241
diff
changeset
|
235 local data & & & \\ |
0 | 236 \hhline{~-~~} |
328
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
241
diff
changeset
|
237 \mrlbrace{3}{parameter area} & last arg & \mrrbrace{3}{stack parameters} & \\ |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
241
diff
changeset
|
238 & \ldots & & \\ |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
241
diff
changeset
|
239 & first arg passed via stack & & \\ |
0 | 240 \hhline{~-~~} |
328
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
241
diff
changeset
|
241 & return address (callee saved) & & \\ |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
241
diff
changeset
|
242 \hhline{~-~~} |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
241
diff
changeset
|
243 & parent stack frame pointer & & \\ |
0 | 244 \hhline{~=~~} |
328
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
241
diff
changeset
|
245 register save area & & & \mrrbrace{4}{current frame} \\ |
0 | 246 \hhline{~-~~} |
328
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
241
diff
changeset
|
247 local data & & & \\ |
0 | 248 \hhline{~-~~} |
328
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
241
diff
changeset
|
249 parameter area & & & \\ |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
241
diff
changeset
|
250 \hhline{~-~~} |
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
241
diff
changeset
|
251 & \vdots & & \\ |
0 | 252 \end{tabular} |
253 \caption{Stack layout on System V ABI for PowerPC 32-bit calling convention} | |
254 \end{figure} | |
328
276eb8c87aa0
- review and fixes, cleanup, amendments to calling convention appendix of manual
Tassilo Philipp
parents:
241
diff
changeset
|
255 |
345
c607d67cd6b8
- doc: added syscall info to appendix, fixed broken literature link
Tassilo Philipp
parents:
331
diff
changeset
|
256 |
467 | 257 \clearpage |
345
c607d67cd6b8
- doc: added syscall info to appendix, fixed broken literature link
Tassilo Philipp
parents:
331
diff
changeset
|
258 |
c607d67cd6b8
- doc: added syscall info to appendix, fixed broken literature link
Tassilo Philipp
parents:
331
diff
changeset
|
259 \subsubsection{System V syscalls} |
c607d67cd6b8
- doc: added syscall info to appendix, fixed broken literature link
Tassilo Philipp
parents:
331
diff
changeset
|
260 |
c607d67cd6b8
- doc: added syscall info to appendix, fixed broken literature link
Tassilo Philipp
parents:
331
diff
changeset
|
261 \paragraph{Parameter passing} |
c607d67cd6b8
- doc: added syscall info to appendix, fixed broken literature link
Tassilo Philipp
parents:
331
diff
changeset
|
262 |
c607d67cd6b8
- doc: added syscall info to appendix, fixed broken literature link
Tassilo Philipp
parents:
331
diff
changeset
|
263 \begin{itemize} |
c607d67cd6b8
- doc: added syscall info to appendix, fixed broken literature link
Tassilo Philipp
parents:
331
diff
changeset
|
264 \item syscall is issued via the {\em sc} instruction |
c607d67cd6b8
- doc: added syscall info to appendix, fixed broken literature link
Tassilo Philipp
parents:
331
diff
changeset
|
265 \item kernel destroys registers r13 |
c607d67cd6b8
- doc: added syscall info to appendix, fixed broken literature link
Tassilo Philipp
parents:
331
diff
changeset
|
266 \item syscall number is set in r0 |
c607d67cd6b8
- doc: added syscall info to appendix, fixed broken literature link
Tassilo Philipp
parents:
331
diff
changeset
|
267 \item params are passed in registers r3 through r10 |
c607d67cd6b8
- doc: added syscall info to appendix, fixed broken literature link
Tassilo Philipp
parents:
331
diff
changeset
|
268 \item no stack in use, meaning syscalls are in theory limited to eight arguments |
c607d67cd6b8
- doc: added syscall info to appendix, fixed broken literature link
Tassilo Philipp
parents:
331
diff
changeset
|
269 \item register r3 holds the return value, overflow flag in conditional register cr0 signals errors in syscall |
c607d67cd6b8
- doc: added syscall info to appendix, fixed broken literature link
Tassilo Philipp
parents:
331
diff
changeset
|
270 \end{itemize} |
c607d67cd6b8
- doc: added syscall info to appendix, fixed broken literature link
Tassilo Philipp
parents:
331
diff
changeset
|
271 |