Skip to main content

disassemble_one

Function disassemble_one 

Source
pub fn disassemble_one(
    peek: impl FnMut(u32) -> u8,
    pbr: u8,
    pc: u16,
    m8: bool,
    x8: bool,
) -> (String, usize)
Expand description

Disassemble one instruction at pbr:pc.

Reads operand bytes via peek (a 24-bit-address byte accessor — prefer a genuinely side-effect-free peek, e.g. Bus::peek_*, over a real bus read where one is available). m8/x8 are crate::regs::Regs::m8/crate::regs::Regs::x8 (true = 8-bit width) — needed because LDA #-style immediates are 1 or 2 operand bytes depending on them.

Returns (text, length): a human-readable "MNEMONIC operand" string, and the total instruction length in bytes (opcode + operand, always >= 1) so a caller can advance to the next instruction without re-decoding.

§Panics

Never in practice: the only unwrap/slice-conversion is over a fixed 2-byte prefix of the local 3-byte op buffer, never over caller-controlled data.