| Routines

07558: 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 | 07558 | LD A,(HL) | Fetch the present character.
| 07559 | CP ":" | Jump forward if it is a ':', which will indicate there are more statements in the present line.
| 07561 | JR Z,LOOK_P_2
Now a loop is entered to examine each further line in the program.
LOOK_P_1 | 07563 | INC HL | Fetch the high byte of the line number and return with carry set if there are no further lines in the program.
| 07564 | LD A,(HL)
| 07565 | AND 192
| 07567 | SCF
| 07568 | RET NZ
| 07569 | LD B,(HL) | The line number is fetched and passed to NEWPPC.
| 07570 | INC HL
| 07571 | LD C,(HL)
| 07572 | LD (23618),BC
| 07576 | INC HL | Then the length is collected.
| 07577 | LD C,(HL)
| 07578 | INC HL
| 07579 | LD B,(HL)
| 07580 | PUSH HL | The pointer is saved whilst the address of the end of the line is formed in the BC register pair.
| 07581 | ADD HL,BC
| 07582 | LD B,H
| 07583 | LD C,L
| 07584 | POP HL | The pointer is restored.
| 07585 | LD D,0 | Set the statement counter to zero.
LOOK_P_2 | 07587 | PUSH BC | The end-of-line pointer is saved whilst the statements of the line are examined.
| 07588 | CALL EACH_STMT
| 07591 | POP BC
| 07592 | RET NC | Make a return if there was an 'occurrence'; otherwise consider the next line.
| 07593 | JR LOOK_P_1