]> git.unchartedbackwaters.co.uk Git - francis/winuae.git/commitdiff
CPU tester test instruction branch indicator.
authorToni Wilen <twilen@winuae.net>
Sun, 17 May 2020 15:56:04 +0000 (18:56 +0300)
committerToni Wilen <twilen@winuae.net>
Sun, 17 May 2020 15:56:04 +0000 (18:56 +0300)
cputest.cpp
cputest/cputest_defines.h
cputest/main.c
cputest/readme.txt

index 5db677051dd336e1a5d1a9511f9dbe28744b9547..b7a0b3b7fb44fd5cadae2c43d1ca1c9d426cc22a 100644 (file)
@@ -5210,19 +5210,20 @@ static void test_mnemo(const TCHAR *path, const TCHAR *mnemo, const TCHAR *ovrfi
                                                                }
                                                                // store test instruction generated changes
                                                                dst = store_mem_writes(dst, 0);
+                                                               uae_u8 bcflag = regs.pc == branch_target_pc ? CT_BRANCHED : 0;
                                                                // save exception, possible combinations:
                                                                // - any exception except trace
                                                                // - any exception except trace + trace stacked on top of previous exception
                                                                // - any exception except trace + following instruction generated trace
                                                                // - trace only
                                                                if (test_exception) {
-                                                                       *dst++ = CT_END | test_exception;
+                                                                       *dst++ = CT_END | test_exception | bcflag;
                                                                        dst = save_exception(dst, dp);
                                                                } else if (test_exception_extra) {
-                                                                       *dst++ = CT_END | 1;
+                                                                       *dst++ = CT_END | 1 | bcflag;
                                                                        dst = save_exception(dst, dp);
                                                                } else {
-                                                                       *dst++ = CT_END;
+                                                                       *dst++ = CT_END | bcflag;
                                                                }
                                                                test_count++;
                                                                subtest_count++;
index 42767ad2b8cb16666e404e08563d235792f65363..baaa1909e9e34720f69ca178c496da74a3aff335 100644 (file)
@@ -1,5 +1,5 @@
 
-#define DATA_VERSION 17
+#define DATA_VERSION 18
 
 #define CT_FPREG 0
 #define CT_DREG 0
@@ -43,3 +43,4 @@
 #define CT_SKIP_REGS (0x80 | 0x40 | 0x02)
 #define CT_EMPTY CT_END_INIT
 #define CT_OVERRIDE_REG (0x80 | 0x40 | 0x10)
