From 14532867a4cea68fb0f46f08ceaab2fafb1f83ec Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Mon, 2 May 2022 08:00:56 -0400 Subject: [PATCH] Sneaks towards testing EXT. --- InstructionSets/M68k/Sequence.cpp | 4 +- .../68000ComparativeTests.mm | 38 +++++++++++++++++++ 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/InstructionSets/M68k/Sequence.cpp b/InstructionSets/M68k/Sequence.cpp index ef95f9c37..ded0749b8 100644 --- a/InstructionSets/M68k/Sequence.cpp +++ b/InstructionSets/M68k/Sequence.cpp @@ -63,7 +63,9 @@ template uint32_t Sequence::steps_for(Operation operation) { // // Single operand, read-modify-write. // - case Operation::NBCD: return Steps< + case Operation::NBCD: + case Operation::EXTbtow: case Operation::EXTwtol: + return Steps< Step::FetchOp1, Step::Perform, Step::StoreOp1 diff --git a/OSBindings/Mac/Clock SignalTests/68000ComparativeTests.mm b/OSBindings/Mac/Clock SignalTests/68000ComparativeTests.mm index 092f43920..08a3ea9cd 100644 --- a/OSBindings/Mac/Clock SignalTests/68000ComparativeTests.mm +++ b/OSBindings/Mac/Clock SignalTests/68000ComparativeTests.mm @@ -28,6 +28,7 @@ - (void)setUp { // To limit tests run to a subset of files and/or of tests, uncomment and fill in below. + _fileSet = [NSSet setWithArray:@[@"ext.json"]]; // _fileSet = [NSSet setWithArray:@[@"jmp_jsr.json"]]; // _testSet = [NSSet setWithArray:@[@"CHK 41a8"]]; } @@ -216,11 +217,48 @@ processor.run_for_instructions(instructions); } + // Initial test-case implementation: + // do a very sedate read and write. + template IntT read(uint32_t address) { + if constexpr (sizeof(IntT) == 1) { + return IntT(ram[address & 0xffffff]); + } + + if constexpr (sizeof(IntT) == 2) { + return IntT( + (ram[address & 0xffffff] << 8) | + ram[(address+1) & 0xffffff] + ); + } + + if constexpr (sizeof(IntT) == 4) { + return IntT( + (ram[address & 0xffffff] << 24) | + (ram[(address+1) & 0xffffff] << 16) | + (ram[(address+2) & 0xffffff] << 8) | + ram[(address+3) & 0xffffff] + ); + } return 0; } template void write(uint32_t address, IntT value) { + if constexpr (sizeof(IntT) == 1) { + ram[address & 0xffffff] = uint8_t(value); + } + + if constexpr (sizeof(IntT) == 2) { + ram[address & 0xffffff] = uint8_t(value >> 8); + ram[(address+1) & 0xffffff] = uint8_t(value); + } + + if constexpr (sizeof(IntT) == 4) { + ram[address & 0xffffff] = uint8_t(value >> 24); + ram[(address+1) & 0xffffff] = uint8_t(value >> 16); + ram[(address+2) & 0xffffff] = uint8_t(value >> 8); + ram[(address+3) & 0xffffff] = uint8_t(value); + } } }; auto uniqueTest68000 = std::make_unique();