vbcc Optimizing C Compiler Gains Experimental Atari 8-bit Support

On 30 July 2020, the author of vbcc (posting on AtariAge as vbc) uploaded a new build of his portable optimizing C compiler with experimental support for Atari 8-bit computers. vbcc is better known among Amiga developers. Its 6502 back end already existed, and this build added an Atari target to it. The Atari port gave the platform another modern C option besides cc65.

What vbcc offered at launch

At launch, the 6502 version:

  • supports C99, including variable-length arrays and designated initializers;
  • produces optimized code (Dhrystone results were included in the samples);
  • supports banked memory and far pointers;
  • has limited floating point based on Steve Wozniak's routines, and more complete 32/64-bit IEEE floating point based on Apple's SANE;
  • can write interrupt handlers, put variables in zero page with attributes, and use stack frames larger than 256 bytes.

The author was open about the weak points. The C library was only partly optimized for the 6502 and could be too large for many programs, and file I/O was not implemented yet (screen and keyboard stdin/stdout worked). He had never used an Atari and had tested only in emulators, so he asked for real-hardware reports and corrections.

Community feedback

Atari programmers replied quickly with specific fixes. One of the first replies pointed out that the RTCLOK timer is updated from the NMI-driven VBI, so disabling IRQs (SEI/CLI) doesn't stop it changing mid-read, and suggested a read-and-recheck loop. dmsc listed three porting issues:

  1. A start address of $700 clashes with every DOS; $2000 is the usual safe default.
  2. Putting the C stack at MEMTOP breaks as soon as a program switches to a graphics mode that uses more RAM.
  3. The runtime ended in an endless loop; it should return to DOS with RTS (or JMP ($0A)).

Moving the start address to $2000 was confirmed to make the samples run on a real Atari. The thread also discussed how much RAM that costs (about 6.5 KB) and whether DOS is needed at all for programs that only use the screen and keyboard.

Why it matters

With vbcc, KickC (September 2020) and later LLVM-MOS (2022), the Atari went from having essentially one maintained C compiler (cc65) to several within two years. Developers now have a real choice between code density, language features and toolchain style.

Getting it

vbcc is distributed from the author's site, compilers.de/vbcc.html. Check the current Atari target documentation there, since the 2020 notes above describe the first experimental release.

Credits