From 2e0e89c494e6318e414e4e8079981b699b6e41bb Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Fri, 24 Oct 2025 16:43:57 -0400 Subject: [PATCH] Implement fast modify path; fix more NOPs. --- Processors/6502Mk2/Decoder.hpp | 22 ++++++++++++++-------- Processors/6502Mk2/Implementation/6502.hpp | 21 +++++++++++++++++++++ 2 files changed, 35 insertions(+), 8 deletions(-) diff --git a/Processors/6502Mk2/Decoder.hpp b/Processors/6502Mk2/Decoder.hpp index 1f4892b38..fd07c4c85 100644 --- a/Processors/6502Mk2/Decoder.hpp +++ b/Processors/6502Mk2/Decoder.hpp @@ -49,6 +49,7 @@ enum class AddressingMode { Absolute, AbsoluteIndexed, + FastAbsoluteIndexedModify, Zero, ZeroIndexed, ZeroIndirect, @@ -556,14 +557,19 @@ struct Decoder> { case 0x3c: return {AbsoluteIndexed, Operation::BIT}; case 0x9c: return {Absolute, Operation::STZ}; - case 0x1f: return {AbsoluteIndexed, Operation::NOP}; - case 0x3f: return {AbsoluteIndexed, Operation::NOP}; - case 0x5f: return {AbsoluteIndexed, Operation::NOP}; - case 0x7f: return {AbsoluteIndexed, Operation::NOP}; - case 0x9f: return {AbsoluteIndexed, Operation::NOP}; - case 0xbf: return {AbsoluteIndexed, Operation::NOP}; - case 0xdf: return {AbsoluteIndexed, Operation::NOP}; - case 0xff: return {AbsoluteIndexed, Operation::NOP}; + case 0x1e: return {FastAbsoluteIndexedModify, Operation::ASL}; + case 0x3e: return {FastAbsoluteIndexedModify, Operation::ROL}; + case 0x5e: return {FastAbsoluteIndexedModify, Operation::LSR}; + case 0x7e: return {FastAbsoluteIndexedModify, Operation::ROR}; + + case 0x1f: return {AbsoluteIndexed, Operation::FastNOP}; + case 0x3f: return {AbsoluteIndexed, Operation::FastNOP}; + case 0x5f: return {AbsoluteIndexed, Operation::FastNOP}; + case 0x7f: return {AbsoluteIndexed, Operation::FastNOP}; + case 0x9f: return {AbsoluteIndexed, Operation::FastNOP}; + case 0xbf: return {AbsoluteIndexed, Operation::FastNOP}; + case 0xdf: return {AbsoluteIndexed, Operation::FastNOP}; + case 0xff: return {AbsoluteIndexed, Operation::FastNOP}; } } }; diff --git a/Processors/6502Mk2/Implementation/6502.hpp b/Processors/6502Mk2/Implementation/6502.hpp index 8002de9a4..8ec4d0280 100644 --- a/Processors/6502Mk2/Implementation/6502.hpp +++ b/Processors/6502Mk2/Implementation/6502.hpp @@ -323,6 +323,27 @@ void Processor::run_for(const Cycles cycles) { access(BusOperation::Read, Literal(registers.pc.full), throwaway); goto access_absolute; + // MARK: - Fast absolute indexed modify, which is a 65c02 improvement but not applied universally. + + case access_program(FastAbsoluteIndexedModify): + ++registers.pc.full; + + // Read top half of address. + Storage::address_.halves.low = Storage::operand_; + check_interrupt(); + access(BusOperation::Read, Literal(registers.pc.full), Storage::address_.halves.high); + + // If this is a read and the top byte doesn't need adjusting, skip that cycle. + Storage::operand_ = Storage::address_.halves.high; + Storage::address_.full += index(); + if(Storage::address_.halves.high == Storage::operand_) { + goto access_absolute; + } + + check_interrupt(); + access(BusOperation::Read, Literal(registers.pc.full), throwaway); + goto access_absolute; + // MARK: - Indexed indirect. case access_program(IndexedIndirect):