https://github.com/alexander-akhmetov/mos6502
MOS 6502 CPU emulator
https://github.com/alexander-akhmetov/mos6502
cpu cpu-emulator mos6502
Last synced: 12 months ago
JSON representation
MOS 6502 CPU emulator
- Host: GitHub
- URL: https://github.com/alexander-akhmetov/mos6502
- Owner: alexander-akhmetov
- Created: 2019-05-11T13:02:23.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2025-05-23T18:59:43.000Z (about 1 year ago)
- Last Synced: 2025-05-23T19:34:12.475Z (about 1 year ago)
- Topics: cpu, cpu-emulator, mos6502
- Language: Rust
- Size: 92.8 KB
- Stars: 6
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# MOS 6502 CPU emulator
Simple emulator of the [MOS 6502](https://en.wikipedia.org/wiki/MOS_Technology_6502) CPU.
I used it to build an [Apple-1](https://github.com/alexander-akhmetov/apple1) emulator.
## Usage
```rust
let mut cpu = mos6502::cpu::CPU::new();
let program = "LDA #$c0
TAX
INX
ADC #$c4";
// you can skip this step,
// if you load an assembled machine code
let bytes = mos6502::asm::assemble(&program);
cpu.load(&bytes, 0x800);
cpu.run();
```
## Tests
Run tests:
```shell
cargo test
```
### Functional tests
You can download functional tests from this [repository](https://github.com/Klaus2m5/6502_65C02_functional_tests).
Put the `6502_functional_test.bin` file to the root of the repository and then run:
```shell
wget "https://github.com/Klaus2m5/6502_65C02_functional_tests/blob/master/bin_files/6502_functional_test.bin?raw=true" -O 6502_functional_test.bin
make functional-tests
```
## Resources
* [6502 instruction set](https://www.masswerk.at/6502/6502_instruction_set.html#BIT)
* [6502 memory test](http://www.willegal.net/appleii/6502mem.htm)
* [6502 instructions description with undocumented commands](http://www.zimmers.net/anonftp/pub/cbm/documents/chipdata/64doc)