a5aab8cb1be5c96f1479b040ac10373bcf13c84e
[binutils-gdb.git] / gdb / testsuite / gdb.arch / thumb2-it.S
1 /* Thumb-2 IT blocks test program.
2
3 Copyright 2010 Free Software Foundation, Inc.
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
30 main:
31 mov r0, #0
32 bx lr @ No Thumb-2
33
34 #else
35
36 .type main,%function
37 .thumb_func
38 .globl main
39 main:
40 mov r0, #0
41 bx lr @ Thumb-2 OK
42
43 @ One conditional instruction, executed.
44 .type it_1,%function
45 .thumb_func
46 it_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
56 it_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
66 it_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
79 it_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
92 it_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
104 it_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
116 it_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.
127 .type it_3,%function
128 .thumb_func
129 it_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
139 #endif /* __thumb2__ */