Introduction¶
DCC C Compiler is an open source C compiler for CP/M 2.2 on the Z80. It supports C89 plus CP/M-relevant C99/C11 features. For every source
file it accepts, the DCC C Compiler translates the .c file to M80 assembly; M80 assembles the
result, and L80 links it into a CP/M .COM program.
The DCC C Compiler runs on Windows, macOS, and Linux, but the programs it builds run under CP/M. The ntvcm emulator and other popular CP/M Z80 emulators run those programs, as do real Z80 CP/M 2.2 and 3.0 systems.
Key Features¶
- Cross-platform toolchain: build CP/M
.COMprograms on Windows, macOS, or Linux with a single dccmake command. - C89-based language with selected C99/C11 additions: use Boolean types, designated initializers, variadic macros, static assertions, and a supported subset of variable-length arrays. The conformance guide distinguishes supported features from partial support and target exceptions.
- Optimizing Z80 code generation: MIR-based optimization, a separate peephole pass, and whole-program reachability analysis remove unnecessary code and runtime routines. See compiler architecture and runtime optimization.
- Small, tailored runtime: standard-library headers cover file and console I/O, allocation, strings, and single-precision math. Formatted-output support is selected per call; CP/M services provide access to the underlying operating system.
- Source-level debugging for VS Code and AI agents: both can use the debugger to investigate issues with breakpoints, watches, call stacks, memory inspection, and Z80 disassembly. Full debug builds favor inspectability; optimized debug builds retain release code generation.
- Optional stack checks: enable
dcc-stack-check=trueto detect stack reserve overflow, including supported VLA allocations.
A small-machine C implementation
DCC is not a fully conforming hosted C99/C11 implementation. Integers and
pointers are 16-bit, long is 32-bit, and float is the only floating
type. CP/M file semantics and library subsets differ from desktop C;
start with Types and conventions and
Limitations when porting code.
Whole-program dead-code elimination
Normal dccmake builds enable LTO-style reachability analysis across every
C source module. Uncalled functions, unused initialized globals/statics, and
unused BSS objects in helper modules are removed before assembly; their
otherwise-unused runtime dependencies disappear as well. Automatic local
variables are optimized earlier by the compiler's MIR passes rather than by
this whole-program step. See
Application and runtime optimization.
Integrated VS Code debugging
Debug DCC programs directly in Visual Studio Code with source breakpoints, source and instruction stepping, call stacks, variables and watches, memory inspection, and linked Z80 disassembly. See VS Code debugging for setup and usage.
This manual describes the language accepted by the DCC C Compiler, the runtime library, and the
build path from C source to .COM file.
- Start with Setting up the toolchain.
- See Building and linking for the normal build flow.
- See C conformance and target exceptions, Types and conventions, and Operators for the language rules.
- Use the library reference for assert.h, ctype.h, errno.h, float.h, limits.h, locale.h, math.h, setjmp.h, signal.h, stdarg.h, stdbool.h, stddef.h, stdint.h, stdio.h, stdlib.h, string.h, time.h, and system / CP/M services.
- Read Limitations before depending on hosted-C behavior.
- Try the worked examples when you want complete programs.
- Use Agentic skills if you want an AI assistant to load the DCC C Compiler rules while working in another project.
Runtime¶
DCCRTL.MAC is the runtime. It is Z80 assembly in M80/L80 syntax. It supplies:
- the
startentry point, which sets up the heap and callsmain, - command-line parsing for
argcandargv, - the supported C library routines,
- integer and floating-point helpers used by generated code.
Normal builds also trim unused runtime routines before linking. The build steps
are shown in Building and linking; the reachability
details are in the dccrtlstrip appendix.
The library reference lists the shipped declarations and explains their target behavior. A familiar C or POSIX function name does not imply desktop semantics; check its reference page and Limitations before porting code.
Performance Snapshot¶
The chart compares .COM programs produced by the DCC C Compiler with CP/M-era and modern
CP/M-targeting compilers. Times come from ntvcm -p cycle counts converted to
the emulator's approx ms at 4Mhz value for Z80-mode runs. Sizes are CP/M file
sizes rounded to 128-byte records. Lower is better for ms and bytes.
The benchmark names are the test programs: strings and memory (tstring),
sieve, digits of e, allocation (tm), tic-tac-toe (ttt), hexadecimal pi
digits (pihex), and matrix multiply (mm). Rows labelled xcomp are DCC C Compiler
output before dccpeep; rows labelled dccpeep optimized are after the
optimizer pass.
Engineering Notes¶
DCC C Compiler was engineered agentically using VS Code GitHub Copilot and Claude Code for VS Code, with plenty of human intelligence, supervision, experience, and patience. It is unit tested against baselines grounded in modern C compilers and a platform-appropriate subset of the community-driven c-testsuite.
Contributions and Feedback Welcome¶
This is an open source C compiler. Community contributions are welcome; please report issues through the project's GitHub Issues page.
Star the Repository¶
If the DCC C Compiler is useful to you, please consider starring the GitHub repository. It helps other CP/M and Z80 developers find the project.

