1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-11-26 23:52:26 +00:00

Corrects RTS behaviour: the return address on the stack is off by one.

Dormann's tests now proceed to a BRK.
This commit is contained in:
Thomas Harte 2020-10-08 16:55:45 -04:00
parent 907c3374c3
commit 054e0af071
3 changed files with 9 additions and 3 deletions

View File

@ -455,6 +455,10 @@ template <typename BusHandler> void Processor<BusHandler>::run_for(const Cycles
pc_ = data_buffer_.value;
break;
case RTS:
pc_ = data_buffer_.value + 1;
break;
case JSL:
program_bank_ = instruction_buffer_.value & 0xff0000;
[[fallthrough]];
@ -678,7 +682,6 @@ template <typename BusHandler> void Processor<BusHandler>::run_for(const Cycles
} break;
// TODO:
// PHK,
// TRB, TSB,
// REP, SEP,
// XCE, XBA,

View File

@ -661,7 +661,7 @@ struct CPU::WDC65816::ProcessorStorageConstructor {
target(CyclePull); // PCH
target(CycleAccessStack); // IO
target(OperationPerform); // [JMP, to perform the RTS]
target(OperationPerform); // [RTS]
}
// 22i. Stack; s, RTL.
@ -812,7 +812,7 @@ ProcessorStorage::ProcessorStorage() {
/* 0x5e LSR a, x */ op(absolute_x_rmw, LSR);
/* 0x5f EOR al, x */ op(absolute_long_x, EOR);
/* 0x60 RTS s */ op(stack_rts, JMPind); // [sic]; loads the PC from data as per an RTS.
/* 0x60 RTS s */ op(stack_rts, RTS);
/* 0x61 ADC (d, x) */ op(direct_indexed_indirect, ADC);
/* 0x62 PER s */ op(stack_per, NOP);
/* 0x63 ADC d, s */ op(stack_relative, ADC);

View File

@ -191,6 +191,9 @@ enum Operation: uint8_t {
/// placing the old PC into the data buffer (and only the PC; PBR not included).
JSL,
/// Loads the PC with the contents of the data buffer + 1.
RTS,
/// i.e. jump to vector. TODO: is this really distinct from JMP? I'm assuming so for now,
/// as I assume the PBR is implicitly modified. But then is it just JML? We'll see.
BRK,