- (direct command) close the loop by reentering LINE RUNto execute any remaining statements. Exit (apart from various report messages): RET from 1BB3 LINE END returns to 12CF MAIN 3 - other RETs are indirect jumps: in 1B55 GET PARAM, jump to the command class table withreturn address into the loop in 1B6F SEPARATOR, jump to 1B52 SCAN LOOP. Output parameters: none. Called from: 12CF MAIN 3 (misprinted PROG RUN) Exit from: 1B7D STMT R 1 Rems: Introduction commands produce jump to command routine 0020 NEXT CHAR called repeatedly during interpretation 0053 ERROR 2 return address to, points to error literal 1B17 LINE SCAN for syntax checking, starts here 1C16 JUMP C R indirect jump to command routine 1CD6 CL 09 1 fetches operands for PLOT etc 1E7A OUT fetches 2 operands for OUT 1EAC CLEAR fetches operand for CLEAR 1EAF CLEAR RUN provides default operand for CLEAR 1F3A PAUSE fetches operand for PAUSE 1F3D PAUSE 1 discriminates zero PAUSE operand 24FB SCANNING brief explanation of function evaluation LINE SCAN subroutine 1B17 The main subroutine for checking the syntax of a line inthe editing area. See errors and 1B8A LINE RUN. Input parameters: none. Action: set bit 7 of FLAGS; "syntax checking" - call 19FB E LINE NO, which reports an error if there is a line number and it is out of range, and puts the start address of the first statement in the BASIC pointer 5C5D CH ADD - zero 5C47 SUBPPC; start with the first statement - put FF in the error index; "OK" - it will be changed if any errors arise. Exit: to 1B28 STMT L 1, entering the statement loop, see under 1B8A LINE RUN; since the syntax checking flag is set, thismakes a "dry run". LINE RUN will merely check each command and expression in the line. Output parameters: none. Called from: 12AC MAIN 2 Rems: 0008 ERROR 1 address reached in the BASIC put in X PTR 0053 ERROR 3 top of stack is address in checking loop line start (BASIC) see BASIC line LINE USE 1BBF (1B8A LINE RUN, 1BEE CHECK END) Jumps from: 1B9E LINE NEW (twice) LINE ZERO 168F Two zero bytes, used at 1961 LINE NO A to load a zero line number in case there is no line in the program area. L IN W/S 2BA3 (2AFF LET) Jumps from: 2B9B L LENGTH LIST key (F0) see also commands, functions and operators, KEYBOARD SCANNING The K key in K mode produces the command LIST; it requires a numeric parameter, but if none is specified in BASIC zero is supplied. It may also be followed by (hatch) with semicolon or comma and a stream number, before the line number if any. It lists BASIC on the screen, or to the specified stream, starting at the given line number. The command is read by 1B29 STMT L 1 referring through the syntax offset table 1A48 to the syntax parameter table 1A7A.1AAE P LIST causes a jump via 1C11 CLASS 05 and 1C16 JUMP C R tothe executive routine 17F9 LIST. LIST subroutine 17F9 Called only by the statement loop from the syntax parameter table at 1AAE P LIST; executes the LIST command. The ROM allows for commands which are "not in the book",eg LIST (hatch)3;1000 or LIST (hatch)3,1000, which are equivalent to LLIST 1000. This command works correctly, but isn't mentioned in any of the "Spectrum" handbooks. The routine starts the listing from a line number specified in BASIC, or from the program start if none is specified. LIST with a line number greater than 9999d will produce no listing, but an "OK" report, see LIST 5 below; greater than 65535d will give "Integer out of range" from 1CDE FETCH NUM called in LIST 4. Input parameters: none. Action: make a stream number 02; print to upper screen. _17FB_LIST_1 (enter here from 17F5 LLIST): zero TV FLAG; bit 4 signals "ordinary listing" and bit zero "upper screen" - call 1601 CHAN OPEN to open a channel with the specified stream - read the code at the BASIC pointer - call 2070 STR ALTER, which changes the stream if the code is (hatch) - if it returns with carry jump on to LIST 4; no (hatch) - (the stream has been changed) check for comma or semicolon - if there is neither jump on to LIST 3. _1814_LIST_2 (the comma or semicolon imply a line number): move on the BASIC pointer - call 1C82 EXPT 1NUM to read the number; [the note is misprinted - "5.20" should be "5,20" or "5;20"] - jump on to LIST 5. _181A_LIST_3 (a stream change with no comma or semicolon implies line zero): call 1CE6 USE ZERO - jump on to LIST 5. _181F_LIST_4 (no stream change and so no comma or semicolon): call 1CDE FETCH NUM to get a line number from BASIC if there is one and use zero if not. _1822_LIST_5 (in all cases the line number is on the calculator stack): call 1BEE CHECK END; in syntax checking it reports "Nonsense in BASIC" if this isn't the end of the statement, or makes a double return to the statement loop if it is - (run time) call 1E99 FIND INT2 to get the line number off the stack - AND its hi byte with 00111111b/3Fh; this reduces it tomaximum 3FFFh/16383d, to ensure that the first byte in the variables area will act as an end marker in case no higher line exists - put this line number in 5C49 E PPC; making it the "current line" - call 196E LINE ADDR, which returns if there is a line with that number, the start addressof the line if there is a line after that number, its start address if there is no such line, the address of 5C4B VARS, holding an 80-byte - put 01 in E to signal to 1865 OUT LINE that "current line hasn't been printed"; this is really the first line of the 1835 LIST ALL exit routine, see below. OUT LINE is called in thenext line; it begins with a call to 1980 CP LINES, which makes aZ flag if it finds an_exact match for the given line number. This Z flag is read in OUT LINE, with the effect that the current line cursor is printed on the first LISTed line if its number is exactly the one specified in the LIST command, but nototherwise. Exit: into 1835 LIST ALL, which makes an "ordinary" listing of every BASIC line starting from the given number. Output parameters: HL holds the start address in the program area of the first line to be printed. E holds the flag 01. LIST ALL subroutine 1835 ["ROM Disassembled" is in a seriousmuddle here. The only call of LIST ALL is from 17ED AUTO L 4, where the call is to 1833, not 1835. However the three auto jumps in LIST ALL are to 1835, not 1833. There should really be another label] Prints out BASIC lines on screen or printer, with the current line cursor ">" on the correct line. It is called both in "automatic" and in "ordinary" listing, signalled by bit 4 of TV FLAG. In either case listing terminates after the last BASIC line has been listed; taken careof by the subroutine 1855 OUT LINE, which makes a "double return" by dropping its own return address if the last line of the program is reached. The difference lies in the action when the screen is full; see 0C55 PO SCR, which is called by the 09F4PRINT OUT routine whenever the print position line number moves on one. In automatic listing the screen is scrolled automati- cally until the current line is on screen, but once it is, thereis a return to editing. In ordinary listing the "scroll?" message is printed and execution awaits an input; this is handled within the 09F4 PRINT OUT routine. Input parameters: HL holds a pointer to the start of the first line to be printed. Action (starting with line 1833): make a flag 01 to signal "current line not yet printed" - call 1855 OUT LINE, which prints the line at the pointer; with the current line cursor if its line number matchesthe one in 5C49 E PPC, and it updates the current line flag if appropriate. If the line is the last in the listing it makes a double return out of the LIST ALL routine - call 0010 PRINT A 1 to print the carriage return - if bit 4 of TV FLAG is zero jump back to LIST ALL and repeat; for an ordinary listing. This endless loop is terminatedif the last line is reached, when OUT LINE makes its double return; otherwise 09F4 PRINT OUT, called by both OUT LINE and PRINT A 1, goes on printing lines and "scroll?" messages indefinitely - (automatic listing; PRINT OUT will have scrolled the screen automatically as much as is needed to print the line, andOUT LINE will again have made its double return if the last linehas been printed) compare the value in 5C6B DF SZ with 5C89 S POSN hi; DF SZ holds the number of lines in the lower screen, S POSN hi the line number of the current upper screen print position counted from the bottom of the screen - if they aren't equal jump back to LIST ALL; there is still space in the upper screen - (the upper screen is full) if the current line flag iszero, return; the current line with its ">" cursor has already been printed - (the current line hasn't been printed yet) point HL at5C6C S TOP and call 190F LN FETCH; 5C6C S TOP is the number of the top line which PRINT OUT won't scroll off the screen; LN FETCH replaces it with the next line number in the BASIC - jump back to LIST ALL to list another line; since 5C6CS TOP has been moved on, automatic scrolling will be possible. Exit: RET, if automatic listing and the current line flaghas been zeroed - if the last line has been printed, taken care of by the double return in 1855 OUT LINE - in ordinary listing, goes on with "scroll?" prompts indefinitely. Output parameters: none. Called from: 17ED AUTO L 4 Exit from: 17F5 LLIST and 17F9 LIST through 1822 LIST 5 Jumps from: auto (3 times) LIST AND LLIST COMMAND ROUTINES see 1795 AUTO LIST LIST ENTRY POINT see 17F9 LIST listing see 1795 AUTO LIST LIST SP system variable 5C3F Bytes: 2 Return from the "automatic listing" routine, starting at1795 AUTO LIST, is from the RET in 17ED AUTO L 4 if no scrollingof the screen was required, but from OC55 PO SCR after enough scrolling has been done to bring the current line on the screen.PO SCR can be called from several different points within the 09F4 PRINT OUT routine, and it is impossible to predict how manyRET addresses, etc will be piled up on the stack when RET is required. So the address of the stack pointer is saved in LIST SP on entry to 1795 AUTO LIST, and the stack pointer is returnedto it before returning, after the automatic listing is complete,from 0C55 PO SCR. Written by: 1795 AUTO LIST Read by: 0C55 PO SCR LIST 1 17FB (17F9 LIST) Jumps from: 17F5 LLIST LIST 2 1814 (17F9 LIST) Jumps from: 17FB LIST 1 LIST 3 181A (17F9 LIST) Jumps from: 17FB LIST 1 LIST 4 181F (17F9 LIST) Jumps from: 17FB LIST 1 LIST 5 1822 (17F9 LIST) Jumps from: 1814 LIST 2 181A LIST 3 literals see CALCULATE L LENGTH 2B9B (2AFF LET) Jumps from: 2B72 L DELETE$ LLIST key (E1) see also commands, functions and operators, KEYBOARD SCANNING, 022C extended mode key table (b) The V key in E mode without shift produces the command LLIST; it requires a numeric parameter, but zero is supplied if none is specified by the BASIC. It may also be followed by a stream number, see LIST key. The command is read by 1B29 STMT L 1 referring through the syntax offset table 1A48 to the syntax parameter table 1A7A.1ADC P LLIST causes a jump via 1C11 CLASS 05 and 1C16 JUMP C R to the executive routine 17F5 LLIST. LLIST subroutine 17F5 Called only from the syntax parameter table 1A7A to execute the LLIST command. Exactly like 17FB LIST except that stream 03, ZX printer, is opened instead of 02. As with LIST, there is an undocumented command option: LLIST (hatch)2;1000 hasexactly the same effect as LIST 1000. When channel 03 is in use all scrolling routines are bypassed. L-mode see 5C41 MODE LN key (B8) see also commands, functions and operators, KEYBOARD SCANNING, 022C extended mode table (b) The Z key in E mode without shift produces the function LN; it requires one numeric operand X, and the value of the function is the_natural logarithm of X, the power to which the constant e must be raised to equal X. The number e is 2.718281828..., see index entry on 36C4 EXP. On execution, 24FB SCANNING quickly leads to 26DF S NEGATE. This converts the key code B8 first to 09, then to E5, and adds the priority 10h/16d. Code and priority 10E5 are now pushed on to the machine stack (270D S PUSH PO) while the expression following LN is evaluated. When the code is taken off the stack (2734 S LOOP), it is converted (2773 S TIGHTER) from E5 to 25, the calculator offset for 3713 ln.