]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.arch/thumb2-it.S
Update copyright year range in header of all files managed by GDB
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.arch / thumb2-it.S
CommitLineData
177321bd
DJ
1/* Thumb-2 IT blocks test program.
2
213516ef 3 Copyright 2010-2023 Free Software Foundation, Inc.
177321bd
DJ
4
5 This file is part of GDB.
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
19
20 .syntax unified
21 .text
22 .p2align 2
23 .code 16
24
25#ifndef __thumb2__
26
27 .type main,%function
28 .thumb_func
29 .globl main
30main:
31 mov r0, #0
32 bx lr @ No Thumb-2
33
34#else
35
36 .type main,%function
37 .thumb_func
38 .globl main
39main:
40 mov r0, #0
41 bx lr @ Thumb-2 OK
42
43 @ One conditional instruction, executed.
44 .type it_1,%function
45 .thumb_func
46it_1:
47 mov r0, #0 @ Setup
48 cmp r0, #0 @ Setup
49 it eq @ IT instruction, Expected == 1
50 addeq r0, #1 @ Reached
51 bx lr @ Done
52
53 @ One conditional instruction, skipped.
54 .type it_2,%function
55 .thumb_func
56it_2:
57 mov r0, #0 @ Setup
58 cmp r0, #0 @ Setup
59 it ne @ IT instruction, Expected == 0
60 addne r0, #1 @ Not reached
61 bx lr @ Done, Check $r0 == 0
62
63 @ Block of four, alternating, starting with executed.
64 .type it_3,%function
65 .thumb_func
66it_3:
67 mov r0, #0 @ Setup
68 cmp r0, #0 @ Setup
69 itete ge @ IT instruction, Expected == 2
70 addge r0, #1 @ Reached
71 addlt r0, #2 @ Not reached
72 addge r0, #4 @ Reached
73 addlt r0, #8 @ Not reached
74 bx lr @ Done, Check $r0 == 5
75
76 @ Block of four, changing flags.
77 .type it_4,%function
78 .thumb_func
79it_4:
80 mov r0, #0 @ Setup
81 cmp r0, #0 @ Setup
82 itttt ge @ IT instruction, Expected == 2
83 addge r0, #1 @ Reached
84 cmpge r0, #10 @ Reached
85 addge r0, #4 @ Not reached
86 addge r0, #8 @ Not reached
87 bx lr @ Done, Check $r0 == 1
88
89 @ Block of two, ending with taken branch.
90 .type it_5,%function
91 .thumb_func
92it_5:
93 mov r0, #0 @ Setup
94 cmp r0, #0 @ Setup
95 itt ge @ IT instruction, Expected == 2
96 addge r0, #1 @ Reached
97 bge .L5 @ Reached
98 add r0, #2 @ Never reached
99.L5: bx lr @ Done, Check $r0 == 1
100
101 @ Block of two, ending with untaken branch.
102 .type it_6,%function
103 .thumb_func
104it_6:
105 mov r0, #0 @ Setup
106 cmp r0, #0 @ Setup
107 ite ge @ IT instruction, Expected == 2
108 addge r0, #1 @ Reached
109 blt .L6 @ Not reached
110 add r0, #2 @ Reached
111.L6: bx lr @ Done, Check $r0 == 3
112
113 @ Block of four, taken, of different sizes
114 .type it_7,%function
115 .thumb_func
116it_7:
117 mov r0, #0 @ Setup
118 cmp r0, #0 @ Setup
119 itttt ge @ IT instruction, Expected == 4
120 addge.n r0, #1 @ Reached
121 addge.w r0, #2 @ Reached
122 addge.n r0, #4 @ Reached
123 addge.w r0, #8 @ Reached
124 bx lr @ Done, Check $r0 == 15
125
126 @ Block of four, only first executed.
71193121 127 .type it_8,%function
177321bd
DJ
128 .thumb_func
129it_8:
130 mov r0, #0 @ Setup
131 cmp r0, #0 @ Setup
132 iteee ge @ IT instruction, Expected == 1
133 addge r0, #1 @ Reached
134 addlt r0, #2 @ Not reached
135 addlt r0, #4 @ Not reached
136 addlt r0, #8 @ Not reached
137 bx lr @ Done, Check $r0 == 1
138
f9d67f43
DJ
139 .type it_breakpoints,%function
140 .thumb_func
141it_breakpoints:
142 mov r0, #0
143 cmp r0, #0
144 it eq @ Location 1 @ Break 1
145 moveq r0, #0
146
147 it eq @ Location 2
148 moveq r0, #0 @ Break 2
149
150 it ne @ Location 3
151 movne r0, #0 @ Break 3
152
153 @ An IT block of maximum size.
154 itttt eq @ Location 4
155 moveq.w r0, #0
156 moveq.w r0, #0
157 moveq.w r0, #0
158 moveq.w r0, #0 @ Break 4
159
160 @ Just outside an IT block.
161 it eq
162 moveq r0, #0
163 mov r0, #0 @ Location 5 @ Break 5
164
165 @ After something that looks like an IT block, but
166 @ is the second half of an instruction.
167 .p2align 6
168 cmp r0, r0
169 b 1f
170 b.w .+0xe14 @ 0xf000 0xbf08 -> second half is IT EQ
1711: mov r0, #0 @ Location 6 @ Break 6
172
173 @ After something that looks like an IT block, but
174 @ is data.
175 .p2align 6
176 b 1f
177 .short 0xbf08
1781: mov r0, #0 @ Location 7 @ Break 7
179
180 bx lr
181
177321bd 182#endif /* __thumb2__ */
0f2cd53c 183 .section .note.GNU-stack,"",@progbits