Ada compiler targeting Z80 processor
Project description
uada80 - Ada Compiler for Z80/CP/M
An Ada compiler targeting the Z80 processor and CP/M 2.2 operating system, aiming for ACATS (Ada Conformity Assessment Test Suite) compliance.
Project Status
🔧 Alpha - Core compiler functionality implemented
Overview
uada80 is a compiler for the Ada programming language that generates code for the Z80 8-bit microprocessor running CP/M 2.2. The project aims to support a substantial subset of Ada 2012 and pass the ACATS conformance tests.
Target Platform: CP/M 2.2 on Z80
- Programs load at 0x0100
- Access to CP/M BDOS for file I/O and console operations
- Approximately 57K TPA on typical 64K system
Goals
- Compile Ada source code to Z80 assembly/machine code
- Generate CP/M .COM executables
- Pass ACATS test suite (or as many tests as feasible for Z80/CP/M)
- Generate efficient code suitable for CP/M systems
- Provide clear error messages and diagnostics
Inspiration
This project builds on experience from uplm80, a PL/M-80 compiler for Z80, reusing proven optimization techniques.
Features
Phase 1 (MVP) ✅
- Project structure
- Lexer and parser
- Basic types: Integer, Boolean, Character
- Procedures and functions
- Control flow: if, case, loop, for
- Arrays and records
- Z80 code generation
Phase 2 (Expanded) ✅
- Packages
- Enumeration types
- Access types (pointers)
- Derived types
- Unconstrained arrays
- AST optimization
Phase 3 (ACATS Compliance) 🔧
- Generics
- Exception handling
- Full attribute support
- Representation clauses
- Standard library (adapted for Z80)
- ACATS test validation
Architecture
Ada Source → Lexer → Parser → AST → Semantic Analysis → Optimizer → Code Gen → Z80 Assembly
See ARCHITECTURE.md for detailed design documentation.
Building
Requirements
- Python 3.10 or later
- Optional: Z80 assembler (z80asm, sjasmplus, or similar)
- Optional: Z80 emulator for testing (e.g., MAME, z80emu)
Installation
# Clone the repository
git clone https://github.com/yourusername/uada80.git
cd uada80
# Create virtual environment
python3 -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install in development mode
pip install -e ".[dev]"
Running Tests
pytest
Usage
# Compile an Ada source file
uada80 hello.ada -o hello.asm
# With optimization
uada80 hello.ada -o hello.asm -O2
# Generate listing
uada80 hello.ada -o hello.asm --listing
Example Programs
Hello World
with Ada.Text_IO;
procedure Hello is
begin
Ada.Text_IO.Put_Line("Hello from Ada on Z80!");
end Hello;
Fibonacci
procedure Fibonacci is
A, B, Temp : Integer;
N : Integer := 10;
begin
A := 0;
B := 1;
for I in 1 .. N loop
Temp := A + B;
A := B;
B := Temp;
end loop;
end Fibonacci;
See examples/ for more examples.
Documentation
Compiler Documentation
- docs/ARCHITECTURE.md - Compiler architecture and design
- docs/AST_DESIGN.md - Abstract syntax tree structure
- docs/OPTIMIZATION_ANALYSIS.md - Optimization strategies
- docs/LANGUAGE_SUBSET.md - Supported Ada language features
CP/M Target Platform
- docs/CPM_RUNTIME.md - Complete Ada/CP/M runtime specification
- docs/CPM_QUICK_REFERENCE.md - CP/M quick reference for developers
- docs/cpm22_bdos_calls.pdf - BDOS system call reference
- docs/cpm22_bios_calls.pdf - BIOS hardware interface
- docs/cpm22_memory_layout.pdf - CP/M memory organization
Ada Language Specifications
- specs/ - Ada language specifications and ACATS tests
ACATS Testing
The Ada Conformity Assessment Test Suite is included in acats/.
# Run ACATS tests (when implemented)
python tests/run_acats.py
Limitations
Due to the Z80's 8-bit architecture and limited resources:
- No floating-point arithmetic (unless software implementation)
- Integer sizes limited to 8-bit and 16-bit
- Reduced standard library
- Tasking support limited or unavailable
- Limited heap (small memory space)
Contributing
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch
- Make your changes with tests
- Run the test suite
- Submit a pull request
License
This project is licensed under the GNU General Public License v2.0 - see LICENSE for details.
References
Related Projects
Acknowledgments
- The Ada programming language community
- The Z80 retrocomputing community
- ANTLR parser generator team
- uplm80 optimization techniques
Status Updates
See CHANGELOG.md for development progress.
Note: This is an educational and hobbyist project. For production Ada development, please use GNAT or other mature Ada compilers.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file uada80-0.3.0.tar.gz.
File metadata
- Download URL: uada80-0.3.0.tar.gz
- Upload date:
- Size: 397.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b1c370f3f262eda224db5cfbc24284c8e2f8c1b41db2286c83145d94883cfe50
|
|
| MD5 |
5b9c7de8778a0eff23f5fa68c0b0395c
|
|
| BLAKE2b-256 |
985f5c317d84555093f048e4ae833b30321d2579eb4270eb1c1b4a69309da12a
|
File details
Details for the file uada80-0.3.0-py3-none-any.whl.
File metadata
- Download URL: uada80-0.3.0-py3-none-any.whl
- Upload date:
- Size: 304.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ef89cd81ff8dcdb0f4d9cec6085180fb8722fab5bf1eb4992e003ad7b65dea7a
|
|
| MD5 |
84d420561e728dbba2e4b376fb703546
|
|
| BLAKE2b-256 |
1d2b6b74c6a7f11db2dd3b2fafdbcc2d02b9e04463f252f6fad3ff31e56b18f8
|