mc6809_core/lib.rs
1// Copyright 2026 Martin Ã…kesson
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15//! # emu6809-core
16//!
17//! A Motorola 6809 CPU emulator core.
18//!
19//! Provides a [`Cpu`] that executes 6809 instructions against any
20//! memory system implementing the [`Bus`] trait.
21//!
22//! ## Example
23//!
24//! ```rust
25//! use mc6809_core::{Cpu, Bus};
26//!
27//! struct FlatRam([u8; 65536]);
28//!
29//! impl Bus for FlatRam {
30//! fn read(&mut self, addr: u16) -> u8 { self.0[addr as usize] }
31//! fn write(&mut self, addr: u16, val: u8) { self.0[addr as usize] = val; }
32//! }
33//!
34//! let mut bus = FlatRam([0; 65536]);
35//! // Place a reset vector pointing to 0x0400
36//! bus.0[0xFFFE] = 0x04;
37//! bus.0[0xFFFF] = 0x00;
38//! // Place a NOP at 0x0400
39//! bus.0[0x0400] = 0x12;
40//!
41//! let mut cpu = Cpu::new();
42//! cpu.reset(&mut bus);
43//! assert_eq!(cpu.reg.pc, 0x0400);
44//! cpu.step(&mut bus);
45//! assert_eq!(cpu.reg.pc, 0x0401);
46//! ```
47
48pub mod addressing;
49pub mod alu;
50pub mod bus;
51mod cpu;
52pub mod registers;
53
54pub use bus::{Bus, BusSignals};
55pub use cpu::Cpu;
56pub use cpu::instruction_cycles;
57pub use registers::{ConditionCodes, Registers};
58
59#[cfg(test)]
60mod tests;