diff --git a/InstructionSets/M68k/Executor.hpp b/InstructionSets/M68k/Executor.hpp index 72e334961..4d0198f22 100644 --- a/InstructionSets/M68k/Executor.hpp +++ b/InstructionSets/M68k/Executor.hpp @@ -27,8 +27,8 @@ enum class FunctionCode { }; struct BusHandler { - template void write(uint32_t address, IntT value); - template IntT read(uint32_t address); + template void write(uint32_t address, IntT value, FunctionCode function); + template IntT read(uint32_t address, FunctionCode function); }; /// Ties together the decoder, sequencer and performer to provide an executor for 680x0 instruction streams. @@ -92,7 +92,7 @@ template class Executor { void read(DataSize size, uint32_t address, CPU::SlicedInt32 &value); void write(DataSize size, uint32_t address, CPU::SlicedInt32 value); - template IntT read(uint32_t address); + template IntT read(uint32_t address, bool is_from_pc = false); template void write(uint32_t address, IntT value); template IntT read_pc(); diff --git a/InstructionSets/M68k/Implementation/ExecutorImplementation.hpp b/InstructionSets/M68k/Implementation/ExecutorImplementation.hpp index dfb4c5ef2..c1f3dc08a 100644 --- a/InstructionSets/M68k/Implementation/ExecutorImplementation.hpp +++ b/InstructionSets/M68k/Implementation/ExecutorImplementation.hpp @@ -37,15 +37,17 @@ void Executor::reset() { template template -IntT Executor::read(uint32_t address) { +IntT Executor::read(uint32_t address, bool is_from_pc) { // TODO: check for an alignment exception, both here and in write. - return bus_handler_.template read(address); + // + // TODO: omit generation of the FunctionCode if the BusHandler doesn't receive it. + return bus_handler_.template read(address, FunctionCode((status_.is_supervisor_ << 2) | 1 << int(is_from_pc))); } template template void Executor::write(uint32_t address, IntT value) { - bus_handler_.template write(address, value); + bus_handler_.template write(address, value, FunctionCode((status_.is_supervisor_ << 2) | 1)); } template @@ -68,7 +70,7 @@ void Executor::write(DataSize size, uint32_t address, CPU::Sl template template IntT Executor::read_pc() { - const IntT result = read(program_counter_.l); + const IntT result = read(program_counter_.l, true); if constexpr (sizeof(IntT) == 4) { program_counter_.l += 4; diff --git a/OSBindings/Mac/Clock SignalTests/68000ComparativeTests.mm b/OSBindings/Mac/Clock SignalTests/68000ComparativeTests.mm index b15506724..fa707dde5 100644 --- a/OSBindings/Mac/Clock SignalTests/68000ComparativeTests.mm +++ b/OSBindings/Mac/Clock SignalTests/68000ComparativeTests.mm @@ -227,7 +227,7 @@ // Initial test-case implementation: // do a very sedate read and write. - template IntT read(uint32_t address) { + template IntT read(uint32_t address, InstructionSet::M68k::FunctionCode) { if constexpr (sizeof(IntT) == 1) { return IntT(ram[address & 0xffffff]); } @@ -250,7 +250,7 @@ return 0; } - template void write(uint32_t address, IntT value) { + template void write(uint32_t address, IntT value, InstructionSet::M68k::FunctionCode) { if constexpr (sizeof(IntT) == 1) { ram[address & 0xffffff] = uint8_t(value); }