diff --git a/InstructionSets/M68k/Executor.hpp b/InstructionSets/M68k/Executor.hpp index 64e44b44d..2b122e135 100644 --- a/InstructionSets/M68k/Executor.hpp +++ b/InstructionSets/M68k/Executor.hpp @@ -50,6 +50,8 @@ template class Executor { void jsr(uint32_t offset); void link(uint32_t &address, uint32_t offset); void unlink(uint32_t &address); + template void movep_fromR(uint32_t reg, uint32_t address); + template void movep_toR(uint32_t ®, 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 e6d500885..49d34d6b5 100644 --- a/InstructionSets/M68k/Implementation/ExecutorImplementation.hpp +++ b/InstructionSets/M68k/Implementation/ExecutorImplementation.hpp @@ -393,6 +393,42 @@ void Executor::unlink(uint32_t &address) { address_[7].l += 4; } +template +template +void Executor::movep_fromR(uint32_t reg, uint32_t address) { + if constexpr (sizeof(IntT) == 4) { + bus_handler_.template write(address, uint8_t(reg >> 24)); + address += 2; + + bus_handler_.template write(address, uint8_t(reg >> 16)); + address += 2; + } + + bus_handler_.template write(address, uint8_t(reg >> 8)); + address += 2; + + bus_handler_.template write(address, uint8_t(reg)); +} + +template +template +void Executor::movep_toR(uint32_t ®, uint32_t address) { + if constexpr (sizeof(IntT) == 4) { + reg = bus_handler_.template read(address) << 24; + address += 2; + + reg |= bus_handler_.template read(address) << 26; + address += 2; + } else { + reg &= 0xffff0000; + } + + reg |= bus_handler_.template read(address) << 8; + address += 2; + + reg |= bus_handler_.template read(address); +} + } }