ATARI BASIC was a ROM resident BASIC interpreter for the Atari 8-bit family of 6502-based home computers. The interpreter originally shipped on an 8 KB cartridge; on later XL/XE model computers it was built in, and would load by default when the machines were booted without other carts in place. The complete commented source code and design specifications of ATARI BASIC had been published early as a book.[Wilkinson et al., 1983] This marked the first time source code was made available for a commercial language.
Background
The machines that would become the
Atari 8-bit family had originally been developed as a 2nd generation
games console intended to replace the
Atari 2600. Ray Kassar, the new president of Atari, decided to challenge
Apple Computer Corp. by building a home computer. This meant Atari needed the
BASIC programming language, the standard language for many home computers.
Atari did what many of the other home computer companies did: they purchased the source code to Microsoft 8K BASIC with the intent to port it to run on the new machines. This turned out to be more difficult than expected; the 8K code expanded to over 11K when ported from the Intel 8080's instruction set to the Atari's 6502 instruction set, and the maximum cartridge size was 8k of ROM. Six months and many man-hours later, they were almost ready. But Atari had a deadline with the Consumer Electronics Show (CES) approaching and decided to ask for help.
Shepardson Microsystems
In September
1978 Atari asked
Shepardson Microsystems, Inc. (SMI) to bid on a new custom BASIC. Shepardson had written a number of programs for the 6502-based
Apple II, and were in the midst of finishing a new BASIC (the Cromemco 32K structured BASIC). When the specifications were finalized in October of 1978,
Paul Laughton and
Kathleen O'Brien began work on the new Atari BASIC. The contract specified a delivery date by April 6, 1979 and this also included a File Manager System (later known as DOS 1.0). Atari's plans were to take an early 8K version of Microsoft BASIC to the 1979 CES and then switch to the new Atari BASIC for production.
The result was a rather different version of BASIC, known as ATARI BASIC. Unlike the MS BASIC which patterned itself after DEC BASIC, the new BASIC was patterned on Data General's BASIC and had a number of obvious differences. Thanks to a bonus clause in the contract, development proceeded quickly and an 8K cartridge was available just before the release of the machines. Because of the speed in getting Atari BASIC, Atari ended up taking it to CES instead of the pre-production Microsoft BASIC.
Shepardson's programmers found bugs in the first-pass review and managed to fix some of them but Atari had already committed BASIC to manufacturing. This initial version became known as Revision A.
- Revision A - First Atari BASIC cartridge. 8kB ROM.
- Revision B - Fixed all of the major bugs in Revision A, but introduced a leaking memory bug. Found built-in on the 600XL and early 800XLs. No cartridges.
- Revision C - Eliminated memory leak in Revision B. Found on later 800XLs, the 800XLF, XEGS and all XE computers. Limited cartridge production run.
Description
ATARI BASIC used a token structure to handle processing. After the user entered a line, BASIC would do syntax checking, then tokenize the statement. This "pre-compiling" reduced memory and enabled faster execution. Variables were stored in the variable name table (VNTP - 82, 83
16) and the values were store in the variable value table (VVTP - 86, 87
16). The string arrays had their own area (STARP - 8C, 8D
16) as did the runtime stack (RUNSTK - 8E, 8F
16). Finally, the end of BASIC memory usage was indicated by the MEMTOP (90, 91
16) pointer.
The token output buffer (LOMEM - 80, 8116) was used by BASIC for tokenizing a line of BASIC code. 256 bytes in size, any tokenized statement that was larger then the buffer would generate an error (14 - Line too long).
Reserved words
ABS DRAWTO NEW RESTORE VAL
ADR END NEXT RETURN XIO
AND ENTER NOT RND
ASC EXP NOTE RUN
ATN FOR ON SAVE
BYE FRE OPEN SETCOLOR
CLOAD GET OR SGN
CHR$ GOSUB PADDLE SIN
CLOG GOTO PEEK SOUND
CLOSE GRAPHICS PLOT SQR
CLR IF POINT STATUS
COLOR INPUT POKE STEP
COM INT POP STICK
CONT LEN POSITION STRIG
COS LET PRINT STOP
CSAVE LIST PTRIG STR$
DATA LOAD PUT THEN
DEG LOCATE RAD TO
DIM LOG READ TRAP
DOS LPRINT REM USR
System Input/Output
ATARI BASIC interacts with the system via the Central Input/Output functions (CIO). Some of the functions have a corresponding BASIC reserve word (OPEN, CLOSE, GET, PUT, etc). The Input/Output channels were known as Input/Output Control Blocks (IOCB). Although there were eight IOCBs, a number of them were reserved. IOCB 0 was for the screen editor and couldn't be accessed from BASIC (although it could from Machine Code). IOCB 7 was used by built in BASIC commands for IO (eg LPRINT, SAVE, LOAD, CSAVE, CLOAD). IOCB 6 was used for accessing the Graphics device in Graphics mode. And when using SpartaDOS, IOCB 4 and 5 were used for console input and output redirection.
Example: Opens the cassette for reading in BASIC
OPEN #1,4,0,"C:"
For the other CIO functions, BASIC uses the XIO statement for access. This included screen functions, serial (RS-232) functions as well as disk operations like format or deleting a file.
Example: Fill command in BASIC
XIO 18,#6,12,0,"S:"
String handling
ATARI BASIC differs from Microsoft-style BASICs primarily in the way it handles strings. Strings were character arrays, like those in
Data General-like systems. The
C programming language also treats strings as character arrays. While this is in theory much faster than MS's solution, it was also much harder to port BASIC programs to the machine because ATARI BASIC didn't directly support string arrays. Finally, according to Bill Wilkinson, the decision to go with strings larger than 255 characters in size made string arrays unfeasible.
On the upside they were easy to work with, using "slicing" commands. A$ referred to the entire string, whereas A$(4,6) "sliced" out the three characters, 4, 5 and 6. In general this was a more elegant solution than MS BASIC's LEFT$, MID$, and RIGHT$ solution. Another difference was that the Atari strings, like C arrays, were 0-indexed while MS strings were 1-indexed.
Sound and graphics
Other features of ATARI BASIC, in comparison to the BASICs of some competing machines at the time, were its built-in support of simple sound effects and high-resolution graphics as well as peripherial units like joysticks, paddles, and floppy disk drives. Other home computer users were often left with cryptic
POKE's for such programming.
Program editing
When not running a program,
Atari BASIC is in intermediate mode, where lines can be entered (with a line-number) or immediate commands can be entered (without a line-number) that are executed immediately. If the user enters a line containing a
syntax error, then the interpreter re-prints the line with the string "
ERROR- " at the start (or after the line-number if the syntax error is entered on a line) and the first character of the
token following the erroneous token is displayed with the foreground and background colours swapped.
Most Atari BASIC statements may be abbreviated when entered. The language used a clever system for this, which did not require a second set of abbreviated tokens (keywords) as did most other languages. Instead they sorted the token list such that the most popular command for any particular letter was at the top of the list, and when searching for a token they stopped at the first one that matched. The user could then enter keywords abbreviated with a period, for instance P. would expand to PRINT, whereas PL. would expand to PLOT. Like most microcomputer BASICs, programs were stored in a tokenized (semi-compiled) form, and since the short-form was not an actual separate token, when the program was later LISTed the short forms would be expanded its "full" form. However, unlike most BASICs, Atari Basic tokenized everything, not just the keywords. This included variables as well.
Performance
Atari BASIC was slower than that of other BASICs. Most of these problems stemmed from two particularly poorly implemented bits of code, one for handling loops like the
FOR...
NEXT that required the system to re-scan the entire program to find the starting point once again every time through the loop, and a particularly poor implementation of the multiply code that was used throughout the math libraries. Several commercial and shareware BASICs were available on the platform that addressed these issues, resulting in performance that was 3 to 5 times faster than the Atari version.
Atari BASIC also didn't support integer variables, all numeric operations and numeric values were in floating point. Atari BASIC relied on the Atari OS's built-in floating point routines (BCD notation), which were slow. Atari later sold a diskette-based version of MS BASIC, Atari Microsoft BASIC, and later managed to fit it onto a cartridge as well, but no compiler or runtime was available for redistribution.
See also
Tips
- In the XL/XE models, BASIC could be disabled by holding down the OPTION key while booting the computer. XEGS powered without the keyboard would disable BASIC.
- The program States and Capitals initially did not work with the 600XL computer. This was caused by the Revision B BASIC being slightly larger memory-wise than the older Revision A, causing the States and Capitals program to abort with a "out of memory" error. The solution was to insert the older Revision A BASIC cartridge until Atari could fix the States and Capitals program!
References
- Wilkinson, Bill (1983). The Atari BASIC Source Book. Compute! Books. ISBN 0-942386-15-9.
- The ATARI BASIC Reference Manual. Atari Inc. (1980). *
- Wilkinson, Bill. Inside Atari DOS. COMPUTE! Books (1982). ISBN 0-942386-02-7. *
- De Re Atari Chapter 10: ATARI BASIC – A detailed description of the dialect and interpreter
External links
- Atari BASIC, The Good, the Bad, and the Ugly
- Atari Basic - A Self-Teaching Guide – By Bob Albrecht, LeRoy Finkel, and Jerald R. Brown, published 1979
- Atari Basic - XL Edition – By Bob Albrecht, LeRoy Finkel, and Jerald R. Brown, published 1985
- XFormer, a free Atari Emulator which needs no ROM's and other items
BASIC programming language family | Atari 8-bit family software
Atari BASIC | Atari BASIC