The ZeroPage programming guide

A guide to writing ZeroPage programs, from typed values and C64 hardware to a complete game and relocatable DLLs.

How to follow the guide

Start with types and control flow if you are learning the language. Follow screen and keyboard I/O into the Tic-Tac-Toe case study to see those choices in an application. For memory-intensive projects, read memory placement before arenas and REU views. The DLL walkthrough starts with one call and works up to a shared execution window.

Code labelled as an excerpt shows part of a program. Complete source links let you read the surrounding declarations and run the example. Build and run links open commands on a separate page. The setup page collects tool installation.

Chapters

Write ZeroPage programs

4. Inline 6502 assembly

Use source operands, follow the preservation wrapper, and call a ROM routine or terminal vector.

Plan memory and move data

Load code and build applications

Verify what runs

Find a worked example by task

Look up a language or machine contract

Find a term used in the guide

Arena and pool
An arena reclaims its allocations together. A fixed-block pool also lets you return individual blocks.
DLL registry row and active row
The registry row tracks a module's residency and references. An execution window's active row identifies the module whose code occupies that window.
Far handle and near pointer
A far handle identifies an REU allocation. A near pointer addresses the C64's CPU-visible address space.
Load address, entry address, and run address
The load address is where the PRG arrives. The entry address is where control starts. A placed section's run address is where its bytes are used after any startup copy.
Materialized view
A typed working copy of a whole far view or a range, held in a C64 arena. Flush writes its contents back to REU.
Relocation
Patching encoded addresses so a copied DLL can run in its assigned C64 window.
Sidecar
A compiler output beside the PRG. Maps and labels support inspection. DLL metadata and relocation files also supply information to caller builds.
Software stack
A reserved C64 RAM range for per-call frames. Machine return addresses still go on the 6510 hardware stack.
Zero-page claim
A byte or range below $0100 owned by the compiler, system, or application according to the selected policy.