summaryrefslogtreecommitdiff
path: root/asmmon.h
diff options
context:
space:
mode:
Diffstat (limited to 'asmmon.h')
-rw-r--r--asmmon.h276
1 files changed, 155 insertions, 121 deletions
diff --git a/asmmon.h b/asmmon.h
index 29924e9..c77cfcf 100644
--- a/asmmon.h
+++ b/asmmon.h
@@ -4,10 +4,12 @@
#define MAX_TOK 0x1000
-typedef struct tok token ;
-typedef struct ln line ;
-typedef struct sym symbol;
-typedef struct fix fixup ;
+typedef struct tok token ;
+typedef struct ln line ;
+typedef struct sym symbol ;
+typedef struct fix fixup ;
+typedef struct inst instruction;
+
struct tok {
token *next; /* Pointer to the next token. */
@@ -56,6 +58,12 @@ struct sym {
uint16_t id;
};
+struct inst {
+ uint16_t am; /* Addressing modes. */
+ uint8_t op; /* Base value used to get the actual opcode. */
+};
+
+
extern char lexeme[];
extern char *string[];
extern char *comment[];
@@ -94,6 +102,7 @@ enum token {
TOK_CHAR,
TOK_IND,
TOK_IMM,
+ TOK_BREG,
TOK_OPCODE,
TOK_RS,
TOK_OF,
@@ -116,6 +125,7 @@ enum pre_token {
PTOK_LBRACK,
PTOK_RBRACK,
PTOK_COMMA,
+ PTOK_B,
PTOK_X,
PTOK_Y,
PTOK_S,
@@ -139,95 +149,143 @@ enum expr {
EXPR_NONE
};
-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, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF2}, /* ARB */
- [ASR] = {0xF1, 0xF6, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF4, 0xFF, 0xFF}, /* ASR */
- [BCC] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x80, 0xFF}, /* BCC */
- [BCS] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x70, 0xFF}, /* BCS */
- [BEQ] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x90, 0xFF}, /* BEQ */
- [BNE] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xA0, 0xFF}, /* BNE */
- [BNG] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x60, 0xFF}, /* BNG */
- [BPO] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x50, 0xFF}, /* BPO */
- [BRA] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xD0, 0xFF}, /* BRA */
- [BRK] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x68}, /* BRK */
- [BVC] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xC0, 0xFF}, /* BVC */
- [BVS] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xB0, 0xFF}, /* BVS */
- [CAB] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xB2}, /* CAB */
- [CLC] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x08}, /* CLC */
- [CLI] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x28}, /* CLI */
- [CLV] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x48}, /* CLV */
- [CMP] = {0xB1, 0xB6, 0xFF, 0xFF, 0x25, 0x7D, 0x7C, 0xB4, 0xFF, 0xFF}, /* CMP */
- [CPB] = {0x2A, 0x2D, 0xFF, 0xFF, 0x55, 0xAD, 0xAC, 0x2C, 0xFF, 0xFF}, /* CPB */
- [CPS] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00}, /* CPS */
- [CPX] = {0x3A, 0x3D, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x3C, 0xFF, 0xFF}, /* CPX */
- [CPY] = {0x4A, 0x4D, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x4C, 0xFF, 0xFF}, /* CPY */
- [DAB] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xA2}, /* DAB */
- [DEB] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xC2}, /* DEB */
- [DEC] = {0xFF, 0x0D, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x0C, 0xFF, 0x0A}, /* DEC */
- [DEX] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x09}, /* DEX */
- [DEY] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x29}, /* DEY */
- [DIV] = {0xA1, 0xA6, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xA4, 0xFF, 0xFF}, /* DIV */
- [INB] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xD2}, /* 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 */
+enum addrmode {
+ AM_IMM = (1 << 0),
+ AM_ZM = (1 << 1),
+ AM_ZMX = (1 << 2),
+ AM_ZMY = (1 << 3),
+ AM_IND = (1 << 4),
+ AM_INDX = (1 << 5),
+ AM_INDY = (1 << 6),
+ AM_ABS = (1 << 7),
+ AM_REL = (1 << 8),
+ AM_BREG = (1 << 9),
+ AM_IMPL = (1 << 10),
+ AM_INDX2 = (1 << 11),
+ AM_ZM2 = (1 << 12)
+};
+
+enum ind {
+ CMP_IND = 0,
+ CMP_IDY = 1,
+ CMP_IDX = 2,
+ CPB_IND = 3,
+ CPB_IDY = 4,
+ CPB_IDX = 5,
+ JMP_IND = 6,
+ JSR_IND = 7,
+ LDA_IND = 8,
+ LDA_IDY = 9,
+ LDB_IND = 10,
+ LDB_IDY = 11,
+ LDX_IND = 12,
+ LDY_IND = 13,
+ STA_IND = 14,
+ STA_IDY = 15,
+ STB_IND = 16,
+ STB_IDY = 17,
+ STX_IND = 18,
+ STY_IND = 19
+};
+
+static const uint8_t ind_ops[20] = {
+ [CMP_IND] = 0x8C,
+ [CMP_IDY] = 0xF9,
+ [CMP_IDX] = 0xAA,
+ [CPB_IND] = 0x7C,
+ [CPB_IDY] = 0xFA,
+ [CPB_IDX] = 0xBA,
+ [JMP_IND] = 0xEC,
+ [JSR_IND] = 0xDC,
+ [LDA_IND] = 0xC4,
+ [LDA_IDY] = 0xD9,
+ [LDB_IND] = 0xE4,
+ [LDB_IDY] = 0xE9,
+ [LDX_IND] = 0xBC,
+ [LDY_IND] = 0xAC,
+ [STA_IND] = 0xD4,
+ [STA_IDY] = 0xCA,
+ [STB_IND] = 0xF4,
+ [STB_IDY] = 0xDA,
+ [STX_IND] = 0xCC,
+ [STY_IND] = 0x9C
+};
+
+static const instruction inst[OPNUM] = {
+ [ADC] = {(AM_IMM|AM_ZM|AM_ABS|AM_BREG), 0x01},
+ [AND] = {(AM_IMM|AM_ZM|AM_ABS|AM_BREG), 0x41},
+ [ASR] = {(AM_IMM|AM_ZM|AM_ABS|AM_BREG), 0x62},
+ [BCC] = {(AM_REL), 0xA0},
+ [BCS] = {(AM_REL), 0x90},
+ [BEQ] = {(AM_REL), 0xB0},
+ [BNE] = {(AM_REL), 0xC0},
+ [BNG] = {(AM_REL), 0x80},
+ [BPO] = {(AM_REL), 0x70},
+ [BRA] = {(AM_REL), 0xF0},
+ [BRK] = {(AM_IMPL), 0x69},
+ [BVC] = {(AM_REL), 0xE0},
+ [BVS] = {(AM_REL), 0xD0},
+ [CLC] = {(AM_IMPL), 0x09},
+ [CLI] = {(AM_IMPL), 0x29},
+ [CLV] = {(AM_IMPL), 0x49},
+ [CMP] = {(AM_IMM|AM_ZM|AM_IND|AM_INDY|AM_ABS|AM_BREG|AM_INDX2), 0x82},
+ [CPB] = {(AM_IMM|AM_ZM|AM_IND|AM_INDY|AM_ABS|AM_INDX2), 0x04},
+ [CPS] = {(AM_IMPL), 0x00},
+ [CPX] = {(AM_IMM|AM_ZM|AM_IND|AM_ABS), 0x24},
+ [CPY] = {(AM_IMM|AM_ZM|AM_IND|AM_ABS), 0x44},
+ [DEB] = {(AM_IMPL), 0x99},
+ [DEC] = {(AM_IMPL|AM_ZM|AM_ABS), 0x84},
+ [DEX] = {(AM_IMPL), 0xB9},
+ [DEY] = {(AM_IMPL), 0x79},
+ [DIV] = {(AM_IMM|AM_ZM|AM_ABS|AM_BREG), 0x42},
+ [INB] = {(AM_IMPL), 0xA9},
+ [INC] = {(AM_IMPL|AM_ZM|AM_ABS), 0xA4},
+ [INX] = {(AM_IMPL), 0xC9},
+ [INY] = {(AM_IMPL), 0x89},
+ [JMP] = {(AM_ABS|AM_IND|AM_ZM2), 0x00},
+ [JSR] = {(AM_ABS|AM_IND|AM_ZM2), 0x20},
+ [LDA] = {(AM_IMM|AM_ZM|AM_ZMX|AM_ZMY|AM_IND|AM_INDX|AM_INDY|AM_ABS), 0xC2},
+ [LDB] = {(AM_IMM|AM_ZM|AM_ZMX|AM_ZMY|AM_IND|AM_INDX|AM_INDY|AM_ABS), 0xE2},
+ [LDX] = {(AM_IMM|AM_ZM|AM_IND|AM_ABS), 0x64},
+ [LDY] = {(AM_IMM|AM_ZM|AM_IND|AM_ABS), 0xA2},
+ [LSL] = {(AM_IMM|AM_ZM|AM_ABS|AM_BREG), 0xA1},
+ [LSR] = {(AM_IMM|AM_ZM|AM_ABS|AM_BREG), 0xC1},
+ [MUL] = {(AM_IMM|AM_ZM|AM_ABS|AM_BREG), 0x22},
+ [NOP] = {(AM_IMPL), 0xEA},
+ [ORA] = {(AM_IMM|AM_ZM|AM_ABS|AM_BREG), 0x61},
+ [PHA] = {(AM_IMPL), 0x8E},
+ [PHB] = {(AM_IMPL), 0xAE},
+ [PHP] = {(AM_IMPL), 0x6E},
+ [PHX] = {(AM_IMPL), 0xEE},
+ [PHY] = {(AM_IMPL), 0xCE},
+ [PLA] = {(AM_IMPL), 0x9E},
+ [PLB] = {(AM_IMPL), 0xBE},
+ [PLP] = {(AM_IMPL), 0x7E},
+ [PLX] = {(AM_IMPL), 0xFE},
+ [PLY] = {(AM_IMPL), 0xDE},
+ [ROL] = {(AM_IMM|AM_ZM|AM_ABS|AM_BREG), 0xE1},
+ [ROR] = {(AM_IMM|AM_ZM|AM_ABS|AM_BREG), 0x02},
+ [RTI] = {(AM_IMPL), 0x60},
+ [RTS] = {(AM_IMPL), 0x50},
+ [SBC] = {(AM_IMM|AM_ZM|AM_ABS|AM_BREG), 0x21},
+ [SEC] = {(AM_IMPL), 0x19},
+ [SEI] = {(AM_IMPL), 0x39},
+ [STA] = {(AM_ZM|AM_ZMX|AM_ZMY|AM_IND|AM_INDX|AM_INDY|AM_ABS), 0x28},
+ [STB] = {(AM_ZM|AM_ZMX|AM_ZMY|AM_IND|AM_INDX|AM_INDY|AM_ABS), 0x48},
+ [STX] = {(AM_ZM|AM_IND|AM_ABS), 0x68},
+ [STY] = {(AM_ZM|AM_IND|AM_ABS), 0x08},
+ [TAB] = {(AM_IMPL), 0x0A},
+ [TAX] = {(AM_IMPL), 0x4A},
+ [TAY] = {(AM_IMPL), 0x2A},
+ [TBA] = {(AM_IMPL), 0x1A},
+ [TSX] = {(AM_IMPL), 0x8A},
+ [TXA] = {(AM_IMPL), 0x5A},
+ [TXS] = {(AM_IMPL|AM_IMM), 0x9A},
+ [TXY] = {(AM_IMPL), 0x7A},
+ [TYA] = {(AM_IMPL), 0x3A},
+ [TYX] = {(AM_IMPL), 0x6A},
+ [WAI] = {(AM_IMPL), 0x59},
+ [XOR] = {(AM_IMM|AM_ZM|AM_ABS|AM_BREG), 0x81}
};
static const char *dir_t[7] = {
@@ -247,7 +305,7 @@ static const char *rs_t[4] = {
[3] = ".q"
};
-static const char *lex_tok[18] = {
+static const char *lex_tok[19] = {
[TOK_DIR ] = "TOK_DIR",
[TOK_LOCAL ] = "TOK_LOCAL",
[TOK_LABEL ] = "TOK_LABEL",
@@ -258,6 +316,7 @@ static const char *lex_tok[18] = {
[TOK_CHAR ] = "TOK_CHAR",
[TOK_IND ] = "TOK_IND",
[TOK_IMM ] = "TOK_IMM",
+ [TOK_BREG ] = "TOK_BREG",
[TOK_OPCODE ] = "TOK_OPCODE",
[TOK_RS ] = "TOK_RS",
[TOK_OF ] = "TOK_OF",
@@ -268,7 +327,7 @@ static const char *lex_tok[18] = {
[TOK_INCLUDE] = "TOK_INCLUDE"
};
-static const char *adrmode[10] = {
+static const char *adrmode[11] = {
[IMM ] = "IMM",
[ZM ] = "ZM",
[ZMX ] = "ZMX",
@@ -278,15 +337,13 @@ static const char *adrmode[10] = {
[INDY] = "INDY",
[ABS ] = "ABS",
[REL ] = "REL",
+ [BREG] = "BREG",
[IMPL] = "IMPL"
};
static const char *mne[OPNUM] = {
- [AAB] = "AAB",
- [ABA] = "ABA",
[ADC] = "ADC",
[AND] = "AND",
- [ARB] = "ARB",
[ASR] = "ASR",
[BCC] = "BCC",
[BCS] = "BCS",
@@ -298,7 +355,6 @@ static const char *mne[OPNUM] = {
[BRK] = "BRK",
[BVC] = "BVC",
[BVS] = "BVS",
- [CAB] = "CAB",
[CLC] = "CLC",
[CLI] = "CLI",
[CLV] = "CLV",
@@ -307,7 +363,6 @@ static const char *mne[OPNUM] = {
[CPS] = "CPS",
[CPX] = "CPX",
[CPY] = "CPY",
- [DAB] = "DAB",
[DEB] = "DEB",
[DEC] = "DEC",
[DEX] = "DEX",
@@ -323,14 +378,10 @@ static const char *mne[OPNUM] = {
[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",
@@ -342,13 +393,10 @@ static const char *mne[OPNUM] = {
[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",
@@ -367,16 +415,12 @@ static const char *mne[OPNUM] = {
[TYA] = "TYA",
[TYX] = "TYX",
[WAI] = "WAI",
- [XAB] = "XAB",
[XOR] = "XOR"
};
static const char *instdesc[OPNUM] = {
- [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.",
@@ -388,7 +432,6 @@ static const char *instdesc[OPNUM] = {
[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.",
@@ -397,7 +440,6 @@ static const char *instdesc[OPNUM] = {
[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.",
@@ -413,14 +455,10 @@ static const char *instdesc[OPNUM] = {
[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.",
@@ -432,13 +470,10 @@ static const char *instdesc[OPNUM] = {
[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.",
@@ -457,7 +492,6 @@ static const char *instdesc[OPNUM] = {
[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."
};