Inside Atari Microsoft BASIC: A First Look

Jim Butterfield

Atari's long-awaited Microsoft BASIC is here at last. Jim Butterfield, an expert on the 8K Microsoft BASIC used on other machines, begins the documentation of the complex inner workings of Atari Microsoft BASIC.

It's a big BASIC. It occupies 18K of RAM, which means there's a lot of code in the interpreter. It also does some new things. Single versus double precision arithmetic, for example, calls for a dramatic rearrangement of the floating accumulators and of the way variables are stored as compared to the better-known 8K Microsoft BASICs.

With the expanded features come new techniques to be mastered. I wince when PRINT 10/4 yields an answer of 2 (to get 2.5, you must force floating point with PRINT 10/4.0).

The Architecture

The following discussion assumes that users have had some exposure to the mechanics of other Microsoft BASICs.

Your BASIC program will be stored right behind the interpreter (Hex 6980 and up). It's the usual format: two-byte forward chain to the next BASIC line, two-byte BASIC line number, the line itself (tokenized) and finally a zero byte to flag end-of-line. The end-of-program is identified by zero-bytes in the forward chain location.

Variables come behind your program – check the address in hex 84 and 85, or PRINT PEEK(132) + PEEK(133) * 256 – but storage is fairly complex. The first two bytes are the first two characters of your variable name, but with many bits stripped away and replaced with "variable type" bits: don't be surprised if your variable A ends up with the name stored as value 1 rather than the ASCII 65 which corresponds to A. The third byte is the length of this variable entry. Now we have a messy bit: if you have a long variable name such as PLUGH the extra letters (UGH) are stored starting at the fourth byte. Finally, the value itself.

The following memory map is a brief list of the locations I have spotted while looking around. It's far from complete; but those who would like to rummage around will find it handy.

0080-0081 128-129 Pointer : Start-of-Basic
0082-0083 130-131 Pointer
0084-0085 132-133 Pointer : Start-of-Variables
0086-0087 134-135 Pointer : Start-of-Arrays
008A-008B 138-139 Pointer : String storage (moving down)
0094-0095 148-149 Current data pointer
00AE-00C5 174-197 CHRGET subroutine
00B4 180 CHRGOT entry point
00B5-00B6 181-182 Basic pointer within subroutine
00C7-00C8 199-200 Variable pointer for FOR/NEXT
00CB 202 $98 = READ, $40 = GET, 0 = INPUT
00CD 204 Default DIM flag
00D1 209 Accum sign compare, #1 vs #2
00D2 210 Accum #1 Low order (rounding)
00D4 212 Variable name length
00D5-00D8 213-216 Utility Pointer area
00DC-00E4 220-228 Misc numeric work area
00E5 229 Accum #1 precision flag
00E6 230 Accum #1 : Sign
00E7 231 Accum #1 : Exponent
00E8-00EE 232-238 Accum #1 : Mantissa
00F0 240 Accum #2 : Sign
00F1 241 Accum #2 : Exponent
00F2-00F8 242-248 Accum #2 : Mantissa
00F9-00FF 249-255 Product area for multiplication
0480- 1152- Variable name setup area
1F00-697F 7936-27007 Microsoft Basic Interpreter
6980- 27008- Basic program staging area

Return to Table of Contents | Previous Section | Next Section