Update copyright dates with scripts/update-copyrights.
[glibc.git] / sysdeps / i386 / fpu / e_scalbf.S
blobb6dd02122a8673af591bd9b225d9bca83fbb5b95
1 /*
2  * Written by J.T. Conklin <jtc@netbsd.org>.
3  * Public domain.
4  * Adapted for float type by Ulrich Drepper <drepper@cygnus.com>.
5  *
6  * Correct handling of y==-inf <drepper@gnu>
7  */
9 #include <machine/asm.h>
11         .section .rodata
13         .align ALIGNARG(4)
14         .type zero_nan,@object
15 zero_nan:
16         .double 0.0
17 nan:    .byte 0, 0, 0, 0, 0, 0, 0xff, 0x7f
18         .byte 0, 0, 0, 0, 0, 0, 0, 0x80
19         .byte 0, 0, 0, 0, 0, 0, 0xff, 0x7f
20         ASM_SIZE_DIRECTIVE(zero_nan)
23 #ifdef PIC
24 # define MO(op) op##@GOTOFF(%ecx)
25 # define MOX(op,x,f) op##@GOTOFF(%ecx,x,f)
26 #else
27 # define MO(op) op
28 # define MOX(op,x,f) op(,x,f)
29 #endif
32         .text
33 ENTRY(__ieee754_scalbf)
34         flds    8(%esp)
35         fxam
36         fnstsw
37         flds    4(%esp)
38         andl    $0x4700, %eax
39         cmpl    $0x0700, %eax
40         je      1f
41         andl    $0x4500, %eax
42         cmpl    $0x0100, %eax
43         je      2f
44         fxam
45         fnstsw
46         andl    $0x4500, %eax
47         cmpl    $0x0100, %eax
48         je      3f
49         fld     %st(1)
50         frndint
51         fcomp   %st(2)
52         fnstsw
53         sahf
54         jne     4f
55         fscale
56         fstp    %st(1)
57         ret
59         /* y is -inf */
60 1:      fxam
61 #ifdef  PIC
62         LOAD_PIC_REG (cx)
63 #endif
64         fnstsw
65         movl    4(%esp), %edx
66         shrl    $5, %eax
67         fstp    %st
68         fstp    %st
69         andl    $0x80000000, %edx
70         andl    $8, %eax
71         jnz     4f
72         shrl    $27, %edx
73         addl    %edx, %eax
74         fldl    MOX(zero_nan, %eax, 1)
75         ret
77         /* The result is NaN, but we must not raise an exception.
78            So use a variable.  */
79 2:      fstp    %st
80         fstp    %st
81 #ifdef  PIC
82         LOAD_PIC_REG (cx)
83 #endif
84         fldl    MO(nan)
85         ret
87         /* The first parameter is a NaN.  Return it.  */
88 3:      fstp    %st(1)
89         ret
91         /* Return NaN and raise the invalid exception.  */
92 4:      fstp    %st
93         fstp    %st
94         fldz
95         fdiv    %st
96         ret
97 END(__ieee754_scalbf)
98 strong_alias (__ieee754_scalbf, __scalbf_finite)