vincente 45182c7759 Fixes + enhancements from test feedback
- Mini-assembler now supports many more common inherent ops (CLRA/CLRB, INCA/INCB, DECA/DECB, COMA/COMB, NEGA/NEGB, TSTA/TSTB, plus several branches: BEQ/BNE/BCC/BCS/BPL/BMI) so quick monitor patches like the classic loop test cases work without falling back to : or M.
- Critical: monitor no longer uppercases the entire input line. command_char() only uppercases the dispatch verb (first significant char). This preserves original case for:
  - Filenames in L and S commands
  - Shell commands after !
  - Any future string arguments
- Improved S dispatch heuristic (Step vs Save) so 'S filename ...' and 'S 5' are reliably distinguished even with mixed-case filenames.
- Added explicit exec-bp check at the top of the monitor G run loop (in addition to the one inside cpu_step). This guarantees that breakpoints set with B are honored during G even when running with debug_mode=false for speed.
- The exact scenarios from the previously killed background tasks (infinite BRA loop + bp, F + S + L + M roundtrip) now complete cleanly, quickly hit bps, restore the terminal, and leave the outer shell fully functional.

All prior robustness (always acia_end_run after G, isatty guards, etc.) remains.
2026-06-12 15:07:08 -05:00
…
…
…

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

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

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).

Enjoy the 6809 on modern iron.

S
Description
6809/6309 Emulator and Debugger
Readme 102 KiB
Languages
C 95.4%
C++ 3.1%
Makefile 1.5%