diff --git a/M6502/inc/mos6502.h b/M6502/inc/mos6502.h index 53252bc..2ee1601 100644 --- a/M6502/inc/mos6502.h +++ b/M6502/inc/mos6502.h @@ -447,8 +447,7 @@ namespace EightBit { case 0b101: return AM_ZeroPageY(); case 0b110: - assert(false); - break; + throw std::domain_error("Illegal addressing mode"); case 0b111: return AM_AbsoluteY(); default: @@ -456,6 +455,35 @@ namespace EightBit { } } + void AM_11(int bbb, uint8_t value) { + switch (bbb) { + case 0b000: + AM_IndexedIndirectX(value); + break; + case 0b001: + AM_ZeroPage(value); + break; + case 0b010: + throw std::domain_error("Illegal addressing mode"); + case 0b011: + AM_Absolute(value); + break; + case 0b100: + AM_IndirectIndexedY(value); + break; + case 0b101: + AM_ZeroPageY(value); + break; + case 0b110: + throw std::domain_error("Illegal addressing mode"); + case 0b111: + AM_AbsoluteY(value); + break; + default: + UNREACHABLE; + } + } + // Operations void ASL(int bbb) { diff --git a/M6502/src/Disassembly.cpp b/M6502/src/Disassembly.cpp index 81d24c3..cce03a5 100644 --- a/M6502/src/Disassembly.cpp +++ b/M6502/src/Disassembly.cpp @@ -389,6 +389,9 @@ std::string EightBit::Disassembly::disassemble(uint16_t current) const { break; case 0b11: switch (aaa) { + case 0b100: + output << disassemble_AM_11(bbb, "*SAX"); + break; case 0b101: output << disassemble_AM_11(bbb, "*LAX"); break; diff --git a/M6502/src/mos6502.cpp b/M6502/src/mos6502.cpp index c3a38af..893cac2 100644 --- a/M6502/src/mos6502.cpp +++ b/M6502/src/mos6502.cpp @@ -13,8 +13,8 @@ EightBit::MOS6502::MOS6502(Bus& bus) /* 5 */ 2, 5, 0, 0, 4, 4, 6, 0, 2, 4, 2, 0, 4, 4, 7, 0, /* 6 */ 6, 6, 0, 0, 3, 3, 5, 0, 4, 2, 2, 0, 5, 4, 6, 0, /* 7 */ 2, 5, 0, 0, 4, 4, 6, 0, 2, 4, 2, 0, 4, 4, 7, 0, - /* 8 */ 2, 6, 0, 0, 3, 3, 3, 0, 2, 0, 2, 0, 4, 4, 4, 0, - /* 9 */ 2, 6, 0, 0, 4, 4, 4, 0, 2, 5, 2, 0, 0, 5, 0, 0, + /* 8 */ 2, 6, 0, 6, 3, 3, 3, 3, 2, 0, 2, 0, 4, 4, 4, 4, + /* 9 */ 2, 6, 0, 0, 4, 4, 4, 4, 2, 5, 2, 0, 0, 5, 0, 0, /* A */ 2, 6, 2, 6, 3, 3, 3, 3, 2, 2, 2, 0, 4, 4, 4, 4, /* B */ 2, 5, 0, 5, 4, 4, 4, 4, 2, 4, 2, 0, 4, 4, 4, 4, /* C */ 2, 6, 0, 0, 3, 3, 5, 0, 2, 2, 2, 0, 4, 4, 6, 0, @@ -411,7 +411,10 @@ int EightBit::MOS6502::execute(uint8_t cell) { break; case 0b11: switch (decoded.aaa) { - case 0b101: + case 0b100: // SAX + AM_11(decoded.bbb, A() & X()); + break; + case 0b101: // LAX adjustNZ(X() = A() = AM_11(decoded.bbb)); break; default: