Keywords

This version of BASIC recognises 129 keywords, whose storage is worthy of explanation. First of all, there is a keyword directory containing 26 pointers to keyword groups, one for each letter of the alphabet.

Keyword Directory

Each entry in the directory points to the group of zero or more keywords beginning with that letter.

Addr.LetterGroup Addr.Addr.LetterGroup Addr.
013B:A016F0155:N02BA
013D:B01800157:O02CD
013F:C01810159:P02DD
0141:D01BD015B:Q02F1
0143:E01FA015D:R02F2
0145:F021F015F:S0322
0147:G02350161:T0351
0149:H02470163:U0368
014B:I024C0165:V0377
014D:J02620167:W0381
014F:K02630169:X038B
0151:L0268016B:Y038F
0153:M029C016D:Z0390

Thus you can see from the above that keywords beginning with 'A' are stored at 016F, keywords beginning with 'B' are stored at 0180, and so on.

Keyword Groups

There are 26 keyword groups, one for each letter of the alphabet. Because the first keyword letter is always known by the group the keyword belongs to, the first letter of each keyword is not stored. The keywords in a group are are concatenated and delimited as follows: the last byte of each keyword has it's topmost bit set to mark the end of the keyword. The byte following this is the keyword ID byte - an ID BASIC uses internally for processing keywords. The end of the group is marked with a null byte. Lets look at the raw bytes for the group of keywords beginning with 'A' which we know from the directory is stored at 016F:

016F: 4E C4 F7 42 D3 06 54 CE 0E 53 C3 15 55 54 CF AB 00

So this is interpreted as:

Addr.BytesKeywordID
016F:4E C4 F7(A)NDF7
0172:42 D3 06(A)BS06
0175:54 CE 0E(A)TN0E
0178:53 C3 15(A)SC15
017B:55 54 CF AB(A)UTOAB
017F:00 <-- end of group marker

This approach has two immediate benefits:
1. Parsing BASIC programs is faster: it's much quicker to search a mere handful of keywords than to iterate through all 129 of them.
2. Less space to required to store keywords. The keyword directory above occupies 26*3=78 bytes. By using such a directory, the first letter of each keyword is always known and therefore doesn't need to be stored. This saves one byte per keyword (ie 129 bytes), which is a profit of 51 bytes.

Those Keywords In Full

Here is the full list of keywords, in the order that BASIC has them stored. When this is finished, each keyword will be linked to the appropriate disassembly page.

KeywordID
ANDF7
ABS06
ATN0E
ASC15
AUTOAB
CONSOLEA0
CLOSEC3
CONT9A
CLEAR92
CLOAD9C
CSAVE9B
CINT1C
CSNG1D
CDBL1E
CVI2B
CVS2C
CVD2D
COS0C
CHR$16
DATA84
DIM86
DEFSTRAD
DEFINTAE
DEFSNGAF
DEFDBLB0
DSKO$BC
DEF98
DELETEAA
DSKI$2A
DSKF2E
DSKINICC
END81
ELSEA2
ERASEA6
EDITA7
ERRORA8
ERLD6
ERRD7
EXP0B
EOF2F
EQVFA
FOR82
FIELDC0
FILESC6
FND3
FRE0F
FIX1F
GOTO89
GO TO89
GOSUB8D
GETC1
HEX$1A
INPUT85
IF8B
INSTRDA
INT05
INP10
IMPFB
KILLC8
LET88
LINEB1
LOADC4
LSETC9
LPRINT9E
LIST93
LLIST9F
LPOS1B
LOG0A
LOC30
LEN12
LEFT$01
LOF31
MOUNTBE
MERGEC5
MODFC
MKI$32
MKS$33
MKD$34
MID$03
NEXT83
NULL96
NAMEC7
NEW94
NOTD5
OUT9D
ON95
OPENBF
ORF8
OCT$19
PUTC2
POKE99
PRINT91
POS11
PEEK17
READ87
RUN8A
RESTORE8C
RETURN8E
REM8F
RESUMEA9
RSETCA
RIGHT$02
RND08
RENUMAC
STOP90
SWAPA5
SAVECB
SPC(D4
STEPD1
SGN04
SQR07
SIN09
STR$13
STRING$D8
SPACE$18
TRONA3
TROFFA4
TAB(D0
TOCE
THENCF
TAN0D
UNLOADBD
USINGD9
USRD2
VAL14
VARPTRDC
WIDTHA1
WAIT97
XORF9