1 #include <stdio.h>
2
3 #define TESTINST1(RSval, RD) \
4 { \
5 unsigned int out = 0; \
6 __asm__ volatile( \
7 ".set push \n\t" \
8 ".set noreorder \n\t" \
9 "move $" #RD ", %1\n\t" \
10 "b end"#RSval"\n\t" \
11 "nop\n\t" \
12 "addi $" #RD ", $" #RD", 5\n\t" \
13 "end"#RSval":\n\t" \
14 "addi $" #RD ", $" #RD", 1\n\t" \
15 "move %0, $" #RD "\n\t" \
16 ".set pop \n\t" \
17 : "=&r" (out) \
18 : "r" (RSval) \
19 : #RD, "memory" \
20 ); \
21 printf("B :: %d, RSval: %d\n", \
22 out, RSval); \
23 }
24
25 #define TESTINST2(RSval, RD) \
26 { \
27 unsigned int out = 0; \
28 __asm__ volatile( \
29 ".set push \n\t" \
30 ".set noreorder \n\t" \
31 "move $" #RD ", %1\n\t" \
32 "b end12"#RSval"\n\t" \
33 "addi $" #RD ", $" #RD", 3\n\t" \
34 "addi $" #RD ", $" #RD", 5\n\t" \
35 "end12"#RSval":\n\t" \
36 "addi $" #RD ", $" #RD", 3\n\t" \
37 "move %0, $" #RD "\n\t" \
38 ".set pop \n\t" \
39 : "=&r" (out) \
40 : "r" (RSval) \
41 : #RD, "memory" \
42 ); \
43 printf("B :: %d, RSval: %d\n", \
44 out, RSval); \
45 }
46
47 #define TESTINST3(RSval, RD) \
48 { \
49 unsigned int out = 0; \
50 __asm__ volatile( \
51 ".set push \n\t" \
52 ".set noreorder \n\t" \
53 "move $" #RD ", %1\n\t" \
54 "bal end21"#RSval"\n\t" \
55 "nop\n\t" \
56 "addi $" #RD ", $" #RD", 5\n\t" \
57 "b r_end"#RSval"\n\t" \
58 "nop\n\t" \
59 "end21"#RSval":\n\t" \
60 "addi $" #RD ", $" #RD", 1\n\t" \
61 "jr $ra\n\t" \
62 "r_end"#RSval":\n\t" \
63 "move %0, $" #RD "\n\t" \
64 ".set pop \n\t" \
65 : "=&r" (out) \
66 : "r" (RSval) \
67 : #RD, "memory" \
68 ); \
69 printf("B BAL JR :: %d, RSval: %d\n", \
70 out, RSval); \
71 }
72
73 #define TESTINST3j(RSval, RD) \
74 { \
75 unsigned int out = 0; \
76 __asm__ volatile( \
77 ".set push \n\t" \
78 ".set noreorder \n\t" \
79 "move $" #RD ", %1\n\t" \
80 "la $t0, end31"#RSval"\n\t" \
81 "jal $t0\n\t" \
82 "nop\n\t" \
83 "addi $" #RD ", $" #RD", 5\n\t" \
84 "la $t0, r_end11"#RSval"\n\t" \
85 "j $t0\n\t" \
86 "nop\n\t" \
87 "end31"#RSval":\n\t" \
88 "addi $" #RD ", $" #RD", 1\n\t" \
89 "jr $ra\n\t" \
90 "r_end11"#RSval":\n\t" \
91 "move %0, $" #RD "\n\t" \
92 ".set pop \n\t" \
93 : "=&r" (out) \
94 : "r" (RSval) \
95 : #RD, "t0", "memory" \
96 ); \
97 printf("J JAL JR :: %d, RSval: %d\n", \
98 out, RSval); \
99 }
100
101 #define TESTINST3ja(RSval, RD) \
102 { \
103 unsigned int out = 0; \
104 __asm__ volatile( \
105 ".set push \n\t" \
106 ".set noreorder \n\t" \
107 "move $" #RD ", %1\n\t" \
108 "la $t0, end41"#RSval"\n\t" \
109 "jalr $t1, $t0\n\t" \
110 "nop\n\t" \
111 "addi $" #RD ", $" #RD", 5\n\t" \
112 "la $t0, r_end21"#RSval"\n\t" \
113 "j $t0\n\t" \
114 "nop\n\t" \
115 "end41"#RSval":\n\t" \
116 "addi $" #RD ", $" #RD", 1\n\t" \
117 "jr $t1\n\t" \
118 "r_end21"#RSval":\n\t" \
119 "move %0, $" #RD "\n\t" \
120 ".set pop \n\t" \
121 : "=&r" (out) \
122 : "r" (RSval) \
123 : #RD, "t0", "t1", "memory" \
124 ); \
125 printf("J JALR JR :: %d, RSval: %d\n", \
126 out, RSval); \
127 }
128
129 #define TESTINST4(instruction, RDval, RSval, RTval, RD, RS, RT) \
130 { \
131 unsigned int out = 0; \
132 __asm__ volatile( \
133 ".set push \n\t" \
134 ".set noreorder \n\t" \
135 "move $" #RS ", %1\n\t" \
136 "move $" #RT ", %2\n\t" \
137 "move $" #RD ", %3\n\t" \
138 instruction" $" #RS ", $" #RT ", end"instruction#RDval"\n\t" \
139 "nop\n\t" \
140 "addi $" #RD ", $" #RD", 5\n\t" \
141 "end"instruction#RDval":\n\t" \
142 "addi $" #RD ", $" #RD", 1\n\t" \
143 "move %0, $" #RD "\n\t" \
144 ".set pop \n\t" \
145 : "=&r" (out) \
146 : "r" (RSval), "r" (RTval), "r" (RDval) \
147 : #RD, #RS, #RT, "memory" \
148 ); \
149 printf(instruction" :: %d, RSval: %d, RTval: %d\n", \
150 out, RSval, RTval); \
151 }
152
153 #define TESTINST5(instruction, RDval, RSval, RD, RS) \
154 { \
155 unsigned int out = 0; \
156 __asm__ volatile( \
157 ".set push \n\t" \
158 ".set noreorder \n\t" \
159 "move $" #RS ", %1\n\t" \
160 "move $" #RD ", %2\n\t" \
161 instruction" $" #RS ", end"instruction#RDval"\n\t" \
162 "nop\n\t" \
163 "addi $" #RD ", $" #RD", 5\n\t" \
164 "end"instruction#RDval":\n\t" \
165 "addi $" #RD ", $" #RD", 1\n\t" \
166 "move %0, $" #RD "\n\t" \
167 ".set pop \n\t" \
168 : "=&r" (out) \
169 : "r" (RSval), "r" (RDval) \
170 : #RD, #RS, "memory" \
171 ); \
172 printf(instruction" :: %d, RSval: %d\n", \
173 out, RSval); \
174 }
175
176 #define TESTINST6(instruction, RDval, RSval, RD, RS) \
177 { \
178 unsigned int out = 0; \
179 __asm__ volatile( \
180 ".set push \n\t" \
181 ".set noreorder \n\t" \
182 "move $" #RD ", %2\n\t" \
183 "move $" #RS ", %1\n\t" \
184 instruction" $" #RS ", end21"instruction#RDval"\n\t" \
185 "nop\n\t" \
186 "addi $" #RD ", $" #RD", 5\n\t" \
187 "b r_end"instruction#RDval"\n\t" \
188 "nop\n\t" \
189 "end21"instruction#RDval":\n\t" \
190 "addi $" #RD ", $" #RD", 1\n\t" \
191 "jr $ra\n\t" \
192 "r_end"instruction#RDval":\n\t" \
193 "move %0, $" #RD "\n\t" \
194 ".set pop \n\t" \
195 : "=&r" (out) \
196 : "r" (RSval), "r" (RDval) \
197 : #RD, #RS, "memory" \
198 ); \
199 printf(instruction" :: %d, RSval: %d\n", \
200 out, RSval); \
201 }
202
203 #define TESTINST4l(instruction, RDval, RSval, RTval, RD, RS, RT) \
204 { \
205 unsigned int out = 0; \
206 __asm__ volatile( \
207 ".set push \n\t" \
208 ".set noreorder \n\t" \
209 "move $" #RS ", %1\n\t" \
210 "move $" #RT ", %2\n\t" \
211 "move $" #RD ", %3\n\t" \
212 instruction" $" #RS ", $" #RT ", end"instruction#RDval"\n\t" \
213 "addi $" #RD ", $" #RD", 3\n\t" \
214 "addi $" #RD ", $" #RD", 5\n\t" \
215 "end"instruction#RDval":\n\t" \
216 "addi $" #RD ", $" #RD", 1\n\t" \
217 "move %0, $" #RD "\n\t" \
218 ".set pop \n\t" \
219 : "=&r" (out) \
220 : "r" (RSval), "r" (RTval), "r" (RDval) \
221 : #RD, #RS, #RT, "memory" \
222 ); \
223 printf(instruction" :: %d, RSval: %d, RTval: %d\n", \
224 out, RSval, RTval); \
225 }
226
227 #define TESTINST5l(instruction, RDval, RSval, RD, RS) \
228 { \
229 unsigned int out = 0; \
230 __asm__ volatile( \
231 ".set push \n\t" \
232 ".set noreorder \n\t" \
233 "move $" #RS ", %1\n\t" \
234 "move $" #RD ", %2\n\t" \
235 instruction" $" #RS ", end"instruction#RDval"\n\t" \
236 "addi $" #RD ", $" #RD", 3\n\t" \
237 "addi $" #RD ", $" #RD", 5\n\t" \
238 "end"instruction#RDval":\n\t" \
239 "addi $" #RD ", $" #RD", 1\n\t" \
240 "move %0, $" #RD "\n\t" \
241 ".set pop \n\t" \
242 : "=&r" (out) \
243 : "r" (RSval), "r" (RDval) \
244 : #RD, #RS, "memory" \
245 ); \
246 printf(instruction" :: %d, RSval: %d\n", \
247 out, RSval); \
248 }
249
250 #define TESTINST6l(instruction, RDval, RSval, RD, RS) \
251 { \
252 unsigned int out = 0; \
253 __asm__ volatile( \
254 ".set push \n\t" \
255 ".set noreorder \n\t" \
256 "move $" #RD ", %2\n\t" \
257 "move $" #RS ", %1\n\t" \
258 instruction" $" #RS ", end21"instruction#RDval"\n\t" \
259 "addi $" #RD ", $" #RD", 3\n\t" \
260 "addi $" #RD ", $" #RD", 5\n\t" \
261 "b r_end"instruction#RDval"\n\t" \
262 "nop\n\t" \
263 "end21"instruction#RDval":\n\t" \
264 "addi $" #RD ", $" #RD", 1\n\t" \
265 "jr $ra\n\t" \
266 "r_end"instruction#RDval":\n\t" \
267 "move %0, $" #RD "\n\t" \
268 ".set pop \n\t" \
269 : "=&r" (out) \
270 : "r" (RSval), "r" (RDval) \
271 : #RD, #RS, "memory" \
272 ); \
273 printf(instruction" :: %d, RSval: %d\n", \
274 out, RSval); \
275 }
276
main()277 int main()
278 {
279 printf("b \n");
280 TESTINST1(0, v0);
281 TESTINST1(1, v1);
282 TESTINST1(2, a0);
283 TESTINST1(3, a1);
284 TESTINST1(4, a2);
285 TESTINST1(5, a3);
286 TESTINST1(6, t0);
287 TESTINST1(7, t1);
288 TESTINST1(8, t2);
289 TESTINST1(9, t3);
290 TESTINST1(10, t4);
291 TESTINST1(11, t5);
292 TESTINST1(12, t6);
293 TESTINST1(13, t7);
294 TESTINST1(14, s0);
295 TESTINST1(15, s1);
296 TESTINST1(16, s2);
297 TESTINST1(17, s3);
298 TESTINST1(18, s4);
299 TESTINST1(19, s5);
300 TESTINST1(20, s6);
301 TESTINST1(21, s7);
302 TESTINST1(22, t8);
303 TESTINST1(23, t9);
304
305 printf("b \n");
306 TESTINST2(0, v0);
307 TESTINST2(1, v1);
308 TESTINST2(2, a0);
309 TESTINST2(3, a1);
310 TESTINST2(4, a2);
311 TESTINST2(5, a3);
312 TESTINST2(6, t0);
313 TESTINST2(7, t1);
314 TESTINST2(8, t2);
315 TESTINST2(9, t3);
316 TESTINST2(10, t4);
317 TESTINST2(11, t5);
318 TESTINST2(12, t6);
319 TESTINST2(13, t7);
320 TESTINST2(14, s0);
321 TESTINST2(15, s1);
322 TESTINST2(16, s2);
323 TESTINST2(17, s3);
324 TESTINST2(18, s4);
325 TESTINST2(19, s5);
326 TESTINST2(20, s6);
327 TESTINST2(21, s7);
328 TESTINST2(22, t8);
329 TESTINST2(23, t9);
330
331 printf("b, bal, jr \n");
332 TESTINST3(0, v0);
333 TESTINST3(1, v1);
334 TESTINST3(2, a0);
335 TESTINST3(3, a1);
336 TESTINST3(4, a2);
337 TESTINST3(5, a3);
338 TESTINST3(6, t0);
339 TESTINST3(7, t1);
340 TESTINST3(8, t2);
341 TESTINST3(9, t3);
342 TESTINST3(10, t4);
343 TESTINST3(11, t5);
344 TESTINST3(12, t6);
345 TESTINST3(13, t7);
346 TESTINST3(14, s0);
347 TESTINST3(15, s1);
348 TESTINST3(16, s2);
349 TESTINST3(17, s3);
350 TESTINST3(18, s4);
351 TESTINST3(19, s5);
352 TESTINST3(20, s6);
353 TESTINST3(21, s7);
354 TESTINST3(22, t8);
355 TESTINST3(23, t9);
356
357 printf("beq\n");
358 TESTINST4("beq", 0, 0, 1, v0, v1, a0);
359 TESTINST4("beq", 1, 1, 1, v1, a0, a1);
360 TESTINST4("beq", 2, 0xffffffff, 0xffffffff, a0, a1, a2);
361 TESTINST4("beq", 3, 0xffffffff, 0xfffffffe, a1, a2, a3);
362 TESTINST4("beq", 4, 0xfffffffe, 0xffffffff, a2, t0, t1);
363 TESTINST4("beq", 5, 0xffffffff, 0xffffffff, a3, t0, t1);
364 TESTINST4("beq", 6, 0x5, 0x5, t0, t1, t2);
365 TESTINST4("beq", 7, -3, -4, t1, t2, t3);
366 TESTINST4("beq", 8, 125, 125, t2, t3, t4);
367 TESTINST4("beq", 9, 0x80000000, 0x80000000, t3, t4, t5);
368 TESTINST4("beq", 10, 0xffffffff, 0x80000000, t4, t5, t6);
369 TESTINST4("beq", 11, 0x256, 0x256, t5, t6, t7);
370 TESTINST4("beq", 12, 0x55, 0x55, t6, t7, s0);
371 TESTINST4("beq", 13, 0xfff, 0xdd, s0, s1, s2);
372 TESTINST4("beq", 14, -1, 0x5, v0, t9, t8);
373 TESTINST4("beq", 15, -1, -1, t9, t8, a3);
374
375 printf("bne\n");
376 TESTINST4("bne", 0, 0, 1, v0, v1, a0);
377 TESTINST4("bne", 1, 1, 1, v1, a0, a1);
378 TESTINST4("bne", 2, 0xffffffff, 0xffffffff, a0, a1, a2);
379 TESTINST4("bne", 3, 0xffffffff, 0xfffffffe, a1, a2, a3);
380 TESTINST4("bne", 4, 0xfffffffe, 0xffffffff, a2, t0, t1);
381 TESTINST4("bne", 5, 0xffffffff, 0xffffffff, a3, t0, t1);
382 TESTINST4("bne", 6, 0x5, 0x5, t0, t1, t2);
383 TESTINST4("bne", 7, -3, -4, t1, t2, t3);
384 TESTINST4("bne", 8, 125, 125, t2, t3, t4);
385 TESTINST4("bne", 9, 0x80000000, 0x80000000, t3, t4, t5);
386 TESTINST4("bne", 10, 0xffffffff, 0x80000000, t4, t5, t6);
387 TESTINST4("bne", 11, 0x256, 0x256, t5, t6, t7);
388 TESTINST4("bne", 12, 0x55, 0x55, t6, t7, s0);
389 TESTINST4("bne", 13, 0xfff, 0xdd, s0, s1, s2);
390 TESTINST4("bne", 14, -1, 0x5, v0, t9, t8);
391 TESTINST4("bne", 15, -1, -1, t9, t8, a3);
392
393 printf("BEQZ\n");
394 TESTINST5("beqz", 0, 0, v0, v1);
395 TESTINST5("beqz", 1, 1, v1, a0);
396 TESTINST5("beqz", 2, 0xffffffff, a0, a1);
397 TESTINST5("beqz", 3, 0xffffffff, a1, a2);
398 TESTINST5("beqz", 4, 0xfffffffe, a2, t0);
399 TESTINST5("beqz", 5, 0xffffffff, a3, t0);
400 TESTINST5("beqz", 6, 0x5, t0, t1);
401 TESTINST5("beqz", 7, -3, t1, t2);
402 TESTINST5("beqz", 8, 125, t2, t3);
403 TESTINST5("beqz", 9, 0x80000000, t3, t4);
404 TESTINST5("beqz", 10, 0xffffffff, t4, t5);
405 TESTINST5("beqz", 11, 0x256, t5, t6);
406 TESTINST5("beqz", 12, 0x55, t6, t7);
407 TESTINST5("beqz", 13, 0xfff, s0, s1);
408 TESTINST5("beqz", 14, -1, v0, t9);
409 TESTINST5("beqz", 15, -1, t9, t8);
410
411 printf("BGEZ\n");
412 TESTINST5("bgez", 0, 0, v0, v1);
413 TESTINST5("bgez", 1, 1, v1, a0);
414 TESTINST5("bgez", 2, 0xffffffff, a0, a1);
415 TESTINST5("bgez", 3, 0xffffffff, a1, a2);
416 TESTINST5("bgez", 4, 0xfffffffe, a2, t0);
417 TESTINST5("bgez", 5, 0xffffffff, a3, t0);
418 TESTINST5("bgez", 6, 0x5, t0, t1);
419 TESTINST5("bgez", 7, -3, t1, t2);
420 TESTINST5("bgez", 8, 125, t2, t3);
421 TESTINST5("bgez", 9, 0x80000000, t3, t4);
422 TESTINST5("bgez", 10, 0xffffffff, t4, t5);
423 TESTINST5("bgez", 11, 0x256, t5, t6);
424 TESTINST5("bgez", 12, 0x55, t6, t7);
425 TESTINST5("bgez", 13, 0xfff, s0, s1);
426 TESTINST5("bgez", 14, -1, v0, t9);
427 TESTINST5("bgez", 15, -1, t9, t8);
428
429 printf("BGTZ\n");
430 TESTINST5("bgtz", 0, 0, v0, v1);
431 TESTINST5("bgtz", 1, 1, v1, a0);
432 TESTINST5("bgtz", 2, 0xffffffff, a0, a1);
433 TESTINST5("bgtz", 3, 0xffffffff, a1, a2);
434 TESTINST5("bgtz", 4, 0xfffffffe, a2, t0);
435 TESTINST5("bgtz", 5, 0xffffffff, a3, t0);
436 TESTINST5("bgtz", 6, 0x5, t0, t1);
437 TESTINST5("bgtz", 7, -3, t1, t2);
438 TESTINST5("bgtz", 8, 125, t2, t3);
439 TESTINST5("bgtz", 9, 0x80000000, t3, t4);
440 TESTINST5("bgtz", 10, 0xffffffff, t4, t5);
441 TESTINST5("bgtz", 11, 0x256, t5, t6);
442 TESTINST5("bgtz", 12, 0x55, t6, t7);
443 TESTINST5("bgtz", 13, 0xfff, s0, s1);
444 TESTINST5("bgtz", 14, -1, v0, t9);
445 TESTINST5("bgtz", 15, -1, t9, t8);
446
447 printf("BLEZ\n");
448 TESTINST5("blez", 0, 0, v0, v1);
449 TESTINST5("blez", 1, 1, v1, a0);
450 TESTINST5("blez", 2, 0xffffffff, a0, a1);
451 TESTINST5("blez", 3, 0xffffffff, a1, a2);
452 TESTINST5("blez", 4, 0xfffffffe, a2, t0);
453 TESTINST5("blez", 5, 0xffffffff, a3, t0);
454 TESTINST5("blez", 6, 0x5, t0, t1);
455 TESTINST5("blez", 7, -3, t1, t2);
456 TESTINST5("blez", 8, 125, t2, t3);
457 TESTINST5("blez", 9, 0x80000000, t3, t4);
458 TESTINST5("blez", 10, 0xffffffff, t4, t5);
459 TESTINST5("blez", 11, 0x256, t5, t6);
460 TESTINST5("blez", 12, 0x55, t6, t7);
461 TESTINST5("blez", 13, 0xfff, s0, s1);
462 TESTINST5("blez", 14, -1, v0, t9);
463 TESTINST5("blez", 15, -1, t9, t8);
464
465 printf("BLTZ\n");
466 TESTINST5("bltz", 0, 0, v0, v1);
467 TESTINST5("bltz", 1, 1, v1, a0);
468 TESTINST5("bltz", 2, 0xffffffff, a0, a1);
469 TESTINST5("bltz", 3, 0xffffffff, a1, a2);
470 TESTINST5("bltz", 4, 0xfffffffe, a2, t0);
471 TESTINST5("bltz", 5, 0xffffffff, a3, t0);
472 TESTINST5("bltz", 6, 0x5, t0, t1);
473 TESTINST5("bltz", 7, -3, t1, t2);
474 TESTINST5("bltz", 8, 125, t2, t3);
475 TESTINST5("bltz", 9, 0x80000000, t3, t4);
476 TESTINST5("bltz", 10, 0xffffffff, t4, t5);
477 TESTINST5("bltz", 11, 0x256, t5, t6);
478 TESTINST5("bltz", 12, 0x55, t6, t7);
479 TESTINST5("bltz", 13, 0xfff, s0, s1);
480 TESTINST5("bltz", 14, -1, v0, t9);
481 TESTINST5("bltz", 15, -1, t9, t8);
482
483 printf("BGEZAL\n");
484 TESTINST6("bgezal", 0, 0, v0, v1);
485 TESTINST6("bgezal", 1, 1, v1, a0);
486 TESTINST6("bgezal", 2, 0xffffffff, a0, a1);
487 TESTINST6("bgezal", 3, 0xffffffff, a1, a2);
488 TESTINST6("bgezal", 4, 0xfffffffe, a2, t0);
489 TESTINST6("bgezal", 5, 0xffffffff, a3, t0);
490 TESTINST6("bgezal", 6, 0x5, t0, t1);
491 TESTINST6("bgezal", 7, -3, t1, t2);
492 TESTINST6("bgezal", 8, 125, t2, t3);
493 TESTINST6("bgezal", 9, 0x80000000, t3, t4);
494 TESTINST6("bgezal", 10, 0xffffffff, t4, t5);
495 TESTINST6("bgezal", 11, 0x256, t5, t6);
496 TESTINST6("bgezal", 12, 0x55, t6, t7);
497 TESTINST6("bgezal", 13, 0xfff, s0, s1);
498 TESTINST6("bgezal", 14, -1, v0, t9);
499 TESTINST6("bgezal", 15, -1, t9, t8);
500
501 printf("BLTZAL\n");
502 TESTINST6("bltzal", 0, 0, v0, v1);
503 TESTINST6("bltzal", 1, 1, v1, a0);
504 TESTINST6("bltzal", 2, 0xffffffff, a0, a1);
505 TESTINST6("bltzal", 3, 0xffffffff, a1, a2);
506 TESTINST6("bltzal", 4, 0xfffffffe, a2, t0);
507 TESTINST6("bltzal", 5, 0xffffffff, a3, t0);
508 TESTINST6("bltzal", 6, 0x5, t0, t1);
509 TESTINST6("bltzal", 7, -3, t1, t2);
510 TESTINST6("bltzal", 8, 125, t2, t3);
511 TESTINST6("bltzal", 9, 0x80000000, t3, t4);
512 TESTINST6("bltzal", 10, 0xffffffff, t4, t5);
513 TESTINST6("bltzal", 11, 0x256, t5, t6);
514 TESTINST6("bltzal", 12, 0x55, t6, t7);
515 TESTINST6("bltzal", 13, 0xfff, s0, s1);
516 TESTINST6("bltzal", 14, -1, v0, t9);
517 TESTINST6("bltzal", 15, -1, t9, t8);
518
519 printf("BNEZ\n");
520 TESTINST5("bnez", 0, 0, v0, v1);
521 TESTINST5("bnez", 1, 1, v1, a0);
522 TESTINST5("bnez", 2, 0xffffffff, a0, a1);
523 TESTINST5("bnez", 3, 0xffffffff, a1, a2);
524 TESTINST5("bnez", 4, 0xfffffffe, a2, t0);
525 TESTINST5("bnez", 5, 0xffffffff, a3, t0);
526 TESTINST5("bnez", 6, 0x5, t0, t1);
527 TESTINST5("bnez", 7, -3, t1, t2);
528 TESTINST5("bnez", 8, 125, t2, t3);
529 TESTINST5("bnez", 9, 0x80000000, t3, t4);
530 TESTINST5("bnez", 10, 0xffffffff, t4, t5);
531 TESTINST5("bnez", 11, 0x256, t5, t6);
532 TESTINST5("bnez", 12, 0x55, t6, t7);
533 TESTINST5("bnez", 13, 0xfff, s0, s1);
534 TESTINST5("bnez", 14, -1, v0, t9);
535 TESTINST5("bnez", 15, -1, t9, t8);
536
537 printf("beql\n");
538 TESTINST4l("beql", 0, 0, 1, v0, v1, a0);
539 TESTINST4l("beql", 1, 1, 1, v1, a0, a1);
540 TESTINST4l("beql", 2, 0xffffffff, 0xffffffff, a0, a1, a2);
541 TESTINST4l("beql", 3, 0xffffffff, 0xfffffffe, a1, a2, a3);
542 TESTINST4l("beql", 4, 0xfffffffe, 0xffffffff, a2, t0, t1);
543 TESTINST4l("beql", 5, 0xffffffff, 0xffffffff, a3, t0, t1);
544 TESTINST4l("beql", 6, 0x5, 0x5, t0, t1, t2);
545 TESTINST4l("beql", 7, -3, -4, t1, t2, t3);
546 TESTINST4l("beql", 8, 125, 125, t2, t3, t4);
547 TESTINST4l("beql", 9, 0x80000000, 0x80000000, t3, t4, t5);
548 TESTINST4l("beql", 10, 0xffffffff, 0x80000000, t4, t5, t6);
549 TESTINST4l("beql", 11, 0x256, 0x256, t5, t6, t7);
550 TESTINST4l("beql", 12, 0x55, 0x55, t6, t7, s0);
551 TESTINST4l("beql", 13, 0xfff, 0xdd, s0, s1, s2);
552 TESTINST4l("beql", 14, -1, 0x5, v0, t9, t8);
553 TESTINST4l("beql", 15, -1, -1, t9, t8, a3);
554
555 printf("BGEZALL\n");
556 TESTINST5l("bgezall", 0, 0, v0, v1);
557 TESTINST5l("bgezall", 1, 1, v1, a0);
558 TESTINST5l("bgezall", 2, 0xffffffff, a0, a1);
559 TESTINST5l("bgezall", 3, 0xffffffff, a1, a2);
560 TESTINST5l("bgezall", 4, 0xfffffffe, a2, t0);
561 TESTINST5l("bgezall", 5, 0xffffffff, a3, t0);
562 TESTINST5l("bgezall", 6, 0x5, t0, t1);
563 TESTINST5l("bgezall", 7, -3, t1, t2);
564 TESTINST5l("bgezall", 8, 125, t2, t3);
565 TESTINST5l("bgezall", 9, 0x80000000, t3, t4);
566 TESTINST5l("bgezall", 10, 0xffffffff, t4, t5);
567 TESTINST5l("bgezall", 11, 0x256, t5, t6);
568 TESTINST5l("bgezall", 12, 0x55, t6, t7);
569 TESTINST5l("bgezall", 13, 0xfff, s0, s1);
570 TESTINST5l("bgezall", 14, -1, v0, t9);
571 TESTINST5l("bgezall", 15, -1, t9, t8);
572
573 printf("BGEZL\n");
574 TESTINST5l("bgezl", 0, 0, v0, v1);
575 TESTINST5l("bgezl", 1, 1, v1, a0);
576 TESTINST5l("bgezl", 2, 0xffffffff, a0, a1);
577 TESTINST5l("bgezl", 3, 0xffffffff, a1, a2);
578 TESTINST5l("bgezl", 4, 0xfffffffe, a2, t0);
579 TESTINST5l("bgezl", 5, 0xffffffff, a3, t0);
580 TESTINST5l("bgezl", 6, 0x5, t0, t1);
581 TESTINST5l("bgezl", 7, -3, t1, t2);
582 TESTINST5l("bgezl", 8, 125, t2, t3);
583 TESTINST5l("bgezl", 9, 0x80000000, t3, t4);
584 TESTINST5l("bgezl", 10, 0xffffffff, t4, t5);
585 TESTINST5l("bgezl", 11, 0x256, t5, t6);
586 TESTINST5l("bgezl", 12, 0x55, t6, t7);
587 TESTINST5l("bgezl", 13, 0xfff, s0, s1);
588 TESTINST5l("bgezl", 14, -1, v0, t9);
589 TESTINST5l("bgezl", 15, -1, t9, t8);
590
591 printf("BGTZL\n");
592 TESTINST5l("bgtzl", 0, 0, v0, v1);
593 TESTINST5l("bgtzl", 1, 1, v1, a0);
594 TESTINST5l("bgtzl", 2, 0xffffffff, a0, a1);
595 TESTINST5l("bgtzl", 3, 0xffffffff, a1, a2);
596 TESTINST5l("bgtzl", 4, 0xfffffffe, a2, t0);
597 TESTINST5l("bgtzl", 5, 0xffffffff, a3, t0);
598 TESTINST5l("bgtzl", 6, 0x5, t0, t1);
599 TESTINST5l("bgtzl", 7, -3, t1, t2);
600 TESTINST5l("bgtzl", 8, 125, t2, t3);
601 TESTINST5l("bgtzl", 9, 0x80000000, t3, t4);
602 TESTINST5l("bgtzl", 10, 0xffffffff, t4, t5);
603 TESTINST5l("bgtzl", 11, 0x256, t5, t6);
604 TESTINST5l("bgtzl", 12, 0x55, t6, t7);
605 TESTINST5l("bgtzl", 13, 0xfff, s0, s1);
606 TESTINST5l("bgtzl", 14, -1, v0, t9);
607 TESTINST5l("bgtzl", 15, -1, t9, t8);
608
609 printf("BLEZL\n");
610 TESTINST5l("blezl", 0, 0, v0, v1);
611 TESTINST5l("blezl", 1, 1, v1, a0);
612 TESTINST5l("blezl", 2, 0xffffffff, a0, a1);
613 TESTINST5l("blezl", 3, 0xffffffff, a1, a2);
614 TESTINST5l("blezl", 4, 0xfffffffe, a2, t0);
615 TESTINST5l("blezl", 5, 0xffffffff, a3, t0);
616 TESTINST5l("blezl", 6, 0x5, t0, t1);
617 TESTINST5l("blezl", 7, -3, t1, t2);
618 TESTINST5l("blezl", 8, 125, t2, t3);
619 TESTINST5l("blezl", 9, 0x80000000, t3, t4);
620 TESTINST5l("blezl", 10, 0xffffffff, t4, t5);
621 TESTINST5l("blezl", 11, 0x256, t5, t6);
622 TESTINST5l("blezl", 12, 0x55, t6, t7);
623 TESTINST5l("blezl", 13, 0xfff, s0, s1);
624 TESTINST5l("blezl", 14, -1, v0, t9);
625 TESTINST5l("blezl", 15, -1, t9, t8);
626
627 printf("BGEZALL\n");
628 TESTINST6l("bgezall", 0, 0, v0, v1);
629 TESTINST6l("bgezall", 1, 1, v1, a0);
630 TESTINST6l("bgezall", 2, 0xffffffff, a0, a1);
631 TESTINST6l("bgezall", 3, 0xffffffff, a1, a2);
632 TESTINST6l("bgezall", 4, 0xfffffffe, a2, t0);
633 TESTINST6l("bgezall", 5, 0xffffffff, a3, t0);
634 TESTINST6l("bgezall", 6, 0x5, t0, t1);
635 TESTINST6l("bgezall", 7, -3, t1, t2);
636 TESTINST6l("bgezall", 8, 125, t2, t3);
637 TESTINST6l("bgezall", 9, 0x80000000, t3, t4);
638 TESTINST6l("bgezall", 10, 0xffffffff, t4, t5);
639 TESTINST6l("bgezall", 11, 0x256, t5, t6);
640 TESTINST6l("bgezall", 12, 0x55, t6, t7);
641 TESTINST6l("bgezall", 13, 0xfff, s0, s1);
642 TESTINST6l("bgezall", 14, -1, v0, t9);
643 TESTINST6l("bgezall", 15, -1, t9, t8);
644
645 printf("BLTZL\n");
646 TESTINST5l("bltzl", 0, 0, v0, v1);
647 TESTINST5l("bltzl", 1, 1, v1, a0);
648 TESTINST5l("bltzl", 2, 0xffffffff, a0, a1);
649 TESTINST5l("bltzl", 3, 0xffffffff, a1, a2);
650 TESTINST5l("bltzl", 4, 0xfffffffe, a2, t0);
651 TESTINST5l("bltzl", 5, 0xffffffff, a3, t0);
652 TESTINST5l("bltzl", 6, 0x5, t0, t1);
653 TESTINST5l("bltzl", 7, -3, t1, t2);
654 TESTINST5l("bltzl", 8, 125, t2, t3);
655 TESTINST5l("bltzl", 9, 0x80000000, t3, t4);
656 TESTINST5l("bltzl", 10, 0xffffffff, t4, t5);
657 TESTINST5l("bltzl", 11, 0x256, t5, t6);
658 TESTINST5l("bltzl", 12, 0x55, t6, t7);
659 TESTINST5l("bltzl", 13, 0xfff, s0, s1);
660 TESTINST5l("bltzl", 14, -1, v0, t9);
661 TESTINST5l("bltzl", 15, -1, t9, t8);
662
663 printf("BNEL\n");
664 TESTINST4l("bnel", 0, 0, 1, v0, v1, a0);
665 TESTINST4l("bnel", 1, 1, 1, v1, a0, a1);
666 TESTINST4l("bnel", 2, 0xffffffff, 0xffffffff, a0, a1, a2);
667 TESTINST4l("bnel", 3, 0xffffffff, 0xfffffffe, a1, a2, a3);
668 TESTINST4l("bnel", 4, 0xfffffffe, 0xffffffff, a2, t0, t1);
669 TESTINST4l("bnel", 5, 0xffffffff, 0xffffffff, a3, t0, t1);
670 TESTINST4l("bnel", 6, 0x5, 0x5, t0, t1, t2);
671 TESTINST4l("bnel", 7, -3, -4, t1, t2, t3);
672 TESTINST4l("bnel", 8, 125, 125, t2, t3, t4);
673 TESTINST4l("bnel", 9, 0x80000000, 0x80000000, t3, t4, t5);
674 TESTINST4l("bnel", 10, 0xffffffff, 0x80000000, t4, t5, t6);
675 TESTINST4l("bnel", 11, 0x256, 0x256, t5, t6, t7);
676 TESTINST4l("bnel", 12, 0x55, 0x55, t6, t7, s0);
677 TESTINST4l("bnel", 13, 0xfff, 0xdd, s0, s1, s2);
678 TESTINST4l("bnel", 14, -1, 0x5, v0, t9, t8);
679 TESTINST4l("bnel", 15, -1, -1, t9, t8, a3);
680
681 printf("j, jal, jr \n");
682 TESTINST3j(0, v0);
683 TESTINST3j(1, v1);
684 TESTINST3j(2, a0);
685 TESTINST3j(3, a1);
686 TESTINST3j(4, a2);
687 TESTINST3j(5, a3);
688 TESTINST3j(6, a0);
689 TESTINST3j(7, t1);
690 TESTINST3j(8, t2);
691 TESTINST3j(9, t3);
692 TESTINST3j(10, t4);
693 TESTINST3j(11, t5);
694 TESTINST3j(12, t6);
695 TESTINST3j(13, t7);
696 TESTINST3j(14, s0);
697 TESTINST3j(15, s1);
698 TESTINST3j(16, s2);
699 TESTINST3j(17, s3);
700 TESTINST3j(18, s4);
701 TESTINST3j(19, s5);
702 TESTINST3j(20, s6);
703 TESTINST3j(21, s7);
704 TESTINST3j(22, t8);
705 TESTINST3j(23, t9);
706
707 printf("j, jalr, jr \n");
708 TESTINST3ja(0, v0);
709 TESTINST3ja(1, v1);
710 TESTINST3ja(2, a0);
711 TESTINST3ja(3, a1);
712 TESTINST3ja(4, a2);
713 TESTINST3ja(5, a3);
714 TESTINST3ja(6, a0);
715 TESTINST3ja(7, a3);
716 TESTINST3ja(8, t2);
717 TESTINST3ja(9, t3);
718 TESTINST3ja(10, t4);
719 TESTINST3ja(11, t5);
720 TESTINST3ja(12, t6);
721 TESTINST3ja(13, t7);
722 TESTINST3ja(14, s0);
723 TESTINST3ja(15, s1);
724 TESTINST3ja(16, s2);
725 TESTINST3ja(17, s3);
726 TESTINST3ja(18, s4);
727 TESTINST3ja(19, s5);
728 TESTINST3ja(20, s6);
729 TESTINST3ja(21, s7);
730 TESTINST3ja(22, t8);
731 TESTINST3ja(23, t9);
732
733 return 0;
734 }
735