Prev: 2AB1 Up: Map Next: 2AEE
2ACC: THE 'INT-EXP' SUBROUTINE
Used by the routines at STK_VAR and DIM.
This subroutine returns the result of evaluating the 'next expression' as an integer value held in the BC register pair. The subroutine also tests this result against a limit-value supplied in the HL register pair. The carry flag becomes set if there is an 'out of range' error.
The A register is used as an 'error register' and holds +00 if there is no 'previous error' and +FF if there has been one.
Input
HL Limit value
Output
BC Expression value
F Carry flag set if this value is out of range
INT_EXP1 2ACC XOR A Clear the 'error register'.
This entry point is used by the routine at SLICING.
INT_EXP2 2ACD PUSH DE Save both the DE and HL register pairs throughout.
2ACE PUSH HL
2ACF PUSH AF Save the 'error register' briefly.
2AD0 CALL CLASS_06 The 'next expression' is evaluated to give a 'last value' on the calculator stack.
2AD3 POP AF Restore the 'error register'.
2AD4 CALL SYNTAX_Z Jump forward if checking syntax.
2AD7 JR Z,I_RESTORE
2AD9 PUSH AF Save the error register again.
2ADA CALL FIND_INT2 The 'last value' is compressed Into BC.
2ADD POP DE Error register to D.
2ADE LD A,B A 'next expression' that gives zero is always in error so jump forward if it is so.
2ADF OR C
2AE0 SCF
2AE1 JR Z,I_CARRY
2AE3 POP HL Take a copy of the limit-value. This will be a 'dimension-size', a 'DIM-limit' or a 'string length'.
2AE4 PUSH HL
2AE5 AND A Now compare the result of evaluating the expression against the limit.
2AE6 SBC HL,BC
The state of the carry flag and the value held in the D register are now manipulated so as to give the appropriate value for the 'error register'.
I_CARRY 2AE8 LD A,D Fetch the 'old error value'.
2AE9 SBC A,$00 Form the 'new error value': +00 if no error at any time, +FF or less if an 'out of range' error on this pass or on previous ones.
Restore the registers before returning.
I_RESTORE 2AEB POP HL Restore HL and DE.
2AEC POP DE
2AED RET Return; 'error register' is the A register.
Prev: 2AB1 Up: Map Next: 2AEE