Undocumented M6502 instruction implemented

This commit is contained in:
Adrian Conlon 2024-01-07 15:52:16 +00:00
parent 86ef340650
commit 72be3238f2
2 changed files with 20 additions and 5 deletions

View File

@ -246,7 +246,7 @@ namespace EightBit {
memoryWrite(A());
}
// Undocumented complicated mode implementations
// Undocumented complicated mode implementations
// SLO
void slo_AbsoluteX() noexcept;
@ -302,6 +302,10 @@ namespace EightBit {
sre(memoryRead());
}
// SHA
void sha_AbsoluteY() noexcept;
void sha_IndirectIndexedY() noexcept;
// SYA
void sya_AbsoluteX() noexcept;

View File

@ -2,7 +2,7 @@
#include "../inc/mos6502.h"
EightBit::MOS6502::MOS6502(Bus& bus) noexcept
: LittleEndianProcessor(bus) {
: LittleEndianProcessor(bus) {
RaisedPOWER.connect([this](EventArgs) {
X() = Bit7;
Y() = 0;
@ -284,7 +284,7 @@ int EightBit::MOS6502::execute() noexcept {
case 0x90: branch(carry() == 0); break; // BCC (relative)
case 0x91: sta_IndirectIndexedY(); break; // STA (indirect indexed Y)
case 0x92: jam(); break; // *JAM
case 0x93: break;
case 0x93: sha_IndirectIndexedY(); break; // *SHA (indirect indexed, Y)
case 0x94: memoryWrite(Address_ZeroPageX(), Y()); break; // STY (zero page, X)
case 0x95: memoryWrite(Address_ZeroPageX(), A()); break; // STA (zero page, X)
case 0x96: memoryWrite(Address_ZeroPageY(), X()); break; // STX (zero page, Y)
@ -296,8 +296,7 @@ int EightBit::MOS6502::execute() noexcept {
case 0x9c: sya_AbsoluteX(); break; // *SYA (absolute, X)
case 0x9d: sta_AbsoluteX(); break; // STA (absolute, X)
case 0x9e: sxa_AbsoluteY(); break; // *SXA (absolute, Y)
case 0x9f: break;
case 0x9f: sha_AbsoluteY(); break; // *SHA (absolute, Y)
case 0xa0: Y() = through(AM_Immediate()); break; // LDY (immediate)
case 0xa1: A() = through(AM_IndexedIndirectX()); break; // LDA (indexed indirect X)
case 0xa2: X() = through(AM_Immediate()); break; // LDX (immediate)
@ -874,6 +873,18 @@ void EightBit::MOS6502::sre_IndirectIndexedY() noexcept {
sre_with_fixup(address, page);
}
void EightBit::MOS6502::sha_AbsoluteY() noexcept {
const auto [address, page] = Address_AbsoluteY();
fixup(address, page);
memoryWrite(address, A() & X() & (address.high + 1));
}
void EightBit::MOS6502::sha_IndirectIndexedY() noexcept {
const auto [address, page] = Address_IndirectIndexedY();
fixup(address, page);
memoryWrite(address, A() & X() & (address.high + 1));
}
void EightBit::MOS6502::sya_AbsoluteX() noexcept {
const auto [address, page] = Address_AbsoluteX();
fixup(address, page);