home *** CD-ROM | disk | FTP | other *** search
/ Outlet 52 / outlet-52.mgt / l4 < prev    next >
Text File  |  2021-04-18  |  20KB  |  1 lines

  1.     LINE END 1BB3 (1B8A LINE RUN, 1BEE CHECK END)                      Exit from:                                                       1B29 STMT L 1                                                   1BB2 REM                                                        1BF4 STMT NEXT (1BEE CHECK END)                                 1CF0 IF                                                                                                                     line execution see 1B8A LINE RUN, BASIC INTERPRETER,        running, run time                                                                                                                   LINE NEW 1B9E (1B8A LINE RUN)                                      Jumps from:                                                      1B7D STMT R 1                                                                                                               LINE NO subroutine 1695                                             Finds the number of a BASIC line at a given address in  the program area. Calls to this subroutine always follow        directly or almost directly a call to 196E LINE ADDR. If there  is no program, both the "line start" and the "preceding line    start" will be the program start address in 5C53 PROG, which    must hold a line number if there is any program at all; if thereis none, it is the same address as 5C4B VARS. If the line start is on 5C4B VARS, its byte will be 40h or more, see "80-byte"    after the end of the alphabet; in this case the routine looks   for the preceding line start and reports its line number. If    this too is on 5C4B VARS, the routine uses the dummy line start at LINE ZERO, and hence reports a zero line number.                    Input parameters: HL holds a pointer to the line start;  if the last line of the program has been reached it is the      address in 5C4B VARS                                                    - DE holds a pointer to the preceding line start, if    any.                                                                   Action: AND the byte at the line start with 11000000b/   C0h; it should be the hi byte of a line number                          - if the result is non-zero jump back to LINE NO A; the byte is 40h or more, ie HL is on 5C4B VARS                              - (the byte is less than 40h) read the hi-lo line numberinto DE and return.                                                    _1691 (misprinted 1961)_LINE_NO_A: remake the pointer on the preceding line start                                                - make the preceding line start pointer the address of  168F LINE ZERO, which holds a two-byte zero                             - reenter LINE NO to try again; if the byte at the      pointer is still out of range, the zero line number from LINE   ZERO will be accepted next time round.                                 Exit: RET.                                                      Output parameters: DE holds the line number in normal lo-hi order                                                                - BC unaffected.                                               Called from:                                                     0FA9 ED EDIT                                                    1059 ED UP                                                      190F LN FETCH                                                                                                               LINE NO A 1691 (misprinted 1961; 1695 LINE NO)                     Jumps from:                                                      1695 LINE NO                                                                                                                line numbers                                                        The term is used in at least five different senses in   the notes; sometimes this can be a little confusing. For 2, 3   and 4 below see DISPLAY AREA.                                        1. The line number of a line in the BASIC program, see     BASIC line.                                                          2. The AT/TAB screen line number, as used in BASIC.             3. The "print position" or "position value" line number as mostly used in ROM.                                                  4. The pixel line number, the same as the PLOT coordinate  line number, when counting pixel lines.                              5. The scroll number or scrolling line number, when        counting scroll lines. See 0E00 CL SCROLL.                                                                                          line of BASIC see BASIC line                                                                                                    line of/on display/screen see DISPLAY AREA                                                                                      line of keys see KEYBOARD SCANNING                                                                                              LINE RUN subroutine 1B8A see also BASIC INTERPRETER                 Executes a BASIC line which has been entered in the     editing area using 0F2C EDITOR; thus it is the main execution   subroutine for the whole of BASIC, since BASIC programs can onlybe executed by commands like RUN, GO TO, in such a line. Also   called for syntax checking, see 1B17 LINE SCAN.                         The main loop runs through 1BD1 NEXT LINE and 1BF4 STMT NEXT to 1BB3 LINE END and so back to 1BD1 NEXT LINE, so long as there are BASIC lines to be executed; from 1BD1 NEXT LINE or    1BF4 STMT NEXT it enters the sub-loop 1B28 STMT LOOP and        following, which executes each command statement in the BASIC   line, and loops back to 1B29 STMT L 1 for another statement tillthe line end is reached, when it exits to 1BB3 LINE END. The    statement loop from 1B28 STMT LOOP is included here as part of  LINE RUN, but its action is described out of order, following   the end of the main LINE RUN loop at 1BF4 STMT NEXT.                    The same loops are turned in executing an un-numbered   BASIC command in the lower screen; but if this contains a RUN orGO TO command, execution continues still within the LINE RUN    loop, and now 1BB3 LINE END will loop on into following numberedBASIC lines till the end of the program is reached.                     There are fifty possible BASIC commands, see the table  under commands, functions and operators. Each command byte in a BASIC line is converted in 1B29 STMT L 1 to an offset, which is used to compute an address in the syntax parameter table at     1A7A. This table contains up to eight entries for each command  address: the first entry again computes an address, this time   from the command class table at 1C01, and makes an indirect jumpto this address.                                                        The command table calls class routines to collect from  the BASIC line whatever "operand" or "parameter" expressions areneeded to carry out the command, checks that the required       "separators" = , THEN etc are present, and finally calls the    executive subroutine.                                                   Eg in the case of IF:                                          - call 1C82 CLASS 06 to evaluate the IF clause in the    BASIC as a logical expression                                          - check that THEN is present in BASIC                           - call 1C11 CLASS 05, which prepares to exit from the    command loop                                                           - call the executive routine 1CF0 IF.                            The mechanism for stepping through this table is in 1B55GET PARAM, which is entered with a table address and the value  of the byte at that address. Each byte in the table is either          - 00 to 0B, indexes for the command class routines              - or a separator = THEN TO or comma, using their normal  token/character codes                                                  - or one of the two bytes of a command routine address;  but they always follow an index to one of the command class     routines which don't return to 1B52 SCAN LOOP, hence these bytesare never read by 1B55 GET PARAM.                                       So if the byte is 20h or more, 1B55 GET PARAM jumps on  to 1B6F SEPARATOR, which handles the separators and returns intothe loop; if it is 00 to 0B, 1B55 GET PARAM adds it to the base address 1C01 of the command class table, adds the offset from   that table and jumps to the resulting address, which is a       command class routine.                                                  The final jump to the executive routine is made by 1C16 JUMP C R.                                                               Another important loop is the 24FB SCANNING loop, which is called from the various command class routines, usually      indirectly via 1C82 EXPT 1NUM etc, to evaluate expressions in   the BASIC: these may be numbers, strings, or variables, or      functions or operators with their arguments - the arguments     themselves being expressions. Every time it evaluates an        expression, it leaves a FP number on the calculator stack, whichis either the value of a numeric expression or the string       parameters of a string expression: for a numeric expression a   decimal number in the BASIC, a numeric variable, or a function, for string parameters the start address and length of some placein the RAM where the codes of the string are stored.                    A resume of the svs used may be useful:                        - 5C45 PPC holds the number of the line at present being executed                                                               - 5C49 E PPC holds the number of the "current line" for  listing on screen with the current line cursor                         - 5C47 SUBPPC holds the number of the present statement -used by CONTINUE, GO SUB and FOR commands, and also for the     statement number in error reports                                      - 5C42 NEWPPC holds the next line number for execution   after a jump                                                           - 5C44 NSPPC holds the statement number for execution    after a jump, or FF as a "no jump" signal, ie "next statement"         - 5C55 NXTLIN holds the start address of the next BASIC  line after the current one                                             - 5C5D CH ADD holds the address of the byte currently    being interpreted                                                      - 5C74 T ADDR holds an address in the syntax parameter   table.                                                                 Input parameters: none.                                         Action [the description starts at 1B8A LINE RUN. The     section from 1B28 STMT LOOP to 1B7D STMT R 1 is all part of the routine, but is taken out of order below following 1BF4 STMT    NEXT]: load 5C45 PPC with -2, the line number of the editing    area                                                                    - set pointers at start and end of the editing area from5C59 E LINE and 5C61 WORKSP                                             - get from 5C44 NSPPC the next statement number for     execution; set to one in 12CF MAIN 3, but probably more if LINE RUN has been entered from 1B29 STMT L 1, looping back after     execution or syntax checking of the first statement                     - jump on to 1BD1 NEXT LINE.                                   _1B9E_LINE_NEW (the loop return point from 1B76 STMT RET,after a statement has been executed, if 5C44 NSPPC indicates a  jump in BASIC - GO TO, GO SUB, NEXT, etc): call 196E LINE ADDR  for the address in the program area corresponding to the line   number in 5C42 NEWPPC                                                   - if the exact line was found, jump on to 1BBF LINE USE         - (the jump is to a line number which isn't used in the program) if the statement number isn't zero report "Statement   lost"; something vital has been deleted from the program                - if the line number is more than 4000h report "OK"; theend of the program has been reached                                     - (LINE ADDR will have returned the number of the       following line) jump on to 1BBF LINE USE.                               [1BB2 REM, the command mini-routine for the REM command,is interpolated here: it merely drops the 1B76 STMT RET address,with the effect that the line is considered executed already.]         _1BB3_LINE_END (see also under 1BEE CHECK END; 1B29 STMT L 1 reenters the loop here if it comes to a newline): if syntax checking return                                                         - (run time) get from 5C55 NXTLIN the address in the    program area of the next line start; it was loaded in 1BD1 NEXT LINE                                                                    - if the line number is more than 4000h return; the end of the program has been reached                                         - zero the statement number.                                   _1BBF_LINE_USE (entered also from 1B9E LINE NEW, with    line address and statement number of the next line to be        executed. Statement number zero means "start from the beginning of the line", ie the same as number one): if the statement      number is zero make it one                                              - read the line number, hi before lo, and put it in 5C45PPC                                                                     - read the length of the line; in the two bytes after   the line number, see BASIC line                                         - compute the address of the next line start.                  _1BD1_NEXT_LINE (entered also from LINE RUN executing    direct commands in the editing area, in which case the "next    line start" address is on the 80-byte at the end of the editing area):                                                                  - put the next line start in 5C55 NXTLIN                        - put the start of the present line in 5C5D CH ADD as a BASIC pointer                                                           - put FF in 5C44 NSPPC; "no jump"                               - decrement the statement number and put it in 5C47     SUBPPC                                                                  - if this is zero jump back to 1B28 STMT LOOP; the BASICpointer is already correct                                              - call 198B EACH STMT to move the BASIC pointer on to   the start of the statement indicated                                    - if there is such a statement jump on to 1BF4 STMT NEXT        - if not report "Statement lost"; something has got     deleted .                                                               [1BEE CHECK END is interpolated here, see its index     entry.]                                                                _1BF4_STMT_NEXT (entered also from 1B7D STMT R 1 after   execution of each statement, if there is no jump in BASIC): if  the next character is a newline jump back to 1BB3 LINE END              - if it is a colon jump back to 1B28 STMT LOOP                  - (statement complete but no terminator) report         "Nonsense in BASIC".                                                   _1B28_STMT_LOOP (execution loops back to here either from1BF4 STMT NEXT at a colon or from 1BD1 NEXT LINE for the first  statement of a line): move on the BASIC pointer; this is now on the first byte of a new statement. It must be a BASIC command ora terminator, otherwise there will be an error report shortly.         _1B29_STMT_L_1 (also entered from 1B17 LINE SCAN for     syntax checking and 1D00 IF 1 after a "true" IF statement): call16BF SET WORK to clear the work space                                   - increment 5C47 SUBPPC                                         - if it goes "negative" report "Nonsense in BASIC";     there are 128d statements in the line.                                  - if the character at the BASIC pointer is a newline    jump on to 1BB3 LINE END                                                - if it is a colon jump back to 1B28 STMT LOOP                  - (it should be a BASIC command) stack the loop return  address 1B76 STMT RET; any RET from here on will return there - unless this address has been dropped first, as is done in some  of the subroutines, or overlaid by another as happens in 1B55   GET PARAM                                                               - put the BASIC pointer on the byte after the command           - reduce the command byte by CE                                 - if this makes carry, report "Nonsense in BASIC"; all  the command token codes start from CE DEF FN                            - (the byte is 00 DEF FN -> 31h COPY) add it to 1A48;   giving an address in the syntax offset table                            - add this offset to the entry address; making an       address in the syntax parameter table starting at 1A7A                  - jump on to 1B55 GET PARAM.                                   _1B52_SCAN_LOOP (this is stacked as the return address by1B55 GET PARAM on top of the 1B76 STMT RET address stacked by   1B29 STMT L 1; all the command class routines return here except00, 02, 03, 05, 07, 0B, which jump out to command routines with the 1B76 STMT RET address for return): recover from 5C74 T ADDR the current place in the syntax parameter table.                       _1B55_GET_PARAM: get a byte from the syntax parameter    table                                                                   - save the next address from the table in 5C74 T ADDR           - put the 1B52 SCAN LOOP return address on the stack;   RET will now be to there till scanning of the syntax parameter  table is complete, when 1B52 SCAN LOOP will be dropped, usually by CLASS 05. Subsequent RETs will be to 1B76 STMT RET, the next address down on the stack                                               - if the syntax parameter byte is more than 20h jump on to 1B6F SEPARATOR                                                       - index into the command class table at 1C01 with the   parameter byte                                                          - compute the command class address and stack it                - get the byte_after the BASIC command in A; the notes  are wrong                                                               - set the NZ flag to stop 1C11 CLASS 05 calling 1BEE    CHECK END; B was zero                                                   - return; an indirect jump to the command class address.       _1B6F_SEPARATOR (entered only from 1B55 GET PARAM when a separator is found in the syntax parameter table): compare the  character in the BASIC with the separator specified in the      syntax parameter table                                                  - if it doesn't match report "Nonsense in BASIC"                - move on the BASIC pointer                                     - return; to 1B52 SCAN LOOP.                                   _1B76_STMT_RET (all the BASIC command routines return    here in run time except 1CF0 IF, 1CEE STOP, 1BB2 REM, 11B7 NEW  and 1793 CAT ETC, and so do command class routines 02 and 07):  call 1F54 BREAK KEY to check for BREAK.                                _1B7D_STMT_R_1: if the hi bit of 5C44 NSPPC is set jump  on to 1BF4 STMT NEXT; it must be FF signalling "no jump in      BASIC"                                                                  - (jump in BASIC) if the hi bit of 5C42 NEWPPC is zero  jump on to 1B9E LINE NEW; it has a real line number, not -2 for the direct commands