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