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(); }; }