Skip to content

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.

DCC C Compiler banner

Key Features

  • Cross-platform toolchain: build CP/M .COM programs 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=true to 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.

DCC source debugging in VS Code with a breakpoint, local variables, Z80 registers, call stack, and debug controls

This manual describes the language accepted by the DCC C Compiler, the runtime library, and the build path from C source to .COM file.

Runtime

DCCRTL.MAC is the runtime. It is Z80 assembly in M80/L80 syntax. It supplies:

  • the start entry point, which sets up the heap and calls main,
  • command-line parsing for argc and argv,
  • 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.

CP/M 2.2 benchmark comparison

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.