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
- A
Memorytrait for pluggable memory and I/O backends - A
Clockedtrait for peripheral timing and interrupt signal delivery, kept separate from memory access - Lightweight API suitable for embedding in emulators, disassemblers, and debuggers
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 Clocked::tick is called separately by the host loop.
The preferred way to feed signals into the CPU is Cpu::apply_signals, which handles
NMI edge detection internally:
let mut prev_signals = default;
loop
The individual cpu.set_irq(), cpu.set_firq(), and cpu.trigger_nmi() methods are
still available for simpler setups where NMI edge detection is handled by the caller.
Behavior notes
- Illegal opcodes set
Cpu::illegal()but do not halt the CPU. This matches the default 6809-style execution model and leaves trap/stop policy to the host. - Repeated page-prefix chaining (
0x10/0x11after an initial page prefix) is intentionally not implemented. Only a single leading page prefix is recognised.
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.