Deep Blue C

Medium
Disk
Year
1982
Publisher
Atari Program Exchange (APX); later Antic Software
Type
Language
Category
Small-C based p-code C compiler and linker (disk, APX)
Developer
John Howard Palevich
Language
C (compiler written in C) with 6502 p-code interpreter
Requirements
Atari 400/800/XL/XE with 48K and a disk drive; a text editor without line numbers (or Assembler Editor using PRINT #D:)
Blue Atari screen reading: Deep Blue C Compiler version 1.2, (C)1982 John Howard Palevich, File to compile (or RETURN to exit)

Overview

Deep Blue C was the first widely available C compiler for the Atari 8-bit. It was published in 1982 by the Atari Program Exchange and written by John Howard Palevich, already known for APX's Chameleon terminal emulator and later for the official Atari port of Kermit. It is based on Ron Cain's public-domain Small-C compiler and accepts a proper subset of UNIX Version 7 C. Code that avoids Atari-specific features will therefore compile on other C systems. Deep Blue C cost about $40 at a time when commercial C compilers were rare and expensive, which made it the way many Atari owners first learned C.

How it works

Deep Blue C does not produce 6502 machine code. It compiles to pseudo-code (p-code), which a small interpreter runs. Harald Striepe reviewed it for Antic in January 1984 and called this a sensible compromise for a machine with little memory. Programs are small, but they run slower than native code. He judged them "significantly faster than BASIC" but slower than Forth or a native compiler such as OSS's C/65.

The package contains:

  • the compiler, which is itself written in C and is therefore slow;
  • a relocating linker, so you can build precompiled libraries and split large programs into separately compiled modules (Striepe called this "essential" given the compiler's speed);
  • the p-code interpreter as object code;
  • libraries for I/O (with a flexible printf), graphics and player/missiles, plus demonstration programs;
  • a cross-reference listing the differences from Kernighan and Ritchie's The C Programming Language.

Compiled programs load at $3000, which kept them compatible with every Atari DOS of the day. KDOS needed some squeezing.

Language limits

Small-C is only part of C, and Deep Blue C keeps most of its limits. It has for, while, switch/case/default and the usual operators, but no structures or unions, no multi-dimensional arrays, no floating point, no sizeof and no type casts. Functions can only return int. Machine code is reached in two ways. One is a usr() function like BASIC's. The other is the special asm address declaration, which turns a function into a call to a routine at a fixed address:

/* a C function whose body is a machine-code routine at $2300 */
example(arg1, arg2)
int arg1, arg2;
asm 0x2300;

main()
{
    int i;
    for (i = 1; i <= 10; i++)
        printf("%d squared is %d\n", i, i * i);
}

The parameter declarations follow the old K&R style that Small-C uses.

Deep Blue Secrets and later releases

Palevich also persuaded Atari to publish the complete source code as a separate APX product, Deep Blue Secrets. It holds the C source of the compiler and linker and the assembly source of the p-code interpreter, which is written for Atari's Macro Assembler (AMAC). Striepe strongly recommended buying it as a way to learn how a p-code engine works and to tailor the system. APX listed both products in its Winter 1982–83 catalogue and added a Mathlib for Deep Blue C in autumn 1983. After APX closed, Antic Software reissued Deep Blue Secrets (catalogue number APO115, 1985).

A pre-release "V0.1" distribution disk, stamped 19 August 1982, has since surfaced through former APX head Fred Thorlin. Its compiler and linker files differ in size from the released V1.1 package. Disk images of the released V1.1 itself are still sought by preservationists.

Using it today

Deep Blue C runs well in an emulator on any 48K configuration with a DOS 2-compatible disk. You need a separate editor that saves plain text without line numbers: Striepe used APX's MEDIT and Datasoft's Text Wizard, and any modern text editor plus an H: device will do. Compile, then link with the run-time and library modules, and run the result from DOS. For serious development today most people use cc65, a native-code cross-compiler that descends from the same Small-C ancestry. Deep Blue C remains a neat historical artefact and a readable example of a complete compiler toolchain that runs on the Atari itself.

Credits