Prev: 06437 Up: Map Next: 06528
06510: THE 'LINE-ADDR' SUBROUTINE
Used by the routines at ED_EDIT, ED_UP, MAIN_ADD, AUTO_LIST, LIST, LN_FETCH, LINE_NEW and RESTORE.
For a given line number, in the HL register pair, this subroutine returns the starting address of that line or the 'first line after', in the HL register pair, and the start of the previous line in the DE register pair.
If the line number is being used the zero flag will be set. However if the 'first line after' is substituted then the zero flag is returned reset.
Input
HL Target line number
Output
DE Start address of the line before the target
HL Start address of the target line (if found) or the first line after
F Zero flag set if the target line was found
LINE_ADDR 06510 PUSH HL Save the given line number.
06511 LD HL,(23635) Fetch the system variable PROG and transfer the address to the DE register pair.
06514 LD D,H
06515 LD E,L
Now enter a loop to test the line number of each line of the program against the given line number until the line number is matched or exceeded.
LINE_AD_1 06516 POP BC The given line number.
06517 CALL CP_LINES Compare the given line number against the addressed line number
06520 RET NC Return if carry reset; otherwise address the next line's number.
06521 PUSH BC
06522 CALL NEXT_ONE
06525 EX DE,HL Switch the pointers and jump back to consider the next line of the program.
06526 JR LINE_AD_1
Prev: 06437 Up: Map Next: 06528