ACE C

Medium
Disk
Publisher
Distributed through public-domain libraries (e.g. Bellcom, Page 6)
Type
Language
Category
Small-C compiler and linker (P-code), Deep Blue C successor
Developer
Ralph E. Walden (based on Deep Blue C by John Palevich)
Language
6502 machine language (run-time engine) and C
Requirements
48K Atari 400/800/XL/XE, disk drive, no cartridges; Atari DOS 2 or OS/A+-style DOS; any text editor that saves ATASCII files
Blue Atari text screen reading 'The ACEC C Compiler by John Palevich and Ralph Walden' with the prompt 'filename (or RETURN to exit)?'

Overview

ACE C is an improved version of Deep Blue C, the C compiler John Palevich wrote for the Atari Program Exchange. Its title screen credits both men: "The ACEC C Compiler by John Palevich and Ralph Walden". Ralph E. Walden of Eugene, Oregon reworked the compiler, linker and run-time so that, by his account, ACE C compiles 10 to 15 times faster (especially with #defines), links 4 to 5 times faster, and produces programs that run about twice as fast. It spread as free software through user-group and public-domain libraries, including Bellcom and the Page 6 library, and was later reposted online in ARC form.

Like Deep Blue C, ACE C implements a subset of C taken mainly from Ron Cain's public-domain Small-C. Walden's documentation tells newcomers to learn the language from Kernighan and Ritchie, and notes that most ACE C programs will compile unchanged on other C systems.

The language

Supported:

  • char, int, pointers and extern, plus single-dimensional arrays
  • the usual unary and binary operators, including ?:, the comma operator and compound assignments such as +=
  • asm, break, case, continue, default, do, else, for, if, return, switch and while
  • #define and #include
  • decimal, hex, octal and backslash constants

Not supported: structures and unions, multidimensional arrays and pointer arrays, functions returning anything but int, sizeof and type casts. Characters are unsigned (0–255).

Braces are written as $( and $) and the tilde as $-. Backslash codes cover Atari screen control: \f clears the screen, \u, \d, \l and \r move the cursor, and \g rings the bell. There are some quirks worth knowing:

  • Comments start at /* and run to the end of the line. They cannot be embedded mid-line or span lines.
  • Tabs are not whitespace (a CFORMAT utility converts them), and source lines can carry BASIC-style line numbers.
  • Constants are folded at compile time strictly right to left with no precedence when written without spaces: num=5*6+1; gives 35. Add a space or parentheses to avoid this.
  • The last case or default in a switch must end with break, continue or return.
  • Floating point is available only through library calls on six-byte char arrays, for example atof(a,"3.14"), fadd(a,b,c), fmul, fdiv, log, clog, exp, and ftoi, which rounds rather than truncates.

Compile, link, run

  1. Write PROG.C in any ATASCII editor.
  2. Load ACEC.COM from DOS (or just type ACEC under OS/A+). The screen blanks while it compiles to PROG.CCC. On an error it stops and shows the offending line; otherwise it lists the functions found. A single .CCC file can be at most about 9K, so large programs should be split up.
  3. Load LINK.COM and give a .LNK file listing the modules, for example PROG.CCC, ACECIO.CCC and finally ENGINE.OBJ or ENGLOAD.OBJ. If no link file exists, the linker creates that default list itself.
  4. Run the resulting PROG.COM from DOS.

ACE C is really a P-code system. ENGINE.OBJ (about 4K, loaded at $2C00) holds the interpreter and most of the I/O library, rewritten in assembly language. Linking ENGLOAD.OBJ instead (about 130 bytes) makes the program fetch the engine from D1: at run time. When a program works, FASTC rewrites the .CCC pseudo-code with 27 new combined instructions, typically saving another 20–30% in run time. Machine code is reached through asm functions or usr(addr,...): arguments sit on a stack pointed to by $C6, their count is in $BF, and zero-page $80–$B5 and $C8–$CF are free.

Walden achieved some of the speed by dropping safety checks. There are no version checks, so linking ACE C code with Deep Blue C's DBC.OBJ crashes the machine. There is no check for the stack running into screen memory and no division-by-zero check. Deep Blue C assembly routines must also be rewritten, because asm works differently.

Using it today

ACE C's compact P-code made it practical for real projects. Its users included the authors of a mid-1980s BBS who moved from Deep Blue C to ACE C. Decades later, one of them noted that the ACE C version fitted on an unmodified 800XL or 65XE, while a cc65 port of the same code needed 128K. Disk images circulate as public-domain software. Boot DOS 2.x in Altirra or atari800 with BASIC off, keep ENGINE.OBJ on D1:, and follow the README files on the disk. For new C work, cc65 is the modern choice, but ACE C remains the best way to experience native C development on the Atari.

Credits