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