^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) | sgetem.sa 3.1 12/10/90
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) | The entry point sGETEXP returns the exponent portion
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) | of the input argument. The exponent bias is removed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) | and the exponent value is returned as an extended
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) | precision number in fp0. sGETEXPD handles denormalized
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) | numbers.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) | The entry point sGETMAN extracts the mantissa of the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) | input argument. The mantissa is converted to an
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) | extended precision number and returned in fp0. The
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) | range of the result is [1.0 - 2.0).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) | Input: Double-extended number X in the ETEMP space in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) | the floating-point save stack.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) | Output: The functions return exp(X) or man(X) in fp0.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) | Modified: fp0.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) | Copyright (C) Motorola, Inc. 1990
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) | All Rights Reserved
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) | For details on the license for this file, please see the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) | file, README, in this same directory.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) |SGETEM idnt 2,1 | Motorola 040 Floating Point Software Package
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) |section 8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) #include "fpsp.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) |xref nrm_set
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) | This entry point is used by the unimplemented instruction exception
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) | handler. It points a0 to the input operand.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) | SGETEXP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) .global sgetexp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) sgetexp:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) movew LOCAL_EX(%a0),%d0 |get the exponent
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) bclrl #15,%d0 |clear the sign bit
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) subw #0x3fff,%d0 |subtract off the bias
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) fmovew %d0,%fp0 |move the exp to fp0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) rts
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) .global sgetexpd
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) sgetexpd:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) bclrb #sign_bit,LOCAL_EX(%a0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) bsr nrm_set |normalize (exp will go negative)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) movew LOCAL_EX(%a0),%d0 |load resulting exponent into d0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) subw #0x3fff,%d0 |subtract off the bias
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) fmovew %d0,%fp0 |move the exp to fp0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) rts
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) | This entry point is used by the unimplemented instruction exception
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) | handler. It points a0 to the input operand.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) | SGETMAN
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) | For normalized numbers, leave the mantissa alone, simply load
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) | with an exponent of +/- $3fff.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) .global sgetman
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) sgetman:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) movel USER_FPCR(%a6),%d0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) andil #0xffffff00,%d0 |clear rounding precision and mode
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) fmovel %d0,%fpcr |this fpcr setting is used by the 882
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) movew LOCAL_EX(%a0),%d0 |get the exp (really just want sign bit)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) orw #0x7fff,%d0 |clear old exp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) bclrl #14,%d0 |make it the new exp +-3fff
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) movew %d0,LOCAL_EX(%a0) |move the sign & exp back to fsave stack
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) fmovex (%a0),%fp0 |put new value back in fp0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) rts
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) | For denormalized numbers, shift the mantissa until the j-bit = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) | then load the exponent with +/1 $3fff.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) .global sgetmand
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) sgetmand:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) movel LOCAL_HI(%a0),%d0 |load ms mant in d0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) movel LOCAL_LO(%a0),%d1 |load ls mant in d1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) bsr shft |shift mantissa bits till msbit is set
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) movel %d0,LOCAL_HI(%a0) |put ms mant back on stack
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) movel %d1,LOCAL_LO(%a0) |put ls mant back on stack
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) bras sgetman
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) | SHFT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) | Shifts the mantissa bits until msbit is set.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) | input:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) | ms mantissa part in d0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) | ls mantissa part in d1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) | output:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) | shifted bits in d0 and d1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) shft:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) tstl %d0 |if any bits set in ms mant
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) bnes upper |then branch
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) | ;else no bits set in ms mant
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) tstl %d1 |test if any bits set in ls mant
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) bnes cont |if set then continue
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) bras shft_end |else return
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) cont:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) movel %d3,-(%a7) |save d3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) exg %d0,%d1 |shift ls mant to ms mant
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) bfffo %d0{#0:#32},%d3 |find first 1 in ls mant to d0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) lsll %d3,%d0 |shift first 1 to integer bit in ms mant
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) movel (%a7)+,%d3 |restore d3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) bras shft_end
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) upper:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) moveml %d3/%d5/%d6,-(%a7) |save registers
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) bfffo %d0{#0:#32},%d3 |find first 1 in ls mant to d0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) lsll %d3,%d0 |shift ms mant until j-bit is set
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) movel %d1,%d6 |save ls mant in d6
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) lsll %d3,%d1 |shift ls mant by count
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) movel #32,%d5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) subl %d3,%d5 |sub 32 from shift for ls mant
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) lsrl %d5,%d6 |shift off all bits but those that will
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) | ;be shifted into ms mant
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) orl %d6,%d0 |shift the ls mant bits into the ms mant
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) moveml (%a7)+,%d3/%d5/%d6 |restore registers
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) shft_end:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) rts
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) |end