define instruction set and opcode decoding tables

This commit is contained in:
2026-07-31 15:22:08 +02:00
parent 5de5730b68
commit 0606ecac2e
5 changed files with 787 additions and 7 deletions
+291
View File
@@ -0,0 +1,291 @@
const Instruction = @import("../instruction.zig");
pub const instructions: [256]Instruction = .{
// 0x00 - 0x0f
.{ .operation = .brk, .mode = .implied },
.{ .operation = .ora, .mode = .indexed_indirect_x },
.{ .operation = .kil, .mode = .implied },
.{ .operation = .slo, .mode = .indexed_indirect_x },
.{ .operation = .nop, .mode = .zero_page },
.{ .operation = .ora, .mode = .zero_page },
.{ .operation = .asl, .mode = .zero_page },
.{ .operation = .slo, .mode = .zero_page },
.{ .operation = .php, .mode = .implied },
.{ .operation = .ora, .mode = .immediate },
.{ .operation = .asl, .mode = .accumulator },
.{ .operation = .anc, .mode = .immediate },
.{ .operation = .nop, .mode = .absolute },
.{ .operation = .ora, .mode = .absolute },
.{ .operation = .asl, .mode = .absolute },
.{ .operation = .slo, .mode = .absolute },
// 0x10 - 0x1f
.{ .operation = .bpl, .mode = .relative },
.{ .operation = .ora, .mode = .indirect_indexed_y },
.{ .operation = .kil, .mode = .implied },
.{ .operation = .slo, .mode = .indirect_indexed_y },
.{ .operation = .nop, .mode = .zero_page_x },
.{ .operation = .ora, .mode = .zero_page_x },
.{ .operation = .asl, .mode = .zero_page_x },
.{ .operation = .slo, .mode = .zero_page_x },
.{ .operation = .clc, .mode = .implied },
.{ .operation = .ora, .mode = .absolute_y },
.{ .operation = .nop, .mode = .implied },
.{ .operation = .slo, .mode = .absolute_y },
.{ .operation = .nop, .mode = .absolute_x },
.{ .operation = .ora, .mode = .absolute_x },
.{ .operation = .asl, .mode = .absolute_x },
.{ .operation = .slo, .mode = .absolute_x },
// 0x20 - 0x2f
.{ .operation = .jsr, .mode = .absolute },
.{ .operation = .@"and", .mode = .indexed_indirect_x },
.{ .operation = .kil, .mode = .implied },
.{ .operation = .rla, .mode = .indexed_indirect_x },
.{ .operation = .bit, .mode = .zero_page },
.{ .operation = .@"and", .mode = .zero_page },
.{ .operation = .rol, .mode = .zero_page },
.{ .operation = .rla, .mode = .zero_page },
.{ .operation = .plp, .mode = .implied },
.{ .operation = .@"and", .mode = .immediate },
.{ .operation = .rol, .mode = .accumulator },
.{ .operation = .anc, .mode = .immediate },
.{ .operation = .bit, .mode = .absolute },
.{ .operation = .@"and", .mode = .absolute },
.{ .operation = .rol, .mode = .absolute },
.{ .operation = .rla, .mode = .absolute },
// 0x30 - 0x3f
.{ .operation = .bmi, .mode = .relative },
.{ .operation = .@"and", .mode = .indirect_indexed_y },
.{ .operation = .kil, .mode = .implied },
.{ .operation = .rla, .mode = .indirect_indexed_y },
.{ .operation = .nop, .mode = .zero_page_x },
.{ .operation = .@"and", .mode = .zero_page_x },
.{ .operation = .rol, .mode = .zero_page_x },
.{ .operation = .rla, .mode = .zero_page_x },
.{ .operation = .sec, .mode = .implied },
.{ .operation = .@"and", .mode = .absolute_y },
.{ .operation = .nop, .mode = .implied },
.{ .operation = .rla, .mode = .absolute_y },
.{ .operation = .nop, .mode = .absolute_x },
.{ .operation = .@"and", .mode = .absolute_x },
.{ .operation = .rol, .mode = .absolute_x },
.{ .operation = .rla, .mode = .absolute_x },
// 0x40 - 0x4f
.{ .operation = .rti, .mode = .implied },
.{ .operation = .eor, .mode = .indexed_indirect_x },
.{ .operation = .kil, .mode = .implied },
.{ .operation = .sre, .mode = .indexed_indirect_x },
.{ .operation = .nop, .mode = .zero_page },
.{ .operation = .eor, .mode = .zero_page },
.{ .operation = .lsr, .mode = .zero_page },
.{ .operation = .sre, .mode = .zero_page },
.{ .operation = .pha, .mode = .implied },
.{ .operation = .eor, .mode = .immediate },
.{ .operation = .lsr, .mode = .accumulator },
.{ .operation = .alr, .mode = .immediate },
.{ .operation = .jmp, .mode = .absolute },
.{ .operation = .eor, .mode = .absolute },
.{ .operation = .lsr, .mode = .absolute },
.{ .operation = .sre, .mode = .absolute },
// 0x50 - 0x5f
.{ .operation = .bvc, .mode = .relative },
.{ .operation = .eor, .mode = .indirect_indexed_y },
.{ .operation = .kil, .mode = .implied },
.{ .operation = .sre, .mode = .indirect_indexed_y },
.{ .operation = .nop, .mode = .zero_page_x },
.{ .operation = .eor, .mode = .zero_page_x },
.{ .operation = .lsr, .mode = .zero_page_x },
.{ .operation = .sre, .mode = .zero_page_x },
.{ .operation = .cli, .mode = .implied },
.{ .operation = .eor, .mode = .absolute_y },
.{ .operation = .nop, .mode = .implied },
.{ .operation = .sre, .mode = .absolute_y },
.{ .operation = .nop, .mode = .absolute_x },
.{ .operation = .eor, .mode = .absolute_x },
.{ .operation = .lsr, .mode = .absolute_x },
.{ .operation = .sre, .mode = .absolute_x },
// 0x60 - 0x6f
.{ .operation = .rts, .mode = .implied },
.{ .operation = .adc, .mode = .indexed_indirect_x },
.{ .operation = .kil, .mode = .implied },
.{ .operation = .rra, .mode = .indexed_indirect_x },
.{ .operation = .nop, .mode = .zero_page },
.{ .operation = .adc, .mode = .zero_page },
.{ .operation = .ror, .mode = .zero_page },
.{ .operation = .rra, .mode = .zero_page },
.{ .operation = .pla, .mode = .implied },
.{ .operation = .adc, .mode = .immediate },
.{ .operation = .ror, .mode = .accumulator },
.{ .operation = .arr, .mode = .immediate },
.{ .operation = .jmp, .mode = .indirect },
.{ .operation = .adc, .mode = .absolute },
.{ .operation = .ror, .mode = .absolute },
.{ .operation = .rra, .mode = .absolute },
// 0x70 - 0x7f
.{ .operation = .bvs, .mode = .relative },
.{ .operation = .adc, .mode = .indirect_indexed_y },
.{ .operation = .kil, .mode = .implied },
.{ .operation = .rra, .mode = .indirect_indexed_y },
.{ .operation = .nop, .mode = .zero_page_x },
.{ .operation = .adc, .mode = .zero_page_x },
.{ .operation = .ror, .mode = .zero_page_x },
.{ .operation = .rra, .mode = .zero_page_x },
.{ .operation = .sei, .mode = .implied },
.{ .operation = .adc, .mode = .absolute_y },
.{ .operation = .nop, .mode = .implied },
.{ .operation = .rra, .mode = .absolute_y },
.{ .operation = .nop, .mode = .absolute_x },
.{ .operation = .adc, .mode = .absolute_x },
.{ .operation = .ror, .mode = .absolute_x },
.{ .operation = .rra, .mode = .absolute_x },
// 0x80 - 0x8f
.{ .operation = .nop, .mode = .immediate },
.{ .operation = .sta, .mode = .indexed_indirect_x },
.{ .operation = .nop, .mode = .immediate },
.{ .operation = .sax, .mode = .indexed_indirect_x },
.{ .operation = .sty, .mode = .zero_page },
.{ .operation = .sta, .mode = .zero_page },
.{ .operation = .stx, .mode = .zero_page },
.{ .operation = .sax, .mode = .zero_page },
.{ .operation = .dey, .mode = .implied },
.{ .operation = .nop, .mode = .immediate },
.{ .operation = .txa, .mode = .implied },
.{ .operation = .xaa, .mode = .immediate },
.{ .operation = .sty, .mode = .absolute },
.{ .operation = .sta, .mode = .absolute },
.{ .operation = .stx, .mode = .absolute },
.{ .operation = .sax, .mode = .absolute },
// 0x90 - 0x9f
.{ .operation = .bcc, .mode = .relative },
.{ .operation = .sta, .mode = .indirect_indexed_y },
.{ .operation = .kil, .mode = .implied },
.{ .operation = .ahx, .mode = .indirect_indexed_y },
.{ .operation = .sty, .mode = .zero_page_x },
.{ .operation = .sta, .mode = .zero_page_x },
.{ .operation = .stx, .mode = .zero_page_y },
.{ .operation = .sax, .mode = .zero_page_y },
.{ .operation = .tya, .mode = .implied },
.{ .operation = .sta, .mode = .absolute_y },
.{ .operation = .txs, .mode = .implied },
.{ .operation = .tas, .mode = .absolute_y },
.{ .operation = .shy, .mode = .absolute_x },
.{ .operation = .sta, .mode = .absolute_x },
.{ .operation = .shx, .mode = .absolute_y },
.{ .operation = .ahx, .mode = .absolute_y },
// 0xa0 - 0xaf
.{ .operation = .ldy, .mode = .immediate },
.{ .operation = .lda, .mode = .indexed_indirect_x },
.{ .operation = .ldx, .mode = .immediate },
.{ .operation = .lax, .mode = .indexed_indirect_x },
.{ .operation = .ldy, .mode = .zero_page },
.{ .operation = .lda, .mode = .zero_page },
.{ .operation = .ldx, .mode = .zero_page },
.{ .operation = .lax, .mode = .zero_page },
.{ .operation = .tay, .mode = .implied },
.{ .operation = .lda, .mode = .immediate },
.{ .operation = .tax, .mode = .implied },
.{ .operation = .lax, .mode = .immediate },
.{ .operation = .ldy, .mode = .absolute },
.{ .operation = .lda, .mode = .absolute },
.{ .operation = .ldx, .mode = .absolute },
.{ .operation = .lax, .mode = .absolute },
// 0xb0 - 0xbf
.{ .operation = .bcs, .mode = .relative },
.{ .operation = .lda, .mode = .indirect_indexed_y },
.{ .operation = .kil, .mode = .implied },
.{ .operation = .lax, .mode = .indirect_indexed_y },
.{ .operation = .ldy, .mode = .zero_page_x },
.{ .operation = .lda, .mode = .zero_page_x },
.{ .operation = .ldx, .mode = .zero_page_y },
.{ .operation = .lax, .mode = .zero_page_y },
.{ .operation = .clv, .mode = .implied },
.{ .operation = .lda, .mode = .absolute_y },
.{ .operation = .tsx, .mode = .implied },
.{ .operation = .las, .mode = .absolute_y },
.{ .operation = .ldy, .mode = .absolute_x },
.{ .operation = .lda, .mode = .absolute_x },
.{ .operation = .ldx, .mode = .absolute_y },
.{ .operation = .lax, .mode = .absolute_y },
// 0xc0 - 0xcf
.{ .operation = .cpy, .mode = .immediate },
.{ .operation = .cmp, .mode = .indexed_indirect_x },
.{ .operation = .nop, .mode = .immediate },
.{ .operation = .dcp, .mode = .indexed_indirect_x },
.{ .operation = .cpy, .mode = .zero_page },
.{ .operation = .cmp, .mode = .zero_page },
.{ .operation = .dec, .mode = .zero_page },
.{ .operation = .dcp, .mode = .zero_page },
.{ .operation = .iny, .mode = .implied },
.{ .operation = .cmp, .mode = .immediate },
.{ .operation = .dex, .mode = .implied },
.{ .operation = .axs, .mode = .immediate },
.{ .operation = .cpy, .mode = .absolute },
.{ .operation = .cmp, .mode = .absolute },
.{ .operation = .dec, .mode = .absolute },
.{ .operation = .dcp, .mode = .absolute },
// 0xd0 - 0xdf
.{ .operation = .bne, .mode = .relative },
.{ .operation = .cmp, .mode = .indirect_indexed_y },
.{ .operation = .kil, .mode = .implied },
.{ .operation = .dcp, .mode = .indirect_indexed_y },
.{ .operation = .nop, .mode = .zero_page_x },
.{ .operation = .cmp, .mode = .zero_page_x },
.{ .operation = .dec, .mode = .zero_page_x },
.{ .operation = .dcp, .mode = .zero_page_x },
.{ .operation = .cld, .mode = .implied },
.{ .operation = .cmp, .mode = .absolute_y },
.{ .operation = .nop, .mode = .implied },
.{ .operation = .dcp, .mode = .absolute_y },
.{ .operation = .nop, .mode = .absolute_x },
.{ .operation = .cmp, .mode = .absolute_x },
.{ .operation = .dec, .mode = .absolute_x },
.{ .operation = .dcp, .mode = .absolute_x },
// 0xe0 - 0xef
.{ .operation = .cpx, .mode = .immediate },
.{ .operation = .sbc, .mode = .indexed_indirect_x },
.{ .operation = .nop, .mode = .immediate },
.{ .operation = .isc, .mode = .indexed_indirect_x },
.{ .operation = .cpx, .mode = .zero_page },
.{ .operation = .sbc, .mode = .zero_page },
.{ .operation = .inc, .mode = .zero_page },
.{ .operation = .isc, .mode = .zero_page },
.{ .operation = .inx, .mode = .implied },
.{ .operation = .sbc, .mode = .immediate },
.{ .operation = .nop, .mode = .implied },
.{ .operation = .sbc, .mode = .immediate },
.{ .operation = .cpx, .mode = .absolute },
.{ .operation = .sbc, .mode = .absolute },
.{ .operation = .inc, .mode = .absolute },
.{ .operation = .isc, .mode = .absolute },
// 0xf0 - 0xff
.{ .operation = .beq, .mode = .relative },
.{ .operation = .sbc, .mode = .indirect_indexed_y },
.{ .operation = .kil, .mode = .implied },
.{ .operation = .isc, .mode = .indirect_indexed_y },
.{ .operation = .nop, .mode = .zero_page_x },
.{ .operation = .sbc, .mode = .zero_page_x },
.{ .operation = .inc, .mode = .zero_page_x },
.{ .operation = .isc, .mode = .zero_page_x },
.{ .operation = .sed, .mode = .implied },
.{ .operation = .sbc, .mode = .absolute_y },
.{ .operation = .nop, .mode = .implied },
.{ .operation = .isc, .mode = .absolute_y },
.{ .operation = .nop, .mode = .absolute_x },
.{ .operation = .sbc, .mode = .absolute_x },
.{ .operation = .inc, .mode = .absolute_x },
.{ .operation = .isc, .mode = .absolute_x },
};