From c78c1211599080c03c341676a27da4641e9dbde4 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Mon, 18 Jan 2021 20:16:01 -0500 Subject: [PATCH] Succeeds at executing a single instruction. --- InstructionSets/CachingExecutor.hpp | 4 ---- InstructionSets/M50740/Executor.cpp | 20 +++++++++++++++++--- InstructionSets/M50740/Executor.hpp | 3 +++ 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/InstructionSets/CachingExecutor.hpp b/InstructionSets/CachingExecutor.hpp index 469ebbf82..1c57b7393 100644 --- a/InstructionSets/CachingExecutor.hpp +++ b/InstructionSets/CachingExecutor.hpp @@ -95,10 +95,6 @@ template < // indexed by array position, which is a lot more compact than a generic pointer. std::array 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 diff --git a/InstructionSets/M50740/Executor.cpp b/InstructionSets/M50740/Executor.cpp index a3067f14a..7e487506e 100644 --- a/InstructionSets/M50740/Executor.cpp +++ b/InstructionSets/M50740/Executor.cpp @@ -10,6 +10,7 @@ #include #include +#include using namespace InstructionSet::M50740; @@ -144,7 +145,20 @@ template void Executor::pe } template 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); } diff --git a/InstructionSets/M50740/Executor.hpp b/InstructionSets/M50740/Executor.hpp index 16273d1bd..81f0f3f21 100644 --- a/InstructionSets/M50740/Executor.hpp +++ b/InstructionSets/M50740/Executor.hpp @@ -100,6 +100,8 @@ class Executor: public CachingExecutor { */ template 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_; };