My Rust learning project writing a simple 6502 emulator.
⚠️ Although there are some unit tests, the functionality is not yet completely tested or proven. And some functionality such as BCD mode still needs to be implemented. This is just a tinkering project - don't expect too much!
Key data:
- Memory size:
64K
- Stack:
0x0100
to0x01FF
- Reset vector address:
0xE000
cargo build --release
This results in the release binary ./target/release/rust-6502-emu
.
Usage: rust-6502-emu [OPTIONS]
Options:
-c, --cycles <CYCLES> Cycles to execute
-d, --demo Load demo data
-f, --file <FILE> Load data from file
-i, --interactive Interactive mode
-v, --verbose... Verbosity; can be specified multiple times
-h, --help Print help
-V, --version Print version
Running an example program:
./target/release/rust-6502-emu -f examples/fibonacci.bin
Running an example program step-by-step in interactive mode:
./target/release/rust-6502-emu -i -f examples/fibonacci.bin
Running with demo code:
./target/release/rust-6502-emu -d
Running without a program initialized in memory is less exciting, as we're hitting a BRK as first instruction:
./target/release/rust-6502-emu
There are some example programs in ./examples
including a Makefile. CC65 is used for assembling and linking.
Pre-built *.bin
files can be loaded using the -f <binfile>
option.
The examples can be (re)build using make all
.
- https://en.wikipedia.org/wiki/MOS_Technology_6502
- https://www.masswerk.at/6502/6502_instruction_set.html
- https://web.archive.org/web/20190925014923/http://www.obelisk.me.uk/6502/
- https://sta.c64.org/cbm64mem.html
- https://www.nesdev.org/wiki/Status_flags
- https://www.pagetable.com/?p=410
- https://en.wikibooks.org/wiki/6502_Assembly
- https://codeburst.io/running-programs-on-the-apple-ii-cc183aab268
- https://en.wikipedia.org/wiki/Interrupts_in_65xx_processors
- Testing