4 releases

Uses old Rust 2015

0.2.2 Apr 11, 2021
0.2.1 Jan 2, 2017
0.2.0 Aug 31, 2016
0.1.0 Aug 30, 2016

#763 in Encoding

33 downloads per month
Used in 2 crates

MIT/Apache

49KB
593 lines

disasm6502

Crates.io Documentation Build Status Build status Coverage Status

A crate providing functionality to disassemble 6502 binary code. Supports decoding of forbidden instructions, provides information about cycle count, which registers the instruction accesses and which status flags are affected. Acceptable data input can be either an array of bytes, a vector of bytes or a binary file.

Documentation

Usage

# Cargo.toml
[dependencies]
disasm6502 = "0.2"

Example

extern crate disasm6502;

fn main()
{
    let bytes = vec![0x05, 0x0B, 0x6C, 0x01, 0x02,
                     0x0A, 0xA2, 0xFF, 0x20, 0x02,
                     0xFD, 0x78, 0xD0, 0xFC, 0x1D,
                     0x05, 0x1E, 0x04, 0x15, 0x02,
                     0x96, 0xAB, 0x58, 0x61, 0x01,
                     0x91, 0xFB];

    // disassemble...
    let instructions = disasm6502::from_array(&bytes).unwrap();

    // ...and print!
    for i in instructions.iter() {
        println!("{}", i);
    }
}

Build instructions

cargo build
cargo run --example disasm6502

This will run the example which produces the following output:

$0000: 05 0B    ORA $0B           (3)  Reads:[A]    Writes:[A]    Affects:[NZ]
$0002: 6C 01 02 JMP ($0201)       (5)                             
$0005: 0A       ASL A             (2)  Reads:[A]    Writes:[A]    Affects:[NZC]
$0006: A2 FF    LDX #$FF          (2)               Writes:[X]    Affects:[NZ]
$0008: 20 02 FD JSR $FD02         (6)                             
$000B: 78       SEI               (2)                             Affects:[I]
$000C: D0 FC    BNE $000A         (*4)                            
$000E: 1D 05 1E ORA $1E05,X       (*5) Reads:[AX]   Writes:[A]    Affects:[NZ]
$0011: 04 15    NOP $15       ??? (3)                             
$0013: 02       HLT           ??? (1)                             
$0014: 96 AB    STX $AB,Y         (4)  Reads:[XY]                 
$0016: 58       CLI               (2)                             Affects:[I]
$0017: 61 01    ADC ($01,X)       (6)  Reads:[AX]   Writes:[A]    Affects:[NVZC]
$0019: 91 FB    STA ($FB),Y       (6)  Reads:[AY]                 
$001B: .END

License

Licensed under either of

No runtime deps