diff --git a/InstructionSets/M68k/Implementation/PerformImplementation.hpp b/InstructionSets/M68k/Implementation/PerformImplementation.hpp index ea1ec6718..525135228 100644 --- a/InstructionSets/M68k/Implementation/PerformImplementation.hpp +++ b/InstructionSets/M68k/Implementation/PerformImplementation.hpp @@ -40,12 +40,13 @@ namespace M68k { template < Model model, - typename FlowController + typename FlowController, + Operation operation = Operation::Undefined > void perform(Preinstruction instruction, CPU::SlicedInt32 &src, CPU::SlicedInt32 &dest, Status &status, FlowController &flow_controller) { #define sub_overflow() ((result ^ destination) & (destination ^ source)) #define add_overflow() ((result ^ destination) & ~(destination ^ source)) - switch(instruction.operation) { + switch((operation != Operation::Undefined) ? operation : instruction.operation) { /* ABCD adds the lowest bytes from the source and destination using BCD arithmetic, obeying the extend flag. diff --git a/InstructionSets/M68k/Perform.hpp b/InstructionSets/M68k/Perform.hpp index 404ec5833..fe032ab2b 100644 --- a/InstructionSets/M68k/Perform.hpp +++ b/InstructionSets/M68k/Perform.hpp @@ -22,13 +22,18 @@ struct NullFlowController { void consume_cycles(int) {} }; -/// Performs @c op using @c source and @c dest (which mmay be ignored as per the semantics of the operation). +/// Performs @c instruction using @c source and @c dest (which mmay be ignored as per the semantics of the operation). /// And change in processor status will be applied to @c status. If this operation raises an exception, causes a /// branch, or consumes additional cycles due to the particular value of the operands (on the 68000, think DIV or MUL), /// that'll be notified to the @c flow_controller. +/// +/// If the template parameter @c operation is not @c Operation::Undefined then that operation will be performed, ignoring +/// whatever is specifed in @c instruction. This allows selection either at compile time or at run time; per Godbolt all modern +/// compilers seem to be smart enough fully to optimise the compile-time case. template < Model model, - typename FlowController + typename FlowController, + Operation operation = Operation::Undefined > void perform(Preinstruction instruction, CPU::RegisterPair32 &source, CPU::RegisterPair32 &dest, Status &status, FlowController &flow_controller); }