static int DetectCsumValidArgsTestParse03(void) { TEST3(ipv4, DETECT_IPV4_CSUM); TEST3(tcpv4, DETECT_TCPV4_CSUM); TEST3(tcpv6, DETECT_TCPV6_CSUM); TEST3(udpv4, DETECT_UDPV4_CSUM); TEST3(udpv6, DETECT_UDPV6_CSUM); TEST3(icmpv4, DETECT_ICMPV4_CSUM); TEST3(icmpv6, DETECT_ICMPV6_CSUM); PASS; }
int main() { TEST1(); TEST2(); TEST2(); TEST3(); TEST4(); TEST5(); TEST6(); TEST7(); TEST8(); TEST9(); TEST10(); TEST11(); TEST12(); TEST12(); TEST13(); TEST14(); TEST15(); TEST16(); TEST17(); TEST18(); TEST19(); TEST20(); TEST21(); TEST22(); TEST22(); TEST23(); TEST24(); TEST25(); TEST26(); TEST27(); TEST28(); TEST29(); TEST30(); TEST31(); TEST32(); TEST32(); TEST33(); TEST34(); TEST35(); TEST36(); TEST37(); TEST38(); TEST39(); return 0; }
void test_stringf() { TEST0("", ""); TEST0("Hello.", "Hello."); TEST0("backslash: \\", "backslash: \\"); TEST0("2-backslash: \\\\", "2-backslash: \\\\"); TEST0("%%", "%"); TEST0("Hello: %%", "Hello: %"); TEST0("%%: Hello", "%: Hello"); TEST0("foo %% bar", "foo % bar"); TEST0("%", "%(err: unfinished reference)"); TEST0("Hello: %", "Hello: %(err: unfinished reference)"); TEST0("% xyz", "%(err: unfinished reference) xyz"); TEST0("%0", "%(err: unknown arg '0')"); TEST0("%1", "%(err: unknown arg '1')"); TEST0("%10", "%(err: unknown arg '10')"); TEST0("%1.", "%(err: unknown arg '1')."); TEST0("Hello: %1.", "Hello: %(err: unknown arg '1')."); TEST0("Hello: %xyz", "Hello: %(err: unknown arg 'xyz')"); TEST0("Hello: %xyz-hello", "Hello: %(err: unknown arg 'xyz')-hello"); TEST0("Hello: %{xyz-he}llo", "Hello: %(err: unknown arg 'xyz-he')llo"); TEST0("Hello: %{} end", "Hello: %(err: blank reference) end"); TEST0("Hello: %_hello end", "Hello: %(err: unknown arg '_hello') end"); TEST1("Hello: %xyz end", formatarg("x", 42), "Hello: %(err: unknown arg 'xyz') end"); TEST1("Hello: %x end", formatarg("xyz", 42), "Hello: %(err: unknown arg 'x') end"); TEST1("Hello: %1 end", formatarg("x", 42), "Hello: %(err: unknown arg '1') end"); TEST1("Hello: %0 end", formatarg("x", 42), "Hello: 42 end"); TEST1("Hello: %xyz end", formatarg("xyz", 42), "Hello: 42 end"); TEST1("Hello: %{xyz} end", formatarg("xyz", 42), "Hello: 42 end"); TEST1("Hello: %xyz%xyz end", formatarg("xyz", 42), "Hello: 4242 end"); TEST1("Hello: %xyz %xyz end", formatarg("xyz", 42), "Hello: 42 42 end"); TEST3("[%x, %y, %z]", formatarg("x", "X"), formatarg("y", "Y"), formatarg("z", "Z"), "[X, Y, Z]"); TEST3("[%z, %y, %x]", formatarg("x", "X"), formatarg("y", "Y"), formatarg("z", "Z"), "[Z, Y, X]"); TEST3("[%z, %y, %z]", formatarg("x", "X"), formatarg("y", "Y"), formatarg("z", "Z"), "[Z, Y, Z]"); TEST3("[%0x, %1y, %2z]", formatarg("x", "X"), formatarg("y", "Y"), formatarg("z", "Z"), "[Xx, Yy, Zz]"); TEST3("[%0x, %1y, %2z]", formatarg("x", "X"), formatarg("y", "Y"), formatarg("z", "Z"), "[Xx, Yy, Zz]"); TESTPF1("%0{f}", 42.125, "%f"); TESTPF1("%0{g}", 42.125, "%g"); TESTPF1("%0{G}", 42.125, "%G"); TESTPF1("%0{g}", 42.125e10, "%g"); TESTPF1("%0{G}", 42.125e10, "%G"); TESTPF1("%0{e}", 42.125, "%e"); TESTPF1("%0{E}", 42.125, "%E"); TESTPF1("%0{f.5}", 42.125, "%.5f"); TESTPF1("%0{f.0}", 42.125, "%.0f"); TESTPF1("%0{f8}", 42.125, "%8f"); TESTPF1("%0{f0}", 42.125, "%0f"); TESTPF1("%0{f#}", 42.125, "%#f"); TESTPF1("%0{f+}", 42.125, "%+f"); TESTPF1("%0{f-8.1}", 42.125, "%-8.1f"); TESTPF1("%0{f08}", 42.125, "%08f"); TESTPF1("%0{f+08}", 42.125, "%+08f"); TESTPF1("%0{f+08.2}", 42.125, "%+08.2f"); TESTPF1("%0{f08.2}", 42.125, "%08.2f"); TESTPF1("%0{f.5}", 42.0, "%.5f"); TESTPF1("%0{f.0}", 42.0, "%.0f"); TESTPF1("%0{f8}", 42.0, "%8f"); TESTPF1("%0{f0}", 42.0, "%0f"); TESTPF1("%0{f#}", 42.0, "%#f"); TESTPF1("%0{f+}", 42.0, "%+f"); TESTPF1("%0{f-8.1}", 42.0, "%-8.1f"); TESTPF1("%0{f08}", 42.0, "%08f"); TESTPF1("%0{f+08}", 42.0, "%+08f"); TESTPF1("%0{f+08.2}", 42.0, "%+08.2f"); TESTPF1("%0{f08.2}", 42.0, "%08.2f"); TEST1("%0{f }", 42.0, "%(err: bad format)"); TESTPF1("%0{i8}", 42, "%8i"); TESTPF1("%0{i0}", 42, "%0i"); TESTPF1("%0{i+}", 42, "%+i"); TESTPF1("%0{i-8}", 42, "%-8i"); TESTPF1("%0{i08}", 42, "%08i"); TESTPF1("%0{i+08}", 42, "%+08i"); TESTPF1("%0{i+8}", 42, "%+8i"); TESTPF1("%0{x02}", 93u, "%02x"); TEST1("%0{i.0}", 42, "%(err: bad format)"); TEST1("%0{i }", 42, "%(err: bad format)"); }
int main() { int i; init_reg_val2(); #if (__mips_isa_rev < 6) printf("B \n"); for (i = 0; i < N; i++) TEST1(reg_val1[i], t0); printf("BAL \n"); for (i = 0; i < N; i++) TEST2(reg_val1[i], t0); printf("--- BEQ --- if RSval == RTval then " \ "out = RDval + 1 else out = RDval + 6\n"); TEST3("beq", 0, 0, 1, 2, 3, 4); TEST3("beq", 1, 1, 1, 3, 4, 5); TEST3("beq", 2, 0xffffffff, 0xffffffff, 4, 5, 6); TEST3("beq", 3, 0xffffffff, 0xfffffffe, 5, 6, 7); TEST3("beq", 4, 0xfffffffe, 0xffffffff, 6, 7, 8); TEST3("beq", 5, 0xffffffff, 0xffffffff, 7, 8, 9); TEST3("beq", 6, 0x5, 0x5, 8, 9, 10); TEST3("beq", 7, -3, -4, 9, 10, 11); TEST3("beq", 8, 125, 125, 10, 11, 12); TEST3("beq", 9, 0x80000000, 0x80000000, 11, 12, 15); TEST3("beq", 10, 0xffffffff, 0x80000000, 12, 13, 14); TEST3("beq", 11, 0x256, 0x256, 13, 14, 15); TEST3("beq", 12, 0x55, 0x55, 14, 15, 16); TEST3("beq", 13, 0xfff, 0xdd, 15, 16, 17); TEST3("beq", 14, -1, 0x5, 16, 17, 18); TEST3("beq", 15, -1, -1, 17, 18, 19); printf("--- BGEZ --- if RSval >= 0 then " \ "out = RDval + 1 else out = RDval + 9\n"); TEST4("bgez", 0, 0, 2, 3); TEST4("bgez", 1, 1, 3, 4); TEST4("bgez", 2, 0xffffffff, 4, 5); TEST4("bgez", 3, 0xffffffff, 5, 6); TEST4("bgez", 4, 0xfffffffe, 6, 7); TEST4("bgez", 5, 0xffffffff, 7, 8); TEST4("bgez", 6, 0x5, 8, 9); TEST4("bgez", 7, -3, 9, 10); TEST4("bgez", 8, 125, 10, 11); TEST4("bgez", 9, 0x80000000, 11, 12); TEST4("bgez", 10, 0xffffffff, 12, 13); TEST4("bgez", 11, 0x256, 13, 14); TEST4("bgez", 12, 0x55, 14, 15); TEST4("bgez", 13, 0xfff, 15, 16); TEST4("bgez", 14, -1, 16, 17); TEST4("bgez", 15, -1, 17, 18); printf("--- BGEZAL --- if RSval >= 0 then " \ "out = RDval + 1 else out = RDval + 6\n"); TEST5("bgezal", 0, 0, 2, 3); TEST5("bgezal", 1, 1, 3, 4); TEST5("bgezal", 2, 0xffffffff, 4, 5); TEST5("bgezal", 3, 0xffffffff, 5, 6); TEST5("bgezal", 4, 0xfffffffe, 6, 7); TEST5("bgezal", 5, 0xffffffff, 7, 8); TEST5("bgezal", 6, 0x5, 8, 9); TEST5("bgezal", 7, -3, 9, 10); TEST5("bgezal", 8, 125, 10, 11); TEST5("bgezal", 9, 0x80000000, 11, 12); TEST5("bgezal", 10, 0xffffffff, 12, 13); TEST5("bgezal", 11, 0x256, 13, 14); TEST5("bgezal", 12, 0x55, 14, 15); TEST5("bgezal", 13, 0xfff, 15, 16); TEST5("bgezal", 14, -1, 16, 17); TEST5("bgezal", 15, -1, 17, 18); printf("--- BGTZ --- if RSval > 0 then " \ "out = RDval + 1 else out = RDval + 9\n"); TEST4("bgtz", 0, 0, 2, 3); TEST4("bgtz", 1, 1, 3, 4); TEST4("bgtz", 2, 0xffffffff, 4, 5); TEST4("bgtz", 3, 0xffffffff, 5, 6); TEST4("bgtz", 4, 0xfffffffe, 6, 7); TEST4("bgtz", 5, 0xffffffff, 7, 8); TEST4("bgtz", 6, 0x5, 8, 9); TEST4("bgtz", 7, -3, 9, 10); TEST4("bgtz", 8, 125, 10, 11); TEST4("bgtz", 9, 0x80000000, 11, 12); TEST4("bgtz", 10, 0xffffffff, 12, 13); TEST4("bgtz", 11, 0x256, 13, 14); TEST4("bgtz", 12, 0x55, 14, 15); TEST4("bgtz", 13, 0xfff, 15, 16); TEST4("bgtz", 14, -1, 16, 17); TEST4("bgtz", 15, -1, 17, 18); printf("--- BLEZ --- if RSval <= 0 then " \ "out = RDval + 1 else out = RDval + 9\n"); TEST4("blez", 0, 0, 2, 3); TEST4("blez", 1, 1, 3, 4); TEST4("blez", 2, 0xffffffff, 4, 5); TEST4("blez", 3, 0xffffffff, 5, 6); TEST4("blez", 4, 0xfffffffe, 6, 7); TEST4("blez", 5, 0xffffffff, 7, 8); TEST4("blez", 6, 0x5, 8, 9); TEST4("blez", 7, -3, 9, 10); TEST4("blez", 8, 125, 10, 11); TEST4("blez", 9, 0x80000000, 11, 12); TEST4("blez", 10, 0xffffffff, 12, 13); TEST4("blez", 11, 0x256, 13, 14); TEST4("blez", 12, 0x55, 14, 15); TEST4("blez", 13, 0xfff, 15, 16); TEST4("blez", 14, -1, 16, 17); TEST4("blez", 15, -1, 17, 18); printf("--- BLTZ --- if RSval < 0 then " \ "out = RDval + 1 else out = RDval + 9\n"); TEST4("bltz", 0, 0, 2, 3); TEST4("bltz", 1, 1, 3, 4); TEST4("bltz", 2, 0xffffffff, 4, 5); TEST4("bltz", 3, 0xffffffff, 5, 6); TEST4("bltz", 4, 0xfffffffe, 6, 7); TEST4("bltz", 5, 0xffffffff, 7, 8); TEST4("bltz", 6, 0x5, 8, 9); TEST4("bltz", 7, -3, 9, 10); TEST4("bltz", 8, 125, 10, 11); TEST4("bltz", 9, 0x80000000, 11, 12); TEST4("bltz", 10, 0xffffffff, 12, 13); TEST4("bltz", 11, 0x256, 13, 14); TEST4("bltz", 12, 0x55, 14, 15); TEST4("bltz", 13, 0xfff, 15, 16); TEST4("bltz", 14, -1, 16, 17); TEST4("bltz", 15, -1, 17, 18); printf("--- BLTZAL --- if RSval < 0 then " \ "out = RDval + 1 else out = RDval + 6\n"); TEST5("bltzal", 0, 0, 2, 3); TEST5("bltzal", 1, 1, 3, 4); TEST5("bltzal", 2, 0xffffffff, 4, 5); TEST5("bltzal", 3, 0xffffffff, 5, 6); TEST5("bltzal", 4, 0xfffffffe, 6, 7); TEST5("bltzal", 5, 0xffffffff, 7, 8); TEST5("bltzal", 6, 0x5, 8, 9); TEST5("bltzal", 7, -3, 9, 10); TEST5("bltzal", 8, 125, 10, 11); TEST5("bltzal", 9, 0x80000000, 11, 12); TEST5("bltzal", 10, 0xffffffff, 12, 13); TEST5("bltzal", 11, 0x256, 13, 14); TEST5("bltzal", 12, 0x55, 14, 15); TEST5("bltzal", 13, 0xfff, 15, 16); TEST5("bltzal", 14, -1, 16, 17); TEST5("bltzal", 15, -1, 17, 18); printf("--- BNE --- if RSval != RTval then " \ "out = RDval + 1 else out = RDval + 6\n"); TEST3("bne", 0, 0, 1, 2, 3, 4); TEST3("bne", 1, 1, 1, 3, 4, 5); TEST3("bne", 2, 0xffffffff, 0xffffffff, 4, 5, 6); TEST3("bne", 3, 0xffffffff, 0xfffffffe, 5, 6, 7); TEST3("bne", 4, 0xfffffffe, 0xffffffff, 6, 7, 8); TEST3("bne", 5, 0xffffffff, 0xffffffff, 7, 8, 9); TEST3("bne", 6, 0x5, 0x5, 8, 9, 10); TEST3("bne", 7, -3, -4, 9, 10, 11); TEST3("bne", 8, 125, 125, 10, 11, 12); TEST3("bne", 9, 0x80000000, 0x80000000, 11, 12, 15); TEST3("bne", 10, 0xffffffff, 0x80000000, 12, 13, 14); TEST3("bne", 11, 0x256, 0x256, 13, 14, 15); TEST3("bne", 12, 0x55, 0x55, 14, 15, 16); TEST3("bne", 13, 0xfff, 0xdd, 15, 16, 17); TEST3("bne", 14, -1, 0x5, 16, 17, 18); TEST3("bne", 15, -1, -1, 17, 18, 19); printf("JAL, JR \n"); for (i = 0; i < N; i++) TEST2a(reg_val1[i], t0); printf("J, JALR \n"); for (i = 0; i < N; i++) TEST2b(reg_val1[i], t1); #endif return 0; }
int main() { int i; init_reg_val2(); for (i = 0; i < N; i++) { TEST1(reg_val1[i]); TEST2(reg_val1[i]); TEST1(reg_val2[i]); TEST2(reg_val2[i]); } printf("--- MOVF.S ---\n"); TEST3("movf.s $f4, $f6, $fcc0", f4, f6, 1, 0); TEST3("movf.s $f4, $f6, $fcc0", f4, f6, 1, 8); TEST3("movf.s $f4, $f6, $fcc0", f4, f6, 1, 16); TEST3("movf.s $f4, $f6, $fcc0", f4, f6, 1, 24); TEST3("movf.s $f4, $f6, $fcc0", f4, f6, 1, 32) TEST3("movf.s $f4, $f6, $fcc0", f4, f6, 1, 40) TEST3("movf.s $f4, $f6, $fcc0", f4, f6, 1, 48) TEST3("movf.s $f4, $f6, $fcc0", f4, f6, 1, 56) TEST3("movf.s $f4, $f6, $fcc0", f4, f6, 0, 0); TEST3("movf.s $f4, $f6, $fcc0", f4, f6, 0, 8); TEST3("movf.s $f4, $f6, $fcc0", f4, f6, 0, 16); TEST3("movf.s $f4, $f6, $fcc0", f4, f6, 0, 24); TEST3("movf.s $f4, $f6, $fcc0", f4, f6, 0, 32); TEST3("movf.s $f4, $f6, $fcc0", f4, f6, 0, 40); TEST3("movf.s $f4, $f6, $fcc0", f4, f6, 0, 48); TEST3("movf.s $f4, $f6, $fcc0", f4, f6, 0, 56); printf("--- MOVF.D ---\n"); TEST3d("movf.d $f4, $f6, $fcc0", f4, f6, 1, 0); TEST3d("movf.d $f4, $f6, $fcc0", f4, f6, 1, 8); TEST3d("movf.d $f4, $f6, $fcc0", f4, f6, 1, 16); TEST3d("movf.d $f4, $f6, $fcc0", f4, f6, 1, 24); TEST3d("movf.d $f4, $f6, $fcc0", f4, f6, 1, 32); TEST3d("movf.d $f4, $f6, $fcc0", f4, f6, 1, 40) TEST3d("movf.d $f4, $f6, $fcc0", f4, f6, 1, 48) TEST3d("movf.d $f4, $f6, $fcc0", f4, f6, 1, 56) TEST3d("movf.d $f4, $f6, $fcc0", f4, f6, 0, 0); TEST3d("movf.d $f4, $f6, $fcc0", f4, f6, 0, 8); TEST3d("movf.d $f4, $f6, $fcc0", f4, f6, 0, 16); TEST3d("movf.d $f4, $f6, $fcc0", f4, f6, 0, 24); TEST3d("movf.d $f4, $f6, $fcc0", f4, f6, 0, 32); TEST3d("movf.d $f4, $f6, $fcc0", f4, f6, 0, 40); TEST3d("movf.d $f4, $f6, $fcc0", f4, f6, 0, 48); TEST3d("movf.d $f4, $f6, $fcc0", f4, f6, 0, 56); printf("--- MOVN.S ---\n"); TEST4("movn.s $f0, $f2, $11", 0, 0, f0, f2, 11); TEST4("movn.s $f0, $f2, $11", 0, 1, f0, f2, 11); TEST4("movn.s $f0, $f2, $11", 8, 0xffff, f0, f2, 11); TEST4("movn.s $f0, $f2, $11", 16, -1, f0, f2, 11); TEST4("movn.s $f0, $f2, $11", 16, 5, f0, f2, 11); TEST4("movn.s $f0, $f2, $11", 24, 0, f0, f2, 11); TEST4("movn.s $f0, $f2, $11", 24, 0, f0, f2, 11); TEST4("movn.s $f0, $f2, $11", 32, 5, f0, f2, 11); TEST4("movn.s $f0, $f2, $11", 32, 125487, f0, f2, 11); TEST4("movn.s $f0, $f2, $11", 40, 68, f0, f2, 11); TEST4("movn.s $f0, $f2, $11", 40, -122544, f0, f2, 11); TEST4("movn.s $f0, $f2, $11", 48, 0, f0, f2, 11); TEST4("movn.s $f0, $f2, $11", 48, 0, f0, f2, 11); TEST4("movn.s $f0, $f2, $11", 56, 0xffffffff, f0, f2, 11); TEST4("movn.s $f0, $f2, $11", 56, 0x80000000, f0, f2, 11); TEST4("movn.s $f0, $f2, $11", 64, 0x7fffffff, f0, f2, 11); printf("--- MOVN.D ---\n"); TEST4d("movn.d $f0, $f2, $11", 0, 0, f0, f2, 11); TEST4d("movn.d $f0, $f2, $11", 0, 1, f0, f2, 11); TEST4d("movn.d $f0, $f2, $11", 8, 0xffff, f0, f2, 11); TEST4d("movn.d $f0, $f2, $11", 8, -1, f0, f2, 11); TEST4d("movn.d $f0, $f2, $11", 16, 5, f0, f2, 11); TEST4d("movn.d $f0, $f2, $11", 24, 0, f0, f2, 11); TEST4d("movn.d $f0, $f2, $11", 24, 0, f0, f2, 11); TEST4d("movn.d $f0, $f2, $11", 32, 5, f0, f2, 11); TEST4d("movn.d $f0, $f2, $11", 32, 125487, f0, f2, 11); TEST4d("movn.d $f0, $f2, $11", 40, 68, f0, f2, 11); TEST4d("movn.d $f0, $f2, $11", 40, -122544, f0, f2, 11); TEST4d("movn.d $f0, $f2, $11", 48, 0, f0, f2, 11); TEST4d("movn.d $f0, $f2, $11", 48, 0, f0, f2, 11); TEST4d("movn.d $f0, $f2, $11", 56, 0xffffffff, f0, f2, 11); TEST4d("movn.d $f0, $f2, $11", 56, 0x80000000, f0, f2, 11); TEST4d("movn.d $f0, $f2, $11", 64, 0x7fffffff, f0, f2, 11); printf("--- MOVT.S ---\n"); TEST3("movt.s $f4, $f6, $fcc0", f4, f6, 1, 0); TEST3("movt.s $f4, $f6, $fcc0", f4, f6, 1, 0); TEST3("movt.s $f4, $f6, $fcc0", f4, f6, 1, 8); TEST3("movt.s $f4, $f6, $fcc0", f4, f6, 1, 16); TEST3("movt.s $f4, $f6, $fcc0", f4, f6, 1, 24); TEST3("movt.s $f4, $f6, $fcc0", f4, f6, 1, 32); TEST3("movt.s $f4, $f6, $fcc0", f4, f6, 1, 40) TEST3("movt.s $f4, $f6, $fcc0", f4, f6, 1, 48) TEST3("movt.s $f4, $f6, $fcc0", f4, f6, 1, 56) TEST3("movt.s $f4, $f6, $fcc0", f4, f6, 0, 0); TEST3("movt.s $f4, $f6, $fcc0", f4, f6, 0, 8); TEST3("movt.s $f4, $f6, $fcc0", f4, f6, 0, 16); TEST3("movt.s $f4, $f6, $fcc0", f4, f6, 0, 24); TEST3("movt.s $f4, $f6, $fcc0", f4, f6, 0, 32); TEST3("movt.s $f4, $f6, $fcc0", f4, f6, 0, 40); TEST3("movt.s $f4, $f6, $fcc0", f4, f6, 0, 48); TEST3("movt.s $f4, $f6, $fcc0", f4, f6, 0, 56); printf("--- MOVT.D ---\n"); TEST3d("movt.d $f4, $f6, $fcc0", f4, f6, 1, 0); TEST3d("movt.d $f4, $f6, $fcc0", f4, f6, 1, 0); TEST3d("movt.d $f4, $f6, $fcc0", f4, f6, 1, 8); TEST3d("movt.d $f4, $f6, $fcc0", f4, f6, 1, 16); TEST3d("movt.d $f4, $f6, $fcc0", f4, f6, 1, 24); TEST3d("movt.d $f4, $f6, $fcc0", f4, f6, 1, 32); TEST3d("movt.d $f4, $f6, $fcc0", f4, f6, 1, 40) TEST3d("movt.d $f4, $f6, $fcc0", f4, f6, 1, 48) TEST3d("movt.d $f4, $f6, $fcc0", f4, f6, 1, 56) TEST3d("movt.d $f4, $f6, $fcc0", f4, f6, 0, 0); TEST3d("movt.d $f4, $f6, $fcc0", f4, f6, 0, 8); TEST3d("movt.d $f4, $f6, $fcc0", f4, f6, 0, 16); TEST3d("movt.d $f4, $f6, $fcc0", f4, f6, 0, 24); TEST3d("movt.d $f4, $f6, $fcc0", f4, f6, 0, 32); TEST3d("movt.d $f4, $f6, $fcc0", f4, f6, 0, 40); TEST3d("movt.d $f4, $f6, $fcc0", f4, f6, 0, 48); TEST3d("movt.d $f4, $f6, $fcc0", f4, f6, 0, 56); printf("--- MOVZ.S ---\n"); TEST4("movz.s $f0, $f2, $11", 0, 0, f0, f2, 11); TEST4("movz.s $f0, $f2, $11", 8, 1, f0, f2, 11); TEST4("movz.s $f0, $f2, $11", 8, 0xffff, f0, f2, 11); TEST4("movz.s $f0, $f2, $11", 16, -1, f0, f2, 11); TEST4("movz.s $f0, $f2, $11", 16, 5, f0, f2, 11); TEST4("movz.s $f0, $f2, $11", 24, 0, f0, f2, 11); TEST4("movz.s $f0, $f2, $11", 24, 0, f0, f2, 11); TEST4("movz.s $f0, $f2, $11", 32, 5, f0, f2, 11); TEST4("movz.s $f0, $f2, $11", 32, 125487, f0, f2, 11); TEST4("movz.s $f0, $f2, $11", 40, 68, f0, f2, 11); TEST4("movz.s $f0, $f2, $11", 40, -122544, f0, f2, 11); TEST4("movz.s $f0, $f2, $11", 48, 0, f0, f2, 11); TEST4("movz.s $f0, $f2, $11", 48, 0, f0, f2, 11); TEST4("movz.s $f0, $f2, $11", 56, 0xffffffff, f0, f2, 11); TEST4("movz.s $f0, $f2, $11", 56, 0x80000000, f0, f2, 11); TEST4("movz.s $f0, $f2, $11", 64, 0x7fffffff, f0, f2, 11); printf("--- MOVZ.D ---\n"); TEST4d("movz.d $f0, $f2, $11", 0, 0, f0, f2, 11); TEST4d("movz.d $f0, $f2, $11", 0, 1, f0, f2, 11); TEST4d("movz.d $f0, $f2, $11", 8, 0xffff, f0, f2, 11); TEST4d("movz.d $f0, $f2, $11", 16, -1, f0, f2, 11); TEST4d("movz.d $f0, $f2, $11", 16, 5, f0, f2, 11); TEST4d("movz.d $f0, $f2, $11", 24, 0, f0, f2, 11); TEST4d("movz.d $f0, $f2, $11", 24, 0, f0, f2, 11); TEST4d("movz.d $f0, $f2, $11", 32, 5, f0, f2, 11); TEST4d("movz.d $f0, $f2, $11", 32, 125487, f0, f2, 11); TEST4d("movz.d $f0, $f2, $11", 40, 68, f0, f2, 11); TEST4d("movz.d $f0, $f2, $11", 40, -122544, f0, f2, 11); TEST4d("movz.d $f0, $f2, $11", 48, 0, f0, f2, 11); TEST4d("movz.d $f0, $f2, $11", 48, 0, f0, f2, 11); TEST4d("movz.d $f0, $f2, $11", 56, 0xffffffff, f0, f2, 11); TEST4d("movz.d $f0, $f2, $11", 56, 0x80000000, f0, f2, 11); TEST4d("movz.d $f0, $f2, $11", 64, 0x7fffffff, f0, f2, 11); printf("--- MOVF --- if FPConditionalCode(cc) == 0 then " "out = RSval else out = RDval\n"); for (i = 0; i < 24; i++) { TEST5("movf", 0xaaaaaaaa, 0x80000000, t0, t1); TEST5("movf", 0xccccffff, 0xffffffff, t1, t2); TEST5("movf", 0xffffaaaa, 0xaaaaffff, t3, t1); TEST5("movf", 0x0, 0xffffffff, t3, t0); } printf("--- MOVT --- if FPConditionalCode(cc) == 1 then " "out = RSval else out = RDval\n"); for (i = 0; i < 24; i++) { TEST5("movt", 0x0, 0xffffffff, t0, t1); TEST5("movt", 0x11111111, 0xeeeeffff, t1, t2); TEST5("movt", 0x5555ffff, 0xffffffff, t3, t1); TEST5("movt", 0xeeeeeeee, 0xffffeeee, t3, t0); } return 0; }
int main() { fs_hash_init(FS_HASH_UMAC); int passes = 0; int fails = 0; #if 1 #define DUMP(t) printf("%lld %s\n", fs_c.xsd_##t, #t); DUMP(double); DUMP(float); DUMP(decimal); DUMP(integer); DUMP(boolean); #endif #define TEST1(f, a, x) printf("[%s] ", fs_value_equal(f(NULL, a), x) ? "PASS" : "FAIL"); printf("%s(", #f); fs_value_print(a); printf(") = "); fs_value_print(f(NULL, a)); printf("\n"); if (!fs_value_equal(f(NULL, a), x)) { fails++; printf(" should have been "); fs_value_print(x); printf("\n"); } else { passes++; } #define TEST2(f, a, b, x) printf("[%s] ", fs_value_equal(f(NULL, a, b), x) ? "PASS" : "FAIL"); printf("%s(", #f); fs_value_print(a); printf(", "); fs_value_print(b); printf(") = "); fs_value_print(f(NULL, a, b)); printf("\n"); if (!fs_value_equal(f(NULL, a, b), x)) { fails++; printf(" should have been "); fs_value_print(x); printf("\n"); } else { passes++; } #define TEST3(f, a, b, c, x) printf("[%s] ", fs_value_equal(f(NULL, a, b, c), x) ? "PASS" : "FAIL"); printf("%s(", #f); fs_value_print(a); printf(", "); fs_value_print(b); printf(", "); fs_value_print(c); printf(") = "); fs_value_print(f(NULL, a, b, c)); printf("\n"); if (!fs_value_equal(f(NULL, a, b, c), x)) { fails++; printf(" should have been "); fs_value_print(x); printf("\n"); } else { passes++; } #define URI(x) fs_value_uri(x) #define RID(x) fs_value_rid(x) #define BND(x) fs_value_rid(0x8000000000000000LL | x) #define STR(x) fs_value_string(x) #define PLN(x) fs_value_plain(x) #define PLN_L(x, l) fs_value_plain_with_lang(x, l) #define DBL(x) fs_value_double(x) #define FLT(x) fs_value_float(x) #define DEC(x) fs_value_decimal(x) #define INT(x) fs_value_integer(x) #define BLN(x) fs_value_boolean(x) #define DAT(x) fs_value_datetime(x) #define DAT_S(x) fs_value_datetime_from_string(x) #define ERR() fs_value_error(FS_ERROR_INVALID_TYPE, NULL) #define BLK() fs_value_blank() TEST2(fn_numeric_add, BLK(), BLK(), ERR()); TEST2(fn_numeric_add, INT(1), URI("test:"), ERR()); TEST2(fn_numeric_add, STR("2"), INT(3), ERR()); TEST2(fn_numeric_add, INT(2), INT(3), INT(5)); TEST2(fn_numeric_add, DEC(2.5), DEC(-1), DEC(1.5)); TEST2(fn_numeric_add, DEC(-2.5), DEC(-1.5), DEC(-4)); TEST2(fn_numeric_subtract, INT(2), INT(3), INT(-1)); TEST2(fn_numeric_add, DBL(1), INT(2), DBL(3)); TEST2(fn_numeric_add, FLT(17000), INT(2), FLT(17002)); TEST2(fn_numeric_subtract, FLT(17000), INT(2), FLT(16998)); TEST2(fn_numeric_subtract, DEC(17000.5), INT(2), DEC(16998.5)); TEST2(fn_numeric_multiply, URI("http://example.com/"), INT(2), ERR()); TEST2(fn_numeric_multiply, DEC(3.5), INT(2), DEC(7)); TEST2(fn_numeric_multiply, DEC(35), DBL(-0.1), DBL(-3.5)); TEST2(fn_numeric_multiply, INT(1), FLT(23), FLT(23)); TEST2(fn_numeric_multiply, INT(10), INT(23), INT(230)); TEST2(fn_numeric_divide, INT(9), URI("http://example.org/"), ERR()); TEST2(fn_numeric_divide, INT(9), INT(2), DEC(4.5)); TEST2(fn_numeric_divide, INT(-9), INT(2), DEC(-4.5)); TEST2(fn_numeric_divide, INT(-9), INT(-2), DEC(4.5)); TEST2(fn_numeric_divide, DBL(90), FLT(10), DBL(9)); TEST2(fn_numeric_divide, FLT(99), FLT(-10), FLT(-9.9)); TEST2(fn_equal, URI("http://example.com/"), DEC(23), BLN(0)); TEST2(fn_equal, URI("http://example.com/"), URI("http://example.com/"), BLN(1)); TEST2(fn_equal, INT(23), DEC(23), BLN(1)); TEST2(fn_equal, fs_value_decimal_from_string("-23.0"), DEC(-23), BLN(1)); TEST2(fn_equal, STR("foo"), PLN("foo"), BLN(0)); TEST2(fn_equal, PLN("foo"), PLN("foo"), BLN(1)); TEST2(fn_equal, BLN(0), BLN(0), BLN(1)); TEST2(fn_greater_than, STR("BBB"), STR("AAA"), BLN(1)); TEST2(fn_greater_than, PLN("BBB"), PLN("AAA"), BLN(1)); TEST2(fn_greater_than, PLN("AAA"), PLN("BBB"), BLN(0)); TEST2(fn_less_than, PLN("BBB"), PLN("AAA"), BLN(0)); TEST2(fn_less_than, PLN("AAA"), PLN("BBB"), BLN(1)); TEST2(fn_less_than, INT(20), INT(15), BLN(0)); TEST2(fn_numeric_equal, INT(23), INT(23), BLN(1)); TEST2(fn_numeric_equal, INT(23), DEC(23), BLN(1)); TEST2(fn_numeric_equal, INT(23), FLT(23), BLN(1)); TEST2(fn_numeric_equal, INT(23), DBL(23), BLN(1)); TEST2(fn_numeric_equal, fn_minus(NULL, INT(23)), DBL(-23), BLN(1)); TEST2(fn_datetime_equal, DAT(1000), DAT(1000), BLN(1)); TEST2(fn_datetime_equal, DAT(time(NULL)), DAT(1000), BLN(0)); TEST2(fn_numeric_less_than, INT(0), DBL(23), BLN(1)); TEST2(fn_numeric_less_than, INT(23), DBL(23), BLN(0)); TEST2(fn_numeric_less_than, DBL(22.99999), INT(23), BLN(1)); TEST2(fn_numeric_less_than, DEC(-18.51), DEC(-18.5), BLN(1)); TEST2(fn_numeric_less_than, DBL(-18.51), DBL(-18.5), BLN(1)); TEST2(fn_numeric_less_than, DEC(-18.5), DEC(-18.51), BLN(0)); TEST2(fn_numeric_less_than, DBL(-18.5), DBL(-18.51), BLN(0)); TEST2(fn_numeric_greater_than, DEC(-121.98882), DEC(-121.739856), BLN(0)); TEST2(fn_numeric_greater_than, DEC(37.67473), DEC(37.677954), BLN(0)); TEST2(fn_numeric_greater_than, INT(0), DBL(23), BLN(0)); TEST2(fn_numeric_greater_than, INT(23), DBL(23), BLN(0)); TEST2(fn_numeric_greater_than, DBL(22.99999), INT(23), BLN(0)); TEST2(fn_numeric_greater_than, DEC(-18.51), DEC(-18.5), BLN(0)); TEST2(fn_numeric_greater_than, DBL(-18.51), DBL(-18.5), BLN(0)); TEST2(fn_numeric_greater_than, DEC(-18.5), DEC(-18.51), BLN(1)); TEST2(fn_numeric_greater_than, DBL(-18.5), DBL(-18.51), BLN(1)); TEST2(fn_logical_and, BLN(1), BLN(0), BLN(0)); TEST2(fn_logical_and, BLN(1), BLN(1), BLN(1)); TEST2(fn_logical_and, INT(0), INT(1), BLN(0)); TEST2(fn_logical_and, INT(1), INT(1), BLN(1)); TEST2(fn_logical_and, STR("true"), INT(1), BLN(1)); TEST2(fn_logical_and, STR("false"), INT(1), BLN(1)); TEST2(fn_logical_and, INT(1), ERR(), ERR()); TEST2(fn_logical_and, ERR(), INT(1), ERR()); TEST2(fn_logical_and, INT(0), ERR(), BLN(0)); TEST2(fn_logical_and, ERR(), INT(0), BLN(0)); TEST2(fn_logical_and, ERR(), ERR(), ERR()); TEST2(fn_logical_or, BLN(1), BLN(0), BLN(1)); TEST2(fn_logical_or, BLN(1), BLN(1), BLN(1)); TEST2(fn_logical_or, INT(0), INT(1), BLN(1)); TEST2(fn_logical_or, INT(1), INT(1), BLN(1)); TEST2(fn_logical_or, STR("true"), INT(32), BLN(1)); TEST2(fn_logical_or, STR("false"), INT(1), BLN(1)); TEST2(fn_logical_or, INT(1), ERR(), BLN(1)); TEST2(fn_logical_or, ERR(), INT(1), BLN(1)); TEST2(fn_logical_or, INT(0), ERR(), ERR()); TEST2(fn_logical_or, ERR(), INT(0), ERR()); TEST2(fn_logical_or, ERR(), ERR(), ERR()); TEST2(fn_compare, STR("AAA"), STR("BBB"), INT(-1)); TEST2(fn_compare, STR("BBB"), STR("BBB"), INT(0)); TEST2(fn_compare, STR("BBB"), STR("AAA"), INT(1)); TEST2(fn_compare, PLN("BBB"), PLN("AAA"), INT(1)); TEST2(fn_compare, STR("BBB"), PLN("BBB"), ERR()); TEST2(fn_compare, STR("http://example.com/"), URI("http://example.com/"), ERR()); TEST2(fn_compare, URI("http://example.com/"), URI("http://example.com/"), ERR()); TEST2(fn_compare, INT(1), PLN("BBB"), ERR()); TEST3(fn_matches, PLN("foobar"), PLN("foo"), BLK(), BLN(1)); TEST3(fn_matches, PLN("foobar"), PLN("^foo"), BLK(), BLN(1)); TEST3(fn_matches, PLN("foobar"), PLN("bar$"), BLK(), BLN(1)); TEST3(fn_matches, PLN("foobar"), PLN("BAR"), STR("i"), BLN(1)); TEST3(fn_matches, PLN("foobar"), PLN("^FOOB[AO]R$"), STR("i"), BLN(1)); TEST3(fn_matches, PLN("foobar"), PLN("^bar"), BLK(), BLN(0)); TEST3(fn_matches, PLN("foobar"), PLN("^foo$"), BLK(), BLN(0)); TEST3(fn_matches, PLN("foobar"), PLN("foo bar"), PLN("x"), BLN(1)); TEST3(fn_matches, INT(23), PLN("foo bar"), PLN("x"), ERR()); TEST3(fn_matches, PLN("foobar"), DAT(1000), PLN("x"), ERR()); TEST1(fn_bound, URI("http://example.com/"), BLN(1)); TEST1(fn_bound, STR("http"), BLN(1)); TEST1(fn_bound, PLN(""), BLN(1)); TEST1(fn_bound, BND(100), BLN(1)); TEST1(fn_bound, RID(FS_RID_NULL), BLN(0)); TEST1(fn_is_blank, URI("http://example.com/"), BLN(0)); TEST1(fn_is_blank, STR("http"), BLN(0)); TEST1(fn_is_blank, PLN(""), BLN(0)); TEST1(fn_is_blank, BND(100), BLN(1)); TEST1(fn_is_blank, RID(FS_RID_NULL), BLN(0)); TEST1(fn_is_iri, URI("http://example.com/"), BLN(1)); TEST1(fn_is_iri, STR("http"), BLN(0)); TEST1(fn_is_iri, PLN(""), BLN(0)); TEST1(fn_is_iri, BND(100), BLN(0)); TEST1(fn_is_iri, RID(FS_RID_NULL), BLN(0)); TEST1(fn_is_literal, URI("http://example.com/"), BLN(0)); TEST1(fn_is_literal, STR("http"), BLN(1)); TEST1(fn_is_literal, PLN(""), BLN(1)); TEST1(fn_is_literal, BND(100), BLN(0)); TEST1(fn_is_literal, RID(FS_RID_NULL), BLN(0)); TEST1(fn_str, URI("http://example.com/"), PLN("http://example.com/")); TEST1(fn_str, STR("http"), PLN("http")); TEST1(fn_str, PLN(""), PLN("")); TEST1(fn_str, BLN(1), PLN("true")); TEST1(fn_str, INT(1), PLN("1")); TEST1(fn_str, FLT(11.1), PLN("11.100000")); TEST1(fn_str, DBL(11.1), PLN("11.100000")); TEST1(fn_str, DEC(23), PLN("23.000000")); TEST1(fn_str, DAT(1000), PLN("1970-01-01T00:16:40")); TEST1(fn_str, BND(100), ERR()); TEST1(fn_str, RID(FS_RID_NULL), ERR()); TEST1(fn_lang, PLN("foo"), PLN("")); TEST1(fn_lang, STR("foo"), PLN("")); TEST1(fn_lang, PLN_L("foo", "en"), PLN("en")); TEST1(fn_lang, PLN_L("foo", ""), PLN("")); TEST1(fn_lang, BLN(1), PLN("")); TEST1(fn_lang, INT(1), PLN("")); TEST1(fn_lang, DEC(1.1), PLN("")); TEST1(fn_lang, FLT(1.1), PLN("")); TEST1(fn_lang, DBL(1.1), PLN("")); TEST1(fn_lang, URI("http://example.org/"), ERR()); TEST1(fn_datatype, PLN("foo"), ERR()); TEST1(fn_datatype, STR("foo"), URI(XSD_STRING)); TEST1(fn_datatype, PLN_L("foo", "en"), ERR()); TEST1(fn_datatype, PLN_L("foo", ""), ERR()); TEST1(fn_datatype, BLN(1), URI(XSD_BOOLEAN)); TEST1(fn_datatype, INT(1), URI(XSD_INTEGER)); TEST1(fn_datatype, DEC(1.1), URI(XSD_DECIMAL)); TEST1(fn_datatype, FLT(1.1), URI(XSD_FLOAT)); TEST1(fn_datatype, DBL(1.1), URI(XSD_DOUBLE)); TEST1(fn_datatype, DAT(1000), URI(XSD_DATETIME)); TEST1(fn_datatype, URI("http://example.org/"), ERR()); TEST2(fn_equal, DAT_S("1975-01-07"), DAT(158284800), BLN(1)); TEST2(fn_equal, DAT_S("1975-01-07T00:00:01"), DAT(158284801), BLN(1)); TEST2(fn_equal, DAT_S("1975-01-07T01:00:01+0000"), DAT(158288401), BLN(1)); TEST2(fn_equal, DAT_S("1975-01-07T01:00:01-0900"), DAT(158320801), BLN(1)); TEST2(fn_cast, DBL(2.1), URI(XSD_INTEGER), INT(2)); TEST2(fn_cast, PLN("2.23"), URI(XSD_DOUBLE), DBL(2.23)); TEST2(fn_cast, PLN_L("2.23", "en"), URI(XSD_DOUBLE), DBL(2.23)); TEST2(fn_cast, STR("2.23"), URI(XSD_DOUBLE), DBL(2.23)); TEST2(fn_cast, URI("http://example.com/"), URI(XSD_STRING), ERR()); TEST2(fn_cast, DAT(1000), URI(XSD_STRING), STR("1970-01-01T00:16:40")); TEST2(fn_cast, STR("1975-01-07T01:00:01-0900"), URI(XSD_DATETIME), DAT(158320801)); printf("\n=== pass %d, fail %d\n", passes, fails); if (fails) { return 1; } return 0; }
int main() { arithmetic_op op; int i; init_reg_val2(); for (op = ADD; op <= SUBU; op++) { for (i = 0; i < N; i++) { switch(op) { case ADD: /* If either GPR rt or GPR rs does not contain sign-extended 32-bit values (bits 63..31 equal), then the result of the operation is UNPREDICTABLE. */ TEST1("add $t0, $t1, $t2", reg_val1[i], reg_val1[N-i-1], t0, t1, t2); break; case ADDI: /* If GPR rs does not contain a sign-extended 32-bit value (bits 63..31 equal), then the result of the operation is UNPREDICTABLE. */ TEST2("addi $t0, $t1, 0xff", reg_val1[i], 0xff, t0, t1); TEST2("addi $t2, $t3, 0xffff", reg_val1[i], 0xffff, t2, t3); TEST2("addi $a0, $a1, 0x0", reg_val1[i], 0x0, a0, a1); TEST2("addi $s0, $s1, 0x23", reg_val1[i], 0x23, s0, s1); break; case ADDIU: /* If GPR rs does not contain a sign-extended 32-bit value (bits 63..31 equal), then the result of the operation is UNPREDICTABLE. */ TEST2("addiu $t0, $t1, 0xff", reg_val1[i], 0xff, t0, t1); TEST2("addiu $t2, $t3, 0xffff", reg_val1[i], 0xffff, t2, t3); TEST2("addiu $a0, $a1, 0x0", reg_val1[i], 0x0, a0, a1); TEST2("addiu $s0, $s1, 0x23", reg_val1[i], 0x23, s0, s1); break; case ADDU: /* If either GPR rt or GPR rs does not contain sign-extended 32-bit values (bits 63..31 equal), then the result of the operation is UNPREDICTABLE. */ TEST1("addu $t0, $t1, $t2", reg_val1[i], reg_val1[N-i-1], t0, t1, t2); break; case CLO: /* If GPR rs does not contain a sign-extended 32-bit value (bits 63..31 equal), then the results of the operation are UNPREDICTABLE. */ TEST3("clo $t0, $t1", reg_val1[i], t0, t1); break; case CLZ: /* If GPR rs does not contain a sign-extended 32-bit value (bits 63..31 equal), then the results of the operation are UNPREDICTABLE. */ TEST3("clz $t0, $t1", reg_val1[i], t0, t1); break; case DADD: /* If the addition results in 64-bit 2âs complement arithmetic overflow, then the destination register is not modified and an IntegerOverflow exception occurs. */ TEST1("dadd $t0, $t1, $t2", reg_val1[i], reg_val1[N-i-1], t0, t1, t2); break; case DADDI: /* If the addition results in 64-bit 2âs complement arithmetic overflow, then the destination register is not modified and an Integer Overflow exception occurs. */ TEST2("daddi $t0, $t1, 0xff", reg_val1[i], 0xff, t0, t1); TEST2("daddi $t2, $t3, 0xffff", reg_val1[i], 0xffff, t2, t3); TEST2("daddi $a0, $a1, 0x0", reg_val1[i], 0x0, a0, a1); TEST2("daddi $s0, $s1, 0x23", reg_val1[i], 0x23, s0, s1); TEST2("daddi $t0, $t1, 0xff", reg_val2[i], 0xff, t0, t1); TEST2("daddi $t2, $t3, 0xffff", reg_val2[i], 0xffff, t2, t3); TEST2("daddi $a0, $a1, 0x0", reg_val2[i], 0x0, a0, a1); TEST2("daddi $s0, $s1, 0x23", reg_val2[i], 0x23, s0, s1); break; case DADDIU: /* No Integer Overflow exception occurs under any circumstances. */ TEST2("daddiu $t0, $t1, 0xff", reg_val1[i], 0xff, t0, t1); TEST2("daddiu $t2, $t3, 0xffff", reg_val1[i], 0xffff, t2, t3); TEST2("daddiu $a0, $a1, 0x0", reg_val1[i], 0x0, a0, a1); TEST2("daddiu $s0, $s1, 0x23", reg_val1[i], 0x23, s0, s1); TEST2("daddiu $t0, $t1, 0xff", reg_val2[i], 0xff, t0, t1); TEST2("daddiu $t2, $t3, 0xffff", reg_val2[i], 0xffff, t2, t3); TEST2("daddiu $a0, $a1, 0x0", reg_val2[i], 0x0, a0, a1); TEST2("daddiu $s0, $s1, 0x23", reg_val2[i], 0x23, s0, s1); break; case DADDU: /* No Integer Overflow exception occurs under any circumstances. */ TEST1("daddu $t0, $t1, $t2", reg_val1[i], reg_val1[N-i-1], t0, t1, t2); TEST1("daddu $s0, $s1, $s2", reg_val2[i], reg_val2[N-i-1], s0, s1, s2); break; case DCLO: /* No arithmetic exception occurs under any circumstances. */ TEST3("dclo $t0, $t1", reg_val1[i], t0, t1); TEST3("dclo $v0, $v1", reg_val2[i], v0, v1); break; case DCLZ: /* No arithmetic exception occurs under any circumstances. */ TEST3("dclz $t0, $t1", reg_val1[i], t0, t1); TEST3("dclz $v0, $v1", reg_val2[i], v0, v1); break; case DDIV: /* If the divisor in GPR rt is zero, the arithmetic result value is UNPREDICTABLE. */ if (reg_val1[N-i-1] != 0) TEST4("ddiv $t0, $t1", reg_val1[i], reg_val1[N-i-1], t0, t1); if (reg_val2[N-i-1] != 0) TEST4("ddiv $v0, $v1", reg_val2[i], reg_val2[N-i-1], v0, v1); break; case DDIVU: /* If the divisor in GPR rt is zero, the arithmetic result value is UNPREDICTABLE. */ if (reg_val1[N-i-1] != 0) TEST4("ddivu $t0, $t1", reg_val1[i], reg_val1[N-i-1], t0, t1); if (reg_val2[N-i-1] != 0) TEST4("ddivu $v0, $v1", reg_val2[i], reg_val2[N-i-1], v0, v1); break; case DIV: /* If either GPR rt or GPR rs does not contain sign-extended 32-bit values (bits 63..31 equal), then the result of the operation is UNPREDICTABLE. If the divisor in GPR rt is zero, the arithmetic result value is UNPREDICTABLE. */ if (reg_val1[N-i-1] != 0) TEST4("div $t0, $t1", reg_val1[i], reg_val1[N-i-1], t0, t1); break; case DIVU: /* If either GPR rt or GPR rs does not contain sign-extended 32-bit values (bits 63..31 equal), then the result of the operation is UNPREDICTABLE. If the divisor in GPR rt is zero, the arithmetic result value is UNPREDICTABLE. */ if (reg_val1[N-i-1] != 0) TEST4("divu $t0, $t1", reg_val1[i], reg_val1[N-i-1], t0, t1); break; case DMULT: /* No arithmetic exception occurs under any circumstances. */ TEST4("dmult $t0, $t1", reg_val1[i], reg_val1[N-i-1], t0, t1); TEST4("dmult $v0, $v1", reg_val2[i], reg_val2[N-i-1], v0, v1); break; case DMULTU: /* No arithmetic exception occurs under any circumstances. */ TEST4("dmultu $t0, $t1", reg_val1[i], reg_val1[N-i-1], t0, t1); TEST4("dmultu $v0, $v1", reg_val2[i], reg_val2[N-i-1], v0, v1); break; case DSUB: /* If the subtraction results in 64-bit 2âs complement arithmetic overflow, then the destination register is not modified and an Integer Overflow exception occurs. */ TEST1("dsub $t0, $t1, $t2", reg_val1[i], reg_val1[N-i-1], t0, t1, t2); break; case DSUBU: /* No Integer Overflow exception occurs under any circumstances. */ TEST1("dsubu $t0, $t1, $t2", reg_val1[i], reg_val1[N-i-1], t0, t1, t2); TEST1("dsubu $s0, $s1, $s2", reg_val2[i], reg_val2[N-i-1], s0, s1, s2); break; case MADD: /* If GPRs rs or rt do not contain sign-extended 32-bit values (bits 63..31 equal), then the results of the operation are UNPREDICTABLE. */ TEST5("madd $t0, $t1", reg_val1[i], reg_val1[N-i-1], t0, t1); break; case MADDU: /* If GPRs rs or rt do not contain sign-extended 32-bit values (bits 63..31 equal), then the results of the operation are UNPREDICTABLE. */ TEST5("maddu $t0, $t1", reg_val1[i], reg_val1[N-i-1], t0, t1); break; case MSUB: /* If GPR rs or rt do not contain a sign-extended 32-bit value (bits 63..31 equal), then the results of the operation are UNPREDICTABLE. */ TEST5("msub $t0, $t1", reg_val1[i], reg_val1[N-i-1], t0, t1); break; case MSUBU: /* If GPRs rs or rt do not contain sign-extended 32-bit values (bits 63..31 equal), then the results of the operation are UNPREDICTABLE. This instruction does not provide the capability of writing directly to a target GPR. */ TEST5("msubu $t0, $t1", reg_val1[i], reg_val1[N-i-1], t0, t1); break; case MUL: /* On 64-bit processors, if either GPR rt or GPR rs does not contain sign-extended 32-bit values (bits 63..31 equal), then the result of the operation is UNPREDICTABLE. */ TEST1("mul $t0, $t1, $t2", reg_val1[i], reg_val1[N-i-1], t0, t1, t2); break; case MULT: /* On 64-bit processors, if either GPR rt or GPR rs does not contain sign-extended 32-bit values (bits 63..31 equal), then the result of the operation is UNPREDICTABLE. */ TEST4("mult $t0, $t1", reg_val1[i], reg_val1[N-i-1], t0, t1); break; case MULTU: /* On 64-bit processors, if either GPR rt or GPR rs does not contain sign-extended 32-bit values (bits 63..31 equal), then the result of the operation is UNPREDICTABLE. */ TEST4("multu $t0, $t1", reg_val1[i], reg_val1[N-i-1], t0, t1); break; case MOVN: /* The arithmetic comparison does not cause an Integer Overflow exception. */ TEST1("movn $t0, $t1, $t2", reg_val1[i], reg_val1[N-i-1], t0, t1, t2); TEST1("movn $s0, $s1, $s2", reg_val2[i], reg_val2[N-i-1], s0, s1, s2); break; case MOVZ: /* The arithmetic comparison does not cause an Integer Overflow exception. */ TEST1("movz $t0, $t1, $t2", reg_val1[i], reg_val1[N-i-1], t0, t1, t2); TEST1("movz $s0, $s1, $s2", reg_val2[i], reg_val2[N-i-1], s0, s1, s2); break; case SEB: #if (__mips==64) && (__mips_isa_rev>=2) /* If GPR rt does not contain a sign-extended 32-bit value (bits 63..31 equal), then the result of the operation is UNPREDICTABLE. */ TEST3("seb $t0, $t1", reg_val1[i], t0, t1); #endif break; case SEH: #if (__mips==64) && (__mips_isa_rev>=2) /* If GPR rt does not contain a sign-extended 32-bit value (bits 63..31 equal), then the result of the operation is UNPREDICTABLE. */ TEST3("seh $t0, $t1", reg_val1[i], t0, t1); #endif break; case SLT: /* The arithmetic comparison does not cause an Integer Overflow exception. */ TEST1("slt $t0, $t1, $t2", reg_val1[i], reg_val1[N-i-1], t0, t1, t2); break; case SLTI: /* The arithmetic comparison does not cause an Integer Overflow exception. */ TEST2("slti $t0, $t1, 0xff", reg_val1[i], 0xff, t0, t1); TEST2("slti $t2, $t3, 0xffff", reg_val1[i], 0xffff, t2, t3); TEST2("slti $a0, $a1, 0x0", reg_val1[i], 0x0, a0, a1); TEST2("slti $s0, $s1, 0x23", reg_val1[i], 0x23, s0, s1); TEST2("slti $t0, $t1, 0xff", reg_val2[i], 0xff, t0, t1); TEST2("slti $t2, $t3, 0xffff", reg_val2[i], 0xffff, t2, t3); TEST2("slti $a0, $a1, 0x0", reg_val2[i], 0x0, a0, a1); TEST2("slti $s0, $s1, 0x23", reg_val2[i], 0x23, s0, s1); break; case SLTIU: /* The arithmetic comparison does not cause an Integer Overflow exception. */ TEST2("sltiu $t0, $t1, 0xff", reg_val1[i], 0xff, t0, t1); TEST2("sltiu $t2, $t3, 0xffff", reg_val1[i], 0xffff, t2, t3); TEST2("sltiu $a0, $a1, 0x0", reg_val1[i], 0x0, a0, a1); TEST2("sltiu $s0, $s1, 0x23", reg_val1[i], 0x23, s0, s1); TEST2("sltiu $t0, $t1, 0xff", reg_val2[i], 0xff, t0, t1); TEST2("sltiu $t2, $t3, 0xffff", reg_val2[i], 0xffff, t2, t3); TEST2("sltiu $a0, $a1, 0x0", reg_val2[i], 0x0, a0, a1); TEST2("sltiu $s0, $s1, 0x23", reg_val2[i], 0x23, s0, s1); break; case SLTU: /* The arithmetic comparison does not cause an Integer Overflow exception. */ TEST1("sltu $t0, $t1, $t2", reg_val1[i], reg_val1[N-i-1], t0, t1, t2); TEST1("sltu $s0, $s1, $s2", reg_val2[i], reg_val2[N-i-1], s0, s1, s2); break; case SUB: /* On 64-bit processors, if either GPR rt or GPR rs does not contain sign-extended 32-bit values (bits 63..31 equal), then the result of the operation is UNPREDICTABLE. */ if (i < 8 || (i > 15 && i < 22)) TEST1("sub $t0, $t1, $t2", reg_val1[i], reg_val1[N-i-1], t0, t1, t2); break; case SUBU: /* On 64-bit processors, if either GPR rt or GPR rs does not contain sign-extended 32-bit values (bits 63..31 equal), then the result of the operation is UNPREDICTABLE. */ TEST1("subu $t0, $t1, $t2", reg_val1[i], reg_val1[N-i-1], t0, t1, t2); break; default: printf("Error!\n"); break; } } } return 0; }