Crates.io | yamos6502 |
lib.rs | yamos6502 |
version | 0.1.4 |
source | src |
created_at | 2023-03-05 08:20:20.541156 |
updated_at | 2023-12-30 22:30:19.918241 |
description | MOS 6502 emulator |
homepage | https://github.com/kromych/yamos6502 |
repository | https://github.com/kromych/yamos6502 |
max_upload_size | |
id | 801160 |
size | 111,130 |
This emulator is geared towards an easy integration with the no_std
Rust projects
to run in the environment where is no OS. That said, it should be very easy to use
in the std
projects, too, as demonstrated by the examples below. A great emphasis
has been put on the clean implementation. Some bit twiddling has been employed in
few places to make the code branchless and hopefully even more performant.
The emulator comes with some unit-tests tests (work in progress), and most notably, it passes the 6502 functional tests.
This emulator strives to perform computation to the letter of the specification which is stricter than the real hardware and 6502 netlist-based emulators such as Perfect 6502 do. In short, this is not a hardware simulator.
The emulation algorithm is quite simple:
That said, there is no emulation of the microarch layer, e.g., no:
Stack underflows and overflows might be set to result in a fault, and the emulator will not continue execution until it is reset.
It goes without saying that the glitches at the physical layer are not emulated, too :)
Add
yamos6502 = "0.1"
to your project's Cargo.toml
. If you intend not to depend on the std
crate, here is the syntax to use instead:
yamos6502 = { version = "0.1", default_features = false }
yamos6502e
Usage: yamos6502e [OPTIONS] <MEM_FILE_LIST>
Arguments:
<MEM_FILE_LIST>
Paths to the files to seed the memory with.
Format is (path[:load_addr_hex_no_0x],)+, load addresses must increase, and the loaded files must not overlap.
Options:
--rom-start <ROM_START>
ROM start. Writes into ROM will cause an error.
[default: 65535]
--reset-pc <RESET_PC>
Initial program counter
[default: 1024]
--exit-pc <EXIT_PC>
Program counter at which exit
[default: 13417]
--stack-wraparound
Allow stack wraparound
--print-stats <PRINT_STATS>
Print statistics after execution every `print_stats` instructions
[default: 0]
--pause-millis <PAUSE_MILLIS>
Pause in milliseconds between executing instructions
--dead-loop-iterations <DEAD_LOOP_ITERATIONS>
Dead loop iterations before exit
[default: 65536]
--log <LOG>
Logging level
[default: info]
[possible values: info, debug, trace]
-h, --help
Print help (see a summary with '-h')
-V, --version
Print version
To run the 6502 functional tests and print staticstics every 15_000_000 instructions:
#
# Assuming https://github.com/Klaus2m5/6502_65C02_functional_tests is cloned one directory above:
#
# `git clone https://github.com/Klaus2m5/6502_65C02_functional_tests ../6502_65C02_functional_tests
#
cargo run --example yamos6502e \
../6502_65C02_functional_tests/bin_files/6502_functional_test.bin:0000 \
--print-stats 15000000 \
--reset-pc 0x400 \
--exit-pc 0x3469 \
--stack-wraparound \
--dead-loop-iterations 16
Building with --release
produces a much faster emulator at the cost of omitting some runtime
checks.