]> git.unchartedbackwaters.co.uk Git - francis/winuae.git/commitdiff
CPU tester undefined CCR option.
authorToni Wilen <twilen@winuae.net>
Mon, 13 Jul 2020 18:00:59 +0000 (21:00 +0300)
committerToni Wilen <twilen@winuae.net>
Mon, 13 Jul 2020 18:00:59 +0000 (21:00 +0300)
cputest.cpp
cputest/cputestgen.ini
cputest/main.c
cputest/readme.txt

index 072b506b31b341bec06040f529e205ac8a4d4375..7a8b32a9fa03a1c6cdf79d425588079b10e176bb 100644 (file)
@@ -55,6 +55,7 @@ static int verbose = 1;
 static int feature_exception3_data = 0;
 static int feature_exception3_instruction = 0;
 static int feature_sr_mask = 0;
+static int feature_undefined_ccr = 0;
 static int feature_min_interrupt_mask = 0;
 static int feature_loop_mode = 0;
 static int feature_loop_mode_register = -1;
@@ -4132,10 +4133,25 @@ static uae_u8 *save_exception(uae_u8 *p, struct instr *dp)
 static uae_u16 get_ccr_ignore(struct instr *dp, uae_u16 extra)
 {
        uae_u16 ccrignoremask = 0;
-       if ((cpu_lvl == 2 || cpu_lvl == 3) && (test_exception == 5 || exception_extra_frame_type == 5)) {
-               if ((dp->mnemo == i_DIVS) || (dp->mnemo == i_DIVL && (extra & 0x0800) && !(extra & 0x0400))) {
-                       // 68020/030 DIVS.W/.L + Divide by Zero: V state is not stable.
-                       ccrignoremask |= 2; // mask CCR=V
+       if (!feature_undefined_ccr) {
+               if (test_exception == 5 || exception_extra_frame_type == 5) {
+                       if (dp->mnemo == i_DIVS || dp->mnemo == i_DIVU || dp->mnemo == i_DIVL) {
+                               // DIV + Divide by Zero: flags are undefined
+                               ccrignoremask |= 0x08 | 0x04 | 0x02 | 0x01;
+                       }
+               } else {
+                       if ((dp->mnemo == i_DIVS || dp->mnemo == i_DIVU || dp->mnemo == i_DIVL) && (regs.sr & 0x02)) {
+                               // DIV + V: other flags are undefined
+                               ccrignoremask |= 0x08 | 0x04 | 0x01;
+                       }
+               }
+               if (dp->mnemo == i_CHK2) {
+                       // CHK: N and V are undefined
+                       ccrignoremask |= 0x08 | 0x02;
+               }
+               if (dp->mnemo == i_CHK) {
+                       // CHK: N and V are undefined
+                       ccrignoremask |= 0x04 | 0x02 | 0x01;
                }
        }
        return ccrignoremask;
@@ -6259,6 +6275,9 @@ static int test(struct ini_data *ini, const TCHAR *sections, const TCHAR *testna
 
        feature_sr_mask = 0;
        ini_getvalx(ini, sections, _T("feature_sr_mask"), &feature_sr_mask);
+       feature_undefined_ccr = 0;
+       ini_getvalx(ini, sections, _T("feature_undefined_ccr"), &feature_undefined_ccr);
+
        feature_min_interrupt_mask = 0;
        ini_getvalx(ini, sections, _T("feature_min_interrupt_mask"), &feature_min_interrupt_mask);
 
index 7429d9c60d0389272a3f2d92396351be3942d6be..dbf9b60804d07a2e2b3d148537e34931ba61e62e 100644 (file)
@@ -142,6 +142,10 @@ feature_interrupts=0
 ; Note: instructions that generate privilege violation exception will automatically add extra S=1 round.
 feature_sr_mask=0x0000
 
+; Do not check undefined flags
+; Currently supported: CHK, CHK2, DIV
+feature_undefined_ccr=0
+
 ; Forced register, always use this value in all tests
 ; D0-D7, A0-A6, FP0-FP7, SR, CCR, FPSR, FPCR, FPIAR
 ; reg=0x1234 or reg=100
@@ -200,6 +204,7 @@ feature_sr_mask=0x8000
 cpu=68000-68010
 enabled=0
 feature_sr_mask=0x8000
+feature_undefined_ccr=1
 mode=all
 
 ; interrupt exception
@@ -208,6 +213,7 @@ enabled=0
 cpu=68000-68010
 feature_sr_mask=0x8000
 feature_interrupts=1
+feature_undefined_ccr=1
 mode=jsr,jmp,bsr,bcc,dbcc,nop,exg,swap,stop,mvsr2,mv2sr,andsr,eorsr,orsr
 min_opcode_test_rounds=100
 
@@ -217,6 +223,7 @@ enabled=0
 cpu=68000-68010
 feature_target_src_ea=0x37fff1,0x7111
 feature_target_dst_ea=
+feature_undefined_ccr=1
 mode=all
 
 ; destination EA address error (MOVE, MOVEM)
@@ -226,6 +233,7 @@ cpu=68000-68010
 feature_target_src_ea=
 feature_target_dst_ea=0x37fff1,0x7111
 verbose=0
+feature_undefined_ccr=1
 mode=move,movea,mvmel,mvmle
 
 ; user stack address error
@@ -234,6 +242,7 @@ enabled=0
 cpu=68000-68010
 feature_usp=2
 verbose=0
+feature_undefined_ccr=1
 mode=rts,rtd,rtr,jsr,bsr,link,unlk,pea
 
 ; exception vector address error
@@ -242,6 +251,7 @@ enabled=0
 cpu=68000-68010
 feature_exception_vectors=0x000123
 verbose=0
+feature_undefined_ccr=1
 mode=mv2sr.w,mvusp2r,mvr2usp,illegal,chk,trap,trapv,divu,divs,orsr.w
 
 ; interrupt exception with odd interrupt vectors
@@ -250,6 +260,7 @@ enabled=0
 cpu=68000-68010
 mode=nop,ext,swap
 feature_interrupts=1
+feature_undefined_ccr=1
 feature_exception_vectors=0x000123
 
 ; prefetch bus error (requires extra hardware)
@@ -264,6 +275,7 @@ opcode_memory_start=0x87ffee
 test_memory_size=0xa0000
 test_memory_size=0x100000
 opcode_memory_start=0x87ffa0
+feature_undefined_ccr=1
 mode=all
 
 ; source EA read bus error (requires extra hardware)
@@ -278,6 +290,7 @@ feature_target_dst_ea=
 test_memory_start=0x860000
 test_memory_size=0x100000
 opcode_memory_start=0x87ffa0
+feature_undefined_ccr=1
 mode=all
 
 ; destination EA read bus error (requires extra hardware)
@@ -292,6 +305,7 @@ feature_target_dst_ea=0x87fffc,0x87fffd,0x87fffe,0x87ffff,0x880000,0x880001,0x88
 test_memory_start=0x860000
 test_memory_size=0x100000
 opcode_memory_start=0x87ffa0
+feature_undefined_ccr=1
 mode=all
 
 ; source EA (=RMW instructions like NOT have only source EA) write bus error (requires extra hardware)
@@ -307,7 +321,8 @@ opcode_memory_start=0x8fffa0
 test_memory_start=0x880000
 test_memory_size=0x100000
 mode=moves
-;mode=all
+feature_undefined_ccr=1
+mode=all
 
 ; destination EA write bus error (requires extra hardware)
 [test=BEDSTW]
@@ -321,6 +336,7 @@ feature_target_dst_ea=0x8ffffc,0x8ffffd,0x8ffffe,0x8fffff,0x900000,0x900001,0x90
 opcode_memory_start=0x8fffa0
 test_memory_start=0x880000
 test_memory_size=0x100000
+feature_undefined_ccr=1
 mode=all
 
 
@@ -332,6 +348,7 @@ feature_loop_mode_68010=1
 feature_loop_mode=3
 feature_loop_mode_register=7
 min_opcode_test_rounds=100
+feature_undefined_ccr=1
 mode=all
 
 ; **************
index c832dc14c544efbcf6bbe234ee41879940b313b5..9d6b061e8eb5d64eef3821560c83ba2a15cd4fbb 100644 (file)
@@ -1661,7 +1661,7 @@ static uae_u8 *validate_exception(struct registers *regs, uae_u8 *p, short excnu
                                p += 2;
                                v = opcode_memory_addr;
                                p = restore_rel_ordered(p, &v);
-                               if (vsr != sr) {
+                               if ((vsr & test_ccrignoremask) != (sr & test_ccrignoremask)) {
                                        sprintf(outbp, "Trace (non-stacked) SR mismatch: %04x != %04x (PC=%08x)\n", sr, vsr, v);
                                        outbp += strlen(outbp);
                                        *experr = 1;
index abcc34c80b387260117fe2171653245af5a4ed01..87094a692f24c1208dbb069df11c901034868e73 100644 (file)
@@ -130,6 +130,10 @@ If mismatch is detected, opcode word(s), instruction disassembly, registers befo
 
 Change log:
 
+13.07.2020
+
+- Added undefined_ccr option. Ignores undefined flags, currently supports DIVx, CHK and CHK2 (Instructions that don't have simple undefined behavior)
+
 10.07.2020
 
 - 68020+ stack frame PC field was ignored.