From 7432e602f86de1bcfb7adc34245780ff2687f640 Mon Sep 17 00:00:00 2001 From: Adrian Conlon Date: Thu, 28 Dec 2017 16:15:22 +0000 Subject: [PATCH] Correct a 6502 bug in absolute indirect addressing mode (unchanging page on address resolution). Signed-off-by: Adrian Conlon --- M6502/inc/mos6502.h | 3 ++- M6502/src/mos6502.cpp | 8 ++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/M6502/inc/mos6502.h b/M6502/inc/mos6502.h index c924c9f..5b487ea 100644 --- a/M6502/inc/mos6502.h +++ b/M6502/inc/mos6502.h @@ -75,6 +75,7 @@ namespace EightBit { adjustNegative(datum); } + void getWord(uint8_t page, uint8_t offset, register16_t& output); void getWord(uint8_t offset, register16_t& output); void getWord(register16_t& output); @@ -104,7 +105,7 @@ namespace EightBit { void Address_Indirect() { Address_Absolute(); - getWord(MEMPTR(), MEMPTR()); + getWord(MEMPTR().high, MEMPTR().low, MEMPTR()); } void Address_ZeroPageX() { diff --git a/M6502/src/mos6502.cpp b/M6502/src/mos6502.cpp index 462fec3..46b4406 100644 --- a/M6502/src/mos6502.cpp +++ b/M6502/src/mos6502.cpp @@ -63,14 +63,18 @@ void EightBit::MOS6502::reset() { getWord(RSTvector, PC()); } -void EightBit::MOS6502::getWord(uint8_t offset, register16_t& output) { +void EightBit::MOS6502::getWord(uint8_t page, uint8_t offset, register16_t& output) { BUS().ADDRESS().low = offset; - BUS().ADDRESS().high = 0; + BUS().ADDRESS().high = page; output.low = getByte(); BUS().ADDRESS().low++; output.high = getByte(); } +void EightBit::MOS6502::getWord(uint8_t offset, register16_t& output) { + getWord(0, offset, output); +} + void EightBit::MOS6502::getWord(register16_t& output) { output.low = getByte(); BUS().ADDRESS().word++;