311 lines
8.3 KiB
C
311 lines
8.3 KiB
C
#include "op.h"
|
|
|
|
const uint8_t opcode_addr[OP_MAX] = {
|
|
/* 0- */
|
|
/* BRK */ OP_ADDR_IMPL,
|
|
/* ORA */ OP_ADDR_IND | OP_ADDR_X,
|
|
/* */ 0xFF,
|
|
/* */ 0xFF,
|
|
/* */ 0xFF,
|
|
/* ORA */ 0xFF,
|
|
/* ASL */ 0xFF,
|
|
/* */ 0xFF,
|
|
/* PHP */ OP_ADDR_IMPL,
|
|
/* ORA */ OP_ADDR_IMM,
|
|
/* ASL */ OP_ADDR_IMPL,
|
|
/* */ 0xFF,
|
|
/* */ 0xFF,
|
|
/* ORA */ OP_ADDR_ABS,
|
|
/* ASL */ OP_ADDR_ABS,
|
|
/* */ 0xFF,
|
|
|
|
/* 1- */
|
|
/* BPL */ OP_ADDR_REL,
|
|
/* ORA */ OP_ADDR_IND | OP_ADDR_Y,
|
|
/* */ 0xFF,
|
|
/* */ 0xFF,
|
|
/* */ 0xFF,
|
|
/* ORA */ 0xFF,
|
|
/* ASL */ 0xFF,
|
|
/* */ 0xFF,
|
|
/* CLC */ OP_ADDR_IMPL,
|
|
/* ORA */ OP_ADDR_ABS | OP_ADDR_Y,
|
|
/* */ 0xFF,
|
|
/* */ 0xFF,
|
|
/* */ 0xFF,
|
|
/* ORA */ OP_ADDR_ABS | OP_ADDR_X,
|
|
/* ASL */ OP_ADDR_ABS | OP_ADDR_X,
|
|
/* */ 0xFF,
|
|
|
|
/* 2- */
|
|
/* JSR */ OP_ADDR_ABS,
|
|
/* AND */ OP_ADDR_IND | OP_ADDR_Y,
|
|
/* */ 0xFF,
|
|
/* */ 0xFF,
|
|
/* BIT */ 0xFF,
|
|
/* AND */ 0xFF,
|
|
/* ROL */ 0xFF,
|
|
/* */ 0xFF,
|
|
/* PLP */ OP_ADDR_IMPL,
|
|
/* AND */ OP_ADDR_IMM,
|
|
/* ROL */ OP_ADDR_IMPL,
|
|
/* */ 0xFF,
|
|
/* BIT */ OP_ADDR_ABS,
|
|
/* AND */ OP_ADDR_ABS,
|
|
/* ROL */ OP_ADDR_ABS,
|
|
/* */ 0xFF,
|
|
|
|
/* 3- */
|
|
/* BMI */ OP_ADDR_REL,
|
|
/* AND */ OP_ADDR_IND | OP_ADDR_Y,
|
|
/* */ 0xFF,
|
|
/* */ 0xFF,
|
|
/* */ 0xFF,
|
|
/* AND */ 0xFF,
|
|
/* ROL */ 0xFF,
|
|
/* */ 0xFF,
|
|
/* SEC */ OP_ADDR_IMPL,
|
|
/* AND */ OP_ADDR_ABS | OP_ADDR_Y,
|
|
/* */ 0xFF,
|
|
/* */ 0xFF,
|
|
/* */ 0xFF,
|
|
/* AND */ OP_ADDR_ABS | OP_ADDR_X,
|
|
/* ROL */ OP_ADDR_ABS | OP_ADDR_X,
|
|
/* */ 0xFF,
|
|
|
|
/* 4- */
|
|
/* RTI */ OP_ADDR_IMPL,
|
|
/* EOR */ OP_ADDR_IND | OP_ADDR_X,
|
|
/* */ 0xFF,
|
|
/* */ 0xFF,
|
|
/* */ 0xFF,
|
|
/* EOR */ 0xFF,
|
|
/* LSR */ 0xFF,
|
|
/* */ 0xFF,
|
|
/* PHA */ OP_ADDR_IMPL,
|
|
/* EOR */ OP_ADDR_IMM,
|
|
/* LSR */ OP_ADDR_IMPL,
|
|
/* */ 0xFF,
|
|
/* JMP */ OP_ADDR_ABS,
|
|
/* EOR */ OP_ADDR_ABS,
|
|
/* LSR */ OP_ADDR_ABS,
|
|
/* */ 0xFF,
|
|
|
|
/* 5- */
|
|
/* BVC */ OP_ADDR_REL,
|
|
/* EOR */ OP_ADDR_IND | OP_ADDR_Y,
|
|
/* */ 0xFF,
|
|
/* */ 0xFF,
|
|
/* */ 0xFF,
|
|
/* EOR */ 0xFF,
|
|
/* LSR */ 0xFF,
|
|
/* */ 0xFF,
|
|
/* CLI */ OP_ADDR_IMPL,
|
|
/* EOR */ OP_ADDR_ABS | OP_ADDR_Y,
|
|
/* */ 0xFF,
|
|
/* */ 0xFF,
|
|
/* */ 0xFF,
|
|
/* EOR */ OP_ADDR_ABS | OP_ADDR_X,
|
|
/* LSR */ OP_ADDR_ABS | OP_ADDR_X,
|
|
/* */ 0xFF,
|
|
|
|
/* 6- */
|
|
/* RTS */ OP_ADDR_IMPL,
|
|
/* ADC */ OP_ADDR_IND | OP_ADDR_X,
|
|
/* */ 0xFF,
|
|
/* */ 0xFF,
|
|
/* */ 0xFF,
|
|
/* ADC */ 0xFF,
|
|
/* ROR */ 0xFF,
|
|
/* */ 0xFF,
|
|
/* PLA */ OP_ADDR_IMPL,
|
|
/* ADC */ OP_ADDR_IMM,
|
|
/* ROR */ OP_ADDR_IMPL,
|
|
/* */ 0xFF,
|
|
/* JMP */ OP_ADDR_IND,
|
|
/* ADC */ OP_ADDR_ABS,
|
|
/* ROR */ OP_ADDR_ABS,
|
|
/* */ 0xFF,
|
|
|
|
/* 7- */
|
|
/* BVS */ OP_ADDR_REL,
|
|
/* ADC */ OP_ADDR_IND | OP_ADDR_Y,
|
|
/* */ 0xFF,
|
|
/* */ 0xFF,
|
|
/* */ 0xFF,
|
|
/* ADC */ 0xFF,
|
|
/* ROR */ 0xFF,
|
|
/* */ 0xFF,
|
|
/* SEI */ OP_ADDR_IMPL,
|
|
/* ADC */ OP_ADDR_ABS | OP_ADDR_Y,
|
|
/* */ 0xFF,
|
|
/* */ 0xFF,
|
|
/* */ 0xFF,
|
|
/* ADC */ OP_ADDR_ABS | OP_ADDR_X,
|
|
/* ROR */ OP_ADDR_ABS | OP_ADDR_X,
|
|
/* */ 0xFF,
|
|
|
|
/* 8- */
|
|
/* */ 0xFF,
|
|
/* STA */ OP_ADDR_IND | OP_ADDR_X,
|
|
/* */ 0xFF,
|
|
/* */ 0xFF,
|
|
/* STY */ 0xFF,
|
|
/* STA */ 0xFF,
|
|
/* STX */ 0xFF,
|
|
/* */ 0xFF,
|
|
/* DEY */ OP_ADDR_IMPL,
|
|
/* */ 0xFF,
|
|
/* TXA */ OP_ADDR_IMPL,
|
|
/* */ 0xFF,
|
|
/* STY */ OP_ADDR_ABS,
|
|
/* STA */ OP_ADDR_ABS,
|
|
/* STX */ OP_ADDR_ABS,
|
|
/* */ 0xFF,
|
|
|
|
/* 9- */
|
|
/* BCC */ OP_ADDR_REL,
|
|
/* STA */ OP_ADDR_IND | OP_ADDR_Y,
|
|
/* */ 0xFF,
|
|
/* */ 0xFF,
|
|
/* STY */ 0xFF,
|
|
/* STA */ 0xFF,
|
|
/* STX */ 0xFF,
|
|
/* */ 0xFF,
|
|
/* TYA */ OP_ADDR_IMPL,
|
|
/* STA */ OP_ADDR_ABS | OP_ADDR_Y,
|
|
/* TXS */ OP_ADDR_IMPL,
|
|
/* */ 0xFF,
|
|
/* */ 0xFF,
|
|
/* STA */ OP_ADDR_ABS | OP_ADDR_X,
|
|
/* */ 0xFF,
|
|
/* */ 0xFF,
|
|
|
|
/* A- */
|
|
/* LDY */ OP_ADDR_IMM,
|
|
/* LDA */ OP_ADDR_IND | OP_ADDR_X,
|
|
/* LDX */ OP_ADDR_IMM,
|
|
/* */ 0xFF,
|
|
/* LDY */ 0xFF,
|
|
/* LDA */ 0xFF,
|
|
/* LDX */ 0xFF,
|
|
/* */ 0xFF,
|
|
/* TAY */ OP_ADDR_IMPL,
|
|
/* LDA */ OP_ADDR_IMM,
|
|
/* TAX */ OP_ADDR_IMPL,
|
|
/* */ 0xFF,
|
|
/* LDY */ OP_ADDR_ABS,
|
|
/* LDA */ OP_ADDR_ABS,
|
|
/* LDX */ OP_ADDR_ABS,
|
|
/* */ 0xFF,
|
|
|
|
/* B- */
|
|
/* BCS */ OP_ADDR_REL,
|
|
/* LDA */ OP_ADDR_IND | OP_ADDR_Y,
|
|
/* */ 0xFF,
|
|
/* */ 0xFF,
|
|
/* LDY */ 0xFF,
|
|
/* LDA */ 0xFF,
|
|
/* LDX */ 0xFF,
|
|
/* */ 0xFF,
|
|
/* CLV */ OP_ADDR_IMPL,
|
|
/* LDA */ OP_ADDR_ABS | OP_ADDR_Y,
|
|
/* TSX */ OP_ADDR_IMPL,
|
|
/* */ 0xFF,
|
|
/* LDY */ OP_ADDR_ABS | OP_ADDR_X,
|
|
/* LDA */ OP_ADDR_ABS | OP_ADDR_X,
|
|
/* LDX */ OP_ADDR_ABS | OP_ADDR_Y,
|
|
/* */ 0xFF,
|
|
|
|
/* C- */
|
|
/* CPY */ OP_ADDR_IMM,
|
|
/* CMP */ OP_ADDR_IND | OP_ADDR_X,
|
|
/* */ 0xFF,
|
|
/* */ 0xFF,
|
|
/* CPY */ 0xFF,
|
|
/* CMP */ 0xFF,
|
|
/* DEC */ 0xFF,
|
|
/* */ 0xFF,
|
|
/* INY */ OP_ADDR_IMPL,
|
|
/* CMP */ OP_ADDR_IMM,
|
|
/* DEX */ OP_ADDR_IMPL,
|
|
/* */ 0xFF,
|
|
/* CPY */ OP_ADDR_ABS,
|
|
/* CMP */ OP_ADDR_ABS,
|
|
/* DEC */ OP_ADDR_ABS,
|
|
/* */ 0xFF,
|
|
|
|
/* D- */
|
|
/* BNE */ OP_ADDR_REL,
|
|
/* CMP */ OP_ADDR_IND | OP_ADDR_Y,
|
|
/* */ 0xFF,
|
|
/* */ 0xFF,
|
|
/* */ 0xFF,
|
|
/* CMP */ 0xFF,
|
|
/* DEC */ 0xFF,
|
|
/* */ 0xFF,
|
|
/* CLD */ OP_ADDR_IMPL,
|
|
/* CMP */ OP_ADDR_ABS | OP_ADDR_Y,
|
|
/* */ 0xFF,
|
|
/* */ 0xFF,
|
|
/* */ 0xFF,
|
|
/* CMP */ OP_ADDR_ABS | OP_ADDR_X,
|
|
/* DEC */ OP_ADDR_ABS | OP_ADDR_X,
|
|
/* */ 0xFF,
|
|
|
|
/* E- */
|
|
/* CPX */ OP_ADDR_IMM,
|
|
/* SBC */ OP_ADDR_IND | OP_ADDR_X,
|
|
/* */ 0xFF,
|
|
/* */ 0xFF,
|
|
/* CPX */ 0xFF,
|
|
/* SBC */ 0xFF,
|
|
/* INC */ 0xFF,
|
|
/* */ 0xFF,
|
|
/* INX */ OP_ADDR_IMPL,
|
|
/* SBC */ OP_ADDR_IMM,
|
|
/* NOP */ OP_ADDR_IMPL,
|
|
/* */ 0xFF,
|
|
/* CPX */ OP_ADDR_ABS,
|
|
/* SBC */ OP_ADDR_ABS,
|
|
/* INC */ OP_ADDR_ABS,
|
|
/* */ 0xFF,
|
|
|
|
/* F- */
|
|
/* BEQ */ OP_ADDR_REL,
|
|
/* SBC */ OP_ADDR_IND | OP_ADDR_Y,
|
|
/* */ 0xFF,
|
|
/* */ 0xFF,
|
|
/* */ 0xFF,
|
|
/* SBC */ 0xFF,
|
|
/* INC */ 0xFF,
|
|
/* */ 0xFF,
|
|
/* SED */ OP_ADDR_IMPL,
|
|
/* SBC */ OP_ADDR_ABS | OP_ADDR_Y,
|
|
/* */ 0xFF,
|
|
/* */ 0xFF,
|
|
/* */ 0xFF,
|
|
/* SBC */ OP_ADDR_ABS | OP_ADDR_X,
|
|
/* INC */ OP_ADDR_ABS | OP_ADDR_X,
|
|
/* */ 0xFF
|
|
};
|
|
|
|
const char *opcode_str[OP_MAX] = {
|
|
"BRK", "ORA", NULL, NULL, NULL, "ORA", "ASL", NULL, "PHP", "ORA", "ASLA", NULL, NULL, "ORA", "ASL", NULL,
|
|
"BPL", "ORA", NULL, NULL, NULL, "ORA", "ASL", NULL, "CLC", "ORA", NULL, NULL, NULL, "ORA", "ASL", NULL,
|
|
"JSR", "AND", NULL, NULL, "BIT", "AND", "ROL", NULL, "PLP", "AND", "ROLA", NULL, "BIT", "AND", "ROL", NULL,
|
|
"BMI", "AND", NULL, NULL, NULL, "AND", "ROL", NULL, "SEC", "AND", NULL, NULL, NULL, "AND", "ROL", NULL,
|
|
"RTI", "EOR", NULL, NULL, NULL, "EOR", "LSR", NULL, "PHA", "EOR", "LSRA", NULL, "JMP", "EOR", "LSR", NULL,
|
|
"BVC", "EOR", NULL, NULL, NULL, "EOR", "LSR", NULL, "CLI", "EOR", NULL, NULL, NULL, "EOR", "LSR", NULL,
|
|
"RTS", "ADC", NULL, NULL, NULL, "ADC", "ROR", NULL, "PLA", "ADC", "RORA", NULL, "JMP", "ADC", "ROR", NULL,
|
|
"BVS", "ADC", NULL, NULL, NULL, "ADC", "ROR", NULL, "SEI", "ADC", NULL, NULL, NULL, "ADC", "ROR", NULL,
|
|
NULL, "STA", NULL, NULL, "STY", "STA", "STX", NULL, "DEY", NULL, "TXA", NULL, "STY", "STA", "STX", NULL,
|
|
"BCC", "STA", NULL, NULL, "STY", "STA", "STX", NULL, "TYA", "STA", "TXS", NULL, NULL, "STA", NULL, NULL,
|
|
"LDY", "LDA", "LDX", NULL, "LDY", "LDA", "LDX", NULL, "TAY", "LDA", "TAX", NULL, "LDY", "LDA", "LDX", NULL,
|
|
"BCS", "LDA", NULL, NULL, "LDY", "LDA", "LDX", NULL, "CLV", "LDA", "TSX", NULL, "LDY", "LDA", "LDX", NULL,
|
|
"CPY", "CMP", NULL, NULL, "CPY", "CMP", "DEC", NULL, "INY", "CMP", "DEX", NULL, "CPY", "CMP", "DEC", NULL,
|
|
"BNE", "CMP", NULL, NULL, NULL, "CMP", "DEC", NULL, "CLD", "CMP", NULL, NULL, NULL, "CMP", "DEC", NULL,
|
|
"CPX", "SBC", NULL, NULL, "CPX", "SBC", "INC", NULL, "INX", "SBC", "NOP", NULL, "CPX", "SBC", "INC", NULL,
|
|
"BEQ", "SBC", NULL, NULL, NULL, "SBC", "INC", NULL, "SED", "SBC", NULL, NULL, NULL, "SBC", "INC", NULL
|
|
};
|