From ac6a9ab631a8c6ab34ac489f8e2bfd8e1426535b Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Fri, 6 May 2022 12:23:04 -0400 Subject: [PATCH] Fix TAS Dn. --- InstructionSets/M68k/Executor.hpp | 2 +- .../Implementation/ExecutorImplementation.hpp | 21 ++++++++++++------- .../Implementation/PerformImplementation.hpp | 2 +- .../68000ComparativeTests.mm | 5 ++++- 4 files changed, 20 insertions(+), 10 deletions(-) diff --git a/InstructionSets/M68k/Executor.hpp b/InstructionSets/M68k/Executor.hpp index 7ee2b779e..c77ddecaf 100644 --- a/InstructionSets/M68k/Executor.hpp +++ b/InstructionSets/M68k/Executor.hpp @@ -54,7 +54,7 @@ template class Executor { template void movem_toM(Preinstruction instruction, uint32_t source, uint32_t dest); template void movem_toR(Preinstruction instruction, uint32_t source, uint32_t dest); void pea(uint32_t address); - void tas(uint32_t address); + void tas(Preinstruction instruction, uint32_t address); // TODO: ownership of this shouldn't be here. struct Registers { diff --git a/InstructionSets/M68k/Implementation/ExecutorImplementation.hpp b/InstructionSets/M68k/Implementation/ExecutorImplementation.hpp index 9271f7930..96ee3ba00 100644 --- a/InstructionSets/M68k/Implementation/ExecutorImplementation.hpp +++ b/InstructionSets/M68k/Implementation/ExecutorImplementation.hpp @@ -402,15 +402,22 @@ void Executor::pea(uint32_t address) { } template -void Executor::tas(uint32_t address) { - uint8_t value = bus_handler_.template read(address); +void Executor::tas(Preinstruction instruction, uint32_t address) { + uint8_t original_value; + if(instruction.mode<0>() != AddressingMode::DataRegisterDirect) { + uint8_t value = bus_handler_.template read(address); + original_value = value; + value |= 0x80; + bus_handler_.template write(address, value); + } else { + original_value = uint8_t(address); + address |= 0x80; + registers_[instruction.reg<0>()].b = uint8_t(address); + } status_.overflow_flag_ = status_.carry_flag_ = 0; - status_.zero_result_ = value; - status_.negative_flag_ = value & 0x80; - value |= 0x80; - - bus_handler_.template write(address, value); + status_.zero_result_ = original_value; + status_.negative_flag_ = original_value & 0x80; } template diff --git a/InstructionSets/M68k/Implementation/PerformImplementation.hpp b/InstructionSets/M68k/Implementation/PerformImplementation.hpp index 8494f9cfe..b227d264f 100644 --- a/InstructionSets/M68k/Implementation/PerformImplementation.hpp +++ b/InstructionSets/M68k/Implementation/PerformImplementation.hpp @@ -794,7 +794,7 @@ template < */ case Operation::TAS: - flow_controller.tas(src.l); + flow_controller.tas(instruction, src.l); break; /* diff --git a/OSBindings/Mac/Clock SignalTests/68000ComparativeTests.mm b/OSBindings/Mac/Clock SignalTests/68000ComparativeTests.mm index d61b5caed..8064e14b3 100644 --- a/OSBindings/Mac/Clock SignalTests/68000ComparativeTests.mm +++ b/OSBindings/Mac/Clock SignalTests/68000ComparativeTests.mm @@ -49,6 +49,9 @@ // mulu_muls // neg_not // negx_clr +// swap +// tas +// tst // Issues to fix: // @@ -78,7 +81,7 @@ - (void)setUp { // To limit tests run to a subset of files and/or of tests, uncomment and fill in below. - _fileSet = [NSSet setWithArray:@[@"swap.json", @"tst.json", @"tas.json"]]; + _fileSet = [NSSet setWithArray:@[@"rts.json", @"rtr.json"]]; // _testSet = [NSSet setWithArray:@[@"NEGX 00c0"]]; // _fileSet = [NSSet setWithArray:@[@"jmp_jsr.json"]]; // _testSet = [NSSet setWithArray:@[@"CHK 41a8"]];