+#define CT_BRANCHED 0x40
index b88b721fe4fd979d0221a459f3210e29a8829a85..8ef94604f402e404526ac5d4c9e0701bfaebd7d4 100644 (file)
@@ -1368,7 +1368,7 @@ static const struct srbit srbits[] = {
 // r2 = expected results
 // sreg = original registers
 
-static void out_regs(struct registers *r, struct registers *r1, struct registers *r2, struct registers *sreg, int before)
+static void out_regs(struct registers *r, struct registers *r1, struct registers *r2, struct registers *sreg, short before, short branched)
 {
        if (before) {
                for (int i = 0; i < 16; i++) {
@@ -1382,7 +1382,7 @@ static void out_regs(struct registers *r, struct registers *r1, struct registers
                        outbp += strlen(outbp);
                }
                *outbp++ = '\n';
-               sprintf(outbp, "SR:%c%04x      PC: %08x ISP: %08x", r1->sr != r2->sr ? '*' : ' ', r->sr, r->pc, r->ssp);
+               sprintf(outbp, "SR:%c%04x      PC: %08x ISP: %08x B: %d", r1->sr != r2->sr ? '*' : ' ', r->sr, r->pc, r->ssp, branched);
        } else {
                // output only lines that have at least one modified register to save screen space
                for (int i = 0; i < 4; i++) {
@@ -1404,7 +1404,7 @@ static void out_regs(struct registers *r, struct registers *r1, struct registers
                                *outbp++ = '\n';
                        }
                }
-               sprintf(outbp, "SR:%c%04x/%04x PC: %08x ISP: %08x", r->sr != r2->sr ? '*' : ' ', r->sr, r->expsr, r->pc, r->ssp);
+               sprintf(outbp, "SR:%c%04x/%04x PC: %08x ISP: %08x B: %d", r->sr != r2->sr ? '*' : ' ', r->sr, r->expsr, r->pc, r->ssp, branched);
        }
        outbp += strlen(outbp);
        if (cpu_lvl >= 2 && cpu_lvl <= 4) {
@@ -2242,6 +2242,7 @@ static uae_u8 *validate_test(uae_u8 *p, short ignore_errors, short ignore_sr, st
        short extrag2w1 = 0;
        short exceptionnum = 0;
        uae_u8 *outbp_old = outbp;
+       short branched = 0, branched2 = 0;
        exception_stored = 0;
 
        for (;;) {
@@ -2250,13 +2251,9 @@ static uae_u8 *validate_test(uae_u8 *p, short ignore_errors, short ignore_sr, st
                        exc = v & CT_EXCEPTION_MASK;
                        short cpuexc = tregs->exc & 65535;
                        short cpuexc010 = tregs->exc010 & 65535;
+                       branched = (v & CT_BRANCHED) != 0;
+                       branched2 = branched;
                        p++;
-                       if ((v & CT_END_INIT) == CT_END_INIT) {
-                               end_test();
-                               printf("Unexpected CT_END_INIT %02x %08x\n", v, p - test_data);
-                               endinfo();
-                               exit(0);
-                       }
                        if (cpu_lvl > 0 && exc >= 2 && cpuexc010 != cpuexc) {
                                if (dooutput) {
                                        sprintf(outbp, "Exception: vector number does not match vector offset! (%d <> %d) %d\n", exc, cpuexc010, cpuexc);
@@ -2276,15 +2273,22 @@ static uae_u8 *validate_test(uae_u8 *p, short ignore_errors, short ignore_sr, st
                        }
                        if (exc == 0 && cpuexc == 4) {
                                // successful complete generates exception 4 with matching PC
-                               if (lregs->pc + opcodeendsizeextra != tregs->pc && lregs->pc != tregs->pc && dooutput) {
-                                       sprintf(outbp, "PC: expected %08x but got %08x\n", lregs->pc, tregs->pc);
-                                       outbp += strlen(outbp);
-                                       if (tregs->pc == opcode_memory_addr) {
-                                               sprintf(outbp, "Got unexpected exception %d (unsupported instruction?)\n", cpuexc);
+                               if ((!branched && lregs->pc + opcodeendsizeextra != tregs->pc) || (branched && lregs->pc != tregs->pc)) {
+                                       if (lregs->pc == tregs->pc) {
+                                               branched2 = 1;
                                        } else {
-                                               sprintf(outbp, "Got unexpected exception %d\n", cpuexc);
+                                               branched2 = 0;
+                                       }
+                                       if (dooutput) {
+                                               sprintf(outbp, "PC (%c): expected %08x but got %08x\n", branched ? 'B' : '-', lregs->pc, tregs->pc);
+                                               outbp += strlen(outbp);
+                                               if (tregs->pc == opcode_memory_addr) {
+                                                       sprintf(outbp, "Got unexpected exception %d (unsupported instruction?)\n", cpuexc);
+                                               } else {
+                                                       sprintf(outbp, "Got unexpected exception %d\n", cpuexc);
+                                               }
+                                               outbp += strlen(outbp);
                                        }
-                                       outbp += strlen(outbp);
                                        errflag |= 1 << 16;
                                }
                                break;
@@ -2617,10 +2621,10 @@ static uae_u8 *validate_test(uae_u8 *p, short ignore_errors, short ignore_sr, st
                strcpy(outbp, outbuffer2);
                strcat(outbp, "Registers before:\n");
                outbp += strlen(outbp);
-               out_regs(sregs, tregs, lregs, sregs, 1);
+               out_regs(sregs, tregs, lregs, sregs, 1, branched);
                strcat(outbp, "Registers after:\n");
                outbp += strlen(outbp);
-               out_regs(tregs, tregs, lregs, sregs, 0);
+               out_regs(tregs, tregs, lregs, sregs, 0, branched2);
                if (exc > 1) {
                        if (!experr) {
                                sprintf(outbp, "OK: exception %d ", exc);
@@ -2966,7 +2970,7 @@ static void process_test(uae_u8 *p)
                                                addinfo();
                                                strcat(outbp, "Registers before:\n");
                                                outbp += strlen(outbp);
-                                               out_regs(&cur_regs, &test_regs, &last_regs, &cur_regs, 1);
+                                               out_regs(&cur_regs, &test_regs, &last_regs, &cur_regs, 1, 0);
                                                end_test();
                                                printf(outbuffer);
                                                printf("\nExit count expired\n");
index b7b9a71f403db445175f66e10f820297bbc2f065..0de203a52539c086492700b22810da7c6f0ed898 100644 (file)
@@ -134,6 +134,7 @@ Change log:
 17.05.2020
 
 - Rewritten disassembler to use indirect and validated opword reads, now it is safe to use when testing bus errors.
+- Added 'B' branching identifier to register output. 0 = instruction didn't branch when test was genered, 1 = instruction branched when test was generated.
 
 09.05.2020