From b7e161ef0bec42a521816336ffc55a1c0fa22a2b Mon Sep 17 00:00:00 2001 From: Trevor Merritt Date: Wed, 9 Jul 2025 11:27:48 -0400 Subject: [PATCH] more instructions decompiled --- cli/src/bin/de6502.rs | 2 +- core/src/instruction_table.rs | 316 ++++++++++++++++---------------- resources/test/instructions.asm | 137 ++++++++++++++ 3 files changed, 296 insertions(+), 159 deletions(-) diff --git a/cli/src/bin/de6502.rs b/cli/src/bin/de6502.rs index 0ee0ebd..2aad2f5 100644 --- a/cli/src/bin/de6502.rs +++ b/cli/src/bin/de6502.rs @@ -72,7 +72,7 @@ fn decompile(data: &[u8]) -> Vec<(u16, DecompiledLine)> { // println!("Instruction {:?}/{:?} needs {:?} bytes.", top.operation, top.mode, top.length); let num_bytes_to_load = top.length - 1; - println!("Need {num_bytes_to_load} more bytes."); + // println!("Need {num_bytes_to_load} more bytes."); let mut formatted_asm = String::from(top.format_prefix); let mut param = None; if num_bytes_to_load == 1 { diff --git a/core/src/instruction_table.rs b/core/src/instruction_table.rs index c9754bf..ec1e1ee 100644 --- a/core/src/instruction_table.rs +++ b/core/src/instruction_table.rs @@ -160,23 +160,23 @@ pub const INSTRUCTION_TABLE: [Option; 256] = { mode: AddressMode::IndirectX, length: 2, cycles: 6, - format_prefix: "TBD", - format_postfix: "", + format_prefix: "AND ($", + format_postfix: ",X)", }); table[ISA_OP_AND_INDY as usize] = Some(OpInfo { operation: AND, mode: AddressMode::IndirectY, length: 2, cycles: 5, - format_prefix: "TBD", - format_postfix: "", + format_prefix: "AND ($", + format_postfix: "),Y", }); table[ISA_OP_ASL_A as usize] = Some(OpInfo { operation: ASL, mode: AddressMode::Accumulator, length: 1, cycles: 2, - format_prefix: "TBD", + format_prefix: "ASL", format_postfix: "", }); table[ISA_OP_ASL_Z as usize] = Some(OpInfo { @@ -184,7 +184,7 @@ pub const INSTRUCTION_TABLE: [Option; 256] = { mode: AddressMode::ZeroPage, length: 2, cycles: 5, - format_prefix: "TBD", + format_prefix: "ASL $", format_postfix: "", }); table[ISA_OP_ASL_ZX as usize] = Some(OpInfo { @@ -192,15 +192,15 @@ pub const INSTRUCTION_TABLE: [Option; 256] = { mode: AddressMode::ZeroPageX, length: 2, cycles: 6, - format_prefix: "TBD", - format_postfix: "", + format_prefix: "ASL $", + format_postfix: ",X", }); table[ISA_OP_ASL_ABS as usize] = Some(OpInfo { operation: ASL, mode: AddressMode::Absolute, length: 3, cycles: 6, - format_prefix: "TBD", + format_prefix: "ASL $", format_postfix: "", }); table[ISA_OP_ASL_ABSX as usize] = Some(OpInfo { @@ -209,34 +209,34 @@ pub const INSTRUCTION_TABLE: [Option; 256] = { length: 3, cycles: 7, - format_prefix: "TBD", - format_postfix: "", + format_prefix: "ASL $", + format_postfix: ",X", }); table[ISA_OP_BCC as usize] = Some(OpInfo { operation: BCC, - mode: AddressMode::Implied, + mode: AddressMode::Immediate, length: 2, cycles: 2, - format_prefix: "TBD", + format_prefix: "BCC #$", format_postfix: "", }); table[ISA_OP_BCS as usize] = Some(OpInfo { operation: BCS, - mode: AddressMode::Implied, + mode: AddressMode::Immediate, length: 2, cycles: 2, - format_prefix: "TBD", + format_prefix: "BCS $", format_postfix: "", }); table[ISA_OP_BEQ as usize] = Some(OpInfo { operation: BEQ, - mode: AddressMode::Implied, + mode: AddressMode::Immediate, length: 2, cycles: 2, - format_prefix: "TBD", + format_prefix: "BEQ $", format_postfix: "", }); @@ -246,7 +246,7 @@ pub const INSTRUCTION_TABLE: [Option; 256] = { mode: AddressMode::ZeroPage, length: 2, cycles: 3, - format_prefix: "TBD", + format_prefix: "BIT $", format_postfix: "", }); @@ -255,36 +255,36 @@ pub const INSTRUCTION_TABLE: [Option; 256] = { mode: AddressMode::Absolute, length: 3, cycles: 4, - format_prefix: "TBD", + format_prefix: "BIT $", format_postfix: "", }); table[ISA_OP_BMI as usize] = Some(OpInfo { operation: BMI, - mode: AddressMode::Implied, + mode: AddressMode::Immediate, length: 2, cycles: 2, - format_prefix: "TBD", + format_prefix: "BMI #$", format_postfix: "", }); table[ISA_OP_BNE as usize] = Some(OpInfo { operation: BNE, - mode: AddressMode::Implied, + mode: AddressMode::Immediate, length: 2, cycles: 2, - format_prefix: "TBD", + format_prefix: "BNE #$", format_postfix: "", }); table[ISA_OP_BPL as usize] = Some(OpInfo { operation: Operation::BPL, - mode: AddressMode::Implied, + mode: AddressMode::Immediate, length: 2, cycles: 2, - format_prefix: "TBD", + format_prefix: "BPL #$", format_postfix: "", }); @@ -293,25 +293,25 @@ pub const INSTRUCTION_TABLE: [Option; 256] = { mode: AddressMode::Implied, length: 1, cycles: 7, - format_prefix: "TBD", + format_prefix: "BRK", format_postfix: "", }); table[ISA_OP_BVC as usize] = Some(OpInfo { operation: BVC, - mode: AddressMode::Implied, + mode: AddressMode::Immediate, length: 2, cycles: 2, - format_prefix: "TBD", + format_prefix: "BVC #$", format_postfix: "", }); table[ISA_OP_BVS as usize] = Some(OpInfo { operation: BVS, - mode: AddressMode::Implied, + mode: AddressMode::Immediate, length: 2, cycles: 2, - format_prefix: "TBD", + format_prefix: "BVS #$", format_postfix: "", }); @@ -320,7 +320,7 @@ pub const INSTRUCTION_TABLE: [Option; 256] = { mode: AddressMode::Implied, length: 1, cycles: 2, - format_prefix: "TBD", + format_prefix: "CLC", format_postfix: "", }); @@ -329,7 +329,7 @@ pub const INSTRUCTION_TABLE: [Option; 256] = { mode: AddressMode::Implied, length: 1, cycles: 2, - format_prefix: "TBD", + format_prefix: "CLD", format_postfix: "", }); @@ -338,7 +338,7 @@ pub const INSTRUCTION_TABLE: [Option; 256] = { mode: AddressMode::Implied, length: 1, cycles: 2, - format_prefix: "TBD", + format_prefix: "CLI", format_postfix: "", }); @@ -347,7 +347,7 @@ pub const INSTRUCTION_TABLE: [Option; 256] = { mode: AddressMode::Implied, length: 1, cycles: 2, - format_prefix: "TBD", + format_prefix: "CLV", format_postfix: "", }); @@ -357,7 +357,7 @@ pub const INSTRUCTION_TABLE: [Option; 256] = { mode: AddressMode::Immediate, length: 2, cycles: 2, - format_prefix: "TBD", + format_prefix: "CMP #$", format_postfix: "", }); @@ -366,7 +366,7 @@ pub const INSTRUCTION_TABLE: [Option; 256] = { mode: AddressMode::ZeroPage, length: 2, cycles: 3, - format_prefix: "TBD", + format_prefix: "CMP $", format_postfix: "", }); @@ -375,8 +375,8 @@ pub const INSTRUCTION_TABLE: [Option; 256] = { mode: AddressMode::ZeroPageX, length: 2, cycles: 4, - format_prefix: "TBD", - format_postfix: "", + format_prefix: "CMP $", + format_postfix: ",X", }); table[ISA_OP_CMP_ABS as usize] = Some(OpInfo { @@ -384,7 +384,7 @@ pub const INSTRUCTION_TABLE: [Option; 256] = { mode: AddressMode::Absolute, length: 3, cycles: 4, - format_prefix: "TBD", + format_prefix: "CMP $", format_postfix: "", }); @@ -393,8 +393,8 @@ pub const INSTRUCTION_TABLE: [Option; 256] = { mode: AddressMode::AbsoluteX, length: 3, cycles: 4, - format_prefix: "TBD", - format_postfix: "", + format_prefix: "CMP $", + format_postfix: ",X", }); table[ISA_OP_CMP_ABSY as usize] = Some(OpInfo { @@ -402,8 +402,8 @@ pub const INSTRUCTION_TABLE: [Option; 256] = { mode: AddressMode::AbsoluteY, length: 3, cycles: 4, - format_prefix: "TBD", - format_postfix: "", + format_prefix: "CMP $", + format_postfix: ",Y", }); table[ISA_OP_CMP_INDX as usize] = Some(OpInfo { @@ -411,8 +411,8 @@ pub const INSTRUCTION_TABLE: [Option; 256] = { mode: AddressMode::IndirectX, length: 2, cycles: 6, - format_prefix: "TBD", - format_postfix: "", + format_prefix: "CMP ($", + format_postfix: " ,X)", }); table[ISA_OP_CMP_INDY as usize] = Some(OpInfo { @@ -420,8 +420,8 @@ pub const INSTRUCTION_TABLE: [Option; 256] = { mode: AddressMode::IndirectY, length: 2, cycles: 5, - format_prefix: "TBD", - format_postfix: "", + format_prefix: "CMP ($", + format_postfix: "),Y", }); @@ -430,7 +430,7 @@ pub const INSTRUCTION_TABLE: [Option; 256] = { mode: AddressMode::Immediate, length: 2, cycles: 2, - format_prefix: "TBD", + format_prefix: "CPX #$", format_postfix: "", }); @@ -439,7 +439,7 @@ pub const INSTRUCTION_TABLE: [Option; 256] = { mode: AddressMode::ZeroPage, length: 2, cycles: 3, - format_prefix: "TBD", + format_prefix: "CPX $", format_postfix: "", }); @@ -448,7 +448,7 @@ pub const INSTRUCTION_TABLE: [Option; 256] = { mode: AddressMode::Absolute, length: 3, cycles: 4, - format_prefix: "TBD", + format_prefix: "CPX $", format_postfix: "", }); @@ -457,7 +457,7 @@ pub const INSTRUCTION_TABLE: [Option; 256] = { mode: AddressMode::Immediate, length: 2, cycles: 2, - format_prefix: "TBD", + format_prefix: "CPY #$", format_postfix: "", }); @@ -466,7 +466,7 @@ pub const INSTRUCTION_TABLE: [Option; 256] = { mode: AddressMode::ZeroPage, length: 2, cycles: 3, - format_prefix: "TBD", + format_prefix: "CPY $", format_postfix: "", }); table[ISA_OP_CPY_ABS as usize] = Some(OpInfo { @@ -474,7 +474,7 @@ pub const INSTRUCTION_TABLE: [Option; 256] = { mode: AddressMode::Absolute, length: 3, cycles: 4, - format_prefix: "TBD", + format_prefix: "CPY $", format_postfix: "", }); @@ -483,7 +483,7 @@ pub const INSTRUCTION_TABLE: [Option; 256] = { mode: AddressMode::ZeroPage, length: 2, cycles: 5, - format_prefix: "TBD", + format_prefix: "DEC $", format_postfix: "", }); @@ -492,8 +492,8 @@ pub const INSTRUCTION_TABLE: [Option; 256] = { mode: AddressMode::ZeroPageX, length: 2, cycles: 6, - format_prefix: "TBD", - format_postfix: "", + format_prefix: "DEC $", + format_postfix: ",X", }); table[ISA_OP_DEC_ABS as usize] = Some(OpInfo { @@ -501,7 +501,7 @@ pub const INSTRUCTION_TABLE: [Option; 256] = { mode: AddressMode::Absolute, length: 3, cycles: 6, - format_prefix: "TBD", + format_prefix: "DEC $", format_postfix: "", }); table[ISA_OP_DEC_ABSX as usize] = Some(OpInfo { @@ -509,15 +509,15 @@ pub const INSTRUCTION_TABLE: [Option; 256] = { mode: AddressMode::AbsoluteX, length: 3, cycles: 7, - format_prefix: "TBD", - format_postfix: "", + format_prefix: "DEC $", + format_postfix: ",X", }); table[ISA_OP_DEX as usize] = Some(OpInfo { operation: DEX, mode: AddressMode::Implied, length: 1, cycles: 2, - format_prefix: "TBD", + format_prefix: "DEX", format_postfix: "", }); table[ISA_OP_DEY as usize] = Some(OpInfo { @@ -525,7 +525,7 @@ pub const INSTRUCTION_TABLE: [Option; 256] = { mode: AddressMode::Implied, length: 1, cycles: 2, - format_prefix: "TBD", + format_prefix: "DEY", format_postfix: "", }); table[ISA_OP_EOR_I as usize] = Some(OpInfo { @@ -533,7 +533,7 @@ pub const INSTRUCTION_TABLE: [Option; 256] = { mode: AddressMode::Immediate, length: 2, cycles: 2, - format_prefix: "TBD", + format_prefix: "EOR #$", format_postfix: "", }); table[ISA_OP_EOR_ZP as usize] = Some(OpInfo { @@ -541,7 +541,7 @@ pub const INSTRUCTION_TABLE: [Option; 256] = { mode: AddressMode::ZeroPage, length: 2, cycles: 3, - format_prefix: "TBD", + format_prefix: "EOR $", format_postfix: "", }); table[ISA_OP_EOR_ZPX as usize] = Some(OpInfo { @@ -549,15 +549,15 @@ pub const INSTRUCTION_TABLE: [Option; 256] = { mode: AddressMode::ZeroPageX, length: 2, cycles: 4, - format_prefix: "TBD", - format_postfix: "", + format_prefix: "EOR $", + format_postfix: ",X", }); table[ISA_OP_EOR_ABS as usize] = Some(OpInfo { operation: EOR, mode: AddressMode::Absolute, length: 3, cycles: 4, - format_prefix: "TBD", + format_prefix: "EOR $", format_postfix: "", }); table[ISA_OP_EOR_ABSX as usize] = Some(OpInfo { @@ -565,32 +565,32 @@ pub const INSTRUCTION_TABLE: [Option; 256] = { mode: AddressMode::AbsoluteX, length: 3, cycles: 4, - format_prefix: "TBD", - format_postfix: "", + format_prefix: "EOR $", + format_postfix: ",X", }); table[ISA_OP_EOR_ABSY as usize] = Some(OpInfo { operation: EOR, mode: AddressMode::AbsoluteY, length: 3, cycles: 4, - format_prefix: "TBD", - format_postfix: "", + format_prefix: "EOR $", + format_postfix: ",Y", }); table[ISA_OP_EOR_INDX as usize] = Some(OpInfo { operation: EOR, mode: AddressMode::IndirectX, length: 2, cycles: 6, - format_prefix: "TBD", - format_postfix: "", + format_prefix: "EOR ($", + format_postfix: ",X)", }); table[ISA_OP_EOR_INDY as usize] = Some(OpInfo { operation: EOR, mode: AddressMode::IndirectY, length: 2, cycles: 5, - format_prefix: "TBD", - format_postfix: "", + format_prefix: "EOR ($", + format_postfix: "),Y", }); table[ISA_OP_INC_ZP as usize] = Some(OpInfo { @@ -598,7 +598,7 @@ pub const INSTRUCTION_TABLE: [Option; 256] = { mode: AddressMode::ZeroPage, length: 2, cycles: 5, - format_prefix: "TBD", + format_prefix: "INC $", format_postfix: "", }); table[ISA_OP_INC_ZPX as usize] = Some(OpInfo { @@ -606,15 +606,15 @@ pub const INSTRUCTION_TABLE: [Option; 256] = { mode: AddressMode::ZeroPageX, length: 2, cycles: 6, - format_prefix: "TBD", - format_postfix: "", + format_prefix: "INC $", + format_postfix: ",X", }); table[ISA_OP_INC_ABS as usize] = Some(OpInfo { operation: INC, mode: AddressMode::Absolute, length: 3, cycles: 6, - format_prefix: "TBD", + format_prefix: "INC $", format_postfix: "", }); table[ISA_OP_INC_ABSX as usize] = Some(OpInfo { @@ -622,15 +622,15 @@ pub const INSTRUCTION_TABLE: [Option; 256] = { mode: AddressMode::AbsoluteX, length: 3, cycles: 7, - format_prefix: "TBD", - format_postfix: "", + format_prefix: "INC $", + format_postfix: ",X", }); table[ISA_OP_INX as usize] = Some(OpInfo { operation: INX, mode: AddressMode::Implied, length: 1, cycles: 2, - format_prefix: "TBD", + format_prefix: "INX", format_postfix: "", }); table[ISA_OP_INY as usize] = Some(OpInfo { @@ -638,7 +638,7 @@ pub const INSTRUCTION_TABLE: [Option; 256] = { mode: AddressMode::Implied, length: 1, cycles: 2, - format_prefix: "TBD", + format_prefix: "INY", format_postfix: "", }); table[ISA_OP_JMP_ABS as usize] = Some(OpInfo { @@ -646,7 +646,7 @@ pub const INSTRUCTION_TABLE: [Option; 256] = { mode: AddressMode::Absolute, length: 3, cycles: 3, - format_prefix: "JMP", + format_prefix: "JMP $", format_postfix: "", }); table[ISA_OP_JMP_IND as usize] = Some(OpInfo { @@ -679,7 +679,7 @@ pub const INSTRUCTION_TABLE: [Option; 256] = { mode: AddressMode::ZeroPage, length: 2, cycles: 3, - format_prefix: "TBD", + format_prefix: "LDA $", format_postfix: "", }); table[ISA_OP_LDA_ZX as usize] = Some(OpInfo { @@ -687,15 +687,15 @@ pub const INSTRUCTION_TABLE: [Option; 256] = { mode: AddressMode::ZeroPageX, length: 2, cycles: 4, - format_prefix: "TBD", - format_postfix: "", + format_prefix: "LDA $", + format_postfix: ",X", }); table[ISA_OP_LDA_ABS as usize] = Some(OpInfo { operation: Operation::LDA, mode: AddressMode::Absolute, length: 3, cycles: 4, - format_prefix: "TBD", + format_prefix: "LDA $", format_postfix: "", }); table[ISA_OP_LDA_ABSX as usize] = Some(OpInfo { @@ -703,32 +703,32 @@ pub const INSTRUCTION_TABLE: [Option; 256] = { mode: AddressMode::AbsoluteX, length: 3, cycles: 4, - format_prefix: "TBD", - format_postfix: "", + format_prefix: "LDA $", + format_postfix: ",X", }); table[ISA_OP_LDA_ABSY as usize] = Some(OpInfo { operation: LDA, mode: AddressMode::AbsoluteY, length: 3, cycles: 4, - format_prefix: "TBD", - format_postfix: "", + format_prefix: "LDA $", + format_postfix: ",Y", }); table[ISA_OP_LDA_INDX as usize] = Some(OpInfo { operation: Operation::LDA, mode: AddressMode::IndirectX, length: 2, cycles: 6, - format_prefix: "TBD", - format_postfix: "", + format_prefix: "LDA ($", + format_postfix: ",X)", }); table[ISA_OP_LDA_INDY as usize] = Some(OpInfo { operation: LDA, mode: AddressMode::IndirectY, length: 2, cycles: 5, - format_prefix: "TBD", - format_postfix: "", + format_prefix: "LDA ($", + format_postfix: "),Y", }); table[ISA_OP_LDX_I as usize] = Some(OpInfo { @@ -736,7 +736,7 @@ pub const INSTRUCTION_TABLE: [Option; 256] = { mode: AddressMode::Immediate, length: 2, cycles: 2, - format_prefix: "TBD", + format_prefix: "LDX #$", format_postfix: "", }); table[ISA_OP_LDX_ZP as usize] = Some(OpInfo { @@ -744,7 +744,7 @@ pub const INSTRUCTION_TABLE: [Option; 256] = { mode: AddressMode::ZeroPage, length: 2, cycles: 3, - format_prefix: "TBD", + format_prefix: "LDX $", format_postfix: "", }); table[ISA_OP_LDX_ZPY as usize] = Some(OpInfo { @@ -752,15 +752,15 @@ pub const INSTRUCTION_TABLE: [Option; 256] = { mode: AddressMode::ZeroPageY, length: 2, cycles: 4, - format_prefix: "TBD", - format_postfix: "", + format_prefix: "LDX $", + format_postfix: ",Y", }); table[ISA_OP_LDX_ABS as usize] = Some(OpInfo { operation: Operation::LDX, mode: AddressMode::Absolute, length: 3, cycles: 4, - format_prefix: "TBD", + format_prefix: "LDX $", format_postfix: "", }); table[ISA_OP_LDX_ABSY as usize] = Some(OpInfo { @@ -768,8 +768,8 @@ pub const INSTRUCTION_TABLE: [Option; 256] = { mode: AddressMode::AbsoluteY, length: 3, cycles: 4, - format_prefix: "TBD", - format_postfix: "", + format_prefix: "LDX $", + format_postfix: ",Y", }); table[ISA_OP_LDY_I as usize] = Some(OpInfo { @@ -777,7 +777,7 @@ pub const INSTRUCTION_TABLE: [Option; 256] = { mode: AddressMode::Immediate, length: 2, cycles: 2, - format_prefix: "TBD", + format_prefix: "LDY #$", format_postfix: "", }); table[ISA_OP_LDY_ZP as usize] = Some(OpInfo { @@ -785,7 +785,7 @@ pub const INSTRUCTION_TABLE: [Option; 256] = { mode: AddressMode::ZeroPage, length: 2, cycles: 3, - format_prefix: "TBD", + format_prefix: "LDY $", format_postfix: "", }); table[ISA_OP_LDY_ZPX as usize] = Some(OpInfo { @@ -793,15 +793,15 @@ pub const INSTRUCTION_TABLE: [Option; 256] = { mode: AddressMode::ZeroPageX, length: 2, cycles: 4, - format_prefix: "TBD", - format_postfix: "", + format_prefix: "LDY $", + format_postfix: ",X", }); table[ISA_OP_LDY_ABS as usize] = Some(OpInfo { operation: LDY, mode: AddressMode::Absolute, length: 3, cycles: 4, - format_prefix: "TBD", + format_prefix: "LDY $", format_postfix: "", }); table[ISA_OP_LDY_ABSX as usize] = Some(OpInfo { @@ -809,8 +809,8 @@ pub const INSTRUCTION_TABLE: [Option; 256] = { mode: AddressMode::AbsoluteX, length: 3, cycles: 4, - format_prefix: "TBD", - format_postfix: "", + format_prefix: "LDY $", + format_postfix: ",X", }); table[ISA_OP_LSR_A as usize] = Some(OpInfo { @@ -818,7 +818,7 @@ pub const INSTRUCTION_TABLE: [Option; 256] = { mode: AddressMode::Accumulator, length: 1, cycles: 2, - format_prefix: "TBD", + format_prefix: "LSR", format_postfix: "", }); table[ISA_OP_LSR_ZP as usize] = Some(OpInfo { @@ -826,7 +826,7 @@ pub const INSTRUCTION_TABLE: [Option; 256] = { mode: AddressMode::ZeroPage, length: 2, cycles: 5, - format_prefix: "TBD", + format_prefix: "LSR $", format_postfix: "", }); table[ISA_OP_LSR_ZPX as usize] = Some(OpInfo { @@ -834,15 +834,15 @@ pub const INSTRUCTION_TABLE: [Option; 256] = { mode: AddressMode::ZeroPageX, length: 2, cycles: 6, - format_prefix: "TBD", - format_postfix: "", + format_prefix: "LSR $", + format_postfix: ",X", }); table[ISA_OP_LSR_ABS as usize] = Some(OpInfo { operation: Operation::LSR, mode: AddressMode::Absolute, length: 3, cycles: 6, - format_prefix: "TBD", + format_prefix: "LSR $", format_postfix: "", }); table[ISA_OP_LSR_ABSX as usize] = Some(OpInfo { @@ -868,7 +868,7 @@ pub const INSTRUCTION_TABLE: [Option; 256] = { mode: AddressMode::Immediate, length: 2, cycles: 2, - format_prefix: "TBD", + format_prefix: "ORA #$", format_postfix: "", }); table[ISA_OP_ORA_ZP as usize] = Some(OpInfo { @@ -876,7 +876,7 @@ pub const INSTRUCTION_TABLE: [Option; 256] = { mode: AddressMode::ZeroPage, length: 2, cycles: 3, - format_prefix: "TBD", + format_prefix: "ORA $", format_postfix: "", }); table[ISA_OP_ORA_ZPX as usize] = Some(OpInfo { @@ -884,15 +884,15 @@ pub const INSTRUCTION_TABLE: [Option; 256] = { mode: AddressMode::ZeroPageX, length: 2, cycles: 4, - format_prefix: "TBD", - format_postfix: "", + format_prefix: "ORA $", + format_postfix: ",X", }); table[ISA_OP_ORA_ABS as usize] = Some(OpInfo { operation: Operation::ORA, mode: AddressMode::Absolute, length: 3, cycles: 4, - format_prefix: "TBD", + format_prefix: "ORA $", format_postfix: "", }); @@ -901,32 +901,32 @@ pub const INSTRUCTION_TABLE: [Option; 256] = { mode: AddressMode::AbsoluteX, length: 3, cycles: 4, - format_prefix: "TBD", - format_postfix: "", + format_prefix: "ORA $", + format_postfix: ",X", }); table[ISA_OP_ORA_ABSY as usize] = Some(OpInfo { operation: Operation::ORA, mode: AddressMode::AbsoluteY, length: 3, cycles: 4, - format_prefix: "TBD", - format_postfix: "", + format_prefix: "ORA $", + format_postfix: ",Y", }); table[ISA_OP_ORA_INDX as usize] = Some(OpInfo { operation: Operation::ORA, mode: AddressMode::IndirectX, length: 2, cycles: 6, - format_prefix: "TBD", - format_postfix: "", + format_prefix: "ORA ($", + format_postfix: ",X)", }); table[ISA_OP_ORA_INDY as usize] = Some(OpInfo { operation: Operation::ORA, mode: AddressMode::IndirectY, length: 2, cycles: 5, - format_prefix: "TBD", - format_postfix: "", + format_prefix: "ORA ($", + format_postfix: "),Y", }); table[ISA_OP_PHA as usize] = Some(OpInfo { @@ -934,7 +934,7 @@ pub const INSTRUCTION_TABLE: [Option; 256] = { mode: AddressMode::Implied, length: 1, cycles: 3, - format_prefix: "TBD", + format_prefix: "PHA", format_postfix: "", }); table[ISA_OP_PHP as usize] = Some(OpInfo { @@ -942,7 +942,7 @@ pub const INSTRUCTION_TABLE: [Option; 256] = { mode: AddressMode::Implied, length: 1, cycles: 3, - format_prefix: "TBD", + format_prefix: "PHP", format_postfix: "", }); table[ISA_OP_PLA as usize] = Some(OpInfo { @@ -950,7 +950,7 @@ pub const INSTRUCTION_TABLE: [Option; 256] = { mode: AddressMode::Implied, length: 1, cycles: 4, - format_prefix: "TBD", + format_prefix: "PLA", format_postfix: "", }); table[ISA_OP_PLP as usize] = Some(OpInfo { @@ -958,7 +958,7 @@ pub const INSTRUCTION_TABLE: [Option; 256] = { mode: AddressMode::Implied, length: 1, cycles: 4, - format_prefix: "TBD", + format_prefix: "PLP", format_postfix: "", }); @@ -967,7 +967,7 @@ pub const INSTRUCTION_TABLE: [Option; 256] = { mode: AddressMode::Accumulator, length: 1, cycles: 2, - format_prefix: "TBD", + format_prefix: "ROL", format_postfix: "", }); table[ISA_OP_ROL_ZP as usize] = Some(OpInfo { @@ -975,7 +975,7 @@ pub const INSTRUCTION_TABLE: [Option; 256] = { mode: AddressMode::ZeroPage, length: 2, cycles: 5, - format_prefix: "TBD", + format_prefix: "ROL $", format_postfix: "", }); table[ISA_OP_ROL_ZPX as usize] = Some(OpInfo { @@ -983,15 +983,15 @@ pub const INSTRUCTION_TABLE: [Option; 256] = { mode: AddressMode::ZeroPageX, length: 2, cycles: 6, - format_prefix: "TBD", - format_postfix: "", + format_prefix: "ROL $", + format_postfix: ",X", }); table[ISA_OP_ROL_ABS as usize] = Some(OpInfo { operation: Operation::ROL, mode: AddressMode::Absolute, length: 3, cycles: 6, - format_prefix: "TBD", + format_prefix: "ROL $", format_postfix: "", }); table[ISA_OP_ROL_ABSX as usize] = Some(OpInfo { @@ -999,8 +999,8 @@ pub const INSTRUCTION_TABLE: [Option; 256] = { mode: AddressMode::AbsoluteX, length: 3, cycles: 7, - format_prefix: "TBD", - format_postfix: "", + format_prefix: "ROL $", + format_postfix: ",X", }); table[ISA_OP_ROR_A as usize] = Some(OpInfo { @@ -1008,7 +1008,7 @@ pub const INSTRUCTION_TABLE: [Option; 256] = { mode: AddressMode::Accumulator, length: 1, cycles: 2, - format_prefix: "TBD", + format_prefix: "ROR", format_postfix: "", }); table[ISA_OP_ROR_ZP as usize] = Some(OpInfo { @@ -1016,7 +1016,7 @@ pub const INSTRUCTION_TABLE: [Option; 256] = { mode: AddressMode::ZeroPage, length: 2, cycles: 5, - format_prefix: "TBD", + format_prefix: "ROR $", format_postfix: "", }); table[ISA_OP_ROR_ZPX as usize] = Some(OpInfo { @@ -1024,15 +1024,15 @@ pub const INSTRUCTION_TABLE: [Option; 256] = { mode: AddressMode::ZeroPageX, length: 2, cycles: 6, - format_prefix: "TBD", - format_postfix: "", + format_prefix: "ROR $", + format_postfix: ",X", }); table[ISA_OP_ROR_ABS as usize] = Some(OpInfo { operation: Operation::ROR, mode: AddressMode::Absolute, length: 3, cycles: 6, - format_prefix: "TBD", + format_prefix: "ROR $", format_postfix: "", }); table[ISA_OP_ROR_ABSX as usize] = Some(OpInfo { @@ -1040,8 +1040,8 @@ pub const INSTRUCTION_TABLE: [Option; 256] = { mode: AddressMode::AbsoluteX, length: 3, cycles: 7, - format_prefix: "TBD", - format_postfix: "", + format_prefix: "ROR $", + format_postfix: ",X", }); table[ISA_OP_RTI as usize] = Some(OpInfo { @@ -1049,7 +1049,7 @@ pub const INSTRUCTION_TABLE: [Option; 256] = { mode: AddressMode::Implied, length: 1, cycles: 2, - format_prefix: "TBD", + format_prefix: "RTI", format_postfix: "", }); table[ISA_OP_RTS as usize] = Some(OpInfo { @@ -1057,7 +1057,7 @@ pub const INSTRUCTION_TABLE: [Option; 256] = { mode: AddressMode::Implied, length: 1, cycles: 2, - format_prefix: "TBD", + format_prefix: "RTS", format_postfix: "", }); @@ -1066,7 +1066,7 @@ pub const INSTRUCTION_TABLE: [Option; 256] = { mode: AddressMode::Immediate, length: 2, cycles: 2, - format_prefix: "TBD", + format_prefix: "SBC #$", format_postfix: "", }); table[ISA_OP_SBC_ZP as usize] = Some(OpInfo { @@ -1074,7 +1074,7 @@ pub const INSTRUCTION_TABLE: [Option; 256] = { mode: AddressMode::ZeroPage, length: 2, cycles: 3, - format_prefix: "TBD", + format_prefix: "SBC $", format_postfix: "", }); table[ISA_OP_SBC_ZPX as usize] = Some(OpInfo { @@ -1082,15 +1082,15 @@ pub const INSTRUCTION_TABLE: [Option; 256] = { mode: AddressMode::ZeroPageX, length: 2, cycles: 4, - format_prefix: "TBD", - format_postfix: "", + format_prefix: "SBC $", + format_postfix: ",X", }); table[ISA_OP_SBC_ABS as usize] = Some(OpInfo { operation: Operation::SBC, mode: AddressMode::Absolute, length: 3, cycles: 4, - format_prefix: "TBD", + format_prefix: "SBC $", format_postfix: "", }); table[ISA_OP_SBC_ABSX as usize] = Some(OpInfo { @@ -1098,24 +1098,24 @@ pub const INSTRUCTION_TABLE: [Option; 256] = { mode: AddressMode::AbsoluteX, length: 3, cycles: 4, - format_prefix: "TBD", - format_postfix: "", + format_prefix: "SBC $", + format_postfix: ",X", }); table[ISA_OP_SBC_ABSY as usize] = Some(OpInfo { operation: Operation::SBC, mode: AddressMode::AbsoluteY, length: 3, cycles: 4, - format_prefix: "TBD", - format_postfix: "", + format_prefix: "SBC $", + format_postfix: ",Y", }); table[ISA_OP_SBC_INDX as usize] = Some(OpInfo { operation: Operation::SBC, mode: AddressMode::IndirectX, length: 2, cycles: 6, - format_prefix: "TBD", - format_postfix: "", + format_prefix: "SBC ($", + format_postfix: ",X)", }); table[ISA_OP_SBC_INDY as usize] = Some(OpInfo { operation: Operation::SBC, diff --git a/resources/test/instructions.asm b/resources/test/instructions.asm index 9867705..365eb47 100644 --- a/resources/test/instructions.asm +++ b/resources/test/instructions.asm @@ -15,3 +15,140 @@ AND #$ab ; AND Immediate AND $ab ; AND ZeroPage AND $ab,X ; AND ZeroPageX + AND $abcd ; AND Absolute + AND $abcd,X; AND AbsoluteX + AND $abcd,Y; AND AbsoluteY + AND ($ab,X); AND IndirectX + AND ($ab),Y; AND IndirectY + + ASL ; ASL Accumulator + ASL $ab ; ASL ZeroPage + ASL $ab,X ; ASL ZeroPageX + ASL $abcd ; ASL Absolute + ASL $abcd,X; ASL AbsoluteX + + BCC $ab ; BCC Immediate + BCS $ab ; BCS Immediate + BEQ $ab ; BEQ Immediate + + BIT $ab ; BIT ZeroPage + BIT $abcd ; BIT Absolute + + BMI $ab ; BMI Immediate + BNE $ab ; BNI Immediate + BPL $ab ; BPL Immediate + + BRK ; BRK + + BVC $ab ; BVC Immediate + BVS $ab ; BVS Immediate + + CLC ; CLC + CLD ; CLD + CLI ; CLI + CLV ; CLV + + CMP #$ab ; CMP Immediate + CMP $ab ; CMP ZeroPage + CMP $ab,X ; CMP ZeroPageX + CMP $abcd ; CMP Absolute + CMP $abcd,X; CMP AbsoluteX + CMP $abcd,Y; CMP AbsoluteY + CMP ($ab,X); CMP IndirectX + CMP ($ab),Y; CMP IndirectY + + CPX #$ab ; CPX Immediate + CPX $ab ; CPX ZeroPage + CPX $abcd ; CPX Absolute + + CPY #$ab ; CPY Immediate + CPY $ab ; CPY ZeroPage + CPY $abcd ; CPY Absolute + + DEC $ab ; DEC ZeroPage + DEC $ab,X ; DEC ZeroPageX + DEC $abcd ; DEC Absolute + DEC $abcd,X; DEC AbsoluteX + + DEX ; DEX + DEY ; DEY + + EOR #$ab ; EOR Immediate + EOR $ab ; EOR ZeroPage + EOR $ab,X ; EOR ZeroPageX + EOR $abcd ; EOR Absolute + EOR $abcd,X; EOR AbsoluteX + EOR $abcd,Y; EOR AbsoluteY + EOR ($ab,X); EOR IndirectX + EOR ($ab),Y; EOR IndirectY + + INC $ab ; INC ZeroPage + INC $ab,X ; INC ZeroPage,X + INC $abcd ; INC Absolute + INC $abcd,X; INC AbsoluteX + + INX ; INX + INY ; INY + + JMP $abcd ; JMP Absolute + JMP ($abcd); JMP Indirect + + JSR $abcd ; JSR Absolute + + LDA #$ab ; LDA Immediate + LDA $ab ; LDA ZeroPage + LDA $ab,X ; LDA ZeroPageX + LDA $abcd ; LDA Absolute + LDA $abcd,X; LDA AbsoluteX + LDA $abcd,Y; LDA AbsoluteY + LDA ($ab,X); LDA IndirectX + LDA ($ab),Y; LDA IndirectY + + LDX #$ab ; LDX Immediate + LDX $ab ; LDX ZeroPage + LDX $ab,Y ; LDX ZeroPageY + LDX $abcd ; LDX Absolute + LDX $abcd,Y; LDX AbsoluteY + + LDY #$ab ; LDY Immediate + LDY $ab ; LDY ZeroPage + LDY $ab,X ; LDY ZeroPageX + LDY $abcd ; LDY Absolute + LDY $abcd,X; LDY AbsoluteX + + LSR ; LSR Accumulator + LSR $ab ; LSR ZeroPage + LSR $ab,X ; LSR ZeroPageX + LSR $abcd ; LSR Absolute + LSR $abcd,X; LSR AbsoluteX + + NOP ; The great and powerful NOP + + ORA #$ab ; ORA Immediate + ORA $ab ; ORA ZeroPage + ORA $ab,X ; ORA ZeroPageX + ORA $abcd ; ORA Absolute + ORA $abcd,X; ORA AbsoluteX + ORA $abcd,Y; ORA AbsoluteY + ORA ($ab,X); ORA IndirectX + ORA ($ab),Y; ORA IndirectY + + PHA ; PHA + PHP ; PHP + PLA ; PLA + PLP ; PLP + + ROL ; ROL Accumulator + ROL $ab ; ROL ZeroPage + ROL $ab,X ; ROL ZeroPageX + ROL $abcd ; ROL Absolute + ROL $abcd,X; ROL AbsoluteX + + ROR ; ROR Accumulator + ROR $ab ; ROR ZeroPage + ROR $ab,X ; ROR ZeroPageX + ROR $abcd ; ROR Absolute + ROR $abcd,X; ROR AbsoluteX + + RTI ; Interrupt Return + RTS ; Subroutine Return \ No newline at end of file