The Atari 680x0 C99 Compiler
A modern optimising C99 compiler targeting the Motorola 680x0 and Atari ST/Falcon: low cycle counts, compact binaries, and fast standalone builds.
.TOS/.PRG binaries.
.PRJ support: Builds classic Atari .PRJ projects natively on Windows, macOS, and Linux with automatic path and library resolution.
$ rg-cc -O2 main.c player.c sound.c -o game.tos █▀▀▄ █▀▀▀ █▀█▄ █ ▀█ RESERVOIR GODS ▀ ▀ ▀▀▀▀ rg-cc 0.8.3 · C99 compiler for 680x0 / Atari Compiling main.c (O2, fastcall, 68000) Compiling player.c (O2, fastcall, 68000) Compiling sound.c (O2, fastcall, 68000) Linking game.tos Finished game.tos (17,672 B · text 14,320 · data 2,400 · bss 8,192) in 64ms $
$ rg-cc -c -O2 --emit-depfile -I include/ src/*.c █▀▀▄ █▀▀▀ █▀█▄ █ ▀█ RESERVOIR GODS ▀ ▀ ▀▀▀▀ rg-cc 0.8.3 · C99 compiler for 680x0 / Atari ✓ Compiled 18 translation units across 16 cores in 14.2ms ✓ Emitted 18 relocatable ELF objects ✓ Generated Makefile dependency files (.d) ┌───────────────────────┬────────────┬───────────┐ │ translation unit │ lines of C │ compile │ ├───────────────────────┼────────────┼───────────┤ │ src/actor.c │ 1420 │ 1.2ms │ │ src/collision.c │ 2180 │ 1.6ms │ │ src/display.c │ 3840 │ 2.4ms │ │ src/engine.c │ 4920 │ 3.1ms │ │ src/physics.c │ 2760 │ 1.8ms │ ├───────────────────────┼────────────┼───────────┤ │ 18 files total │ 26140 │ 14.2ms │ └───────────────────────┴────────────┴───────────┘ $
$ rg-cc -c -O3 --lto engine.c physics.c render.c -o engine.o █▀▀▄ █▀▀▀ █▀█▄ █ ▀█ RESERVOIR GODS ▀ ▀ ▀▀▀▀ rg-cc 0.8.3 · C99 compiler for 680x0 / Atari ✓ [LTO] Merged 3 translation units into unified SSA module ✓ [LTO] Inlined 24 cross-unit call sites ✓ [LTO] Eliminated 6 unreferenced static functions ✓ [LTO] Global constant propagation: 18 branches folded ✓ [LTO] Interprocedural register allocation (IPRA) applied ✓ Wrote optimised object: engine.o (savings: -14.2% cycles, -8.6% bytes) $
$ rg-cc --ir --opt 2 math.c █▀▀▄ █▀▀▀ █▀█▄ █ ▀█ RESERVOIR GODS ▀ ▀ ▀▀▀▀ rg-cc 0.8.3 · C99 compiler for 680x0 / Atari ; SSA IR: fn @Vector_Transform (fastcall: %a0=vec, %d0=matrix, %d1=count) bb0: %0 = phi [ %d1, entry ], [ %8, bb1 ] %1 = phi [ %a0, entry ], [ %9, bb1 ] %2 = load.w (%1) %3 = muls.w %2, %d0 %4 = asr.l #4, %3 ; fixed-point scale shift store.l %4, (%1)+ ; synthesised auto-increment (An)+ %8 = subq.w #1, %0 %cond = cmp.w %8, #0 br.ge %cond, bb1, bb2 ; lowered to DBRA countdown loop ; MC68000 Codegen (-S -O2): .Vector_Transform: .Lloop: move.w (a0),d2 muls.w d0,d2 asr.l #4,d2 ; fixed-point scale shift move.l d2,(a0)+ ; CISC post-increment store dbra d1,.Lloop ; zero-overhead hardware loop rts $
$ rg-cc --emit-headers include/ --emit-runtime lib/ █▀▀▄ █▀▀▀ █▀█▄ █ ▀█ RESERVOIR GODS ▀ ▀ ▀▀▀▀ rg-cc 0.8.3 · C99 compiler for 680x0 / Atari ✓ Exported 53 built-in C & Atari headers to include/ - <stdint.h>, <stddef.h>, <stdbool.h>, <stdarg.h>, <limits.h> - <osbind.h>, <mint/mintbind.h>, <gemdos.h>, <xbios.h>, <gem.h> ✓ Exported runtime objects and archives to lib/ - lib/crt0.o (standard Atari GEMDOS startup) - lib/libc.a, lib/libm.a, lib/libgem.a, lib/liblinea.a, lib/libext.a, lib/libposix.a - lib/libintrt.a, lib/libsoftfloat-fast.a, lib/libsoftfloat-correct.a $
rg-cc -O2 main.c player.c sound.c -o game.tos # direct compilation to TOS rg-cc -c -O2 --opt-size game.c -o game.o # size-optimised object rg-cc -c -O3 --lto *.c -o engine.o # whole-program LTO rg-cc -c --emit-depfile -I include/ src/*.c # generate Makefile depfiles rg-cc --emit-headers include/ # export built-in headers
After unzipping, check the extracted files (the archive includes SHA256SUMS):
sha256sum -c SHA256SUMS