]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - sim/testsuite/sim/fr30/testutils.inc
* config/sh/tm-sh.h (BELIEVE_PCC_PROMOTION): Define, so that
[thirdparty/binutils-gdb.git] / sim / testsuite / sim / fr30 / testutils.inc
1 # r0, r4-r6 are used as tmps, consider them call clobbered by these macros.
2
3 .macro start
4 .data
5 failmsg:
6 .ascii "fail\n"
7 passmsg:
8 .ascii "pass\n"
9 .text
10 .global _start
11 _start:
12 ldi32 0x7fffc,sp ; TODO -- what's a good value for this?
13 mov sp,usp
14 mov sp,ssp
15 .endm
16
17 ; Exit with return code
18 .macro exit rc
19 ldi32 \rc,r4
20 ldi32 #1,r0
21 int #10
22 .endm
23
24 ; Pass the test case
25 .macro pass
26 ldi32 #5,r6
27 ldi32 #passmsg,r5
28 ldi32 #1,r4
29 ldi32 #5,r0
30 int #10
31 exit #0
32 .endm
33
34 ; Fail the testcase
35 .macro fail
36 ldi32 #5,r6
37 ldi32 #failmsg,r5
38 ldi32 #1,r4
39 ldi32 #5,r0
40 int #10
41 exit #1
42 .endm
43
44 ; Load an immediate value into a general register
45 ; TODO: use minimal sized insn
46 .macro mvi_h_gr val reg
47 ldi32 \val,\reg
48 .endm
49
50 ; Load an immediate value into a dedicated register
51 .macro mvi_h_dr val reg
52 ldi32 \val,r0
53 mov r0,\reg
54 .endm
55
56 ; Load a general register into another general register
57 .macro mvr_h_gr src targ
58 mov \src,\targ
59 .endm
60
61 ; Store an immediate into a word in memory
62 .macro mvi_h_mem val addr
63 mvi_h_gr \val r4
64 mvr_h_mem r4,\addr
65 .endm
66
67 ; Store a register into a word in memory
68 .macro mvr_h_mem reg addr
69 st \reg,@\addr
70 .endm
71
72 ; Load a word value from memory
73 .macro ldmem_h_gr addr reg
74 ld @\addr,\reg
75 .endm
76
77 ; Add 2 general registers
78 .macro add_h_gr reg1 reg2
79 add \reg1,\reg2
80 .endm
81
82 ; Increment a register by and immediate
83 .macro inci_h_gr inc reg
84 mvi_h_gr \inc,r4
85 add r4,\reg
86 .endm
87
88 ; Test the value of an immediate against a general register
89 .macro test_h_gr val reg
90 .if (\val >= 0) && (\val <= 15)
91 cmp \val,\reg
92 .else
93 .if (\val < 0) && (\val >= -16)
94 cmp2 \val,\reg
95 .else
96 ldi32 \val,r4
97 cmp r4,\reg
98 .endif
99 .endif
100 beq test_gr\@
101 fail
102 test_gr\@:
103 .endm
104
105 ; compare two general registers
106 .macro testr_h_gr reg1 reg2
107 cmp \reg1,\reg2
108 beq testr_gr\@
109 fail
110 testr_gr\@:
111 .endm
112
113 ; Test the value of an immediate against a dedicated register
114 .macro test_h_dr val reg
115 mov \reg,r5
116 test_h_gr \val r5
117 .endm
118
119 ; Test the value of an general register against a dedicated register
120 .macro testr_h_dr gr dr
121 mov \dr,r5
122 testr_h_gr \gr r5
123 .endm
124
125 ; Compare an immediate with word in memory
126 .macro test_h_mem val addr
127 ldmem_h_gr \addr r5
128 test_h_gr \val r5
129 .endm
130
131 ; Compare a general register with word in memory
132 .macro testr_h_mem reg addr
133 ldmem_h_gr \addr r5
134 testr_h_gr \reg r5
135 .endm
136
137 ; Set the condition codes
138 .macro set_cc mask
139 andccr 0xf0
140 orccr \mask
141 .endm
142
143 ; Set the stack mode
144 .macro set_s_user
145 orccr 0x20
146 .endm
147
148 .macro set_s_system
149 andccr 0x1f
150 .endm
151
152 ; Test the condition codes
153 .macro test_cc N Z V C
154 .if (\N == 1)
155 bp fail\@
156 .else
157 bn fail\@
158 .endif
159 .if (\Z == 1)
160 bne fail\@
161 .else
162 beq fail\@
163 .endif
164 .if (\V == 1)
165 bnv fail\@
166 .else
167 bv fail\@
168 .endif
169 .if (\C == 1)
170 bnc fail\@
171 .else
172 bc fail\@
173 .endif
174 bra test_cc\@
175 fail\@:
176 fail
177 test_cc\@:
178 .endm
179
180 ; Set the division bits
181 .macro set_dbits val
182 mvr_h_gr ps,r5
183 mvi_h_gr 0xfffff8ff,r4
184 and r4,r5
185 mvi_h_gr \val,r0
186 mvi_h_gr 3,r4
187 and r4,r0
188 lsl 9,r0
189 or r0,r5
190 mvr_h_gr r5,ps
191 .endm
192
193 ; Test the division bits
194 .macro test_dbits val
195 mvr_h_gr ps,r0
196 lsr 9,r0
197 mvi_h_gr 3,r4
198 and r4,r0
199 test_h_gr \val,r0
200 .endm
201
202 ; Save the return pointer
203 .macro save_rp
204 st rp,@-R15
205 .ENDM
206
207 ; restore the return pointer
208 .macro restore_rp
209 ld @R15+,rp
210 .endm