Submitted by Steve Fewell
Description:
[&9703] If the 6502 Stack pointer address is not less than #&FC, then we are not inside a Subroutine call (as a
subroutine call pushes 4 bytes of information to the 6502 stack), so issue 'Not LOCAL' error.
Call routine &98AE to evaluate the variable name following the LOCAL-keyword and create the variable if it has not been
created yet.
If the zero flag is set on return from &98AE then the variable name is not valid, so jump to &9002 to issue
'Syntax error', unless the end of statement (either a carriage return, ELSE-token or ':' character) is found. This means
that a LOCAL-keyword without any following variable names is valid, but has no effect.
Call routine &B181 to load the variable's value and push the value to the BASIC stack and then push the variable's
value address (&2A-&2B) and variable's type (&2C) to the BASIC Stack.
Set Y to the value at location &2C, which is the Variable's type.
If Y is negative (variable is a String), then jump to &96FB to store zero in the 3rd byte of the variable's value
parameter block (the location pointed to by the address stored in &2A-&2B + 3) and then jump to location &971F to
continue the LOCAL-statement. This initialises the String variable to null (i.e. String value is zero characters long).
96FB | 160 003 | A0 03 | LDY#&03 | |
96FD | 169 000 | A9 00 | LDA#&00 | |
96FF | * | 145 042 | 91 2A | STA (&2A),Y |
9701 | 240 028 | F0 1C | BEQ 28 --> &971F | |
9703 | 186 | BA | TSX | |
9704 | 224 252 | E0 FC | CPX#&FC | |
9706 | * | 176 042 | B0 2A | BCS 42 --> &9732 'Not LOCAL' error |
9708 | 032 174 152 | 20 AE 98 | JSR &98AE Evaluate variable name & create it if it's a new variable | |
970B | " | 240 034 | F0 22 | BEQ 34 --> &972F (issue 'Syntax error' if not end of statement) |
970D | 032 129 177 | 20 81 B1 | JSR &B181 Load Variable & Push its value, address and type to the BASIC Stack | |
9710 | , | 164 044 | A4 2C | LDY &2C |
9712 | 0 | 048 231 | 30 E7 | BMI -25 --> &96FB Check whether there are any more LOCAL variables to declare (if so then declare them) |
9714 | C | 032 067 188 | 20 43 BC | JSR &BC43 Push &2A, &2B & &2C (the variable info) to the 6502 Stack |
9717 | 032 232 171 | 20 E8 AB | JSR &ABE8 Set IWA to FALSE (0) | |
971A | ' | 133 039 | 85 27 | STA &27 |
971C | + | 032 043 179 | 20 2B B3 | JSR &B32B Set numeric variable |
971F | 186 | BA | TSX | |
9720 | 254 006 001 | FE 06 01 | INC &0106,X | |
9723 | 164 027 | A4 1B | LDY &1B | |
9725 | 132 010 | 84 0A | STY &0A | |
9727 | 032 229 140 | 20 E5 8C | JSR &8CE5 Compare next non-space [PTR A] character with ',' | |
972A | 240 215 | F0 D7 | BEQ -41 --> &9703 LOCAL (Declare LOCAL variable) | |
972C | L | 076 000 144 | 4C 00 90 | JMP &9000 Check end of statement & execute the next statement on the Command/Program line |
972F | L | 076 002 144 | 4C 02 90 | JMP &9002 'Syntax error' if not end of statement; otherwise, execute next statement/program line |