Prev: 06035 Up: Map Next: 06133
06037: THE 'LIST and LLIST' COMMAND ROUTINES
The routines in this part of the 16K program are used to produce listings of the current BASIC program. Each line has to have its line number evaluated, its tokens expanded and the appropriate cursors positioned.
The entry point AUTO_LIST is used by both MAIN_EXEC and ED_UP to produce a single page of the listing.
AUTO_LIST 06037 LD (23615),SP The stack pointer is saved at LIST-SP allowing the machine stack to be reset when the listing is finished (see PO_SCR).
06041 LD (IY+2),16 Signal 'automatic listing in the main screen' (set bit 4 of TV-FLAG and reset all other bits).
06045 CALL CL_ALL Clear this part of the screen.
06048 SET 0,(IY+2) Switch to the editing area (set bit 0 of TV-FLAG).
06052 LD B,(IY+49) Now clear the the lower part of the screen as well (see DF-SZ).
06055 CALL CL_LINE
06058 RES 0,(IY+2) Then switch back (reset bit 0 of TV-FLAG).
06062 SET 0,(IY+48) Signal 'screen is clear' (set bit 0 of FLAGS2).
06066 LD HL,(23625) Now fetch the the 'current' line number (E-PPC) and the 'automatic' line number (S-TOP).
06069 LD DE,(23660)
06073 AND A If the 'current' number is less than the 'automatic' number then jump forward to update the 'automatic' number.
06074 SBC HL,DE
06076 ADD HL,DE
06077 JR C,AUTO_L_2
The 'automatic' number has now to be altered to give a listing with the 'current' line appearing near the bottom of the screen.
06079 PUSH DE Save the 'automatic' number.
06080 CALL LINE_ADDR Find the address of the start of the 'current' line and produce an address roughly a 'screen before it' (negated).
06083 LD DE,704
06086 EX DE,HL
06087 SBC HL,DE
06089 EX (SP),HL Save the 'result' on the machine stack whilst the 'automatic' line address is also found (in HL).
06090 CALL LINE_ADDR
06093 POP BC The 'result' goes to the BC register pair.
A loop is now entered. The 'automatic' line number is increased on each pass until it is likely that the 'current' line will show on a listing.
AUTO_L_1 06094 PUSH BC Save the 'result'.
06095 CALL NEXT_ONE Find the address of the start of the line after the present 'automatic' line (in DE).
06098 POP BC Restore the 'result'.
06099 ADD HL,BC Perform the computation and jump forward if finished.
06100 JR C,AUTO_L_3
06102 EX DE,HL Move the next line's address to the HL register pair and collect its line number.
06103 LD D,(HL)
06104 INC HL
06105 LD E,(HL)
06106 DEC HL
06107 LD (23660),DE Now S-TOP can be updated and the test repeated with the new line.
06111 JR AUTO_L_1
Now the 'automatic' listing can be made.
AUTO_L_2 06113 LD (23660),HL When E-PPC is less than S-TOP.
AUTO_L_3 06116 LD HL,(23660) Fetch the top line's number (S-TOP) and hence its address.
06119 CALL LINE_ADDR
06122 JR Z,AUTO_L_4 If the line cannot be found use DE instead.
06124 EX DE,HL
AUTO_L_4 06125 CALL LIST_ALL The listing is produced.
06128 RES 4,(IY+2) The return will be to here unless scrolling was needed to show the current line; reset bit 4 of TV-FLAG before returning.
06132 RET
Prev: 06035 Up: Map Next: 06133