]> git.unchartedbackwaters.co.uk Git - francis/winuae.git/commitdiff
68020+ test presets, CPU selection update.
authorToni Wilen <twilen@winuae.net>
Sun, 1 Mar 2020 11:30:02 +0000 (13:30 +0200)
committerToni Wilen <twilen@winuae.net>
Sun, 1 Mar 2020 11:30:02 +0000 (13:30 +0200)
cputest.cpp
cputest/cputestgen.ini
cputest/readme.txt

index 16c5aed4682579c84c269910fe7f4d66bac388f1..6e9866a13a53c058b9a0cfa994d224aee84ba508 100644 (file)
@@ -83,6 +83,7 @@ static uae_u32 feature_target_ea[MAX_TARGET_EA][3];
 static int target_ea_src_cnt, target_ea_dst_cnt, target_ea_opcode_cnt;
 static int target_ea_src_max, target_ea_dst_max, target_ea_opcode_max;
 static uae_u32 target_ea[3];
+static int maincpu[6];
 
 #define HIGH_MEMORY_START (addressing_mask == 0xffffffff ? 0xffff8000 : 0x00ff8000)
 
@@ -980,8 +981,6 @@ static void doexcstack(void)
        bool g1 = generates_group1_exception(regs.ir);
 
        doexcstack2();
-       if (cpu_lvl >= 2)
-               return;
        if (test_exception < 4)
                return;
 
@@ -1942,6 +1941,10 @@ static int create_ea_random(uae_u16 *opcodep, uaecptr pc, int mode, int reg, str
        uaecptr old_pc = pc;
        uae_u16 opcode = *opcodep;
 
+       // feature_full_extension_format = 2 and 68020 addressing modes enabled: do not generate any normal addressing modes
+       if (feature_full_extension_format == 2 && (ad8r[srcdst] || pc8r[srcdst]) && (mode != Ad8r && mode != PC8r))
+               return -1;
+
        switch (mode)
        {
        case Dreg:
@@ -2082,7 +2085,7 @@ static int create_ea_random(uae_u16 *opcodep, uaecptr pc, int mode, int reg, str
                                put_word_test(pc, v);
                                pc += 2;
                        }
-                       *isconstant = 32;
+                       *isconstant = 128;
                        *eap = 1;
                }
                break;
@@ -3230,7 +3233,7 @@ 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) {
+       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
@@ -3637,6 +3640,9 @@ static void test_mnemo(const TCHAR *path, const TCHAR *mnemo, const TCHAR *ovrfi
                                                regs.regs[15] = target_usp_address;
                                        }
 
+                                       regs.usp = regs.regs[15];
+                                       regs.isp = super_stack_memory - 0x80;
+
                                        if (opc == 0x0e51)
                                                printf("");
                                        if (subtest_count >= 700)
@@ -3789,6 +3795,8 @@ static void test_mnemo(const TCHAR *path, const TCHAR *mnemo, const TCHAR *ovrfi
                                                }
                                        }
 
+                                       uae_u16 extraword = get_word_test(opcode_memory_address + 2);
+
                                        // loop mode
                                        if (feature_loop_mode) {
                                                // dbf dn, opcode_memory_start
@@ -4347,7 +4355,7 @@ static void test_mnemo(const TCHAR *path, const TCHAR *mnemo, const TCHAR *ovrfi
                                                                        }
                                                                }
                                                                // SR/CCR
