kondrak / disasm6502

6502 disassembler

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

disasm6502

Crates.io Documentation build 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

About

6502 disassembler

License:MIT License


Languages

Language:Rust 100.0%