
BASIC IV ROM Routines
Page Last Altered:
Submitted by Steve Fewell
Description:
This routine has many entry points (depending on how the last statement finished and what needs to be done to tidy up
before the next statement can be executed. The entry points are listed between square brackets ([]).
Therefore, this routine may not necessarily be executed in the order described.
[&8FAE] Skip the rest of the line. This routine is called when a DATA keyword is found (as DATA statements are skipped
when reached and not executed (as the READ command controls how they are handled). It is also called when the DEF keyword
is found (as function and procedure definitions are not directly executed until they are called by an FN or PROC keyword).
This routine is also called when a REM keyword is found, to skip the rest of the line - as it is a comment line.
Additionally, this routine is also executed when a '*' command is found (the '*' command is first passed to the Operating
System OSCLI routine and then this routine skips the line - so that BASIC doesn't try to execute the '*' command.
The rest of the line is skipped as follows:
* Set A to #&0D (the end of line character - '<cr>').
* Set Y to the BASIC Text Pointer A offset (&0A) - 1.
* Keep incrementing Y and checking the character at BASIC Text pointer A (&0B-&0C) plus Y (offset) with the
character in A (the '<cr>' character) until the characters match.
* Call routine &9BBC to update the BASIC Text Pointer A address (to include the Y offset value) and to reset the offset
(&0A) to 1. (basically, this adds Y to the Text Pointer A address (&0B-&0C)).
[&8FBD] This routine checks whether the last character read (in A) is '<cr>', if it isn't then jump to &8FAE
to skip the rest of the line.
Now, we are at the end of the line (i.e. we have reached the '<cr>' character).
[&8FC1] If the BASIC Text pointer MSB address is #&07 then there are no more program lines to execute (as we were
executing a statement from the command line - and not from within a program), so jump to &8F86 to prompt for the next
command line input.
Set Y to #&01.
Load the next character (offset Y) from the BASIC text pointer A location.
If the character is negative (i.e. #&FF) then we have reached the end of the program, so jump to &8F86 to prompt
for the next command line input.
| 8FAE | 169 013 | A9 0D | LDA#&0D | |
| 8FB0 | 164 010 | A4 0A | LDY &0A | |
| 8FB2 | 136 | 88 | DEY | |
| 8FB3 | 200 | C8 | INY | |
| 8FB4 | 209 011 | D1 0B | CMP (&0B),Y | |
| 8FB6 | 208 251 | D0 FB | BNE -5 --> &8FB3 | |
| 8FB8 | 032 188 155 | 20 BC 9B | JSR &9BBC Update BASIC Text pointer A (Add offset value & then reset offset to 1) | |
| 8FBB | 128 004 | 80 04 | BRA 4 --> &8FC1 Process the next program line | |
| 8FBD | 201 013 | C9 0D | CMP#&0D | |
| 8FBF | 208 237 | D0 ED | BNE -19 --> &8FAE Skip the rest of the line and process the next program line | |
| 8FC1 | 165 012 | A5 0C | LDA &0C | |
| 8FC3 | 201 007 | C9 07 | CMP#&07 | |
| 8FC5 | 240 191 | F0 BF | BEQ -65 --> &8F86 Read & execute command line input | |
| 8FC7 | 160 001 | A0 01 | LDY#&01 | |
| 8FC9 | 177 011 | B1 0B | LDA (&0B),Y | |
| 8FCB | 0 | 048 185 | 30 B9 | BMI -71 --> &8F86 Read & execute command line input |
| 8FCD | 166 032 | A6 20 | LDX &20 | |
| 8FCF | 240 010 | F0 0A | BEQ 10 --> &8FDB | |
| 8FD1 | + | 133 043 | 85 2B | STA &2B |
| 8FD3 | 200 | C8 | INY | |
| 8FD4 | 177 011 | B1 0B | LDA (&0B),Y | |
| 8FD6 | * | 133 042 | 85 2A | STA &2A |
| 8FD8 | K | 032 075 156 | 20 4B 9C | JSR &9C4B Display current line number (IWA) on screen [if TRACE is on] |
| 8FDB | 160 004 | A0 04 | LDY#&04 | |
| 8FDD | 132 010 | 84 0A | STY &0A | |
| 8FDF | , | 128 044 | 80 2C | BRA 44 --> &900D |
| 8FE1 | 169 003 | A9 03 | LDA#&03 | |
| 8FE3 | ( | 133 040 | 85 28 | STA &28 |
| 8FE5 | L | 076 032 137 | 4C 20 89 | JMP &8920 '[' Begin Assembly |
| 8FE8 | L | 076 147 190 | 4C 93 BE | JMP &BE93 EXT = |
| 8FEB | 164 010 | A4 0A | LDY &0A | |
| 8FED | 136 | 88 | DEY | |
| 8FEE | 177 011 | B1 0B | LDA (&0B),Y | |
| 8FF0 | * | 201 042 | C9 2A | CMP#&2A |
| 8FF2 | 240 176 | F0 B0 | BEQ -80 --> &8FA4 '*'-Command | |
| 8FF4 | [ | 201 091 | C9 5B | CMP#&5B |
| 8FF6 | 240 233 | F0 E9 | BEQ -23 --> &8FE1 | |
| 8FF8 | 201 162 | C9 A2 | CMP#&A2 | |
| 8FFA | 240 236 | F0 EC | BEQ -20 --> &8FE8 | |
| 8FFC | = | 201 061 | C9 3D | CMP#&3D |
| 8FFE | ` | 240 096 | F0 60 | BEQ 96 --> &9060 '=' Return from Function Call (FN) |
| 9000 | 198 010 | C6 0A | DEC &0A | |
| 9002 | 032 166 155 | 20 A6 9B | JSR &9BA6 Check end of Statement | |
| 9005 | 178 011 | B2 0B | LDA (&0B) | |
| 9007 | : | 201 058 | C9 3A | CMP#&3A |
| 9009 | 208 178 | D0 B2 | BNE -78 --> &8FBD Skip the rest of the line (until '<cr>' found) & process the next program line | |
| 900B | 164 010 | A4 0A | LDY &0A | |
| 900D | 230 010 | E6 0A | INC &0A | |
| 900F | 177 011 | B1 0B | LDA (&0B),Y | |
| 9011 | 201 032 | C9 20 | CMP#&20 | |
| 9013 | 240 246 | F0 F6 | BEQ -10 --> &900B | |
| 9015 | 201 207 | C9 CF | CMP#&CF | |
| 9017 | 144 012 | 90 0C | BCC 12 --> &9025 | |
| 9019 | 010 | 0A | ASL A | |
| 901A | 170 | AA | TAX | |
| 901B | ÝM | 124 077 135 | 7C 4D 87 | JMP (&874D,X) |
| 901E | 032 224 142 | 20 E0 8E | JSR &8EE0 Get next non-space character pointed to by Ptr A | |
| 9021 | 201 198 | C9 C6 | CMP#&C6 | |
| 9023 | 176 244 | B0 F4 | BCS -12 --> &9019 | |
| 9025 | 166 011 | A6 0B | LDX &0B | |
| 9027 | 134 025 | 86 19 | STX &19 | |
| 9029 | 166 012 | A6 0C | LDX &0C | |
| 902B | 134 026 | 86 1A | STX &1A | |
| 902D | 132 027 | 84 1B | STY &1B | |
| 902F | 032 009 153 | 20 09 99 | JSR &9909 Evaluate variable/array name & return the address of the value | |
| 9032 | 208 027 | D0 1B | BNE 27 --> &904F Create variable (LET) | |
| 9034 | 176 181 | B0 B5 | BCS -75 --> &8FEB | |
| 9036 | 134 027 | 86 1B | STX &1B | |
| 9038 | 032 134 155 | 20 86 9B | JSR &9B86 Check for '=' | |
| 903B | T | 032 084 152 | 20 54 98 | JSR &9854 Create new variable name in variable pointer table |
| 903E | 162 005 | A2 05 | LDX#&05 | |
| 9040 | , | 228 044 | E4 2C | CPX &2C |
| 9042 | 208 001 | D0 01 | BNE 1 --> &9045 | |
| 9044 | 232 | E8 | INX | |
| 9045 | 032 131 152 | 20 83 98 | JSR &9883 Allocate space for variable | |
| 9048 | 198 010 | C6 0A | DEC &0A | |
| 904A | ...LET keyword... |
| 9B86 | 032 213 142 | 20 D5 8E | JSR &8ED5 Get next non-space character (PTR B) | |
| 9B89 | = | 201 061 | C9 3D | CMP#&3D |
| 9B8B | 208 211 | D0 D3 | BNE -45 --> Mistake error | |
| 9B8D | ` | 096 | 60 | RTS |