21 opcode_table_[0x01] = {
"ORA", AM::kDirectPageIndexedIndirectX, 2};
27 opcode_table_[0x07] = {
"ORA", AM::kDirectPageIndirectLong, 2};
38 opcode_table_[0x10] = {
"BPL", AM::kProgramCounterRelative, 2};
39 opcode_table_[0x11] = {
"ORA", AM::kDirectPageIndirectIndexedY, 2};
41 opcode_table_[0x13] = {
"ORA", AM::kStackRelativeIndirectIndexedY, 2};
45 opcode_table_[0x17] = {
"ORA", AM::kDirectPageIndirectLongIndexedY, 2};
57 opcode_table_[0x21] = {
"AND", AM::kDirectPageIndexedIndirectX, 2};
63 opcode_table_[0x27] = {
"AND", AM::kDirectPageIndirectLong, 2};
74 opcode_table_[0x30] = {
"BMI", AM::kProgramCounterRelative, 2};
75 opcode_table_[0x31] = {
"AND", AM::kDirectPageIndirectIndexedY, 2};
77 opcode_table_[0x33] = {
"AND", AM::kStackRelativeIndirectIndexedY, 2};
81 opcode_table_[0x37] = {
"AND", AM::kDirectPageIndirectLongIndexedY, 2};
93 opcode_table_[0x41] = {
"EOR", AM::kDirectPageIndexedIndirectX, 2};
99 opcode_table_[0x47] = {
"EOR", AM::kDirectPageIndirectLong, 2};
110 opcode_table_[0x50] = {
"BVC", AM::kProgramCounterRelative, 2};
111 opcode_table_[0x51] = {
"EOR", AM::kDirectPageIndirectIndexedY, 2};
113 opcode_table_[0x53] = {
"EOR", AM::kStackRelativeIndirectIndexedY, 2};
117 opcode_table_[0x57] = {
"EOR", AM::kDirectPageIndirectLongIndexedY, 2};
129 opcode_table_[0x61] = {
"ADC", AM::kDirectPageIndexedIndirectX, 2};
130 opcode_table_[0x62] = {
"PER", AM::kProgramCounterRelativeLong, 3};
135 opcode_table_[0x67] = {
"ADC", AM::kDirectPageIndirectLong, 2};
146 opcode_table_[0x70] = {
"BVS", AM::kProgramCounterRelative, 2};
147 opcode_table_[0x71] = {
"ADC", AM::kDirectPageIndirectIndexedY, 2};
149 opcode_table_[0x73] = {
"ADC", AM::kStackRelativeIndirectIndexedY, 2};
153 opcode_table_[0x77] = {
"ADC", AM::kDirectPageIndirectLongIndexedY, 2};
158 opcode_table_[0x7C] = {
"JMP", AM::kAbsoluteIndexedIndirect, 3};
164 opcode_table_[0x80] = {
"BRA", AM::kProgramCounterRelative, 2};
165 opcode_table_[0x81] = {
"STA", AM::kDirectPageIndexedIndirectX, 2};
166 opcode_table_[0x82] = {
"BRL", AM::kProgramCounterRelativeLong, 3};
171 opcode_table_[0x87] = {
"STA", AM::kDirectPageIndirectLong, 2};
182 opcode_table_[0x90] = {
"BCC", AM::kProgramCounterRelative, 2};
183 opcode_table_[0x91] = {
"STA", AM::kDirectPageIndirectIndexedY, 2};
185 opcode_table_[0x93] = {
"STA", AM::kStackRelativeIndirectIndexedY, 2};
189 opcode_table_[0x97] = {
"STA", AM::kDirectPageIndirectLongIndexedY, 2};
201 opcode_table_[0xA1] = {
"LDA", AM::kDirectPageIndexedIndirectX, 2};
207 opcode_table_[0xA7] = {
"LDA", AM::kDirectPageIndirectLong, 2};
218 opcode_table_[0xB0] = {
"BCS", AM::kProgramCounterRelative, 2};
219 opcode_table_[0xB1] = {
"LDA", AM::kDirectPageIndirectIndexedY, 2};
221 opcode_table_[0xB3] = {
"LDA", AM::kStackRelativeIndirectIndexedY, 2};
225 opcode_table_[0xB7] = {
"LDA", AM::kDirectPageIndirectLongIndexedY, 2};
237 opcode_table_[0xC1] = {
"CMP", AM::kDirectPageIndexedIndirectX, 2};
243 opcode_table_[0xC7] = {
"CMP", AM::kDirectPageIndirectLong, 2};
254 opcode_table_[0xD0] = {
"BNE", AM::kProgramCounterRelative, 2};
255 opcode_table_[0xD1] = {
"CMP", AM::kDirectPageIndirectIndexedY, 2};
257 opcode_table_[0xD3] = {
"CMP", AM::kStackRelativeIndirectIndexedY, 2};
261 opcode_table_[0xD7] = {
"CMP", AM::kDirectPageIndirectLongIndexedY, 2};
273 opcode_table_[0xE1] = {
"SBC", AM::kDirectPageIndexedIndirectX, 2};
279 opcode_table_[0xE7] = {
"SBC", AM::kDirectPageIndirectLong, 2};
290 opcode_table_[0xF0] = {
"BEQ", AM::kProgramCounterRelative, 2};
291 opcode_table_[0xF1] = {
"SBC", AM::kDirectPageIndirectIndexedY, 2};
293 opcode_table_[0xF3] = {
"SBC", AM::kStackRelativeIndirectIndexedY, 2};
297 opcode_table_[0xF7] = {
"SBC", AM::kDirectPageIndirectLongIndexedY, 2};
302 opcode_table_[0xFC] = {
"JSR", AM::kAbsoluteIndexedIndirect, 3};
419 const std::vector<uint8_t>& ops,
420 uint32_t address,
bool m_flag,
426 case AM::kAccumulator:
429 case AM::kImmediate8:
430 if (ops.size() >= 1) {
431 return absl::StrFormat(
"#$%02X", ops[0]);
435 case AM::kImmediate16:
436 if (ops.size() >= 2) {
437 return absl::StrFormat(
"#$%04X", ops[0] | (ops[1] << 8));
441 case AM::kImmediateM:
442 if (m_flag && ops.size() >= 1) {
443 return absl::StrFormat(
"#$%02X", ops[0]);
444 }
else if (!m_flag && ops.size() >= 2) {
445 return absl::StrFormat(
"#$%04X", ops[0] | (ops[1] << 8));
449 case AM::kImmediateX:
450 if (x_flag && ops.size() >= 1) {
451 return absl::StrFormat(
"#$%02X", ops[0]);
452 }
else if (!x_flag && ops.size() >= 2) {
453 return absl::StrFormat(
"#$%04X", ops[0] | (ops[1] << 8));
457 case AM::kDirectPage:
458 if (ops.size() >= 1) {
459 return absl::StrFormat(
"$%02X", ops[0]);
463 case AM::kDirectPageIndexedX:
464 if (ops.size() >= 1) {
465 return absl::StrFormat(
"$%02X,X", ops[0]);
469 case AM::kDirectPageIndexedY:
470 if (ops.size() >= 1) {
471 return absl::StrFormat(
"$%02X,Y", ops[0]);
475 case AM::kDirectPageIndirect:
476 if (ops.size() >= 1) {
477 return absl::StrFormat(
"($%02X)", ops[0]);
481 case AM::kDirectPageIndirectLong:
482 if (ops.size() >= 1) {
483 return absl::StrFormat(
"[$%02X]", ops[0]);
487 case AM::kDirectPageIndexedIndirectX:
488 if (ops.size() >= 1) {
489 return absl::StrFormat(
"($%02X,X)", ops[0]);
493 case AM::kDirectPageIndirectIndexedY:
494 if (ops.size() >= 1) {
495 return absl::StrFormat(
"($%02X),Y", ops[0]);
499 case AM::kDirectPageIndirectLongIndexedY:
500 if (ops.size() >= 1) {
501 return absl::StrFormat(
"[$%02X],Y", ops[0]);
506 if (ops.size() >= 2) {
507 uint16_t addr = ops[0] | (ops[1] << 8);
511 if (!symbol.empty()) {
515 return absl::StrFormat(
"$%04X", addr);
519 case AM::kAbsoluteIndexedX:
520 if (ops.size() >= 2) {
521 return absl::StrFormat(
"$%04X,X", ops[0] | (ops[1] << 8));
525 case AM::kAbsoluteIndexedY:
526 if (ops.size() >= 2) {
527 return absl::StrFormat(
"$%04X,Y", ops[0] | (ops[1] << 8));
531 case AM::kAbsoluteLong:
532 if (ops.size() >= 3) {
533 uint32_t addr = ops[0] | (ops[1] << 8) | (ops[2] << 16);
536 if (!symbol.empty()) {
540 return absl::StrFormat(
"$%06X", addr);
544 case AM::kAbsoluteLongIndexedX:
545 if (ops.size() >= 3) {
546 return absl::StrFormat(
"$%06X,X",
547 ops[0] | (ops[1] << 8) | (ops[2] << 16));
551 case AM::kAbsoluteIndirect:
552 if (ops.size() >= 2) {
553 return absl::StrFormat(
"($%04X)", ops[0] | (ops[1] << 8));
557 case AM::kAbsoluteIndirectLong:
558 if (ops.size() >= 2) {
559 return absl::StrFormat(
"[$%04X]", ops[0] | (ops[1] << 8));
563 case AM::kAbsoluteIndexedIndirect:
564 if (ops.size() >= 2) {
565 return absl::StrFormat(
"($%04X,X)", ops[0] | (ops[1] << 8));
569 case AM::kProgramCounterRelative:
570 if (ops.size() >= 1) {
572 int8_t offset =
static_cast<int8_t
>(ops[0]);
573 uint32_t target = (address + 2 + offset) & 0xFFFF;
575 target |= (address & 0xFF0000);
578 if (!symbol.empty()) {
582 return absl::StrFormat(
"$%04X", target & 0xFFFF);
586 case AM::kProgramCounterRelativeLong:
587 if (ops.size() >= 2) {
589 int16_t offset =
static_cast<int16_t
>(ops[0] | (ops[1] << 8));
590 uint32_t target = (address + 3 + offset) & 0xFFFF;
591 target |= (address & 0xFF0000);
594 if (!symbol.empty()) {
598 return absl::StrFormat(
"$%04X", target & 0xFFFF);
602 case AM::kStackRelative:
603 if (ops.size() >= 1) {
604 return absl::StrFormat(
"$%02X,S", ops[0]);
608 case AM::kStackRelativeIndirectIndexedY:
609 if (ops.size() >= 1) {
610 return absl::StrFormat(
"($%02X,S),Y", ops[0]);
615 if (ops.size() >= 2) {
617 return absl::StrFormat(
"$%02X,$%02X", ops[0], ops[1]);