start implementing unofficial opcodes

This commit is contained in:
Vineet K 2024-07-04 12:11:53 -04:00
parent 5cd467eaf6
commit c4fc40a036
3 changed files with 434 additions and 153 deletions

149
cpu.c
View File

@ -177,6 +177,8 @@ branch(uint16_t addr, bool cond)
regs.pc = addr; regs.pc = addr;
} }
/* OFFICIAL OPCODES */
void void
ADC(uint16_t arg) ADC(uint16_t arg)
{ {
@ -696,6 +698,140 @@ TYA(uint16_t arg)
STATUS_UPDATE_NZ(regs.a); STATUS_UPDATE_NZ(regs.a);
} }
/* UNOFFICIAL OPCODES */
void
AAC(uint16_t arg)
{
NOP(0);
}
void
AAX(uint16_t arg)
{
NOP(0);
}
void
ARR(uint16_t arg)
{
NOP(0);
}
void
ASR(uint16_t arg)
{
NOP(0);
}
void
ATX(uint16_t arg)
{
NOP(0);
}
void
AXA(uint16_t arg)
{
NOP(0);
}
void
AXS(uint16_t arg)
{
NOP(0);
}
void
DCP(uint16_t arg)
{
NOP(0);
}
void
DOP(uint16_t arg)
{
NOP(0);
}
void
ISC(uint16_t arg)
{
NOP(0);
}
void
KIL(uint16_t arg)
{
NOP(0);
}
void
LAR(uint16_t arg)
{
NOP(0);
}
void
LAX(uint16_t arg)
{
NOP(0);
}
void
RLA(uint16_t arg)
{
NOP(0);
}
void
RRA(uint16_t arg)
{
NOP(0);
}
void
SLO(uint16_t arg)
{
NOP(0);
}
void
SRE(uint16_t arg)
{
NOP(0);
}
void
SXA(uint16_t arg)
{
NOP(0);
}
void
SYA(uint16_t arg)
{
NOP(0);
}
void
TOP(uint16_t arg)
{
NOP(0);
}
void
XAA(uint16_t arg)
{
NOP(0);
}
void
XAS(uint16_t arg)
{
NOP(0);
}
static void static void
interpret(void) interpret(void)
{ {
@ -711,7 +847,18 @@ interpret(void)
printf("%02X", op); printf("%02X", op);
for (uint8_t i = 0; i < opcodes[op].bytes - 1; i++) for (uint8_t i = 0; i < opcodes[op].bytes - 1; i++)
printf(" %02X", peek(regs.pc + i)); printf(" %02X", peek(regs.pc + i));
printf("\t%s ", opcodes[op].name);
if (opcodes[op].unofficial) {
if (opcodes[op].bytes == 1)
printf(" ");
else if (opcodes[op].bytes == 2)
printf(" ");
else if (opcodes[op].bytes == 3)
putchar(' ');
putchar('*');
} else
putchar('\t');
printf("%s ", opcodes[op].name);
mode = opcodes[op].mode; mode = opcodes[op].mode;
arg = opcode_mem(mode); arg = opcode_mem(mode);

27
cpu.h
View File

@ -1,5 +1,6 @@
#include <stdint.h> #include <stdint.h>
/* OFFICIAL OPCODES */
void ADC(uint16_t arg); void ADC(uint16_t arg);
void AND(uint16_t arg); void AND(uint16_t arg);
void ASL_acc(uint16_t arg); void ASL_acc(uint16_t arg);
@ -60,3 +61,29 @@ void TSX(uint16_t arg);
void TXA(uint16_t arg); void TXA(uint16_t arg);
void TXS(uint16_t arg); void TXS(uint16_t arg);
void TYA(uint16_t arg); void TYA(uint16_t arg);
/* UNOFFICIAL OPCODES */
void AAC(uint16_t arg);
void AAX(uint16_t arg);
void ARR(uint16_t arg);
void ASR(uint16_t arg);
void ATX(uint16_t arg);
void AXA(uint16_t arg);
void AXS(uint16_t arg);
void DCP(uint16_t arg);
void DOP(uint16_t arg);
void ISC(uint16_t arg);
void KIL(uint16_t arg);
void LAR(uint16_t arg);
void LAX(uint16_t arg);
void NOP(uint16_t arg);
void RLA(uint16_t arg);
void RRA(uint16_t arg);
void SBC(uint16_t arg);
void SLO(uint16_t arg);
void SRE(uint16_t arg);
void SXA(uint16_t arg);
void SYA(uint16_t arg);
void TOP(uint16_t arg);
void XAA(uint16_t arg);
void XAS(uint16_t arg);

411
opcodes.h
View File

@ -29,160 +29,267 @@ struct opcode {
bool memread; bool memread;
bool memwrite; bool memwrite;
bool page_cross; bool page_cross;
bool unofficial;
enum addressing_mode mode; enum addressing_mode mode;
}; };
struct opcode opcodes[0x100] = { struct opcode opcodes[0x100] = {
/* official opcodes */ /* official opcodes: https://www.nesdev.org/obelisk-6502-guide/instructions.html */
[0x69] = { "ADC", ADC, 2, 2, false, false, false, AM_IMM }, [0x69] = { "ADC", ADC, 2, 2, false, false, false, false, AM_IMM },
[0x65] = { "ADC", ADC, 2, 3, true, false, false, AM_ZP }, [0x65] = { "ADC", ADC, 2, 3, true, false, false, false, AM_ZP },
[0x75] = { "ADC", ADC, 2, 4, true, false, false, AM_ZP_X }, [0x75] = { "ADC", ADC, 2, 4, true, false, false, false, AM_ZP_X },
[0x6D] = { "ADC", ADC, 3, 4, true, false, false, AM_ABS }, [0x6D] = { "ADC", ADC, 3, 4, true, false, false, false, AM_ABS },
[0x7D] = { "ADC", ADC, 3, 4, true, false, true, AM_ABS_X }, [0x7D] = { "ADC", ADC, 3, 4, true, false, true, false, AM_ABS_X },
[0x79] = { "ADC", ADC, 3, 4, true, false, true, AM_ABS_Y }, [0x79] = { "ADC", ADC, 3, 4, true, false, true, false, AM_ABS_Y },
[0x61] = { "ADC", ADC, 2, 6, true, false, false, AM_IND_X }, [0x61] = { "ADC", ADC, 2, 6, true, false, false, false, AM_IND_X },
[0x71] = { "ADC", ADC, 2, 5, true, false, true, AM_IND_Y }, [0x71] = { "ADC", ADC, 2, 5, true, false, true, false, AM_IND_Y },
[0x29] = { "AND", AND, 2, 2, false, false, false, AM_IMM }, [0x29] = { "AND", AND, 2, 2, false, false, false, false, AM_IMM },
[0x25] = { "AND", AND, 2, 3, true, false, false, AM_ZP }, [0x25] = { "AND", AND, 2, 3, true, false, false, false, AM_ZP },
[0x35] = { "AND", AND, 2, 4, true, false, false, AM_ZP_X }, [0x35] = { "AND", AND, 2, 4, true, false, false, false, AM_ZP_X },
[0x2D] = { "AND", AND, 3, 4, true, false, false, AM_ABS }, [0x2D] = { "AND", AND, 3, 4, true, false, false, false, AM_ABS },
[0x3D] = { "AND", AND, 3, 4, true, false, true, AM_ABS_X }, [0x3D] = { "AND", AND, 3, 4, true, false, true, false, AM_ABS_X },
[0x39] = { "AND", AND, 3, 4, true, false, true, AM_ABS_Y }, [0x39] = { "AND", AND, 3, 4, true, false, true, false, AM_ABS_Y },
[0x21] = { "AND", AND, 2, 6, true, false, false, AM_IND_X }, [0x21] = { "AND", AND, 2, 6, true, false, false, false, AM_IND_X },
[0x31] = { "AND", AND, 2, 5, true, false, true, AM_IND_Y }, [0x31] = { "AND", AND, 2, 5, true, false, true, false, AM_IND_Y },
[0x0A] = { "ASL", ASL_acc, 1, 2, false, false, false, AM_ACC }, [0x0A] = { "ASL", ASL_acc, 1, 2, false, false, false, false, AM_ACC },
[0x06] = { "ASL", ASL, 2, 5, false, true, false, AM_ZP }, [0x06] = { "ASL", ASL, 2, 5, false, true, false, false, AM_ZP },
[0x16] = { "ASL", ASL, 2, 6, false, true, false, AM_ZP_X }, [0x16] = { "ASL", ASL, 2, 6, false, true, false, false, AM_ZP_X },
[0x0E] = { "ASL", ASL, 3, 6, false, true, false, AM_ABS }, [0x0E] = { "ASL", ASL, 3, 6, false, true, false, false, AM_ABS },
[0x1E] = { "ASL", ASL, 3, 7, false, true, false, AM_ABS_X }, [0x1E] = { "ASL", ASL, 3, 7, false, true, false, false, AM_ABS_X },
[0x90] = { "BCC", BCC, 2, 2, false, false, true, AM_REL }, [0x90] = { "BCC", BCC, 2, 2, false, false, true, false, AM_REL },
[0xB0] = { "BCS", BCS, 2, 2, false, false, true, AM_REL }, [0xB0] = { "BCS", BCS, 2, 2, false, false, true, false, AM_REL },
[0xF0] = { "BEQ", BEQ, 2, 2, false, false, true, AM_REL }, [0xF0] = { "BEQ", BEQ, 2, 2, false, false, true, false, AM_REL },
[0x24] = { "BIT", BIT, 2, 3, true, false, false, AM_ZP }, [0x24] = { "BIT", BIT, 2, 3, true, false, false, false, AM_ZP },
[0x2C] = { "BIT", BIT, 3, 4, true, false, false, AM_ABS }, [0x2C] = { "BIT", BIT, 3, 4, true, false, false, false, AM_ABS },
[0x30] = { "BMI", BMI, 2, 2, false, false, true, AM_REL }, [0x30] = { "BMI", BMI, 2, 2, false, false, true, false, AM_REL },
[0xD0] = { "BNE", BNE, 2, 2, false, false, true, AM_REL }, [0xD0] = { "BNE", BNE, 2, 2, false, false, true, false, AM_REL },
[0x10] = { "BPL", BPL, 2, 2, false, false, true, AM_REL }, [0x10] = { "BPL", BPL, 2, 2, false, false, true, false, AM_REL },
[0x00] = { "BRK", BRK, 1, 7, false, false, false, AM_NONE }, [0x00] = { "BRK", BRK, 1, 7, false, false, false, false, AM_NONE },
[0x50] = { "BVC", BVC, 2, 2, false, false, true, AM_REL }, [0x50] = { "BVC", BVC, 2, 2, false, false, true, false, AM_REL },
[0x70] = { "BVS", BVS, 2, 2, false, false, true, AM_REL }, [0x70] = { "BVS", BVS, 2, 2, false, false, true, false, AM_REL },
[0x18] = { "CLC", CLC, 1, 2, false, false, false, AM_NONE }, [0x18] = { "CLC", CLC, 1, 2, false, false, false, false, AM_NONE },
[0xD8] = { "CLD", CLD, 1, 2, false, false, false, AM_NONE }, [0xD8] = { "CLD", CLD, 1, 2, false, false, false, false, AM_NONE },
[0x58] = { "CLI", CLI, 1, 2, false, false, false, AM_NONE }, [0x58] = { "CLI", CLI, 1, 2, false, false, false, false, AM_NONE },
[0xB8] = { "CLV", CLV, 1, 2, false, false, false, AM_NONE }, [0xB8] = { "CLV", CLV, 1, 2, false, false, false, false, AM_NONE },
[0xC9] = { "CMP", CMP, 2, 2, false, false, false, AM_IMM }, [0xC9] = { "CMP", CMP, 2, 2, false, false, false, false, AM_IMM },
[0xC5] = { "CMP", CMP, 2, 3, true, false, false, AM_ZP }, [0xC5] = { "CMP", CMP, 2, 3, true, false, false, false, AM_ZP },
[0xD5] = { "CMP", CMP, 2, 4, true, false, false, AM_ZP_X }, [0xD5] = { "CMP", CMP, 2, 4, true, false, false, false, AM_ZP_X },
[0xCD] = { "CMP", CMP, 3, 4, true, false, false, AM_ABS }, [0xCD] = { "CMP", CMP, 3, 4, true, false, false, false, AM_ABS },
[0xDD] = { "CMP", CMP, 3, 4, true, false, true, AM_ABS_X }, [0xDD] = { "CMP", CMP, 3, 4, true, false, true, false, AM_ABS_X },
[0xD9] = { "CMP", CMP, 3, 4, true, false, true, AM_ABS_Y }, [0xD9] = { "CMP", CMP, 3, 4, true, false, true, false, AM_ABS_Y },
[0xC1] = { "CMP", CMP, 2, 6, true, false, false, AM_IND_X }, [0xC1] = { "CMP", CMP, 2, 6, true, false, false, false, AM_IND_X },
[0xD1] = { "CMP", CMP, 2, 5, true, false, true, AM_IND_Y }, [0xD1] = { "CMP", CMP, 2, 5, true, false, true, false, AM_IND_Y },
[0xE0] = { "CPX", CPX, 2, 2, false, false, false, AM_IMM }, [0xE0] = { "CPX", CPX, 2, 2, false, false, false, false, AM_IMM },
[0xE4] = { "CPX", CPX, 2, 3, true, false, false, AM_ZP }, [0xE4] = { "CPX", CPX, 2, 3, true, false, false, false, AM_ZP },
[0xEC] = { "CPX", CPX, 3, 4, true, false, false, AM_ABS }, [0xEC] = { "CPX", CPX, 3, 4, true, false, false, false, AM_ABS },
[0xC0] = { "CPY", CPY, 2, 2, false, false, false, AM_IMM }, [0xC0] = { "CPY", CPY, 2, 2, false, false, false, false, AM_IMM },
[0xC4] = { "CPY", CPY, 2, 3, true, false, false, AM_ZP }, [0xC4] = { "CPY", CPY, 2, 3, true, false, false, false, AM_ZP },
[0xCC] = { "CPY", CPY, 3, 4, true, false, false, AM_ABS }, [0xCC] = { "CPY", CPY, 3, 4, true, false, false, false, AM_ABS },
[0xC6] = { "DEC", DEC, 2, 5, false, true, false, AM_ZP }, [0xC6] = { "DEC", DEC, 2, 5, false, true, false, false, AM_ZP },
[0xD6] = { "DEC", DEC, 2, 6, false, true, false, AM_ZP_X }, [0xD6] = { "DEC", DEC, 2, 6, false, true, false, false, AM_ZP_X },
[0xCE] = { "DEC", DEC, 3, 6, false, true, false, AM_ABS }, [0xCE] = { "DEC", DEC, 3, 6, false, true, false, false, AM_ABS },
[0xDE] = { "DEC", DEC, 3, 7, false, true, false, AM_ABS_X }, [0xDE] = { "DEC", DEC, 3, 7, false, true, false, false, AM_ABS_X },
[0xCA] = { "DEX", DEX, 1, 2, false, false, false, AM_NONE }, [0xCA] = { "DEX", DEX, 1, 2, false, false, false, false, AM_NONE },
[0x88] = { "DEY", DEY, 1, 2, false, false, false, AM_NONE }, [0x88] = { "DEY", DEY, 1, 2, false, false, false, false, AM_NONE },
[0x49] = { "EOR", EOR, 2, 2, false, false, false, AM_IMM }, [0x49] = { "EOR", EOR, 2, 2, false, false, false, false, AM_IMM },
[0x45] = { "EOR", EOR, 2, 3, true, false, false, AM_ZP }, [0x45] = { "EOR", EOR, 2, 3, true, false, false, false, AM_ZP },
[0x55] = { "EOR", EOR, 2, 4, true, false, false, AM_ZP_X }, [0x55] = { "EOR", EOR, 2, 4, true, false, false, false, AM_ZP_X },
[0x4D] = { "EOR", EOR, 3, 4, true, false, false, AM_ABS }, [0x4D] = { "EOR", EOR, 3, 4, true, false, false, false, AM_ABS },
[0x5D] = { "EOR", EOR, 3, 4, true, false, true, AM_ABS_X }, [0x5D] = { "EOR", EOR, 3, 4, true, false, true, false, AM_ABS_X },
[0x59] = { "EOR", EOR, 3, 4, true, false, true, AM_ABS_Y }, [0x59] = { "EOR", EOR, 3, 4, true, false, true, false, AM_ABS_Y },
[0x41] = { "EOR", EOR, 2, 6, true, false, false, AM_IND_X }, [0x41] = { "EOR", EOR, 2, 6, true, false, false, false, AM_IND_X },
[0x51] = { "EOR", EOR, 2, 5, true, false, true, AM_IND_Y }, [0x51] = { "EOR", EOR, 2, 5, true, false, true, false, AM_IND_Y },
[0xE6] = { "INC", INC, 2, 5, false, true, false, AM_ZP }, [0xE6] = { "INC", INC, 2, 5, false, true, false, false, AM_ZP },
[0xF6] = { "INC", INC, 2, 6, false, true, false, AM_ZP_X }, [0xF6] = { "INC", INC, 2, 6, false, true, false, false, AM_ZP_X },
[0xEE] = { "INC", INC, 3, 6, false, true, false, AM_ABS }, [0xEE] = { "INC", INC, 3, 6, false, true, false, false, AM_ABS },
[0xFE] = { "INC", INC, 3, 7, false, true, false, AM_ABS_X }, [0xFE] = { "INC", INC, 3, 7, false, true, false, false, AM_ABS_X },
[0xE8] = { "INX", INX, 1, 2, false, false, false, AM_NONE }, [0xE8] = { "INX", INX, 1, 2, false, false, false, false, AM_NONE },
[0xC8] = { "INY", INY, 1, 2, false, false, false, AM_NONE }, [0xC8] = { "INY", INY, 1, 2, false, false, false, false, AM_NONE },
[0x4C] = { "JMP", JMP, 3, 3, false, false, false, AM_ABS }, [0x4C] = { "JMP", JMP, 3, 3, false, false, false, false, AM_ABS },
[0x6C] = { "JMP", JMP, 3, 5, false, false, false, AM_IND }, [0x6C] = { "JMP", JMP, 3, 5, false, false, false, false, AM_IND },
[0x20] = { "JSR", JSR, 3, 6, false, false, false, AM_ABS }, [0x20] = { "JSR", JSR, 3, 6, false, false, false, false, AM_ABS },
[0xA9] = { "LDA", LDA, 2, 2, false, false, false, AM_IMM }, [0xA9] = { "LDA", LDA, 2, 2, false, false, false, false, AM_IMM },
[0xA5] = { "LDA", LDA, 2, 3, true, false, false, AM_ZP }, [0xA5] = { "LDA", LDA, 2, 3, true, false, false, false, AM_ZP },
[0xB5] = { "LDA", LDA, 2, 4, true, false, false, AM_ZP_X }, [0xB5] = { "LDA", LDA, 2, 4, true, false, false, false, AM_ZP_X },
[0xAD] = { "LDA", LDA, 3, 4, true, false, false, AM_ABS }, [0xAD] = { "LDA", LDA, 3, 4, true, false, false, false, AM_ABS },
[0xBD] = { "LDA", LDA, 3, 4, true, false, true, AM_ABS_X }, [0xBD] = { "LDA", LDA, 3, 4, true, false, true, false, AM_ABS_X },
[0xB9] = { "LDA", LDA, 3, 4, true, false, true, AM_ABS_Y }, [0xB9] = { "LDA", LDA, 3, 4, true, false, true, false, AM_ABS_Y },
[0xA1] = { "LDA", LDA, 2, 6, true, false, false, AM_IND_X }, [0xA1] = { "LDA", LDA, 2, 6, true, false, false, false, AM_IND_X },
[0xB1] = { "LDA", LDA, 2, 5, true, false, true, AM_IND_Y }, [0xB1] = { "LDA", LDA, 2, 5, true, false, true, false, AM_IND_Y },
[0xA2] = { "LDX", LDX, 2, 2, false, false, false, AM_IMM }, [0xA2] = { "LDX", LDX, 2, 2, false, false, false, false, AM_IMM },
[0xA6] = { "LDX", LDX, 2, 3, true, false, false, AM_ZP }, [0xA6] = { "LDX", LDX, 2, 3, true, false, false, false, AM_ZP },
[0xB6] = { "LDX", LDX, 2, 4, true, false, false, AM_ZP_Y }, [0xB6] = { "LDX", LDX, 2, 4, true, false, false, false, AM_ZP_Y },
[0xAE] = { "LDX", LDX, 3, 4, true, false, false, AM_ABS }, [0xAE] = { "LDX", LDX, 3, 4, true, false, false, false, AM_ABS },
[0xBE] = { "LDX", LDX, 3, 4, true, false, true, AM_ABS_Y }, [0xBE] = { "LDX", LDX, 3, 4, true, false, true, false, AM_ABS_Y },
[0xA0] = { "LDY", LDY, 2, 2, false, false, false, AM_IMM }, [0xA0] = { "LDY", LDY, 2, 2, false, false, false, false, AM_IMM },
[0xA4] = { "LDY", LDY, 2, 3, true, false, false, AM_ZP }, [0xA4] = { "LDY", LDY, 2, 3, true, false, false, false, AM_ZP },
[0xB4] = { "LDY", LDY, 2, 4, true, false, false, AM_ZP_X }, [0xB4] = { "LDY", LDY, 2, 4, true, false, false, false, AM_ZP_X },
[0xAC] = { "LDY", LDY, 3, 4, true, false, false, AM_ABS }, [0xAC] = { "LDY", LDY, 3, 4, true, false, false, false, AM_ABS },
[0xBC] = { "LDY", LDY, 3, 4, true, false, true, AM_ABS_X }, [0xBC] = { "LDY", LDY, 3, 4, true, false, true, false, AM_ABS_X },
[0x4A] = { "LSR", LSR_acc, 1, 2, false, false, false, AM_ACC }, [0x4A] = { "LSR", LSR_acc, 1, 2, false, false, false, false, AM_ACC },
[0x46] = { "LSR", LSR, 2, 5, false, true, false, AM_ZP }, [0x46] = { "LSR", LSR, 2, 5, false, true, false, false, AM_ZP },
[0x56] = { "LSR", LSR, 2, 6, false, true, false, AM_ZP_X }, [0x56] = { "LSR", LSR, 2, 6, false, true, false, false, AM_ZP_X },
[0x4E] = { "LSR", LSR, 3, 6, false, true, false, AM_ABS }, [0x4E] = { "LSR", LSR, 3, 6, false, true, false, false, AM_ABS },
[0x5E] = { "LSR", LSR, 3, 7, false, true, false, AM_ABS_X }, [0x5E] = { "LSR", LSR, 3, 7, false, true, false, false, AM_ABS_X },
[0xEA] = { "NOP", NOP, 1, 2, false, false, false, AM_NONE }, [0xEA] = { "NOP", NOP, 1, 2, false, false, false, false, AM_NONE },
[0x09] = { "ORA", ORA, 2, 2, false, false, false, AM_IMM }, [0x09] = { "ORA", ORA, 2, 2, false, false, false, false, AM_IMM },
[0x05] = { "ORA", ORA, 2, 3, true, false, false, AM_ZP }, [0x05] = { "ORA", ORA, 2, 3, true, false, false, false, AM_ZP },
[0x15] = { "ORA", ORA, 2, 4, true, false, false, AM_ZP_X }, [0x15] = { "ORA", ORA, 2, 4, true, false, false, false, AM_ZP_X },
[0x0D] = { "ORA", ORA, 3, 4, true, false, false, AM_ABS }, [0x0D] = { "ORA", ORA, 3, 4, true, false, false, false, AM_ABS },
[0x1D] = { "ORA", ORA, 3, 4, true, false, true, AM_ABS_X }, [0x1D] = { "ORA", ORA, 3, 4, true, false, true, false, AM_ABS_X },
[0x19] = { "ORA", ORA, 3, 4, true, false, true, AM_ABS_Y }, [0x19] = { "ORA", ORA, 3, 4, true, false, true, false, AM_ABS_Y },
[0x01] = { "ORA", ORA, 2, 6, true, false, false, AM_IND_X }, [0x01] = { "ORA", ORA, 2, 6, true, false, false, false, AM_IND_X },
[0x11] = { "ORA", ORA, 2, 5, true, false, true, AM_IND_Y }, [0x11] = { "ORA", ORA, 2, 5, true, false, true, false, AM_IND_Y },
[0x48] = { "PHA", PHA, 1, 3, false, false, false, AM_NONE }, [0x48] = { "PHA", PHA, 1, 3, false, false, false, false, AM_NONE },
[0x08] = { "PHP", PHP, 1, 3, false, false, false, AM_NONE }, [0x08] = { "PHP", PHP, 1, 3, false, false, false, false, AM_NONE },
[0x68] = { "PLA", PLA, 1, 4, false, false, false, AM_NONE }, [0x68] = { "PLA", PLA, 1, 4, false, false, false, false, AM_NONE },
[0x28] = { "PLP", PLP, 1, 4, false, false, false, AM_NONE }, [0x28] = { "PLP", PLP, 1, 4, false, false, false, false, AM_NONE },
[0x2A] = { "ROL", ROL_acc, 1, 2, false, false, false, AM_ACC }, [0x2A] = { "ROL", ROL_acc, 1, 2, false, false, false, false, AM_ACC },
[0x26] = { "ROL", ROL, 2, 5, false, true, false, AM_ZP }, [0x26] = { "ROL", ROL, 2, 5, false, true, false, false, AM_ZP },
[0x36] = { "ROL", ROL, 2, 6, false, true, false, AM_ZP_X }, [0x36] = { "ROL", ROL, 2, 6, false, true, false, false, AM_ZP_X },
[0x2E] = { "ROL", ROL, 3, 6, false, true, false, AM_ABS }, [0x2E] = { "ROL", ROL, 3, 6, false, true, false, false, AM_ABS },
[0x3E] = { "ROL", ROL, 3, 7, false, true, false, AM_ABS_X }, [0x3E] = { "ROL", ROL, 3, 7, false, true, false, false, AM_ABS_X },
[0x6A] = { "ROR", ROR_acc, 1, 2, false, false, false, AM_ACC }, [0x6A] = { "ROR", ROR_acc, 1, 2, false, false, false, false, AM_ACC },
[0x66] = { "ROR", ROR, 2, 5, false, true, false, AM_ZP }, [0x66] = { "ROR", ROR, 2, 5, false, true, false, false, AM_ZP },
[0x76] = { "ROR", ROR, 2, 6, false, true, false, AM_ZP_X }, [0x76] = { "ROR", ROR, 2, 6, false, true, false, false, AM_ZP_X },
[0x6E] = { "ROR", ROR, 3, 6, false, true, false, AM_ABS }, [0x6E] = { "ROR", ROR, 3, 6, false, true, false, false, AM_ABS },
[0x7E] = { "ROR", ROR, 3, 7, false, true, false, AM_ABS_X }, [0x7E] = { "ROR", ROR, 3, 7, false, true, false, false, AM_ABS_X },
[0x40] = { "RTI", RTI, 1, 6, false, false, false, AM_NONE }, [0x40] = { "RTI", RTI, 1, 6, false, false, false, false, AM_NONE },
[0x60] = { "RTS", RTS, 1, 6, false, false, false, AM_NONE }, [0x60] = { "RTS", RTS, 1, 6, false, false, false, false, AM_NONE },
[0xE9] = { "SBC", SBC, 2, 2, false, false, false, AM_IMM }, [0xE9] = { "SBC", SBC, 2, 2, false, false, false, false, AM_IMM },
[0xE5] = { "SBC", SBC, 2, 3, true, false, false, AM_ZP }, [0xE5] = { "SBC", SBC, 2, 3, true, false, false, false, AM_ZP },
[0xF5] = { "SBC", SBC, 2, 4, true, false, false, AM_ZP_X }, [0xF5] = { "SBC", SBC, 2, 4, true, false, false, false, AM_ZP_X },
[0xED] = { "SBC", SBC, 3, 4, true, false, false, AM_ABS }, [0xED] = { "SBC", SBC, 3, 4, true, false, false, false, AM_ABS },
[0xFD] = { "SBC", SBC, 3, 4, true, false, true, AM_ABS_X }, [0xFD] = { "SBC", SBC, 3, 4, true, false, true, false, AM_ABS_X },
[0xF9] = { "SBC", SBC, 3, 4, true, false, true, AM_ABS_Y }, [0xF9] = { "SBC", SBC, 3, 4, true, false, true, false, AM_ABS_Y },
[0xE1] = { "SBC", SBC, 2, 6, true, false, false, AM_IND_X }, [0xE1] = { "SBC", SBC, 2, 6, true, false, false, false, AM_IND_X },
[0xF1] = { "SBC", SBC, 2, 5, true, false, true, AM_IND_Y }, [0xF1] = { "SBC", SBC, 2, 5, true, false, true, false, AM_IND_Y },
[0x38] = { "SEC", SEC, 1, 2, false, false, false, AM_NONE }, [0x38] = { "SEC", SEC, 1, 2, false, false, false, false, AM_NONE },
[0xF8] = { "SED", SED, 1, 2, false, false, false, AM_NONE }, [0xF8] = { "SED", SED, 1, 2, false, false, false, false, AM_NONE },
[0x78] = { "SEI", SEI, 1, 2, false, false, false, AM_NONE }, [0x78] = { "SEI", SEI, 1, 2, false, false, false, false, AM_NONE },
[0x85] = { "STA", STA, 2, 3, false, true, false, AM_ZP }, [0x85] = { "STA", STA, 2, 3, false, true, false, false, AM_ZP },
[0x95] = { "STA", STA, 2, 4, false, true, false, AM_ZP_X }, [0x95] = { "STA", STA, 2, 4, false, true, false, false, AM_ZP_X },
[0x8D] = { "STA", STA, 3, 4, false, true, false, AM_ABS }, [0x8D] = { "STA", STA, 3, 4, false, true, false, false, AM_ABS },
[0x9D] = { "STA", STA, 3, 5, false, true, false, AM_ABS_X }, [0x9D] = { "STA", STA, 3, 5, false, true, false, false, AM_ABS_X },
[0x99] = { "STA", STA, 3, 5, false, true, false, AM_ABS_Y }, [0x99] = { "STA", STA, 3, 5, false, true, false, false, AM_ABS_Y },
[0x81] = { "STA", STA, 2, 6, false, true, false, AM_IND_X }, [0x81] = { "STA", STA, 2, 6, false, true, false, false, AM_IND_X },
[0x91] = { "STA", STA, 2, 6, false, true, false, AM_IND_Y }, [0x91] = { "STA", STA, 2, 6, false, true, false, false, AM_IND_Y },
[0x86] = { "STX", STX, 2, 3, false, true, false, AM_ZP }, [0x86] = { "STX", STX, 2, 3, false, true, false, false, AM_ZP },
[0x96] = { "STX", STX, 2, 4, false, true, false, AM_ZP_Y }, [0x96] = { "STX", STX, 2, 4, false, true, false, false, AM_ZP_Y },
[0x8E] = { "STX", STX, 3, 4, false, true, false, AM_ABS }, [0x8E] = { "STX", STX, 3, 4, false, true, false, false, AM_ABS },
[0x84] = { "STY", STY, 2, 3, false, true, false, AM_ZP }, [0x84] = { "STY", STY, 2, 3, false, true, false, false, AM_ZP },
[0x94] = { "STY", STY, 2, 4, false, true, false, AM_ZP_X }, [0x94] = { "STY", STY, 2, 4, false, true, false, false, AM_ZP_X },
[0x8C] = { "STY", STY, 3, 4, false, true, false, AM_ABS }, [0x8C] = { "STY", STY, 3, 4, false, true, false, false, AM_ABS },
[0xAA] = { "TAX", TAX, 1, 2, false, false, false, AM_NONE }, [0xAA] = { "TAX", TAX, 1, 2, false, false, false, false, AM_NONE },
[0xA8] = { "TAY", TAY, 1, 2, false, false, false, AM_NONE }, [0xA8] = { "TAY", TAY, 1, 2, false, false, false, false, AM_NONE },
[0xBA] = { "TSX", TSX, 1, 2, false, false, false, AM_NONE }, [0xBA] = { "TSX", TSX, 1, 2, false, false, false, false, AM_NONE },
[0x8A] = { "TXA", TXA, 1, 2, false, false, false, AM_NONE }, [0x8A] = { "TXA", TXA, 1, 2, false, false, false, false, AM_NONE },
[0x9A] = { "TXS", TXS, 1, 2, false, false, false, AM_NONE }, [0x9A] = { "TXS", TXS, 1, 2, false, false, false, false, AM_NONE },
[0x98] = { "TYA", TYA, 1, 2, false, false, false, AM_NONE }, [0x98] = { "TYA", TYA, 1, 2, false, false, false, false, AM_NONE },
/* unofficial opcodes: https://www.nesdev.org/undocumented_opcodes.txt */
[0x0B] = { "AAC", AAC, 2, 2, false, false, false, true, AM_IMM },
[0x2B] = { "AAC", AAC, 2, 2, false, false, false, true, AM_IMM },
[0x87] = { "AAX", AAX, 2, 3, false, false, false, true, AM_ZP },
[0x97] = { "AAX", AAX, 2, 4, false, false, false, true, AM_ZP_Y },
[0x83] = { "AAX", AAX, 2, 6, false, false, false, true, AM_IND_X },
[0x8F] = { "AAX", AAX, 3, 4, false, false, false, true, AM_ABS },
[0x6B] = { "ARR", ARR, 2, 2, false, false, false, true, AM_IMM },
[0x4B] = { "ASR", ASR, 2, 2, false, false, false, true, AM_IMM },
[0xAB] = { "ATX", ATX, 2, 2, false, false, false, true, AM_IMM },
[0x9F] = { "AXA", AXA, 3, 5, false, false, false, true, AM_ABS_Y },
[0x93] = { "AXA", AXA, 2, 6, false, false, false, true, AM_IND_Y },
[0xCB] = { "AXS", AXS, 2, 2, false, false, false, true, AM_IMM },
[0xC7] = { "DCP", DCP, 2, 5, false, false, false, true, AM_ZP },
[0xD7] = { "DCP", DCP, 2, 6, false, false, false, true, AM_ZP_X },
[0xCF] = { "DCP", DCP, 3, 6, false, false, false, true, AM_ABS },
[0xDF] = { "DCP", DCP, 3, 7, false, false, false, true, AM_ABS_X },
[0xDB] = { "DCP", DCP, 3, 7, false, false, false, true, AM_ABS_Y },
[0xC3] = { "DCP", DCP, 2, 8, false, false, false, true, AM_IND_X },
[0xD3] = { "DCP", DCP, 2, 8, false, false, false, true, AM_IND_Y },
[0x04] = { "NOP", NOP, 2, 3, true, false, false, true, AM_ZP },
[0x14] = { "NOP", NOP, 2, 4, true, false, false, true, AM_ZP_X },
[0x34] = { "NOP", NOP, 2, 4, true, false, false, true, AM_ZP_X },
[0x44] = { "NOP", NOP, 2, 3, true, false, false, true, AM_ZP },
[0x54] = { "NOP", NOP, 2, 4, true, false, false, true, AM_ZP_X },
[0x64] = { "NOP", NOP, 2, 3, true, false, false, true, AM_ZP },
[0x74] = { "NOP", NOP, 2, 4, true, false, false, true, AM_ZP_X },
[0x80] = { "NOP", NOP, 2, 2, false, false, false, true, AM_IMM },
[0x82] = { "NOP", NOP, 2, 2, false, false, false, true, AM_IMM },
[0x89] = { "NOP", NOP, 2, 2, false, false, false, true, AM_IMM },
[0xC2] = { "NOP", NOP, 2, 2, false, false, false, true, AM_IMM },
[0xD4] = { "NOP", NOP, 2, 4, false, false, false, true, AM_ZP_X },
[0xE2] = { "NOP", NOP, 2, 2, false, false, false, true, AM_IMM },
[0xF4] = { "NOP", NOP, 2, 4, false, false, false, true, AM_ZP_X },
[0xE7] = { "ISC", ISC, 2, 5, false, false, false, true, AM_ZP },
[0xF7] = { "ISC", ISC, 2, 6, false, false, false, true, AM_ZP_X },
[0xEF] = { "ISC", ISC, 3, 6, false, false, false, true, AM_ABS },
[0xFF] = { "ISC", ISC, 3, 7, false, false, false, true, AM_ABS_X },
[0xFB] = { "ISC", ISC, 3, 7, false, false, false, true, AM_ABS_Y },
[0xE3] = { "ISC", ISC, 2, 8, false, false, false, true, AM_IND_X },
[0xF3] = { "ISC", ISC, 2, 8, false, false, false, true, AM_IND_Y },
[0x02] = { "KIL", KIL, 1, 0, false, false, false, true, AM_NONE },
[0x12] = { "KIL", KIL, 1, 0, false, false, false, true, AM_NONE },
[0x22] = { "KIL", KIL, 1, 0, false, false, false, true, AM_NONE },
[0x32] = { "KIL", KIL, 1, 0, false, false, false, true, AM_NONE },
[0x42] = { "KIL", KIL, 1, 0, false, false, false, true, AM_NONE },
[0x52] = { "KIL", KIL, 1, 0, false, false, false, true, AM_NONE },
[0x62] = { "KIL", KIL, 1, 0, false, false, false, true, AM_NONE },
[0x72] = { "KIL", KIL, 1, 0, false, false, false, true, AM_NONE },
[0x92] = { "KIL", KIL, 1, 0, false, false, false, true, AM_NONE },
[0xB2] = { "KIL", KIL, 1, 0, false, false, false, true, AM_NONE },
[0xD2] = { "KIL", KIL, 1, 0, false, false, false, true, AM_NONE },
[0xF2] = { "KIL", KIL, 1, 0, false, false, false, true, AM_NONE },
[0xBB] = { "LAR", LAR, 3, 4, false, false, true, true, AM_ABS_Y },
[0xA7] = { "LAX", LAX, 2, 3, false, false, false, true, AM_ZP },
[0xB7] = { "LAX", LAX, 2, 4, false, false, false, true, AM_ZP_Y },
[0xAF] = { "LAX", LAX, 3, 4, false, false, false, true, AM_ABS },
[0xBF] = { "LAX", LAX, 3, 4, false, false, true, true, AM_ABS_Y },
[0xA3] = { "LAX", LAX, 2, 6, false, false, false, true, AM_IND_X },
[0xB3] = { "LAX", LAX, 2, 5, false, false, true, true, AM_IND_Y },
[0x1A] = { "NOP", NOP, 1, 2, false, false, false, true, AM_NONE },
[0x3A] = { "NOP", NOP, 1, 2, false, false, false, true, AM_NONE },
[0x5A] = { "NOP", NOP, 1, 2, false, false, false, true, AM_NONE },
[0x7A] = { "NOP", NOP, 1, 2, false, false, false, true, AM_NONE },
[0xDA] = { "NOP", NOP, 1, 2, false, false, false, true, AM_NONE },
[0xFA] = { "NOP", NOP, 1, 2, false, false, false, true, AM_NONE },
[0x27] = { "RLA", RLA, 2, 5, false, false, false, true, AM_ZP },
[0x37] = { "RLA", RLA, 2, 6, false, false, false, true, AM_ZP_X },
[0x2F] = { "RLA", RLA, 3, 6, false, false, false, true, AM_ABS },
[0x3F] = { "RLA", RLA, 3, 7, false, false, false, true, AM_ABS_X },
[0x3B] = { "RLA", RLA, 3, 7, false, false, false, true, AM_ABS_Y },
[0x23] = { "RLA", RLA, 2, 8, false, false, false, true, AM_IND_X },
[0x33] = { "RLA", RLA, 2, 8, false, false, false, true, AM_IND_Y },
[0x67] = { "RRA", RRA, 2, 5, false, false, false, true, AM_ZP },
[0x77] = { "RRA", RRA, 2, 6, false, false, false, true, AM_ZP_X },
[0x6F] = { "RRA", RRA, 3, 6, false, false, false, true, AM_ABS },
[0x7F] = { "RRA", RRA, 3, 7, false, false, false, true, AM_ABS_X },
[0x7B] = { "RRA", RRA, 3, 7, false, false, false, true, AM_ABS_Y },
[0x63] = { "RRA", RRA, 2, 8, false, false, false, true, AM_IND_X },
[0x73] = { "RRA", RRA, 2, 8, false, false, false, true, AM_IND_Y },
[0xEB] = { "SBC", SBC, 2, 2, false, false, false, true, AM_IMM },
[0x07] = { "SLO", SLO, 2, 5, false, false, false, true, AM_ZP },
[0x17] = { "SLO", SLO, 2, 6, false, false, false, true, AM_ZP_X },
[0x0F] = { "SLO", SLO, 3, 6, false, false, false, true, AM_ABS },
[0x1F] = { "SLO", SLO, 3, 7, false, false, false, true, AM_ABS_X },
[0x1B] = { "SLO", SLO, 3, 7, false, false, false, true, AM_ABS_Y },
[0x03] = { "SLO", SLO, 2, 8, false, false, false, true, AM_IND_X },
[0x13] = { "SLO", SLO, 2, 8, false, false, false, true, AM_IND_Y },
[0x47] = { "SRE", SRE, 2, 5, false, false, false, true, AM_ZP },
[0x57] = { "SRE", SRE, 2, 6, false, false, false, true, AM_ZP_X },
[0x4F] = { "SRE", SRE, 3, 6, false, false, false, true, AM_ABS },
[0x5F] = { "SRE", SRE, 3, 7, false, false, false, true, AM_ABS_X },
[0x5B] = { "SRE", SRE, 3, 7, false, false, false, true, AM_ABS_Y },
[0x43] = { "SRE", SRE, 2, 8, false, false, false, true, AM_IND_X },
[0x53] = { "SRE", SRE, 2, 8, false, false, false, true, AM_IND_Y },
[0x9E] = { "SXA", SXA, 3, 5, false, false, false, true, AM_ABS_Y },
[0x9C] = { "SYA", SYA, 3, 5, false, false, false, true, AM_ABS_X },
[0x0C] = { "NOP", NOP, 3, 4, true, false, false, true, AM_ABS },
[0x1C] = { "NOP", NOP, 3, 4, true, false, true, true, AM_ABS_X },
[0x3C] = { "NOP", NOP, 3, 4, true, false, true, true, AM_ABS_X },
[0x5C] = { "NOP", NOP, 3, 4, true, false, true, true, AM_ABS_X },
[0x7C] = { "NOP", NOP, 3, 4, true, false, true, true, AM_ABS_X },
[0xDC] = { "NOP", NOP, 3, 4, true, false, true, true, AM_ABS_X },
[0xFC] = { "NOP", NOP, 3, 4, true, false, true, true, AM_ABS_X },
[0x8B] = { "XAA", XAA, 2, 2, false, false, false, true, AM_IMM },
[0x9B] = { "XAS", XAS, 3, 5, false, false, false, true, AM_ABS_Y },
}; };