From b9672c066949c7ea6fe86584ca2e0eedb72d81ae Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Wed, 20 Jan 2021 18:21:44 -0500 Subject: [PATCH] Gets beyond a prima facie convincing JSR/RET. --- InstructionSets/M50740/Executor.cpp | 12 ++++++++++++ InstructionSets/M50740/Executor.hpp | 1 + 2 files changed, 13 insertions(+) diff --git a/InstructionSets/M50740/Executor.cpp b/InstructionSets/M50740/Executor.cpp index 79c1c6b19..20033027c 100644 --- a/InstructionSets/M50740/Executor.cpp +++ b/InstructionSets/M50740/Executor.cpp @@ -90,6 +90,11 @@ void Executor::push(uint8_t value) { --s_; } +uint8_t Executor::pull() { + ++s_; + return read(s_); +} + template void Executor::perform() { // Deal with all modes that don't access memory up here; // those that access memory will go through a slightly longer @@ -264,6 +269,13 @@ template void Executor::perform(uint8_t *operand [[maybe_u case Operation::DEC: --*operand; set_nz(*operand); break; case Operation::INC: ++*operand; set_nz(*operand); break; + case Operation::RTS: { + uint16_t target = pull(); + target |= pull() << 8; + ++target; + set_program_counter(target); + } break; + /* Already removed from the instruction stream: diff --git a/InstructionSets/M50740/Executor.hpp b/InstructionSets/M50740/Executor.hpp index 0a5f4149c..5c99623c5 100644 --- a/InstructionSets/M50740/Executor.hpp +++ b/InstructionSets/M50740/Executor.hpp @@ -121,6 +121,7 @@ class Executor: public CachingExecutor { inline uint8_t read(uint16_t address); inline void write(uint16_t address, uint8_t value); inline void push(uint8_t value); + inline uint8_t pull(); }; }