source: rtems/c/src/lib/libcpu/m68k/m68040/fpsp/slog2.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: 5.2 KB
Line 
1//
2//
3//      slog2.sa 3.1 12/10/90
4//
5//       The entry point slog10 computes the base-10
6//      logarithm of an input argument X.
7//      slog10d does the same except the input value is a
8//      denormalized number.
9//      sLog2 and sLog2d are the base-2 analogues.
10//
11//       INPUT: Double-extended value in memory location pointed to
12//              by address register a0.
13//
14//       OUTPUT: log_10(X) or log_2(X) returned in floating-point
15//              register fp0.
16//
17//       ACCURACY and MONOTONICITY: The returned result is within 1.7
18//              ulps in 64 significant bit, i.e. within 0.5003 ulp
19//              to 53 bits if the result is subsequently rounded
20//              to double precision. The result is provably monotonic
21//              in double precision.
22//
23//       SPEED: Two timings are measured, both in the copy-back mode.
24//              The first one is measured when the function is invoked
25//              the first time (so the instructions and data are not
26//              in cache), and the second one is measured when the
27//              function is reinvoked at the same input argument.
28//
29//       ALGORITHM and IMPLEMENTATION NOTES:
30//
31//       slog10d:
32//
33//       Step 0.   If X < 0, create a NaN and raise the invalid operation
34//                 flag. Otherwise, save FPCR in D1; set FpCR to default.
35//       Notes:    Default means round-to-nearest mode, no floating-point
36//                 traps, and precision control = double extended.
37//
38//       Step 1.   Call slognd to obtain Y = log(X), the natural log of X.
39//       Notes:    Even if X is denormalized, log(X) is always normalized.
40//
41//       Step 2.   Compute log_10(X) = log(X) * (1/log(10)).
42//            2.1  Restore the user FPCR
43//            2.2  Return ans := Y * INV_L10.
44//
45//
46//       slog10:
47//
48//       Step 0.   If X < 0, create a NaN and raise the invalid operation
49//                 flag. Otherwise, save FPCR in D1; set FpCR to default.
50//       Notes:    Default means round-to-nearest mode, no floating-point
51//                 traps, and precision control = double extended.
52//
53//       Step 1.   Call sLogN to obtain Y = log(X), the natural log of X.
54//
55//       Step 2.   Compute log_10(X) = log(X) * (1/log(10)).
56//            2.1  Restore the user FPCR
57//            2.2  Return ans := Y * INV_L10.
58//
59//
60//       sLog2d:
61//
62//       Step 0.   If X < 0, create a NaN and raise the invalid operation
63//                 flag. Otherwise, save FPCR in D1; set FpCR to default.
64//       Notes:    Default means round-to-nearest mode, no floating-point
65//                 traps, and precision control = double extended.
66//
67//       Step 1.   Call slognd to obtain Y = log(X), the natural log of X.
68//       Notes:    Even if X is denormalized, log(X) is always normalized.
69//
70//       Step 2.   Compute log_10(X) = log(X) * (1/log(2)).
71//            2.1  Restore the user FPCR
72//            2.2  Return ans := Y * INV_L2.
73//
74//
75//       sLog2:
76//
77//       Step 0.   If X < 0, create a NaN and raise the invalid operation
78//                 flag. Otherwise, save FPCR in D1; set FpCR to default.
79//       Notes:    Default means round-to-nearest mode, no floating-point
80//                 traps, and precision control = double extended.
81//
82//       Step 1.   If X is not an integer power of two, i.e., X != 2^k,
83//                 go to Step 3.
84//
85//       Step 2.   Return k.
86//            2.1  Get integer k, X = 2^k.
87//            2.2  Restore the user FPCR.
88//            2.3  Return ans := convert-to-double-extended(k).
89//
90//       Step 3.   Call sLogN to obtain Y = log(X), the natural log of X.
91//
92//       Step 4.   Compute log_2(X) = log(X) * (1/log(2)).
93//            4.1  Restore the user FPCR
94//            4.2  Return ans := Y * INV_L2.
95//
96
97//              Copyright (C) Motorola, Inc. 1990
98//                      All Rights Reserved
99//
100//      THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF MOTOROLA
101//      The copyright notice above does not evidence any
102//      actual or intended publication of such source code.
103
104//SLOG2    idnt    2,1 | Motorola 040 Floating Point Software Package
105
106        |section        8
107
108        |xref   t_frcinx
109        |xref   t_operr
110        |xref   slogn
111        |xref   slognd
112
113INV_L10:  .long 0x3FFD0000,0xDE5BD8A9,0x37287195,0x00000000
114
115INV_L2:   .long 0x3FFF0000,0xB8AA3B29,0x5C17F0BC,0x00000000
116
117        .global slog10d
118slog10d:
119//--entry point for Log10(X), X is denormalized
120        movel           (%a0),%d0
121        blt             invalid
122        movel           %d1,-(%sp)
123        clrl            %d1
124        bsr             slognd                  // ...log(X), X denorm.
125        fmovel          (%sp)+,%fpcr
126        fmulx           INV_L10,%fp0
127        bra             t_frcinx
128
129        .global slog10
130slog10:
131//--entry point for Log10(X), X is normalized
132
133        movel           (%a0),%d0
134        blt             invalid
135        movel           %d1,-(%sp)
136        clrl            %d1
137        bsr             slogn                   // ...log(X), X normal.
138        fmovel          (%sp)+,%fpcr
139        fmulx           INV_L10,%fp0
140        bra             t_frcinx
141
142
143        .global slog2d
144slog2d:
145//--entry point for Log2(X), X is denormalized
146
147        movel           (%a0),%d0
148        blt             invalid
149        movel           %d1,-(%sp)
150        clrl            %d1
151        bsr             slognd                  // ...log(X), X denorm.
152        fmovel          (%sp)+,%fpcr
153        fmulx           INV_L2,%fp0
154        bra             t_frcinx
155
156        .global slog2
157slog2:
158//--entry point for Log2(X), X is normalized
159        movel           (%a0),%d0
160        blt             invalid
161
162        movel           8(%a0),%d0
163        bnes            continue                // ...X is not 2^k
164
165        movel           4(%a0),%d0
166        andl            #0x7FFFFFFF,%d0
167        tstl            %d0
168        bnes            continue
169
170//--X = 2^k.
171        movew           (%a0),%d0
172        andl            #0x00007FFF,%d0
173        subl            #0x3FFF,%d0
174        fmovel          %d1,%fpcr
175        fmovel          %d0,%fp0
176        bra             t_frcinx
177
178continue:
179        movel           %d1,-(%sp)
180        clrl            %d1
181        bsr             slogn                   // ...log(X), X normal.
182        fmovel          (%sp)+,%fpcr
183        fmulx           INV_L2,%fp0
184        bra             t_frcinx
185
186invalid:
187        bra             t_operr
188
189        |end
Note: See TracBrowser for help on using the repository browser.