2011-05-05 Yao Qi <yao@codesourcery.com>
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.arch / arm-disp-step.S
1 /* Copyright 2010, 2011 Free Software Foundation, Inc.
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__)
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__)
48 bl test_ldm_stm_pc
49 #endif
50
51 /* Test ldrX literal in ARM */
52 #if !defined (__thumb__)
53 bl test_ldr_literal
54 #endif
55
56 /* Test 32-bit adr in ARM */
57 #if !defined(__thumb__)
58 bl test_adr_32bit
59 #endif
60
61 #if !defined(__thumb__)
62 bl test_pop_pc
63 #endif
64
65 /* Test str in ARM mode and Thumb-2 */
66 #if !defined(__thumb__)
67 bl test_str_pc
68 #endif
69 /* Return */
70 mov sp, r7
71 sub sp, sp, #4
72 movs r0, #0
73 pop {r7, pc}
74 .size main, .-main
75
76 .global test_call_subr
77 #if defined (__thumb__)
78 .code 16
79 .thumb_func
80 #endif
81 .type test_call_subr, %function
82 test_call_subr:
83 nop
84 .global test_call_end
85 test_call_end:
86 nop @ Location test_call_end
87 .global test_ret
88 test_ret:
89 bx lr
90 .size test_call_subr, .-test_call_subr
91
92
93 .global test_branch
94 #if defined (__thumb__)
95 .code 16
96 .thumb_func
97 #endif
98 .type test_branch, %function
99 test_branch:
100 b L_branch
101 .global
102 L_branch:
103 bx lr
104 .size test_branch, .-test_branch
105
106 .global test_ldr_pc
107 #if defined (__thumb__)
108 .code 16
109 .thumb_func
110 #endif
111 .type test_ldr_pc, %function
112 test_ldr_pc:
113 ldr r1, [pc, #0]
114
115 .global
116 test_ldr_pc_ret:
117 bx lr
118 .size test_ldr_pc, .-test_ldr_pc
119
120 #if !defined (__thumb__)
121 .global test_ldm_stm_pc
122 .type test_ldm_stm_pc, %function
123 test_ldm_stm_pc:
124 stmdb sp!, {lr, pc}
125 ldmia sp!, {r0, r1}
126 ldr r0, .L1
127 stmdb sp!, {r0}
128 .global
129 test_ldm_pc:
130 ldmia sp!, {pc}
131 .global
132 test_ldm_stm_pc_ret:
133 bx lr
134 .align 2
135 .L1:
136 .word test_ldm_stm_pc_ret
137 .size test_ldm_stm_pc, .-test_ldm_stm_pc
138 #endif
139
140 #if !defined (__thumb__)
141 .global test_ldr_literal
142 .type test_ldr_literal, %function
143 test_ldr_literal:
144 ldrh r0, [pc]
145 .global test_ldrsb_literal
146 test_ldrsb_literal:
147 ldrsb r0, [pc]
148 .global test_ldrsh_literal
149 test_ldrsh_literal:
150 ldrsh r0, [pc]
151 .global test_ldr_literal_end
152 test_ldr_literal_end:
153 bx lr
154 .size test_ldr_literal, .-test_ldr_literal
155 #endif
156
157
158 #if !defined(__thumb__)
159 .global test_adr_32bit
160 #if defined(__thumb2__)
161 .code 16
162 .thumb_func
163 #endif
164 test_adr_32bit:
165 adr r0, .L6
166 nop
167 .L6:
168 nop
169 .global test_adr_32bit_after
170 test_adr_32bit_after:
171 adr r0, .L6
172
173 .global test_adr_32bit_end
174 test_adr_32bit_end:
175 bx lr
176 .size test_adr_32bit, .-test_adr_32bit
177 #endif
178
179 .global test_pop_pc
180 .type test_pop_pc, %function
181 #if defined(__thumb__)
182 .code 16
183 .thumb_func
184 #endif
185
186 test_pop_pc:
187 ldr r1, .L5
188 #if defined(__thumb__)
189 movs r0, #1
190 orrs r1, r0
191 #endif
192 push {r1}
193 push {r1}
194 .global test_pop_pc_1
195 test_pop_pc_1:
196 pop {r1, pc}
197 .global test_pop_pc_ret
198 test_pop_pc_ret:
199 bx lr
200 .align 2
201 .L5:
202 .word test_pop_pc_ret
203 .size test_pop_pc, .-test_pop_pc
204
205 #if !defined(__thumb__)
206 #if defined (__thumb2__)
207 .code 16
208 .thumb_func
209 #endif
210 .global test_str_pc
211 .type test_str_pc, %function
212 test_str_pc:
213 str pc, [sp, #-4]
214 ldr r0, [sp, #-4]
215 sub r0, r0, pc
216 /* compute offset again without displaced stepping. */
217 str pc, [sp, #-4]
218 ldr r1, [sp, #-4]
219 sub r1, r1, pc
220
221 /* r0 should be equal to r1. */
222 cmp r0, r1
223 bne pc_offset_wrong
224
225 .global pc_offset_right
226 pc_offset_right:
227 b test_str_pc_end
228
229 .global pc_offset_wrong
230 pc_offset_wrong:
231 nop
232
233 .global test_str_pc_end
234 test_str_pc_end:
235 bx lr
236 #endif
This page took 0.036485 seconds and 4 git commands to generate.