No description
Find a file
2026-01-06 14:16:20 +01:00
editor_syntaxes/sublime Fixed script keyword in sublime syntax 2026-01-06 14:16:20 +01:00
examples Added SWITCH/CASE/DEFAULT/ENDSWITCH 2025-12-19 22:56:16 +01:00
internal Made error messages display the source and some context. 2026-01-03 12:05:02 +01:00
lib Fixed up memlib.c65 and added errors to POKEW and PEEKW if using the same variable for pointer and value. 2025-11-22 11:26:19 +01:00
vendor Added Starlark scripting language for SCRIPT blocks. 2025-11-06 06:57:06 +01:00
.gitignore Added SWITCH/CASE/DEFAULT/ENDSWITCH 2025-12-19 22:56:16 +01:00
claude_code_docker.sh Added claude code docker setup for project. Added language guide. 2025-12-19 19:26:56 +01:00
commands.md Added SWICH/CASE/DEFAULT/ENDSWITCH to docs 2025-12-22 23:48:18 +02:00
docker-compose.yml Added claude code docker setup for project. Added language guide. 2025-12-19 19:26:56 +01:00
Dockerfile Added SWITCH/CASE/DEFAULT/ENDSWITCH 2025-12-19 22:56:16 +01:00
go.mod Added Starlark scripting language for SCRIPT blocks. 2025-11-06 06:57:06 +01:00
go.sum Added Starlark scripting language for SCRIPT blocks. 2025-11-06 06:57:06 +01:00
language.md Updated language guide slightly 2025-12-19 19:44:13 +01:00
main.go Added SWITCH/CASE/DEFAULT/ENDSWITCH 2025-12-19 22:56:16 +01:00
README.md Fixed requirements 2026-01-03 11:45:22 +01:00
syntax.md Yet another fix 2025-11-21 17:05:21 +01:00

c65gm

A high-level 6502 cross-compiler targeting the ACME Cross-Assembler. c65gm provides a more expressive language for writing 6502 assembly programs, with features like functions, type-checked variables, control flow structures, and compile-time optimizations.

What It Does

c65gm compiles high-level source code into ACME assembler syntax for the 6502 processor (Commodore 64 and similar platforms). It provides:

  • Type system: BYTE and WORD variables with scope resolution
  • Functions: Named functions with parameters and call graph analysis
  • Control flow: IF/ENDIF, WHILE/WEND, FOR loops, SWITCH/CASE
  • Memory operations: PEEK/POKE/PEEKW/POKEW with zero-page optimization. Access registers as variables.
  • Operators: Arithmetic (ADD, SUB), bitwise (AND, OR, XOR)
  • Preprocessor: File inclusion, macros, conditional compilation, Starlark scripting
  • Standard library: C64 screen/kernal routines, memory management, string handling, graphics (Koala), FAT16 filesystem, and more (accessed via #include <file>, path set by C65LIBPATH environment variable)
  • Optimizations: Constant folding, self-assignment detection
  • Safety features: Compile-time detection of overlapping absolute addresses in function call chains

Requirements

  • Go: Version 1.25.1 or higher (tested with 1.25.5)
  • Acme: Tested with release 0.97 ("Zem")

The project uses Go modules with these dependencies:

  • github.com/armon/go-radix - Prefix tree for command lookup
  • go.starlark.net - Embedded Starlark scripting support

Building

Build the compiler binary:

go build -o c65gm

Or install to your GOPATH:

go install

Usage

Compile a source file to ACME assembly:

./c65gm -in input.c65 -out output.asm

Then assemble the output with ACME:

acme -f cbm -o output.prg output.asm

Running Tests

Run all tests:

go test ./...

Run tests with verbose output:

go test -v ./...

Run tests for a specific package:

go test ./internal/compiler
go test ./internal/commands

Examples

See the examples/ directory for sample programs:

  • hires/ - High-resolution graphics demo
  • multicolorbm/ - Multicolor bitmap demo
  • memlib_demo/ - Memory library usage
  • switch_demo/ - SWITCH/CASE statement examples

Documentation

  • language.md - Complete language reference
  • syntax.md - Syntax guide
  • commands.md - Command reference

License

Copyright (C) 1999, 2025 Mattias Hansson Distributed under GPL.