×   Main Menu ALL The 8BS News Manuals (New menu) Links Worth a Look Tools Disc and Basic Webring Site Map 8BS Guestbook Old Guest Book Me The Barnsley Rovers   
8-Bit Software

The BBC and Master Computer Public Domain Library

904A LET

Submitted by Steve Fewell

Description:

Call routine &98AE to evaluate the variable name - check whether it exists or not
and create the variable if it does not exist. &98AE also returns with &2A and &2B pointing
to the address of the variable's value (which will be blank (zero) if the variable was newly created),
and &2C set to the variable's type.

If the zero flag is set, then there was an error and the text after the LET command
was not a valid variable name, so issue a Syntax Error.

If the Carry flag is clear then the variable has a numerical value type (E.g. Integer or Floating-Point),
so do the following:
* Store &2A, &2B and &2C on the stack (to save variable info for the Set numerical variable
routine (&B32B) to retrieve)
* Call routine &9B52 to check for '=' (if no '=' then Mistake error), get result of expression and check
that the Statement Line is terminated correctly (if it isn't then Syntax Error).
* Call routine &B32B to set the numerical variable to the value of the expression, or issue
Type mismatch error if the expression returned a String value.
* Jump to routine &9005 to continue running the BASIC program/command line.

If the Carry flag is set then the variable has a String value type, so do the following:
* Push the IWA (&2A-&2D) to the BASIC stack (to save variable info for the Set String variable
routine (&90AB) to retrieve)
* Call routine &9B52 to check for '=' (if no '=' then Mistake error), get result of expression and check
that the Statement Line is terminated correctly (if it isn't then Syntax Error).
* Issue a Type mismatch error if the expression returned a numerical (non string) value.
* Call routine &90AB to set the String variable to the value of the expression.
* Jump to routine &9005 to continue running the BASIC program/command line.


Disassembly for the LET routine

904A   032 174 152 20 AE 98 JSR &98AE Evaluate Variable Name & Allocate variable space (if necessary)
904D 4 240 052 F0 34 BEQ 52 --> &9083 [JMP &9B69 Syntax error]
904F ! 144 033 90 21 BCC 33 --> &9072 Variable is numeric
9051 & 032 038 188 20 26 BC JSR &BC26 Push IWA to Basic Stack
9054 R 032 082 155 20 52 9B JSR &9B52 Check for '=' & get result of expression; check end of statement
9057 ' 165 039 A5 27 LDA &27
9059 7 208 055 D0 37 BNE 55 --> &9092 Type mismatch error
905B   032 171 144 20 AB 90 JSR &90AB Set String variable (with check length)
905E   128 165 80 A5 BRA -91 --> &9005 Continue running program (next statement)
....
9072 * 165 042 A5 2A LDA &2A
9074 H 072 48 PHA
9075 + 165 043 A5 2B LDA &2B
9077 H 072 48 PHA
9078 , 165 044 A5 2C LDA &2C
907A H 072 48 PHA
907B R 032 082 155 20 52 9B JSR &9B52 Check for '=' & get result of expression; check end of statement
907E + 032 043 179 20 2B B3 JSR &B32B Set numeric variable
9081   128 130 80 82 BRA -126 --> &9005 Continue running program (next statement)
9083 Li 076 105 155 4C 69 9B JMP &9B69 Syntax error

 


 Back to 8BS
Or