1 #include "optable.h" 2 #include "dis.h" 3 4 /* A bit modified to include Break Points : "BP?" at $?B */ 5 /* Beware, the name does matter, invalid opcodes got "???" as name or are BP */ 6 7 operation_debug optable_debug[256] = { 8 {AM_IMPL, "BRK", &follow_straight}, /* $00 */ 9 {AM_ZPINDX, "ORA", &follow_straight}, /* $01 */ 10 {AM_IMPL, "SXY", &follow_straight}, /* $02 */ 11 {AM_IMMED, "ST0", &follow_straight}, /* $03 */ 12 {AM_ZP, "TSB", &follow_straight}, /* $04 */ 13 {AM_ZP, "ORA", &follow_straight}, /* $05 */ 14 {AM_ZP, "ASL", &follow_straight}, /* $06 */ 15 {AM_ZP, "RMB0", &follow_straight}, /* $07 */ 16 {AM_IMPL, "PHP", &follow_straight}, /* $08 */ 17 {AM_IMMED, "ORA", &follow_straight}, /* $09 */ 18 {AM_IMPL, "ASL", &follow_straight}, /* $0A */ 19 {AM_IMPL, "BP0", &follow_straight}, /* $0B */ 20 {AM_ABS, "TSB", &follow_straight}, /* $0C */ 21 {AM_ABS, "ORA", &follow_straight}, /* $0D */ 22 {AM_ABS, "ASL", &follow_straight}, /* $0E */ 23 {AM_PSREL, "BBR0", &follow_BBRi}, /* $0F */ 24 {AM_REL, "BPL", &follow_BPL}, /* $10 */ 25 {AM_ZPINDY, "ORA", &follow_straight}, /* $11 */ 26 {AM_ZPIND, "ORA", &follow_straight}, /* $12 */ 27 {AM_IMMED, "ST1", &follow_straight}, /* $13 */ 28 {AM_ZP, "TRB", &follow_straight}, /* $14 */ 29 {AM_ZPX, "ORA", &follow_straight}, /* $15 */ 30 {AM_ZPX, "ASL", &follow_straight}, /* $16 */ 31 {AM_ZP, "RMB1", &follow_straight}, /* $17 */ 32 {AM_IMPL, "CLC", &follow_straight}, /* $18 */ 33 {AM_ABSY, "ORA", &follow_straight}, /* $19 */ 34 {AM_IMPL, "INC", &follow_straight}, /* $1A */ 35 {AM_IMPL, "BP1", &follow_straight}, /* $1B */ 36 {AM_ABS, "TRB", &follow_straight}, /* $1C */ 37 {AM_ABSX, "ORA", &follow_straight}, /* $1D */ 38 {AM_ABSX, "ASL", &follow_straight}, /* $1E */ 39 {AM_PSREL, "BBR1", &follow_BBRi}, /* $1F */ 40 {AM_ABS, "JSR", &follow_JSR}, /* $20 */ 41 {AM_ZPINDX, "AND", &follow_straight}, /* $21 */ 42 {AM_IMPL, "SAX", &follow_straight}, /* $22 */ 43 {AM_IMMED, "ST2", &follow_straight}, /* $23 */ 44 {AM_ZP, "BIT", &follow_straight}, /* $24 */ 45 {AM_ZP, "AND", &follow_straight}, /* $25 */ 46 {AM_ZP, "ROL", &follow_straight}, /* $26 */ 47 {AM_ZP, "RMB2", &follow_straight}, /* $27 */ 48 {AM_IMPL, "PLP", &follow_straight}, /* $28 */ 49 {AM_IMMED, "AND", &follow_straight}, /* $29 */ 50 {AM_IMPL, "ROL", &follow_straight}, /* $2A */ 51 {AM_IMPL, "BP2", &follow_straight}, /* $2B */ 52 {AM_ABS, "BIT", &follow_straight}, /* $2C */ 53 {AM_ABS, "AND", &follow_straight}, /* $2D */ 54 {AM_ABS, "ROL", &follow_straight}, /* $2E */ 55 {AM_PSREL, "BBR2", &follow_BBRi}, /* $2F */ 56 {AM_REL, "BMI", &follow_BMI}, /* $30 */ 57 {AM_ZPINDY, "AND", &follow_straight}, /* $31 */ 58 {AM_ZPIND, "AND", &follow_straight}, /* $32 */ 59 {AM_IMPL, "???", &follow_straight}, /* $33 */ 60 {AM_ZPX, "BIT", &follow_straight}, /* $34 */ 61 {AM_ZPX, "AND", &follow_straight}, /* $35 */ 62 {AM_ZPX, "ROL", &follow_straight}, /* $36 */ 63 {AM_ZP, "RMB3", &follow_straight}, /* $37 */ 64 {AM_IMPL, "SEC", &follow_straight}, /* $38 */ 65 {AM_ABSY, "AND", &follow_straight}, /* $39 */ 66 {AM_IMPL, "DEC", &follow_straight}, /* $3A */ 67 {AM_IMPL, "BP3", &follow_straight}, /* $3B */ 68 {AM_ABSX, "BIT", &follow_straight}, /* $3C */ 69 {AM_ABSX, "AND", &follow_straight}, /* $3D */ 70 {AM_ABSX, "ROL", &follow_straight}, /* $3E */ 71 {AM_PSREL, "BBR3", &follow_BBRi}, /* $3F */ 72 {AM_IMPL, "RTI", &follow_RTI}, /* $40 */ 73 {AM_ZPINDX, "EOR", &follow_straight}, /* $41 */ 74 {AM_IMPL, "SAY", &follow_straight}, /* $42 */ 75 {AM_IMMED, "TMA", &follow_straight}, /* $43 */ 76 {AM_REL, "BSR", &follow_BSR}, /* $44 */ 77 {AM_ZP, "EOR", &follow_straight}, /* $45 */ 78 {AM_ZP, "LSR", &follow_straight}, /* $46 */ 79 {AM_ZP, "RMB4", &follow_straight}, /* $47 */ 80 {AM_IMPL, "PHA", &follow_straight}, /* $48 */ 81 {AM_IMMED, "EOR", &follow_straight}, /* $49 */ 82 {AM_IMPL, "LSR", &follow_straight}, /* $4A */ 83 {AM_IMPL, "BP4", &follow_straight}, /* $4B */ 84 {AM_ABS, "JMP", &follow_JMPabs}, /* $4C */ 85 {AM_ABS, "EOR", &follow_straight}, /* $4D */ 86 {AM_ABS, "LSR", &follow_straight}, /* $4E */ 87 {AM_PSREL, "BBR4", &follow_BBRi}, /* $4F */ 88 {AM_REL, "BVC", &follow_BVC}, /* $50 */ 89 {AM_ZPINDY, "EOR", &follow_straight}, /* $51 */ 90 {AM_ZPIND, "EOR", &follow_straight}, /* $52 */ 91 {AM_IMMED, "TAM", &follow_straight}, /* $53 */ 92 {AM_IMPL, "???", &follow_straight}, /* $54 */ 93 {AM_ZPX, "EOR", &follow_straight}, /* $55 */ 94 {AM_ZPX, "LSR", &follow_straight}, /* $56 */ 95 {AM_ZP, "RMB5", &follow_straight}, /* $57 */ 96 {AM_IMPL, "CLI", &follow_straight}, /* $58 */ 97 {AM_ABSY, "EOR", &follow_straight}, /* $59 */ 98 {AM_IMPL, "PHY", &follow_straight}, /* $5A */ 99 {AM_IMPL, "BP5", &follow_straight}, /* $5B */ 100 {AM_IMPL, "???", &follow_straight}, /* $5C */ 101 {AM_ABSX, "EOR", &follow_straight}, /* $5D */ 102 {AM_ABSX, "LSR", &follow_straight}, /* $5E */ 103 {AM_PSREL, "BBR5", &follow_BBRi}, /* $5F */ 104 {AM_IMPL, "RTS", &follow_RTS}, /* $60 */ 105 {AM_ZPINDX, "ADC", &follow_straight}, /* $61 */ 106 {AM_IMPL, "CLA", &follow_straight}, /* $62 */ 107 {AM_IMPL, "???", &follow_straight}, /* $63 */ 108 {AM_ZP, "STZ", &follow_straight}, /* $64 */ 109 {AM_ZP, "ADC", &follow_straight}, /* $65 */ 110 {AM_ZP, "ROR", &follow_straight}, /* $66 */ 111 {AM_ZP, "RMB6", &follow_straight}, /* $67 */ 112 {AM_IMPL, "PLA", &follow_straight}, /* $68 */ 113 {AM_IMMED, "ADC", &follow_straight}, /* $69 */ 114 {AM_IMPL, "ROR", &follow_straight}, /* $6A */ 115 {AM_IMPL, "BP6", &follow_straight}, /* $6B */ 116 {AM_ABSIND, "JMP", &follow_JMPindir}, /* $6C */ 117 {AM_ABS, "ADC", &follow_straight}, /* $6D */ 118 {AM_ABS, "ROR", &follow_straight}, /* $6E */ 119 {AM_PSREL, "BBR6", &follow_BBRi}, /* $6F */ 120 {AM_REL, "BVS", &follow_BVS}, /* $70 */ 121 {AM_ZPINDY, "ADC", &follow_straight}, /* $71 */ 122 {AM_ZPIND, "ADC", &follow_straight}, /* $72 */ 123 {AM_XFER, "TII", &follow_straight}, /* $73 */ 124 {AM_ZPX, "STZ", &follow_straight}, /* $74 */ 125 {AM_ZPX, "ADC", &follow_straight}, /* $75 */ 126 {AM_ZPX, "ROR", &follow_straight}, /* $76 */ 127 {AM_ZP, "RMB7", &follow_straight}, /* $77 */ 128 {AM_IMPL, "SEI", &follow_straight}, /* $78 */ 129 {AM_ABSY, "ADC", &follow_straight}, /* $79 */ 130 {AM_IMPL, "PLY", &follow_straight}, /* $7A */ 131 {AM_IMPL, "BP7", &follow_straight}, /* $7B */ 132 {AM_ABSINDX, "JMP", &follow_JMPindirX}, /* $7C */ 133 {AM_ABSX, "ADC", &follow_straight}, /* $7D */ 134 {AM_ABSX, "ROR", &follow_straight}, /* $7E */ 135 {AM_PSREL, "BBR7", &follow_BBRi}, /* $7F */ 136 {AM_REL, "BRA", &follow_BRA}, /* $80 */ 137 {AM_ZPINDX, "STA", &follow_straight}, /* $81 */ 138 {AM_IMPL, "CLX", &follow_straight}, /* $82 */ 139 {AM_TST_ZP, "TST", &follow_straight}, /* $83 */ 140 {AM_ZP, "STY", &follow_straight}, /* $84 */ 141 {AM_ZP, "STA", &follow_straight}, /* $85 */ 142 {AM_ZP, "STX", &follow_straight}, /* $86 */ 143 {AM_ZP, "SMB0", &follow_straight}, /* $87 */ 144 {AM_IMPL, "DEY", &follow_straight}, /* $88 */ 145 {AM_IMMED, "BIT", &follow_straight}, /* $89 */ 146 {AM_IMPL, "TXA", &follow_straight}, /* $8A */ 147 {AM_IMPL, "BP8", &follow_straight}, /* $8B */ 148 {AM_ABS, "STY", &follow_straight}, /* $8C */ 149 {AM_ABS, "STA", &follow_straight}, /* $8D */ 150 {AM_ABS, "STX", &follow_straight}, /* $8E */ 151 {AM_PSREL, "BBS0", &follow_BBSi}, /* $8F */ 152 {AM_REL, "BCC", &follow_BCC}, /* $90 */ 153 {AM_ZPINDY, "STA", &follow_straight}, /* $91 */ 154 {AM_ZPIND, "STA", &follow_straight}, /* $92 */ 155 {AM_TST_ABS, "TST", &follow_straight}, /* $93 */ 156 {AM_ZPX, "STY", &follow_straight}, /* $94 */ 157 {AM_ZPX, "STA", &follow_straight}, /* $95 */ 158 {AM_ZPY, "STX", &follow_straight}, /* $96 */ 159 {AM_ZP, "SMB1", &follow_straight}, /* $97 */ 160 {AM_IMPL, "TYA", &follow_straight}, /* $98 */ 161 {AM_ABSY, "STA", &follow_straight}, /* $99 */ 162 {AM_IMPL, "TXS", &follow_straight}, /* $9A */ 163 {AM_IMPL, "BP9", &follow_straight}, /* $9B */ 164 {AM_ABS, "STZ", &follow_straight}, /* $9C */ 165 {AM_ABSX, "STA", &follow_straight}, /* $9D */ 166 {AM_ABSX, "STZ", &follow_straight}, /* $9E */ 167 {AM_PSREL, "BBS1", &follow_BBSi}, /* $9F */ 168 {AM_IMMED, "LDY", &follow_straight}, /* $A0 */ 169 {AM_ZPINDX, "LDA", &follow_straight}, /* $A1 */ 170 {AM_IMMED, "LDX", &follow_straight}, /* $A2 */ 171 {AM_TST_ZPX, "TST", &follow_straight}, /* $A3 */ 172 {AM_ZP, "LDY", &follow_straight}, /* $A4 */ 173 {AM_ZP, "LDA", &follow_straight}, /* $A5 */ 174 {AM_ZP, "LDX", &follow_straight}, /* $A6 */ 175 {AM_ZP, "SMB2", &follow_straight}, /* $A7 */ 176 {AM_IMPL, "TAY", &follow_straight}, /* $A8 */ 177 {AM_IMMED, "LDA", &follow_straight}, /* $A9 */ 178 {AM_IMPL, "TAX", &follow_straight}, /* $AA */ 179 {AM_IMPL, "BPA", &follow_straight}, /* $AB */ 180 {AM_ABS, "LDY", &follow_straight}, /* $AC */ 181 {AM_ABS, "LDA", &follow_straight}, /* $AD */ 182 {AM_ABS, "LDX", &follow_straight}, /* $AE */ 183 {AM_PSREL, "BBS2", &follow_BBSi}, /* $AF */ 184 {AM_REL, "BCS", &follow_BCS}, /* $B0 */ 185 {AM_ZPINDY, "LDA", &follow_straight}, /* $B1 */ 186 {AM_ZPIND, "LDA", &follow_straight}, /* $B2 */ 187 {AM_TST_ABSX, "TST", &follow_straight}, /* $B3 */ 188 {AM_ZPX, "LDY", &follow_straight}, /* $B4 */ 189 {AM_ZPX, "LDA", &follow_straight}, /* $B5 */ 190 {AM_ZPY, "LDX", &follow_straight}, /* $B6 */ 191 {AM_ZP, "SMB3", &follow_straight}, /* $B7 */ 192 {AM_IMPL, "CLV", &follow_straight}, /* $B8 */ 193 {AM_ABSY, "LDA", &follow_straight}, /* $B9 */ 194 {AM_IMPL, "TSX", &follow_straight}, /* $BA */ 195 {AM_IMPL, "BPB", &follow_straight}, /* $BB */ 196 {AM_ABSX, "LDY", &follow_straight}, /* $BC */ 197 {AM_ABSX, "LDA", &follow_straight}, /* $BD */ 198 {AM_ABSY, "LDX", &follow_straight}, /* $BE */ 199 {AM_PSREL, "BBS3", &follow_BBSi}, /* $BF */ 200 {AM_IMMED, "CPY", &follow_straight}, /* $C0 */ 201 {AM_ZPINDX, "CMP", &follow_straight}, /* $C1 */ 202 {AM_IMPL, "CLY", &follow_straight}, /* $C2 */ 203 {AM_XFER, "TDD", &follow_straight}, /* $C3 */ 204 {AM_ZP, "CPY", &follow_straight}, /* $C4 */ 205 {AM_ZP, "CMP", &follow_straight}, /* $C5 */ 206 {AM_ZP, "DEC", &follow_straight}, /* $C6 */ 207 {AM_ZP, "SMB4", &follow_straight}, /* $C7 */ 208 {AM_IMPL, "INY", &follow_straight}, /* $C8 */ 209 {AM_IMMED, "CMP", &follow_straight}, /* $C9 */ 210 {AM_IMPL, "DEX", &follow_straight}, /* $CA */ 211 {AM_IMPL, "BPC", &follow_straight}, /* $CB */ 212 {AM_ABS, "CPY", &follow_straight}, /* $CC */ 213 {AM_ABS, "CMP", &follow_straight}, /* $CD */ 214 {AM_ABS, "DEC", &follow_straight}, /* $CE */ 215 {AM_PSREL, "BBS4", &follow_BBSi}, /* $CF */ 216 {AM_REL, "BNE", &follow_BNE}, /* $D0 */ 217 {AM_ZPINDY, "CMP", &follow_straight}, /* $D1 */ 218 {AM_ZPIND, "CMP", &follow_straight}, /* $D2 */ 219 {AM_XFER, "TIN", &follow_straight}, /* $D3 */ 220 {AM_IMPL, "CSH", &follow_straight}, /* $D4 */ 221 {AM_ZPX, "CMP", &follow_straight}, /* $D5 */ 222 {AM_ZPX, "DEC", &follow_straight}, /* $D6 */ 223 {AM_ZP, "SMB5", &follow_straight}, /* $D7 */ 224 {AM_IMPL, "CLD", &follow_straight}, /* $D8 */ 225 {AM_ABSY, "CMP", &follow_straight}, /* $D9 */ 226 {AM_IMPL, "PHX", &follow_straight}, /* $DA */ 227 {AM_IMPL, "BPD", &follow_straight}, /* $DB */ 228 {AM_IMPL, "???", &follow_straight}, /* $DC */ 229 {AM_ABSX, "CMP", &follow_straight}, /* $DD */ 230 {AM_ABSX, "DEC", &follow_straight}, /* $DE */ 231 {AM_PSREL, "BBS5", &follow_BBSi}, /* $DF */ 232 {AM_IMMED, "CPX", &follow_straight}, /* $E0 */ 233 {AM_ZPINDX, "SBC", &follow_straight}, /* $E1 */ 234 {AM_IMPL, "???", &follow_straight}, /* $E2 */ 235 {AM_XFER, "TIA", &follow_straight}, /* $E3 */ 236 {AM_ZP, "CPX", &follow_straight}, /* $E4 */ 237 {AM_ZP, "SBC", &follow_straight}, /* $E5 */ 238 {AM_ZP, "INC", &follow_straight}, /* $E6 */ 239 {AM_ZP, "SMB6", &follow_straight}, /* $E7 */ 240 {AM_IMPL, "INX", &follow_straight}, /* $E8 */ 241 {AM_IMMED, "SBC", &follow_straight}, /* $E9 */ 242 {AM_IMPL, "NOP", &follow_straight}, /* $EA */ 243 {AM_IMPL, "BPE", &follow_straight}, /* $EB */ 244 {AM_ABS, "CPX", &follow_straight}, /* $EC */ 245 {AM_ABS, "SBC", &follow_straight}, /* $ED */ 246 {AM_ABS, "INC", &follow_straight}, /* $EE */ 247 {AM_PSREL, "BBS6", &follow_BBSi}, /* $EF */ 248 {AM_REL, "BEQ", &follow_BEQ}, /* $F0 */ 249 {AM_ZPINDY, "SBC", &follow_straight}, /* $F1 */ 250 {AM_ZPIND, "SBC", &follow_straight}, /* $F2 */ 251 {AM_XFER, "TAI", &follow_straight}, /* $F3 */ 252 {AM_IMPL, "SET", &follow_straight}, /* $F4 */ 253 {AM_ZPX, "SBC", &follow_straight}, /* $F5 */ 254 {AM_ZPX, "INC", &follow_straight}, /* $F6 */ 255 {AM_ZP, "SMB7", &follow_straight}, /* $F7 */ 256 {AM_IMPL, "SED", &follow_straight}, /* $F8 */ 257 {AM_ABSY, "SBC", &follow_straight}, /* $F9 */ 258 {AM_IMPL, "PLX", &follow_straight}, /* $FA */ 259 {AM_IMPL, "BPF", &follow_straight}, /* $FB */ 260 {AM_IMPL, "CD EMU", &follow_RTS}, /* $FC */ 261 {AM_ABSX, "SBC", &follow_straight}, /* $FD */ 262 {AM_ABSX, "INC", &follow_straight}, /* $FE */ 263 {AM_PSREL, "BBS7", &follow_BBSi} /* $FF */ 264 }; 265 266 267 /* number of bytes per instruction in each addressing mode */ 268 269 mode_struct_debug addr_info_debug[MAX_MODES] = { 270 {1, &(implicit)}, /* implicit */ 271 {2, &(immed)}, /* immediate */ 272 {2, &(relative)}, /* relative */ 273 {2, &(ind_zp)}, /* zero page */ 274 {2, &(ind_zpx)}, /* zero page, x */ 275 {2, &(ind_zpy)}, /* zero page, y */ 276 {2, &(ind_zpind)}, /* zero page indirect */ 277 {2, &(ind_zpix)}, /* zero page indirect, x */ 278 {2, &(ind_zpiy)}, /* zero page indirect, y */ 279 {3, &(absol)}, /* absolute */ 280 {3, &(absx)}, /* absolute, x */ 281 {3, &(absy)}, /* absolute, y */ 282 {3, &(absind)}, /* absolute indirect */ 283 {3, &(absindx)}, /* absolute indirect */ 284 {3, &(pseudorel)}, /* pseudo-relative */ 285 {3, &(tst_zp)}, /* special 'TST' addressing mode */ 286 {4, &(tst_abs)}, /* special 'TST' addressing mode */ 287 {3, &(tst_zpx)}, /* special 'TST' addressing mode */ 288 {4, &(tst_absx)}, /* special 'TST' addressing mode */ 289 {7, &(xfer)} /* special 7-byte transfer addressing mode */ 290 }; 291