source: rtems/c/src/lib/libcpu/m68k/m68040/fpsp/sgetem.s @ 6f9c75c3

4.104.114.84.95
Last change on this file since 6f9c75c3 was 6f9c75c3, checked in by Joel Sherrill <joel.sherrill@…>, on 01/16/98 at 16:56:48

Ralf Corsepius reported a number of missing CVS Id's:

RTEMS is under CVS control and has been since rtems 3.1.16 which was
around May 1995. So I just to add the $Id$. If you notice other files
with missing $Id$'s let me know. I try to keep w\up with it.

Now that you have asked -- I'll attach a list of files lacking an RCS-Id to
this mail. This list has been generated by a little sh-script I'll also
enclose.

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