| Routines

1D86: THE 'LOOK-PROG' SUBROUTINE

Used by the routines at FOR, READ_3 and S_FN_SBRN. This subroutine is used to find occurrences of either DATA, DEF FN or NEXT.
Input
E | Token code to search for
HL | Search start address
Output
F | Carry flag reset if the token is found
LOOK_PROG | 1D86 | LD A,(HL) | Fetch the present character.
| 1D87 | CP ":" | Jump forward if it is a ':', which will indicate there are more statements in the present line.
| 1D89 | JR Z,LOOK_P_2
Now a loop is entered to examine each further line in the program.
LOOK_P_1 | 1D8B | INC HL | Fetch the high byte of the line number and return with carry set if there are no further lines in the program.
| 1D8C | LD A,(HL)
| 1D8D | AND $C0
| 1D8F | SCF
| 1D90 | RET NZ
| 1D91 | LD B,(HL) | The line number is fetched and passed to NEWPPC.
| 1D92 | INC HL
| 1D93 | LD C,(HL)
| 1D94 | LD ($5C42),BC
| 1D98 | INC HL | Then the length is collected.
| 1D99 | LD C,(HL)
| 1D9A | INC HL
| 1D9B | LD B,(HL)
| 1D9C | PUSH HL | The pointer is saved whilst the address of the end of the line is formed in the BC register pair.
| 1D9D | ADD HL,BC
| 1D9E | LD B,H
| 1D9F | LD C,L
| 1DA0 | POP HL | The pointer is restored.
| 1DA1 | LD D,$00 | Set the statement counter to zero.
LOOK_P_2 | 1DA3 | PUSH BC | The end-of-line pointer is saved whilst the statements of the line are examined.
| 1DA4 | CALL EACH_STMT
| 1DA7 | POP BC
| 1DA8 | RET NC | Make a return if there was an 'occurrence'; otherwise consider the next line.
| 1DA9 | JR LOOK_P_1