mirror of
https://github.com/TomHarte/CLK.git
synced 2025-01-15 05:31:30 +00:00
Reduce repetition.
This commit is contained in:
parent
5a77f0c93c
commit
769aed10ea
@ -34,31 +34,23 @@ uint32_t address(
|
||||
MemoryT &memory
|
||||
) {
|
||||
// TODO: non-word indexes and bases.
|
||||
uint32_t address;
|
||||
switch(source) {
|
||||
default: return 0;
|
||||
case Source::Indirect: {
|
||||
uint16_t zero = 0;
|
||||
address = *resolve<model, uint16_t>(instruction, pointer.index(), pointer, registers, memory, &zero);
|
||||
if constexpr (is_32bit(model)) {
|
||||
address <<= pointer.scale();
|
||||
if constexpr (source == Source::DirectAddress) {
|
||||
return instruction.offset();
|
||||
}
|
||||
address += instruction.offset() + *resolve<model, uint16_t>(instruction, pointer.base(), pointer, registers, memory);
|
||||
} break;
|
||||
|
||||
case Source::IndirectNoBase: {
|
||||
uint32_t address;
|
||||
uint16_t zero = 0;
|
||||
address = *resolve<model, uint16_t>(instruction, pointer.index(), pointer, registers, memory, &zero);
|
||||
if constexpr (is_32bit(model)) {
|
||||
address <<= pointer.scale();
|
||||
}
|
||||
address += instruction.offset();
|
||||
} break;
|
||||
|
||||
case Source::DirectAddress: return instruction.offset();
|
||||
}
|
||||
if constexpr (source == Source::IndirectNoBase) {
|
||||
return address;
|
||||
}
|
||||
return address + *resolve<model, uint16_t>(instruction, pointer.base(), pointer, registers, memory);
|
||||
}
|
||||
|
||||
template <Model model, typename IntT, typename InstructionT, typename RegistersT, typename MemoryT>
|
||||
IntT *resolve(
|
||||
|
Loading…
x
Reference in New Issue
Block a user