/mini6502

6502 processor emulation library

Primary LanguageRust

mini6502

A lightweight and simple 6502 emulation library.

Build Status

Example

use mini6502::{Cpu, SimpleMemory}

let rom : Vec<u8> = std::fs::read("my_rom.bin").unwrap();

let memory = SimpleMemory::from_rom(&rom);

let mut cpu = Cpu::with_mem(memory);

let stdin = std::io::stdin();

// Pass a closure that will be run every time before stepping an instruction.
cpu.run(|cpu: &Cpu<SimpleMemory>|{
    println!("{cpu}");
    //      Instruction: LDA
    //      Registers:
    //      PC 0x0600
    //      AC 0x00
    //      X: 0x00
    //      Y: 0x00
    //      SP:0x00ff
    //
    //      Flags:
    //      NV-BDIZC
    //      01110001

    // Stop until PC reaches 0x35db
    cpu.pc() == 0x35db
})

Implementation checklist

  • Official opcodes
  • "Illegal" opcodes
  • Decimal mode