Undocumented instruction: SAX added

Signed-off-by: Adrian Conlon <Adrian.conlon@gmail.com>
This commit is contained in:
Adrian Conlon 2018-01-01 12:46:21 +00:00
parent 75aece30e3
commit 1beee9782f
3 changed files with 39 additions and 5 deletions

View File

@ -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) {

View File

@ -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;

View File

@ -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: