OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [trunk/] [rtos/] [rtems/] [c/] [src/] [lib/] [libcpu/] [m68k/] [m68040/] [fpsp/] [slog2.S] - Blame information for rev 173

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.