Prev: 1D86 Up: Map Next: 1DDA
1DAB: THE 'NEXT' COMMAND ROUTINE
The address of this routine is found in the parameter table.
The 'variable in assignment' has already been determined (see CLASS_04), and it remains to change the VALUE as required.
NEXT 1DAB BIT 1,(IY+$37) Jump to give the error report if the variable was not found (bit 1 of FLAGX set).
1DAF JP NZ,REPORT_2
1DB2 LD HL,($5C4D) The address of the variable is fetched from DEST and the name tested further.
1DB5 BIT 7,(HL)
1DB7 JR Z,REPORT_1
Next the variable's VALUE (v) and STEP (s) are manipulated by the calculator.
1DB9 INC HL Step past the name.
1DBA LD ($5C68),HL Make the variable a temporary 'memory area' by setting MEM.
1DBD RST $28 -
1DBE DEFB $E0 get_mem_0: v
1DBF DEFB $E2 get_mem_2: v, s
1DC0 DEFB $0F addition: v+s
1DC1 DEFB $C0 st_mem_0: v+s (v is replaced by v+s in mem-0)
1DC2 DEFB $02 delete: -
1DC3 DEFB $38 end_calc: -
The result of adding the VALUE and the STEP is now tested against the LIMIT by calling NEXT_LOOP.
1DC4 CALL NEXT_LOOP Test the new VALUE against the LIMIT.
1DC7 RET C Return now if the FOR-NEXT loop has been completed.
Otherwise collect the 'looping' line number and statement.
1DC8 LD HL,($5C68) Find the address of the low byte of the looping line number (MEM+0F).
1DCB LD DE,$000F
1DCE ADD HL,DE
1DCF LD E,(HL) Now fetch this line number.
1DD0 INC HL
1DD1 LD D,(HL)
1DD2 INC HL
1DD3 LD H,(HL) Followed by the statement number.
1DD4 EX DE,HL Exchange the numbers before jumping forward to treat them as the destination line of a GO TO command.
1DD5 JP GO_TO_2
Report 1 - NEXT without FOR.
REPORT_1 1DD8 RST $08 Call the error handling routine.
1DD9 DEFB $00
Prev: 1D86 Up: Map Next: 1DDA