comparison doc/disas_examples/arm.armhf.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 0fc22b5feac7
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 raspbian-wheezy_20120715-raspberrypi w/ gcc 4.6.3
23 ; note: this is arm mode, -mthumb says "sorry, unimplemented: Thumb-1 hard-float VFP ABI" (however, -msoft-float -mthumb is supported)
24 ; not sure about thumb-2 as there is no flag for it, but I don't think this exists if using the VFP
25
26 00000000 <leaf_call>:
27 0: e52db004 push {fp} ; (str fp, [sp, #-4]!)
28 4: e28db000 add fp, sp, #0
29 8: e24dd014 sub sp, sp, #20
30 c: e50b0008 str r0, [fp, #-8]
31 10: e50b100c str r1, [fp, #-12]
32 14: e50b2010 str r2, [fp, #-16]
33 18: e50b3014 str r3, [fp, #-20]
34 1c: e28bd000 add sp, fp, #0
35 20: e8bd0800 pop {fp}
36 24: e12fff1e bx lr
37
38 00000028 <nonleaf_call>:
39 ;spill here, if needed: push {r0, r1, r2, r3} ; | just for ref, if present this would change below offsets
40 28: e92d4800 push {fp, lr} ; |
41 2c: e28db004 add fp, sp, #4 ; | prolog
42 30: e24dd020 sub sp, sp, #32 ; |
43 34: e50b0008 str r0, [fp, #-8] ; in arg 0 -> temp space in local area
44 38: e50b100c str r1, [fp, #-12] ; in arg 1 -> temp space in local area
45 3c: e50b2010 str r2, [fp, #-16] ; in arg 2 -> temp space in local area
46 40: e50b3014 str r3, [fp, #-20] ; in arg 3 -> temp space in local area
47 44: e24dd0e8 sub sp, sp, #232 ; alloca(220) - with padding to guarantee alignment
48 48: e28d3010 add r3, sp, #16 ; |
49 4c: e2833007 add r3, r3, #7 ; |
50 50: e1a031a3 lsr r3, r3, #3 ; | start of (aligned) alloca()'d memory -> r3, leaving room at top of stack for param area
51 54: e1a03183 lsl r3, r3, #3 ; |
52 58: e3a0204c mov r2, #76 ; 'L' -> r2, and ...
53 5c: e5c32000 strb r2, [r3] ; ... store in local area (of alloca()'d space)
54 60: e59b3008 ldr r3, [fp, #8] ; arg 4 (fetched from prev frame's param area), and ...
55 64: e58d3000 str r3, [sp] ; ... "pushed" onto stack
56 68: e59b300c ldr r3, [fp, #12] ; arg 5 (fetched from prev frame's param area), and ...
57 6c: e58d3004 str r3, [sp, #4] ; ... "pushed" onto stack
58 70: e59b3010 ldr r3, [fp, #16] ; arg 6 (fetched from prev frame's param area), and ...
59 74: e58d3008 str r3, [sp, #8] ; ... "pushed" onto stack
60 78: e51b000c ldr r0, [fp, #-12] ; arg 0
61 7c: e51b1010 ldr r1, [fp, #-16] ; arg 1
62 80: e51b2014 ldr r2, [fp, #-20] ; arg 2
63 84: e59b3004 ldr r3, [fp, #4] ; arg 3 (fetched from prev frame's param area)
64 88: ebfffffe bl 0 <leaf_call> ; return address -> r14/lr, and call
65 8c: e24bd004 sub sp, fp, #4 ; |
66 90: e8bd8800 pop {fp, pc} ; | epilog
67
68 00000094 <main>:
69 94: e92d4800 push {fp, lr} ; |
70 98: e28db004 add fp, sp, #4 ; | prolog
71 9c: e24dd010 sub sp, sp, #16 ; |
72 a0: e3a03004 mov r3, #4 ; arg 4, and ...
73 a4: e58d3000 str r3, [sp] ; ... "pushed" onto stack
74 a8: e3a03005 mov r3, #5 ; arg 5, and ...
75 ac: e58d3004 str r3, [sp, #4] ; ... "pushed" onto stack
76 b0: e3a03006 mov r3, #6 ; arg 6, and ...
77 b4: e58d3008 str r3, [sp, #8] ; ... "pushed" onto stack
78 b8: e3a03007 mov r3, #7 ; arg 7, and ...
79 bc: e58d300c str r3, [sp, #12] ; ... "pushed" onto stack
80 c0: e3a00000 mov r0, #0 ; arg 0
81 c4: e3a01001 mov r1, #1 ; arg 1
82 c8: e3a02002 mov r2, #2 ; arg 2
83 cc: e3a03003 mov r3, #3 ; arg 3
84 d0: ebfffffe bl 28 <nonleaf_call> ; return address -> r14/lr, and call
85 d4: e3a03000 mov r3, #0 ; return value (0) via r3 ... (a bit unoptimal)
86 d8: e1a00003 mov r0, r3 ; ... to r0
87 dc: e24bd004 sub sp, fp, #4 ; |
88 e0: e8bd8800 pop {fp, pc} ; | epilog
89
90 ; vim: ft=asm68k
91