aboutsummaryrefslogtreecommitdiff
path: root/sysdeps/i386/fpu/e_scalbl.S
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1999-07-14 00:54:57 +0000
committerUlrich Drepper <drepper@redhat.com>1999-07-14 00:54:57 +0000
commitabfbdde177c3a7155070dda1b2cdc8292054cc26 (patch)
treee021306b596381fbf8311d2b7eb294e918ff17c8 /sysdeps/i386/fpu/e_scalbl.S
parent86421aa57ecfd70963ae66848bd6a6dd3b8e0fe6 (diff)
downloadglibc-abfbdde177c3a7155070dda1b2cdc8292054cc26.zip
glibc-abfbdde177c3a7155070dda1b2cdc8292054cc26.tar.gz
glibc-abfbdde177c3a7155070dda1b2cdc8292054cc26.tar.bz2
Update.
Diffstat (limited to 'sysdeps/i386/fpu/e_scalbl.S')
-rw-r--r--sysdeps/i386/fpu/e_scalbl.S96
1 files changed, 96 insertions, 0 deletions
diff --git a/sysdeps/i386/fpu/e_scalbl.S b/sysdeps/i386/fpu/e_scalbl.S
new file mode 100644
index 0000000..56cc833
--- /dev/null
+++ b/sysdeps/i386/fpu/e_scalbl.S
@@ -0,0 +1,96 @@
+/*
+ * Written by J.T. Conklin <jtc@netbsd.org>.
+ * Public domain.
+ *
+ * Adapted for `long double' by Ulrich Drepper <drepper@cygnus.com>.
+ *
+ * Correct handling of y==-inf <drepper@gnu>
+ */
+
+#include <machine/asm.h>
+
+RCSID("$NetBSD: $")
+
+#ifdef __ELF__
+ .section .rodata
+#else
+ .text
+#endif
+
+ .align ALIGNARG(4)
+ ASM_TYPE_DIRECTIVE(zero_nan,@object)
+zero_nan:
+ .double 0.0
+nan: .byte 0, 0, 0, 0, 0, 0, 0xff, 0x7f
+minus_zero:
+ .byte 0, 0, 0, 0, 0, 0, 0, 0x80
+ .byte 0, 0, 0, 0, 0, 0, 0xff, 0x7f
+ ASM_SIZE_DIRECTIVE(zero_nan)
+
+
+#ifdef PIC
+#define MO(op) op##@GOTOFF(%ecx)
+#define MOX(op,x,f) op##@GOTOFF(%ecx,x,f)
+#else
+#define MO(op) op
+#define MOX(op,x,f) op(,x,f)
+#endif
+
+ .text
+ENTRY(__ieee754_scalbl)
+ fldt 16(%esp)
+ fxam
+ fnstsw
+ fldt 4(%esp)
+ andl $0x4700, %eax
+ cmpl $0x0700, %eax
+ je 1f
+ andl $0x4500, %eax
+ cmpl $0x0100, %eax
+ je 2f
+ fxam
+ fnstsw
+ andl $0x4500, %eax
+ cmpl $0x0100, %eax
+ je 2f
+ fld %st(1)
+ frndint
+ fcomp %st(2)
+ fnstsw
+ sahf
+ jne 2f
+ fscale
+ fstp %st(1)
+ ret
+
+ /* y is -inf */
+1: fxam
+#ifdef PIC
+ call 1f
+1: popl %ecx
+ addl $_GLOBAL_OFFSET_TABLE_+[.-1b], %ecx
+#endif
+ fnstsw
+ movl 12(%esp), %edx
+ shrl $5, %eax
+ fstp %st
+ fstp %st
+ andl $0x8000, %edx
+ andl $8, %eax
+ shrl $11, %edx
+ addl %edx, %eax
+ fldl MOX(zero_nan, %eax, 1)
+ ret
+
+ /* The result is NaN, but we must not raise an exception.
+ So use a variable. */
+2: fstp %st
+ fstp %st
+#ifdef PIC
+ call 1f
+1: popl %ecx
+ addl $_GLOBAL_OFFSET_TABLE_+[.-1b], %ecx
+#endif
+ fldl MO(nan)
+ ret
+END(__ieee754_scalbl)