24 opcode_table_[0x01] = {
"ORA", AM::kDirectPageIndexedIndirectX, 2};
30 opcode_table_[0x07] = {
"ORA", AM::kDirectPageIndirectLong, 2};
41 opcode_table_[0x10] = {
"BPL", AM::kProgramCounterRelative, 2};
42 opcode_table_[0x11] = {
"ORA", AM::kDirectPageIndirectIndexedY, 2};
44 opcode_table_[0x13] = {
"ORA", AM::kStackRelativeIndirectIndexedY, 2};
48 opcode_table_[0x17] = {
"ORA", AM::kDirectPageIndirectLongIndexedY, 2};
60 opcode_table_[0x21] = {
"AND", AM::kDirectPageIndexedIndirectX, 2};
66 opcode_table_[0x27] = {
"AND", AM::kDirectPageIndirectLong, 2};
77 opcode_table_[0x30] = {
"BMI", AM::kProgramCounterRelative, 2};
78 opcode_table_[0x31] = {
"AND", AM::kDirectPageIndirectIndexedY, 2};
80 opcode_table_[0x33] = {
"AND", AM::kStackRelativeIndirectIndexedY, 2};
84 opcode_table_[0x37] = {
"AND", AM::kDirectPageIndirectLongIndexedY, 2};
96 opcode_table_[0x41] = {
"EOR", AM::kDirectPageIndexedIndirectX, 2};
102 opcode_table_[0x47] = {
"EOR", AM::kDirectPageIndirectLong, 2};
113 opcode_table_[0x50] = {
"BVC", AM::kProgramCounterRelative, 2};
114 opcode_table_[0x51] = {
"EOR", AM::kDirectPageIndirectIndexedY, 2};
116 opcode_table_[0x53] = {
"EOR", AM::kStackRelativeIndirectIndexedY, 2};
120 opcode_table_[0x57] = {
"EOR", AM::kDirectPageIndirectLongIndexedY, 2};
132 opcode_table_[0x61] = {
"ADC", AM::kDirectPageIndexedIndirectX, 2};
133 opcode_table_[0x62] = {
"PER", AM::kProgramCounterRelativeLong, 3};
138 opcode_table_[0x67] = {
"ADC", AM::kDirectPageIndirectLong, 2};
149 opcode_table_[0x70] = {
"BVS", AM::kProgramCounterRelative, 2};
150 opcode_table_[0x71] = {
"ADC", AM::kDirectPageIndirectIndexedY, 2};
152 opcode_table_[0x73] = {
"ADC", AM::kStackRelativeIndirectIndexedY, 2};
156 opcode_table_[0x77] = {
"ADC", AM::kDirectPageIndirectLongIndexedY, 2};
161 opcode_table_[0x7C] = {
"JMP", AM::kAbsoluteIndexedIndirect, 3};
167 opcode_table_[0x80] = {
"BRA", AM::kProgramCounterRelative, 2};
168 opcode_table_[0x81] = {
"STA", AM::kDirectPageIndexedIndirectX, 2};
169 opcode_table_[0x82] = {
"BRL", AM::kProgramCounterRelativeLong, 3};
174 opcode_table_[0x87] = {
"STA", AM::kDirectPageIndirectLong, 2};
185 opcode_table_[0x90] = {
"BCC", AM::kProgramCounterRelative, 2};
186 opcode_table_[0x91] = {
"STA", AM::kDirectPageIndirectIndexedY, 2};
188 opcode_table_[0x93] = {
"STA", AM::kStackRelativeIndirectIndexedY, 2};
192 opcode_table_[0x97] = {
"STA", AM::kDirectPageIndirectLongIndexedY, 2};
204 opcode_table_[0xA1] = {
"LDA", AM::kDirectPageIndexedIndirectX, 2};
210 opcode_table_[0xA7] = {
"LDA", AM::kDirectPageIndirectLong, 2};
221 opcode_table_[0xB0] = {
"BCS", AM::kProgramCounterRelative, 2};
222 opcode_table_[0xB1] = {
"LDA", AM::kDirectPageIndirectIndexedY, 2};
224 opcode_table_[0xB3] = {
"LDA", AM::kStackRelativeIndirectIndexedY, 2};
228 opcode_table_[0xB7] = {
"LDA", AM::kDirectPageIndirectLongIndexedY, 2};
240 opcode_table_[0xC1] = {
"CMP", AM::kDirectPageIndexedIndirectX, 2};
246 opcode_table_[0xC7] = {
"CMP", AM::kDirectPageIndirectLong, 2};
257 opcode_table_[0xD0] = {
"BNE", AM::kProgramCounterRelative, 2};
258 opcode_table_[0xD1] = {
"CMP", AM::kDirectPageIndirectIndexedY, 2};
260 opcode_table_[0xD3] = {
"CMP", AM::kStackRelativeIndirectIndexedY, 2};
264 opcode_table_[0xD7] = {
"CMP", AM::kDirectPageIndirectLongIndexedY, 2};
276 opcode_table_[0xE1] = {
"SBC", AM::kDirectPageIndexedIndirectX, 2};
282 opcode_table_[0xE7] = {
"SBC", AM::kDirectPageIndirectLong, 2};
293 opcode_table_[0xF0] = {
"BEQ", AM::kProgramCounterRelative, 2};
294 opcode_table_[0xF1] = {
"SBC", AM::kDirectPageIndirectIndexedY, 2};
296 opcode_table_[0xF3] = {
"SBC", AM::kStackRelativeIndirectIndexedY, 2};
300 opcode_table_[0xF7] = {
"SBC", AM::kDirectPageIndirectLongIndexedY, 2};
305 opcode_table_[0xFC] = {
"JSR", AM::kAbsoluteIndexedIndirect, 3};
424 const std::vector<uint8_t>& ops,
425 uint32_t address,
bool m_flag,
431 case AM::kAccumulator:
434 case AM::kImmediate8:
435 if (ops.size() >= 1) {
436 return absl::StrFormat(
"#$%02X", ops[0]);
440 case AM::kImmediate16:
441 if (ops.size() >= 2) {
442 return absl::StrFormat(
"#$%04X", ops[0] | (ops[1] << 8));
446 case AM::kImmediateM:
447 if (m_flag && ops.size() >= 1) {
448 return absl::StrFormat(
"#$%02X", ops[0]);
449 }
else if (!m_flag && ops.size() >= 2) {
450 return absl::StrFormat(
"#$%04X", ops[0] | (ops[1] << 8));
454 case AM::kImmediateX:
455 if (x_flag && ops.size() >= 1) {
456 return absl::StrFormat(
"#$%02X", ops[0]);
457 }
else if (!x_flag && ops.size() >= 2) {
458 return absl::StrFormat(
"#$%04X", ops[0] | (ops[1] << 8));
462 case AM::kDirectPage:
463 if (ops.size() >= 1) {
464 return absl::StrFormat(
"$%02X", ops[0]);
468 case AM::kDirectPageIndexedX:
469 if (ops.size() >= 1) {
470 return absl::StrFormat(
"$%02X,X", ops[0]);
474 case AM::kDirectPageIndexedY:
475 if (ops.size() >= 1) {
476 return absl::StrFormat(
"$%02X,Y", ops[0]);
480 case AM::kDirectPageIndirect:
481 if (ops.size() >= 1) {
482 return absl::StrFormat(
"($%02X)", ops[0]);
486 case AM::kDirectPageIndirectLong:
487 if (ops.size() >= 1) {
488 return absl::StrFormat(
"[$%02X]", ops[0]);
492 case AM::kDirectPageIndexedIndirectX:
493 if (ops.size() >= 1) {
494 return absl::StrFormat(
"($%02X,X)", ops[0]);
498 case AM::kDirectPageIndirectIndexedY:
499 if (ops.size() >= 1) {
500 return absl::StrFormat(
"($%02X),Y", ops[0]);
504 case AM::kDirectPageIndirectLongIndexedY:
505 if (ops.size() >= 1) {
506 return absl::StrFormat(
"[$%02X],Y", ops[0]);
511 if (ops.size() >= 2) {
512 uint16_t addr = ops[0] | (ops[1] << 8);
516 if (!symbol.empty()) {
520 return absl::StrFormat(
"$%04X", addr);
524 case AM::kAbsoluteIndexedX:
525 if (ops.size() >= 2) {
526 return absl::StrFormat(
"$%04X,X", ops[0] | (ops[1] << 8));
530 case AM::kAbsoluteIndexedY:
531 if (ops.size() >= 2) {
532 return absl::StrFormat(
"$%04X,Y", ops[0] | (ops[1] << 8));
536 case AM::kAbsoluteLong:
537 if (ops.size() >= 3) {
538 uint32_t addr = ops[0] | (ops[1] << 8) | (ops[2] << 16);
541 if (!symbol.empty()) {
545 return absl::StrFormat(
"$%06X", addr);
549 case AM::kAbsoluteLongIndexedX:
550 if (ops.size() >= 3) {
551 return absl::StrFormat(
"$%06X,X",
552 ops[0] | (ops[1] << 8) | (ops[2] << 16));
556 case AM::kAbsoluteIndirect:
557 if (ops.size() >= 2) {
558 return absl::StrFormat(
"($%04X)", ops[0] | (ops[1] << 8));
562 case AM::kAbsoluteIndirectLong:
563 if (ops.size() >= 2) {
564 return absl::StrFormat(
"[$%04X]", ops[0] | (ops[1] << 8));
568 case AM::kAbsoluteIndexedIndirect:
569 if (ops.size() >= 2) {
570 return absl::StrFormat(
"($%04X,X)", ops[0] | (ops[1] << 8));
574 case AM::kProgramCounterRelative:
575 if (ops.size() >= 1) {
577 int8_t offset =
static_cast<int8_t
>(ops[0]);
578 uint32_t target = (address + 2 + offset) & 0xFFFF;
580 target |= (address & 0xFF0000);
583 if (!symbol.empty()) {
587 return absl::StrFormat(
"$%04X", target & 0xFFFF);
591 case AM::kProgramCounterRelativeLong:
592 if (ops.size() >= 2) {
594 int16_t offset =
static_cast<int16_t
>(ops[0] | (ops[1] << 8));
595 uint32_t target = (address + 3 + offset) & 0xFFFF;
596 target |= (address & 0xFF0000);
599 if (!symbol.empty()) {
603 return absl::StrFormat(
"$%04X", target & 0xFFFF);
607 case AM::kStackRelative:
608 if (ops.size() >= 1) {
609 return absl::StrFormat(
"$%02X,S", ops[0]);
613 case AM::kStackRelativeIndirectIndexedY:
614 if (ops.size() >= 1) {
615 return absl::StrFormat(
"($%02X,S),Y", ops[0]);
620 if (ops.size() >= 2) {
622 return absl::StrFormat(
"$%02X,$%02X", ops[0], ops[1]);