1 .file "libm_frexp_4f.s"
3 // Copyright (c) 2000, 2001, Intel Corporation
4 // All rights reserved.
6 // Contributed 2/2/2000 by John Harrison, Ted Kubaska, Bob Norin, Shane Story,
7 // and Ping Tak Peter Tang of the Computational Software Lab, Intel Corporation.
11 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
12 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
13 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
14 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR ITS
15 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
16 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
17 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
18 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
19 // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY OR TORT (INCLUDING
20 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
21 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 // Intel Corporation is the author of this code, and requests that all
24 // problem reports or change requests be submitted to it directly at
25 // http://developer.intel.com/opensource.
28 //==============================================================
29 // 2/02/00: Initial version
30 // 3/20/00: Improved speed
31 // 6/01/00: Fixed bug when x a double-extended denormal
32 // 12/08/00 Corrected label on .endp
35 //==============================================================
36 // float frexp(float x, int* y)
37 // float __libm_frexp_4f(float x, int* y)
38 // where int* y is a 32-bit integer
40 // Overview of operation
41 //==============================================================
42 // break a floating point x number into fraction and an exponent
43 // The fraction is returned as a float
44 // The exponent is returned as an integer pointed to by y
45 // This is a true (not a biased exponent) but 0fffe is subtracted
46 // as a bias instead of 0xffff. This is because the fraction returned
47 // is between 0.5 and 1.0, not the expected IEEE range.
49 // The fraction is 0.5 <= fraction < 1.0
52 //==============================================================
55 // r14 exponent bias for x negative
56 // r15 exponent bias for x positive
60 // r19 exponent result
61 // r20 signexp of 2^64
62 // r32 on input contains the 32-bit IEEE float that is in f8
63 // r33 on input pointer to 32-bit integer for exponent
65 // predicate registers:
66 // p6 set if x is Nan, zero, or infinity
67 // p7 set if x negative
68 // p8 set if x positive
69 // p9 set if x double-extended denormal
71 // floating-point registers:
74 // f10 signexp for significand result for x positive
75 // f11 signexp for significand result for x negative
78 #include "libm_support.h"
81 .global __libm_frexp_4f#
84 .proc __libm_frexp_4f#
89 // Set signexp for significand result for x>0
90 // If x is a NaN, zero, or infinity, return it.
91 // Put 0 in the int pointer.
92 // x NAN, ZERO, INFINITY?
93 // Set signexp for significand result for x<0
95 (p0) mov r15 = 0x0fffe
96 (p0) fclass.m.unc p6,p0 = f8, 0xe7
97 (p0) mov r14 = 0x2fffe
99 // Form signexp of 2^64 in case x double-extended denormal
100 // Save the normalized value of input in f9
101 // The normalization also sets fault flags and takes faults if necessary
103 (p0) mov r20 = 0x1003f
108 // Move signexp for significand result for x>0 to FP reg
109 // Form 2^64 in case x double-extended denormal
111 (p0) setf.exp f10 = r15
112 (p0) setf.exp f12 = r20
116 // Move signexp for significand result for x<0 to FP reg
117 // If x NAN, ZERO, INFINITY, set *y=0 as a 32-bit integer, and exit
119 (p0) setf.exp f11 = r14
121 (p6) br.ret.spnt b0 ;;
124 // Form exponent mask
125 // p7 if x<0, else p8
127 (p0) mov r17 = 0x1ffff
128 (p0) fcmp.lt.unc p7,p8 = f8,f0
132 // Test for fnorm(x) denormal, means x double-extended denormal
135 (p0) fclass.m.unc p9,p0 = f9, 0x0b
139 // If x double-extended denormal add 64 to exponent bias for scaling
140 // If x double-extended denormal multiply x * 2^64 which is normal
142 (p9) add r15 = 64, r15
143 (p9) fmpy f9 = f9, f12
147 // true exponent stored to int pointer
148 // the bias is treated as 0xfffe instead of
149 // normal 0xffff because we want the significand
150 // to be in the range <=0.5 sig < 1.0
151 // Store the value of the exponent at the pointer in r33
153 // If x>0 form significand result
156 (p8) fmerge.se f8 = f10,f9
160 // Get signexp of normalized x
161 // If x<0 form significand result
163 (p0) getf.exp r16 = f9
164 (p7) fmerge.se f8 = f11,f9
168 // Get exp of normalized x
169 // Subtract off bias to get true exponent of x
171 (p0) and r18 = r17,r16 ;;
172 (p0) sub r19 = r18,r15
176 // Store int y as a 32-bit integer
177 // Make the value a float
181 (p0) br.ret.sptk b0 ;;
184 .endp __libm_frexp_4f
185 ASM_SIZE_DIRECTIVE(__libm_frexp_4f)