Applesoft BASIC tokenized file

From Just Solve the File Format Problem
Jump to: navigation, search
File Format
Name Applesoft BASIC tokenized file
Ontology
Wikidata ID Q28600391
Released 1977

Applesoft BASIC was licensed from Microsoft (with some changes by Apple) and originally made available to be loaded from tape or disk. Apple models starting with the Apple II+ (the first new model after the Apple II) had Applesoft BASIC in ROM instead of the older Integer BASIC. An Applesoft I language was first released in 1977, followed by Applesoft II Floating Point BASIC in 1978, which is the most-used version. The later Apple III Business BASIC was based on Applesoft.

There were some notorious bugs in Applesoft, such as an implementation of ONERR GOTO which messed up the program stack, requiring some devious peeks, pokes, and calls to get around it. Unfortunately, the fact that the language was stored in ROM (except for users of really old Apples who loaded it from disk or tape) made it difficult to update with bug fixes (unlike today's software that pesters you to install new updates practically every time you start your computer), and they couldn't fix it in newer machines either, since that would break all the old programs that expected the bug. So Apple users were stuck with the bugs for the whole life of that platform.

Applesoft BASIC programs were stored in a tokenized format, in files which were designated in Apple DOS directories as type "A".

Similar to a number of other BASIC tokenizations (but distinct from Integer BASIC tokenization), Applesoft programs preserved ASCII characters unchanged in the 7-bit range (bytes with high bit clear) and used the "high bit set" byte values (#128-#255) to store tokens. BASIC lines were separated by the null byte (00), and started with a two-byte address of the next program line in memory, then a two-byte little-endian integer giving the line number, then the tokenized commands and literal characters of the program line.

The token list reveals what is probably the most obscure command in Applesoft BASIC (or maybe any BASIC at all), SHLOAD. Urban Dictionary defines this as a synonym for "shitload", but Applesoft uses it as a command to load a shape table from cassette. Yes, cassette... to do the same from disk required some messy PEEKs and POKEs. Well, doing just about anything on an Apple II ended up requiring PEEKs and POKEs and CALLs... if you were a serious Apple programmer, you probably had some of those Beagle Bros. charts listing them.

Microsoft released a compiler for Applesoft called TASC (The AppleSoft Compiler).

Contents

Tokens

Blank values indicate either that the token is unused or is used for something unknown.

Hex Dec Token meaning
80 128 END
81 129 FOR
82 130 NEXT
83 131 DATA
84 132 INPUT
85 133 DEL
86 134 DIM
87 135 READ
88 136 GR
89 137 TEXT
8A 138 PR #
8B 139 IN #
8C 140 CALL
8D 141 PLOT
8E 142 HLIN
8F 143 VLIN
90 144 HGR2
91 145 HGR
92 146 HCOLOR=
93 147 HPLOT
94 148 DRAW
95 149 XDRAW
96 150 HTAB
97 151 HOME
98 152 ROT=
99 153 SCALE=
9A 154 SHLOAD
9B 155 TRACE
9C 156 NOTRACE
9D 157 NORMAL
9E 158 INVERSE
9F 159 FLASH
A0 160 COLOR=
A1 161 POP
A2 162 VTAB
A3 163 HIMEM:
A4 164 LOMEM:
A5 165 ONERR
A6 166 RESUME
A7 167 RECALL
A8 168 STORE
A9 169 SPEED=
AA 170 LET
AB 171 GOTO
AC 172 RUN
AD 173 IF
AE 174 RESTORE
AF 175 &
B0 176 GOSUB
B1 177 RETURN
B2 178 REM
B3 179 STOP
B4 180 ON
B5 181 WAIT
B6 182 LOAD
B7 183 SAVE
B8 184 DEF FN
B9 185 POKE
BA 186 PRINT
BB 187 CONT
BC 188 LIST
BD 189 CLEAR
BE 190 GET
BF 191 NEW
C0 192 TAB
C1 193 TO
C2 194 FN
C3 195 SPC(
C4 196 THEN
C5 197 AT
C6 198 NOT
C7 199 STEP
C8 200 +
C9 201 -
CA 202 *
CB 203 /
CC 204 ;
CD 205 AND
CE 206 OR
CF 207 >
D0 208 =
D1 209 <
D2 210 SGN
D3 211 INT
D4 212 ABS
D5 213 USR
D6 214 FRE
D7 215 SCRN (
D8 216 PDL
D9 217 POS
DA 218 SQR
DB 219 RND
DC 220 LOG
DD 221 EXP
DE 222 COS
DF 223 SIN
E0 224 TAN
E1 225 ATN
E2 226 PEEK
E3 227 LEN
E4 228 STR$
E5 229 VAL
E6 230 ASC
E7 231 CHR$
E8 232 LEFT$
E9 233 RIGHT$
EA 234 MID$
EB 235
EC 236
ED 237
EE 238
EF 239
E0 240
F1 241
F2 242
F3 243
F4 244
F5 245
F6 246
F7 247
F8 248
F9 249
FA 250
FB 251
FC 252
FD 253
FE 254
FF 255

Format documentation

Manuals

Tools

Other links

Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox