source: rtems/c/src/lib/libcpu/m68k/m68040/fpsp/sgetem.S @ 9b4422a2

4.115
Last change on this file since 9b4422a2 was 9b4422a2, checked in by Joel Sherrill <joel.sherrill@…>, on 05/03/12 at 15:09:24

Remove All CVS Id Strings Possible Using a Script

Script does what is expected and tries to do it as
smartly as possible.

+ remove occurrences of two blank comment lines

next to each other after Id string line removed.

+ remove entire comment blocks which only exited to

contain CVS Ids

+ If the processing left a blank line at the top of

a file, it was removed.

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