comparison doc/disas_examples/sparc64.sparc64.disas @ 327:c0390dc85a07

- doc: added disassembly examples for many platforms and calling conventions, for reference
author Tassilo Philipp
date Fri, 22 Nov 2019 23:08:59 +0100
parents
children 74c056b597b7
comparison
equal deleted inserted replaced
326:09aaa2e774cd 327:c0390dc85a07
1 ; #include <stdlib.h>
2 ;
3 ; void leaf_call(int b, int c, int d, int e, int f, int g, int h)
4 ; {
5 ; }
6 ;
7 ; void nonleaf_call(int a, int b, int c, int d, int e, int f, int g, int h)
8 ; {
9 ; /* use some local data */
10 ; *(char*)alloca(220) = 'L';
11 ; leaf_call(b, c, d, e, f, g, h);
12 ; }
13 ;
14 ; int main()
15 ; {
16 ; nonleaf_call(0, 1, 2, 3, 4, 5, 6, 7);
17 ; return 0;
18 ; }
19
20
21
22 ; output from debian-9.0-sparc64 w/ gcc 6.1.1
23
24 0000000000000000 <leaf_call>:
25 0: 9d e3 bf 50 save %sp, -176, %sp
26 4: 8a 10 00 19 mov %i1, %g5
27 8: 88 10 00 1a mov %i2, %g4
28 c: 86 10 00 1b mov %i3, %g3
29 10: 84 10 00 1c mov %i4, %g2
30 14: 82 10 00 1d mov %i5, %g1
31 18: f0 27 a8 7f st %i0, [ %fp + 0x87f ]
32 1c: ca 27 a8 87 st %g5, [ %fp + 0x887 ]
33 20: c8 27 a8 8f st %g4, [ %fp + 0x88f ]
34 24: c6 27 a8 97 st %g3, [ %fp + 0x897 ]
35 28: c4 27 a8 9f st %g2, [ %fp + 0x89f ]
36 2c: c2 27 a8 a7 st %g1, [ %fp + 0x8a7 ]
37 30: 01 00 00 00 nop
38 34: 81 cf e0 08 rett %i7 + 8
39 38: 01 00 00 00 nop
40
41 000000000000003c <nonleaf_call>:
42 3c: 9d e3 bf 40 save %sp, -192, %sp ; prolog
43 40: 8a 10 00 19 mov %i1, %g5 ; |
44 44: 88 10 00 1a mov %i2, %g4 ; |
45 48: 86 10 00 1b mov %i3, %g3 ; |
46 4c: 84 10 00 1c mov %i4, %g2 ; |
47 50: 82 10 00 1d mov %i5, %g1 ; |
48 54: f0 27 a8 7f st %i0, [ %fp + 0x87f ] ; | write input to prev frame's spill area (e.g. offset = 128 for i0, jumping over i*/l* save area)
49 58: ca 27 a8 87 st %g5, [ %fp + 0x887 ] ; | (pointlessly using an extra reg copy to g* for most)
50 5c: c8 27 a8 8f st %g4, [ %fp + 0x88f ] ; |
51 60: c6 27 a8 97 st %g3, [ %fp + 0x897 ] ; |
52 64: c4 27 a8 9f st %g2, [ %fp + 0x89f ] ; |
53 68: c2 27 a8 a7 st %g1, [ %fp + 0x8a7 ] ; |
54 6c: 9c 03 bf 10 add %sp, -240, %sp ; alloca(220) - with padding, and ...
55 70: 82 03 a8 bf add %sp, 0x8bf, %g1 ; ... at least 192b at top of stack
56 74: 82 00 60 0f add %g1, 0xf, %g1 ; |
57 78: 83 30 70 04 srlx %g1, 4, %g1 ; |
58 7c: 83 28 70 04 sllx %g1, 4, %g1 ; | 16b alignment of alloca()'d space pointed to by g2
59 80: 84 10 00 01 mov %g1, %g2 ; |
60 84: 82 10 20 4c mov 0x4c, %g1 ; 'L' -> g1, and ...
61 88: c2 28 80 00 stb %g1, [ %g2 ] ; ... store in aligned alloca()'d space
62 8c: c2 07 a8 b3 ld [ %fp + 0x8b3 ], %g1 ; arg 5 (fetched from prev frame's stack param area), ...
63 90: b9 38 60 00 sra %g1, 0, %i4 ; ... -> i4
64 94: c2 07 a8 a7 ld [ %fp + 0x8a7 ], %g1 ; arg 4 (fetched from prev frame's spill area), ...
65 98: bb 38 60 00 sra %g1, 0, %i5 ; ... -> i5
66 9c: c2 07 a8 9f ld [ %fp + 0x89f ], %g1 ; arg 3 (fetched from prev frame's spill area), ...
67 a0: 8b 38 60 00 sra %g1, 0, %g5 ; ... -> g5
68 a4: c2 07 a8 97 ld [ %fp + 0x897 ], %g1 ; arg 2 (fetched from prev frame's spill area), ...
69 a8: 89 38 60 00 sra %g1, 0, %g4 ; ... -> g4
70 ac: c2 07 a8 8f ld [ %fp + 0x88f ], %g1 ; arg 1 (fetched from prev frame's spill area), ...
71 b0: 87 38 60 00 sra %g1, 0, %g3 ; ... -> g3
72 b4: c2 07 a8 87 ld [ %fp + 0x887 ], %g1 ; arg 0 (fetched from prev frame's spill area), ...
73 b8: 85 38 60 00 sra %g1, 0, %g2 ; ... -> g2
74 bc: c2 07 a8 bb ld [ %fp + 0x8bb ], %g1 ; arg 6 (fetched from prev frame's stack param area), ...
75 c0: 83 38 60 00 sra %g1, 0, %g1 ; ... -> g1, and ...
76 c4: c2 73 a8 af stx %g1, [ %sp + 0x8af ] ; ... "pushed" onto stack
77 c8: 9a 10 00 1c mov %i4, %o5 ; |
78 cc: 98 10 00 1d mov %i5, %o4 ; |
79 d0: 96 10 00 05 mov %g5, %o3 ; |
80 d4: 94 10 00 04 mov %g4, %o2 ; | arg 0,1,2,3,4 (fetched from prev frame's spill area)
81 d8: 92 10 00 03 mov %g3, %o1 ; |
82 dc: 90 10 00 02 mov %g2, %o0 ; |
83 e0: 40 00 00 00 call e0 <nonleaf_call+0xa4> ; call leaf_call (objdump not from final link but .o)
84 e4: 01 00 00 00 nop ; branch delay slot
85 e8: 01 00 00 00 nop ;
86 ec: 81 cf e0 08 rett %i7 + 8 ; | epilog
87 f0: 01 00 00 00 nop ; | branch delay slot
88
89 00000000000000f4 <main>:
90 f4: 9d e3 bf 40 save %sp, -192, %sp ; prolog
91 f8: 82 10 20 07 mov 7, %g1 ; arg 7, ...
92 fc: c2 73 a8 b7 stx %g1, [ %sp + 0x8b7 ] ; ... "pushed" onto stack
93 100: 82 10 20 06 mov 6, %g1 ; arg 6, ...
94 104: c2 73 a8 af stx %g1, [ %sp + 0x8af ] ; ... "pushed" onto stack
95 108: 9a 10 20 05 mov 5, %o5 ; arg 5
96 10c: 98 10 20 04 mov 4, %o4 ; arg 4
97 110: 96 10 20 03 mov 3, %o3 ; arg 3
98 114: 94 10 20 02 mov 2, %o2 ; arg 2
99 118: 92 10 20 01 mov 1, %o1 ; arg 1
100 11c: 90 10 20 00 clr %o0 ; arg 0
101 120: 40 00 00 00 call 120 <main+0x2c> ; call nonleaf_call (objdump not from final link but .o)
102 124: 01 00 00 00 nop ; branch delay slot
103 128: 82 10 20 00 clr %g1 ! 0 <leaf_call> ; |
104 12c: 83 38 60 00 sra %g1, 0, %g1 ; | return value
105 130: b0 10 00 01 mov %g1, %i0 ; /
106 134: 81 cf e0 08 rett %i7 + 8 ; \ epilog
107 138: 01 00 00 00 nop ; | branch delay slot
108
109
110
111 ; output from freebsd-11.0-sparc64 w/ gcc 4.2.1
112
113 0000000000000000 <leaf_call>:
114 0: 9d e3 bf 40 save %sp, -192, %sp
115 4: 82 10 00 18 mov %i0, %g1
116 8: 84 10 00 19 mov %i1, %g2
117 c: 86 10 00 1a mov %i2, %g3
118 10: 88 10 00 1b mov %i3, %g4
119 14: 8a 10 00 1c mov %i4, %g5
120 18: c2 27 a8 7f st %g1, [ %fp + 0x87f ]
121 1c: c4 27 a8 87 st %g2, [ %fp + 0x887 ]
122 20: c6 27 a8 8f st %g3, [ %fp + 0x88f ]
123 24: c8 27 a8 97 st %g4, [ %fp + 0x897 ]
124 28: ca 27 a8 9f st %g5, [ %fp + 0x89f ]
125 2c: fa 27 a8 a7 st %i5, [ %fp + 0x8a7 ]
126 30: 81 cf e0 08 rett %i7 + 8
127 34: 01 00 00 00 nop
128 38: 01 00 00 00 nop
129 3c: 01 00 00 00 nop
130
131 0000000000000040 <nonleaf_call>:
132 40: 9d e3 bf 20 save %sp, -224, %sp
133 44: 82 10 00 18 mov %i0, %g1
134 48: 84 10 00 19 mov %i1, %g2
135 4c: 86 10 00 1a mov %i2, %g3
136 50: 88 10 00 1b mov %i3, %g4
137 54: 8a 10 00 1c mov %i4, %g5
138 58: 9a 10 00 1d mov %i5, %o5
139 5c: c2 27 a8 7f st %g1, [ %fp + 0x87f ]
140 60: c4 27 a8 87 st %g2, [ %fp + 0x887 ]
141 64: c6 27 a8 8f st %g3, [ %fp + 0x88f ]
142 68: c8 27 a8 97 st %g4, [ %fp + 0x897 ]
143 6c: ca 27 a8 9f st %g5, [ %fp + 0x89f ]
144 70: da 27 a8 a7 st %o5, [ %fp + 0x8a7 ]
145 74: 9c 03 bf 20 add %sp, -224, %sp
146 78: 82 03 a8 bf add %sp, 0x8bf, %g1
147 7c: c2 77 a7 e7 stx %g1, [ %fp + 0x7e7 ]
148 80: c4 5f a7 e7 ldx [ %fp + 0x7e7 ], %g2
149 84: 82 00 a0 0f add %g2, 0xf, %g1
150 88: 83 30 70 04 srlx %g1, 4, %g1
151 8c: 83 28 70 04 sllx %g1, 4, %g1
152 90: c2 77 a7 e7 stx %g1, [ %fp + 0x7e7 ]
153 94: c4 5f a7 e7 ldx [ %fp + 0x7e7 ], %g2
154 98: 82 10 20 4c mov 0x4c, %g1
155 9c: c2 28 80 00 stb %g1, [ %g2 ]
156 a0: c2 07 a8 87 ld [ %fp + 0x887 ], %g1
157 a4: 89 38 60 00 sra %g1, 0, %g4
158 a8: c2 07 a8 8f ld [ %fp + 0x88f ], %g1
159 ac: 8b 38 60 00 sra %g1, 0, %g5
160 b0: c2 07 a8 97 ld [ %fp + 0x897 ], %g1
161 b4: 9b 38 60 00 sra %g1, 0, %o5
162 b8: c2 07 a8 9f ld [ %fp + 0x89f ], %g1
163 bc: 99 38 60 00 sra %g1, 0, %o4
164 c0: c2 07 a8 a7 ld [ %fp + 0x8a7 ], %g1
165 c4: 85 38 60 00 sra %g1, 0, %g2
166 c8: c2 07 a8 b3 ld [ %fp + 0x8b3 ], %g1
167 cc: 87 38 60 00 sra %g1, 0, %g3
168 d0: c2 07 a8 bb ld [ %fp + 0x8bb ], %g1
169 d4: 83 38 60 00 sra %g1, 0, %g1
170 d8: c2 73 a8 af stx %g1, [ %sp + 0x8af ]
171 dc: 90 10 00 04 mov %g4, %o0
172 e0: 92 10 00 05 mov %g5, %o1
173 e4: 94 10 00 0d mov %o5, %o2
174 e8: 96 10 00 0c mov %o4, %o3
175 ec: 98 10 00 02 mov %g2, %o4
176 f0: 9a 10 00 03 mov %g3, %o5
177 f4: 40 00 00 00 call f4 <nonleaf_call+0xb4>
178 f8: 01 00 00 00 nop
179 fc: 81 cf e0 08 rett %i7 + 8
180 100: 01 00 00 00 nop
181 104: 30 68 00 07 b,a %xcc, 120 <main>
182 108: 01 00 00 00 nop
183 10c: 01 00 00 00 nop
184 110: 01 00 00 00 nop
185 114: 01 00 00 00 nop
186 118: 01 00 00 00 nop
187 11c: 01 00 00 00 nop
188
189 0000000000000120 <main>:
190 120: 9d e3 bf 30 save %sp, -208, %sp
191 124: 82 10 20 06 mov 6, %g1
192 128: c2 73 a8 af stx %g1, [ %sp + 0x8af ]
193 12c: 82 10 20 07 mov 7, %g1
194 130: c2 73 a8 b7 stx %g1, [ %sp + 0x8b7 ]
195 134: 90 10 20 00 clr %o0
196 138: 92 10 20 01 mov 1, %o1
197 13c: 94 10 20 02 mov 2, %o2
198 140: 96 10 20 03 mov 3, %o3
199 144: 98 10 20 04 mov 4, %o4
200 148: 9a 10 20 05 mov 5, %o5
201 14c: 40 00 00 00 call 14c <main+0x2c>
202 150: 01 00 00 00 nop
203 154: 82 10 20 00 clr %g1 ! 0 <leaf_call>
204 158: 83 38 60 00 sra %g1, 0, %g1
205 15c: b0 10 00 01 mov %g1, %i0
206 160: 81 cf e0 08 rett %i7 + 8
207 164: 01 00 00 00 nop
208 168: 30 68 00 06 b,a %xcc, 180 <main+0x60>
209 16c: 01 00 00 00 nop
210 170: 01 00 00 00 nop
211 174: 01 00 00 00 nop
212 178: 01 00 00 00 nop
213 17c: 01 00 00 00 nop
214
215
216
217 ; output from netbsd-7.1-sparc64 w/ gcc 4.8.5
218
219 0000000000000000 <leaf_call>:
220 0: 9d e3 bf 50 save %sp, -176, %sp
221 4: 8a 10 00 19 mov %i1, %g5
222 8: 88 10 00 1a mov %i2, %g4
223 c: 86 10 00 1b mov %i3, %g3
224 10: 84 10 00 1c mov %i4, %g2
225 14: 82 10 00 1d mov %i5, %g1
226 18: f0 27 a8 7f st %i0, [ %fp + 0x87f ]
227 1c: ca 27 a8 87 st %g5, [ %fp + 0x887 ]
228 20: c8 27 a8 8f st %g4, [ %fp + 0x88f ]
229 24: c6 27 a8 97 st %g3, [ %fp + 0x897 ]
230 28: c4 27 a8 9f st %g2, [ %fp + 0x89f ]
231 2c: c2 27 a8 a7 st %g1, [ %fp + 0x8a7 ]
232 30: 81 cf e0 08 rett %i7 + 8
233 34: 01 00 00 00 nop
234
235 0000000000000038 <nonleaf_call>:
236 38: 9d e3 bf 40 save %sp, -192, %sp
237 3c: 8a 10 00 19 mov %i1, %g5
238 40: 88 10 00 1a mov %i2, %g4
239 44: 86 10 00 1b mov %i3, %g3
240 48: 84 10 00 1c mov %i4, %g2
241 4c: 82 10 00 1d mov %i5, %g1
242 50: f0 27 a8 7f st %i0, [ %fp + 0x87f ]
243 54: ca 27 a8 87 st %g5, [ %fp + 0x887 ]
244 58: c8 27 a8 8f st %g4, [ %fp + 0x88f ]
245 5c: c6 27 a8 97 st %g3, [ %fp + 0x897 ]
246 60: c4 27 a8 9f st %g2, [ %fp + 0x89f ]
247 64: c2 27 a8 a7 st %g1, [ %fp + 0x8a7 ]
248 68: 9c 03 bf 10 add %sp, -240, %sp
249 6c: 82 03 a8 bf add %sp, 0x8bf, %g1
250 70: 82 00 60 0f add %g1, 0xf, %g1
251 74: 83 30 70 04 srlx %g1, 4, %g1
252 78: 83 28 70 04 sllx %g1, 4, %g1
253 7c: 84 10 20 4c mov 0x4c, %g2
254 80: c4 28 40 00 stb %g2, [ %g1 ]
255 84: c2 07 a8 87 ld [ %fp + 0x887 ], %g1
256 88: bb 38 60 00 sra %g1, 0, %i5
257 8c: c2 07 a8 8f ld [ %fp + 0x88f ], %g1
258 90: 8b 38 60 00 sra %g1, 0, %g5
259 94: c2 07 a8 97 ld [ %fp + 0x897 ], %g1
260 98: 89 38 60 00 sra %g1, 0, %g4
261 9c: c2 07 a8 9f ld [ %fp + 0x89f ], %g1
262 a0: 87 38 60 00 sra %g1, 0, %g3
263 a4: c2 07 a8 a7 ld [ %fp + 0x8a7 ], %g1
264 a8: 85 38 60 00 sra %g1, 0, %g2
265 ac: c2 07 a8 b3 ld [ %fp + 0x8b3 ], %g1
266 b0: 83 38 60 00 sra %g1, 0, %g1
267 b4: f8 07 a8 bb ld [ %fp + 0x8bb ], %i4
268 b8: b9 3f 20 00 sra %i4, 0, %i4
269 bc: f8 73 a8 af stx %i4, [ %sp + 0x8af ]
270 c0: 90 10 00 1d mov %i5, %o0
271 c4: 92 10 00 05 mov %g5, %o1
272 c8: 94 10 00 04 mov %g4, %o2
273 cc: 96 10 00 03 mov %g3, %o3
274 d0: 98 10 00 02 mov %g2, %o4
275 d4: 9a 10 00 01 mov %g1, %o5
276 d8: 40 00 00 00 call d8 <nonleaf_call+0xa0>
277 dc: 01 00 00 00 nop
278 e0: 81 cf e0 08 rett %i7 + 8
279 e4: 01 00 00 00 nop
280
281 00000000000000e8 <main>:
282 e8: 9d e3 bf 40 save %sp, -192, %sp
283 ec: 82 10 20 06 mov 6, %g1
284 f0: c2 73 a8 af stx %g1, [ %sp + 0x8af ]
285 f4: 82 10 20 07 mov 7, %g1
286 f8: c2 73 a8 b7 stx %g1, [ %sp + 0x8b7 ]
287 fc: 90 10 20 00 clr %o0
288 100: 92 10 20 01 mov 1, %o1
289 104: 94 10 20 02 mov 2, %o2
290 108: 96 10 20 03 mov 3, %o3
291 10c: 98 10 20 04 mov 4, %o4
292 110: 9a 10 20 05 mov 5, %o5
293 114: 40 00 00 00 call 114 <main+0x2c>
294 118: 01 00 00 00 nop
295 11c: 82 10 20 00 clr %g1 ! 0 <leaf_call>
296 120: 83 38 60 00 sra %g1, 0, %g1
297 124: b0 10 00 01 mov %g1, %i0
298 128: 81 cf e0 08 rett %i7 + 8
299 12c: 01 00 00 00 nop
300
301
302
303 ; output from openbsd-7.1-sparc64 w/ gcc 4.2.1
304
305 0000000000000000 <leaf_call>:
306 0: 9d e3 bf 30 save %sp, -208, %sp
307 4: 82 10 00 18 mov %i0, %g1
308 8: 84 10 00 19 mov %i1, %g2
309 c: 86 10 00 1a mov %i2, %g3
310 10: 88 10 00 1b mov %i3, %g4
311 14: 8a 10 00 1c mov %i4, %g5
312 18: c2 27 a8 7f st %g1, [ %fp + 0x87f ]
313 1c: c4 27 a8 87 st %g2, [ %fp + 0x887 ]
314 20: c6 27 a8 8f st %g3, [ %fp + 0x88f ]
315 24: c8 27 a8 97 st %g4, [ %fp + 0x897 ]
316 28: ca 27 a8 9f st %g5, [ %fp + 0x89f ]
317 2c: fa 27 a8 a7 st %i5, [ %fp + 0x8a7 ]
318 30: 81 cf e0 08 rett %i7 + 8
319 34: 01 00 00 00 nop
320 38: ae 03 c0 17 add %o7, %l7, %l7
321 3c: 81 c3 e0 08 retl
322 40: 01 00 00 00 nop
323
324 0000000000000044 <nonleaf_call>:
325 44: 9d e3 bf 10 save %sp, -240, %sp
326 48: 2f 00 00 00 sethi %hi(0), %l7
327 4c: ae 05 e0 00 add %l7, 0, %l7 ! 0 <leaf_call>
328 50: 7f ff ff fa call 38 <leaf_call+0x38>
329 54: 01 00 00 00 nop
330 58: 82 10 00 18 mov %i0, %g1
331 5c: 84 10 00 19 mov %i1, %g2
332 60: 86 10 00 1a mov %i2, %g3
333 64: 88 10 00 1b mov %i3, %g4
334 68: 8a 10 00 1c mov %i4, %g5
335 6c: 9a 10 00 1d mov %i5, %o5
336 70: c2 27 a8 7f st %g1, [ %fp + 0x87f ]
337 74: c4 27 a8 87 st %g2, [ %fp + 0x887 ]
338 78: c6 27 a8 8f st %g3, [ %fp + 0x88f ]
339 7c: c8 27 a8 97 st %g4, [ %fp + 0x897 ]
340 80: ca 27 a8 9f st %g5, [ %fp + 0x89f ]
341 84: da 27 a8 a7 st %o5, [ %fp + 0x8a7 ]
342 88: 03 00 00 00 sethi %hi(0), %g1
343 8c: 82 10 60 00 mov %g1, %g1 ! 0 <leaf_call>
344 90: c2 5d c0 01 ldx [ %l7 + %g1 ], %g1
345 94: c4 58 40 00 ldx [ %g1 ], %g2
346 98: c4 77 a7 e7 stx %g2, [ %fp + 0x7e7 ]
347 9c: 84 10 20 00 clr %g2
348 a0: 9c 03 bf 20 add %sp, -224, %sp
349 a4: 86 03 a8 bf add %sp, 0x8bf, %g3
350 a8: c6 77 a7 d7 stx %g3, [ %fp + 0x7d7 ]
351 ac: c4 5f a7 d7 ldx [ %fp + 0x7d7 ], %g2
352 b0: 82 00 a0 0f add %g2, 0xf, %g1
353 b4: 83 30 70 04 srlx %g1, 4, %g1
354 b8: 83 28 70 04 sllx %g1, 4, %g1
355 bc: c2 77 a7 d7 stx %g1, [ %fp + 0x7d7 ]
356 c0: c4 5f a7 d7 ldx [ %fp + 0x7d7 ], %g2
357 c4: 82 10 20 4c mov 0x4c, %g1
358 c8: c2 28 80 00 stb %g1, [ %g2 ]
359 cc: c2 07 a8 87 ld [ %fp + 0x887 ], %g1
360 d0: 89 38 60 00 sra %g1, 0, %g4
361 d4: c2 07 a8 8f ld [ %fp + 0x88f ], %g1
362 d8: 8b 38 60 00 sra %g1, 0, %g5
363 dc: c2 07 a8 97 ld [ %fp + 0x897 ], %g1
364 e0: 9b 38 60 00 sra %g1, 0, %o5
365 e4: c2 07 a8 9f ld [ %fp + 0x89f ], %g1
366 e8: 99 38 60 00 sra %g1, 0, %o4
367 ec: c2 07 a8 a7 ld [ %fp + 0x8a7 ], %g1
368 f0: 85 38 60 00 sra %g1, 0, %g2
369 f4: c2 07 a8 b3 ld [ %fp + 0x8b3 ], %g1
370 f8: 87 38 60 00 sra %g1, 0, %g3
371 fc: c2 07 a8 bb ld [ %fp + 0x8bb ], %g1
372 100: 83 38 60 00 sra %g1, 0, %g1
373 104: c2 73 a8 af stx %g1, [ %sp + 0x8af ]
374 108: 90 10 00 04 mov %g4, %o0
375 10c: 92 10 00 05 mov %g5, %o1
376 110: 94 10 00 0d mov %o5, %o2
377 114: 96 10 00 0c mov %o4, %o3
378 118: 98 10 00 02 mov %g2, %o4
379 11c: 9a 10 00 03 mov %g3, %o5
380 120: 40 00 00 00 call 120 <nonleaf_call+0xdc>
381 124: 01 00 00 00 nop
382 128: 03 00 00 00 sethi %hi(0), %g1
383 12c: 82 10 60 00 mov %g1, %g1 ! 0 <leaf_call>
384 130: c2 5d c0 01 ldx [ %l7 + %g1 ], %g1
385 134: c6 5f a7 e7 ldx [ %fp + 0x7e7 ], %g3
386 138: c4 58 40 00 ldx [ %g1 ], %g2
387 13c: 86 18 c0 02 xor %g3, %g2, %g3
388 140: 84 10 20 00 clr %g2
389 144: 82 10 00 03 mov %g3, %g1
390 148: 02 c8 40 08 brz %g1, 168 <nonleaf_call+0x124>
391 14c: 01 00 00 00 nop
392 150: 03 00 00 00 sethi %hi(0), %g1
393 154: 82 10 60 00 mov %g1, %g1 ! 0 <leaf_call>
394 158: c2 5d c0 01 ldx [ %l7 + %g1 ], %g1
395 15c: 90 10 00 01 mov %g1, %o0
396 160: 40 00 00 00 call 160 <nonleaf_call+0x11c>
397 164: 01 00 00 00 nop
398 168: 81 cf e0 08 rett %i7 + 8
399 16c: 01 00 00 00 nop
400
401 0000000000000170 <main>:
402 170: 9d e3 bf 20 save %sp, -224, %sp
403 174: 82 10 20 06 mov 6, %g1
404 178: c2 73 a8 af stx %g1, [ %sp + 0x8af ]
405 17c: 82 10 20 07 mov 7, %g1
406 180: c2 73 a8 b7 stx %g1, [ %sp + 0x8b7 ]
407 184: 90 10 20 00 clr %o0
408 188: 92 10 20 01 mov 1, %o1
409 18c: 94 10 20 02 mov 2, %o2
410 190: 96 10 20 03 mov 3, %o3
411 194: 98 10 20 04 mov 4, %o4
412 198: 9a 10 20 05 mov 5, %o5
413 19c: 40 00 00 00 call 19c <main+0x2c>
414 1a0: 01 00 00 00 nop
415 1a4: 82 10 20 00 clr %g1 ! 0 <leaf_call>
416 1a8: 83 38 60 00 sra %g1, 0, %g1
417 1ac: b0 10 00 01 mov %g1, %i0
418 1b0: 81 cf e0 08 rett %i7 + 8
419 1b4: 01 00 00 00 nop
420
421
422
423 ; --------------------- with float params, aggregate return value (<32b, passed in regs) and ellipsis with float ------------------->
424
425 ; #include <stdlib.h>
426 ; #include <stdarg.h>
427 ;
428 ; void leaf_call(int b, float c, int d, float e, int f, int g, float h)
429 ; {
430 ; }
431 ;
432 ; struct aggr { int x; int y; int z; };
433 ;
434 ; struct aggr nonleaf_call(int a, int b, float c, int d, float e, int f, ...)
435 ; {
436 ; va_list v;
437 ; int g;
438 ; float h;
439 ; struct aggr st = { b, d, f };
440 ; va_start(v, f);
441 ; g = va_arg(v, int);
442 ; h = va_arg(v, float);
443 ; /* use some local data */
444 ; *(char*)alloca(220) = 'L';
445 ; leaf_call(b, c, d, e, f, g, h);
446 ;
447 ; return st;
448 ; }
449 ;
450 ; int main()
451 ; {
452 ; struct aggr st = nonleaf_call(0, 1, 2.f, 3, 4.f, 5, 6, 7.f);
453 ; return 0;
454 ; }
455
456
457
458 ; output from netbsd-7.1-sparc64 w/ gcc 4.8.5
459
460 0000000000000000 <leaf_call>:
461 0: 9d e3 bf 50 save %sp, -176, %sp ; prolog
462 4: 88 10 00 18 mov %i0, %g4 ; |
463 8: c7 27 a8 87 st %f3, [ %fp + 0x887 ] ; |
464 c: 86 10 00 1a mov %i2, %g3 ; |
465 10: cf 27 a8 97 st %f7, [ %fp + 0x897 ] ; |
466 14: 84 10 00 1c mov %i4, %g2 ; | write input to prev frame's spill area (e.g. offset = 128 for i0, jumping over i*/l* save area)
467 18: 82 10 00 1d mov %i5, %g1 ; | (pointlessly using an extra reg copy to g* for most)
468 1c: db 27 a8 af st %f13, [ %fp + 0x8af ] ; | note: float args are spilled as are all others
469 20: c8 27 a8 7f st %g4, [ %fp + 0x87f ] ; |
470 24: c6 27 a8 8f st %g3, [ %fp + 0x88f ] ; |
471 28: c4 27 a8 9f st %g2, [ %fp + 0x89f ] ; |
472 2c: c2 27 a8 a7 st %g1, [ %fp + 0x8a7 ] ; /
473 30: 81 cf e0 08 rett %i7 + 8 ; \ trap epilog
474 34: 01 00 00 00 nop ; | branch delay slot
475
476 0000000000000038 <nonleaf_call>:
477 38: 9d e3 bf 20 save %sp, -224, %sp ; prolog
478 3c: 88 10 00 18 mov %i0, %g4 ; |
479 40: 86 10 00 19 mov %i1, %g3 ; |
480 44: cb 27 a8 8f st %f5, [ %fp + 0x88f ] ; |
481 48: 84 10 00 1b mov %i3, %g2 ; |
482 4c: d3 27 a8 9f st %f9, [ %fp + 0x89f ] ; | write input to prev frame's spill area (e.g. offset = 128 for i0, jumping over i*/l* save area)
483 50: 82 10 00 1d mov %i5, %g1 ; | (pointlessly using an extra reg copy to g* for most)
484 54: c8 27 a8 7f st %g4, [ %fp + 0x87f ] ; | note: float args are spilled as are all others
485 58: c6 27 a8 87 st %g3, [ %fp + 0x887 ] ; |
486 5c: c4 27 a8 97 st %g2, [ %fp + 0x897 ] ; |
487 60: c2 27 a8 a7 st %g1, [ %fp + 0x8a7 ] ; |
488 64: c2 07 a8 87 ld [ %fp + 0x887 ], %g1 ; in arg 1 (int b, fetched from prev frame's spill area), ...
489 68: c2 27 a7 db st %g1, [ %fp + 0x7db ] ; ... copied to local space (0x7db - bias = -36)
490 6c: c2 07 a8 97 ld [ %fp + 0x897 ], %g1 ; in arg 3 (int d, fetched from prev frame's spill area), ...
491 70: c2 27 a7 df st %g1, [ %fp + 0x7df ] ; ... copied to local space (0x7df - bias = -32)
492 74: c2 07 a8 a7 ld [ %fp + 0x8a7 ], %g1 ; in arg 5 (int f, fetched from prev frame's spill area), ...
493 78: c2 27 a7 e3 st %g1, [ %fp + 0x7e3 ] ; ... copied to local space (0x7e3 - bias = -28)
494 7c: 82 07 a8 af add %fp, 0x8af, %g1 ; va_list: pointer to arg 5 -> g1 ...
495 80: c2 77 a7 e7 stx %g1, [ %fp + 0x7e7 ] ; ... store to local space (0x7e7 - bias = -24)
496 84: c2 5f a7 e7 ldx [ %fp + 0x7e7 ], %g1 ; reread to start iteration (pointlessly)
497 88: 84 00 60 04 add %g1, 4, %g2 ; point read ptr in g2 to first unnamed param (int)
498 8c: c4 00 80 00 ld [ %g2 ], %g2 ; in arg 6 (fetched from prev frame's stack param area), ...
499 90: c4 27 a7 fb st %g2, [ %fp + 0x7fb ] ; ... copied to local space (0x7fb - bias = -4) helper var (probably int g)
500 94: 82 00 60 08 add %g1, 8, %g1 ; point read ptr in g1 to second unnamed param (float, promoted to double), ...
501 98: c2 77 a7 e7 stx %g1, [ %fp + 0x7e7 ] ; ... store in local space (0x7fb - bias = -24)
502 9c: 91 d0 20 05 ta 5 ; trap - not sure what else is involved (objdump was made from .o, not finally linked exec)
503
504 00000000000000a0 <main>:
505 a0: 9d e3 bf 30 save %sp, -208, %sp ; prolog
506 a4: 03 00 00 00 sethi %hi(0), %g1 ; |
507 a8: 82 10 60 00 mov %g1, %g1 ! 0 <leaf_call> ; |
508 ac: 83 28 70 0c sllx %g1, 0xc, %g1 ; | prep arg 2, load from static data into f11 (addr = 0 b/c objdumped .o, not final linked)
509 b0: 82 10 60 00 mov %g1, %g1 ; |
510 b4: d7 00 40 00 ld [ %g1 ], %f11 ; /
511 b8: 03 00 00 00 sethi %hi(0), %g1 ; \
512 bc: 82 10 60 00 mov %g1, %g1 ! 0 <leaf_call> ; | prep arg 4, load from static data into f10 (addr = 0 b/c objdumped .o, not final linked)
513 c0: 83 28 70 0c sllx %g1, 0xc, %g1 ; |
514 c4: 82 10 60 00 mov %g1, %g1 ; |
515 c8: d5 00 40 00 ld [ %g1 ], %f10 ; |
516 cc: 82 10 20 06 mov 6, %g1 ; arg 6, ...
517 d0: c2 73 a8 af stx %g1, [ %sp + 0x8af ] ; ... "pushed" onto stack
518 d4: 03 00 00 00 sethi %hi(0), %g1 ; |
519 d8: 82 10 60 00 mov %g1, %g1 ! 0 <leaf_call> ; |
520 dc: 83 28 70 0c sllx %g1, 0xc, %g1 ; | prep arg 7, load from static data as double (b/c of vararg promotion) into d8 (addr = 0 b/c objdumped .o, not final linked)
521 e0: 82 10 60 00 mov %g1, %g1 ; |
522 e4: d1 18 40 00 ldd [ %g1 ], %f8 ; |
523 e8: d1 3b a8 b7 std %f8, [ %sp + 0x8b7 ] ; arg 7 "pushed" onto stack as double
524 ec: 90 10 20 00 clr %o0 ; arg 0 (note, this is not the pointer to the aggregate return value, b/c latter <= 32b)
525 f0: 92 10 20 01 mov 1, %o1 ; arg 1
526 f4: 8b a0 00 2b fmovs %f11, %f5 ; arg 2
527 f8: 96 10 20 03 mov 3, %o3 ; arg 3
528 fc: 93 a0 00 2a fmovs %f10, %f9 ; arg 4
529 100: 9a 10 20 05 mov 5, %o5 ; arg 5
530 104: 40 00 00 00 call 104 <main+0x64> ; call nonleaf_call (objdump not from final link but .o)
531 108: 01 00 00 00 nop ; branch delay slot
532 10c: 84 10 00 08 mov %o0, %g2 ; |
533 110: 82 10 00 09 mov %o1, %g1 ; / get return value (12b aggregate) out of 2 regs (16b)
534 114: 87 30 b0 20 srlx %g2, 0x20, %g3 ; \
535 118: c8 07 a7 f3 ld [ %fp + 0x7f3 ], %g4 ; |
536 11c: 88 09 20 00 and %g4, 0, %g4 ; | store 1st struct field (int) by g2 >> 32 (and some other operations unnecessary here)
537 120: 86 11 00 03 or %g4, %g3, %g3 ; |
538 124: c6 27 a7 f3 st %g3, [ %fp + 0x7f3 ] ; /
539 128: 86 10 3f ff mov -1, %g3 ; \
540 12c: 87 30 f0 20 srlx %g3, 0x20, %g3 ; |
541 130: 84 08 80 03 and %g2, %g3, %g2 ; |
542 134: c6 07 a7 f7 ld [ %fp + 0x7f7 ], %g3 ; | store 2nd struct field (int) by (-1 >> 32) & g2 (and then some other operations unnecessary here)
543 138: 86 08 e0 00 and %g3, 0, %g3 ; |
544 13c: 84 10 c0 02 or %g3, %g2, %g2 ; |
545 140: c4 27 a7 f7 st %g2, [ %fp + 0x7f7 ] ; /
546 144: 83 38 70 20 srax %g1, 0x20, %g1 ; \
547 148: c4 07 a7 fb ld [ %fp + 0x7fb ], %g2 ; |
548 14c: 84 08 a0 00 and %g2, 0, %g2 ; | store 3rd struct field (int) by g1 >> 32 (and then some other operations unnecessary here)
549 150: 82 10 80 01 or %g2, %g1, %g1 ; |
550 154: c2 27 a7 fb st %g1, [ %fp + 0x7fb ] ; /
551 158: 82 10 20 00 clr %g1 ; \
552 15c: 83 38 60 00 sra %g1, 0, %g1 ; / return value
553 160: b0 10 00 01 mov %g1, %i0 ; \
554 164: 81 cf e0 08 rett %i7 + 8 ; | epilog
555 168: 01 00 00 00 nop ; | branch delay slot
556
557 ; vim: ft=asm
558