From 4a6512f5d579ae0fcfb88e87d5ac8868d0609746 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Sun, 22 May 2022 07:39:16 -0400 Subject: [PATCH] Reduce dispatch boilerplate. --- .../Implementation/68000Mk2Implementation.hpp | 300 ++++++++---------- .../Implementation/68000Mk2Storage.hpp | 4 +- 2 files changed, 142 insertions(+), 162 deletions(-) diff --git a/Processors/68000Mk2/Implementation/68000Mk2Implementation.hpp b/Processors/68000Mk2/Implementation/68000Mk2Implementation.hpp index c4e672114..f4a34e39a 100644 --- a/Processors/68000Mk2/Implementation/68000Mk2Implementation.hpp +++ b/Processors/68000Mk2/Implementation/68000Mk2Implementation.hpp @@ -182,9 +182,11 @@ void Processor() == InstructionSet::M68k::DataSize::LongWord) { \ SetupDataAccess(Microcycle::Read, Microcycle::SelectWord); \ - MoveToState(FetchOperand_l); \ + MoveToStateSpecific(FetchOperand_l); \ } else { \ if constexpr (InstructionSet::M68k::operand_size() == InstructionSet::M68k::DataSize::Byte) { \ SetupDataAccess(Microcycle::Read, Microcycle::SelectByte); \ } else { \ SetupDataAccess(Microcycle::Read, Microcycle::SelectWord); \ } \ - MoveToState(FetchOperand_bw); \ + MoveToStateSpecific(FetchOperand_bw); \ } #define Duplicate(x, y) \ @@ -515,10 +516,10 @@ void Processor R @@ -1672,12 +1651,12 @@ void Processor>= 1; ++register_index_; - MoveToState(MOVEMtoR_w_read); + MoveToStateSpecific(MOVEMtoR_w_read); BeginState(MOVEMtoR_l_read): // If there's nothing left to read, move on. if(!operand_[0].w) { - MoveToState(MOVEMtoR_finish); + MoveToStateSpecific(MOVEMtoR_finish); } // Find the next register to read, read it. @@ -1713,7 +1692,7 @@ void Processor>= 1; ++register_index_; - MoveToState(MOVEMtoR_l_read); + MoveToStateSpecific(MOVEMtoR_l_read); BeginState(MOVEMtoR_finish): // Perform one more read, spuriously. @@ -1726,7 +1705,7 @@ void Processor M @@ -1746,9 +1725,9 @@ void Processor>= 1; ++register_index_; - MoveToState(MOVEMtoM_w_write); + MoveToStateSpecific(MOVEMtoM_w_write); BeginState(MOVEMtoM_l_write): // If there's nothing left to read, move on. if(!operand_[0].w) { - MoveToState(MOVEMtoM_finish); + MoveToStateSpecific(MOVEMtoM_finish); } // Find the next register to write, write it. @@ -1797,12 +1776,12 @@ void Processor>= 1; ++register_index_; - MoveToState(MOVEMtoM_l_write); + MoveToStateSpecific(MOVEMtoM_l_write); BeginState(MOVEMtoM_w_write_predec): // If there's nothing left to read, move on. if(!operand_[0].w) { - MoveToState(MOVEMtoM_finish); + MoveToStateSpecific(MOVEMtoM_finish); } // Find the next register to write, write it. @@ -1816,12 +1795,12 @@ void Processor>= 1; --register_index_; - MoveToState(MOVEMtoM_w_write_predec); + MoveToStateSpecific(MOVEMtoM_w_write_predec); BeginState(MOVEMtoM_l_write_predec): // If there's nothing left to read, move on. if(!operand_[0].w) { - MoveToState(MOVEMtoM_finish); + MoveToStateSpecific(MOVEMtoM_finish); } // Find the next register to write, write it. @@ -1838,7 +1817,7 @@ void Processor>= 1; --register_index_; - MoveToState(MOVEMtoM_l_write_predec); + MoveToStateSpecific(MOVEMtoM_l_write_predec); BeginState(MOVEMtoM_finish): // Write the address back to the register if @@ -1848,7 +1827,7 @@ void Processor= 0) { - MoveToState(StandardException); + MoveToStateSpecific(StandardException); } // DIVU and DIVS are always to a register, so just write back here @@ -1873,7 +1852,7 @@ void Processor void complete_bcc(bool, IntT); inline void complete_dbcc(bool, bool, int16_t); inline void bsr(uint32_t); - inline void jsr(uint32_t) {} // - inline void jmp(uint32_t) {} // inline void rtr() {} // inline void rte() {} // inline void rts() {} // @@ -154,6 +152,8 @@ struct ProcessorBase: public InstructionSet::M68k::NullFlowController { template void movep(Preinstruction, uint32_t, uint32_t) {} template void movem_toM(Preinstruction, uint32_t, uint32_t) {} template void movem_toR(Preinstruction, uint32_t, uint32_t) {} + void jsr(uint32_t) {} + void jmp(uint32_t) {} // Some microcycles that will be modified as required and used in the main loop; // the semantics of a switch statement make in-place declarations awkward and