Atari BASIC

Medium
Cartridge
Year
1979
Publisher
Atari, Inc.
Type
Language
Category
BASIC interpreter (8K ROM cartridge / built-in ROM)
Developer
Shepardson Microsystems, Inc. (Paul Laughton, Kathleen O'Brien, Bill Wilkinson, Paul Krasno, Mike Peters)
Language
6502 machine language
Requirements
Any Atari 400/800 with the CXL4002 cartridge (8K RAM minimum); built into the XL/XE range (hold OPTION at power-on to disable)
Atari 400/800 box for the BASIC computing language cartridge (CXL 4002), showing an illustration of two people at an Atari 800

Overview

Atari BASIC was the first language almost every Atari 8-bit owner used. On the 400 and 800 it came as an 8K left-slot cartridge (CXL4002). From the 600XL and 800XL onward it was built into the computer's ROM, so the machine started in BASIC unless you held OPTION during power-up. It is an interpreter: you type a numbered line, BASIC checks its syntax at once, and the program runs as soon as you type RUN. It runs slowly and it has quirks. But it gives direct access to the Atari's graphics modes, sound, joysticks and every device the operating system knows about, which is why thousands of magazine type-ins were written for it.

Behind the scenes

In October 1978 Atari hired Shepardson Microsystems, Inc. (SMI) to write a BASIC, plus the file manager that became Atari DOS, for its new computers. Paul Laughton was the main programmer and Kathleen O'Brien wrote the floating-point routines. Bill Wilkinson drew up the preliminary language specification, Paul Krasno built the maths library and Mike Peters did keypunching and operating. SMI designed it to fit in 10K, including a 2K floating-point package. Atari moved that package into the operating system ROM at $D800–$DFFF so every program could use it, and that cut the cartridge to 8K.

Atari BASIC does not follow Microsoft's dialect. It works more like Hewlett-Packard's BASICs, so strings are dimensioned character arrays sliced with A$(3,5) rather than handled with LEFT$/MID$. In February 1981 the source code was sold to Optimized Systems Software (OSS), the company Wilkinson and Peters founded after leaving SMI. Wilkinson, O'Brien and Laughton later published the complete Rev. A source as The Atari BASIC Source Book (COMPUTE! Books, 1983).

Reviewers were not kind. The Creative Atari languages survey (1983) called it the slowest BASIC its author had used and blamed its 6-byte BCD arithmetic. De Re Atari puts it more evenly. It praises the built-in graphics and sound statements, the USR call into machine code and the support for any peripheral the OS recognises, but it lists the weaknesses too: no integers, slow maths and no string arrays.

How it works

De Re Atari explains the internals. Each line you type is syntax-checked and tokenised straight away, so a typing error is reported when you press RETURN, not when the program runs. Variable names go into a name table with a limit of 128 different variables, and every number is stored as a 6-byte BCD value. GOTO, GOSUB and the return from NEXT all search the program for their target line from the top. Jerry White's 1984 Antic test shows the cost: the same FOR/NEXT loop took 15 jiffies at line 0 and 91 jiffies at line 32700. That is the reason for the old advice to put busy loops and subroutines at the start of a program.

Keywords can be abbreviated with a full stop (L. for LIST), and ? stands for PRINT. Programs are saved tokenised with SAVE/LOAD (or CSAVE/CLOAD on cassette), or as plain text with LIST "D:FILE.LST" and ENTER.

10 GRAPHICS 7+16:COLOR 1
20 FOR I=0 TO 159 STEP 4
30 PLOT I,0:DRAWTO 159-I,95
40 SOUND 0,I,10,8
50 NEXT I
60 SOUND 0,0,0,0
70 GOTO 70

Versions & releases

There are three revisions, and you can identify yours by typing ? PEEK(43234) at the READY prompt:

Value Revision Where it shipped
162 A 400/800 cartridge, 1979–82
96 B Built into the 600XL/800XL, from autumn 1983
234 C Cartridge from June 1984; built into late 800XLs, 65XE, 130XE, XEGS and 800XE

Rev. A went into mass production before debugging was finished. Its best-known fault is a "keyboard lockup" that can freeze the machine while you edit. Matthew Ratcliff traced it to a carry-bit error when deleted lines removed a multiple of 256 bytes. Rev. B fixed most of the old bugs but added a worse one. Each time a program is loaded, it grows by 16 bytes, and if you then save it the extra bytes are saved too, so a program can slowly fill memory by itself. You can avoid it by saving with LIST and reloading with ENTER. Antic also published a type-in Revision C Converter in September 1985. Rev. C is the final, debugged version. Atari sent it out on cartridge, free to XL owners still under warranty, and built it into all later machines.

Using it today

Every emulator supports Atari BASIC. In Altirra, choose a BASIC ROM and switch BASIC on in the system settings, or attach the cartridge image on a 400/800 configuration. Use Rev. C unless you are deliberately testing old bugs. On a real XL/XE, check the revision with the PEEK above. A Rev. B machine is fine for typing in listings, provided you save your work with LIST. Many later languages were designed to load Atari BASIC programs, among them BASIC XL, BASIC XE and Turbo-BASIC XL, so Atari BASIC code is also the easiest way to move to a faster dialect.

Credits