From: Toni Wilen Date: Thu, 12 May 2022 18:57:54 +0000 (+0300) Subject: STOP update X-Git-Tag: 41000~236 X-Git-Url: https://git.unchartedbackwaters.co.uk/w/?a=commitdiff_plain;h=08f964ad1b1d0c403a3aa1af143173bf97c4acf8;p=francis%2Fwinuae.git STOP update --- diff --git a/gencpu.cpp b/gencpu.cpp index 7fcf8a0d..78e9fde8 100644 --- a/gencpu.cpp +++ b/gencpu.cpp @@ -6669,9 +6669,6 @@ static void gen_opcode (unsigned int opcode) // 68000/68010: Traced STOP runs 4 cycles faster. // 68020 68030 68040: STOP works normally // 68060: Immediate privilege violation exception - if ((cpu_level == 0 || cpu_level == 1) && using_ce) { - out("%s(regs.t1 ? 4 : 8);\n", do_cycles); - } if (cpu_level >= 5) { out("if (!(sr & 0x2000)) {\n"); out("Exception(8);\n"); @@ -6681,6 +6678,9 @@ static void gen_opcode (unsigned int opcode) out("regs.sr = sr;\n"); makefromsr(); out("m68k_setstopped();\n"); + if ((cpu_level == 0 || cpu_level == 1) && (using_ce || using_prefetch)) { + out("%s(4);\n", do_cycles); + } sync_m68k_pc(); // STOP does not prefetch anything did_prefetch = -1; diff --git a/newcpu.cpp b/newcpu.cpp index 2dcdb4ab..89acfc0c 100644 --- a/newcpu.cpp +++ b/newcpu.cpp @@ -4484,17 +4484,19 @@ static int do_specialties (int cycles) Exception (3); } - if ((regs.spcflags & SPCFLAG_STOP) && regs.s == 0 && currprefs.cpu_model <= 68010) { - // 68000/68010 undocumented special case: - // if STOP clears S-bit and T was not set: - // cause privilege violation exception, PC pointing to following instruction. - // If T was set before STOP: STOP works as documented. - m68k_unset_stop(); - Exception(8); - } - bool first = true; while (regs.spcflags & SPCFLAG_STOP) { + + if (regs.s == 0 && currprefs.cpu_model <= 68010) { + // 68000/68010 undocumented special case: + // if STOP clears S-bit and T was not set: + // cause privilege violation exception, PC pointing to following instruction. + // If T was set before STOP: STOP works as documented. + m68k_unset_stop(); + Exception(8); + break; + } + isstopped: check_uae_int_request(); { @@ -4515,11 +4517,12 @@ static int do_specialties (int cycles) if (m68k_interrupt_delay) { unset_special(SPCFLAG_INT); - if (first) { - ipl_fetch(); - } if (time_for_interrupt()) { - x_do_cycles(4 * cpucycleunit); + if (!first) { + // extra loop because even after higher ipl detection, + // stop needs to do one more loop before it exits. + x_do_cycles(4 * cpucycleunit); + } do_interrupt(regs.ipl); break; } @@ -4544,23 +4547,16 @@ static int do_specialties (int cycles) } } - if (!first) { - if (currprefs.cpu_compatible) { - x_do_cycles(2 * cpucycleunit); - ipl_fetch(); - x_do_cycles(2 * cpucycleunit); - } else { - x_do_cycles(4 * cpucycleunit); - ipl_fetch(); - } - } first = false; + ipl_fetch(); + x_do_cycles(4 * cpucycleunit); if (regs.spcflags & SPCFLAG_COPPER) do_copper(); if (regs.spcflags & SPCFLAG_MODE_CHANGE) { m68k_resumestopped(); + fill_prefetch(); return 1; } @@ -7634,18 +7630,14 @@ void m68k_setstopped (void) if ((regs.spcflags & SPCFLAG_DOTRACE) == 0) { m68k_set_stop(); } else { - m68k_resumestopped (); + m68k_resumestopped(); } } -void m68k_resumestopped (void) +void m68k_resumestopped(void) { if (!regs.stopped) return; - if (currprefs.cpu_cycle_exact && currprefs.cpu_model == 68000) { - x_do_cycles (6 * cpucycleunit); - } - fill_prefetch (); m68k_unset_stop(); }