From 756c606af68be8ccca7aced3b9c3d56fb2d5087f Mon Sep 17 00:00:00 2001 From: mrb0nk500 Date: Mon, 6 Jul 2020 20:04:41 -0400 Subject: - Implemented a new opcode table. - Added a new preifx called the OF prefix, which adds the contents of a specific register to the current operand. - Added a table generator, which parses opcode table csv files. --- asmmon.h | 572 ++++++++++++++++++++++++++++++++------------------------------- 1 file changed, 287 insertions(+), 285 deletions(-) (limited to 'asmmon.h') diff --git a/asmmon.h b/asmmon.h index 39e2d19..eadbc83 100644 --- a/asmmon.h +++ b/asmmon.h @@ -93,6 +93,7 @@ enum token { TOK_IMM, TOK_OPCODE, TOK_RS, + TOK_OF, TOK_COMMENT, TOK_HEX, TOK_DEC, @@ -114,6 +115,8 @@ enum pre_token { PTOK_COMMA, PTOK_X, PTOK_Y, + PTOK_S, + PTOK_P, PTOK_DQUOTE, PTOK_SQUOTE, PTOK_HASH, @@ -133,96 +136,95 @@ enum expr { EXPR_NONE }; -static const uint8_t opcodes[OPNUM][9] = { - /* IMM ZM ZMX ZMY IND INDX INDY ABS IMPL*/ - [ 0] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00}, - [ 1] = {0x01, 0x06, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x04, 0xFF}, - [ 2] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x02}, - [ 3] = {0x08, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}, - [ 4] = {0x09, 0x2D, 0xFF, 0xFF, 0x55, 0xAD, 0xAC, 0x2C, 0xFF}, - [ 5] = {0x0A, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}, - [ 6] = {0xFF, 0x0D, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x0C, 0xE5}, - [ 7] = {0xFF, 0x0E, 0xFF, 0xFF, 0xCE, 0xFF, 0xFF, 0x10, 0xFF}, - [ 8] = {0x11, 0x16, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x14, 0xFF}, - [ 9] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x12}, - [10] = {0x18, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}, - [11] = {0x19, 0x3D, 0xFF, 0xFF, 0x85, 0xFF, 0xFF, 0x4C, 0xFF}, - [12] = {0x1A, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}, - [13] = {0xFF, 0x1D, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x1C, 0xF5}, - [14] = {0xFF, 0x1E, 0xFF, 0xFF, 0xBE, 0xFF, 0xFF, 0x20, 0xFF}, - [15] = {0x21, 0x26, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x24, 0xFF}, - [16] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x22}, - [17] = {0x28, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}, - [18] = {0x29, 0x4D, 0xFF, 0xFF, 0xB5, 0xFF, 0xFF, 0x3C, 0xFF}, - [19] = {0x2A, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}, - [20] = {0xFF, 0x2E, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x30, 0xFF}, - [21] = {0x31, 0x36, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x34, 0xFF}, - [22] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x32}, - [23] = {0x38, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}, - [24] = {0x3A, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}, - [25] = {0xFF, 0x3E, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x40, 0xFF}, - [26] = {0x41, 0x46, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x44, 0xFF}, - [27] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x42}, - [28] = {0x48, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}, - [29] = {0x4A, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}, - [30] = {0xFF, 0x4E, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x50, 0xFF}, - [31] = {0x51, 0x56, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x54, 0xFF}, - [32] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x52}, - [33] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x58}, - [34] = {0x5A, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}, - [35] = {0xFF, 0x5E, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x60, 0xFF}, - [36] = {0x61, 0x66, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x64, 0xFF}, - [37] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x62}, - [38] = {0x68, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}, - [39] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x6A}, - [40] = {0xFF, 0x6E, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x70, 0xFF}, - [41] = {0x71, 0x76, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x74, 0xFF}, - [42] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF,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FF, 0xDD, 0xA9, 0x69, 0x45, 0x9D, 0x9C, 0xDC, 0xFF}, - [78] = {0xE0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}, - [79] = {0xE1, 0xE6, 0xE9, 0xFF, 0x65, 0xFF, 0xFF, 0xE4, 0xFF}, - [80] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xE8}, - [81] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xEA}, - [82] = {0xFF, 0xED, 0xF9, 0xFF, 0x75, 0xFF, 0xFF, 0xEC, 0xFF}, - [83] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xEE}, - [84] = {0xF1, 0xF6, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF4, 0xFF}, - [85] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF2}, - [86] = {0xFF, 0xFD, 0xFF, 0xD9, 0xA5, 0xFF, 0xFF, 0xFC, 0xFF}, - [87] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE} +static const uint8_t opcodes[OPNUM][10] = { + /* IMM ZM ZMX ZMY IND INDX INDY ABS REL IMPL*/ + [AAB] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x02}, /* AAB */ + [ABA] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x22}, /* ABA */ + [ADC] = {0x01, 0x06, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x04, 0xFF, 0xFF}, /* ADC */ + [AND] = {0x21, 0x26, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x24, 0xFF, 0xFF}, /* AND */ + [ARB] = {0xFF, 0xFF, 0xFF, 0x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D2}, /* INB */ + [INC] = {0xFF, 0x1D, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x1C, 0xFF, 0x1A}, /* INC */ + [INX] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x19}, /* INX */ + [INY] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x39}, /* INY */ + [JMP] = {0xFF, 0x30, 0xFF, 0xFF, 0xB5, 0xFF, 0xFF, 0x10, 0xFF, 0xFF}, /* JMP */ + [JSR] = {0xFF, 0x40, 0xFF, 0xFF, 0xA5, 0xFF, 0xFF, 0x20, 0xFF, 0xFF}, /* JSR */ + [LDA] = {0xC1, 0xC6, 0xB8, 0x78, 0x05, 0x5D, 0x5C, 0xC4, 0xFF, 0xFF}, /* LDA */ + [LDB] = {0xD1, 0xD6, 0xD8, 0x98, 0x35, 0x8D, 0x8C, 0xD4, 0xFF, 0xFF}, /* LDB */ + [LDX] = {0xB9, 0xBD, 0xFF, 0xFF, 0x85, 0xFF, 0xFF, 0xBC, 0xFF, 0xFF}, /* LDX */ + [LDY] = {0xE1, 0xE6, 0xFF, 0xFF, 0x65, 0xFF, 0xFF, 0xE4, 0xFF, 0xFF}, /* LDY */ + [LLB] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x52}, /* LLB */ + [LRB] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x62}, /* LRB */ + [LSL] = {0x51, 0x56, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x54, 0xFF, 0xFF}, /* LSL */ + [LSR] = {0x61, 0x66, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x64, 0xFF, 0xFF}, /* LSR */ + [MAB] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x92}, /* MAB */ + [MUL] = {0x91, 0x96, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x94, 0xFF, 0xFF}, /* MUL */ + [NOP] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xEA}, /* NOP */ + [OAB] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x32}, /* OAB */ + [ORA] = {0x31, 0x36, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x34, 0xFF, 0xFF}, /* ORA */ + [PHA] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x79}, /* PHA */ + [PHB] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x99}, /* PHB */ + [PHP] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x59}, /* PHP */ + [PHX] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xE9}, /* PHX */ + [PHY] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xC9}, /* PHY */ + [PLA] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x89}, /* PLA */ + [PLB] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xA9}, /* PLB */ + [PLP] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x69}, /* PLP */ + [PLX] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF9}, /* PLX */ + [PLY] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xD9}, /* PLY */ + [RLB] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x72}, /* RLB */ + [ROL] = {0x71, 0x76, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x74, 0xFF, 0xFF}, /* ROL */ + [ROR] = {0x81, 0x86, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x84, 0xFF, 0xFF}, /* ROR */ + [RRB] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x82}, /* RRB */ + [RTI] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF0}, /* RTI */ + [RTS] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xE0}, /* RTS */ + [SAB] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x12}, /* SAB */ + [SBC] = {0x11, 0x16, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x14, 0xFF, 0xFF}, /* SBC */ + [SEC] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x18}, /* SEC */ + [SEI] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x38}, /* SEI */ + [STA] = {0xFF, 0xCD, 0xC8, 0x88, 0x15, 0x6D, 0x6C, 0xCC, 0xFF, 0xFF}, /* STA */ + [STB] = {0xFF, 0xDD, 0xE8, 0xA8, 0x45, 0x9D, 0x9C, 0xDC, 0xFF, 0xFF}, /* STB */ + [STX] = {0xFF, 0xFD, 0xFF, 0xFF, 0x95, 0xFF, 0xFF, 0xFC, 0xFF, 0xFF}, /* STX */ + [STY] = {0xFF, 0xED, 0xFF, 0xFF, 0x75, 0xFF, 0xFF, 0xEC, 0xFF, 0xFF}, /* STY */ + [TAB] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x5A}, /* TAB */ + [TAX] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x9A}, /* TAX */ + [TAY] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7A}, /* TAY */ + [TBA] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x6A}, /* TBA */ + [TSX] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xDA}, /* TSX */ + [TXA] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xAA}, /* TXA */ + [TXS] = {0xFA, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}, /* TXS */ + [TXY] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xCA}, /* TXY */ + [TYA] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x8A}, /* TYA */ + [TYX] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xBA}, /* TYX */ + [WAI] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x58}, /* WAI */ + [XAB] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x42}, /* XAB */ + [XOR] = {0x41, 0x46, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x44, 0xFF, 0xFF} /* XOR */ }; static const char *dir_t[6] = { @@ -241,27 +243,28 @@ static const char *rs_t[4] = { [3] = ".q" }; -static const char *lex_tok[17] = { - [0x00] = "TOK_DIR", - [0x01] = "TOK_LOCAL", - [0x02] = "TOK_LABEL", - [0x03] = "TOK_SYM", - [0x04] = "TOK_EXPR", - [0x05] = "TOK_CSV", - [0x06] = "TOK_STRING", - [0x07] = "TOK_CHAR", - [0x08] = "TOK_IND", - [0x09] = "TOK_IMM", - [0x0A] = "TOK_OPCODE", - [0x0B] = "TOK_RS", - [0x0C] = "TOK_COMMENT", - [0x0D] = "TOK_HEX", - [0x0E] = "TOK_DEC", - [0x0F] = "TOK_BIN", - [0x10] = "TOK_INCLUDE" +static const char *lex_tok[18] = { + [TOK_DIR ] = "TOK_DIR", + [TOK_LOCAL ] = "TOK_LOCAL", + [TOK_LABEL ] = "TOK_LABEL", + [TOK_SYM ] = "TOK_SYM", + [TOK_EXPR ] = "TOK_EXPR", + [TOK_CSV ] = "TOK_CSV", + [TOK_STRING ] = "TOK_STRING", + [TOK_CHAR ] = "TOK_CHAR", + [TOK_IND ] = "TOK_IND", + [TOK_IMM ] = "TOK_IMM", + [TOK_OPCODE ] = "TOK_OPCODE", + [TOK_RS ] = "TOK_RS", + [TOK_OF ] = "TOK_OF", + [TOK_COMMENT] = "TOK_COMMENT", + [TOK_HEX ] = "TOK_HEX", + [TOK_DEC ] = "TOK_DEC", + [TOK_BIN ] = "TOK_BIN", + [TOK_INCLUDE] = "TOK_INCLUDE" }; -static const char *adrmode[9] = { +static const char *adrmode[10] = { [IMM ] = "IMM", [ZM ] = "ZM", [ZMX ] = "ZMX", @@ -270,189 +273,188 @@ static const char *adrmode[9] = { [INDX] = "INDX", [INDY] = "INDY", [ABS ] = "ABS", + [REL ] = "REL", [IMPL] = "IMPL" }; static const char *mne[OPNUM] = { - [ 0] = "CPS", - [ 1] = "ADC", - [ 2] = "AAB", - [ 3] = "PHP", - [ 4] = "CPB", - [ 5] = "PHB", - [ 6] = "DEC", - [ 7] = "JMP", - [ 8] = "SBC", - [ 9] = "SAB", - [10] = "ENT", - [11] = "CPY", - [12] = "PLB", - [13] = "INC", - [14] = "JSR", - [15] = "AND", - [16] = "ABA", - [17] = "PLP", - [18] = "CPX", - [19] = "PHY", - [20] = "BPO", - [21] = "ORA", - [22] = "OAB", - [23] = "STT", - [24] = "PLY", - [25] = "BNG", - [26] = "XOR", - [27] = "XAB", - [28] = "PHA", - [29] = "PHX", - [30] = "BCS", - [31] = "LSL", - [32] = "LLB", - [33] = "CLC", - [34] = "PLX", - [35] = "BCC", - [36] = "LSR", - [37] = "LRB", - [38] = "PLA", - [39] = "TAB", - [40] = "BEQ", - [41] = "ROL", - [42] = "RLB", - [43] = "SEC", - [44] = "TBA", - [45] = "BNE", - [46] = "ROR", - [47] = "RRB", - [48] = "DEY", - [49] = "TAY", - [50] = "BVS", - [51] = "MUL", - [52] = "MAB", - [53] = "CLI", - [54] = "TYA", - [55] = "BVC", - [56] = "DIV", - [57] = "DAB", - [58] = "INY", - [59] = "TAX", - [60] = "RTS", - [61] = "CMP", - [62] = "CAB", - [63] = "SEI", - [64] = "LDX", - [65] = "TXA", - [66] = "RTI", - [67] = "LDA", - [68] = "DEX", - [69] = "CLV", - [70] = "TYX", - [71] = "STA", - [72] = "TSX", - [73] = "LDB", - [74] = "INX", - [75] = "WAI", - [76] = "TXY", - [77] = "STB", - [78] = "TXS", - [79] = "LDY", - [80] = "BRK", - [81] = "NOP", - [82] = "STY", - [83] = "DEB", - [84] = "ASR", - [85] = "ARB", - [86] = "STX", - [87] = "INB" + [AAB] = "AAB", + [ABA] = "ABA", + [ADC] = "ADC", + [AND] = "AND", + [ARB] = "ARB", + [ASR] = "ASR", + [BCC] = "BCC", + [BCS] = "BCS", + [BEQ] = "BEQ", + [BNE] = "BNE", + [BNG] = "BNG", + [BPO] = "BPO", + [BRA] = "BRA", + [BRK] = "BRK", + [BVC] = "BVC", + [BVS] = "BVS", + [CAB] = "CAB", + [CLC] = "CLC", + [CLI] = "CLI", + [CLV] = "CLV", + [CMP] = "CMP", + [CPB] = "CPB", + [CPS] = "CPS", + [CPX] = "CPX", + [CPY] = "CPY", + [DAB] = "DAB", + [DEB] = "DEB", + [DEC] = "DEC", + [DEX] = "DEX", + [DEY] = "DEY", + [DIV] = "DIV", + [INB] = "INB", + [INC] = "INC", + [INX] = "INX", + [INY] = "INY", + [JMP] = "JMP", + [JSR] = "JSR", + [LDA] = "LDA", + [LDB] = "LDB", + [LDX] = "LDX", + [LDY] = "LDY", + [LLB] = "LLB", + [LRB] = "LRB", + [LSL] = "LSL", + [LSR] = "LSR", + [MAB] = "MAB", + [MUL] = "MUL", + [NOP] = "NOP", + [OAB] = "OAB", + [ORA] = "ORA", + [PHA] = "PHA", + [PHB] = "PHB", + [PHP] = "PHP", + [PHX] = "PHX", + [PHY] = "PHY", + [PLA] = "PLA", + [PLB] = "PLB", + [PLP] = "PLP", + [PLX] = "PLX", + [PLY] = "PLY", + [RLB] = "RLB", + [ROL] = "ROL", + [ROR] = "ROR", + [RRB] = "RRB", + [RTI] = "RTI", + [RTS] = "RTS", + [SAB] = "SAB", + [SBC] = "SBC", + [SEC] = "SEC", + [SEI] = "SEI", + [STA] = "STA", + [STB] = "STB", + [STX] = "STX", + [STY] = "STY", + [TAB] = "TAB", + [TAX] = "TAX", + [TAY] = "TAY", + [TBA] = "TBA", + [TSX] = "TSX", + [TXA] = "TXA", + [TXS] = "TXS", + [TXY] = "TXY", + [TYA] = "TYA", + [TYX] = "TYX", + [WAI] = "WAI", + [XAB] = "XAB", + [XOR] = "XOR" }; static const char *instdesc[OPNUM] = { - [ 0] = "Clears the Processor Status register.", - [ 1] = "ADd accumulator, with operand, Carry if needed.", - [ 2] = "Add Accumulator, with B, carry if needed.", - [ 3] = "PusH the number of bytes specified, from the Processor status register to the stack.", - [ 4] = "ComPare the B register, with operand.", - [ 5] = "PusH the number of bytes specified, from the B register to the stack.", - [ 6] = "DECrement accumulator, or memory.", - [ 7] = "JuMP to the address specified.", - [ 8] = "SuBtract accumulator, with operand, Carry if needed", - [ 9] = "Subtract Accumulator, with B, carry if needed.", - [10] = "ENd a Thread.", - [11] = "ComPare the Y register, with operand.", - [12] = "PuLl the number of bytes specified, from the stack, to the B register.", - [13] = "INCrement accumulator, or memory.", - [14] = "Jump to a SubRoutine.", - [15] = "Bitwise AND accumulator, with operand.", - [16] = "Bitwise AND Accumulator, with B.", - [17] = "PuLl the number of bytes specified, from the stack, to the Processor status register.", - [18] = "ComPare the X register, with operand.", - [19] = "PusH the number of bytes specified, from the Y register to the stack.", - [20] = "Branch if POsitive.", - [21] = "Bitwise OR Accumulator, with operand.", - [22] = "Bitwise OR Accumulator, with B.", - [23] = "STart a Thread.", - [24] = "PuLl the number of bytes specified, from the stack, to the Y register.", - [25] = "Branch if NeGative.", - [26] = "Bitwise XOR Accumulator, with operand.", - [27] = "Bitwise XOR Accumulator, with B.", - [28] = "PusH the number of bytes specified, from the Accumulator to the stack.", - [29] = "PusH the number of bytes specified, from the X register to the stack.", - [30] = "Branch if the Carry flag is Set.", - [31] = "Logical Shift Left accumulator, with operand.", - [32] = "Logical Shift Left accumulator, with B.", - [33] = "CLear the Carry flag.", - [34] = "PuLl the number of bytes specified, from the stack, to the X register.", - [35] = "Branch if the Carry flag has been Cleared.", - [36] = "Logical Shift Right accumulator, with operand.", - [37] = "Logical Shift Right accumulator, with B.", - [38] = "PuLl the number of bytes specified, from the stack, to the Accumulator.", - [39] = "Transfer the value from the Accumulator, to the B register.", - [40] = "Branch if EQual (the zero flag has been set).", - [41] = "ROtate Left accumulator, with operand.", - [42] = "Rotate Left accumulator, with B.", - [43] = "SEt the Carry flag.", - [44] = "Transfer the value from the Y register, to the Accumulator.", - [45] = "Branch if Not Equal (the zero flag has been cleared)", - [46] = "ROtate Right accumulator, with operand.", - [47] = "Rotate Right accumulator, with B.", - [48] = "DEcrement the Y register.", - [49] = "Transfer the value from the Accumulator, to the Y register.", - [50] = "Branch if the oVerflow flag is Set.", - [51] = "MULtiply accumulator, with operand.", - [52] = "Multiply Accumulator, with B.", - [53] = "CLear the Interrupt flag.", - [54] = "Transfer the value from the Y register, to the Accumulator.", - [55] = "Branch if the oVerflow flag has been Cleared.", - [56] = "DIVide accumulator, with operand, and put the remainder into the B register.", - [57] = "Divide Accumulator, with B, and put the remainder into the X register.", - [58] = "INcrement the Y register.", - [59] = "Transfer the value from the Accumulator, to the X register.", - [60] = "ReTurn from a Subroutine.", - [61] = "CoMPare acumulator, with operand.", - [62] = "Compare Accumulator, with B.", - [63] = "SEt the Interrupt flag.", - [64] = "LoaD the value from the operand, to the X register.", - [65] = "Transfer the value from the X register, to the Accumulator.", - [66] = "ReTurn from an Interrupt.", - [67] = "LoaD the value from the operand, to the Accumulator.", - [68] = "DEcrement the X register.", - [69] = "CLear the oVerflow flag.", - [70] = "Transfer the value from the Y register, to the X register.", - [71] = "STore the value from the Accumulator, in memory.", - [72] = "Transfer the value from the Stack pointer, to the X register.", - [73] = "LoaD the value from the operand, to the B register.", - [74] = "INcrement the X register.", - [75] = "WAIt for an interrupt", - [76] = "Transfer the value from the X register, to the Y register.", - [77] = "STore the value from the B register, in memory.", - [78] = "Transfer the value from the X register, to the Stack pointer.", - [79] = "LoaD the value from the operand, to the Y register.", - [80] = "BReaKpoint", - [81] = "NO oPeration", - [82] = "STore the value from the Y register, in memory.", - [83] = "DEcrement the B register.", - [84] = "Arithmetic Shift Right accumulator, with operand.", - [85] = "Arithmetic shift Right accumulator, with B.", - [86] = "STore the value from the X register, in memory.", - [87] = "INcrement the B register." + [AAB] = "Add Accumulator, with B, carry if needed.", + [ABA] = "Bitwise AND Accumulator, with B.", + [ADC] = "ADd accumulator, with operand, Carry if needed.", + [AND] = "Bitwise AND accumulator, with operand.", + [ARB] = "Arithmetic shift Right accumulator, with B.", + [ASR] = "Arithmetic Shift Right accumulator, with operand.", + [BCC] = "Branch if the Carry flag has been Cleared.", + [BCS] = "Branch if the Carry flag is Set.", + [BEQ] = "Branch if EQual (the zero flag has been set).", + [BNE] = "Branch if Not Equal (the zero flag has been cleared)", + [BNG] = "Branch if NeGative.", + [BPO] = "Branch if POsitive.", + [BRA] = "BRanch Always.", + [BRK] = "BReaKpoint", + [BVC] = "Branch if the oVerflow flag has been Cleared.", + [BVS] = "Branch if the oVerflow flag is Set.", + [CAB] = "Compare Accumulator, with B.", + [CLC] = "CLear the Carry flag.", + [CLI] = "CLear the Interrupt flag.", + [CLV] = "CLear the oVerflow flag.", + [CMP] = "CoMPare acumulator, with operand.", + [CPB] = "ComPare the B register, with operand.", + [CPS] = "Clears the Processor Status register.", + [CPX] = "ComPare the X register, with operand.", + [CPY] = "ComPare the Y register, with operand.", + [DAB] = "Divide Accumulator, with B, and put the remainder into the X register.", + [DEB] = "DEcrement the B register.", + [DEC] = "DECrement accumulator, or memory.", + [DEX] = "DEcrement the X register.", + [DEY] = "DEcrement the Y register.", + [DIV] = "DIVide accumulator, with operand, and put the remainder into the B register.", + [INB] = "INcrement the B register.", + [INC] = "INCrement accumulator, or memory.", + [INX] = "INcrement the X register.", + [INY] = "INcrement the Y register.", + [JMP] = "JuMP to the address specified.", + [JSR] = "Jump to a SubRoutine.", + [LDA] = "LoaD the value from the operand, to the Accumulator.", + [LDB] = "LoaD the value from the operand, to the B register.", + [LDX] = "LoaD the value from the operand, to the X register.", + [LDY] = "LoaD the value from the operand, to the Y register.", + [LLB] = "Logical Shift Left accumulator, with B.", + [LRB] = "Logical Shift Right accumulator, with B.", + [LSL] = "Logical Shift Left accumulator, with operand.", + [LSR] = "Logical Shift Right accumulator, with operand.", + [MAB] = "Multiply Accumulator, with B.", + [MUL] = "MULtiply accumulator, with operand.", + [NOP] = "NO oPeration", + [OAB] = "Bitwise OR Accumulator, with B.", + [ORA] = "Bitwise OR Accumulator, with operand.", + [PHA] = "PusH the number of bytes specified, from the Accumulator to the stack.", + [PHB] = "PusH the number of bytes specified, from the B register to the stack.", + [PHP] = "PusH the number of bytes specified, from the Processor status register to the stack.", + [PHX] = "PusH the number of bytes specified, from the X register to the stack.", + [PHY] = "PusH the number of bytes specified, from the Y register to the stack.", + [PLA] = "PuLl the number of bytes specified, from the stack, to the Accumulator.", + [PLB] = "PuLl the number of bytes specified, from the stack, to the B register.", + [PLP] = "PuLl the number of bytes specified, from the stack, to the Processor status register.", + [PLX] = "PuLl the number of bytes specified, from the stack, to the X register.", + [PLY] = "PuLl the number of bytes specified, from the stack, to the Y register.", + [RLB] = "Rotate Left accumulator, with B.", + [ROL] = "ROtate Left accumulator, with operand.", + [ROR] = "ROtate Right accumulator, with operand.", + [RRB] = "Rotate Right accumulator, with B.", + [RTI] = "ReTurn from an Interrupt.", + [RTS] = "ReTurn from a Subroutine.", + [SAB] = "Subtract Accumulator, with B, carry if needed.", + [SBC] = "SuBtract accumulator, with operand, Carry if needed", + [SEC] = "SEt the Carry flag.", + [SEI] = "SEt the Interrupt flag.", + [STA] = "STore the value from the Accumulator, in memory.", + [STB] = "STore the value from the B register, in memory.", + [STX] = "STore the value from the X register, in memory.", + [STY] = "STore the value from the Y register, in memory.", + [TAB] = "Transfer the value from the Accumulator, to the B register.", + [TAX] = "Transfer the value from the Accumulator, to the X register.", + [TAY] = "Transfer the value from the Accumulator, to the Y register.", + [TBA] = "Transfer the value from the Y register, to the Accumulator.", + [TSX] = "Transfer the value from the Stack pointer, to the X register.", + [TXA] = "Transfer the value from the X register, to the Accumulator.", + [TXS] = "Transfer the value from the X register, to the Stack pointer.", + [TXY] = "Transfer the value from the X register, to the Y register.", + [TYA] = "Transfer the value from the Y register, to the Accumulator.", + [TYX] = "Transfer the value from the Y register, to the X register.", + [WAI] = "WAIt for an interrupt", + [XAB] = "Bitwise XOR Accumulator, with B.", + [XOR] = "Bitwise XOR Accumulator, with operand." }; static const uint8_t bitsize[4] = { -- cgit v1.2.3-13-gbd6f