Skip to main content

ucow

A Python-based Cowgol compiler targeting Z80 CP/M.

Usage

Single File Compilation

# Compile a Cowgol source file to Z80 assembly
python3 -m src.main source.cow -o output.mac

# Assemble with um80
um80 output.mac

# Link with ul80
ul80 output.rel -o output.com

Multi-File Compilation

Compile multiple Cowgol source files together in a single compiler run:

# Compile all modules together into one assembly file
python3 -m src.main main.cow utils.cow math.cow -o program.mac

# Assemble and link
um80 program.mac
ul80 program.rel -o program.com

This approach enables workspace optimization: the compiler analyzes the call graph across all modules to determine which subroutines can never be active simultaneously. Subroutines that don't overlap in the call tree share local variable storage, significantly reducing data segment size.

For example, if sub_a and sub_b each use 100 bytes of locals but never call each other, they share the same 100 bytes instead of using 200 bytes total.

Use --graph-debug to see the call graph analysis:

python3 -m src.main --graph-debug main.cow lib.cow -o output.mac

Include Paths

Use -I to add directories to the include search path:

python3 -m src.main -I ./lib -I ./include source.cow -o output.mac

Compiler Options

Option Description
-o OUTPUT Output assembly file name
-I PATH Add include search path
-O0 Disable optimization
--no-post-opt Disable post-assembly optimization
--graph-debug Show call graph analysis
--tokens Dump tokens and exit
--ast Dump AST and exit

Requirements

  • Python 3
  • um80 (Z80 assembler)
  • ul80 (linker)
  • cpmemu (for testing)

Related Projects

  • 80un - Unpacker for the CP/M archive and compression formats LBR, ARC, squeeze, crunch, and CrLZH.
  • cpmdroid - Z80/CP/M emulator for Android phones and tablets. It emulates the RomWBW HBIOS interface and a VT100 terminal.
  • cpmemu - Z80/CP/M emulator for Linux and Windows, with Z80 and 8080 CPU cores. It translates the BDOS and BIOS calls of CP/M 2.2 programs to the host file system.
  • ioscpm - Z80/CP/M emulator for iOS and macOS. It emulates the RomWBW HBIOS interface and runs CP/M 2.2 and CP/M 3.
  • learn-ada-z80 - Collection of more than 90 Ada example programs for uada80, the Ada compiler for the Z80 processor and CP/M.
  • mbasic - Python interpreter for MBASIC 5.21, the Microsoft BASIC-80 for CP/M. Two compiler backends compile the programs to CP/M .COM files or to JavaScript.
  • mbasic2025 - Reconstruction of the lost source code of MBASIC 5.21, the Microsoft BASIC-80 for CP/M. The MACRO-80 source code assembles to a binary that matches mbasic.com byte for byte.
  • mbasicc - C++17 interpreter for MBASIC 5.21, the Microsoft BASIC-80 for CP/M. It runs on Linux and macOS.
  • mbasicc_web - Web browser interpreter for MBASIC 5.21, the Microsoft BASIC-80 for CP/M. Emscripten compiles the mbasicc interpreter to WebAssembly.
  • mpm2 - Z80 emulator for MP/M II, the multi-user CP/M operating system. Users connect over SSH, and SFTP clients transfer files.
  • romwbw_emu - Hardware-level Z80/CP/M emulator for Linux and macOS. It emulates the RomWBW HBIOS interface and switches banks in 512 KB of ROM and 512 KB of RAM.
  • scelbal - Floating-point BASIC interpreter for the 8080 processor and CP/M. A translator converts the original 8008 source code to 8080 source code.
  • uada80 - Ada compiler for the Z80 processor and CP/M 2.2. It compiles a subset of Ada 2012 to CP/M .COM files.
  • uc80 - C compiler for the Z80 processor and CP/M. It optimizes for small code size.
  • um80_and_friends - Linux toolchain that is compatible with Microsoft MACRO-80. It has an assembler, a linker, a librarian, and a disassembler.
  • upeepz80 - Peephole optimizer for Z80 compilers that write lowercase Z80 assembly language. It shortens jumps to jr, builds djnz loops, and removes dead stores.
  • uplm80 - PL/M-80 compiler for the Z80 processor and CP/M. It writes Intel 8080 and Zilog Z80 assembly language.
  • z80cpmw - Z80/CP/M emulator for Windows. It emulates the RomWBW HBIOS interface and boots CP/M from disk images.

Release files for ucow 0.4.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ucow 0.4.3
File Size Uploaded
ucow-0.4.3.tar.gz 156.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ucow 0.4.3
File Interpreter ABI Platform
ucow-0.4.3-py3-none-any.whl Python 3 none any Details

Total release size: 323.7 kB

Release files / ucow-0.4.3.tar.gz

Download URL ucow-0.4.3.tar.gz
Size 156.0 kB
Tags Source
SHA-256 checksum
How to use checksums
193b118d1acb3dc7ae9b012305eb3e2c4da9091f95e1458c72c277ba282359a5
BLAKE2b-256 checksum
How to use checksums
632da0eca4d12951c042671cacba600b871eb4bb2036da041bd7975fa13c3eec
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 20, 2026.

Transparency log

Release files / ucow-0.4.3-py3-none-any.whl

Download URL ucow-0.4.3-py3-none-any.whl
Size 167.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d1be89e73a159e25359f6480e2e9ca46751d64f99654b44de324c3af4767c95e
BLAKE2b-256 checksum
How to use checksums
d8a8a631b843e04cb0ebe896d060c6da7b14cc9931709535e1cc3521f450726a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 20, 2026.

Transparency log

Release history Release notifications | RSS feed

0.4.5

2 release files

0.4.4

2 release files

This release

0.4.3 This release

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page