pub enum InstructionType {
Show 15 variants
Read,
Write,
ReadModifyWrite,
Implied,
Accumulator,
Branch,
JumpAbsolute,
JumpIndirect,
JumpSubroutine,
ReturnSubroutine,
ReturnInterrupt,
Push,
Pull,
Break,
Jam,
}Expand description
Instruction execution pattern classification.
Different instruction types follow different state sequences:
- Read: Fetch operand, read from effective address
- Write: Fetch operand, write to effective address
- ReadModifyWrite: Read, dummy write old, write new
- etc.
Variants§
Read
Read instructions (LDA, LDX, LDY, AND, ORA, EOR, CMP, ADC, SBC, BIT, LAX, etc.)
Write
Write instructions (STA, STX, STY, SAX, SHA, SHX, SHY, TAS)
ReadModifyWrite
Read-Modify-Write (ASL, LSR, ROL, ROR, INC, DEC, SLO, RLA, SRE, RRA, DCP, ISC)
Implied
Implied/Register operations (TAX, INX, CLC, NOP, etc.) Single-byte instructions with internal operation
Accumulator
Accumulator operations (ASL A, LSR A, ROL A, ROR A) Two-cycle, single-byte
Branch
Branch instructions (BEQ, BNE, BCC, BCS, BPL, BMI, BVC, BVS) 2/3/4 cycles depending on condition and page crossing
JumpAbsolute
Jump Absolute (JMP $NNNN) 3 cycles
JumpIndirect
Jump Indirect (JMP ($NNNN)) 5 cycles
JumpSubroutine
Jump to Subroutine (JSR $NNNN) 6 cycles
ReturnSubroutine
Return from Subroutine (RTS) 6 cycles
ReturnInterrupt
Return from Interrupt (RTI) 6 cycles
Push
Push to Stack (PHA, PHP) 3 cycles
Pull
Pull from Stack (PLA, PLP) 4 cycles
Break
Software Interrupt (BRK) 7 cycles
Jam
JAM/KIL - Halt CPU
Implementations§
Source§impl InstructionType
impl InstructionType
Sourcepub const fn base_cycles(&self) -> u8
pub const fn base_cycles(&self) -> u8
Returns the base number of cycles for this instruction type. This does not include addressing mode cycles or penalties.
Sourcepub const fn has_page_cross_penalty(&self) -> bool
pub const fn has_page_cross_penalty(&self) -> bool
Returns true if this instruction type can have page crossing penalty.
Sourcepub const fn from_opcode(opcode: u8) -> Self
pub const fn from_opcode(opcode: u8) -> Self
Classify an opcode into its instruction type.
This function maps all 256 opcodes (official and unofficial) to their execution pattern type, enabling proper cycle-by-cycle state machine dispatch.
Trait Implementations§
Source§impl Clone for InstructionType
impl Clone for InstructionType
Source§fn clone(&self) -> InstructionType
fn clone(&self) -> InstructionType
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more