Initial mimic09: fast 6809/6309 emulator + C64-style monitor + SREC/IHEX loader + ACIA/PIA

- Complete project skeleton per AGENTS.md (src/, bin/, samples/, attic/ with 1994 code, docs/)
- High-performance C core (cpu.c) with most 6809 instructions + selected 6309
- Table-driven disassembler (D) and minimal built-in assembler (A)
- Full C64-monitor inspired debugger (R ; M : D A G S B BC F L S ! X ?)
  - Single step, breakpoints (exec), register/memory view+edit
- Robust S-Record, Intel HEX, raw binary load/save (tolerant of CRLF)
- 6850 ACIA and 6821 PIA emulation (memory-mapped, registered devices)
- CLI: -l load, -g go, -i interactive, --cpu 6309, --acia/--pia bases
- Designed for tight integration with cc09 (WINTEK re-creation)
- Optimized Makefile for macOS/Linux (clang/gcc, -O3 -flto -march=native)
- AGENTS.md with mission, structure, coding rules, monitor reference

Verified: builds release+debug, loads provided samples (140A.HEX 2299.HEX 2299.MIK), monitor commands, A/D/S/B, roundtrip save/load.

Remote: http://gitea.binary-systems.com/vincente/mimic
This commit is contained in:
2026-06-12 14:59:59 -05:00
parent 1710066010
commit 78b8838cc7
27 changed files with 5381 additions and 0 deletions
+107
View File
@@ -0,0 +1,107 @@
# mimic09 — Fast Motorola 6809/6309 Emulator with C64-Style Monitor
**mimic09** is an extremely efficient 6809 and 6309 emulator for macOS and UNIX/Linux. It includes a powerful built-in debugger/monitor inspired by classic Commodore 64 machine language monitors, a built-in assembler/disassembler, S-Record + Intel HEX + binary loaders, and emulation of the 6850 ACIA and 6821 PIA.
It is designed to work hand-in-hand with the **cc09** project (the modern recreation of the WINTEK 6809 assembler and C compiler).
## Quick Start
```bash
make # optimized release build → bin/mimic09
make debug # for development
./bin/mimic09 -h
./bin/mimic09 -i # enter interactive monitor immediately
./bin/mimic09 -l samples/2299.HEX -g # load and go (if it has a sensible start vector)
```
In the monitor you will see a prompt (e.g. `m9>`). Type `?` for help.
## Key Features
- Full 6809 instruction set + major 6309 extensions
- Very high performance interpreter (tuned for modern CPUs)
- C64-style monitor/debugger:
- Single step, step-over, breakpoints
- Memory view/edit (M / : )
- Disassemble (D) and Assemble (A) — round-trippable
- Register view/edit (R / ;)
- Load/Save S-Records, Intel HEX, raw binary
- 6850 ACIA and 6821 PIA emulation (configurable base addresses)
- Excellent for running and debugging code produced by cc09
## Monitor Commands (C64-inspired)
```
R show registers + flags
; <new values> edit registers (copy/paste from R line)
M <addr> [len] dump memory (hex + ASCII)
:<addr> <bytes...> write bytes starting at addr
D [addr] [count] disassemble
A <addr> <mnemonic> assemble one line (e.g. A 1000 LDA #$2A)
G [addr] run (until breakpoint or Ctrl-C)
S [n] single-step n instructions (default 1)
N step over (JSR/BSR/BSR counted as one)
B [addr] set/clear breakpoint (no addr = list)
BC clear all breakpoints
L <file> [addr] load SREC / IHEX / BIN (addr forces raw load)
S <file> <start> <end> [S19|IHEX|BIN]
F <s> <e> <val> fill
H <s> <e> <pat...> hunt (search)
! <cmd> run shell command
? or H help
X or Q quit
```
While a program is running (after `G`), Ctrl-C will usually return you to the monitor.
## Loading Programs
mimic09 understands:
- Motorola S-Records (`.s19`, `.srec`, many `.HEX` files from 6809 tools)
- Intel HEX (`.hex`)
- Raw binary (use `L foo.bin 0xC000` to load at a specific address)
After loading, set the PC (`; PC=xxxx` or use the `G xxxx` form) or let the reset vector (usually at 0xFFFE) be used.
## ACIA / Serial Console
When your 6809/6309 code uses a 6850 ACIA for I/O, mimic09 can wire it to your terminal during `G` runs. Use the `-acia 0xA000` (or whatever base your code expects) flag.
Simple programs that do polled serial I/O will "just work" for interactive debugging.
## Building & Installing
```bash
make
make debug
sudo make install PREFIX=/usr/local
```
The binary is `bin/mimic09`. A convenience symlink `mimic` is also created by install.
## Interfacing with cc09
1. Build your program with the cc09 toolchain → produces S-Record or binary + optional listing.
2. `mimic09 -l myprog.s19`
3. In the monitor: set breakpoints, inspect, single-step.
4. `G` to run at full speed with emulated peripherals.
5. Capture ACIA output or interact live.
This gives you a very fast "edit–assemble–debug on real 6809 semantics" loop on a modern machine.
## Status
This is an active re-creation and modernization of the 1994 "mimic09" effort. The original incomplete sources live in `attic/`.
Core goals: correctness + extreme speed + delightful C64-monitor debugging experience.
## License
See LICENSE (heritage code fragments retain original copyright notices where applicable; new code is under the terms in LICENSE).
## Links
- Repository: http://gitea.binary-systems.com/vincente/mimic
- Companion: cc09 (Wintek 6809 toolchain recreation)
Enjoy the 6809 on modern iron.