]> git.unchartedbackwaters.co.uk Git - francis/winuae.git/commitdiff
Fix approximate 68000 mode cycle counts.
authorToni Wilen <twilen@winuae.net>
Sat, 18 Jan 2020 15:13:18 +0000 (17:13 +0200)
committerToni Wilen <twilen@winuae.net>
Sat, 18 Jan 2020 15:13:18 +0000 (17:13 +0200)
gencpu.cpp
include/ini.h
newcpu.cpp

index e24a7544362d0000a83a7ea7c616fbd20ac5a63e..dd84ab428a445dd078b8ea5ed6c5a6ab229ff1b0 100644 (file)
@@ -422,29 +422,54 @@ static void returncycles(const char *s, int cycles)
 
 static void write_return_cycles(const char *s, int end)
 {
-       if (!end) {
+       if (end <= 0) {
                clearmmufixup(0, 1);
                clearmmufixup(1, 1);
        }
        if (using_ce || using_prefetch) {
-               if (count_read + count_write + count_cycles == 0)
-                       count_cycles = 4;
-               returncycles(s, (count_read + count_write) * 4 + count_cycles);
-               if (end) {
-                       printf("}\n");
-                       printf("/* %d%s (%d/%d)",
-                               (count_read + count_write) * 4 + count_cycles, count_ncycles ? "+" : "", count_read, count_write);
-                       printf(" */\n");
+               if (end < 0) {
+                       if (using_ce) {
+                               printf("%sreturn;\n", s);
+                       } else {
+                               printf("%sreturn 0;\n", s);
+                       }
+               } else {
+                       int cc = count_cycles;
+                       if (count_read + count_write + cc == 0)
+                               cc = 4;
+                       returncycles(s, (count_read + count_write) * 4 + cc);
+                       if (end) {
+                               printf("}\n");
+                               printf("/* %d%s (%d/%d)",
+                                       (count_read + count_write) * 4 + cc, count_ncycles ? "+" : "", count_read, count_write);
+                               printf(" */\n");
+                       }
                }
        } else if (count_read + count_write) {
-               returncycles(s, (count_read + count_write) * 4 + count_cycles);
-               if (end) {
-                       printf("}\n");
+               if (end < 0) {
+                       if (using_ce020) {
+                               printf("%sreturn;\n", s);
+                       } else {
+                               printf("%sreturn 0;\n", s);
+                       }
+               } else {
+                       returncycles(s, (count_read + count_write) * 4 + count_cycles);
+                       if (end) {
+                               printf("}\n");
+                       }
                }
        } else {
-               returncycles(s, insn_n_cycles);
-               if (end) {
-                       printf("}\n");
+               if (end < 0) {
+                       if (using_ce020) {
+                               printf("%sreturn;\n", s);
+                       } else {
+                               printf("%sreturn 0;\n", s);
+                       }
+               } else {
+                       returncycles(s, insn_n_cycles);
+                       if (end) {
+                               printf("}\n");
+                       }
                }
        }
 }
@@ -3457,6 +3482,7 @@ static void genastore_2 (const char *from, amodes mode, const char *reg, wordsiz
                                        term ();
                                if (store_dir) {
                                        printf("\t%s(%sa + 2, %s);\n", dstwx, to, from);
+                                       count_write++;
                                        check_bus_error(to, 0, 1, 1, from, 1);
                                        check_bus_error(to, 2, 1, 1, from, 1);
                                        if (opcode_nextcopy)
@@ -3466,11 +3492,13 @@ static void genastore_2 (const char *from, amodes mode, const char *reg, wordsiz
                                                genflags(flag_logical, g_instr->size, "src", "", "");
                                        }
                                        printf("\t%s(%sa, %s >> 16); \n", dstwx, to, from);
+                                       count_write++;
                                        sprintf(tmp, "%s >> 16", from);
                                        check_bus_error(to, 0, 1, 1, from, 1);
                                        check_bus_error(to, 0, 1, 1, tmp, 1);
                                } else {
                                        printf("\t%s(%sa, %s >> 16);\n", dstwx, to, from);
+                                       count_write++;
                                        sprintf(tmp, "%s >> 16", from);
                                        check_bus_error(to, 0, 1, 1, from, 1);
                                        check_bus_error(to, 0, 1, 1, tmp, 1);
@@ -3480,6 +3508,7 @@ static void genastore_2 (const char *from, amodes mode, const char *reg, wordsiz
                                        if (flags & GF_SECONDWORDSETFLAGS) {
                                                genflags(flag_logical, g_instr->size, "src", "", "");
                                        }
+                                       count_write++;
                                        printf("\t%s(%sa + 2, %s); \n", dstwx, to, from);
                                        check_bus_error(to, 0, 1, 1, from, 1);
                                        check_bus_error(to, 2, 1, 1, from, 1);
@@ -4615,8 +4644,8 @@ static void gen_opcode (unsigned int opcode)
        case 2: /* priviledged */
                printf(
                        "\tif (!regs.s) {\n"
-                       "\t\tException (8);\n");
-               write_return_cycles("\t\t", 0);
+                       "\t\tException(8);\n");
+               write_return_cycles("\t\t", -1);
                printf("\t}\n");
                break;
        case 3: /* privileged if size == word */
@@ -4624,8 +4653,8 @@ static void gen_opcode (unsigned int opcode)
                        break;
                printf(
                        "\tif (!regs.s) {\n"
-                       "\t\tException (8);\n");
-               write_return_cycles("\t\t", 0);
+                       "\t\tException(8);\n");
+               write_return_cycles("\t\t", -1);
                printf("\t}\n");
                break;
        }
@@ -4681,8 +4710,9 @@ static void gen_opcode (unsigned int opcode)
        case i_EORSR:
                next_level_000();
                printf("\tMakeSR();\n");
-               if (cpu_level == 0)
+               if (cpu_level == 0) {
                        printf("\tint t1 = regs.t1;\n");
+               }
                genamode (curi, curi->smode, "srcreg", curi->size, "src", 1, 0, cpu_level == 1 ? GF_NOREFILL : 0);
                if (curi->size == sz_byte) {
                        printf("\tsrc &= 0xFF;\n");
@@ -6251,6 +6281,7 @@ static void gen_opcode (unsigned int opcode)
                        printf("\tuaecptr oldpc = %s;\n", getpc);
                        printf("\tuaecptr nextpc = oldpc + %d;\n", m68k_pc_offset);
                        if (using_exception_3 && cpu_level <= 1) {
+                               push_ins_cnt();
                                printf("\tif (srca & 1) {\n");
                                if (curi->smode >= Ad16 && cpu_level == 1 && using_prefetch) {
                                        dummy_prefetch("srca", NULL);
@@ -6262,6 +6293,7 @@ static void gen_opcode (unsigned int opcode)
                                printf("\t\texception3i(opcode, srca);\n");
                                write_return_cycles("\t\t", 0);
                                printf("\t}\n");
+                               pop_ins_cnt();
                        }
                        if (using_mmu) {
                                printf("\t%s(m68k_areg(regs, 7) - 4, nextpc);\n", dstl);
@@ -6339,6 +6371,7 @@ static void gen_opcode (unsigned int opcode)
                no_prefetch_ce020 = true;
                genamode (curi, curi->smode, "srcreg", curi->size, "src", 0, 0, GF_AA|GF_NOREFILL);
                if (using_exception_3) {
+                       push_ins_cnt();
                        printf("\tif (srca & 1) {\n");
                        if (curi->smode >= Ad16 && cpu_level == 1 && using_prefetch) {
                                dummy_prefetch("srca", NULL);
@@ -6350,6 +6383,7 @@ static void gen_opcode (unsigned int opcode)
                        printf("\t\texception3i(opcode, srca);\n");
                        write_return_cycles("\t\t", 0);
                        printf("\t}\n");
+                       pop_ins_cnt();
                }
                if (curi->smode == Ad16 || curi->smode == absw || curi->smode == PC16)
                        addcycles000 (2);
@@ -6720,6 +6754,7 @@ bccl_not68020:
                genamodedual (curi,
                        curi->smode, "srcreg", sz_word, "src", 1, 0,
                        curi->dmode, "dstreg", sz_long, "dst", 1, 0);
+               push_ins_cnt();
                printf("\tif (src == 0) {\n");
                printf("\t\tdivbyzero_special(0, dst);\n");
                incpc("%d", m68k_pc_offset);
@@ -6727,6 +6762,7 @@ bccl_not68020:
                printf("\t\tException_cpu(5);\n");
                write_return_cycles("\t\t", 0);
                printf("\t}\n");
+               pop_ins_cnt();
                printf("\tuae_u32 newv = (uae_u32)dst / (uae_u32)(uae_u16)src;\n");
                printf("\tuae_u32 rem = (uae_u32)dst %% (uae_u32)(uae_u16)src;\n");
                if (using_ce) {
@@ -6755,6 +6791,7 @@ bccl_not68020:
                genamodedual(curi,
                        curi->smode, "srcreg", sz_word, "src", 1, 0,
                        curi->dmode, "dstreg", sz_long, "dst", 1, 0);
+               push_ins_cnt();
                printf("\tif (src == 0) {\n");
                printf("\t\tdivbyzero_special (1, dst);\n");
                incpc("%d", m68k_pc_offset);
@@ -6762,6 +6799,7 @@ bccl_not68020:
                printf("\t\tException_cpu(5);\n");
                write_return_cycles("\t\t", 0);
                printf("\t}\n");
+               pop_ins_cnt();
                if (using_ce) {
                        printf("\tint cycles = getDivs68kCycles((uae_s32)dst, (uae_s16)src);\n");
                        addcycles000_3("\t");
index 06f71d5bd4a998444693c3efbb839a485e16c9ec..4cd5e77f75ef74e6571edda28541061537a21daf 100644 (file)
@@ -42,6 +42,7 @@ bool ini_getval_multi(struct ini_data *ini, const TCHAR *section, const TCHAR *k
 bool ini_getdata(struct ini_data *ini, const TCHAR *section, const TCHAR *key, uae_u8 **out, int *size);
 bool ini_getdata_multi(struct ini_data *ini, const TCHAR *section, const TCHAR *key, uae_u8 **out, int *size, struct ini_context*);
 bool ini_getsectionstring(struct ini_data *ini, const TCHAR *section, int idx, TCHAR **keyout, TCHAR **valout);
+bool ini_getsection(struct ini_data *ini, int idx, TCHAR **section);
 
 bool ini_addstring(struct ini_data *ini, const TCHAR *section, const TCHAR *key, const TCHAR *val);
 bool ini_delete(struct ini_data *ini, const TCHAR *section, const TCHAR *key);
index 894db7a7384a12027ffc81ac3413a9c76558260f..904171525a24368e919e509ecae92f1884092641 100644 (file)
@@ -2810,7 +2810,7 @@ static void add_approximate_exception_cycles(int nr)
                        case 4: cycles = 34; break;             /* Illegal instruction */
                        case 5: cycles = 34; break;             /* Division by zero */
                        case 6: cycles = 34; break;             /* CHK */
-                       case 7: cycles = 34; break;             /* TRAPV */
+                       case 7: cycles = 30; break;             /* TRAPV */
                        case 8: cycles = 34; break;             /* Privilege violation */
                        case 9: cycles = 34; break;             /* Trace */
                        case 10: cycles = 34; break;    /* Line-A */