Skip to main content

A Cowgol compiler for 8080/Z80 CP/M

Project description

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)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ucow-0.3.0.tar.gz (117.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ucow-0.3.0-py3-none-any.whl (127.3 kB view details)

Uploaded Python 3

File details

Details for the file ucow-0.3.0.tar.gz.

File metadata

  • Download URL: ucow-0.3.0.tar.gz
  • Upload date:
  • Size: 117.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for ucow-0.3.0.tar.gz
Algorithm Hash digest
SHA256 f7f8e29e30e87b300f01eeca8b9122ddf59c99fc0e794d99f4e48f79ed3cfab0
MD5 938939dd6a758392e6d7d74a58a02cd5
BLAKE2b-256 f464fe0fcdeae78850355dd98ed52fb60b90962dead3983c1502c5926a42b431

See more details on using hashes here.

File details

Details for the file ucow-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: ucow-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 127.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for ucow-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ea4bb1392c04a19b360406d4603dd59fd0d9eb2120ef12c2051b9aede2eab17c
MD5 e1b042a29c5573148bcac63725b1a71d
BLAKE2b-256 66eadc719319f3c52cbbc7ef0d75692a91f8140a7383777d683f3c834e0382f7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page