^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) | bindec.sa 3.4 1/3/91
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) | bindec
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) | Description:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) | Converts an input in extended precision format
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) | to bcd format.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) | Input:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) | a0 points to the input extended precision value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) | value in memory; d0 contains the k-factor sign-extended
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) | to 32-bits. The input may be either normalized,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) | unnormalized, or denormalized.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) | Output: result in the FP_SCR1 space on the stack.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) | Saves and Modifies: D2-D7,A2,FP2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) | Algorithm:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) | A1. Set RM and size ext; Set SIGMA = sign of input.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) | The k-factor is saved for use in d7. Clear the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) | BINDEC_FLG for separating normalized/denormalized
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) | input. If input is unnormalized or denormalized,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) | normalize it.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) | A2. Set X = abs(input).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) | A3. Compute ILOG.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) | ILOG is the log base 10 of the input value. It is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) | approximated by adding e + 0.f when the original
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) | value is viewed as 2^^e * 1.f in extended precision.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) | This value is stored in d6.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) | A4. Clr INEX bit.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) | The operation in A3 above may have set INEX2.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) | A5. Set ICTR = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) | ICTR is a flag used in A13. It must be set before the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) | loop entry A6.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) | A6. Calculate LEN.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) | LEN is the number of digits to be displayed. The
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) | k-factor can dictate either the total number of digits,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) | if it is a positive number, or the number of digits
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) | after the decimal point which are to be included as
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) | significant. See the 68882 manual for examples.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) | If LEN is computed to be greater than 17, set OPERR in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) | USER_FPSR. LEN is stored in d4.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) | A7. Calculate SCALE.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) | SCALE is equal to 10^ISCALE, where ISCALE is the number
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) | of decimal places needed to insure LEN integer digits
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) | in the output before conversion to bcd. LAMBDA is the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) | sign of ISCALE, used in A9. Fp1 contains
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) | 10^^(abs(ISCALE)) using a rounding mode which is a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) | function of the original rounding mode and the signs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) | of ISCALE and X. A table is given in the code.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) | A8. Clr INEX; Force RZ.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) | The operation in A3 above may have set INEX2.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) | RZ mode is forced for the scaling operation to insure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) | only one rounding error. The grs bits are collected in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) | the INEX flag for use in A10.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) | A9. Scale X -> Y.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) | The mantissa is scaled to the desired number of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) | significant digits. The excess digits are collected
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) | in INEX2.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) | A10. Or in INEX.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) | If INEX is set, round error occurred. This is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) | compensated for by 'or-ing' in the INEX2 flag to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) | the lsb of Y.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) | A11. Restore original FPCR; set size ext.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) | Perform FINT operation in the user's rounding mode.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) | Keep the size to extended.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) | A12. Calculate YINT = FINT(Y) according to user's rounding
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) | mode. The FPSP routine sintd0 is used. The output
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) | is in fp0.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) | A13. Check for LEN digits.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) | If the int operation results in more than LEN digits,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) | or less than LEN -1 digits, adjust ILOG and repeat from
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) | A6. This test occurs only on the first pass. If the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) | result is exactly 10^LEN, decrement ILOG and divide
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) | the mantissa by 10.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) | A14. Convert the mantissa to bcd.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) | The binstr routine is used to convert the LEN digit
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) | mantissa to bcd in memory. The input to binstr is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) | to be a fraction; i.e. (mantissa)/10^LEN and adjusted
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) | such that the decimal point is to the left of bit 63.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) | The bcd digits are stored in the correct position in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) | the final string area in memory.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) | A15. Convert the exponent to bcd.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) | As in A14 above, the exp is converted to bcd and the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) | digits are stored in the final string.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) | Test the length of the final exponent string. If the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) | length is 4, set operr.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) | A16. Write sign bits to final string.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) | Implementation Notes:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) | The registers are used as follows:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) | d0: scratch; LEN input to binstr
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) | d1: scratch
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) | d2: upper 32-bits of mantissa for binstr
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) | d3: scratch;lower 32-bits of mantissa for binstr
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) | d4: LEN
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) | d5: LAMBDA/ICTR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) | d6: ILOG
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) | d7: k-factor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) | a0: ptr for original operand/final result
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) | a1: scratch pointer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) | a2: pointer to FP_X; abs(original value) in ext
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) | fp0: scratch
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) | fp1: scratch
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) | fp2: scratch
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) | F_SCR1:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) | F_SCR2:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) | L_SCR1:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) | L_SCR2:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) | Copyright (C) Motorola, Inc. 1990
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) | All Rights Reserved
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) | For details on the license for this file, please see the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) | file, README, in this same directory.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) |BINDEC idnt 2,1 | Motorola 040 Floating Point Software Package
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) #include "fpsp.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) |section 8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) | Constants in extended precision
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) LOG2: .long 0x3FFD0000,0x9A209A84,0xFBCFF798,0x00000000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) LOG2UP1: .long 0x3FFD0000,0x9A209A84,0xFBCFF799,0x00000000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) | Constants in single precision
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) FONE: .long 0x3F800000,0x00000000,0x00000000,0x00000000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) FTWO: .long 0x40000000,0x00000000,0x00000000,0x00000000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) FTEN: .long 0x41200000,0x00000000,0x00000000,0x00000000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) F4933: .long 0x459A2800,0x00000000,0x00000000,0x00000000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) RBDTBL: .byte 0,0,0,0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) .byte 3,3,2,2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) .byte 3,2,2,3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) .byte 2,3,3,2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) |xref binstr
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) |xref sintdo
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) |xref ptenrn,ptenrm,ptenrp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) .global bindec
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) .global sc_mul
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) bindec:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) moveml %d2-%d7/%a2,-(%a7)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) fmovemx %fp0-%fp2,-(%a7)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) | A1. Set RM and size ext. Set SIGMA = sign input;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) | The k-factor is saved for use in d7. Clear BINDEC_FLG for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) | separating normalized/denormalized input. If the input
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) | is a denormalized number, set the BINDEC_FLG memory word
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) | to signal denorm. If the input is unnormalized, normalize
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) | the input and test for denormalized result.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) fmovel #rm_mode,%FPCR |set RM and ext
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) movel (%a0),L_SCR2(%a6) |save exponent for sign check
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) movel %d0,%d7 |move k-factor to d7
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) clrb BINDEC_FLG(%a6) |clr norm/denorm flag
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) movew STAG(%a6),%d0 |get stag
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) andiw #0xe000,%d0 |isolate stag bits
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) beq A2_str |if zero, input is norm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) | Normalize the denorm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) un_de_norm:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) movew (%a0),%d0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) andiw #0x7fff,%d0 |strip sign of normalized exp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) movel 4(%a0),%d1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) movel 8(%a0),%d2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) norm_loop:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) subw #1,%d0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) lsll #1,%d2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) roxll #1,%d1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) tstl %d1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) bges norm_loop
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) | Test if the normalized input is denormalized
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) tstw %d0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) bgts pos_exp |if greater than zero, it is a norm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) st BINDEC_FLG(%a6) |set flag for denorm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) pos_exp:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) andiw #0x7fff,%d0 |strip sign of normalized exp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) movew %d0,(%a0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) movel %d1,4(%a0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) movel %d2,8(%a0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) | A2. Set X = abs(input).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) A2_str:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) movel (%a0),FP_SCR2(%a6) | move input to work space
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) movel 4(%a0),FP_SCR2+4(%a6) | move input to work space
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) movel 8(%a0),FP_SCR2+8(%a6) | move input to work space
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) andil #0x7fffffff,FP_SCR2(%a6) |create abs(X)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) | A3. Compute ILOG.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) | ILOG is the log base 10 of the input value. It is approx-
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) | imated by adding e + 0.f when the original value is viewed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) | as 2^^e * 1.f in extended precision. This value is stored
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) | in d6.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) | Register usage:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) | Input/Output
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) | d0: k-factor/exponent
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) | d2: x/x
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) | d3: x/x
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) | d4: x/x
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) | d5: x/x
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) | d6: x/ILOG
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) | d7: k-factor/Unchanged
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) | a0: ptr for original operand/final result
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) | a1: x/x
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) | a2: x/x
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) | fp0: x/float(ILOG)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) | fp1: x/x
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) | fp2: x/x
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) | F_SCR1:x/x
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) | F_SCR2:Abs(X)/Abs(X) with $3fff exponent
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) | L_SCR1:x/x
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) | L_SCR2:first word of X packed/Unchanged
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) tstb BINDEC_FLG(%a6) |check for denorm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) beqs A3_cont |if clr, continue with norm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) movel #-4933,%d6 |force ILOG = -4933
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) bras A4_str
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) A3_cont:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) movew FP_SCR2(%a6),%d0 |move exp to d0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) movew #0x3fff,FP_SCR2(%a6) |replace exponent with 0x3fff
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) fmovex FP_SCR2(%a6),%fp0 |now fp0 has 1.f
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) subw #0x3fff,%d0 |strip off bias
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) faddw %d0,%fp0 |add in exp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) fsubs FONE,%fp0 |subtract off 1.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) fbge pos_res |if pos, branch
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) fmulx LOG2UP1,%fp0 |if neg, mul by LOG2UP1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) fmovel %fp0,%d6 |put ILOG in d6 as a lword
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) bras A4_str |go move out ILOG
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) pos_res:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) fmulx LOG2,%fp0 |if pos, mul by LOG2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) fmovel %fp0,%d6 |put ILOG in d6 as a lword
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) | A4. Clr INEX bit.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) | The operation in A3 above may have set INEX2.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) A4_str:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) fmovel #0,%FPSR |zero all of fpsr - nothing needed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) | A5. Set ICTR = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) | ICTR is a flag used in A13. It must be set before the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) | loop entry A6. The lower word of d5 is used for ICTR.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) clrw %d5 |clear ICTR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) | A6. Calculate LEN.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) | LEN is the number of digits to be displayed. The k-factor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) | can dictate either the total number of digits, if it is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) | a positive number, or the number of digits after the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) | original decimal point which are to be included as
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) | significant. See the 68882 manual for examples.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) | If LEN is computed to be greater than 17, set OPERR in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) | USER_FPSR. LEN is stored in d4.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) | Register usage:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) | Input/Output
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) | d0: exponent/Unchanged
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) | d2: x/x/scratch
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) | d3: x/x
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) | d4: exc picture/LEN
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) | d5: ICTR/Unchanged
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) | d6: ILOG/Unchanged
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) | d7: k-factor/Unchanged
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) | a0: ptr for original operand/final result
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) | a1: x/x
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) | a2: x/x
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) | fp0: float(ILOG)/Unchanged
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) | fp1: x/x
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) | fp2: x/x
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) | F_SCR1:x/x
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) | F_SCR2:Abs(X) with $3fff exponent/Unchanged
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) | L_SCR1:x/x
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) | L_SCR2:first word of X packed/Unchanged
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) A6_str:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) tstl %d7 |branch on sign of k
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) bles k_neg |if k <= 0, LEN = ILOG + 1 - k
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) movel %d7,%d4 |if k > 0, LEN = k
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) bras len_ck |skip to LEN check
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) k_neg:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) movel %d6,%d4 |first load ILOG to d4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) subl %d7,%d4 |subtract off k
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) addql #1,%d4 |add in the 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) len_ck:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) tstl %d4 |LEN check: branch on sign of LEN
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) bles LEN_ng |if neg, set LEN = 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) cmpl #17,%d4 |test if LEN > 17
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) bles A7_str |if not, forget it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) movel #17,%d4 |set max LEN = 17
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) tstl %d7 |if negative, never set OPERR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) bles A7_str |if positive, continue
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) orl #opaop_mask,USER_FPSR(%a6) |set OPERR & AIOP in USER_FPSR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) bras A7_str |finished here
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) LEN_ng:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) moveql #1,%d4 |min LEN is 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) | A7. Calculate SCALE.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) | SCALE is equal to 10^ISCALE, where ISCALE is the number
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) | of decimal places needed to insure LEN integer digits
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) | in the output before conversion to bcd. LAMBDA is the sign
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) | of ISCALE, used in A9. Fp1 contains 10^^(abs(ISCALE)) using
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) | the rounding mode as given in the following table (see
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) | Coonen, p. 7.23 as ref.; however, the SCALE variable is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) | of opposite sign in bindec.sa from Coonen).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) | Initial USE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) | FPCR[6:5] LAMBDA SIGN(X) FPCR[6:5]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) | ----------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) | RN 00 0 0 00/0 RN
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) | RN 00 0 1 00/0 RN
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) | RN 00 1 0 00/0 RN
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) | RN 00 1 1 00/0 RN
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) | RZ 01 0 0 11/3 RP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) | RZ 01 0 1 11/3 RP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) | RZ 01 1 0 10/2 RM
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) | RZ 01 1 1 10/2 RM
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) | RM 10 0 0 11/3 RP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) | RM 10 0 1 10/2 RM
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) | RM 10 1 0 10/2 RM
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) | RM 10 1 1 11/3 RP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) | RP 11 0 0 10/2 RM
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) | RP 11 0 1 11/3 RP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) | RP 11 1 0 11/3 RP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) | RP 11 1 1 10/2 RM
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) | Register usage:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) | Input/Output
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) | d0: exponent/scratch - final is 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) | d2: x/0 or 24 for A9
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) | d3: x/scratch - offset ptr into PTENRM array
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) | d4: LEN/Unchanged
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) | d5: 0/ICTR:LAMBDA
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) | d6: ILOG/ILOG or k if ((k<=0)&(ILOG<k))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) | d7: k-factor/Unchanged
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) | a0: ptr for original operand/final result
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) | a1: x/ptr to PTENRM array
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) | a2: x/x
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) | fp0: float(ILOG)/Unchanged
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) | fp1: x/10^ISCALE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) | fp2: x/x
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) | F_SCR1:x/x
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) | F_SCR2:Abs(X) with $3fff exponent/Unchanged
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) | L_SCR1:x/x
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) | L_SCR2:first word of X packed/Unchanged
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) A7_str:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) tstl %d7 |test sign of k
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) bgts k_pos |if pos and > 0, skip this
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) cmpl %d6,%d7 |test k - ILOG
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) blts k_pos |if ILOG >= k, skip this
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) movel %d7,%d6 |if ((k<0) & (ILOG < k)) ILOG = k
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) k_pos:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) movel %d6,%d0 |calc ILOG + 1 - LEN in d0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) addql #1,%d0 |add the 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) subl %d4,%d0 |sub off LEN
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) swap %d5 |use upper word of d5 for LAMBDA
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) clrw %d5 |set it zero initially
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) clrw %d2 |set up d2 for very small case
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) tstl %d0 |test sign of ISCALE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) bges iscale |if pos, skip next inst
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) addqw #1,%d5 |if neg, set LAMBDA true
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) cmpl #0xffffecd4,%d0 |test iscale <= -4908
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) bgts no_inf |if false, skip rest
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) addil #24,%d0 |add in 24 to iscale
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) movel #24,%d2 |put 24 in d2 for A9
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) no_inf:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) negl %d0 |and take abs of ISCALE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) iscale:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) fmoves FONE,%fp1 |init fp1 to 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) bfextu USER_FPCR(%a6){#26:#2},%d1 |get initial rmode bits
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) lslw #1,%d1 |put them in bits 2:1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) addw %d5,%d1 |add in LAMBDA
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) lslw #1,%d1 |put them in bits 3:1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) tstl L_SCR2(%a6) |test sign of original x
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) bges x_pos |if pos, don't set bit 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) addql #1,%d1 |if neg, set bit 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) x_pos:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) leal RBDTBL,%a2 |load rbdtbl base
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) moveb (%a2,%d1),%d3 |load d3 with new rmode
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) lsll #4,%d3 |put bits in proper position
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) fmovel %d3,%fpcr |load bits into fpu
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) lsrl #4,%d3 |put bits in proper position
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) tstb %d3 |decode new rmode for pten table
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) bnes not_rn |if zero, it is RN
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) leal PTENRN,%a1 |load a1 with RN table base
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) bras rmode |exit decode
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) not_rn:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) lsrb #1,%d3 |get lsb in carry
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) bccs not_rp |if carry clear, it is RM
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) leal PTENRP,%a1 |load a1 with RP table base
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) bras rmode |exit decode
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) not_rp:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) leal PTENRM,%a1 |load a1 with RM table base
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) rmode:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) clrl %d3 |clr table index
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) e_loop:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) lsrl #1,%d0 |shift next bit into carry
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) bccs e_next |if zero, skip the mul
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) fmulx (%a1,%d3),%fp1 |mul by 10**(d3_bit_no)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) e_next:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) addl #12,%d3 |inc d3 to next pwrten table entry
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) tstl %d0 |test if ISCALE is zero
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) bnes e_loop |if not, loop
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) | A8. Clr INEX; Force RZ.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) | The operation in A3 above may have set INEX2.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) | RZ mode is forced for the scaling operation to insure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) | only one rounding error. The grs bits are collected in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) | the INEX flag for use in A10.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) | Register usage:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) | Input/Output
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) fmovel #0,%FPSR |clr INEX
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) fmovel #rz_mode,%FPCR |set RZ rounding mode
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) | A9. Scale X -> Y.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) | The mantissa is scaled to the desired number of significant
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) | digits. The excess digits are collected in INEX2. If mul,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) | Check d2 for excess 10 exponential value. If not zero,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) | the iscale value would have caused the pwrten calculation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) | to overflow. Only a negative iscale can cause this, so
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) | multiply by 10^(d2), which is now only allowed to be 24,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) | with a multiply by 10^8 and 10^16, which is exact since
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) | 10^24 is exact. If the input was denormalized, we must
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) | create a busy stack frame with the mul command and the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) | two operands, and allow the fpu to complete the multiply.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) | Register usage:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) | Input/Output
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) | d0: FPCR with RZ mode/Unchanged
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) | d2: 0 or 24/unchanged
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) | d3: x/x
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) | d4: LEN/Unchanged
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) | d5: ICTR:LAMBDA
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) | d6: ILOG/Unchanged
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) | d7: k-factor/Unchanged
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) | a0: ptr for original operand/final result
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) | a1: ptr to PTENRM array/Unchanged
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) | a2: x/x
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) | fp0: float(ILOG)/X adjusted for SCALE (Y)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) | fp1: 10^ISCALE/Unchanged
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) | fp2: x/x
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) | F_SCR1:x/x
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) | F_SCR2:Abs(X) with $3fff exponent/Unchanged
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) | L_SCR1:x/x
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) | L_SCR2:first word of X packed/Unchanged
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) A9_str:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) fmovex (%a0),%fp0 |load X from memory
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) fabsx %fp0 |use abs(X)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) tstw %d5 |LAMBDA is in lower word of d5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) bne sc_mul |if neg (LAMBDA = 1), scale by mul
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) fdivx %fp1,%fp0 |calculate X / SCALE -> Y to fp0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) bras A10_st |branch to A10
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) sc_mul:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) tstb BINDEC_FLG(%a6) |check for denorm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) beqs A9_norm |if norm, continue with mul
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) fmovemx %fp1-%fp1,-(%a7) |load ETEMP with 10^ISCALE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) movel 8(%a0),-(%a7) |load FPTEMP with input arg
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) movel 4(%a0),-(%a7)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) movel (%a0),-(%a7)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) movel #18,%d3 |load count for busy stack
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) A9_loop:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) clrl -(%a7) |clear lword on stack
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) dbf %d3,A9_loop
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) moveb VER_TMP(%a6),(%a7) |write current version number
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) moveb #BUSY_SIZE-4,1(%a7) |write current busy size
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) moveb #0x10,0x44(%a7) |set fcefpte[15] bit
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) movew #0x0023,0x40(%a7) |load cmdreg1b with mul command
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505) moveb #0xfe,0x8(%a7) |load all 1s to cu savepc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) frestore (%a7)+ |restore frame to fpu for completion
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) fmulx 36(%a1),%fp0 |multiply fp0 by 10^8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) fmulx 48(%a1),%fp0 |multiply fp0 by 10^16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) bras A10_st
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) A9_norm:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) tstw %d2 |test for small exp case
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) beqs A9_con |if zero, continue as normal
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) fmulx 36(%a1),%fp0 |multiply fp0 by 10^8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) fmulx 48(%a1),%fp0 |multiply fp0 by 10^16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) A9_con:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516) fmulx %fp1,%fp0 |calculate X * SCALE -> Y to fp0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519) | A10. Or in INEX.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520) | If INEX is set, round error occurred. This is compensated
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521) | for by 'or-ing' in the INEX2 flag to the lsb of Y.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523) | Register usage:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524) | Input/Output
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525) | d0: FPCR with RZ mode/FPSR with INEX2 isolated
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526) | d2: x/x
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527) | d3: x/x
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528) | d4: LEN/Unchanged
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529) | d5: ICTR:LAMBDA
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530) | d6: ILOG/Unchanged
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531) | d7: k-factor/Unchanged
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532) | a0: ptr for original operand/final result
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533) | a1: ptr to PTENxx array/Unchanged
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534) | a2: x/ptr to FP_SCR2(a6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535) | fp0: Y/Y with lsb adjusted
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536) | fp1: 10^ISCALE/Unchanged
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537) | fp2: x/x
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539) A10_st:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540) fmovel %FPSR,%d0 |get FPSR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541) fmovex %fp0,FP_SCR2(%a6) |move Y to memory
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542) leal FP_SCR2(%a6),%a2 |load a2 with ptr to FP_SCR2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543) btstl #9,%d0 |check if INEX2 set
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544) beqs A11_st |if clear, skip rest
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545) oril #1,8(%a2) |or in 1 to lsb of mantissa
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546) fmovex FP_SCR2(%a6),%fp0 |write adjusted Y back to fpu
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549) | A11. Restore original FPCR; set size ext.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 550) | Perform FINT operation in the user's rounding mode. Keep
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 551) | the size to extended. The sintdo entry point in the sint
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 552) | routine expects the FPCR value to be in USER_FPCR for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 553) | mode and precision. The original FPCR is saved in L_SCR1.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 554)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 555) A11_st:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 556) movel USER_FPCR(%a6),L_SCR1(%a6) |save it for later
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 557) andil #0x00000030,USER_FPCR(%a6) |set size to ext,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 558) | ;block exceptions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 559)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 560)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 561) | A12. Calculate YINT = FINT(Y) according to user's rounding mode.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 562) | The FPSP routine sintd0 is used. The output is in fp0.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 563) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 564) | Register usage:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 565) | Input/Output
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 566) | d0: FPSR with AINEX cleared/FPCR with size set to ext
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 567) | d2: x/x/scratch
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 568) | d3: x/x
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 569) | d4: LEN/Unchanged
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 570) | d5: ICTR:LAMBDA/Unchanged
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 571) | d6: ILOG/Unchanged
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 572) | d7: k-factor/Unchanged
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 573) | a0: ptr for original operand/src ptr for sintdo
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 574) | a1: ptr to PTENxx array/Unchanged
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 575) | a2: ptr to FP_SCR2(a6)/Unchanged
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 576) | a6: temp pointer to FP_SCR2(a6) - orig value saved and restored
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 577) | fp0: Y/YINT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 578) | fp1: 10^ISCALE/Unchanged
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 579) | fp2: x/x
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 580) | F_SCR1:x/x
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 581) | F_SCR2:Y adjusted for inex/Y with original exponent
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 582) | L_SCR1:x/original USER_FPCR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 583) | L_SCR2:first word of X packed/Unchanged
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 584)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 585) A12_st:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 586) moveml %d0-%d1/%a0-%a1,-(%a7) |save regs used by sintd0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 587) movel L_SCR1(%a6),-(%a7)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 588) movel L_SCR2(%a6),-(%a7)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 589) leal FP_SCR2(%a6),%a0 |a0 is ptr to F_SCR2(a6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 590) fmovex %fp0,(%a0) |move Y to memory at FP_SCR2(a6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 591) tstl L_SCR2(%a6) |test sign of original operand
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 592) bges do_fint |if pos, use Y
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 593) orl #0x80000000,(%a0) |if neg, use -Y
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 594) do_fint:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 595) movel USER_FPSR(%a6),-(%a7)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 596) bsr sintdo |sint routine returns int in fp0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 597) moveb (%a7),USER_FPSR(%a6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 598) addl #4,%a7
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 599) movel (%a7)+,L_SCR2(%a6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 600) movel (%a7)+,L_SCR1(%a6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 601) moveml (%a7)+,%d0-%d1/%a0-%a1 |restore regs used by sint
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 602) movel L_SCR2(%a6),FP_SCR2(%a6) |restore original exponent
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 603) movel L_SCR1(%a6),USER_FPCR(%a6) |restore user's FPCR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 604)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 605)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 606) | A13. Check for LEN digits.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 607) | If the int operation results in more than LEN digits,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 608) | or less than LEN -1 digits, adjust ILOG and repeat from
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 609) | A6. This test occurs only on the first pass. If the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 610) | result is exactly 10^LEN, decrement ILOG and divide
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 611) | the mantissa by 10. The calculation of 10^LEN cannot
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 612) | be inexact, since all powers of ten up to 10^27 are exact
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 613) | in extended precision, so the use of a previous power-of-ten
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 614) | table will introduce no error.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 615) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 616) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 617) | Register usage:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 618) | Input/Output
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 619) | d0: FPCR with size set to ext/scratch final = 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 620) | d2: x/x
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 621) | d3: x/scratch final = x
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 622) | d4: LEN/LEN adjusted
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 623) | d5: ICTR:LAMBDA/LAMBDA:ICTR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 624) | d6: ILOG/ILOG adjusted
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 625) | d7: k-factor/Unchanged
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 626) | a0: pointer into memory for packed bcd string formation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 627) | a1: ptr to PTENxx array/Unchanged
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 628) | a2: ptr to FP_SCR2(a6)/Unchanged
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 629) | fp0: int portion of Y/abs(YINT) adjusted
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 630) | fp1: 10^ISCALE/Unchanged
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 631) | fp2: x/10^LEN
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 632) | F_SCR1:x/x
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 633) | F_SCR2:Y with original exponent/Unchanged
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 634) | L_SCR1:original USER_FPCR/Unchanged
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 635) | L_SCR2:first word of X packed/Unchanged
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 636)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 637) A13_st:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 638) swap %d5 |put ICTR in lower word of d5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 639) tstw %d5 |check if ICTR = 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 640) bne not_zr |if non-zero, go to second test
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 641) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 642) | Compute 10^(LEN-1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 643) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 644) fmoves FONE,%fp2 |init fp2 to 1.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 645) movel %d4,%d0 |put LEN in d0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 646) subql #1,%d0 |d0 = LEN -1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 647) clrl %d3 |clr table index
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 648) l_loop:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 649) lsrl #1,%d0 |shift next bit into carry
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 650) bccs l_next |if zero, skip the mul
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 651) fmulx (%a1,%d3),%fp2 |mul by 10**(d3_bit_no)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 652) l_next:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 653) addl #12,%d3 |inc d3 to next pwrten table entry
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 654) tstl %d0 |test if LEN is zero
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 655) bnes l_loop |if not, loop
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 656) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 657) | 10^LEN-1 is computed for this test and A14. If the input was
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 658) | denormalized, check only the case in which YINT > 10^LEN.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 659) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 660) tstb BINDEC_FLG(%a6) |check if input was norm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 661) beqs A13_con |if norm, continue with checking
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 662) fabsx %fp0 |take abs of YINT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 663) bra test_2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 664) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 665) | Compare abs(YINT) to 10^(LEN-1) and 10^LEN
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 666) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 667) A13_con:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 668) fabsx %fp0 |take abs of YINT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 669) fcmpx %fp2,%fp0 |compare abs(YINT) with 10^(LEN-1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 670) fbge test_2 |if greater, do next test
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 671) subql #1,%d6 |subtract 1 from ILOG
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 672) movew #1,%d5 |set ICTR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 673) fmovel #rm_mode,%FPCR |set rmode to RM
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 674) fmuls FTEN,%fp2 |compute 10^LEN
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 675) bra A6_str |return to A6 and recompute YINT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 676) test_2:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 677) fmuls FTEN,%fp2 |compute 10^LEN
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 678) fcmpx %fp2,%fp0 |compare abs(YINT) with 10^LEN
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 679) fblt A14_st |if less, all is ok, go to A14
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 680) fbgt fix_ex |if greater, fix and redo
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 681) fdivs FTEN,%fp0 |if equal, divide by 10
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 682) addql #1,%d6 | and inc ILOG
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 683) bras A14_st | and continue elsewhere
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 684) fix_ex:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 685) addql #1,%d6 |increment ILOG by 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 686) movew #1,%d5 |set ICTR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 687) fmovel #rm_mode,%FPCR |set rmode to RM
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 688) bra A6_str |return to A6 and recompute YINT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 689) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 690) | Since ICTR <> 0, we have already been through one adjustment,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 691) | and shouldn't have another; this is to check if abs(YINT) = 10^LEN
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 692) | 10^LEN is again computed using whatever table is in a1 since the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 693) | value calculated cannot be inexact.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 694) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 695) not_zr:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 696) fmoves FONE,%fp2 |init fp2 to 1.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 697) movel %d4,%d0 |put LEN in d0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 698) clrl %d3 |clr table index
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 699) z_loop:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 700) lsrl #1,%d0 |shift next bit into carry
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 701) bccs z_next |if zero, skip the mul
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 702) fmulx (%a1,%d3),%fp2 |mul by 10**(d3_bit_no)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 703) z_next:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 704) addl #12,%d3 |inc d3 to next pwrten table entry
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 705) tstl %d0 |test if LEN is zero
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 706) bnes z_loop |if not, loop
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 707) fabsx %fp0 |get abs(YINT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 708) fcmpx %fp2,%fp0 |check if abs(YINT) = 10^LEN
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 709) fbne A14_st |if not, skip this
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 710) fdivs FTEN,%fp0 |divide abs(YINT) by 10
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 711) addql #1,%d6 |and inc ILOG by 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 712) addql #1,%d4 | and inc LEN
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 713) fmuls FTEN,%fp2 | if LEN++, the get 10^^LEN
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 714)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 715)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 716) | A14. Convert the mantissa to bcd.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 717) | The binstr routine is used to convert the LEN digit
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 718) | mantissa to bcd in memory. The input to binstr is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 719) | to be a fraction; i.e. (mantissa)/10^LEN and adjusted
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 720) | such that the decimal point is to the left of bit 63.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 721) | The bcd digits are stored in the correct position in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 722) | the final string area in memory.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 723) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 724) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 725) | Register usage:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 726) | Input/Output
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 727) | d0: x/LEN call to binstr - final is 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 728) | d1: x/0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 729) | d2: x/ms 32-bits of mant of abs(YINT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 730) | d3: x/ls 32-bits of mant of abs(YINT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 731) | d4: LEN/Unchanged
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 732) | d5: ICTR:LAMBDA/LAMBDA:ICTR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 733) | d6: ILOG
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 734) | d7: k-factor/Unchanged
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 735) | a0: pointer into memory for packed bcd string formation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 736) | /ptr to first mantissa byte in result string
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 737) | a1: ptr to PTENxx array/Unchanged
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 738) | a2: ptr to FP_SCR2(a6)/Unchanged
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 739) | fp0: int portion of Y/abs(YINT) adjusted
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 740) | fp1: 10^ISCALE/Unchanged
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 741) | fp2: 10^LEN/Unchanged
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 742) | F_SCR1:x/Work area for final result
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 743) | F_SCR2:Y with original exponent/Unchanged
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 744) | L_SCR1:original USER_FPCR/Unchanged
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 745) | L_SCR2:first word of X packed/Unchanged
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 746)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 747) A14_st:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 748) fmovel #rz_mode,%FPCR |force rz for conversion
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 749) fdivx %fp2,%fp0 |divide abs(YINT) by 10^LEN
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 750) leal FP_SCR1(%a6),%a0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 751) fmovex %fp0,(%a0) |move abs(YINT)/10^LEN to memory
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 752) movel 4(%a0),%d2 |move 2nd word of FP_RES to d2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 753) movel 8(%a0),%d3 |move 3rd word of FP_RES to d3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 754) clrl 4(%a0) |zero word 2 of FP_RES
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 755) clrl 8(%a0) |zero word 3 of FP_RES
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 756) movel (%a0),%d0 |move exponent to d0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 757) swap %d0 |put exponent in lower word
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 758) beqs no_sft |if zero, don't shift
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 759) subil #0x3ffd,%d0 |sub bias less 2 to make fract
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 760) tstl %d0 |check if > 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 761) bgts no_sft |if so, don't shift
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 762) negl %d0 |make exp positive
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 763) m_loop:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 764) lsrl #1,%d2 |shift d2:d3 right, add 0s
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 765) roxrl #1,%d3 |the number of places
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 766) dbf %d0,m_loop |given in d0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 767) no_sft:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 768) tstl %d2 |check for mantissa of zero
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 769) bnes no_zr |if not, go on
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 770) tstl %d3 |continue zero check
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 771) beqs zer_m |if zero, go directly to binstr
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 772) no_zr:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 773) clrl %d1 |put zero in d1 for addx
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 774) addil #0x00000080,%d3 |inc at bit 7
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 775) addxl %d1,%d2 |continue inc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 776) andil #0xffffff80,%d3 |strip off lsb not used by 882
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 777) zer_m:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 778) movel %d4,%d0 |put LEN in d0 for binstr call
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 779) addql #3,%a0 |a0 points to M16 byte in result
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 780) bsr binstr |call binstr to convert mant
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 781)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 782)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 783) | A15. Convert the exponent to bcd.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 784) | As in A14 above, the exp is converted to bcd and the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 785) | digits are stored in the final string.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 786) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 787) | Digits are stored in L_SCR1(a6) on return from BINDEC as:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 788) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 789) | 32 16 15 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 790) | -----------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 791) | | 0 | e3 | e2 | e1 | e4 | X | X | X |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 792) | -----------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 793) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 794) | And are moved into their proper places in FP_SCR1. If digit e4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 795) | is non-zero, OPERR is signaled. In all cases, all 4 digits are
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 796) | written as specified in the 881/882 manual for packed decimal.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 797) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 798) | Register usage:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 799) | Input/Output
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 800) | d0: x/LEN call to binstr - final is 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 801) | d1: x/scratch (0);shift count for final exponent packing
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 802) | d2: x/ms 32-bits of exp fraction/scratch
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 803) | d3: x/ls 32-bits of exp fraction
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 804) | d4: LEN/Unchanged
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 805) | d5: ICTR:LAMBDA/LAMBDA:ICTR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 806) | d6: ILOG
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 807) | d7: k-factor/Unchanged
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 808) | a0: ptr to result string/ptr to L_SCR1(a6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 809) | a1: ptr to PTENxx array/Unchanged
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 810) | a2: ptr to FP_SCR2(a6)/Unchanged
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 811) | fp0: abs(YINT) adjusted/float(ILOG)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 812) | fp1: 10^ISCALE/Unchanged
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 813) | fp2: 10^LEN/Unchanged
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 814) | F_SCR1:Work area for final result/BCD result
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 815) | F_SCR2:Y with original exponent/ILOG/10^4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 816) | L_SCR1:original USER_FPCR/Exponent digits on return from binstr
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 817) | L_SCR2:first word of X packed/Unchanged
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 818)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 819) A15_st:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 820) tstb BINDEC_FLG(%a6) |check for denorm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 821) beqs not_denorm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 822) ftstx %fp0 |test for zero
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 823) fbeq den_zero |if zero, use k-factor or 4933
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 824) fmovel %d6,%fp0 |float ILOG
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 825) fabsx %fp0 |get abs of ILOG
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 826) bras convrt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 827) den_zero:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 828) tstl %d7 |check sign of the k-factor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 829) blts use_ilog |if negative, use ILOG
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 830) fmoves F4933,%fp0 |force exponent to 4933
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 831) bras convrt |do it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 832) use_ilog:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 833) fmovel %d6,%fp0 |float ILOG
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 834) fabsx %fp0 |get abs of ILOG
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 835) bras convrt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 836) not_denorm:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 837) ftstx %fp0 |test for zero
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 838) fbne not_zero |if zero, force exponent
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 839) fmoves FONE,%fp0 |force exponent to 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 840) bras convrt |do it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 841) not_zero:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 842) fmovel %d6,%fp0 |float ILOG
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 843) fabsx %fp0 |get abs of ILOG
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 844) convrt:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 845) fdivx 24(%a1),%fp0 |compute ILOG/10^4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 846) fmovex %fp0,FP_SCR2(%a6) |store fp0 in memory
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 847) movel 4(%a2),%d2 |move word 2 to d2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 848) movel 8(%a2),%d3 |move word 3 to d3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 849) movew (%a2),%d0 |move exp to d0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 850) beqs x_loop_fin |if zero, skip the shift
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 851) subiw #0x3ffd,%d0 |subtract off bias
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 852) negw %d0 |make exp positive
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 853) x_loop:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 854) lsrl #1,%d2 |shift d2:d3 right
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 855) roxrl #1,%d3 |the number of places
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 856) dbf %d0,x_loop |given in d0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 857) x_loop_fin:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 858) clrl %d1 |put zero in d1 for addx
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 859) addil #0x00000080,%d3 |inc at bit 6
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 860) addxl %d1,%d2 |continue inc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 861) andil #0xffffff80,%d3 |strip off lsb not used by 882
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 862) movel #4,%d0 |put 4 in d0 for binstr call
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 863) leal L_SCR1(%a6),%a0 |a0 is ptr to L_SCR1 for exp digits
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 864) bsr binstr |call binstr to convert exp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 865) movel L_SCR1(%a6),%d0 |load L_SCR1 lword to d0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 866) movel #12,%d1 |use d1 for shift count
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 867) lsrl %d1,%d0 |shift d0 right by 12
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 868) bfins %d0,FP_SCR1(%a6){#4:#12} |put e3:e2:e1 in FP_SCR1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 869) lsrl %d1,%d0 |shift d0 right by 12
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 870) bfins %d0,FP_SCR1(%a6){#16:#4} |put e4 in FP_SCR1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 871) tstb %d0 |check if e4 is zero
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 872) beqs A16_st |if zero, skip rest
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 873) orl #opaop_mask,USER_FPSR(%a6) |set OPERR & AIOP in USER_FPSR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 874)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 875)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 876) | A16. Write sign bits to final string.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 877) | Sigma is bit 31 of initial value; RHO is bit 31 of d6 (ILOG).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 878) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 879) | Register usage:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 880) | Input/Output
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 881) | d0: x/scratch - final is x
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 882) | d2: x/x
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 883) | d3: x/x
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 884) | d4: LEN/Unchanged
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 885) | d5: ICTR:LAMBDA/LAMBDA:ICTR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 886) | d6: ILOG/ILOG adjusted
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 887) | d7: k-factor/Unchanged
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 888) | a0: ptr to L_SCR1(a6)/Unchanged
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 889) | a1: ptr to PTENxx array/Unchanged
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 890) | a2: ptr to FP_SCR2(a6)/Unchanged
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 891) | fp0: float(ILOG)/Unchanged
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 892) | fp1: 10^ISCALE/Unchanged
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 893) | fp2: 10^LEN/Unchanged
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 894) | F_SCR1:BCD result with correct signs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 895) | F_SCR2:ILOG/10^4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 896) | L_SCR1:Exponent digits on return from binstr
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 897) | L_SCR2:first word of X packed/Unchanged
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 898)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 899) A16_st:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 900) clrl %d0 |clr d0 for collection of signs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 901) andib #0x0f,FP_SCR1(%a6) |clear first nibble of FP_SCR1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 902) tstl L_SCR2(%a6) |check sign of original mantissa
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 903) bges mant_p |if pos, don't set SM
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 904) moveql #2,%d0 |move 2 in to d0 for SM
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 905) mant_p:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 906) tstl %d6 |check sign of ILOG
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 907) bges wr_sgn |if pos, don't set SE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 908) addql #1,%d0 |set bit 0 in d0 for SE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 909) wr_sgn:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 910) bfins %d0,FP_SCR1(%a6){#0:#2} |insert SM and SE into FP_SCR1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 911)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 912) | Clean up and restore all registers used.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 913)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 914) fmovel #0,%FPSR |clear possible inex2/ainex bits
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 915) fmovemx (%a7)+,%fp0-%fp2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 916) moveml (%a7)+,%d2-%d7/%a2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 917) rts
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 918)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 919) |end