From 2e42bda0a34cb97cab8834d8bcfa0f0bd1a1480d Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Wed, 8 Jun 2022 16:15:33 -0400 Subject: [PATCH] Permit instructions that end in an address error to differ in transactions. --- .../Mac/Clock SignalTests/68000OldVsNew.mm | 66 +++++++++++-------- 1 file changed, 38 insertions(+), 28 deletions(-) diff --git a/OSBindings/Mac/Clock SignalTests/68000OldVsNew.mm b/OSBindings/Mac/Clock SignalTests/68000OldVsNew.mm index 605957e94..24df61569 100644 --- a/OSBindings/Mac/Clock SignalTests/68000OldVsNew.mm +++ b/OSBindings/Mac/Clock SignalTests/68000OldVsNew.mm @@ -258,6 +258,8 @@ template struct Tester { srand(68000); for(int c = 0; c < 65536; c++) { + printf("%04x\n", c); + // Test only defined opcodes. const auto instruction = decoder.decode(uint16_t(c)); if(instruction.operation == InstructionSet::M68k::Operation::Undefined) { @@ -295,37 +297,45 @@ template struct Tester { newTester->run_instructions(1); oldTester->run_instructions(1); - // Compare bus activity. - const auto &oldTransactions = oldTester->bus_handler.transactions; - const auto &newTransactions = newTester->bus_handler.transactions; - - auto newIt = newTransactions.begin(); - auto oldIt = oldTransactions.begin(); - while(newIt != newTransactions.end() && oldIt != oldTransactions.end()) { - if(*newIt != *oldIt) { - printf("Mismatch in %s, test %d:\n", instruction.to_string().c_str(), test); - - auto repeatIt = newTransactions.begin(); - while(repeatIt != newIt) { - repeatIt->print(); - ++repeatIt; - } - printf("---\n"); - printf("o: "); oldIt->print(); - printf("n: "); newIt->print(); - printf("\n"); - - break; - } - - ++newIt; - ++oldIt; - } - - // Compare registers. + // Grab final states. oldState = oldTester->processor.get_state(); newState = newTester->processor.get_state(); + // Compare bus activity only if it doesn't look like an address + // error occurred. Don't check those as I don't have good information + // on the proper stack write order, so transactions are permitted to differ. + // + // Net effect will be 50% fewer transaction comparisons for instructions that + // can trigger an address error. + if(oldState.program_counter != 0x1404 || newState.registers.program_counter != 0x1404) { + const auto &oldTransactions = oldTester->bus_handler.transactions; + const auto &newTransactions = newTester->bus_handler.transactions; + + auto newIt = newTransactions.begin(); + auto oldIt = oldTransactions.begin(); + while(newIt != newTransactions.end() && oldIt != oldTransactions.end()) { + if(*newIt != *oldIt) { + printf("Mismatch in %s, test %d:\n", instruction.to_string().c_str(), test); + + auto repeatIt = newTransactions.begin(); + while(repeatIt != newIt) { + repeatIt->print(); + ++repeatIt; + } + printf("---\n"); + printf("o: "); oldIt->print(); + printf("n: "); newIt->print(); + printf("\n"); + + break; + } + + ++newIt; + ++oldIt; + } + } + + // Compare registers. bool mismatch = false; for(int c = 0; c < 8; c++) { mismatch |= oldState.data[c] != newState.registers.data[c];