| Crates.io | kz80_action |
| lib.rs | kz80_action |
| version | 0.1.0 |
| created_at | 2026-01-01 23:32:54.623999+00 |
| updated_at | 2026-01-01 23:32:54.623999+00 |
| description | Action! language compiler for Z80 |
| homepage | https://github.com/ajokela/kz80_action |
| repository | https://github.com/ajokela/kz80_action |
| max_upload_size | |
| id | 2017708 |
| size | 104,791 |
A cross-compiler that translates Action! source code into Z80 machine code. Action! was a popular compiled programming language for Atari 8-bit computers, known for producing fast, efficient code. This compiler brings Action! to the Z80 platform.
Requires Rust toolchain (1.70+):
cargo build --release
The compiler binary will be at target/release/kz80_action.
kz80_action -i <source.act> -o <output.bin> [options]
| Option | Description |
|---|---|
-i, --input <FILE> |
Input Action! source file |
-o, --output <FILE> |
Output binary file (default: input with .bin extension) |
--org <ADDRESS> |
Origin address for code (default: 0x4200) |
-l, --listing |
Generate listing file (.lst) |
-v, --verbose |
Verbose output |
# Compile with origin at 0x0000 (for RetroShield emulator)
./target/release/kz80_action -i examples/simple.act -o simple.bin --org 0x0000 -l
# Run on RetroShield emulator
../emulator/retroshield -l simple.bin
BYTE b ; 8-bit unsigned (0-255)
CARD c ; 16-bit unsigned (0-65535)
INT i ; 16-bit signed (-32768 to 32767)
CHAR ch ; Character (same as BYTE)
BYTE ARRAY buf(100) ; Array of 100 bytes
CARD ARRAY nums(50) ; Array of 50 words
; Procedure (no return value)
PROC PrintNumber(BYTE n)
PrintB(n)
PrintE()
RETURN
; Function (returns a value)
FUNC BYTE Double(BYTE n)
RETURN(n * 2)
; IF statement
IF x > 10 THEN
PrintB(x)
ELSEIF x > 5 THEN
PrintB(5)
ELSE
PrintB(0)
FI
; WHILE loop
WHILE i < 100
DO
i = i + 1
OD
; FOR loop
FOR i = 1 TO 10 STEP 2
DO
PrintB(i)
PrintE()
OD
| Category | Operators |
|---|---|
| Arithmetic | +, -, *, /, MOD |
| Comparison | =, <>, <, >, <=, >= |
| Logical | AND, OR, XOR, NOT |
| Bitwise | &, %, ! |
| Unary | - (negate), ^ (dereference), @ (address-of) |
; This is a comment (semicolon to end of line)
| Function | Description |
|---|---|
PrintB(BYTE n) |
Print byte as decimal number (0-255) |
PrintC(CARD n) |
Print card as decimal number (0-65535) |
PrintE() |
Print end of line (CR+LF) |
Print(STRING s) |
Print null-terminated string |
PutD(BYTE ch) |
Output a single character |
GetD() |
Read a character from input (blocking) |
PROC main()
BYTE i
i = 65 ; ASCII 'A'
WHILE i <= 90
DO
PutD(i)
i = i + 1
OD
PrintE()
RETURN
PROC main()
BYTE i
FOR i = 1 TO 10
DO
PrintB(i)
PrintE()
OD
RETURN
PROC main()
CARD a, b, temp, count
a = 0
b = 1
count = 0
WHILE count < 20
DO
PrintC(a)
PrintE()
temp = a + b
a = b
b = temp
count = count + 1
OD
RETURN
The compiler generates code with the following layout:
+------------------+ <- Origin (e.g., 0x0000)
| JP entry_point | 3 bytes
+------------------+
| Runtime Library | ~109 bytes
+------------------+
| CALL main | 3 bytes
| HALT | 1 byte
+------------------+
| User Code | Variable
+------------------+
| ... |
+------------------+ <- 0x2000
| Variables (RAM) |
+------------------+
This compiler targets Z80-based systems with:
BSD 3-Clause License. See LICENSE for details.