Tandy 200 BASIC tokenized file
m (→File Format: Tidy language) |
m (→Acceptable variances: use specific verb) |
||
Line 309: | Line 309: | ||
=== Acceptable variances === | === Acceptable variances === | ||
− | While Tandy BASIC will never generate such files, it has no problem | + | While Tandy BASIC will never generate such files, it has no problem loading a tokenized program that: |
* Has line numbers out of order; they will be sorted when loaded. | * Has line numbers out of order; they will be sorted when loaded. | ||
Line 317: | Line 317: | ||
* Contains illegal line numbers; this can be used to store hidden binary data [https://www.mail-archive.com/m100@lists.bitchin100.com/msg16195.html according to John R. Hogerhuis]. | * Contains illegal line numbers; this can be used to store hidden binary data [https://www.mail-archive.com/m100@lists.bitchin100.com/msg16195.html according to John R. Hogerhuis]. | ||
− | Note that while these variances are accepted on an actual Model T device (Model 100, Tandy 200, or Tandy 102), emulators may not be able to handle such files. For example, the [https://sourceforge.net/projects/virtualt/ Virtual T] emulator (as of version 1.7 in 2022) refuses to load tokenized BASIC programs that have lines out of order, duplicate lines, or bogus values for PL PH. | + | Note that while these variances are accepted on an actual Model T device (Model 100, Tandy 200, or Tandy 102), emulators may not be able to handle such files. For example, the [https://sourceforge.net/projects/virtualt/ Virtual T] emulator (as of version 1.7 in 2022) refuses to load tokenized BASIC programs that have lines out of order, duplicate lines, or bogus values for PL PH. |
=== Details for PL PH === | === Details for PL PH === |
Revision as of 20:56, 5 October 2022
Tandy 200 BASIC was a version of Microsoft BASIC for the Radio Shack Tandy 200 computer. The tokenizations for the TRS-80 Model 100 and Tandy 102 appear to be identical. The NEC PC-8201/8300 format is not the same, but should be similar.
Contents |
Tokens
Table of tokenized BASIC keywords.
Hex | Dec | Token meaning | Notes |
---|---|---|---|
80 | 128 | END | |
81 | 129 | FOR | |
82 | 130 | NEXT | |
83 | 131 | DATA | |
84 | 132 | INPUT | |
85 | 133 | DIM | |
86 | 134 | READ | |
87 | 135 | LET | |
88 | 136 | GOTO | |
89 | 137 | RUN | |
8A | 138 | IF | |
8B | 139 | RESTORE | |
8C | 140 | GOSUB | |
8D | 141 | RETURN | |
8E | 142 | REM | |
8F | 143 | STOP | |
90 | 144 | WIDTH | |
91 | 145 | ELSE | When tokenizing, the Tandy 200 always adds a colon (':') before the ELSE token (3A 91). If the user actually writes :ELSE it is tokenized as 3A 3A 91. |
92 | 146 | LINE | |
93 | 147 | EDIT | |
94 | 148 | ERROR | |
95 | 149 | RESUME | |
96 | 150 | OUT | |
97 | 151 | ON | |
98 | 152 | DSKO$ | |
99 | 153 | OPEN | |
9A | 154 | CLOSE | |
9B | 155 | LOAD | Note that LOADM is simply the token for LOAD followed by an ASCII 'M'. |
9C | 156 | MERGE | |
9D | 157 | FILES | |
9E | 158 | SAVE | |
9F | 159 | LFILES | |
A0 | 160 | LPRINT | |
A1 | 161 | DEF | |
A2 | 162 | POKE | |
A3 | 163 | ||
A4 | 164 | CONT | |
A5 | 165 | LIST | |
A6 | 166 | LLIST | |
A7 | 167 | CLEAR | |
A8 | 168 | CLOAD | |
A9 | 169 | CSAVE | |
AA | 170 | TIME$ | |
AB | 171 | DATE$ | |
AC | 172 | DAY$ | |
AD | 173 | COM | |
AE | 174 | MDM | |
AF | 175 | KEY | |
B0 | 176 | CLS | |
B1 | 177 | BEEP | |
B2 | 178 | SOUND | |
B3 | 179 | LCOPY | |
B4 | 180 | PSET | |
B5 | 181 | PRESET | |
B6 | 182 | MOTOR | |
B7 | 183 | MAX | |
B8 | 184 | POWER | |
B9 | 185 | CALL | |
BA | 186 | MENU | |
BB | 187 | IPL | |
BC | 188 | NAME | |
BD | 189 | KILL | |
BE | 190 | SCREEN | |
BF | 191 | NEW | |
C0 | 192 | TAB( | |
C1 | 193 | TO | |
C2 | 194 | USING | |
C3 | 195 | VARPTR | |
C4 | 196 | ERL | |
C5 | 197 | ERR | |
C6 | 198 | STRING$ | |
C7 | 199 | INSTR | |
C8 | 200 | DSKI$ | |
C9 | 201 | INKEY$ | |
CA | 202 | CSRLIN | |
CB | 203 | OFF | |
CC | 204 | HIMEM | |
CD | 205 | THEN | |
CE | 206 | NOT | |
CF | 207 | STEP | |
D0 | 208 | + | |
D1 | 209 | - | |
D2 | 210 | * | |
D3 | 211 | / | |
D4 | 212 | ^ | |
D5 | 213 | AND | |
D6 | 214 | OR | |
D7 | 215 | XOR | |
D8 | 216 | EQV | |
D9 | 217 | IMP | |
DA | 218 | MOD | |
DB | 219 | \ | |
DC | 220 | > | |
DD | 221 | = | |
DE | 222 | < | |
DF | 223 | SGN | |
E0 | 224 | INT | |
E1 | 225 | ABS | |
E2 | 226 | FRE | |
E3 | 227 | INP | |
E4 | 228 | LPOS | |
E5 | 229 | POS | |
E6 | 230 | SQR | |
E7 | 231 | RND | |
E8 | 232 | LOG | |
E9 | 233 | EXP | |
EA | 234 | COS | |
EB | 235 | SIN | |
EC | 236 | TAN | |
ED | 237 | ATN | |
EE | 238 | PEEK | |
EF | 239 | EOF | |
F0 | 240 | LOC | |
F1 | 241 | LOF | |
F2 | 242 | CINT | |
F3 | 243 | CSNG | |
F4 | 244 | CDBL | |
F5 | 245 | FIX | |
F6 | 246 | LEN | |
F7 | 247 | STR$ | |
F8 | 248 | VAL | |
F9 | 249 | ASC | |
FA | 250 | CHR$ | |
FB | 251 | SPACE$ | |
FC | 252 | LEFT$ | |
FD | 253 | RIGHT$ | |
FE | 254 | MID$ | |
FF | 255 | ' (QUOTE) | When tokenizing, the single quote character expands to three characters: a colon (3A), the byte for REM (8E), and then FF. |
File Format
Tokenised BASIC code is a sequence of tokenized lines. Each tokenized line has the following format:
Name | Length | Description |
---|---|---|
PL PH | 2 bytes | Address in RAM of the next line of BASIC; unsigned 16-bit integer, little-endian. PL PH equal to zero marks the end of a tokenized BASIC listing. All other values can be ignored as they are merely placeholders in the file. During program load, Tandy BASIC always recalculates PL PH. Once in memory, PL PH is used to skip to the line required for GOTO, GOSUB, and READ, thus speeding up the program. |
LL LH | 2 bytes | Line number, unsigned 16-bit integer, little-endian. |
B0 … Bn | Any number | Sequence of tokens or ASCII characters. If a character's value is ≥ 128, then it is a token. All tokens are a single byte. |
NULL | 1 byte | NULL byte (0x00 ) to signal end of line.
|
The end of the tokenized data is signaled by two consecutive NULLs in the location where PL PH would normally begin a new line.
Limits
- Line numbers can range from 0 to 65529 (but see variances below).
- Tokenized line length is limited to 256 characters, including the trailing NULL byte. (To do: double check this.)
Acceptable variances
While Tandy BASIC will never generate such files, it has no problem loading a tokenized program that:
- Has line numbers out of order; they will be sorted when loaded.
- Contains duplicate line numbers; previous line is discarded.
- Contains arbitrary bytes for PL PH; they are always regenerated during loading.
- Has a ^Z (ASCII 26) at the end of the file.
- Contains illegal line numbers; this can be used to store hidden binary data according to John R. Hogerhuis.
Note that while these variances are accepted on an actual Model T device (Model 100, Tandy 200, or Tandy 102), emulators may not be able to handle such files. For example, the Virtual T emulator (as of version 1.7 in 2022) refuses to load tokenized BASIC programs that have lines out of order, duplicate lines, or bogus values for PL PH.
Details for PL PH
(Stub. This is where the correct calculation of PL PH values will go.)
Format documentation
- Discussion of byte format on Bitchin 100 Mailing List
- BASIC program to create a table of tokens
- Hidden Powers of the TRS 80 Model 100. Appendix B lists the BASIC token values for the Model 100. Other than the omission of 255 for a single quote remark, this reference matches what hackerb9 found programmatically for the Tandy 200.
- Ayra Model 100 BASIC Reference