From e066546c13ccd2c0367c55cdbb573b1313e29e11 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Mon, 13 Jun 2022 14:08:42 -0400 Subject: [PATCH] Resolve PEA timing errors. --- .../Mac/Clock SignalTests/68000OldVsNew.mm | 15 +++-- .../Implementation/68000Mk2Implementation.hpp | 64 +++++++++++++++++-- 2 files changed, 70 insertions(+), 9 deletions(-) diff --git a/OSBindings/Mac/Clock SignalTests/68000OldVsNew.mm b/OSBindings/Mac/Clock SignalTests/68000OldVsNew.mm index 9f924f7bd..1665652fd 100644 --- a/OSBindings/Mac/Clock SignalTests/68000OldVsNew.mm +++ b/OSBindings/Mac/Clock SignalTests/68000OldVsNew.mm @@ -262,7 +262,6 @@ template struct Tester { // InstructionSet::M68k::Operation::MOVEb, // InstructionSet::M68k::Operation::MOVEw, // InstructionSet::M68k::Operation::MOVEl, -// InstructionSet::M68k::Operation::PEA, // InstructionSet::M68k::Operation::MOVEtoSR, // Old implementation doesn't repeat a PC fetch. // InstructionSet::M68k::Operation::MOVEtoCCR, // Old implementation doesn't repeat a PC fetch. // InstructionSet::M68k::Operation::CMPAl, // Old implementation omits an idle cycle before -(An) @@ -285,6 +284,7 @@ template struct Tester { // InstructionSet::M68k::Operation::TAS, // Old implementation just doesn't match published cycle counts. }; + int testsRun = 0; std::set failing_operations; for(int c = 0; c < 65536; c++) { // printf("%04x\n", c); @@ -305,6 +305,8 @@ template struct Tester { // Test each 1000 times. for(int test = 0; test < 100; test++) { + ++testsRun; + // Establish with certainty the initial memory state. random_store.clear(); newTester->reset_with_opcode(c); @@ -408,9 +410,14 @@ template struct Tester { } } - printf("\nAll failing operations:\n"); - for(const auto operation: failing_operations) { - printf("%d,\n", int(operation)); + printf("%d tests run\n", testsRun); + if(failing_operations.empty()) { + printf("No failures\n"); + } else { + printf("\nAll failing operations:\n"); + for(const auto operation: failing_operations) { + printf("%d,\n", int(operation)); + } } } diff --git a/Processors/68000Mk2/Implementation/68000Mk2Implementation.hpp b/Processors/68000Mk2/Implementation/68000Mk2Implementation.hpp index 62ced29af..4b207b005 100644 --- a/Processors/68000Mk2/Implementation/68000Mk2Implementation.hpp +++ b/Processors/68000Mk2/Implementation/68000Mk2Implementation.hpp @@ -64,8 +64,10 @@ enum ExecutionState: int { /// Perform the proper sequence to fetch a byte or word operand. AddressingDispatch(FetchOperand_bw), + /// Perform the proper sequence to fetch a long-word operand. AddressingDispatch(FetchOperand_l), + /// Perform the sequence to calculate an effective address, but don't fetch from it. /// There's a lack of uniformity in the bus programs used by the 68000 for relevant /// instructions; this entry point uses: @@ -76,6 +78,7 @@ enum ExecutionState: int { /// (d16, PC) np (d8, PC, Xn) np n /// (xxx).w np (xxx).l np np AddressingDispatch(CalcEffectiveAddress), + /// Similar to CalcEffectiveAddress, but varies slightly in the patterns: /// /// -(An) n @@ -153,7 +156,6 @@ enum ExecutionState: int { DIVU_DIVS, Perform_idle_dyamic_Dn, LEA, - PEA, TAS, MOVEtoCCRSR, RTR, @@ -169,6 +171,10 @@ enum ExecutionState: int { AddressRegisterIndirectWithIndex8bitDisplacement_n_np, ProgramCounterIndirectWithIndex8bitDisplacement_n_np, + + AddressingDispatch(PEA), + PEA_np_nS_ns, // Used to complete (An), (d16, [An/PC]) and (d8, [An/PC], Xn). + PEA_np_nS_ns_np, // Used to complete (xxx).w and (xxx).l }; #undef AddressingDispatch @@ -961,10 +967,7 @@ void Processor