Your initial interpretation was correct -- Microsoft Basic is storing the address of the first statement of the FOR
/NEXT
loop. But it is also storing the line number of the first statement. See the comment at the top of flow1.s:
; ----------------------------------------------------------------------------
; "FOR" STATEMENT
;
; FOR PUSHES 18 BYTES ON THE STACK:
; 2 -- TXTPTR
; 2 -- LINE NUMBER
; 5 -- INITIAL (CURRENT) FOR VARIABLE VALUE
; 1 -- STEP SIGN
; 5 -- STEP VALUE
; 2 -- ADDRESS OF FOR VARIABLE IN VARTAB
; 1 -- FOR TOKEN ($81)
; ----------------------------------------------------------------------------
In eval.s we see the code that happens when a NEXT
continues the loop. The current line and the pointer to the next statement are copied off the stack into their zero page variables. Then it jumps to NEWSTT
to continue execution at TXTPTR
.
sbc STACK+BYTES_FP+4,x
beq L2C22
lda STACK+2*BYTES_FP+5,x
sta CURLIN
lda STACK+2*BYTES_FP+6,x
sta CURLIN+1
lda STACK+2*BYTES_FP+8,x
sta TXTPTR
lda STACK+2*BYTES_FP+7,x
sta TXTPTR+1
L2C1F:
jmp NEWSTT
The current line isn't really needed unless an error occurs at which point BASIC will want to report the line where the error was triggered.