1 #include <stdio.h> 2 #include "const.h" 3 #include "macro_int.h" 4 5 typedef enum { 6 AND=0, ANDI, LUI, NOR, 7 OR, ORI, XOR, XORI 8 } logical_op; 9 10 int main() 11 { 12 logical_op op; 13 int i; 14 init_reg_val2(); 15 for (op = AND; op <= XORI; op++) { 16 for (i = 0; i < N; i++) { 17 switch (op) { 18 case AND: 19 /* No Integer Overflow exception occurs under any 20 circumstances. */ 21 TEST1("and $t0, $t1, $t2", reg_val1[i], reg_val1[N-i-1], 22 t0, t1, t2); 23 TEST1("and $s0, $s1, $s2", reg_val2[i], reg_val2[N-i-1], 24 s0, s1, s2); 25 break; 26 27 case ANDI: 28 /* No Integer Overflow exception occurs under any 29 circumstances. */ 30 TEST2("andi $t0, $t1, 0xff", reg_val1[i], 0xff, t0, t1); 31 TEST2("andi $t2, $t3, 0xffff", reg_val1[i], 0xffff, t2, t3); 32 TEST2("andi $a0, $a1, 0x0", reg_val1[i], 0x0, a0, a1); 33 TEST2("andi $s0, $s1, 0x23", reg_val1[i], 0x23, s0, s1); 34 TEST2("andi $t0, $t1, 0xff", reg_val2[i], 0xff, t0, t1); 35 TEST2("andi $t2, $t3, 0xffff", reg_val2[i], 0xffff, t2, t3); 36 TEST2("andi $a0, $a1, 0x0", reg_val2[i], 0x0, a0, a1); 37 TEST2("andi $s0, $s1, 0x23", reg_val2[i], 0x23, s0, s1); 38 break; 39 40 case LUI: 41 /* No Integer Overflow exception occurs under any 42 circumstances. */ 43 if (i == 0) { 44 TEST6("lui $t0, 0xffff", 0xffff, t0); 45 TEST6("lui $a0, 0x0", 0x0, a0); 46 TEST6("lui $t9, 0xff", 0xff, t9); 47 TEST6("lui $v0, 0xfff", 0xfff, v0); 48 TEST6("lui $s0, 0x2", 0x2, s0); 49 } 50 break; 51 52 case NOR: 53 /* No arithmetic exception occurs under any circumstances. */ 54 TEST1("nor $t0, $t1, $t2", reg_val1[i], reg_val1[N-i-1], 55 t0, t1, t2); 56 TEST1("nor $s0, $s1, $s2", reg_val2[i], reg_val2[N-i-1], 57 s0, s1, s2); 58 break; 59 60 case OR: 61 /* No arithmetic exception occurs under any circumstances. */ 62 TEST1("or $t0, $t1, $t2", reg_val1[i], reg_val1[N-i-1], 63 t0, t1, t2); 64 TEST1("or $s0, $s1, $s2", reg_val2[i], reg_val2[N-i-1], 65 s0, s1, s2); 66 break; 67 68 case ORI: 69 /* No arithmetic exception occurs under any circumstances. */ 70 TEST2("ori $t0, $t1, 0xff", reg_val1[i], 0xff, t0, t1); 71 TEST2("ori $t2, $t3, 0xffff", reg_val1[i], 0xffff, t2, t3); 72 TEST2("ori $a0, $a1, 0x0", reg_val1[i], 0x0, a0, a1); 73 TEST2("ori $s0, $s1, 0x23", reg_val1[i], 0x23, s0, s1); 74 TEST2("ori $t0, $t1, 0xff", reg_val2[i], 0xff, t0, t1); 75 TEST2("ori $t2, $t3, 0xffff", reg_val2[i], 0xffff, t2, t3); 76 TEST2("ori $a0, $a1, 0x0", reg_val2[i], 0x0, a0, a1); 77 TEST2("ori $s0, $s1, 0x23", reg_val2[i], 0x23, s0, s1); 78 break; 79 80 case XOR: 81 /* No arithmetic exception occurs under any circumstances. */ 82 TEST1("xor $t0, $t1, $t2", reg_val1[i], reg_val1[N-i-1], 83 t0, t1, t2); 84 TEST1("xor $s0, $s1, $s2", reg_val2[i], reg_val2[N-i-1], 85 s0, s1, s2); 86 break; 87 88 case XORI: 89 /* No arithmetic exception occurs under any circumstances. */ 90 TEST2("xori $t0, $t1, 0xff", reg_val1[i], 0xff, t0, t1); 91 TEST2("xori $t2, $t3, 0xffff", reg_val1[i], 0xffff, t2, t3); 92 TEST2("xori $a0, $a1, 0x0", reg_val1[i], 0x0, a0, a1); 93 TEST2("xori $s0, $s1, 0x23", reg_val1[i], 0x23, s0, s1); 94 TEST2("xori $t0, $t1, 0xff", reg_val2[i], 0xff, t0, t1); 95 TEST2("xori $t2, $t3, 0xffff", reg_val2[i], 0xffff, t2, t3); 96 TEST2("xori $a0, $a1, 0x0", reg_val2[i], 0x0, a0, a1); 97 TEST2("xori $s0, $s1, 0x23", reg_val2[i], 0x23, s0, s1); 98 break; 99 } 100 } 101 } 102 return 0; 103 } 104