Thu Dec 10 18:46:25 1998 Dave Brolley <brolley@cygnus.com>
[deliverable/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 .endm
14
15 ; Exit with return code
16 .macro exit rc
17 ldi32 \rc,r4
18 ldi32 #1,r0
19 int #10
20 .endm
21
22 ; Pass the test case
23 .macro pass
24 ldi32 #5,r6
25 ldi32 #passmsg,r5
26 ldi32 #1,r4
27 ldi32 #5,r0
28 int #10
29 exit #0
30 .endm
31
32 ; Fail the testcase
33 .macro fail
34 ldi32 #5,r6
35 ldi32 #failmsg,r5
36 ldi32 #1,r4
37 ldi32 #5,r0
38 int #10
39 exit #1
40 .endm
41
42 ; Load an immediate value into a general register
43 ; TODO: use minimal sized insn
44 .macro mvi_h_gr val reg
45 ldi32 \val,\reg
46 .endm
47
48 ; Load an immediate value into a dedicated register
49 .macro mvi_h_dr val reg
50 ldi32 \val,r0
51 mov r0,\reg
52 .endm
53
54 ; Load a general register into another general register
55 .macro mvr_h_gr src targ
56 mov \src,\targ
57 .endm
58
59 ; Store an immediate into a word in memory
60 .macro mvi_h_mem val addr
61 mvi_h_gr \val r4
62 mvr_h_mem r4,\addr
63 .endm
64
65 ; Store a register into a word in memory
66 .macro mvr_h_mem reg addr
67 st \reg,@\addr
68 .endm
69
70 ; Load a word value from memory
71 .macro ldmem_h_gr addr reg
72 ld @\addr,\reg
73 .endm
74
75 ; Add 2 general registers
76 .macro add_h_gr reg1 reg2
77 add \reg1,\reg2
78 .endm
79
80 ; Increment a register by and immediate
81 .macro inci_h_gr inc reg
82 mvi_h_gr \inc,r4
83 add r4,\reg
84 .endm
85
86 ; Test the value of an immediate against a general register
87 .macro test_h_gr val reg
88 .if (\val >= 0) && (\val <= 15)
89 cmp \val,\reg
90 .else
91 .if (\val < 0) && (\val >= -16)
92 cmp2 \val,\reg
93 .else
94 ldi32 \val,r4
95 cmp r4,\reg
96 .endif
97 .endif
98 beq test_gr\@
99 fail
100 test_gr\@:
101 .endm
102
103 ; compare two general registers
104 .macro testr_h_gr reg1 reg2
105 cmp \reg1,\reg2
106 beq testr_gr\@
107 fail
108 testr_gr\@:
109 .endm
110
111 ; Test the value of an immediate against a dedicated register
112 .macro test_h_dr val reg
113 mov \reg,r5
114 test_h_gr \val r5
115 .endm
116
117 ; Test the value of an general register against a dedicated register
118 .macro testr_h_dr gr dr
119 mov \dr,r5
120 testr_h_gr \gr r5
121 .endm
122
123 ; Compare an immediate with word in memory
124 .macro test_h_mem val addr
125 ldmem_h_gr \addr r5
126 test_h_gr \val r5
127 .endm
128
129 ; Compare a general register with word in memory
130 .macro testr_h_mem reg addr
131 ldmem_h_gr \addr r5
132 testr_h_gr \reg r5
133 .endm
134
135 ; Set the condition codes
136 .macro set_cc mask
137 andccr 0xf0
138 orccr \mask
139 .endm
140
141 ; Set the stack mode
142 .macro set_s_user
143 orccr 0x20
144 .endm
145
146 .macro set_s_system
147 andccr 0x1f
148 .endm
149
150 ; Test the condition codes
151 .macro test_cc N Z V C
152 .if (\N == 1)
153 bp fail\@
154 .else
155 bn fail\@
156 .endif
157 .if (\Z == 1)
158 bne fail\@
159 .else
160 beq fail\@
161 .endif
162 .if (\V == 1)
163 bnv fail\@
164 .else
165 bv fail\@
166 .endif
167 .if (\C == 1)
168 bnc fail\@
169 .else
170 bc fail\@
171 .endif
172 bra test_cc\@
173 fail\@:
174 fail
175 test_cc\@:
176 .endm
177
178 ; Set the division bits
179 .macro set_dbits val
180 mvr_h_gr ps,r5
181 mvi_h_gr 0xfffff8ff,r4
182 and r4,r5
183 mvi_h_gr \val,r0
184 mvi_h_gr 3,r4
185 and r4,r0
186 lsl 9,r0
187 or r0,r5
188 mvr_h_gr r5,ps
189 .endm
190
191 ; Test the division bits
192 .macro test_dbits val
193 mvr_h_gr ps,r0
194 lsr 9,r0
195 mvi_h_gr 3,r4
196 and r4,r0
197 test_h_gr \val,r0
198 .endm
This page took 0.051985 seconds and 4 git commands to generate.