vincente adeafa5742 Add POSIX a9/xld/xc9 recreation sources and goldens.
Keep WINTEK/ read-only. Add assembler, linker, compiler driver, hex, runtime asm, reloc S-record docs, tests/golden, Makefile, and a pointer to the Mimic 21-Implementation plan. Ignore host bin/ and object files.
2026-10-18 13:41:26 -05:00

cc09 - Wintek 6809 Cross Assembler, Linker, and C Compiler (Recreation)

Recreation of the classic WINTEK 6809 cross-development tools (A9 assembler, XLD linker, XC9 C compiler driver + passes) for modern macOS and Linux/UNIX.

Key preserved feature: Generation and consumption of Relocatable S-Records. This extended Motorola S-record format (using S4/S8/SD records + augmented S2/S3/S7 payloads) is what allows hand-written 6809 assembly and C-compiler-generated assembly to be freely mixed and fed into the common linker.

  • Original WINTEK tools and files are in the WINTEK/ directory (read-only archive; never modified).
  • All new source, build artifacts, runtime ports, docs, and examples live in the new top-level tree (src/, bin/, lib/, include/, docs/, etc.).
  • Results intended for http://gitea.binary-systems.com/vincente/cc09

Status

  • AGENTS.md created with full mission instructions.
  • New directory structure established.
  • Analysis of original via strings, hexdumps, and S-record parsing of KRCSTART.REL + *LIB9.LIB (see docs/reloc-srecords.md).
  • Portable C implementation of the critical relocatable S-record writer/reader.
  • a9 (assembler) - CLI + banners + basic assembly of runtime sources + emits proper extended S-record .rel objects.
  • xld (linker) - CLI + banners + consumes .rel (and would handle .lib), produces absolute S-records (.mik style) + map.
  • xc9 (driver stub) - CLI + orchestration notes; real multi-pass C front-end/codegen is large future work (original used Lattice-derived passes + 6809-specific cg emitting many .L* .D* .F* runtime calls).
  • hex (PROM/S-record filter) stub with original options and help text.
  • Runtime sources from the original kit staged under lib/src/ (cstart.asm, chario.asm, clrio.asm, stdio.asm + headers) for testing and porting.
  • include/stdio.h etc. for C work.
  • Build system: simple portable Makefile (make, make test, make asm-test).

The assembler and linker already demonstrate round-tripping small sources through the reloc S-record format into absolute S-records, which is the heart of being able to combine Assembly + C objects.

Full instruction coverage, expression/relocation engine, macros, conditionals, listing fidelity, complete C passes, and the numeric/long/float runtime support library will be expanded iteratively. The original EXEs were used (via strings + behavioral artifacts) to capture exact messages, usage, versions (A9 3.1r0, XC 2.1r0 / driver 1.0r3), section names (PSCT/DSCT/BSCT/ASCT), directives, and error texts.

Building

make
make test
make asm-test          # assemble one of the staged runtime .asm files

Produces:

  • bin/a9, bin/xld, bin/xc9, bin/hex

Install (optional):

make install PREFIX=/usr/local

Basic Usage (matching original)

Assembler:

a9 file.asm -l file.lst -o file.rel
a9 file1.asm file2.asm -o combined.rel -nh

Linker:

xld file.rel -o image.mik -map image.map
xld -v -d my.dir -l rnlib9.lib -l krlib9.lib main.rel -o app.mik

C driver (currently notes + default.dir generation):

xc9 foo.c -list -map foo.map

PROM filter:

hex -S 0xC000 0xFFFF < image.mik > prom.srec

See original WINTEK/.DIR and BATCH_ (read-only) for realistic multi-section memory maps and build flows.

Relocatable S-Records

The object format is text S-records with Wintek extensions. Documented in docs/reloc-srecords.md.

This is what makes the "common linker for asm and C" possible:

  • A9 emits .rel containing S0 (module), S8 (symbols), S4 (section meta), S2 (section-tagged chunks with code + zero placeholders for fixups), S7 (chunk ends), SD, S9.
  • .lib files are simply concatenated objects.
  • XLD reads them, allocates per SECTION/MODULE directives (or defaults), resolves externals across user files + libraries, applies 6809-specific relocs, and writes normal absolute S1/S9 output.

Runtime & C Support

The provided assembly sources (CSTART, CHARIO, CLRIO, ...) illustrate:

  • Special C startup (.CSTRT), stack in DSCT, .clrio init.
  • The .LINK calling convention (A = param byte count before JSR; special epilog).
  • ACIA character I/O customization points.
  • Compiler helper symbols that must be provided by rnlib9-style library (longs, floats, mul/div, switches, etc.).

lib/src/ contains the originals for reference/porting. Re-assembling them with the new a9 and linking should (as the tools mature) produce compatible images.

Reverse Engineering Notes

  • Primary technique: strings WINTEK/*.EXE, hexdump + python S-record parsers on the .REL/.LIB/.MIK, inspection of the small .ASM/.H/.DIR sources.
  • Attempted full 16-bit disassembly via ndisasm on extracted segments (after MZ header) and dosbox execution for golden outputs on crafted tests (dosbox + nasm available via brew but not required for basic recreation).
  • The EXE sources themselves are lost; this is a behavior-and-format-compatible reimplementation in portable C.

Directory Layout (New)

See AGENTS.md for the intended complete tree. Current layout includes src/{a9,xld,xc9,common}, bin/, lib/src/, include/, docs/, examples/, tests/.

Do not edit anything under WINTEK/.

Future / Help Wanted

  • Complete 6809 assembler (all modes, auto long/short branches, full indexed postbytes, register lists, relocatable expression rules, macros with NARG, full conditionals, listing with pagination/symbol table).
  • Robust XLD with real memory reservation, library search via S8 records, fixup application, multiple section contribs per module, warning texts, etc.
  • Real XC9 passes (or integration of an external 6809 C compiler that can be driven to emit a9-compatible asm + the runtime call symbols).
  • Port/build of the full runtime libs (KRLIB9 / RNLIB9) as .rel archives.
  • More tests + golden outputs captured from original EXEs under emulation.
  • Polish, man pages, etc.

License / Provenance

Preservation project. Original tools Copyright 1986 Wintek Corporation (defunct). New code here is original work to enable continued development of 6809-based systems.

Upload target: http://gitea.binary-systems.com/vincente/cc09

Contributions should keep WINTEK/ pristine and update AGENTS.md + docs/ as format/behavior discoveries are made.

S
Description
A recreation of the Wintek C compiler for the 6809
Readme 200 KiB
Languages
C 79.2%
Assembly 18.2%
Makefile 2.4%
Component Pascal 0.2%