Submitted by Steve Fewell
Description:
Zero &3B (FOR counter) & &3C (REPEAT counter).
Obtain the "list from" line number after the LIST token (if specified), as follows:
Set the IWA to zero.
Call &9B1E to set the IWA to the untokenised Line number value based on the tokenised Line Number at BASIC Text
pointer A (if any found; otherwise, the IWA will retain the value 0).
Store the processor flags (PHP) on the 6502 stack (for future checking).
Push the IWA value to the BASIC Stack.
Obtain the "list to" line number after the LIST token (if specified), as follows:
Set the IWA to -1 (&FFFFFFFF) (true).
Shift right the 2nd byte of the IWA (byte &2B), so that the first 2 bytes of the IWA contain the maximum Line Number
value: &7FFF.
Retrieve the processor flags from the stack and check the carry flag as follows:
-->If carry is set (the first Line Number was specified) then check for a second (To) line number as follows:
* Check whether the next non-space character (after the "from Line number") is a comma ','.
* If comma found then check for a "To Line Number":
* [&B3C6] Call &9B1E to set the IWA to the untokenised Line number value based on the tokenised Line Number at BASIC Text
pointer A (if any found; otherwise, the IWA will retain the value &7FFF).
* Store the IWA value ("To Line Number") at locations &31-&34.
* If the next non-space character if 'IF-token' then set the BASIC text Pointer A to point to the next non-space character
(and set PTR A offset to 1); otherwise, [&B3F3] Check for the end of statement ('Syntax error' if not terminated correctly).
* If comma not found then, a single Line has been specified, so:
* Retrieve the "from Line Number" IWA value from the BASIC Stack.
* Store the "from Line Number" to the BASIC Stack again (keeping the IWA set to the "From Line Number" value).
* Decrement the BASIC Text pointer A offset.
* [&B3C9] Store the IWA value (the "From Line Number" specified) at locations &31-&34 (the "To Line Number").
* If the next non-space character if 'IF-token' then set the BASIC text Pointer A to point to the next non-space character
(and set PTR A offset to 1); otherwise, [&B3F3] Check for the end of statement ('Syntax error' if not terminated correctly).
-->If carry was not set (the first Line Number wasn't specified) then check for a second (To) line number as follows:
* Check whether the next non-space character (after the "from Line number") is a comma ','.
* If comma found then check for a "To Line Number":
* [&B3C6] Call &9B1E to set the IWA to the untokenised Line number value based on the tokenised Line Number at BASIC Text
pointer A (if any found; otherwise, the IWA will retain the value &7FFF).
* Store the IWA value ("To Line Number") at locations &31-&34.
* If the next non-space character if 'IF-token' then set the BASIC text Pointer A to point to the next non-space character
(and set PTR A offset to 1); otherwise, [&B3F3] Check for the end of statement ('Syntax error' if not terminated correctly).
* If comma not found then:
* [&B3C4] Decrement the BASIC Text Pointer A offset and jump to &B3C9.
* [&B3C9] Store the IWA value ("To Line Number" - &7FFF) at locations &31-&34.
* If the next non-space character if 'IF-token' then set the BASIC text Pointer A to point to the next non-space character
(and set PTR A offset to 1); otherwise, [&B3F3] Check for the end of statement ('Syntax error' if not terminated correctly).
Now, BASIC Text pointer A points to the Next command line statement and BASIC text pointer B points to the 'IF' part of the
List Statement.
[&B3F6] Set BASIC Text Pointer B (LSB) to BASIC Text Pointer A (LSB).
Call routine &BDE5 to check that the program can be read correctly (display the warning message 'Bad program' if the
program is corrupt and cannot be read correctly).
Retrieve the Integer value from the BASIC Stack into the IWA. This is the minimum line number value.
Call routine &80CD to find the first program line that is greater than or equal to the IWA value.
Set text pointer A to the address of the first program line returned by the &80CD routine.
B39A | d; | 100 059 | 64 3B | STZ &3B |
B39C | d< | 100 060 | 64 3C | STZ &3C |
B39E | 032 232 171 | 20 E8 AB | JSR &ABE8 Set IWA to FALSE (0) | |
B3A1 | 032 030 155 | 20 1E 9B | JSR &9B1E Detokenise the Line Number at PTR A & Set IWA to the Line Number value | |
B3A4 | 008 | 08 | PHP | |
B3A5 | & | 032 038 188 | 20 26 BC | JSR &BC26 Push IWA value to the BASIC Stack [pushi] |
B3A8 | 032 219 171 | 20 DB AB | JSR &ABDB Set IWA to TRUE (-1) | |
B3AB | F+ | 070 043 | 46 2B | LSR &2B |
B3AD | ( | 040 | 28 | PLP |
B3AE | 144 015 | 90 0F | BCC 15 --> &B3BF | |
B3B0 | 032 229 140 | 20 E5 8C | JSR &8CE5 Compare next non-space [PTR A] character with ',' | |
B3B3 | 240 017 | F0 11 | BEQ 17 --> &B3C6 | |
B3B5 | 032 230 188 | 20 E6 BC | JSR &BCE6 Retrieve IWA value from the BASIC Stack [popi] | |
B3B8 | & | 032 038 188 | 20 26 BC | JSR &BC26 Push IWA value to the BASIC Stack [pushi] |
B3BB | 198 010 | C6 0A | DEC &0A | |
B3BD | 128 010 | 80 0A | BRA 10 --> &B3C9 | |
B3BF | 032 229 140 | 20 E5 8C | JSR &8CE5 Compare next non-space [PTR A] character with ',' | |
B3C2 | 240 002 | F0 02 | BEQ 2 --> &B3C6 | |
B3C4 | 198 010 | C6 0A | DEC &0A | |
B3C6 | 032 030 155 | 20 1E 9B | JSR &9B1E Detokenise the Line Number at PTR A & Set IWA to the Line Number value | |
B3C9 | 1 | 162 049 | A2 31 | LDX#&31 |
B3CB | 032 198 189 | 20 C6 BD | JSR &BDC6 Store Integer (IWA) to zero page location (specified by X) | |
B3CE | 032 224 142 | 20 E0 8E | JSR &8EE0 Get next non-space character pointed to by Ptr A | |
B3D1 | 201 231 | C9 E7 | CMP#&E7 | |
B3D3 | 208 030 | D0 1E | BNE 30 --> &B3F3 | |
B3D5 | 032 224 142 | 20 E0 8E | JSR &8EE0 Get next non-space character pointed to by Ptr A | |
B3D8 | 032 188 155 | 20 BC 9B | JSR &9BBC Update BASIC Text pointer A (Add offset value & then reset offset to 1) | |
B3DB | 128 025 | 80 19 | BRA 25 --> &B3F6 |
B3F3 | 032 176 155 | 20 B0 9B | BRA 26 --> &9BB0 Check for end of Statement | |
B3F6 | 165 011 | A5 0B | LDA &0B | |
B3F8 | 133 025 | 85 19 | STA &19 | |
B3FA | 032 229 189 | 20 E5 BD | JSR &BDE5 Check program can be read correctly ('Bad program' message if not) | |
B3FD | 032 230 188 | 20 E6 BC | JSR &BCE6 Retrieve IWA value from the BASIC Stack [popi] | |
B400 | 032 205 128 | 20 CD 80 | JSR &80CD Search for Program Line >= the Line Number in the IWA | |
B403 | = | 165 061 | A5 3D | LDA &3D |
B405 | 133 011 | 85 0B | STA &0B | |
B407 | > | 165 062 | A5 3E | LDA &3E |
B409 | 133 012 | 85 0C | STA &0C | |
B40B | 176 027 | B0 1B | BCS 27 --> &B428 | |
B40D | 136 | 88 | DEY | |
B40E | 128 015 | 80 0F | BRA 15 --> &B41F | |
B410 | 032 148 189 | 20 94 BD | JSR &BD94 Output character to the screen | |
B413 | $ | 036 031 | 24 1F | BIT &1F |
B415 | 0 | 048 005 | 30 05 | BMI 5 --> &B41C |
B417 | 169 010 | A9 0A | LDA#&0A | |
B419 | 032 238 255 | 20 EE FF | JSR &FFEE OSWRCH | |
B41C | 032 188 155 | 20 BC 9B | JSR &9BBC Update BASIC Text pointer A (Add offset value & then reset offset to 1) | |
B41F | 177 011 | B1 0B | LDA (&0B),Y | |
B421 | + | 133 043 | 85 2B | STA &2B |
B423 | 200 | C8 | INY | |
B424 | 177 011 | B1 0B | LDA (&0B),Y | |
B426 | * | 133 042 | 85 2A | STA &2A |
B428 | * | 165 042 | A5 2A | LDA &2A |
B42A | 024 | 18 | CLC | |
B42B | 1 | 229 049 | E5 31 | SBC &31 |
B42D | + | 165 043 | A5 2B | LDA &2B |
B42F | 2 | 229 050 | E5 32 | SBC &32 |
B431 | 144 011 | 90 0B | BCC 11 --> &B43E | |
B433 | $ | 036 031 | 24 1F | BIT &1F |
B435 | 016 185 | 10 B9 | BPL -71 --> &B3F0 | |
B437 | 162 137 | A2 89 | LDX#&89 | |
B439 | 160 179 | A0 B3 | LDY#&B3 | |
B43B | L | 076 247 255 | 4C F7 FF | JMP &FFF7 OSCLI |
B43E | dL | 100 076 | 64 4C | STZ &4C |
B440 | dM | 100 077 | 64 4D | STZ &4D |
B442 | 160 004 | A0 04 | LDY#&04 | |
B444 | 132 010 | 84 0A | STY &0A | |
B446 | 132 027 | 84 1B | STY &1B | |
B448 | $; | 036 059 | 24 3B | BIT &3B |
B44A | 016 002 | 10 02 | BPL 2 --> &B44E | |
B44C | d; | 100 059 | 64 3B | STZ &3B |
B44E | $< | 036 060 | 24 3C | BIT &3C |
B450 | 016 002 | 10 02 | BPL 2 --> &B454 | |
B452 | d< | 100 060 | 64 3C | STZ &3C |
B454 | 177 011 | B1 0B | LDA (&0B),Y | |
B456 | 201 013 | C9 0D | CMP#&0D | |
B458 | 7 | 240 055 | F0 37 | BEQ 55 --> &B491 |
B45A | 201 244 | C9 F4 | CMP#&F4 | |
B45C | 240 006 | F0 06 | BEQ 6 --> &B464 | |
B45E | " | 201 034 | C9 22 | CMP#&22 |
B460 | 208 004 | D0 04 | BNE 4 --> &B466 | |
B462 | EL | 069 076 | 45 4C | EOR &4C |
B464 | L | 133 076 | 85 4C | STA &4C |
B466 | L | 166 076 | A6 4C | LDX &4C |
B468 | 208 012 | D0 0C | BNE 12 --> &B476 | |
B46A | 201 237 | C9 ED | CMP#&ED | |
B46C | 208 002 | D0 02 | BNE 2 --> &B470 | |
B46E | ; | 198 059 | C6 3B | DEC &3B |
B470 | 201 253 | C9 FD | CMP#&FD | |
B472 | 208 002 | D0 02 | BNE 2 --> &B476 | |
B474 | < | 198 060 | C6 3C | DEC &3C |
B476 | 166 025 | A6 19 | LDX &19 | |
B478 | 189 000 007 | BD 00 07 | LDA &0700,X | |
B47B | 201 013 | C9 0D | CMP#&0D | |
B47D | 240 010 | F0 0A | BEQ 10 --> &B489 | |
B47F | 209 011 | D1 0B | CMP (&0B),Y | |
B481 | 208 008 | D0 08 | BNE 8 --> &B48B | |
B483 | 200 | C8 | INY | |
B484 | 232 | E8 | INX | |
B485 | 128 241 | 80 F1 | BRA -15 --> &B478 | |
B487 | 128 135 | 80 87 | BRA -121 --> &B410 | |
B489 | M | 133 077 | 85 4D | STA &4D |
B48B | 230 027 | E6 1B | INC &1B | |
B48D | 164 027 | A4 1B | LDY &1B | |
B48F | 128 195 | 80 C3 | BRA -61 --> &B454 | |
B491 | M | 165 077 | A5 4D | LDA &4D |
B493 | 240 135 | F0 87 | BEQ -121 --> &B41C | |
B495 | 032 133 160 | 20 85 A0 | JSR &A085 Print Line Number on screen (width 5) | |
B498 | 169 001 | A9 01 | LDA#&01 | |
B49A | 232 | E8 | INX | |
B49B | 8 | 056 | 38 | SEC |
B49C | 032 180 189 | 20 B4 BD | JSR &BDB4 AND value in A with LISTO option (&1F), Output (result divided by 2 + carry*&80) number of spaces | |
B49F | ; | 166 059 | A6 3B | LDX &3B |
B4A1 | 169 002 | A9 02 | LDA#&02 | |
B4A3 | 032 179 189 | 20 B3 BD | JSR &BDB3 AND value in A with LISTO option (&1F), Output (result divided by 2) number of spaces | |
B4A6 | < | 166 060 | A6 3C | LDX &3C |
B4A8 | 169 004 | A9 04 | LDA#&04 | |
B4AA | 032 179 189 | 20 B3 BD | JSR &BDB3 AND value in A with LISTO option (&1F), Output (result divided by 2) number of spaces | |
B4AD | dL | 100 076 | 64 4C | STZ &4C |
B4AF | 164 010 | A4 0A | LDY &0A | |
B4B1 | 177 011 | B1 0B | LDA (&0B),Y | |
B4B3 | 201 013 | C9 0D | CMP#&0D | |
B4B5 | 240 208 | F0 D0 | BEQ -48 --> &B487 | |
B4B7 | " | 201 034 | C9 22 | CMP#&22 |
B4B9 | 208 012 | D0 0C | BNE 12 --> &B4C7 | |
B4BB | EL | 069 076 | 45 4C | EOR &4C |
B4BD | L | 133 076 | 85 4C | STA &4C |
B4BF | " | 169 034 | A9 22 | LDA#&22 |
B4C1 | 032 148 189 | 20 94 BD | JSR &BD94 Output character to the screen | |
B4C4 | 200 | C8 | INY | |
B4C5 | 128 234 | 80 EA | BRA -22 --> &B4B1 | |
B4C7 | L | 166 076 | A6 4C | LDX &4C |
B4C9 | 208 246 | D0 F6 | BNE -10 --> &B4C1 | |
B4CB | 201 141 | C9 8D | CMP#&8D | |
B4CD | 208 010 | D0 0A | BNE 10 --> &B4D9 | |
B4CF | * | 032 042 155 | 20 2A 9B | JSR &9B2A Detokenise Line Number at PTR A (without skip spaces or skip #&8D char) & Set IWA to the Line Number value |
B4D2 | 132 010 | 84 0A | STY &0A | |
B4D4 | 032 129 160 | 20 81 A0 | JSR &A081 Print Line Number on screen (width 0) | |
B4D7 | 128 214 | 80 D6 | BRA -42 --> &B4AF | |
B4D9 | 201 227 | C9 E3 | CMP#&E3 | |
B4DB | 208 002 | D0 02 | BNE 2 --> &B4DF | |
B4DD | ; | 230 059 | E6 3B | INC &3B |
B4DF | 201 245 | C9 F5 | CMP#&F5 | |
B4E1 | 208 002 | D0 02 | BNE 2 --> &B4E5 | |
B4E3 | < | 230 060 | E6 3C | INC &3C |
B4E5 | 201 244 | C9 F4 | CMP#&F4 | |
B4E7 | 208 002 | D0 02 | BNE 2 --> &B4EB | |
B4E9 | L | 133 076 | 85 4C | STA &4C |
B4EB | 7 | 032 055 189 | 20 37 BD | JSR &BD37 Output Character/Token on screen |
B4EE | 200 | C8 | INY | |
B4EF | 128 192 | 80 C0 | BRA -64 --> &B4B1 |