1 .file "libm_frexp_4l.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 // 3/20/00: Initial version
30 // 6/01/00: Fixed bug when x a double-extended denormal
31 // 12/08/00 Corrected label on .endp
34 //==============================================================
35 // long double frexpl(long double x, int* y)
36 // long double __libm_frexp_4l(long double x, int* y)
37 // where int* y is a 32-bit integer
39 // Overview of operation
40 //==============================================================
41 // break a floating point x number into fraction and an exponent
42 // The fraction is returned as a long double
43 // The exponent is returned as an integer pointed to by y
44 // This is a true (not a biased exponent) but 0fffe is subtracted
45 // as a bias instead of 0xffff. This is because the fraction returned
46 // is between 0.5 and 1.0, not the expected IEEE range.
48 // The fraction is 0.5 <= fraction < 1.0
51 //==============================================================
54 // r14 exponent bias for x negative
55 // r15 exponent bias for x positive
59 // r19 exponent result
60 // r20 signexp of 2^64
61 // r32-33 on input contains the 80-bit IEEE long double that is in f8
62 // r34 on input pointer to 32-bit integer for exponent
64 // predicate registers:
65 // p6 set if x is Nan, zero, or infinity
66 // p7 set if x negative
67 // p8 set if x positive
68 // p9 set if x double-extended denormal
70 // floating-point registers:
73 // f10 signexp for significand result for x positive
74 // f11 signexp for significand result for x negative
77 #include "libm_support.h"
80 .global __libm_frexp_4l#
83 .proc __libm_frexp_4l#
88 // Set signexp for significand result for x>0
89 // If x is a NaN, zero, or infinity, return it.
90 // Put 0 in the int pointer.
91 // x NAN, ZERO, INFINITY?
92 // Set signexp for significand result for x<0
94 (p0) mov r15 = 0x0fffe
95 (p0) fclass.m.unc p6,p0 = f8, 0xe7
96 (p0) mov r14 = 0x2fffe
98 // Form signexp of 2^64 in case x double-extended denormal
99 // Save the normalized value of input in f9
100 // The normalization also sets fault flags and takes faults if necessary
102 (p0) mov r20 = 0x1003f
107 // Move signexp for significand result for x>0 to FP reg
108 // Form 2^64 in case x double-extended denormal
110 (p0) setf.exp f10 = r15
111 (p0) setf.exp f12 = r20
115 // Move signexp for significand result for x<0 to FP reg
116 // If x NAN, ZERO, INFINITY, set *y=0 as a 32-bit integer, and exit
118 (p0) setf.exp f11 = r14
120 (p6) br.ret.spnt b0 ;;
123 // Form exponent mask
124 // p7 if x<0, else p8
126 (p0) mov r17 = 0x1ffff
127 (p0) fcmp.lt.unc p7,p8 = f8,f0
131 // Test for fnorm(x) denormal, means x double-extended denormal
134 (p0) fclass.m.unc p9,p0 = f9, 0x0b
138 // If x double-extended denormal add 64 to exponent bias for scaling
139 // If x double-extended denormal multiply x * 2^64 which is normal
141 (p9) add r15 = 64, r15
142 (p9) fmpy f9 = f9, f12
146 // true exponent stored to int pointer
147 // the bias is treated as 0xfffe instead of
148 // normal 0xffff because we want the significand
149 // to be in the range <=0.5 sig < 1.0
150 // Store the value of the exponent at the pointer in r34
152 // If x>0 form significand result
155 (p8) fmerge.se f8 = f10,f9
159 // Get signexp of normalized x
160 // If x<0 form significand result
162 (p0) getf.exp r16 = f9
163 (p7) fmerge.se f8 = f11,f9
167 // Get exp of normalized x
168 // Subtract off bias to get true exponent of x
170 (p0) and r18 = r17,r16 ;;
171 (p0) sub r19 = r18,r15
175 // Store int y as a 32-bit integer
176 // Make the value a long double
180 (p0) br.ret.sptk b0 ;;
183 .endp __libm_frexp_4l
184 ASM_SIZE_DIRECTIVE(__libm_frexp_4l)