Entry point for the HARD_RESET routine, currently at $4023.
BASIC cold-start entry point. This is the normal entry point following a system reset.
Entry point for the SOFT_RESET routine, currently at $4009.
BASIC warm-start entry point. This is the normal entry point during a RUN/STOP-RESTORE NMI interrupt.
Entry point for the BASIC_IRQ routine, currently at $A84D.
BASIC IRQ entry point. The target routine supports sprite movement, sprite collision detection, light pen reading, and the BASIC music statements. This is the normal entry point during the system IRQ service routine.
This routine is the normal final step of the RUN/STOP-RESTORE sequence. It resets the SID registers and sound locations, and calls the routine at $418D to stop sprite movement. However, it does not reinitialize the BASIC vectors or pointers.
Three unused bytes filled with the value 255/$FF.
This routine is the normal final step of the reset sequence. It performs a complete initialization of BASIC, including resetting all vectors, pointers, and working storage locations to their default values. This routine also includes a call to the Kernal PHOENIX routine $FF56, which will start any function ROMs that may be present, or boot a disk if one is in the drive.
This is the main initalization routine of the cold-start sequence. It is responsible for setting all RAM working storage locations for BASIC to their default values.
This routine sets all SID chip registers to 0/$00 and initializes all locations associated with the SOUND and PLAY statements.
This routine copies a 0/$00 into the speed control byte for each entry in the sprite movement table at $117E, effectively halting all sprite motion.
This routine displays the text from the following area of ROM. Note that the free memory figure is part of the ROM message, and may not reflect the actual amount of memory available to BASIC.
{CLR} COMMODORE BASIC V7.0 122365 BYTES FREE (C)1985 COMMODORE ELECTRONICS, LTD. (C)1977 MICROSOFT CORP. ALL RIGHTS RESERVED
This routine copies the BASIC indirect vectors from the following table to locations 768-785/$0300-$0311, and initializes the vector at $02FC-$02FD.
This area contains the default addresses copied into the page 3 indirect vectors by the routine at $4251.
This area contains the code for CHRGET and the other page 3 character retrieval subroutines. The routines are copied into RAM.
The following table holds the BASIC 7.0 keywords in token number order. Bit 7 of the last character of each keyword will be set to %1 to indicate the end of the keyword.
Token | Keyword | Token | Keyword |
---|---|---|---|
128/$80 | END | 160/$A0 | CLOSE |
129/$81 | FOR | 161/$A1 | GET |
130/$82 | NEXT | 162/$A2 | NEW |
131/$83 | DATA | 163/$A3 | TAB( |
132/$84 | INPUT# | 164/$A4 | TO |
133/$85 | INPUT | 165/$A5 | FN |
134/$86 | DIM | 166/$A6 | SPC( |
135/$87 | READ | 167/$A7 | THEN |
136/$88 | LET | 168/$A8 | NOT |
137/$89 | GOTO | 169/$A9 | STEP |
138/$8A | RUN | 170/$AA | + |
139/$8B | IF | 171/$AB | - |
140/$8C | RESTORE | 172/$AC | * |
141/$8D | GOSUB | 173/$AD | / |
142/$8E | RETURN | 174/$AE | ^ |
143/$8F | REM | 175/$AF | AND |
144/$90 | STOP | 176/$B0 | OR |
145/$91 | ON | 177/$B1 | > |
146/$92 | WAIT | 178/$B2 | = |
147/$93 | LOAD | 179/$B3 | < |
148/$94 | SAVE | 180/$B4 | SGN |
149/$95 | VERIFY | 181/$B5 | INT |
150/$96 | DEF | 182/$B6 | ABS |
151/$97 | POKE | 183/$B7 | USR |
152/$98 | PRINT# | 184/$B8 | FRE |
153/$99 | 185/$B9 | POS | |
154/$9A | CONT | 186/$BA | SQR |
155/$9B | LIST | 187/$BB | RND |
156/$9C | CLR | 188/$BC | LOG |
157/$9D | CMD | 189/$BD | EXP |
158/$9E | SYS | 190/$BE | COS |
159/$9F | OPEN | 191/$BF | SIN |
192/$C0 | TAN | 224/$E0 | CHAR |
193/$C1 | ATN | 225/$E1 | BOX |
194/$C2 | PEEK | 226/$E2 | CIRCLE |
195/$C3 | LEN | 227/$E3 | GSHAPE |
196/$C4 | STR$ | 228/$E4 | SSHAPE |
197/$C5 | VAL | 229/$E5 | DRAW |
198/$C6 | ASC | 230/$E6 | LOCATE |
199/$C7 | CHR$ | 231/$E7 | COLOR |
200/$C8 | LEFT$ | 232/$E8 | SCNCLR |
201/$C9 | RIGHT$ | 233/$E9 | SCALE |
202/$CA | MID$ | 234/$EA | HELP |
203/$CB | GO | 235/$EB | DO |
204/$CC | RGR | 236/$EC | LOOP |
205/$CD | RCLR | 237/$EO | EXIT |
206/$CE | function token extender | 238/$EE | DIRECTORY |
207/$CF | JOY | 239/$EF | DSAVE |
208/$D0 | ROOT | 240/$F0 | DLOAD |
209/$D1 | OEC | 241/$F1 | HEADER |
210/$D2 | HEX$ | 242/$F2 | SCRATCH |
211/$D3 | ERR$ | 243/$F3 | COLLECT |
212/$D4 | INSTR | 244/$F4 | COPY |
213/$D5 | ELSE | 245/$F5 | RENAME |
214/$D6 | RESUME | 246/$F6 | BACKUP |
215/$D7 | TRAP | 247/$F7 | OELETE |
216/$D8 | TRON | 248/$F8 | RENUMBER |
217/$D9 | TROFF | 249/$F9 | KEY |
218/$DA | SOUNO | 250/$FA | MONITOR |
219/$DB | VOL | 251/$FB | USING |
220/$DC | AUTO | 252/$FC | UNTIL |
221/$DD | PUOEF | 253/$FO | WHILE |
222/$DE | GRAPHIC | 254/$FE | statement token extender |
223/$DF | PAINT |
BASIC 7.0 has too many keywords to have a one-byte token for each. Additional statements use a two-byte token where the first byte is always 254/$FE. This table holds the extended token statement keywords in order of the second byte of the token. Like the standard keywords, bit 7 of the last character of each keyword will be set to %1.
Token | Keyword | Token | Keyword |
---|---|---|---|
2/$02 | BANK | 21/$15 | DCLEAR |
3/$03 | FILTER | 22/$16 | SPRSAV |
4/$04 | PLAY | 23/$17 | COLLISION |
5/$05 | TEMPO | 24/$18 | BEGIN |
6/$06 | MOVSPR | 25/$19 | BEND |
7/$07 | SPRITE | 26/$1A | WINDOW |
8/$08 | SPRCOLOR | 27/$1B | BOOT |
9/$09 | RREG | 28/$1C | WIDTH |
10/$0A | ENVELOPE | 29/$1D | SPRDEF |
11/$0B | SLEEP | 30/$1E | QUIT |
12/$0C | CATALOG | 31/$1F | STASH |
13/$0D | DOPEN | 32/$20 | (no keyword for this token) |
14/$0E | APPEND | 33/$21 | FETCH |
15/$0F | DCLOSE | 34/$22 | (no keyword for this token) |
16/$10 | BSAVE | 35/$23 | SWAP |
17/$11 | BLOAD | 36/$24 | OFF |
18/$12 | RECORD | 37/$25 | FAST |
19/$13 | CONCAT | 38/$26 | SLOW |
BASIC 7.0 has too many keywords to have a one-byte token for each. Additional functions use a two-byte token where the first byte is always 206/$CE. This table holds the extended token function keywords in order of the second byte of the token. Like the standard keywords, bit 7 of the last character of each entry is set to % 1.
Token | Keyword |
---|---|
2/$02 | POT |
3/$03 | BUMP |
4/$04 | PEN |
5/$05 | RSPPOS |
6/$06 | RSPRITE |
7/$07 | RSPCOLOR |
8/$08 | XOR |
9/$09 | RWINDOW |
10/$0A | POINTER |
This area holds the address of the routines to execute tokens 128-162/$80-$A2. Because of the way statement execution is handled, the values here are actually one less than the address of the target routine.
This area holds the address of the routines to execute tokens 213-250/$D5-$FA. Because of the way statement execution is handled, the values here are actually one less than the address of the target routine.
This area holds the address of the routines to execute extended statement tokens 2-38/$02-$26. Because of the way statement execution is handled, the values here are actually one less than the address of the target routine.
This area holds the address of the routines to execute tokens 180-211/$B4-$D3.
This area holds the address of the routines to execute extended function tokens 2-10/$02-$0A.
Each mathematical operator such as +, -, *, and / has a three-byte entry in this table. The first byte is the priority of the operator for expression evaluation and the next two are the address of the routine to perform the specified operation.
BASIC 7.0 contains two unused keywords, QUIT and OFF.
Either of those will use this routine to print the UNIMPLEMENTED COMMAND error message.
This area holds text for the BASIC error messages in error number order. Bit 7 in the last character of each message will be set to %1 to mark the end of the message.
Error number | Error message |
---|---|
1/$01 | TOO MANY FILES |
2/$02 | FILE OPEN |
3/$03 | FILE NOT OPEN |
4/$04 | FILE NOT FOUND |
5/$05 | DEVICE NOT PRESENT |
6/$06 | NOT INPUT FILE |
7/$07 | NOT OUTPUT FILE |
8/$08 | MISSING FILE NAME |
9/$09 | ILLEGAL DEVICE NUMBER |
lO/$OA | NEXT WITHOUT FOR |
11/$OB | SYNTAX |
12/$OC | RETURN WITHOUT GOSUB |
13/$OD | OUT OF DATA |
14/$OE | ILLEGAL QUANTITY |
15/$OF | OVERFLOW |
16/$10 | OUT OF MEMORY |
17/$11 | UNDEF’D STATEMENT |
18/$12 | BAD SUBSCRIPT |
19/$13 | REDIM’D ARRAY |
20/$14 | DIVISION BY ZERO |
21/$15 | ILLEGAL DIRECT |
22/$16 | TYPE MISMATCH |
23/$17 | STRING TOO LONG |
24/$18 | FILE DATA |
25/$19 | FORMULA TOO COMPLEX |
26/$1A | CAN’T CONTINUE |
27/$1B | UNDEF’D FUNCTION |
28/$1C | VERIFY |
29/$1D | LOAD |
30/$1E | BREAK |
31/$1F | CAN’T RESUME |
32/$20 | LOOP NOT FOUND |
33/$21 | LOOP WITHOUT DO |
34/$22 | DIRECT MODE ONLY |
35/$23 | NO GRAPHICS AREA |
36/$24 | BAD DISK |
37/$25 | BEND NOT FOUND |
38/$26 | LINE NUMBER TOO LARGE |
39/$27 | UNRESOLVED REFERENCE |
40/$28 | UNIMPLEMENTED COMMAND |
41/$29 | FILE READ |
Sets locations $26-$27 to point to the error number specified in the accmulator upon entry.
This routine handles COLLISION processing, then falls through into the next routine to execute the current BASIC statement.
This routine tests whether the RUN/STOP key is being pressed. If so, a branch will be taken into the following routine.
This routine is the normal path back to immediate mode after a program or previous immediate mode line has been executed. It prints the READY prompt and falls through into the MAIN routine.
This routine tests whether there is sufficient space in the string pool before a string is added. If no space is available, garbage collection is attempted.
This routine converts a string of characters at the current text pointer address into a two-byte integer value in locations $16-$17.
This routine resets the CHRGET text pointer, locations 61-62/ $3D-$3E, to the beginning of the BASIC text area.
This routine evaluates the expression on the right of a relational operator and assigns the resulting value to the variable on the left.
Begins by testing whether the GO token is followed by the token for TO, indicating that GOTO was entered as GO TO. The acceptance of GO TO as a synonym for GOTO is unique to Commodore.
This routine has many suboutines to handle parsing and execution of the strings of music data. PLAY is actually a minilanguage within BASIC.
This routine sets up the conditions for COLLISION checking. The actual testing for collisions occurs during the BASIC IRQ routine $A84D.
If a filename is provided, the routine does the equivalent of BLOAD followed by SYS, rather than actually attempting to boot a disk.
SPRDEF isn’t really a statement; it’s a built-in machine language sprite-design utility program.
This routine is also responsible for processing all the BASIC reserved variables: TI, TI$, ST, DS, DS$, ER, and EL.
This routine searches the variable table in bank 1 for a specified variable, and creates the variable if it does not already exist.
This unused area of BASIC ROM is filled with the value 255/$FF.
When you use the statement SYS 32800,123,45,6, you’ll get a rather political message from the designers of the 128.
This routine returns with locations $24-25 set to point to the string and the Y register holding the length of the string.
This routine evaluates a numeric parameter and checks that it is in the range 0-255/$00-$FF. If the parameter is valid, it will be returned in the X register.
This routine retrieves a pair of parameters: The first, a value in the range 0-65535/$0000-$FFFF, will be returned in locations $16-$17, and the second, a value in the range 0-255/ $00-$FF, will be returned in the X register.
This routine retrieves a numeric parameter, checking that it is in the range 0-65535/$0000-$FFFF. If the value is valid, it will be returned in locations $16-$17.
Loads FAC2 with the five-byte floating-point value pointed to by the accumulator and Y register (low byte/high byte), then subtracts the value in FAC2 from the one in FAC1, leaving the results in FAC1.
Subtracts the value in FAC2 from the one in FAC1, leaving the results in FAC1.
Loads FAC2 with the five-byte floating-point value pointed to by the accumulator and Y register (low byte/high byte), then adds the value in FAC2 to the one in FAC1, leaving the results in FAC1.
Adds the value in FAC2 to the one in FAC1, leaving the results in FAC1.
Loads FAC2 with the five-byte floating-point value pointed to by the accumulator and Y register (low byte/high byte), then multiplies the value in FAC2 by the one in FAC1, leaving the results in FAC1.
Loads FAC2 with the five-byte floating-point value pointed to by the accumulator and Y register (low byte/high byte), then multiplies the value in FAC2 by the one in FAC1, leaving the results in FAC1.
Loads FAC2 with the five-byte floating-point value pointed to by the accumulator and Y register (low byte/high byte).
Loads FAC2 with the five-byte floating-point value in bank 1 pointed to by the accumulator and Y register (low byte/high byte).
Loads FAC2 with the five-byte floating-point value pointed to by the accumulator and Y register (low byte/high byte), then divides the value in FAC2 by the one in FAC1, leaving the results in FAC1.
Divides the value in FAC2 by the one in FAC1, leaving the results in FAC1.
Loads FAC1 with the five-byte floating-point value pointed to by the accumulator and Y register (low byte/high byte).
Stores the value in FAC1 in five bytes pointed to by the X and Y registers (low byte/high byte).
Fills FAC1 with the value in the accumulator
This routine reads a character string from BASIC program text and generates the equivalent floating-point value in FAC1.
This routine generates a string based on the value in $3B-$3C, then prints the results.
This routine generates a string of characters in the work area at 256/$0100 representing the value in FAC1.
This routine calculates the square root of the value in FAC1, taking advantage of the fact that SQR(X) = X ^ 0.5.
This routine raises the value in FAC1 to the power specified in FAC2. This routine takes advantage of the fact that A ^ B = EXP(LOG(A) * B).
The subroutines in this area are BASIC’s formal calls to Kernal routines:
Address | Routine |
---|---|
37457/$9251 | READSS |
37463/$9257 | SETLFS |
37469/$9250 | SETNAM |
37475/$9263 | BASIN |
37481/$9269 | BSOUT |
37487/$926F | CLRCH |
37493/$9275 | CLOSE |
37499/$927B | CLALL |
37505/$9281 | PRIMM |
37511/$9287 | SETBANK |
37517/$9280 | PLOT |
37523/$9293 | STOP |
This routine takes advantage of the fact that COS(X) = SIN (X + $\pi$/2).
This routine takes advantage of the fact that TAN (X) = SIN(X) / COS(X).
This routine supports the MOVSPR sprite movement statement, the COLLISION statement, and the PEN function. It is also responsible for updating the duration timers for the SOUND and PLAY statements.
All locations in this unused area of ROM are filled with the value 255/$FF.
This area contains a heavily encoded message from the designers of the 128.