Prev: 24B7 Up: Map Next: 250F
Used by the routines at PROGNAME, VAL_FET_1, NEXT_2NUM, DATA, DEF_FN, PR_ITEM_1, S_BRACKET, S_FN_SBRN and val.
This subroutine is used to produce an evaluation result of the 'next expression'.
The result is returned as the 'last value' on the calculator stack. For a numerical result, the last value will be the actual floating point number. However, for a string result the last value will consist of a set of parameters. The first of the five bytes is unspecified, the second and third bytes hold the address of the start of the string and the fourth and fifth bytes hold the length of the string.
Bit 6 of FLAGS is set for a numeric result and reset for a string result.
When a next expression consists of only a single operand (e.g. 'A', 'RND', 'A$(4,3 TO 7)'), then the last value is simply the value that is obtained from evaluating the operand.
However when the next expression contains a function and an operand (e.g. 'CHR$ A', 'NOT A', 'SIN 1'), the operation code of the function is stored on the machine stack until the last value of the operand has been calculated. This last value is then subjected to the appropriate operation to give a new last value.
In the case of there being an arithmetic or logical operation to be performed (e.g. 'A+B', 'A*B', 'A=B'), then both the last value of the first argument and the operation code have to be kept until the last value of the second argument has been found. Indeed the calculation of the last value of the second argument may also involve the storing of last values and operation codes whilst the calculation is being performed.
It can therefore be shown that as a complex expression is evaluated (e.g. 'CHR$ (T+A-26*INT ((T+A)/26)+65)'), a hierarchy of operations yet to be performed is built up until the point is reached from which it must be dismantled to produce the final last value.
Each operation code has associated with it an appropriate priority code and operations of higher priority are always performed before those of lower priority.
The subroutine begins with the A register being set to hold the first character of the expression and a starting priority marker - zero - being put on the machine stack.
SCANNING 24FB RST $18 The first character is fetched.
24FC LD B,$00 The starting priority marker.
24FE PUSH BC It is stacked.
This entry point is used by the routines at S_U_PLUS and S_LETTER.
S_LOOP_1 24FF LD C,A The main re-entry point.
2500 LD HL,$2596 Index into the scanning function table with the code in C.
2506 LD A,C Restore the code to A.
2507 JP NC,S_ALPHNUM Jump if code not found in table.
250A LD B,$00 Use the entry found in the table to build up the required address in HL, and jump to it.
250C LD C,(HL)
250E JP (HL)
Prev: 24B7 Up: Map Next: 250F