mirror of
https://github.com/TomHarte/CLK.git
synced 2024-11-26 23:52:26 +00:00
Remove branch from combined_mode
.
On x86 it was probably only a conditional move, but this is fine.
This commit is contained in:
parent
4c806d7c51
commit
72772c9a83
@ -14,22 +14,27 @@ using namespace InstructionSet::M68k;
|
|||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
constexpr AddressingMode extended_modes[] = {
|
||||||
|
AddressingMode::AbsoluteShort, // 1'000
|
||||||
|
AddressingMode::AbsoluteLong, // 1'001
|
||||||
|
AddressingMode::ProgramCounterIndirectWithDisplacement, // 1'010
|
||||||
|
AddressingMode::ProgramCounterIndirectWithIndex8bitDisplacement, // 1'011
|
||||||
|
AddressingMode::ImmediateData, // 1'100
|
||||||
|
AddressingMode::None, // [1'101]
|
||||||
|
AddressingMode::None, // [1'110]
|
||||||
|
AddressingMode::None, // [1'111]
|
||||||
|
};
|
||||||
|
|
||||||
/// @returns The @c AddressingMode given the specified mode and reg, subject to potential
|
/// @returns The @c AddressingMode given the specified mode and reg, subject to potential
|
||||||
/// aliasing on the '020+ as described above the @c AddressingMode enum.
|
/// aliasing on the '020+ as described above the @c AddressingMode enum.
|
||||||
constexpr AddressingMode combined_mode(int raw_mode, int reg) {
|
constexpr AddressingMode combined_mode(int mode, int reg) {
|
||||||
const auto mode = AddressingMode(raw_mode);
|
assert(mode >= 0 && mode < 8);
|
||||||
constexpr AddressingMode extended_modes[] = {
|
assert(reg >= 0 && reg < 8);
|
||||||
AddressingMode::AbsoluteShort,
|
|
||||||
AddressingMode::AbsoluteLong,
|
|
||||||
AddressingMode::ProgramCounterIndirectWithDisplacement,
|
|
||||||
AddressingMode::ProgramCounterIndirectWithIndex8bitDisplacement,
|
|
||||||
AddressingMode::ImmediateData,
|
|
||||||
|
|
||||||
AddressingMode::None,
|
// Look up mode, mapping invalid combinations to ::None, branchlessly.
|
||||||
AddressingMode::None,
|
const int use_reg = ((mode + 1) >> 3) & 1;
|
||||||
AddressingMode::None,
|
const AddressingMode modes[] = { AddressingMode(mode), extended_modes[reg] };
|
||||||
};
|
return modes[use_reg];
|
||||||
return (raw_mode != 7) ? mode : extended_modes[reg];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user