Tabulka prikazu BASIC (Atari BASIC Token Table Lister)

Type
Utility
Category
Programming utility — reads Atari BASIC's keyword tables from ROM
Published in
ATOM, issue 11/89; reissued on the Czech disk magazine Flop, issue 7
Year
1989
Language
Atari BASIC
Requirements
Any 8-bit Atari with the original Atari BASIC (cartridge or XL/XE built-in)

About the program

Atari BASIC never stores your program as text. Every keyword is crunched to a one-byte token as you press RETURN, and LIST turns the tokens back into words using tables inside the 8K BASIC ROM. This short program walks those tables and prints them, giving you a reference card of every statement token (0–55) and every operator and function token (from 14 upwards). That's very useful if you ever want to write a detokeniser, a cross-reference tool or a "variable searcher".

The REMs say the program is PODLE ATOM 11/89, "after ATOM, issue 11/89", and that it was typed in (PRETUKAL) by Ing. J. Vácha of Náměšť nad Oslavou, the same typist who supplied Atari Logik to the Czech disk magazine Flop 7.

Typing it in

Plain ASCII apart from two inverse-video headings, {inverse} TABULKA PRIKAZU BASIC {/inverse} ("table of BASIC statements") and {inverse} TABULKA OPERATORU A FUNKCI {/inverse} ("table of operators and functions"). Type them with the inverse (Atari logo) key on. Keep the DATA in lines 220–280 in order: thirteen descriptions, read one by one for particular tokens.

What the Czech notes mean

Czech English
54 (IMPLITED LET) 54 = implied LET (a statement like A=1)
55 ERROR (SYNTAX) 55 = a line that failed the syntax check
ciselna konstanta numeric constant (token 14)
retezcova konstanta string constant (token 15)
nevyuzito unused (16, 17)
konec radku end of line
ciselne porovnani / retezcove porovnani numeric / string comparison
prirazeni cisla / prirazeni retezce numeric / string assignment
zvlastni operatory special operators
leva zavorka retezce / pole / DIM pole left bracket of a string / array / DIM'd array
funkce leve zavorky function's left bracket
leva zavorka DIM retezce, carka v DIM poli left bracket of a DIM'd string, comma in a DIM'd array

How it works

  • Statements (lines 20–80): starts at ROM address 42145 ($A4A1). Each entry is a keyword whose last letter has bit 7 set, followed by a two-byte pointer into BASIC's syntax tables. The program prints characters until it meets the one with bit 7 set, prints that one with 128 subtracted, skips two bytes and moves on to the next token number. A zero byte ends the table.
  • Operators (lines 130–210): the second table at 42976 ($A7E0) is just names, again ending each one with bit 7. Some tokens appear more than once, because Atari BASIC uses separate tokens for the same symbol in different roles: = as comparison versus assignment, ( for strings, arrays and functions, and so on. Lines 150–160 attach the Czech descriptions to exactly those duplicates.

Gotchas

The addresses are hard-wired for Atari's own BASIC ROM. Under BASIC XL/XE, Turbo BASIC XL or the free Altirra BASIC replacement, the tables live elsewhere and you'll see garbage.

Listing

5 REM **** PODLE ATOM 11/89 ****
6 REM PRETUKAL ING.J.VACHA,NAMEST N.O.
10 ? CHR$(125):? " {inverse}  TABULKA PRIKAZU BASIC  {/inverse}":?
20 ADRESA=42145
30 IF NOT PEEK(ADRESA) THEN 90
40 ? TOKEN;" ";
50 BYTE=PEEK(ADRESA):ADRESA=ADRESA+1
60 IF BYTE<128 THEN ? CHR$(BYTE);:GOTO 50
70 ? CHR$(BYTE-128)
80 ADRESA=ADRESA+2:TOKEN=TOKEN+1:GOTO 30
90 ? "54 (IMPLITED LET)":? "55 ERROR (SYNTAX)":?:?
100 ? " {inverse}  TABULKA OPERATORU A FUNKCI  {/inverse}":?
110 ? "14 ciselna konstanta"
111 ? "15 retezcova konstanta"
112 ? "16, 17 nevyuzito"
120 DIM A$(30)
130 ADRESA=42976:TOKEN=18:A$=""
140 IF NOT PEEK(ADRESA) THEN ?:END
150 ? TOKEN;" ";:IF TOKEN=22 OR TOKEN=29 OR (TOKEN>44 AND TOKEN<48) OR (TOKEN>52 AND TOKEN<61) THEN READ A$
160 IF TOKEN=23 OR TOKEN=35 OR TOKEN>60 THEN A$=""
170 BYTE=PEEK(ADRESA):ADRESA=ADRESA+1
180 IF BYTE<128 THEN ? CHR$(BYTE);:GOTO 170
190 ? CHR$(BYTE-128);" ";A$
200 TOKEN=TOKEN+1
210 GOTO 140
220 DATA konec radku
230 DATA ciselne porovnani
240 DATA prirazeni cisla, prirazeni retezce
250 DATA retezcove porovnani
260 DATA zvlastni operatory,zvlastni operatory
270 DATA leva zavorka retezce,leva zavorka pole,leva zavorka DIM pole,funkce leve zavorky
280 DATA leva zavorka DIM retezce,carka v DIM poli

Credits