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

  1.                         byte buffer in A                                                     /    \                                           hi digit of (HL) <- lo digit of (HL)                                                                               and signals Z or NZ depending on what goes into the byte buffer        - make a leading zero flag FF.                                 _2EA1_PF_DIGITS: RLD again, getting the next digit in thebyte buffer                                                             - if it isn't zero jump on to PF INSERT                         - (zero digit) test the leading zero flag                       - if it is still FF jump on to PF TEST 2; leading zeroesaren't put in the buffer.                                              _2EA9_PF_INSERT: load the single digit to the destinationpointer                                                                 - move on the pointer                                           - increment the significant figures counter and the     magnitude counter                                                       - flag 00 "no leading zeroes now".                             _2EB3_PF_TEST_2: check the lo bit of the digit counter           - if it is zero jump on to PF ALL 9; the counter is even        - (the counter is odd) move on the source pointer; so onodd turns RLD puts what was the lo digit in the byte buffer; on even turns it puts the hi digit in the byte buffer and the lo   digit in the hi position.                                              _2EB8_PF_ALL_9: loop back to PF DIGITS till nine turns   are complete                                                            - (iX is now loaded as a decimal in the first nine bytesof the buffer) take nine from the significant figures counter           - if this makes carry jump on to PF MORE; there are lessthan nine decimal digits so far, and there may be a fractional  part                                                                    - (nine digits already loaded) decrement the significantfigures counter to eight; only eight will actually be output            - check the ninth digit against 04; it makes carry if   the ninth digit is five or more, so carry means "round up eighthdigit"                                                                  - jump on to PF ROUND.                                         _2ECB_PF_MORE (iX has gone into the print buffer, and    there are digits to spare for fX): use the calculator to delete iX and put fX as last value; it has been in mem-2 since PF LOOP.       _2ECF_PF_FRACTN (entry also from PF SMALL, when there wasno integer part): switch the pointers and call 2FBA FETCH TWO toget fX in L'D'E'DE                                                      - get the exponent and subtract it from 80h; this is thenumber of binary places the mantissa must be shifted right to   make zero its true exponent, never negative since fX being less than one has an exponent of 80h or less                                 - make the exponent zero                                        - set the hi bit of the mantissa; now the true mantissa         - call 2FDD SHIFT FP to make the right shift in the     mantissa; now the binary representation of fX                          _2EDF_PF_FRN_LP (fX is in D'E'DE): get the significant   figures count from the print buffer                                     - if it is less than eight jump on to PF FR DGT                 - (eight digits already) rotate the hi bit of fX into   carry                                                                   - jump on to PF ROUND; carry means "round up eighth     digit"                                                                 _2EEC_PF_FR_DGT (fX in binary form is in D'E'DE, and     there is room for it in digital form in the print buffer): zero a carry buffer                                                          - make a loop counter two for the main and alternate    registers.                                                             _2EEF_PF_FR_EXX: call 2F8B CA=10*A+C twice, first with   the lo digit and then with the hi digit of the present two      digits of fX, each time putting the lo byte of the result in fX replacing the old digit; CA=10*A+C multiplies the digit by ten, adds the carry buffer, and puts the lo byte of the result in A -this is put in fX replacing the old digit - and the hi in the   carry buffer                                                            - switch the registers and loop back to PF FR EXX               - (after two turns of the loop, fX has been multiplied  by ten; the fractional part replaces fX in D'E'DE, the integer  part is in the carry buffer, and is the next digit to be put in the print buffer) get a pointer to the start of the print buffer        - add the significant figures counter; now the pointer  is on the first empty digit                                             - put the new digit in the print buffer at this place           - increment the significant figures counter.                    - loop back to PF FRN LP for another decimal digit.            _2F0C_PF_ROUND (entry here from PF ALL 9 and PF FRN LP,  in either case with eight or less digits in the buffer and the  carry flag indicating whether to round up or down): save the    flag                                                                    - put a pointer on the first digit in the buffer                - add the significant figures counter; now the pointer  is just after the last significant digit                                - make a digit counter equal to the significant figure  counter                                                                 - recover the carry.                                           _2F18_PF_RND_LP: move the pointer back one and get the   digit                                                                   - add in the carry and put the digit back at the pointer        - if it is zero jump on to PF R BACK; this must be a    trailing zero, so the significant figures count is to be reduced        - compare it with ten, and reverse the carry flag; now  carry means "ten", it can't be more than ten                            - if it isn't ten jump on to PF COUNT; this exits from  the loop, there are no more carries.                                   _2F25_PF_R_BACK (if there is no carry, the last digit    with the carry was a trailing zero; if there is carry the last  digit with the carry was ten, which is also a trailing zero, butthe carry must be added into the preceding digit): count down   the loop counter and loop back to PF RND LP                             - (there is_still a carry after all the digits have beenchecked; so all the digits were nines): put one in the digit    byte reached                                                            - increment the digit count                                     - increment the magnitude count in the print buffer.           _2F2D_PF_COUNT: put the digit count in the print buffer  as the significant figures counter; it has been reduced if therewere any trailing zeroes, increased if all the digits were nines        - (now the print buffer is ready for outputting; it     holds digits in bytes one to nine, with the eighth rounded, the significant figures counter in byte eleven and the magnitude    counter in byte twelve) clear the calculator stack                      - recover the saved HL'; the registers aren't exchanged again                                                                   - make a printing counter equal to the significant      figures counter                                                         - make a pointer to the first digit in the buffer               - if the magnitude counter is less than 08 jump on to PFNOT E                                                                   - if it is less than FB/minus 4 jump on to PF E FRMT;   the number is either more than 99,999,999 or less than 0.00001, and must be output in E format.                                        _2F46_PF_NOT_E (the label is omitted by a misprint: it   should be on the "AND A" line): if the magnitude counter is zerocall 15EF OUT CODE to output a zero; no integer part and no     leading zeroes [a minor error, of style rather than execution:  the initial zero isn't output if there are four or less leading zeroes, and it really should be. "PRINT 1/7" produces 0.14285714with an initial zero, "PRINT 1/70" produces .014285714 without  one.]                                                                   2F4A_PF_E_SBRN (this section down to the return in PF DCOUT is also called as a subroutine from PF E FRMT, with 01 as   magnitude counter and the original significant figures counter):subtract the magnitude counter from zero                                - if the result is negative jump on to PF OUT LP; the   counter was positive                                                    - (the magnitude counter is negative) make the positive result a loop counter and jump on to PF DC OUT.                        _2F52_PF_OUT_LP (there are digits to output before the   decimal point): if the significant figures counter has been     counted down to zero jump on to PF OUT DT; the magnitude counteris still non-zero, so there are trailing zeroes in the integer  part                                                                    - (still significant digits to output) read the next    digit from the buffer and move on the pointer                           - decrement the significant figures counter.                   _2F59_PF_OUT_DT: call 15EF OUT CODE to output the digit; it will be a zero if the significant figures counter was zero           - loop back to PF OUT LP counting down the magnitude    counter.                                                               _2F5E_PF_DC_OUT (either the integer part has been output and the magnitude counter counted down to zero,                          or on entry from PF E SBRN there was no integer part   and the magnitude counter indicates leading zeroes to be output,         or on the second time round, after the jump back to PF OUT LP from PF DEC 0S below, both integer and fractional parts  have been output and both the magnitude counter and the         significant figures counter have been counted down)                     - if the significant figures counter has been counted   down to zero, return; there are no more digits to output                - (more digits to output) increment the loop counter;   there will be one extra turn of the PF DEC 0S loop to output thedecimal point                                                           - load 2E decimal point.                                       _2F64_PF_DEC_0S: call 0010 PRINT A 1 to output the       decimal point or zero                                                   - load 30h "zero"                                               - loop back to PF DEC 0S till the magnitude counter     counts down to zero                                                     - (decimal point and leading zeroes output) take the    significant figures counter for a loop counter                          - jump back to PF OUT LP to output the digits of the    fractional part.                                                       _2F6C_PF_E_FRMT (entered from PF COUNT with the magnitudecounter showing either more than eight significant figures or   more than four leading zeroes):                                         - decrement the magnitude to get the decimal exponent,  the number after E; eg 100,000,000, nine digits, is 1E+8, while 0.000001, five leading zeroes, is 1E-6                                  - call 2F4A PF E SBRN with magnitude count one; it      prints the number before E, always with one digit before its    decimal point                                                           - load 45h "E"                                                  - call 0010 PRINT A 1 to output it                              - check the exponent                                            - if it is positive jump on to PF E POS                         - (negative exponent) negate it                                 - load 2D "minus sign"                                          - jump on to PF E SIGN.                                        _2F83_PF_E_POS: load 2B +                                       _2F85_PF_E_SIGN: call 0010 PRINT A 1 to output the + or -        - exit into 1A1B OUT NUM 1 (misprinted OUT NUM); it can output any integer up to 9999d.                                        Exit: RETs at PF NEGTVE if the number is zero and at PF  DC OUT                                                                  - to 1A1B OUT NUM 1 from PF E SIGN if E format is used.        Output parameters: none                                          - the calculator stack has been cleared; except,        unfortunately, if PF SMALL is used - see 361F str$.                    Called from:                                                     361F str$                                                      Exit from:                                                       2024 PR ITEM 3                                                 Rems:                                                            2DC1 LOG(2**A) calculates no of digits in integer part          2F8B CA=10*A+C converts FP fractions to digits                                                                              PRINTING CHARACTER IN A BASIC LINE SUBROUTINE see 1925 OUT  SP 2                                                                                                                                printing on screen or ZX printer                                    Although we usually call it "printing", what actually   happens to the bytes "printed" depends on which channel is      currently open: they may go to the main or lower screen, to the ZX printer, to the work space, to the network, etc. See upper   screen, printer, channel R.                                             There are two more or less distinct kinds of routine in the ROM concerned with printing or_output:                             - the general-purpose output restart 0010 PRINT A 1, and the normal channel output routine 09F4 PRINT OUT, which handle  listings of BASIC as well as the output of computed expressions        - the 1FCD PRINT command routine, which is concerned withtransforming_print_items in or computed by the BASIC program -  colour and position controls, string and numeric expressions -  into forms suitable for output, and uses the general-purpose    routines for actual output.                                             The distinction is important eg in the handling of      position and colour controls: in PRINT OUT, an expression such  as "AT X,Y; INK Z" will be output as a string, with the tokens  expanded but without any attempt to execute the instructions; inPRINT, the tokens are converted to control codes before being   output through PRINT OUT, which therefore executes them in this case.                                                                   In the following REM list the command and control       routines, as opposed to the general-purpose output routines, aremarked with an asterisk.*                                              *078A LD TYPE message printed on screen                         *07A6 LD NAME loop to print filename                            *07AD LD CH PR print one character of filename                   09F4 PRINT OUT start of main output routines                    0A3D PO RIGHT equivalent to PRINT OVER 1; CHR$ 32               0A4F PO ENTER carriage return works differently on                            screen and ZX printer                             0A69 PO QUEST prints '?' for non-printable characters           0AAC PO AT ERR checks for scroll in lower screen                0AD0 PO SPACE print D spaces for TAB                            0AD9 PO ABLE calls PO ANY to print characters                   0B24 PO ANY calls appropriate routines for different                        character types                                     0B5F PO T prints tokens                                         0B7F PR ALL prints character from character form                0BB7 PR ALL 4 prints eight pixels of character                  0BC1 PR ALL 5 set attribute byte after printing                 0C0A PO MSG prints messages/tokens from lists                   0C14 PO TABLE finds message/token in table                      0C22 PO EACH prints each character of message/token             0C3B PO SAVE prints character while saving registers            0C88 PO SCR 2 prints "scroll?" message                          0EF4 COPY LINE printing to ZX printer                           0EFD COPY L 1 if BREAK pressed, empty buffer and stop           0F1E COPY L 5 single bits sent to ZX printer                    0FA9 ED EDIT copies BASIC line to editing area                  111D ED COPY copies line in editing area to lower screen        1150 ED BLANK lines filled out with blanks                      115E ED SPACES prints each blank                               *1219 RAM SET prints copyright message                           17F5 LLIST opens channel for ZX printer                         1835 LIST ALL loop to print whole lines of BASIC                1855 OUT LINE prints BASIC line with line number                1865 OUT LINE1 prints line number and line cursor               1881 OUT LINE3 set signals to print in K or L mode              1894 OUT LINE4 loop to print each char in BASIC line,                          and error marker                                 18A1 OUT LINE5 print cursor if required                         18B4 OUT LINE6 line print of BASIC complete                     18C1 OUT FLASH prints cursor or error cursor                    18E1 OUT CURS checks if C E G K L cursor to be printed          18F3 OUT C 1 selects C K or L for cursor print                  1909 OUT C 2 prints cursor with flash                           1925 OUT SP 2 start of routine to print individual                            characters in BASIC line                          192B OUT SP 1 prints line number digit or leading space         1937 OUT CHAR prints each character except line numbers         195A OUT CH 1 signals quote mode on/off                         196D OUT CH 2 print character and loop                          1A1B OUT NUM 1 prints numbers 0-9999 from BC register           1A2B OUT NUM 2 prints numbers 0-9999 from (HL)                  1A30 OUT NUM 3 prints integer in HL                             1A42 OUT NUM 4 prints last digit                               *1FC3 UNSTACK Z skips printing in syntax checks                 *1FC9 LPRINT signals channel for ZX printer                     *1FCD PRINT signals channel for screen output                   *1FCF PRINT 1 opens channel, sets temp colours                  *1FDF PRINT 2 checks for last print item                        *1FE5 PRINT 3 checks for position and colour items              *1FFC PR ITEM 1 handles AT and parameters                       *201E PR AT TAB outputs AT or TAB and parameters                *2024 PR ITEM 3 sorts out colour items, numeric and      string                                                                                 expressions                                     *2045 PR END 2 checks end of printing                           *21AF IN NEXT 1 handles position/colour controls in                             INPUTs                                          *2DC1 LOG(2**A) calculates printing length of FP number         *2DE3 PRINT FP start of routine to print numbers from                          calculator stack                                 *2DF2 PF NEGTVE prints minus sign                               *2E24 PF SMALL digits for printing stored in buffer