Struct disasm6502::instruction::Instruction [] [src]

pub struct Instruction {
    pub opcode: OpCode,
    pub cycles: u8,
    pub addr_mode: AddrMode,
    pub address: u16,
    pub operand: Option<u16>,
    pub extra_cycle: bool,
    pub illegal: bool,
    pub registers_read: RegVec,
    pub registers_written: RegVec,
}

Decoded 6502 instruction.

Fields

instruction opcode

cycle count for the instruction

instruction addressing mode

address of the instruction in memory buffer

optional instruction operand

instruction may take an extra cycle if zero page boundary is crossed

instruction is illegal/undocumented

registers read by this instruction (optional)

registers written by this instruction (optional)

Methods

impl Instruction
[src]

Convert instruction to fixed length string of hex values (opcode + operand, if applicable).

Examples

extern crate disasm6502;

let memory = vec![0x05, 0x0B, 0x6C, 0x01, 0x02];

// set program counter to 0 - will decode first instruction
let mut pc: usize = 0;

// interprets 0x05 as an instruction, places it at $0800
let instruction = disasm6502::instruction::decode(0x0800, &mut pc, &memory);

// prints: "0x05 0x0B   " (instruction + operand value)
println!("{}", instruction.as_hex_str());

Convert instruction to assembler mnemonic.

Examples

extern crate disasm6502;

let memory = vec![0x05, 0x0B, 0x6C, 0x01, 0x02];

// set program counter to 0 - will decode first instruction
let mut pc: usize = 0;

// interprets 0x05 as an instruction, places it at $0800
let instruction = disasm6502::instruction::decode(0x0800, &mut pc, &memory);

// prints: "ORA $0B"
println!("{}", instruction.as_str());

Trait Implementations

impl Display for Instruction
[src]

Formats the value using the given formatter.