Submitted by Steve Fewell
Description:
Call routine &98AE to evaluate the variable name at the BASIC Text Pointer A location, and to create it if it doesn't
exist, and return the variable value's memory address in locations &2A-&2B and its type in &2C.
If the zero flag is set on return from &98AE, then the variable name is not a valid variable name, so issue
'FOR variable' error.
If the carry flag is set on return from &98AE, then the variable is a String variable, so issue 'FOR variable'
error, as a FOR variable must be numeric.
Call routine &BC43 to store the variable information data (&2A-&2C) to the 6502 stack.
Call routine &9B86 to check whether the next non-space character is '=' (equals), if not then issue 'Mistake' error;
otherwise, skip over the '=' character.
Call routine &B328 to evaluate the expression (after the '=' character), retrieve the variable information from the
6502 stack and set the Numeric FOR variable to the result of the expression.
If the next non-space character at BASIC Text Pointer B is not the 'TO-token', then issue 'No TO' error, as the TO-Keyword
must follow the expression giving the variable's start value.
Load Y with the current FOR level (location &26).
If the current FOR level is greater than or equal to #&96 (150) then issue 'Too many FORs' error, as only a maximum
of 10 FOR loops can be nested (each FOR loop uses 15 bytes on the FOR stack - and increases the FOR level by 15).
Add #&0F (15) to the current FOR level, and update location &26 with the new value.
Now, the &26 location has been updated, but Y still contains the original FOR level (before the addition).
Store the variable value address (&37-&38) in locations &0528 + Y and &0529 + Y; and store the
variable type (&39) in location &052A + Y.
B618 | 032 174 152 | 20 AE 98 | JSR &98AE Evaluate variable name & create it if it's a new variable | |
B61B | 240 219 | F0 DB | BEQ -37 --> &B5F8 'FOR variable' error | |
B61D | 176 217 | B0 D9 | BCS -39 --> &B5F8 'FOR variable' error | |
B61F | C | 032 067 188 | 20 43 BC | JSR &BC43 Push &2A, &2B & &2C (the variable info) to the 6502 Stack |
B622 | 032 134 155 | 20 86 9B | JSR &9B86 Check whether the next non-space character is '=' ('Mistake' error if not) | |
B625 | ( | 032 040 179 | 20 28 B3 | JSR &B328 Evaluate expression and set Numeric variable |
B628 | 032 213 142 | 20 D5 8E | JSR &8ED5 Get next non-space character (PTR B) | |
B62B | 201 184 | C9 B8 | CMP#&B8 | |
B62D | 208 226 | D0 E2 | BNE -30 --> &B611 'No TO' error | |
B62F | & | 164 038 | A4 26 | LDY &26 |
B631 | 192 150 | C0 96 | CPY#&96 | |
B633 | 176 207 | B0 CF | BCS -49 --> &B604 'Too many FORs' error | |
B635 | 152 | 98 | TYA | |
B636 | i | 105 015 | 69 0F | ADC#&0F |
B638 | & | 133 038 | 85 26 | STA &26 |
B63A | 7 | 165 055 | A5 37 | LDA &37 |
B63C | ( | 153 040 005 | 99 28 05 | STA &0528,Y |
B63F | 8 | 165 056 | A5 38 | LDA &38 |
B641 | ) | 153 041 005 | 99 29 05 | STA &0529,Y |
B644 | 9 | 165 057 | A5 39 | LDA &39 |
B646 | * | 153 042 005 | 99 2A 05 | STA &052A,Y |
B649 | 201 005 | C9 05 | CMP#&05 | |
B64B | T | 240 084 | F0 54 | BEQ 84 --> &B6A1 |
B64D | 032 175 150 | 20 AF 96 | JSR &96AF Get expression result & convert it to Integer | |
B650 | & | 164 038 | A4 26 | LDY &26 |
B652 | * | 165 042 | A5 2A | LDA &2A |
B654 | ! | 153 033 005 | 99 21 05 | STA &0521,Y |
B657 | + | 165 043 | A5 2B | LDA &2B |
B659 | " | 153 034 005 | 99 22 05 | STA &0522,Y |
B65C | , | 165 044 | A5 2C | LDA &2C |
B65E | # | 153 035 005 | 99 23 05 | STA &0523,Y |
B661 | - | 165 045 | A5 2D | LDA &2D |
B663 | $ | 153 036 005 | 99 24 05 | STA &0524,Y |
B666 | 169 001 | A9 01 | LDA#&01 | |
B668 | 032 024 174 | 20 18 AE | JSR &AE18 Set IWA to the 8-bit value in A | |
B66B | 032 213 142 | 20 D5 8E | JSR &8ED5 Get next non-space character (PTR B) | |
B66E | 201 136 | C9 88 | CMP#&88 | |
B670 | 208 005 | D0 05 | BNE 5 --> &B677 | |
B672 | 032 175 150 | 20 AF 96 | JSR &96AF Get expression result & convert it to Integer | |
B675 | 164 027 | A4 1B | LDY &1B | |
B677 | 132 010 | 84 0A | STY &0A | |
B679 | & | 164 038 | A4 26 | LDY &26 |
B67B | * | 165 042 | A5 2A | LDA &2A |
B67D | 153 028 005 | 99 1C 05 | STA &051C,Y | |
B680 | + | 165 043 | A5 2B | LDA &2B |
B682 | 153 029 005 | 99 1D 05 | STA &051D,Y | |
B685 | , | 165 044 | A5 2C | LDA &2C |
B687 | 153 030 005 | 99 1E 05 | STA &051E,Y | |
B68A | - | 165 045 | A5 2D | LDA &2D |
B68C | 153 031 005 | 99 1F 05 | STA &051F,Y | |
B68F | 032 207 155 | 20 CF 9B | JSR &9BCF Check & skip end of program line | |
B692 | & | 164 038 | A4 26 | LDY &26 |
B694 | 165 011 | A5 0B | LDA &0B | |
B696 | & | 153 038 005 | 99 26 05 | STA &0526,Y |
B699 | 165 012 | A5 0C | LDA &0C | |
B69B | ' | 153 039 005 | 99 27 05 | STA &0527,Y |
B69E | L | 076 011 144 | 4C 0B 90 | JMP &900B Process next BASIC program statement |
B6A1 | ; | 032 059 157 | 20 3B 9D | JSR &9D3B Evaluate expression at BASIC Text pointer B |
B6A4 | 032 221 150 | 20 DD 96 | JSR &96DD Check Float value (Convert if Integer, or 'Type mismatch' error if String) | |
B6A7 | & | 165 038 | A5 26 | LDA &26 |
B6A9 | 024 | 18 | CLC | |
B6AA | i! | 105 033 | 69 21 | ADC#&21 |
B6AC | J | 133 074 | 85 4A | STA &4A |
B6AE | 169 005 | A9 05 | LDA#&05 | |
B6B0 | K | 133 075 | 85 4B | STA &4B |
B6B2 | 032 025 165 | 20 19 A5 | JSR &A519 Store FWA's value to argp address (&4A-&4B) | |
B6B5 | 032 216 165 | 20 D8 A5 | JSR &A5D8 Set FWA to 1.0 | |
B6B8 | 032 213 142 | 20 D5 8E | JSR &8ED5 Get next non-space character (PTR B) | |
B6BB | 201 136 | C9 88 | CMP#&88 | |
B6BD | 208 008 | D0 08 | BNE 8 --> &B6C7 | |
B6BF | ; | 032 059 157 | 20 3B 9D | JSR &9D3B Evaluate expression at BASIC Text pointer B |
B6C2 | 032 221 150 | 20 DD 96 | JSR &96DD Check Float value (Convert if Integer, or 'Type mismatch' error if String) | |
B6C5 | 164 027 | A4 1B | LDY &1B | |
B6C7 | 132 010 | 84 0A | STY &0A | |
B6C9 | & | 165 038 | A5 26 | LDA &26 |
B6CB | 024 | 18 | CLC | |
B6CC | i | 105 028 | 69 1C | ADC#&1C |
B6CE | J | 133 074 | 85 4A | STA &4A |
B6D0 | 169 005 | A9 05 | LDA#&05 | |
B6D2 | K | 133 075 | 85 4B | STA &4B |
B6D4 | 032 025 165 | 20 19 A5 | JSR &A519 Store FWA's value to argp address (&4A-&4B) | |
B6D7 | 128 182 | 80 B6 | BRA -74 --> &B68F |