mc6809-core
mc6809-core is a small, focused Rust library implementing the Motorola 6809 CPU for use in emulators, tools, and testing harnesses. It provides a Cpu implementation capable of executing 6809 instructions against any memory system that implements the Memory trait.
Features
- Accurate 6809 instruction execution and addressing modes
- Modular design: separate
alu,addressing,bus,registersmodules - A
Memorytrait for pluggable memory and I/O backends - A
Bustrait for peripheral timing and interrupt signal delivery, kept separate from memory access - Lightweight API suitable for embedding in emulators, disassemblers, and debuggers
Public modules
addressing— addressing mode helpersalu— arithmetic and logic operationsbus—Memorytrait for address/data bus access;Bustrait for peripheral tick and interrupt signalsregisters— CPU register and status types
Quick example
use ;
;
let mut mem = FlatRam;
// Place a reset vector pointing to 0x0400
mem.0 = 0x04;
mem.0 = 0x00;
// Place a NOP at 0x0400
mem.0 = 0x12;
let mut cpu = new;
cpu.reset;
assert_eq!;
cpu.step;
assert_eq!;
Systems with peripherals implement both traits on the same type. The Memory trait is
passed to the CPU, while Bus::tick is called separately by the host loop:
let signals = system.tick;
cpu.set_irq;
cpu.set_firq;
Building and testing
- Build:
cargo build(run in the workspace or this crate) - Test:
cargo test
Contributing
- Contributions, bug reports and improvements are welcome — open an issue or pull request in the main repository.