Struct Disassembler

Source
pub struct Disassembler { /* private fields */ }

Implementations§

Source§

impl Disassembler

A 6502 instruction disassembler

Source

pub fn new() -> Disassembler

Creates a new, default instance of the Disassembler

§Example
use rs6502::Disassembler;

let dasm = Disassembler::new();

let code: Vec<u8> = vec![0xA9, 0x20, 0x8D, 0x00, 0x44];
let asm = dasm.disassemble(&code);

assert_eq!(Disassembler::clean_asm("

    0000 LDA #$20
    0002 STA $4400

"), Disassembler::clean_asm(asm));
Source

pub fn with_code_only() -> Disassembler

Creates an instance of the Disassembler where no byte offsets are generated in the Assembly output

§Example
use rs6502::Disassembler;

let dasm = Disassembler::with_code_only();

let code: Vec<u8> = vec![0xA9, 0x20, 0x8D, 0x00, 0x44];
let asm = dasm.disassemble(&code);

assert_eq!(Disassembler::clean_asm("

    LDA #$20
    STA $4400

"), Disassembler::clean_asm(asm));
Source

pub fn with_verbose_output() -> Disassembler

Creates an instance of the Disassembler with all available information generated into the output

§Example
use rs6502::Disassembler;

let dasm = Disassembler::with_verbose_output();

let code: Vec<u8> = vec![0xA9, 0x20, 0x8D, 0x00, 0x44];
let asm = dasm.disassemble(&code);

assert_eq!(Disassembler::clean_asm("

    0000 A9 20    LDA #$20
    0002 8D 00 44 STA $4400

"), Disassembler::clean_asm(asm));
Source

pub fn with_offset(offset: u16) -> Disassembler

Source

pub fn disassemble(&self, raw: &[u8]) -> String

Source

pub fn disassemble_with_addresses(&self, raw: &[u8]) -> Vec<(String, u16)>

Accepts a slice of 6502 bytecodes and translates them into an assembly String representation

§Example
use rs6502::Disassembler;

let dasm = Disassembler::new();

let code: Vec<u8> = vec![0xA9, 0x20, 0x8D, 0x00, 0x44];
let asm = dasm.disassemble(&code);

assert_eq!(Disassembler::clean_asm("

    0000 LDA #$20
    0002 STA $4400

"), Disassembler::clean_asm(asm));
Source

pub fn clean_asm<I>(input: I) -> Vec<String>
where I: Into<String>,

Returns a Vector of Strings where each entry is a non-empty line of assembly instructions, with all leading and trailing whitespace removed.

§Example
use rs6502::Disassembler;

assert_eq!(Disassembler::clean_asm("

    0000 LDA #$20
    0002 STA $4400

"), &["0000 LDA #$20", "0002 STA $4400"]);

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.