mirror of
https://github.com/TomHarte/CLK.git
synced 2024-11-26 08:49:37 +00:00
Succeeds at executing a single instruction.
This commit is contained in:
parent
e71e506883
commit
c78c121159
@ -95,10 +95,6 @@ template <
|
||||
// indexed by array position, which is a lot more compact than a generic pointer.
|
||||
std::array<Performer, max_performer_count> performers_;
|
||||
|
||||
// TODO: should I include a program counter at all? Are there platforms
|
||||
// for which the expense of retaining opcode length doesn't buy any benefit?
|
||||
ProgramCounterType program_counter_;
|
||||
|
||||
|
||||
/*!
|
||||
Moves the current point of execution to @c address, updating necessary performer caches
|
||||
|
@ -10,6 +10,7 @@
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
|
||||
using namespace InstructionSet::M50740;
|
||||
|
||||
@ -144,7 +145,20 @@ template <Operation operation, AddressingMode addressing_mode> void Executor::pe
|
||||
}
|
||||
|
||||
template <Operation operation> void Executor::perform(uint8_t *operand [[maybe_unused]]) {
|
||||
// switch(operation) {
|
||||
// default: assert(false);
|
||||
// }
|
||||
switch(operation) {
|
||||
case Operation::LDA: a_ = *operand; break; // TODO: flags (for all three here).
|
||||
case Operation::LDX: x_ = *operand; break;
|
||||
case Operation::LDY: y_ = *operand; break;
|
||||
|
||||
case Operation::STA: *operand = a_; break;
|
||||
case Operation::STX: *operand = x_; break;
|
||||
case Operation::STY: *operand = y_; break;
|
||||
|
||||
default: assert(false);
|
||||
}
|
||||
}
|
||||
|
||||
void Executor::set_program_counter(uint16_t address) {
|
||||
program_counter_ = address;
|
||||
CachingExecutor::set_program_counter(address);
|
||||
}
|
||||
|
@ -100,6 +100,8 @@ class Executor: public CachingExecutor {
|
||||
*/
|
||||
template <Operation operation, AddressingMode addressing_mode> void perform();
|
||||
|
||||
void set_program_counter(uint16_t address);
|
||||
|
||||
private:
|
||||
// MARK: - Instruction set state.
|
||||
|
||||
@ -107,6 +109,7 @@ class Executor: public CachingExecutor {
|
||||
uint8_t memory_[0x2000];
|
||||
|
||||
// Registers.
|
||||
uint16_t program_counter_;
|
||||
uint8_t a_, x_, y_;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user