-                                                               uae_u32 ccrignoremask = get_ccr_ignore(dp, ((pcaddr[2] << 8) | pcaddr[3])) << 16;
+                                                               uae_u32 ccrignoremask = get_ccr_ignore(dp, extraword) << 16;
                                                                if ((regs.sr | ccrignoremask) != last_sr) {
                                                                        dst = store_reg(dst, CT_SR, last_sr, regs.sr | ccrignoremask, -1);
                                                                        last_sr = regs.sr | ccrignoremask;
@@ -4791,6 +4799,24 @@ static bool ini_getstringx(struct ini_data *ini, const TCHAR *sections, const TC
        return ret;
 }
 
+static int cputoindex(int cpu)
+{
+       if (cpu == 68000) {
+               return 0;
+       } else if (cpu == 68010) {
+               return 1;
+       } else if (cpu == 68020) {
+               return 2;
+       } else if (cpu == 68030) {
+               return 3;
+       } else if (cpu == 68040) {
+               return 4;
+       } else if (cpu == 68060) {
+               return 5;
+       }
+       return -1;
+}
+
 static int test(struct ini_data *ini, const TCHAR *sections, const TCHAR *testname)
 {
        const struct cputbl *tbl = NULL;
@@ -4806,19 +4832,72 @@ static int test(struct ini_data *ini, const TCHAR *sections, const TCHAR *testna
                return 1;
        }
 
-       currprefs.cpu_model = 68000;
-       ini_getvalx(ini, sections, _T("cpu"), &currprefs.cpu_model);
-       if (currprefs.cpu_model != 68000 && currprefs.cpu_model != 68010 && currprefs.cpu_model != 68020 &&
-               currprefs.cpu_model != 68030 && currprefs.cpu_model != 68040 && currprefs.cpu_model != 68060) {
-               wprintf(_T("Unsupported CPU model.\n"));
-               return 0;
+       bool cpufound = false;
+       if (ini_getstringx(ini, sections, _T("cpu"), &vs)) {
+               TCHAR *p = vs;
+               while (p && *p) {
+                       TCHAR *pp1 = _tcschr(p, ',');
+                       TCHAR *pp2 = _tcschr(p, '-');
+                       if (pp1) {
+                               *pp1++ = 0;
+                               int idx = cputoindex(_tstol(p));
+                               if (idx < 0) {
+                                       wprintf(_T("Invalid CPU string '%s'\n"), vs);
+                                       return 0;
+                               }
+                               if (maincpu[idx]) {
+                                       cpufound = true;
+                                       break;
+                               }
+                               p = pp1;
+                       } else if (pp2) {
+                               *pp2++ = 0;
+                               int idx1 = cputoindex(_tstol(p));
+                               int idx2 = cputoindex(_tstol(pp2));
+                               if (idx1 < 0 || idx2 < 0) {
+                                       wprintf(_T("Invalid CPU string '%s'\n"), vs);
+                                       return 0;
+                               }
+                               for (int i = idx1; i <= idx2; i++) {
+                                       if (maincpu[i]) {
+                                               cpufound = true;
+                                               break;
+                                       }
+                               }
+                               if (cpufound) {
+                                       break;
+                               }
+                               p = pp2;
+                       } else {
+                               int idx = cputoindex(_tstol(p));
+                               if (idx < 0) {
+                                       wprintf(_T("Invalid CPU string '%s'\n"), vs);
+                                       return 0;
+                               }
+                               if (maincpu[idx]) {
+                                       cpufound = true;
+                               }
+                               break;
+                       }
+               }
+               xfree(vs);
+       }
+
+       if (!cpufound) {
+               wprintf(_T("Test skipped. CPU does not match.\n"));
+               return 1;
        }
 
        currprefs.address_space_24 = 1;
        addressing_mask = 0x00ffffff;
-       v = 24;
+       v = 68030;
        ini_getvalx(ini, sections, _T("cpu_address_space"), &v);
-       if (v == 32 || currprefs.cpu_model >= 68030) {
+       if (v < 68000) {
+               if (v == 32) {
+                       currprefs.address_space_24 = 0;
+                       addressing_mask = 0xffffffff;
+               }
+       } else if (currprefs.cpu_model >= v) {
                currprefs.address_space_24 = 0;
                addressing_mask = 0xffffffff;
        }
@@ -4827,7 +4906,7 @@ static int test(struct ini_data *ini, const TCHAR *sections, const TCHAR *testna
        currprefs.fpu_mode = 1;
        ini_getvalx(ini, sections, _T("fpu"), &currprefs.fpu_model);
        if (currprefs.fpu_model && currprefs.cpu_model < 68020) {
-               wprintf(_T("FPU requires 68020 or 68040 CPU.\n"));
+               wprintf(_T("FPU requires 68020+ CPU.\n"));
                return 0;
        }
        if (currprefs.fpu_model != 0 && currprefs.fpu_model != 68881 && currprefs.fpu_model != 68882 && currprefs.fpu_model != 68040 && currprefs.fpu_model != 68060) {
@@ -5393,7 +5472,7 @@ int __cdecl main(int argc, char *argv[])
 {
        struct ini_data *ini = ini_load(_T("cputestgen.ini"), false);
        if (!ini) {
-               wprintf(_T("Couldn't open cputestgen.ini"));
+               wprintf(_T("Couldn't open cputestgen.ini\n"));
                return 0;
        }
 
@@ -5401,6 +5480,20 @@ int __cdecl main(int argc, char *argv[])
        _tcscpy(sections, INISECTION);
        sptr += _tcslen(sptr) + 1;
 
+       int cpu;
+       if (!ini_getval(ini, INISECTION, _T("cpu"), &cpu)) {
+               wprintf(_T("CPU model is not set\n"));
+               return 0;
+       }
+
+       int cpuidx = cputoindex(cpu);
+       if (cpuidx < 0) {
+               wprintf(_T("Unsupport CPU model\n"));
+               return 0;
+       }
+       maincpu[cpuidx] = 1;
+       currprefs.cpu_model = cpu;
+
        int idx = 0;
        for (;;) {
                TCHAR *section = NULL;
index 19a67436d9cc07766115e1dd20e7466dfab3e199..093184c6543a2d2dced9d620c24e1764b8834099 100644 (file)
@@ -4,8 +4,10 @@
 ; Always select 68020 when testing FPU instructions, even if test hardware CPU is 68040 or 68060.
 cpu=68000
 
-; CPU address space. 24-bit or 32-bit. If 24-bit, tester will assume upper 8-bits of addresses gets ignored.
-cpu_address_space=24
+; CPU address space.
+; If 24-bit, tester will assume upper 8-bits of addresses gets ignored.
+; 24 = 24-bit address space, 32 = 32-bit address space. 680x0 = this and higher CPU models are 32-bit.
+cpu_address_space=68030
 
 ; FPU model (empty string or 0, 68881, 68882, 68040, 68060)
 ; Enable only when testing FPU. Enabled FPU mode will slow down native test execution even when not testing FPU instructions.
@@ -43,7 +45,7 @@ test_memory_start=0x860000
 ;test_memory_start=0x68800000
 ;test_memory_start=0x07800000
 ;test_memory_start=0x340000
-test_memory_size=0xa0000
+test_memory_size=0x40000
 
 ; address where test instructions are located
 ; if not defined: mid point of test memory
@@ -51,7 +53,7 @@ opcode_memory_start=0x87ffa0
 
 ; number of test rounds
 ; registers are re-randomized after each round if not in target ea mode.
-test_rounds=2
+test_rounds=1
 
 ; test word or long odd data access address errors (68000/010 only)
 ; 0 = do not generate address errors
@@ -140,6 +142,9 @@ feature_loop_mode_68010=0
 
 ; 68020+ addressing modes (this makes test files much larger if other addressing modes are also enabled)
 ; currently does not generate any reserved mode bit combinations.
+; 0 = disabled
+; 1 = enabled
+; 2 = enabled + do not generate any non-68020 addressing modes
 feature_full_extension_format=0
 
 ; empty = all addressing modes (feature_full_extension_format=1 enables 68020+ modes)
@@ -163,11 +168,18 @@ mode=
 ; use key=* to restore default value
 
 [test=Default]
-enabled=1
+enabled=0
+test_rounds=2
 mode=all
+feature_sr_mask=0x8000
+
+; *********************
+; 68000 - 68010 presets
+; *********************
 
 ; basic instruction test
 [test=Basic]
+cpu=68000-68010
 enabled=0
 mode=all
 feature_sr_mask=0x8000
@@ -175,12 +187,14 @@ feature_sr_mask=0x8000
 ; interrupt exception
 [test=IRQ]
 enabled=0
+cpu=68000-68010
 mode=nop,ext,swap
 feature_interrupts=1
 
 ; source EA address error
 [test=AE_SRC]
 enabled=0
+cpu=68000-68010
 feature_target_src_ea=0x87fff1,0x7111
 feature_target_dst_ea=
 mode=all
@@ -188,6 +202,7 @@ mode=all
 ; destination EA address error (MOVE, MOVEM)
 [test=AE_DST]
 enabled=0
+cpu=68000-68010
 feature_target_src_ea=
 feature_target_dst_ea=0x87fff1,0x7111
 mode=all
@@ -195,18 +210,21 @@ mode=all
 ; user stack address error
 [test=ODD_STK]
 enabled=0
+cpu=68000-68010
 feature_usp=2
 mode=rts,rtd,rtr,jsr,bsr,link,unlk,pea
 
 ; exception vector address error
 [test=ODD_EXC]
 enabled=0
+cpu=68000-68010
 feature_exception_vectors=0x000123
 mode=mv2sr.w,mvusp2r,mvr2usp,illegal,chk,trap,trapv,divu,divs,orsr.w
 
 ; interrupt exception with odd interrupt vectors
 [test=ODD_IRQ]
 enabled=0
+cpu=68000-68010
 mode=nop,ext,swap
 feature_interrupts=1
 feature_exception_vectors=0x000123
@@ -214,6 +232,7 @@ feature_exception_vectors=0x000123
 ; prefetch bus error (requires extra hardware)
 [test=BE_PR]
 enabled=0
+cpu=68000-68010
 feature_safe_memory_start=0x880000
 feature_safe_memory_size=0x80000
 feature_safe_memory_mode=P
@@ -225,6 +244,7 @@ mode=all
 ; source EA read bus error (requires extra hardware)
 [test=BE_SRC]
 enabled=0
+cpu=68000-68010
 feature_safe_memory_start=0x880000
 feature_safe_memory_size=0x80000
 feature_safe_memory_mode=R
@@ -236,6 +256,7 @@ mode=all
 ; destination EA read bus error (requires extra hardware)
 [test=BE_DST]
 enabled=0
+cpu=68000-68010
 feature_safe_memory_start=0x880000
 feature_safe_memory_size=0x80000
 feature_safe_memory_mode=R
@@ -247,6 +268,7 @@ mode=all
 ; source EA (=RMW instructions like NOT have only source EA) write bus error (requires extra hardware)
 [test=BE_SRCW]
 enabled=0
+cpu=68000-68010
 feature_safe_memory_start=0x900000
 feature_safe_memory_size=0x80000
 feature_safe_memory_mode=W
@@ -260,6 +282,7 @@ mode=all
 ; destination EA write bus error (requires extra hardware)
 [test=BE_DSTW]
 enabled=0
+cpu=68000-68010
 feature_safe_memory_start=0x900000
 feature_safe_memory_size=0x80000
 feature_safe_memory_mode=W
@@ -269,3 +292,68 @@ opcode_memory_start=0x8fffa0
 test_memory_start=0x880000
 test_memory_size=0x100000
 mode=all
+
+; 68010 loop mode compatible instructions
+[test=loopmode]
+enabled=0
+cpu=68010
+feature_loop_mode_68010=1
+mode=all
+
+; **************
+; 68020+ presets
+; **************
+
+; basic tests
+; with all SR T1, T0 and M combinations
+[test=Basic]
+enabled=0
+cpu=68020-68060
+feature_sr_mask=0xd000
+mode=all
+
+; 68020+ addressing mode tests
+[test=FFEXT_SRC]
+enabled=0
+cpu=68020-68060
+feature_full_extension_format=2
+feature_addressing_modes_src=Ad8rf,PC8rf
+test_rounds=4
+mode=not,move
+
+[test=FFEXT_DST]
+enabled=0
+cpu=68020-68060
+feature_full_extension_format=2
+feature_addressing_modes_dst=Ad8rf,PC8rf
+test_rounds=4
+mode=move,add
+
+;address error tests
+[test=AE]
+enabled=0
+cpu=68020-68060
+feature_exception3_instruction=2
+mode=all
+
+; user stack address error
+[test=ODD_STK]
+enabled=0
+cpu=68020-68060
+feature_usp=2
+mode=rts,rtd,rtr,jsr,bsr,link,unlk,pea
+
+; exception vector address error
+[test=ODD_EXC]
+enabled=0
+cpu=68020-68060
+feature_exception_vectors=0x000123
+mode=mv2sr.w,mvsr2.w,mvusp2r,mvr2usp,illegal,chk,trap,trapv,orsr.w,eorsr.w,andsr.w,divu,divs,divul,divsl
+
+; interrupt exception with odd interrupt vectors
+[test=ODD_IRQ]
+enabled=0
+cpu=68020-68060
+mode=nop,ext,swap
+feature_interrupts=1
+feature_exception_vectors=0x000123
index 793834bab07faad9a8d7d2e8f988225b733e0058..a036c68a1318fed27febaa771c4922fa49434fcf 100644 (file)
@@ -156,3 +156,8 @@ Change log:
 - Multiple test sets can be generated and tested in single step.
 - Stack usage reduced, gzip decompression works with default 4096 byte stack.
 
+01.03.2020
+
+- Added 68020+ test presets.
+- CPU selection changed. CPU=680x0 line at the top of ini is now the main CPU selection field. Test is generated if CPU model matches preset's CPU and preset is active. This update allows use of same preset for multiple CPU models.
+- cpu_address_space can be also used to select which CPU model is first 32-bit addressing capable model (normally 68020 or 68030).