1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-09-28 09:54:49 +00:00

Provide both compile- and run-time operation selection options.

This commit is contained in:
Thomas Harte 2022-05-01 17:39:56 -04:00
parent fe8f0d960d
commit 3c26177239
2 changed files with 10 additions and 4 deletions

View File

@ -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.

View File

@ -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);
}