1
0
mirror of https://github.com/TomHarte/CLK.git synced 2025-01-26 15:32:04 +00:00

Ensure relevant throwaway stack reads use the previous stack address.

TODO: can CycleFetchPreviousThrowaway be used more widely?
This commit is contained in:
Thomas Harte 2022-06-24 14:00:03 -04:00
parent ef5ac1442f
commit 4467eb1c41
3 changed files with 14 additions and 8 deletions

View File

@ -103,6 +103,10 @@ template <typename BusHandler, bool uses_ready_line> void Processor<BusHandler,
perform_bus(((registers_.pc - 1) & 0xffff) | registers_.program_bank, &bus_throwaway_, MOS6502Esque::InternalOperationRead);
break;
case CycleFetchPreviousThrowaway:
perform_bus(bus_address_, &bus_throwaway_, MOS6502Esque::InternalOperationRead);
break;
//
// Data fetches and stores.
//

View File

@ -320,7 +320,7 @@ struct CPU::WDC65816::ProcessorStorageConstructor {
target(OperationCopyPBRToData); // Copy PBR to the data register.
target(CyclePush); // PBR.
target(CycleAccessStack); // IO.
target(CycleFetchPreviousThrowaway); // IO.
target(CycleFetchPC); // New PBR.
@ -728,14 +728,14 @@ struct CPU::WDC65816::ProcessorStorageConstructor {
// 22h. Stack; s, RTS.
static void stack_rts(AccessType, bool, const std::function<void(MicroOp)> &target) {
target(CycleFetchPCThrowaway); // IO.
target(CycleFetchPCThrowaway); // IO.
target(CycleFetchPCThrowaway); // IO.
target(CycleFetchPCThrowaway); // IO.
target(CyclePull); // PCL.
target(CyclePull); // PCH.
target(CycleAccessStack); // IO.
target(CyclePull); // PCL.
target(CyclePull); // PCH.
target(CycleFetchPreviousThrowaway); // IO.
target(OperationPerform); // [RTS]
target(OperationPerform); // [RTS]
}
// 22i. Stack; s, RTL.

View File

@ -15,6 +15,8 @@ enum MicroOp: uint8_t {
CycleFetchPCThrowaway,
/// Fetches a byte from (PC - 1), and throws it away; useful for IO cycles that immediately follow incremented PCs.
CycleFetchPreviousPCThrowaway,
/// Fetches from whichever address was used in the last bus cycle, and throws away the result.
CycleFetchPreviousThrowaway,
/// The same as CycleFetchIncrementPC but indicates valid program address rather than valid data address.
CycleFetchOpcode,
@ -274,7 +276,7 @@ struct ProcessorStorage {
// Registers.
RegisterPair16 a;
RegisterPair16 x, y;
RegisterPair16 s;
RegisterPair16 s;
uint16_t pc;
// Flags aplenty.