Splitting the Atom back exit forward page 4

II. The FOR / NEXT Stacks

240       24A   Variable 1=A, 2=B, etc.
 
24B       255 LSB Step size
stack
256       260  
261       26B  
26C       276 MSB
 
277         LSB Terminal value
stack
282          
28D          
298         MSB
 
2A3       2AD LSB NEXT return address
- i.e. where FOR was.
2AE       2B8 MSB
  ^
|
 
  15 = FOR / NEXT Stack Pointer  

Each new FOR command increments the FOR/NEXT stack pointer to point at the data relevant to this loop, viz, the location of the FOR, the terminal value, the STEP size and the variable used.

A similar map can be drawn for DO/UNTIL and GOSUB/RETURN loops, though there are obvious differences. See Chapter 3: RAM Usage.

back exit forward