Prev: 1988 Up: Map Next: 19B8
Used by the routines at NEXT_LINE, LOOK_PROG, PASS_BY and S_FN_SBRN.
This subroutine has two distinct functions.
  • It can be used to find the Dth statement in a BASIC line - returning with the HL register pair addressing the location before the start of the statement and the zero flag set.
  • Also the subroutine can be used to find a statement, if any, that starts with a given token code (in the E register).
D Statement number to look for (or +00 if looking for a token code)
E Token code to look for (or +00 if looking for a statement)
HL Address of the next character to consider
HL Address of the token code or first character in the statement (if found)
F Carry flag reset if the token code is found
F Zero flag set if the statement is found
EACH_STMT 198B LD ($5C5D),HL Set CH-ADD to the current byte.
198E LD C,$00 Set a 'quotes off' flag.
Enter a loop to handle each statement in the BASIC line.
EACH_S_1 1990 DEC D Decrease D and return if the required statement has been found.
1991 RET Z
1992 RST $20 Fetch the next character code and jump if it does not match the given token code.
1993 CP E
1994 JR NZ,EACH_S_3
1996 AND A But should it match then return with the carry and the zero flags both reset.
1997 RET
Now enter another loop to consider the individual characters in the line to find where the statement ends.
EACH_S_2 1998 INC HL Update the pointer and fetch the new code.
1999 LD A,(HL)
EACH_S_3 199A CALL NUMBER Step over any number.
199D LD ($5C5D),HL Update CH-ADD.
19A0 CP "\"" Jump forward if the character is not a '"'.
19A4 DEC C Otherwise set the 'quotes flag'.
EACH_S_4 19A5 CP ":" Jump forward if the character is a ':'.
19A7 JR Z,EACH_S_5
19A9 CP $CB Jump forward unless the code is the token 'THEN'.
EACH_S_5 19AD BIT 0,C Read the 'quotes flag' and jump back at the end of each statement (including after 'THEN').
EACH_S_6 19B1 CP $0D Jump back unless at the end of a BASIC line.
19B5 DEC D Decrease the statement counter and set the carry flag before returning.
19B6 SCF
19B7 RET
Prev: 1988 Up: Map Next: 19B8