Commit | Line | Data |
---|---|---|
7b6bb8da | 1 | /* Copyright 2010, 2011 Free Software Foundation, Inc. |
2a20745c YQ |
2 | |
3 | This file is part of GDB. | |
4 | ||
5 | This program is free software; you can redistribute it and/or modify | |
6 | it under the terms of the GNU General Public License as published by | |
7 | the Free Software Foundation; either version 3 of the License, or | |
8 | (at your option) any later version. | |
9 | ||
10 | This program is distributed in the hope that it will be useful, | |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | GNU General Public License for more details. | |
14 | ||
15 | You should have received a copy of the GNU General Public License | |
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ | |
17 | ||
18 | .syntax unified | |
19 | .text | |
20 | .type main,%function | |
21 | #if defined (__thumb__) || defined (__thumb2__) | |
22 | .code 16 | |
23 | .thumb_func | |
24 | #endif | |
25 | .globl main | |
26 | main: | |
27 | push {r7, lr} | |
28 | add sp, sp, #4 | |
29 | mov r7, sp | |
30 | ||
31 | ||
32 | /* Test call and return */ | |
33 | .global test_call | |
34 | test_call: | |
35 | bl test_call_subr | |
36 | .global test_ret_end | |
37 | test_ret_end: | |
38 | nop @ Location test_ret_end | |
39 | ||
40 | /* Test branch */ | |
41 | bl test_branch | |
42 | ||
43 | /* Test ldr from pc */ | |
44 | bl test_ldr_pc | |
45 | ||
46 | /* Test ldm/stm only in ARM mode */ | |
47 | #if !defined (__thumb__) && !defined (__thumb2__) | |
48 | bl test_ldm_stm_pc | |
49 | #endif | |
50 | ||
51 | /* Return */ | |
52 | mov sp, r7 | |
53 | sub sp, sp, #4 | |
54 | movs r0, #0 | |
55 | pop {r7, pc} | |
56 | .size main, .-main | |
57 | ||
58 | .global test_call_subr | |
59 | #if defined (__thumb__) || defined (__thumb2__) | |
60 | .code 16 | |
61 | .thumb_func | |
62 | #endif | |
63 | .type test_call_subr, %function | |
64 | test_call_subr: | |
65 | nop | |
66 | .global test_call_end | |
67 | test_call_end: | |
68 | nop @ Location test_call_end | |
69 | .global test_ret | |
70 | test_ret: | |
71 | bx lr | |
72 | .size test_call_subr, .-test_call_subr | |
73 | ||
74 | ||
75 | .global test_branch | |
76 | #if defined (__thumb__) || defined (__thumb2__) | |
77 | .code 16 | |
78 | .thumb_func | |
79 | #endif | |
80 | .type test_branch, %function | |
81 | test_branch: | |
82 | b L_branch | |
83 | .global | |
84 | L_branch: | |
85 | bx lr | |
86 | .size test_branch, .-test_branch | |
87 | ||
88 | .global test_ldr_pc | |
89 | #if defined (__thumb__) || defined (__thumb2__) | |
90 | .code 16 | |
91 | .thumb_func | |
92 | #endif | |
93 | .type test_ldr_pc, %function | |
94 | test_ldr_pc: | |
95 | ldr r1, [pc, #0] | |
96 | ||
97 | .global | |
98 | test_ldr_pc_ret: | |
99 | bx lr | |
100 | .size test_ldr_pc, .-test_ldr_pc | |
101 | ||
102 | #if !defined (__thumb__) && !defined (__thumb2__) | |
103 | .global test_ldm_stm_pc | |
104 | .type test_ldm_stm_pc, %function | |
105 | test_ldm_stm_pc: | |
106 | stmdb sp!, {lr, pc} | |
107 | ldmia sp!, {r0, r1} | |
108 | ldr r0, .L1 | |
109 | stmdb sp!, {r0} | |
110 | .global | |
111 | test_ldm_pc: | |
112 | ldmia sp!, {pc} | |
113 | .global | |
114 | test_ldm_stm_pc_ret: | |
115 | bx lr | |
116 | .align 2 | |
117 | .L1: | |
118 | .word test_ldm_stm_pc_ret | |
119 | .size test_ldm_stm_pc, .-test_ldm_stm_pc | |
120 | #endif |