1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-11-02 16:04:59 +00:00

Gets beyond a prima facie convincing JSR/RET.

This commit is contained in:
Thomas Harte 2021-01-20 18:21:44 -05:00
parent e58608b25a
commit b9672c0669
2 changed files with 13 additions and 0 deletions

View File

@ -90,6 +90,11 @@ void Executor::push(uint8_t value) {
--s_;
}
uint8_t Executor::pull() {
++s_;
return read(s_);
}
template <Operation operation, AddressingMode addressing_mode> 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 <Operation operation> 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:

View File

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