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

  1.     OUT SP NO subroutine 192A                                           Prints the decimal digit of an integer, and returns the value of the integer after "decapitation" of its first digit,   ready for a further call. It will print leading spaces if       supplied with a space byte in the E register, and no leading    character if supplied with FF. Any other value in the E registerwill print in the position of leading zeroes. After each call to15EF OUT CODE from OUT SP 1, the E register holds 30h "zero" so non-leading zeroes print correctly as zeroes.                           It is called only from 1A30 OUT NUM 3, which makes threesuccessive calls to OUT SP NO, one for each of the three first  digits of a four-digit number, with BC indicating the digit; BC is successively FC18h/-1000d, FF9Ch/-100d and FFF6h/-10d, and   what is left of HL is brought round again with the next BC when the subroutine is called again.                                         There is no SUB HL,BC in the Z80 instruction set, but   ADD HL,BC is just as good if BC is negative. The loop in OUT SP 1 "subtracts" BC repeatedly from the integer, keeping count in  A, till the "subtraction"_fails to set carry; then it reverses  the last "subtraction" and decrements the count, giving the     required result.                                                        Despite the arrangement of the ROM, the two subroutines in this section are OUT SP NO and OUT CHAR - to which OUT SP NO also exits. OUT SP 2 would have been better placed after OUT SP 1 where it belongs, in fact this would have saved a jump        instruction. Here the routines are taken in their logical order,not their numeric order.                                               Input parameters: HL holds an integer less than 2710h/   10000d.                                                                 - BC holds FC18h/-1000d on the first call, FF9C/-100d onthe second and FFF6h/-10d on the third                                  - E holds 20h space if leading spaces are required, FF  if not; until any digit has printed and then 30h "zero", from   OUT CODE.                                                              Action                                                          _192A_OUT_SP_NO: make a zero digit counter.                     _192B_OUT_SP_1: "subtract" BC from HL                            - increase the digit counter                                    - if the "subtraction"_didn't make a carry jump back to OUT SP 1                                                                - "add" it back and decrement the digit counter; it now holds the required digit                                                - if the digit is zero jump on to OUT SP 2                      - (non-zero digit) exit into 15EF OUT CODE.                    _1925_OUT_SP_2 (zero digit): copy the leading space flag to the digit byte                                                       - if it is FF return; skip leading spaces                       - (it is 20h space or 30h zero) exit to 1937 OUT CHAR.         Exit: RET from OUT SP 2                                         - through 15EF OUT CODE, which prints the digit, from OUTSP 1                                                                   - through 1937 OUT CHAR, which prints the space or zero, from OUT SP 2.                                                         Output parameters: A holds the digit                             - HL holds the "remainder" from the input integer after decapitation of its first decimal digit; eg if HL was input as  2304d on the first call, it will be 304d and 04 on the two      following calls.                                                       Called from:                                                     1A30 OUT NUM 3 (3 times)                                       Rems:                                                            1925 OUT SP 2 line nos may require leading spaces or not                                                                    OUT SP 1 192B (192A OUT SP NO)                                     Jumps from:                                                      auto                                                                                                                        OUT SP 2 1925 (192A OUT SP NO)                                     Jumps from:                                                      192B OUT SP 1                                                                                                               OVER key (DE) see also KEYBOARD SCANNING, extended mode key table (c)                                                               The N key in E mode with either shift produces the tokenOVER. OVER can be used either as a BASIC command or as a print  control item within a PRINT etc statement. In either case it    causes any new printing to merge with what is on screen already,overwriting it bit by bit rather than byte by byte.                     The OVER mask is 00000000 for OVER 0 and 11111111 for   OVER 1. This mask is ANDed with the pixel already on screen,    which blanks it completely for OVER 0 and leaves it unchanged   for OVER 1; then the result is XORed with the new pixel. See    0B93 PR ALL 1, 0BB7 PR ALL 4; for an example see under 0B24 PO  ANY.                                                                    As a command, it is read by 1B29 STMT L 1 referring     through the syntax offset table 1A48 to the syntax parameter    table 1A7A. 1AF0 P OVER causes a jump to 1C96 CLASS 07 (PERMS), the executive routine for all the colour item commands INK to   OVER.                                                                   As a print control item, execution is from within the   PRINT executive routine 1FCD PRINT; each new expression         following the PRINT command is checked by a call to 1FFC PR ITEM1 from 1FE5 PRINT 3. If it is OVER, this in turn calls 21F2 CO  TEMP 3 from 2024 PR ITEM 3; here the token code DE is converted to the "embedded" control code 15h, which is then sent through  the output routine followed by the parameter one or zero.               The way this works when printing on screen can be seen  at 09F4 PRINT OUT; indexing with 15h for OVER into the control  character table at 0A11 produces an indirect jump to 0A7A (0A20 + 5A) PO 1 OPER. See under PO 1 OPER for the rather tricky way  in which it collects the parameter and sends execution to 0A87  PO CONT, which finally executes the OVER command.                       Introduction checked on every input                             0A3D PO RIGHT cursor right equiv to PRINT OVER 1;CHR$ 32        18C1 OUT FLASH ensures OVER 0 for flashing cursors                                                                          overflow                                                            Can mean several different things, but primarily        _overflow refers to numbers produced by calculation which are   too large to fit into the particular register(s) designated for them, or too large for the Spectrum system as a whole to handle;this latter is_arithmetic_overflow. Either of these usually getsreported as an error.                                                  _Underflow may mean either                                      "big underflow": a minus number has been produced which  similarly overflows the system or the registers, or                    "zero underflow": a number has been produced whose       absolute value is so small as to be indistinguishable from zero.        Big underflow is an error, zero underflow merely resultsin zero being used as the value instead.                                The exponent of a full-format FP number cannot be zero, because if its exponent byte is zero it must be read as a small integer; so the smallest positive number that can be representedis 01 00 00 00 00, which represents 2**-127 times one-half, ie  2**-128 or one divided by 2**128. Anything less than this must  be reformed as zero, 00 00 00 00 00. It is about 2.94 E-39,     0.0...0294 with the "..." representing 37 zeroes. The negative  of 01 00 00 00 00 is 01 80 00 00 00.                                    The largest possible exponent is obviously FF, true     exponent 7Fh/127d. If an operation produces a number with       exponent bigger than 127d, it must be detected and the          "Arithmetic overflow" report given.                                     Sometimes in the notes "overflow" means little more than"carry", eg when FF is added to FF giving FE with carry,        occasionally called "overflow to the left", or shifting a byte  to the right produces a carry called "overflow to the right".   These are usually not errors.                                           1E9C FIND I 1 flag indicates 1-byte or 2-byte integer                         too big for registers.                            2AF4 GET HL*DE overflow signalled as "Out of memory"            2CA2 BIN DIGIT system cannot handle 17-digit BIN inputs!        2CFF ST E PART overflow if exponent > 127d                      2F25 PF R BACK "overflow to the left"; more digits                             needed                                           2FDD SHIFT FP "overflow to the right"; round up lo bit          2FFB ZEROS 4/5 makes zero from zero underflow                   3004 ADD BACK incrementing exponent may overflow                3014 addition if small integer addn overflows, FULL ADDN        303E FULL ADDN two quite different overflows:                                  1. if adding the mantissas comes out > 1,                       shift them right and increment the                              exponent (or vice versa for negatives);                         2. the answer may be too big for the                            system                                           3055 SHIFT LEN same as last                                     307C TEST NEG big underflow is possible                         30A9 HL=HL*DE returns with carry if overflow                    30CA multiply if small integers overflow, MULT LONG             30F0 MULT LONG has check for overflow and zero underflow        313D DIVN EXPT overflow indicated by NC                         3146 OFLW1 CLR checks "true exponent" for overflow              3151 OFLW2 CLR multiplying 4-byte mantissas has produced                       a 5-byte result; an entirely different                          "overflow"                                       3155 TEST NORM handles zero underflow                           3186 NORML NOW final carry may produce too big result           31AF division dividing by zero produces "Number too big"        37DA tan sin/cos can produce overflow                           3851 to-power zero to minus power gives overflow                385D XISO divide by zero to make overflow                                                                                   overhead see 05E7 LD EDGE 1                                                                                                                              -----                                                                                                  PAPER key (DA) see also colours, commands, functions and    operators, KEYBOARD SCANNING, 0246 extended mode key table (c)          The C key in E mode with either shift produces the tokenPAPER. PAPER can be used either as a BASIC command or as a printcontrol item within a PRINT etc statement. In either case it    sets the "pixel off" colour of any new printing on the screen;  INK sets the "pixel on" colour. It must be followed by a        parameter, a numeric expression with the value zero to 9. Zero  to seven are the screen colours, PAPER 8 means "don't change thePAPER colour in this position", PAPER 9 means "use black or     white, whichever contrasts best with the INK colour".                   As a command, it is read by 1B29 STMT L 1 referring     through the syntax offset table 1A48 to the syntax parameter    table 1A7A. 1AEC P PAPER causes a jump to 1C96 CLASS 07 (PERMS),the executive routine for all the colour commands INK to OVER.          As a print control item, execution is from within the   PRINT executive routine 1FC0 PRINT; each new expression         following the PRINT command is checked by a call to 1FFC PR ITEM1 from 1FE5 PRINT 3. If it is PAPER, this in turn calls 21F2 CO TEMP 3, from 2024 PR ITEM 3; here the token code DA is convertedinto the embedded control code 11h, which is then sent through  the output routine followed by its parameter.                           The way this works when printing on screen can be seen  at 09F4 PRINT OUT; indexing with 11h for PAPER into the control character table at 0A11 produces an indirect jump to 0A7A (0A1C + 5E) PO 1 OPER. See under PO 1 OPER for the rather tricky way  in which it collects the parameter and sends execution to 0A87  PO CONT, which finally executes the PAPER command.                      OBD9 PO ATTR jump for PAPER 9                                   18C1 OUT FLASH eliminate PAPER 9                                                                                            paper colour see colours                                                                                                        PAPER control code (11h) see INK control code                                                                                   parameters of array see arrays                                                                                                  parameters of AT and TAB see control characters                                                                                 parameters of BASIC command see BASIC INTERPRETER                                                                               parameters of DEF FN see DEF FN key                                                                                             parameters of embedded control character see colours                                                                            parameters of INK to OVER see colours                                                                                           parameters of name see strings                                                                                                  parameters of print position see DISPLAY AREA                                                                                   parameters of save command, parameters of save/load header  see 0605 SAVE ETC                                                                                                                   parameters of string see strings                                                                                                parenthesised expression see expressions                                                                                        parity byte of save/load see 04C2 SA BYTES                                                                                      PASS BY subroutine 1E39                                             During BASIC execution, skips over the present BASIC    statement, which is a DATA or DEF FN statement.                        Input parameters: A holds E4 DATA or CE DEF FN                   - HL holds the pointer to the BASIC program from 5C5D CHADD; if A holds DATA this will be in the DATA statement, if DEF FN in the DEF FN statement.                                            Action: move the pointer back to the DATA or DEF FN      command; in the ROM calls this is unnecessary, since HL is      already on the address of the command byte in all cases                 - put 2 in D.                                                  Exit: to 198B EACH STMT; this decrements D, then moves onthrough the program till it finds a colon or newline, when it   decrements D to zero and RETs with the BASIC pointer in HL.            Output parameters: HL is the address of the DATA or DEF  FN, D is 2.                                                            Exit from:                                                       1E37 DATA 2 (1E27 DATA)                                         1F60 DEF FN                                                                                                                 "pass" in FOR ... NEXT loops see FOR ... NEXT loops                                                                             passing by see 1E39 PASS BY                                                                                                     PAUSE key (F2) see also commands, functions and operators,  KEYBOARD SCANNING                                                       The M key in K mode produces the command PAUSE. The     "PAUSE statement" must include a numeric parameter X indicating the length of the pause in 1/50th second units; not necessarily an integer, but it will be read as an integer and it must be    less than 10000h/65536d; zero gives an indefinite pause.                The command is read by 1B29 STMT L 1 referring through  the syntax offset table 1A48 to the syntax parameter table 1A7A.1AC5 P PAUSE causes a jump via 1C82 CLASS 06, to collect the    parameter, 1C10 CLASS 00 and 1C16 JUMP C R to the executive     routine 1F3A PAUSE.                                                                                                                 PAUSE subroutine 1F3A                                               Called only from 1AC5 P PAUSE in the statement loop to  execute the PAUSE command.                                             Input parameters: none                                           - the PAUSE parameter is on the calculator stack.              Action: call 1E99 FIND INT2 to get the parameter.               _1F3D_PAUSE_1: HALT; 1/50th second, or 1/60th in USA             - decrement the parameter                                       - if it is zero, jump on to PAUSE END                           - if it isn't FFFFh, jump on to PAUSE 2                         - (FFFFh, so it was zero) increment it back to zero.           _1F49_PAUSE_2: if bit 5 of FLAGS is zero jump back to    PAUSE 1; the "new key pressed" flag, no new key was pressed.           _1F4F_PAUSE_END (either the counter has gone to zero or akey has been pressed): zero bit 5 of FLAGS; "waiting for key"           - return.                                                      Exit: RET from PAUSE END.                                       Output parameters: none                                          - the parameter has come off the calculator stack.                                                                          PAUSE END 1F4F (1F3A PAUSE)                                        Exit from:                                                       1F3A PAUSE through                                              1F3D PAUSE 1                                                                                                                PAUSE 1 1F3D (1F3A PAUSE)                                          Jumps from:                                                      1F49 PAUSE 2                                                                                                                PAUSE 2 1F49 (1F3A PAUSE)                                          Jumps from:                                                      1F3D PAUSE 1                                                                                                                P BEEP 1AE3                                                     P BORDER 1AF5                                                   P BRIGHT 1AEE                                                   P CAT 1B14                                                      P CIRCLE 1AE7                                                   P CLEAR 1ABB                                                    P CLOSE 1B02