mirror of
https://github.com/TomHarte/CLK.git
synced 2024-11-26 08:49:37 +00:00
Corrects performer population, lookup, calls.
This commit is contained in:
parent
9b92753e0a
commit
a601ac0cab
@ -127,7 +127,8 @@ template <
|
|||||||
// and until one branches.
|
// and until one branches.
|
||||||
has_branched_ = false;
|
has_branched_ = false;
|
||||||
for(auto index: program_) {
|
for(auto index: program_) {
|
||||||
performers_[index]();
|
const auto performer = performers_[index];
|
||||||
|
(static_cast<Executor *>(this)->*performer)();
|
||||||
if(has_branched_) break;
|
if(has_branched_) break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -144,7 +144,7 @@ template <Operation operation, AddressingMode addressing_mode> void Executor::pe
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <Operation operation> void Executor::perform(uint8_t *operand [[maybe_unused]]) {
|
template <Operation operation> void Executor::perform(uint8_t *operand [[maybe_unused]]) {
|
||||||
switch(operation) {
|
// switch(operation) {
|
||||||
default: assert(false);
|
// default: assert(false);
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@ namespace InstructionSet {
|
|||||||
namespace M50740 {
|
namespace M50740 {
|
||||||
|
|
||||||
class Executor;
|
class Executor;
|
||||||
using CachingExecutor = CachingExecutor<Executor, 0x1fff, 256, Instruction, false>;
|
using CachingExecutor = CachingExecutor<Executor, 0x1fff, 255, Instruction, false>;
|
||||||
|
|
||||||
class Executor: public CachingExecutor {
|
class Executor: public CachingExecutor {
|
||||||
public:
|
public:
|
||||||
@ -58,28 +58,35 @@ class Executor: public CachingExecutor {
|
|||||||
class PerformerLookup {
|
class PerformerLookup {
|
||||||
public:
|
public:
|
||||||
PerformerLookup() {
|
PerformerLookup() {
|
||||||
fill<int(MinOperation), int(MinAddressingMode)>(performers);
|
fill<int(MinOperation)>(performers_);
|
||||||
}
|
}
|
||||||
|
|
||||||
Performer performer(Operation operation, AddressingMode addressing_mode) {
|
Performer performer(Operation operation, AddressingMode addressing_mode) {
|
||||||
return performers[int(addressing_mode) * (MaxOperation - MinOperation) + int(operation) - MinOperation];
|
const auto index =
|
||||||
|
(int(operation) - MinOperation) * (1 + MaxAddressingMode - MinAddressingMode) +
|
||||||
|
(int(addressing_mode) - MinAddressingMode);
|
||||||
|
|
||||||
|
assert(index < decltype(index)(sizeof(performers_)/sizeof(*performers_)));
|
||||||
|
return performers_[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Performer performers[(MaxAddressingMode - MinAddressingMode) * (MaxOperation - MinOperation)];
|
Performer performers_[(1 + MaxAddressingMode - MinAddressingMode) * (1 + MaxOperation - MinOperation)];
|
||||||
|
|
||||||
template<int operation, int addressing_mode> void fill_operation(Performer *target) {
|
template<int operation, int addressing_mode> void fill_operation(Performer *target) {
|
||||||
*target = &Executor::perform<Operation(operation), AddressingMode(addressing_mode)>;
|
*target = &Executor::perform<Operation(operation), AddressingMode(addressing_mode)>;
|
||||||
if constexpr (addressing_mode+1 < MaxAddressingMode) {
|
|
||||||
|
if constexpr (addressing_mode+1 <= MaxAddressingMode) {
|
||||||
fill_operation<operation, addressing_mode+1>(target + 1);
|
fill_operation<operation, addressing_mode+1>(target + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template<int operation, int addressing_mode> void fill(Performer *target) {
|
template<int operation> void fill(Performer *target) {
|
||||||
fill_operation<operation, addressing_mode>(target);
|
fill_operation<operation, int(MinAddressingMode)>(target);
|
||||||
target += MaxOperation - MinOperation;
|
target += 1 + MaxAddressingMode - MinAddressingMode;
|
||||||
if constexpr (operation+1 < MaxOperation) {
|
|
||||||
fill<operation+1, addressing_mode>(target);
|
if constexpr (operation+1 <= MaxOperation) {
|
||||||
|
fill<operation+1>(target);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user