| Routines

07642: THE 'NEXT-LOOP' SUBROUTINE

Used by the routines at FOR and NEXT. This subroutine is used to determine whether the LIMIT (l) has been exceeded by the present VALUE (v). Note has to be taken of the sign of the STEP (s). The subroutine returns the carry flag set if the LIMIT is exceeded.
NEXT_LOOP | 07642 | RST 40 | -
| 07643 | DEFB 225 | get_mem_1: l
| 07644 | DEFB 224 | get_mem_0: l, v
| 07645 | DEFB 226 | get_mem_2: l, v, s
| 07646 | DEFB 54 | less_0: l, v,( 1/0)
| 07647 | DEFB 0 | jump_true to NEXT_1: l, v, (1/0)
| 07648 | DEFB 2
| 07649 | DEFB 1 | exchange: v, l
NEXT_1 | 07650 | DEFB 3 | subtract: v-l or l-v
| 07651 | DEFB 55 | greater_0: (1/0)
| 07652 | DEFB 0 | jump_true to NEXT_2: (1/0)
| 07653 | DEFB 4
| 07654 | DEFB 56 | end_calc: -
| 07655 | AND A | Clear the carry flag and return - loop is possible.
| 07656 | RET
However if the loop is impossible the carry flag has to be set.
NEXT_2 | 07657 | DEFB 56 | end_calc: -
| 07658 | SCF | Set the carry flag and return.
| 07659 | RET