summaryrefslogtreecommitdiff
path: root/lib/libm/arch
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libm/arch')
-rw-r--r--lib/libm/arch/i387/e_acos.S20
-rw-r--r--lib/libm/arch/i387/e_asin.S19
-rw-r--r--lib/libm/arch/i387/e_atan2.S14
-rw-r--r--lib/libm/arch/i387/e_atan2f.S14
-rw-r--r--lib/libm/arch/i387/e_exp.S23
-rw-r--r--lib/libm/arch/i387/e_fmod.S18
-rw-r--r--lib/libm/arch/i387/e_log.S14
-rw-r--r--lib/libm/arch/i387/e_log10.S14
-rw-r--r--lib/libm/arch/i387/e_remainder.S18
-rw-r--r--lib/libm/arch/i387/e_remainderf.S18
-rw-r--r--lib/libm/arch/i387/e_scalb.S14
-rw-r--r--lib/libm/arch/i387/e_sqrt.S13
-rw-r--r--lib/libm/arch/i387/e_sqrtf.S13
-rw-r--r--lib/libm/arch/i387/s_atan.S14
-rw-r--r--lib/libm/arch/i387/s_atanf.S14
-rw-r--r--lib/libm/arch/i387/s_ceil.S28
-rw-r--r--lib/libm/arch/i387/s_ceilf.S28
-rw-r--r--lib/libm/arch/i387/s_copysign.S18
-rw-r--r--lib/libm/arch/i387/s_copysignf.S18
-rw-r--r--lib/libm/arch/i387/s_cos.S26
-rw-r--r--lib/libm/arch/i387/s_cosf.S14
-rw-r--r--lib/libm/arch/i387/s_finite.S16
-rw-r--r--lib/libm/arch/i387/s_finitef.S16
-rw-r--r--lib/libm/arch/i387/s_floor.S28
-rw-r--r--lib/libm/arch/i387/s_floorf.S28
-rw-r--r--lib/libm/arch/i387/s_ilogb.S23
-rw-r--r--lib/libm/arch/i387/s_ilogbf.S23
-rw-r--r--lib/libm/arch/i387/s_log1p.S22
-rw-r--r--lib/libm/arch/i387/s_log1pf.S22
-rw-r--r--lib/libm/arch/i387/s_logb.S14
-rw-r--r--lib/libm/arch/i387/s_logbf.S14
-rw-r--r--lib/libm/arch/i387/s_rint.S13
-rw-r--r--lib/libm/arch/i387/s_rintf.S13
-rw-r--r--lib/libm/arch/i387/s_scalbn.S14
-rw-r--r--lib/libm/arch/i387/s_scalbnf.S14
-rw-r--r--lib/libm/arch/i387/s_significand.S14
-rw-r--r--lib/libm/arch/i387/s_significandf.S14
-rw-r--r--lib/libm/arch/i387/s_sin.S26
-rw-r--r--lib/libm/arch/i387/s_sinf.S14
-rw-r--r--lib/libm/arch/i387/s_tan.S28
-rw-r--r--lib/libm/arch/i387/s_tanf.S15
-rw-r--r--lib/libm/arch/mc68881/e_acos.S50
-rw-r--r--lib/libm/arch/mc68881/e_asin.S50
-rw-r--r--lib/libm/arch/mc68881/e_atanh.S50
-rw-r--r--lib/libm/arch/mc68881/e_cosh.S50
-rw-r--r--lib/libm/arch/mc68881/e_exp.S50
-rw-r--r--lib/libm/arch/mc68881/e_log.S50
-rw-r--r--lib/libm/arch/mc68881/e_log10.S50
-rw-r--r--lib/libm/arch/mc68881/e_remainder.S16
-rw-r--r--lib/libm/arch/mc68881/e_scalb.S18
-rw-r--r--lib/libm/arch/mc68881/e_sinh.S50
-rw-r--r--lib/libm/arch/mc68881/e_sqrt.S56
-rw-r--r--lib/libm/arch/mc68881/s_atan.S50
-rw-r--r--lib/libm/arch/mc68881/s_ceil.S63
-rw-r--r--lib/libm/arch/mc68881/s_copysign.S56
-rw-r--r--lib/libm/arch/mc68881/s_cos.S50
-rw-r--r--lib/libm/arch/mc68881/s_expm1.S50
-rw-r--r--lib/libm/arch/mc68881/s_finite.S57
-rw-r--r--lib/libm/arch/mc68881/s_floor.S63
-rw-r--r--lib/libm/arch/mc68881/s_log1p.S50
-rw-r--r--lib/libm/arch/mc68881/s_logb.S69
-rw-r--r--lib/libm/arch/mc68881/s_rint.S52
-rw-r--r--lib/libm/arch/mc68881/s_scalbn.S55
-rw-r--r--lib/libm/arch/mc68881/s_sin.S50
-rw-r--r--lib/libm/arch/mc68881/s_tan.S50
-rw-r--r--lib/libm/arch/mc68881/s_tanh.S50
-rw-r--r--lib/libm/arch/vax/n_argred.S792
-rw-r--r--lib/libm/arch/vax/n_atan2.S219
-rw-r--r--lib/libm/arch/vax/n_cabs.S133
-rw-r--r--lib/libm/arch/vax/n_cbrt.S101
-rw-r--r--lib/libm/arch/vax/n_infnan.S62
-rw-r--r--lib/libm/arch/vax/n_sincos.S109
-rw-r--r--lib/libm/arch/vax/n_sqrt.S121
-rw-r--r--lib/libm/arch/vax/n_support.S230
-rw-r--r--lib/libm/arch/vax/n_tan.S95
75 files changed, 3860 insertions, 0 deletions
diff --git a/lib/libm/arch/i387/e_acos.S b/lib/libm/arch/i387/e_acos.S
new file mode 100644
index 00000000000..6ec77853631
--- /dev/null
+++ b/lib/libm/arch/i387/e_acos.S
@@ -0,0 +1,20 @@
+/*
+ * Written by J.T. Conklin <jtc@netbsd.org>.
+ * Public domain.
+ */
+
+#include <machine/asm.h>
+
+RCSID("$NetBSD: e_acos.S,v 1.4 1995/05/08 23:44:37 jtc Exp $")
+
+/* acos = atan (sqrt(1 - x^2) / x) */
+ENTRY(__ieee754_acos)
+ fldl 4(%esp) /* x */
+ fst %st(1)
+ fmul %st(0) /* x^2 */
+ fld1
+ fsubp /* 1 - x^2 */
+ fsqrt /* sqrt (1 - x^2) */
+ fxch %st(1)
+ fpatan
+ ret
diff --git a/lib/libm/arch/i387/e_asin.S b/lib/libm/arch/i387/e_asin.S
new file mode 100644
index 00000000000..dfcd7bce95c
--- /dev/null
+++ b/lib/libm/arch/i387/e_asin.S
@@ -0,0 +1,19 @@
+/*
+ * Written by J.T. Conklin <jtc@netbsd.org>.
+ * Public domain.
+ */
+
+#include <machine/asm.h>
+
+RCSID("$NetBSD: e_asin.S,v 1.4 1995/05/08 23:45:40 jtc Exp $")
+
+/* asin = atan (x / sqrt(1 - x^2)) */
+ENTRY(__ieee754_asin)
+ fldl 4(%esp) /* x */
+ fst %st(1)
+ fmul %st(0) /* x^2 */
+ fld1
+ fsubp /* 1 - x^2 */
+ fsqrt /* sqrt (1 - x^2) */
+ fpatan
+ ret
diff --git a/lib/libm/arch/i387/e_atan2.S b/lib/libm/arch/i387/e_atan2.S
new file mode 100644
index 00000000000..da2e11925c6
--- /dev/null
+++ b/lib/libm/arch/i387/e_atan2.S
@@ -0,0 +1,14 @@
+/*
+ * Written by J.T. Conklin <jtc@netbsd.org>.
+ * Public domain.
+ */
+
+#include <machine/asm.h>
+
+RCSID("$NetBSD: e_atan2.S,v 1.4 1995/05/08 23:46:28 jtc Exp $")
+
+ENTRY(__ieee754_atan2)
+ fldl 4(%esp)
+ fldl 12(%esp)
+ fpatan
+ ret
diff --git a/lib/libm/arch/i387/e_atan2f.S b/lib/libm/arch/i387/e_atan2f.S
new file mode 100644
index 00000000000..21fc0d9a574
--- /dev/null
+++ b/lib/libm/arch/i387/e_atan2f.S
@@ -0,0 +1,14 @@
+/*
+ * Written by J.T. Conklin <jtc@netbsd.org>.
+ * Public domain.
+ */
+
+#include <machine/asm.h>
+
+RCSID("$NetBSD: e_atan2f.S,v 1.1 1995/05/08 23:35:10 jtc Exp $")
+
+ENTRY(__ieee754_atan2f)
+ flds 4(%esp)
+ flds 8(%esp)
+ fpatan
+ ret
diff --git a/lib/libm/arch/i387/e_exp.S b/lib/libm/arch/i387/e_exp.S
new file mode 100644
index 00000000000..8c41ce09dd5
--- /dev/null
+++ b/lib/libm/arch/i387/e_exp.S
@@ -0,0 +1,23 @@
+/*
+ * Written by J.T. Conklin <jtc@netbsd.org>.
+ * Public domain.
+ */
+
+#include <machine/asm.h>
+
+RCSID("$NetBSD: e_exp.S,v 1.4 1995/05/08 23:47:04 jtc Exp $")
+
+/* e^x = 2^(x * log2(e)) */
+ENTRY(__ieee754_exp)
+ fldl 4(%esp)
+ fldl2e
+ fmulp /* x * log2(e) */
+ fstl %st(1)
+ frndint /* int(x * log2(e)) */
+ fstl %st(2)
+ fsubrp /* fract(x * log2(e)) */
+ f2xm1 /* 2^(fract(x * log2(e))) - 1 */
+ fld1
+ faddp /* 2^(fract(x * log2(e))) */
+ fscale /* e^x */
+ ret
diff --git a/lib/libm/arch/i387/e_fmod.S b/lib/libm/arch/i387/e_fmod.S
new file mode 100644
index 00000000000..c02df44e18b
--- /dev/null
+++ b/lib/libm/arch/i387/e_fmod.S
@@ -0,0 +1,18 @@
+/*
+ * Written by J.T. Conklin <jtc@netbsd.org>.
+ * Public domain.
+ */
+
+#include <machine/asm.h>
+
+RCSID("$NetBSD: e_fmod.S,v 1.4 1995/05/08 23:47:56 jtc Exp $")
+
+ENTRY(__ieee754_fmod)
+ fldl 12(%esp)
+ fldl 4(%esp)
+1: fprem
+ fstsw %ax
+ sahf
+ jp 1b
+ fstpl %st(1)
+ ret
diff --git a/lib/libm/arch/i387/e_log.S b/lib/libm/arch/i387/e_log.S
new file mode 100644
index 00000000000..98d569ea43a
--- /dev/null
+++ b/lib/libm/arch/i387/e_log.S
@@ -0,0 +1,14 @@
+/*
+ * Written by J.T. Conklin <jtc@netbsd.org>.
+ * Public domain.
+ */
+
+#include <machine/asm.h>
+
+RCSID("$NetBSD: e_log.S,v 1.4 1995/05/08 23:48:39 jtc Exp $")
+
+ENTRY(__ieee754_log)
+ fldln2
+ fldl 4(%esp)
+ fyl2x
+ ret
diff --git a/lib/libm/arch/i387/e_log10.S b/lib/libm/arch/i387/e_log10.S
new file mode 100644
index 00000000000..612344be56a
--- /dev/null
+++ b/lib/libm/arch/i387/e_log10.S
@@ -0,0 +1,14 @@
+/*
+ * Written by J.T. Conklin <jtc@netbsd.org>.
+ * Public domain.
+ */
+
+#include <machine/asm.h>
+
+RCSID("$NetBSD: e_log10.S,v 1.4 1995/05/08 23:49:24 jtc Exp $")
+
+ENTRY(__ieee754_log10)
+ fldlg2
+ fldl 4(%esp)
+ fyl2x
+ ret
diff --git a/lib/libm/arch/i387/e_remainder.S b/lib/libm/arch/i387/e_remainder.S
new file mode 100644
index 00000000000..d14f2e82bd6
--- /dev/null
+++ b/lib/libm/arch/i387/e_remainder.S
@@ -0,0 +1,18 @@
+/*
+ * Written by J.T. Conklin <jtc@netbsd.org>.
+ * Public domain.
+ */
+
+#include <machine/asm.h>
+
+RCSID("$NetBSD: e_remainder.S,v 1.4 1995/05/08 23:49:37 jtc Exp $")
+
+ENTRY(__ieee754_remainder)
+ fldl 12(%esp)
+ fldl 4(%esp)
+1: fprem1
+ fstsw %ax
+ sahf
+ jp 1b
+ fstpl %st(1)
+ ret
diff --git a/lib/libm/arch/i387/e_remainderf.S b/lib/libm/arch/i387/e_remainderf.S
new file mode 100644
index 00000000000..ed578ea542b
--- /dev/null
+++ b/lib/libm/arch/i387/e_remainderf.S
@@ -0,0 +1,18 @@
+/*
+ * Written by J.T. Conklin <jtc@netbsd.org>.
+ * Public domain.
+ */
+
+#include <machine/asm.h>
+
+RCSID("$NetBSD: e_remainderf.S,v 1.2 1995/05/08 23:49:47 jtc Exp $")
+
+ENTRY(__ieee754_remainderf)
+ flds 8(%esp)
+ flds 4(%esp)
+1: fprem1
+ fstsw %ax
+ sahf
+ jp 1b
+ fstpl %st(1)
+ ret
diff --git a/lib/libm/arch/i387/e_scalb.S b/lib/libm/arch/i387/e_scalb.S
new file mode 100644
index 00000000000..7d95f8e3b30
--- /dev/null
+++ b/lib/libm/arch/i387/e_scalb.S
@@ -0,0 +1,14 @@
+/*
+ * Written by J.T. Conklin <jtc@netbsd.org>.
+ * Public domain.
+ */
+
+#include <machine/asm.h>
+
+RCSID("$NetBSD: e_scalb.S,v 1.4 1995/05/08 23:49:52 jtc Exp $")
+
+ENTRY(__ieee754_scalb)
+ fldl 12(%esp)
+ fldl 4(%esp)
+ fscale
+ ret
diff --git a/lib/libm/arch/i387/e_sqrt.S b/lib/libm/arch/i387/e_sqrt.S
new file mode 100644
index 00000000000..34fe9b71362
--- /dev/null
+++ b/lib/libm/arch/i387/e_sqrt.S
@@ -0,0 +1,13 @@
+/*
+ * Written by J.T. Conklin <jtc@netbsd.org>.
+ * Public domain.
+ */
+
+#include <machine/asm.h>
+
+RCSID("$NetBSD: e_sqrt.S,v 1.4 1995/05/08 23:49:57 jtc Exp $")
+
+ENTRY(__ieee754_sqrt)
+ fldl 4(%esp)
+ fsqrt
+ ret
diff --git a/lib/libm/arch/i387/e_sqrtf.S b/lib/libm/arch/i387/e_sqrtf.S
new file mode 100644
index 00000000000..d20c4c1254a
--- /dev/null
+++ b/lib/libm/arch/i387/e_sqrtf.S
@@ -0,0 +1,13 @@
+/*
+ * Written by J.T. Conklin <jtc@netbsd.org>.
+ * Public domain.
+ */
+
+#include <machine/asm.h>
+
+RCSID("$NetBSD: e_sqrtf.S,v 1.2 1995/05/08 23:50:14 jtc Exp $")
+
+ENTRY(__ieee754_sqrtf)
+ flds 4(%esp)
+ fsqrt
+ ret
diff --git a/lib/libm/arch/i387/s_atan.S b/lib/libm/arch/i387/s_atan.S
new file mode 100644
index 00000000000..9d199743c59
--- /dev/null
+++ b/lib/libm/arch/i387/s_atan.S
@@ -0,0 +1,14 @@
+/*
+ * Written by J.T. Conklin <jtc@netbsd.org>.
+ * Public domain.
+ */
+
+#include <machine/asm.h>
+
+RCSID("$NetBSD: s_atan.S,v 1.4 1995/05/08 23:50:41 jtc Exp $")
+
+ENTRY(atan)
+ fldl 4(%esp)
+ fld1
+ fpatan
+ ret
diff --git a/lib/libm/arch/i387/s_atanf.S b/lib/libm/arch/i387/s_atanf.S
new file mode 100644
index 00000000000..fb1f9b0dbb3
--- /dev/null
+++ b/lib/libm/arch/i387/s_atanf.S
@@ -0,0 +1,14 @@
+/*
+ * Written by J.T. Conklin <jtc@netbsd.org>.
+ * Public domain.
+ */
+
+#include <machine/asm.h>
+
+RCSID("$NetBSD: s_atanf.S,v 1.3 1995/05/08 23:51:33 jtc Exp $")
+
+ENTRY(atanf)
+ flds 4(%esp)
+ fld1
+ fpatan
+ ret
diff --git a/lib/libm/arch/i387/s_ceil.S b/lib/libm/arch/i387/s_ceil.S
new file mode 100644
index 00000000000..0802c0ecdf9
--- /dev/null
+++ b/lib/libm/arch/i387/s_ceil.S
@@ -0,0 +1,28 @@
+/*
+ * Written by J.T. Conklin <jtc@netbsd.org>.
+ * Public domain.
+ */
+
+#include <machine/asm.h>
+
+RCSID("$NetBSD: s_ceil.S,v 1.4 1995/05/08 23:52:13 jtc Exp $")
+
+ENTRY(ceil)
+ pushl %ebp
+ movl %esp,%ebp
+ subl $8,%esp
+
+ fstcw -12(%ebp) /* store fpu control word */
+ movw -12(%ebp),%dx
+ orw $0x0800,%dx /* round towards +oo */
+ andw $0xfbff,%dx
+ movw %dx,-16(%ebp)
+ fldcw -16(%ebp) /* load modfied control word */
+
+ fldl 8(%ebp); /* round */
+ frndint
+
+ fldcw -12(%ebp) /* restore original control word */
+
+ leave
+ ret
diff --git a/lib/libm/arch/i387/s_ceilf.S b/lib/libm/arch/i387/s_ceilf.S
new file mode 100644
index 00000000000..253f4fc6933
--- /dev/null
+++ b/lib/libm/arch/i387/s_ceilf.S
@@ -0,0 +1,28 @@
+/*
+ * Written by J.T. Conklin <jtc@netbsd.org>.
+ * Public domain.
+ */
+
+#include <machine/asm.h>
+
+RCSID("$NetBSD: s_ceilf.S,v 1.3 1995/05/08 23:52:44 jtc Exp $")
+
+ENTRY(ceilf)
+ pushl %ebp
+ movl %esp,%ebp
+ subl $8,%esp
+
+ fstcw -12(%ebp) /* store fpu control word */
+ movw -12(%ebp),%dx
+ orw $0x0800,%dx /* round towards +oo */
+ andw $0xfbff,%dx
+ movw %dx,-16(%ebp)
+ fldcw -16(%ebp) /* load modfied control word */
+
+ flds 8(%ebp); /* round */
+ frndint
+
+ fldcw -12(%ebp) /* restore original control word */
+
+ leave
+ ret
diff --git a/lib/libm/arch/i387/s_copysign.S b/lib/libm/arch/i387/s_copysign.S
new file mode 100644
index 00000000000..a57cb96b025
--- /dev/null
+++ b/lib/libm/arch/i387/s_copysign.S
@@ -0,0 +1,18 @@
+/*
+ * Written by J.T. Conklin <jtc@netbsd.org>.
+ * Public domain.
+ */
+
+#include <machine/asm.h>
+
+RCSID("$NetBSD: s_copysign.S,v 1.4 1995/05/08 23:53:02 jtc Exp $")
+
+ENTRY(copysign)
+ movl 16(%esp),%edx
+ andl $0x80000000,%edx
+ movl 8(%esp),%eax
+ andl $0x7fffffff,%eax
+ orl %edx,%eax
+ movl %eax,8(%esp)
+ fldl 4(%esp)
+ ret
diff --git a/lib/libm/arch/i387/s_copysignf.S b/lib/libm/arch/i387/s_copysignf.S
new file mode 100644
index 00000000000..b3e609f7575
--- /dev/null
+++ b/lib/libm/arch/i387/s_copysignf.S
@@ -0,0 +1,18 @@
+/*
+ * Written by J.T. Conklin <jtc@netbsd.org>.
+ * Public domain.
+ */
+
+#include <machine/asm.h>
+
+RCSID("$NetBSD: s_copysignf.S,v 1.3 1995/05/08 23:53:25 jtc Exp $")
+
+ENTRY(copysignf)
+ movl 8(%esp),%edx
+ andl $0x80000000,%edx
+ movl 4(%esp),%eax
+ andl $0x7fffffff,%eax
+ orl %edx,%eax
+ movl %eax,4(%esp)
+ flds 4(%esp)
+ ret
diff --git a/lib/libm/arch/i387/s_cos.S b/lib/libm/arch/i387/s_cos.S
new file mode 100644
index 00000000000..6ee81b1d332
--- /dev/null
+++ b/lib/libm/arch/i387/s_cos.S
@@ -0,0 +1,26 @@
+/*
+ * Written by J.T. Conklin <jtc@netbsd.org>.
+ * Public domain.
+ */
+
+#include <machine/asm.h>
+
+RCSID("$NetBSD: s_cos.S,v 1.5 1995/05/08 23:54:00 jtc Exp $")
+
+ENTRY(cos)
+ fldl 4(%esp)
+ fcos
+ fnstsw %ax
+ andw $0x400,%ax
+ jnz 1f
+ ret
+1: fldpi
+ fadd %st(0)
+ fxch %st(1)
+2: fprem1
+ fnstsw %ax
+ andw $0x400,%ax
+ jnz 2b
+ fstp %st(1)
+ fcos
+ ret
diff --git a/lib/libm/arch/i387/s_cosf.S b/lib/libm/arch/i387/s_cosf.S
new file mode 100644
index 00000000000..adf8e87abbc
--- /dev/null
+++ b/lib/libm/arch/i387/s_cosf.S
@@ -0,0 +1,14 @@
+/*
+ * Written by J.T. Conklin <jtc@netbsd.org>.
+ * Public domain.
+ */
+
+#include <machine/asm.h>
+
+RCSID("$NetBSD: s_cosf.S,v 1.3 1995/05/08 23:55:16 jtc Exp $")
+
+/* A float's domain isn't large enough to require argument reduction. */
+ENTRY(cosf)
+ flds 4(%esp)
+ fcos
+ ret
diff --git a/lib/libm/arch/i387/s_finite.S b/lib/libm/arch/i387/s_finite.S
new file mode 100644
index 00000000000..9887e88c9c2
--- /dev/null
+++ b/lib/libm/arch/i387/s_finite.S
@@ -0,0 +1,16 @@
+/*
+ * Written by J.T. Conklin <jtc@netbsd.org>.
+ * Public domain.
+ */
+
+#include <machine/asm.h>
+
+RCSID("$NetBSD: s_finite.S,v 1.4 1995/05/08 23:57:41 jtc Exp $")
+
+ENTRY(finite)
+ movl 8(%esp),%eax
+ andl $0x7ff00000, %eax
+ cmpl $0x7ff00000, %eax
+ setnel %al
+ andl $0x000000ff, %eax
+ ret
diff --git a/lib/libm/arch/i387/s_finitef.S b/lib/libm/arch/i387/s_finitef.S
new file mode 100644
index 00000000000..aee90cdd32e
--- /dev/null
+++ b/lib/libm/arch/i387/s_finitef.S
@@ -0,0 +1,16 @@
+/*
+ * Written by J.T. Conklin <jtc@netbsd.org>.
+ * Public domain.
+ */
+
+#include <machine/asm.h>
+
+RCSID("$NetBSD: s_finitef.S,v 1.3 1995/05/09 00:00:02 jtc Exp $")
+
+ENTRY(finitef)
+ movl 4(%esp),%eax
+ andl $0x7ff00000, %eax
+ cmpl $0x7ff00000, %eax
+ setnel %al
+ andl $0x000000ff, %eax
+ ret
diff --git a/lib/libm/arch/i387/s_floor.S b/lib/libm/arch/i387/s_floor.S
new file mode 100644
index 00000000000..e39369fc906
--- /dev/null
+++ b/lib/libm/arch/i387/s_floor.S
@@ -0,0 +1,28 @@
+/*
+ * Written by J.T. Conklin <jtc@netbsd.org>.
+ * Public domain.
+ */
+
+#include <machine/asm.h>
+
+RCSID("$NetBSD: s_floor.S,v 1.4 1995/05/09 00:01:59 jtc Exp $")
+
+ENTRY(floor)
+ pushl %ebp
+ movl %esp,%ebp
+ subl $8,%esp
+
+ fstcw -12(%ebp) /* store fpu control word */
+ movw -12(%ebp),%dx
+ orw $0x0400,%dx /* round towards -oo */
+ andw $0xf7ff,%dx
+ movw %dx,-16(%ebp)
+ fldcw -16(%ebp) /* load modfied control word */
+
+ fldl 8(%ebp); /* round */
+ frndint
+
+ fldcw -12(%ebp) /* restore original control word */
+
+ leave
+ ret
diff --git a/lib/libm/arch/i387/s_floorf.S b/lib/libm/arch/i387/s_floorf.S
new file mode 100644
index 00000000000..4c0f87bc384
--- /dev/null
+++ b/lib/libm/arch/i387/s_floorf.S
@@ -0,0 +1,28 @@
+/*
+ * Written by J.T. Conklin <jtc@netbsd.org>.
+ * Public domain.
+ */
+
+#include <machine/asm.h>
+
+RCSID("$NetBSD: s_floorf.S,v 1.3 1995/05/09 00:04:32 jtc Exp $")
+
+ENTRY(floorf)
+ pushl %ebp
+ movl %esp,%ebp
+ subl $8,%esp
+
+ fstcw -12(%ebp) /* store fpu control word */
+ movw -12(%ebp),%dx
+ orw $0x0400,%dx /* round towards -oo */
+ andw $0xf7ff,%dx
+ movw %dx,-16(%ebp)
+ fldcw -16(%ebp) /* load modfied control word */
+
+ flds 8(%ebp); /* round */
+ frndint
+
+ fldcw -12(%ebp) /* restore original control word */
+
+ leave
+ ret
diff --git a/lib/libm/arch/i387/s_ilogb.S b/lib/libm/arch/i387/s_ilogb.S
new file mode 100644
index 00000000000..ed7f777c378
--- /dev/null
+++ b/lib/libm/arch/i387/s_ilogb.S
@@ -0,0 +1,23 @@
+/*
+ * Written by J.T. Conklin <jtc@netbsd.org>.
+ * Public domain.
+ */
+
+#include <machine/asm.h>
+
+RCSID("$NetBSD: s_ilogb.S,v 1.4 1995/05/09 00:06:28 jtc Exp $")
+
+ENTRY(ilogb)
+ pushl %esp
+ movl %esp,%ebp
+ subl $4,%esp
+
+ fldl 8(%ebp)
+ fxtract
+ fstpl %st
+
+ fistpl -4(%ebp)
+ movl -4(%ebp),%eax
+
+ leave
+ ret
diff --git a/lib/libm/arch/i387/s_ilogbf.S b/lib/libm/arch/i387/s_ilogbf.S
new file mode 100644
index 00000000000..36f93251ea5
--- /dev/null
+++ b/lib/libm/arch/i387/s_ilogbf.S
@@ -0,0 +1,23 @@
+/*
+ * Written by J.T. Conklin <jtc@netbsd.org>.
+ * Public domain.
+ */
+
+#include <machine/asm.h>
+
+RCSID("$NetBSD: s_ilogbf.S,v 1.3 1995/05/09 00:08:15 jtc Exp $")
+
+ENTRY(ilogbf)
+ pushl %esp
+ movl %esp,%ebp
+ subl $4,%esp
+
+ flds 8(%ebp)
+ fxtract
+ fstpl %st
+
+ fistpl -4(%ebp)
+ movl -4(%ebp),%eax
+
+ leave
+ ret
diff --git a/lib/libm/arch/i387/s_log1p.S b/lib/libm/arch/i387/s_log1p.S
new file mode 100644
index 00000000000..561841fc1b0
--- /dev/null
+++ b/lib/libm/arch/i387/s_log1p.S
@@ -0,0 +1,22 @@
+/*
+ * Written by J.T. Conklin <jtc@netbsd.org>.
+ * Public domain.
+ */
+
+#include <machine/asm.h>
+
+RCSID("$NetBSD: s_log1p.S,v 1.7 1995/05/09 00:10:58 jtc Exp $")
+
+/*
+ * Since the fyl2xp1 instruction has such a limited range:
+ * -(1 - (sqrt(2) / 2)) <= x <= sqrt(2) - 1
+ * it's not worth trying to use it.
+ */
+
+ENTRY(log1p)
+ fldln2
+ fldl 4(%esp)
+ fld1
+ faddp
+ fyl2x
+ ret
diff --git a/lib/libm/arch/i387/s_log1pf.S b/lib/libm/arch/i387/s_log1pf.S
new file mode 100644
index 00000000000..c53cb73a35b
--- /dev/null
+++ b/lib/libm/arch/i387/s_log1pf.S
@@ -0,0 +1,22 @@
+/*
+ * Written by J.T. Conklin <jtc@netbsd.org>.
+ * Public domain.
+ */
+
+#include <machine/asm.h>
+
+RCSID("$NetBSD: s_log1pf.S,v 1.4 1995/05/09 00:13:05 jtc Exp $")
+
+/*
+ * Since the fyl2xp1 instruction has such a limited range:
+ * -(1 - (sqrt(2) / 2)) <= x <= sqrt(2) - 1
+ * it's not worth trying to use it.
+ */
+
+ENTRY(log1pf)
+ fldln2
+ flds 4(%esp)
+ fld1
+ faddp
+ fyl2x
+ ret
diff --git a/lib/libm/arch/i387/s_logb.S b/lib/libm/arch/i387/s_logb.S
new file mode 100644
index 00000000000..532837f8ae5
--- /dev/null
+++ b/lib/libm/arch/i387/s_logb.S
@@ -0,0 +1,14 @@
+/*
+ * Written by J.T. Conklin <jtc@netbsd.org>.
+ * Public domain.
+ */
+
+#include <machine/asm.h>
+
+RCSID("$NetBSD: s_logb.S,v 1.4 1995/05/09 00:14:30 jtc Exp $")
+
+ENTRY(logb)
+ fldl 4(%esp)
+ fxtract
+ fstpl %st
+ ret
diff --git a/lib/libm/arch/i387/s_logbf.S b/lib/libm/arch/i387/s_logbf.S
new file mode 100644
index 00000000000..b22964cf64b
--- /dev/null
+++ b/lib/libm/arch/i387/s_logbf.S
@@ -0,0 +1,14 @@
+/*
+ * Written by J.T. Conklin <jtc@netbsd.org>.
+ * Public domain.
+ */
+
+#include <machine/asm.h>
+
+RCSID("$NetBSD: s_logbf.S,v 1.3 1995/05/09 00:15:12 jtc Exp $")
+
+ENTRY(logbf)
+ flds 4(%esp)
+ fxtract
+ fstpl %st
+ ret
diff --git a/lib/libm/arch/i387/s_rint.S b/lib/libm/arch/i387/s_rint.S
new file mode 100644
index 00000000000..df3e3fef547
--- /dev/null
+++ b/lib/libm/arch/i387/s_rint.S
@@ -0,0 +1,13 @@
+/*
+ * Written by J.T. Conklin <jtc@netbsd.org>.
+ * Public domain.
+ */
+
+#include <machine/asm.h>
+
+RCSID("$NetBSD: s_rint.S,v 1.4 1995/05/09 00:16:08 jtc Exp $")
+
+ENTRY(rint)
+ fldl 4(%esp)
+ frndint
+ ret
diff --git a/lib/libm/arch/i387/s_rintf.S b/lib/libm/arch/i387/s_rintf.S
new file mode 100644
index 00000000000..3454c650b60
--- /dev/null
+++ b/lib/libm/arch/i387/s_rintf.S
@@ -0,0 +1,13 @@
+/*
+ * Written by J.T. Conklin <jtc@netbsd.org>.
+ * Public domain.
+ */
+
+#include <machine/asm.h>
+
+RCSID("$NetBSD: s_rintf.S,v 1.3 1995/05/09 00:17:22 jtc Exp $")
+
+ENTRY(rintf)
+ flds 4(%esp)
+ frndint
+ ret
diff --git a/lib/libm/arch/i387/s_scalbn.S b/lib/libm/arch/i387/s_scalbn.S
new file mode 100644
index 00000000000..743ee38c49b
--- /dev/null
+++ b/lib/libm/arch/i387/s_scalbn.S
@@ -0,0 +1,14 @@
+/*
+ * Written by J.T. Conklin <jtc@netbsd.org>.
+ * Public domain.
+ */
+
+#include <machine/asm.h>
+
+RCSID("$NetBSD: s_scalbn.S,v 1.4 1995/05/09 00:19:06 jtc Exp $")
+
+ENTRY(scalbn)
+ fildl 12(%esp)
+ fldl 4(%esp)
+ fscale
+ ret
diff --git a/lib/libm/arch/i387/s_scalbnf.S b/lib/libm/arch/i387/s_scalbnf.S
new file mode 100644
index 00000000000..6cae0248876
--- /dev/null
+++ b/lib/libm/arch/i387/s_scalbnf.S
@@ -0,0 +1,14 @@
+/*
+ * Written by J.T. Conklin <jtc@netbsd.org>.
+ * Public domain.
+ */
+
+#include <machine/asm.h>
+
+RCSID("$NetBSD: s_scalbnf.S,v 1.3 1995/05/09 00:19:59 jtc Exp $")
+
+ENTRY(scalbnf)
+ fildl 8(%esp)
+ flds 4(%esp)
+ fscale
+ ret
diff --git a/lib/libm/arch/i387/s_significand.S b/lib/libm/arch/i387/s_significand.S
new file mode 100644
index 00000000000..74811a3057a
--- /dev/null
+++ b/lib/libm/arch/i387/s_significand.S
@@ -0,0 +1,14 @@
+/*
+ * Written by J.T. Conklin <jtc@netbsd.org>.
+ * Public domain.
+ */
+
+#include <machine/asm.h>
+
+RCSID("$NetBSD: s_significand.S,v 1.4 1995/05/09 00:21:47 jtc Exp $")
+
+ENTRY(significand)
+ fldl 4(%esp)
+ fxtract
+ fstpl %st(1)
+ ret
diff --git a/lib/libm/arch/i387/s_significandf.S b/lib/libm/arch/i387/s_significandf.S
new file mode 100644
index 00000000000..77b8ae0e210
--- /dev/null
+++ b/lib/libm/arch/i387/s_significandf.S
@@ -0,0 +1,14 @@
+/*
+ * Written by J.T. Conklin <jtc@netbsd.org>.
+ * Public domain.
+ */
+
+#include <machine/asm.h>
+
+RCSID("$NetBSD: s_significandf.S,v 1.3 1995/05/09 00:24:07 jtc Exp $")
+
+ENTRY(significandf)
+ flds 4(%esp)
+ fxtract
+ fstpl %st(1)
+ ret
diff --git a/lib/libm/arch/i387/s_sin.S b/lib/libm/arch/i387/s_sin.S
new file mode 100644
index 00000000000..b792ef07f2f
--- /dev/null
+++ b/lib/libm/arch/i387/s_sin.S
@@ -0,0 +1,26 @@
+/*
+ * Written by J.T. Conklin <jtc@netbsd.org>.
+ * Public domain.
+ */
+
+#include <machine/asm.h>
+
+RCSID("$NetBSD: s_sin.S,v 1.5 1995/05/09 00:25:54 jtc Exp $")
+
+ENTRY(sin)
+ fldl 4(%esp)
+ fsin
+ fnstsw %ax
+ andw $0x400,%ax
+ jnz 1f
+ ret
+1: fldpi
+ fadd %st(0)
+ fxch %st(1)
+2: fprem1
+ fnstsw %ax
+ andw $0x400,%ax
+ jnz 2b
+ fstp %st(1)
+ fsin
+ ret
diff --git a/lib/libm/arch/i387/s_sinf.S b/lib/libm/arch/i387/s_sinf.S
new file mode 100644
index 00000000000..b2ffe739334
--- /dev/null
+++ b/lib/libm/arch/i387/s_sinf.S
@@ -0,0 +1,14 @@
+/*
+ * Written by J.T. Conklin <jtc@netbsd.org>.
+ * Public domain.
+ */
+
+#include <machine/asm.h>
+
+RCSID("$NetBSD: s_sinf.S,v 1.3 1995/05/09 00:27:53 jtc Exp $")
+
+/* A float's domain isn't large enough to require argument reduction. */
+ENTRY(sinf)
+ flds 4(%esp)
+ fsin
+ ret
diff --git a/lib/libm/arch/i387/s_tan.S b/lib/libm/arch/i387/s_tan.S
new file mode 100644
index 00000000000..e99698492c8
--- /dev/null
+++ b/lib/libm/arch/i387/s_tan.S
@@ -0,0 +1,28 @@
+/*
+ * Written by J.T. Conklin <jtc@netbsd.org>.
+ * Public domain.
+ */
+
+#include <machine/asm.h>
+
+RCSID("$NetBSD: s_tan.S,v 1.5 1995/05/09 00:30:00 jtc Exp $")
+
+ENTRY(tan)
+ fldl 4(%esp)
+ fptan
+ fnstsw %ax
+ andw $0x400,%ax
+ jnz 1f
+ fstp %st(0)
+ ret
+1: fldpi
+ fadd %st(0)
+ fxch %st(1)
+2: fprem1
+ fstsw %ax
+ andw $0x400,%ax
+ jnz 2b
+ fstp %st(1)
+ fptan
+ fstp %st(0)
+ ret
diff --git a/lib/libm/arch/i387/s_tanf.S b/lib/libm/arch/i387/s_tanf.S
new file mode 100644
index 00000000000..11059526f20
--- /dev/null
+++ b/lib/libm/arch/i387/s_tanf.S
@@ -0,0 +1,15 @@
+/*
+ * Written by J.T. Conklin <jtc@netbsd.org>.
+ * Public domain.
+ */
+
+#include <machine/asm.h>
+
+RCSID("$NetBSD: s_tanf.S,v 1.3 1995/05/09 00:31:09 jtc Exp $")
+
+/* A float's domain isn't large enough to require argument reduction. */
+ENTRY(tanf)
+ flds 4(%esp)
+ fptan
+ fstp %st(0)
+ ret
diff --git a/lib/libm/arch/mc68881/e_acos.S b/lib/libm/arch/mc68881/e_acos.S
new file mode 100644
index 00000000000..e1a1f9d2469
--- /dev/null
+++ b/lib/libm/arch/mc68881/e_acos.S
@@ -0,0 +1,50 @@
+/*-
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * the Systems Programming Group of the University of Utah Computer
+ * Science Department.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/asm.h>
+
+;_sccsid:
+;.asciz "from: @(#)asincos.s 5.1 (Berkeley) 5/17/90"
+
+RCSID("$NetBSD: e_acos.S,v 1.3 1995/05/09 00:38:23 jtc Exp $")
+
+ENTRY(__ieee754_acos)
+ facosd sp@(4),fp0
+ fmoved fp0,sp@-
+ movel sp@+,d0
+ movel sp@+,d1
+ rts
diff --git a/lib/libm/arch/mc68881/e_asin.S b/lib/libm/arch/mc68881/e_asin.S
new file mode 100644
index 00000000000..abd608b9f2b
--- /dev/null
+++ b/lib/libm/arch/mc68881/e_asin.S
@@ -0,0 +1,50 @@
+/*-
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * the Systems Programming Group of the University of Utah Computer
+ * Science Department.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/asm.h>
+
+;_sccsid:
+;.asciz "from: @(#)asincos.s 5.1 (Berkeley) 5/17/90"
+
+RCSID("$NetBSD: e_asin.S,v 1.3 1995/05/09 00:42:19 jtc Exp $")
+
+ENTRY(__ieee754_asin)
+ fasind sp@(4),fp0
+ fmoved fp0,sp@-
+ movel sp@+,d0
+ movel sp@+,d1
+ rts
diff --git a/lib/libm/arch/mc68881/e_atanh.S b/lib/libm/arch/mc68881/e_atanh.S
new file mode 100644
index 00000000000..23ef840fa51
--- /dev/null
+++ b/lib/libm/arch/mc68881/e_atanh.S
@@ -0,0 +1,50 @@
+/*-
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * the Systems Programming Group of the University of Utah Computer
+ * Science Department.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/asm.h>
+
+;_sccsid:
+;.asciz "from: @(#)atanh.s 5.1 (Berkeley) 5/17/90"
+
+RCSID("$NetBSD: e_atanh.S,v 1.3 1995/05/09 00:45:54 jtc Exp $")
+
+ENTRY(__ieee754_atanh)
+ fatanhd sp@(4),fp0
+ fmoved fp0,sp@-
+ movel sp@+,d0
+ movel sp@+,d1
+ rts
diff --git a/lib/libm/arch/mc68881/e_cosh.S b/lib/libm/arch/mc68881/e_cosh.S
new file mode 100644
index 00000000000..c1282260b53
--- /dev/null
+++ b/lib/libm/arch/mc68881/e_cosh.S
@@ -0,0 +1,50 @@
+/*-
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * the Systems Programming Group of the University of Utah Computer
+ * Science Department.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/asm.h>
+
+;_sccsid:
+;.asciz "from: @(#)cosh.s 5.1 (Berkeley) 5/17/90"
+
+RCSID("$NetBSD: e_cosh.S,v 1.3 1995/05/09 00:48:41 jtc Exp $")
+
+ENTRY(__ieee754_cosh)
+ fcoshd sp@(4),fp0
+ fmoved fp0,sp@-
+ movel sp@+,d0
+ movel sp@+,d1
+ rts
diff --git a/lib/libm/arch/mc68881/e_exp.S b/lib/libm/arch/mc68881/e_exp.S
new file mode 100644
index 00000000000..f337306b70a
--- /dev/null
+++ b/lib/libm/arch/mc68881/e_exp.S
@@ -0,0 +1,50 @@
+/*-
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * the Systems Programming Group of the University of Utah Computer
+ * Science Department.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/asm.h>
+
+;_sccsid:
+;.asciz "from: @(#)exp.s 5.1 (Berkeley) 5/17/90"
+
+RCSID("$NetBSD: e_exp.S,v 1.3 1995/05/09 00:52:06 jtc Exp $")
+
+ENTRY(__ieee754_exp)
+ fetoxd sp@(4),fp0
+ fmoved fp0,sp@-
+ movel sp@+,d0
+ movel sp@+,d1
+ rts
diff --git a/lib/libm/arch/mc68881/e_log.S b/lib/libm/arch/mc68881/e_log.S
new file mode 100644
index 00000000000..19f83b22768
--- /dev/null
+++ b/lib/libm/arch/mc68881/e_log.S
@@ -0,0 +1,50 @@
+/*-
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * the Systems Programming Group of the University of Utah Computer
+ * Science Department.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/asm.h>
+
+;_sccsid:
+;.asciz "from: @(#)log.s 5.1 (Berkeley) 5/17/90"
+
+RCSID("$NetBSD: e_log.S,v 1.3 1995/05/09 00:56:09 jtc Exp $")
+
+ENTRY(__ieee754_log)
+ flognd sp@(4),fp0
+ fmoved fp0,sp@-
+ movel sp@+,d0
+ movel sp@+,d1
+ rts
diff --git a/lib/libm/arch/mc68881/e_log10.S b/lib/libm/arch/mc68881/e_log10.S
new file mode 100644
index 00000000000..3e37d21e79b
--- /dev/null
+++ b/lib/libm/arch/mc68881/e_log10.S
@@ -0,0 +1,50 @@
+/*-
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * the Systems Programming Group of the University of Utah Computer
+ * Science Department.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/asm.h>
+
+;_sccsid:
+;.asciz "from: @(#)log10.s 5.1 (Berkeley) 5/17/90"
+
+RCSID("$NetBSD: e_log10.S,v 1.3 1995/05/09 01:01:17 jtc Exp $")
+
+ENTRY(__ieee754_log10)
+ flog10d sp@(4),fp0
+ fmoved fp0,sp@-
+ movel sp@+,d0
+ movel sp@+,d1
+ rts
diff --git a/lib/libm/arch/mc68881/e_remainder.S b/lib/libm/arch/mc68881/e_remainder.S
new file mode 100644
index 00000000000..a68b35e5567
--- /dev/null
+++ b/lib/libm/arch/mc68881/e_remainder.S
@@ -0,0 +1,16 @@
+/*
+ * Written by J.T. Conklin <jtc@netbsd.org>.
+ * Public domain.
+ */
+
+#include <machine/asm.h>
+
+RCSID("$NetBSD: e_remainder.S,v 1.3 1995/05/11 23:19:52 jtc Exp $")
+
+ENTRY(__ieee754_remainder)
+ fmoved sp@(4),fp0
+ fremd sp@(12),fp0
+ fmoved fp0,sp@-
+ movel sp@+,d0
+ movel sp@+,d1
+ rts
diff --git a/lib/libm/arch/mc68881/e_scalb.S b/lib/libm/arch/mc68881/e_scalb.S
new file mode 100644
index 00000000000..45e92da9f0c
--- /dev/null
+++ b/lib/libm/arch/mc68881/e_scalb.S
@@ -0,0 +1,18 @@
+/*
+ * Written by J.T. Conklin <jtc@netbsd.org>.
+ * Public domain.
+ */
+
+#include <machine/asm.h>
+
+RCSID("$NetBSD: e_scalb.S,v 1.4 1995/05/11 23:19:42 jtc Exp $")
+
+ENTRY(__ieee754_scalb)
+ fmoved sp@(4),fp0
+ fbeq Ldone
+ fscaled sp@(12),fp0
+Ldone:
+ fmoved fp0,sp@-
+ movel sp@+,d0
+ movel sp@+,d1
+ rts
diff --git a/lib/libm/arch/mc68881/e_sinh.S b/lib/libm/arch/mc68881/e_sinh.S
new file mode 100644
index 00000000000..dbe0f5b3ace
--- /dev/null
+++ b/lib/libm/arch/mc68881/e_sinh.S
@@ -0,0 +1,50 @@
+/*-
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * the Systems Programming Group of the University of Utah Computer
+ * Science Department.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/asm.h>
+
+;_sccsid:
+;.asciz "from: @(#)sinh.s 5.1 (Berkeley) 5/17/90"
+
+RCSID("$NetBSD: e_sinh.S,v 1.3 1995/05/09 01:22:19 jtc Exp $")
+
+ENTRY(__ieee754_sinh)
+ fsinhd sp@(4),fp0
+ fmoved fp0,sp@-
+ movel sp@+,d0
+ movel sp@+,d1
+ rts
diff --git a/lib/libm/arch/mc68881/e_sqrt.S b/lib/libm/arch/mc68881/e_sqrt.S
new file mode 100644
index 00000000000..d71dbf693fe
--- /dev/null
+++ b/lib/libm/arch/mc68881/e_sqrt.S
@@ -0,0 +1,56 @@
+/*-
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * the Systems Programming Group of the University of Utah Computer
+ * Science Department.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/asm.h>
+
+;_sccsid:
+;.asciz "from: @(#)sqrt.s 5.1 (Berkeley) 5/17/90"
+
+RCSID("$NetBSD: e_sqrt.S,v 1.3 1995/05/09 01:28:27 jtc Exp $")
+
+/*
+ * sqrt(x)
+ * returns the square root of x correctly rounded according
+ * to the rounding mode.
+ */
+
+ENTRY(__ieee754_sqrt)
+ fsqrtd sp@(4),fp0
+ fmoved fp0,sp@-
+ movel sp@+,d0
+ movel sp@+,d1
+ rts
diff --git a/lib/libm/arch/mc68881/s_atan.S b/lib/libm/arch/mc68881/s_atan.S
new file mode 100644
index 00000000000..735d9f506b5
--- /dev/null
+++ b/lib/libm/arch/mc68881/s_atan.S
@@ -0,0 +1,50 @@
+/*-
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * the Systems Programming Group of the University of Utah Computer
+ * Science Department.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/asm.h>
+
+;_sccsid:
+;.asciz "from: @(#)atan.s 5.1 (Berkeley) 5/17/90"
+
+RCSID("$NetBSD: s_atan.S,v 1.3 1995/05/09 01:34:03 jtc Exp $")
+
+ENTRY(atan)
+ fatand sp@(4),fp0
+ fmoved fp0,sp@-
+ movel sp@+,d0
+ movel sp@+,d1
+ rts
diff --git a/lib/libm/arch/mc68881/s_ceil.S b/lib/libm/arch/mc68881/s_ceil.S
new file mode 100644
index 00000000000..c0c1f607769
--- /dev/null
+++ b/lib/libm/arch/mc68881/s_ceil.S
@@ -0,0 +1,63 @@
+/*-
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * the Systems Programming Group of the University of Utah Computer
+ * Science Department.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/asm.h>
+
+;_sccsid:
+;.asciz "from: @(#)floor.s 5.1 (Berkeley) 5/17/90"
+
+RCSID("$NetBSD: s_ceil.S,v 1.3 1995/05/09 01:39:23 jtc Exp $")
+
+| ceil(x)
+| -floor(-x), for all real x
+ENTRY(ceil)
+ fmovel fpcr,d0 | save old FPCR
+ fmoved sp@(4),fp0 | get argument
+ fbun Lret | if NaN, return NaN
+ fbolt Lrtz | <0, round to zero
+ fmovel #0x30,fpcr | >=0, round to inf
+ jra Ldoit
+Lrtz:
+ fmovel #0x10,fpcr
+Ldoit:
+ fintd sp@(4),fp0 | truncate
+ fmovel d0,fpcr | restore old FPCR
+Lret:
+ fmoved fp0,sp@-
+ movel sp@+,d0
+ movel sp@+,d1
+ rts
diff --git a/lib/libm/arch/mc68881/s_copysign.S b/lib/libm/arch/mc68881/s_copysign.S
new file mode 100644
index 00000000000..151be5e7ce2
--- /dev/null
+++ b/lib/libm/arch/mc68881/s_copysign.S
@@ -0,0 +1,56 @@
+/*-
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * the Systems Programming Group of the University of Utah Computer
+ * Science Department.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/asm.h>
+
+;_sccsid:
+;.asciz "from: @(#)support.s 5.2 (Berkeley) 5/17/90"
+
+RCSID("$NetBSD: s_copysign.S,v 1.3 1995/05/09 01:46:33 jtc Exp $")
+
+| copysign(x,y)
+| returns x with the sign of y.
+ENTRY(copysign)
+ movl sp@(4),d0
+ movl sp@(8),d1
+ tstw sp@(12)
+ jmi Lneg
+ bclr #31,d0
+ rts
+Lneg:
+ bset #31,d0
+ rts
diff --git a/lib/libm/arch/mc68881/s_cos.S b/lib/libm/arch/mc68881/s_cos.S
new file mode 100644
index 00000000000..285d277a4cd
--- /dev/null
+++ b/lib/libm/arch/mc68881/s_cos.S
@@ -0,0 +1,50 @@
+/*-
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * the Systems Programming Group of the University of Utah Computer
+ * Science Department.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/asm.h>
+
+;_sccsid:
+;.asciz "from: @(#)sincos.s 5.1 (Berkeley) 5/17/90"
+
+RCSID("$NetBSD: s_cos.S,v 1.3 1995/05/09 01:51:45 jtc Exp $")
+
+ENTRY(cos)
+ fcosd sp@(4),fp0
+ fmoved fp0,sp@-
+ movel sp@+,d0
+ movel sp@+,d1
+ rts
diff --git a/lib/libm/arch/mc68881/s_expm1.S b/lib/libm/arch/mc68881/s_expm1.S
new file mode 100644
index 00000000000..8dfef277fb7
--- /dev/null
+++ b/lib/libm/arch/mc68881/s_expm1.S
@@ -0,0 +1,50 @@
+/*-
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * the Systems Programming Group of the University of Utah Computer
+ * Science Department.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/asm.h>
+
+;_sccsid:
+;.asciz "from: @(#)expm1.s 5.1 (Berkeley) 5/17/90"
+
+RCSID("$NetBSD: s_expm1.S,v 1.3 1995/05/09 01:57:05 jtc Exp $")
+
+ENTRY(expm1)
+ fetoxm1d sp@(4),fp0
+ fmoved fp0,sp@-
+ movel sp@+,d0
+ movel sp@+,d1
+ rts
diff --git a/lib/libm/arch/mc68881/s_finite.S b/lib/libm/arch/mc68881/s_finite.S
new file mode 100644
index 00000000000..5cb8d4e68e5
--- /dev/null
+++ b/lib/libm/arch/mc68881/s_finite.S
@@ -0,0 +1,57 @@
+/*-
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * the Systems Programming Group of the University of Utah Computer
+ * Science Department.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/asm.h>
+
+;_sccsid:
+;.asciz "from: @(#)support.s 5.2 (Berkeley) 5/17/90"
+
+RCSID("$NetBSD: s_finite.S,v 1.3 1995/05/09 02:03:31 jtc Exp $")
+
+| finite(x)
+| returns the value TRUE if -INF < x < +INF and returns FALSE otherwise.
+ENTRY(finite)
+ movw #0x7FF0,d0
+ movw sp@(4),d1
+ andw d0,d1
+ cmpw d0,d1
+ beq Lnotfin
+ moveq #1,d0
+ rts
+Lnotfin:
+ clrl d0
+ rts
diff --git a/lib/libm/arch/mc68881/s_floor.S b/lib/libm/arch/mc68881/s_floor.S
new file mode 100644
index 00000000000..09691b252a8
--- /dev/null
+++ b/lib/libm/arch/mc68881/s_floor.S
@@ -0,0 +1,63 @@
+/*-
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * the Systems Programming Group of the University of Utah Computer
+ * Science Department.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/asm.h>
+
+;_sccsid:
+;.asciz "from: @(#)floor.s 5.1 (Berkeley) 5/17/90"
+
+RCSID("$NetBSD: s_floor.S,v 1.3 1995/05/09 02:11:19 jtc Exp $")
+
+| floor(x)
+| the largest integer no larger than x
+ENTRY(floor)
+ fmovel fpcr,d0 | save old FPCR
+ fmoved sp@(4),fp0 | get argument
+ fbun Lret | if NaN, return NaN
+ fboge Lrtz | >=0, round to zero
+ fmovel #0x20,fpcr | <0, round to -inf
+ jra Ldoit
+Lrtz:
+ fmovel #0x10,fpcr
+Ldoit:
+ fintd sp@(4),fp0 | truncate
+ fmovel d0,fpcr | restore old FPCR
+Lret:
+ fmoved fp0,sp@-
+ movel sp@+,d0
+ movel sp@+,d1
+ rts
diff --git a/lib/libm/arch/mc68881/s_log1p.S b/lib/libm/arch/mc68881/s_log1p.S
new file mode 100644
index 00000000000..3b8c39c3b43
--- /dev/null
+++ b/lib/libm/arch/mc68881/s_log1p.S
@@ -0,0 +1,50 @@
+/*-
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * the Systems Programming Group of the University of Utah Computer
+ * Science Department.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/asm.h>
+
+;_sccsid:
+;.asciz "from: @(#)log1p.s 5.1 (Berkeley) 5/17/90"
+
+RCSID("$NetBSD: s_log1p.S,v 1.3 1995/05/09 02:20:35 jtc Exp $")
+
+ENTRY(log1p)
+ flognp1d sp@(4),fp0
+ fmoved fp0,sp@-
+ movel sp@+,d0
+ movel sp@+,d1
+ rts
diff --git a/lib/libm/arch/mc68881/s_logb.S b/lib/libm/arch/mc68881/s_logb.S
new file mode 100644
index 00000000000..b912e1f39a5
--- /dev/null
+++ b/lib/libm/arch/mc68881/s_logb.S
@@ -0,0 +1,69 @@
+/*-
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * the Systems Programming Group of the University of Utah Computer
+ * Science Department.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/asm.h>
+
+;_sccsid:
+;.asciz "from: @(#)support.s 5.2 (Berkeley) 5/17/90"
+
+RCSID("$NetBSD: s_logb.S,v 1.4 1995/05/09 02:37:09 jtc Exp $")
+
+| logb(x)
+| returns the unbiased exponent of x, a signed integer in double precision,
+| except that logb(0) is -INF, logb(INF) is +INF, and logb(NAN) is that NAN.
+ENTRY(logb)
+ movw sp@(4),d0
+ movw #0x7FF0,d1 | exponent bits
+ andw d1,d0 | mask off all else
+ cmpw d1,d0 | max exponent?
+ bne Lfinite | no, is finite
+ fmoved sp@(4),fp0 | yes, infinite or NaN
+ fbun Ldone | NaN returns NaN
+ fabsx fp0 | +-inf returns inf
+ jra Ldone
+Lfinite:
+ fmoved sp@(4),fp0 | get entire number
+ fbne Lnonz | zero?
+ flog2x fp0 | yes, log(0) a convenient source of -inf
+ jra Ldone
+Lnonz:
+ fgetexpx fp0 | get exponent
+Ldone:
+ fmoved fp0,sp@-
+ movel sp@+,d0
+ movel sp@+,d1
+ rts
diff --git a/lib/libm/arch/mc68881/s_rint.S b/lib/libm/arch/mc68881/s_rint.S
new file mode 100644
index 00000000000..6ab3ac0edb9
--- /dev/null
+++ b/lib/libm/arch/mc68881/s_rint.S
@@ -0,0 +1,52 @@
+/*-
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * the Systems Programming Group of the University of Utah Computer
+ * Science Department.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/asm.h>
+
+;_sccsid:
+;.asciz "from: @(#)floor.s 5.1 (Berkeley) 5/17/90"
+
+RCSID("$NetBSD: s_rint.S,v 1.3 1995/05/09 02:48:48 jtc Exp $")
+
+| rint(x)
+| delivers integer nearest x in direction of prevailing rounding mode
+ENTRY(rint)
+ fintd sp@(4),fp0 | use prevailing rounding mode
+ fmoved fp0,sp@-
+ movel sp@+,d0
+ movel sp@+,d1
+ rts
diff --git a/lib/libm/arch/mc68881/s_scalbn.S b/lib/libm/arch/mc68881/s_scalbn.S
new file mode 100644
index 00000000000..685617d5340
--- /dev/null
+++ b/lib/libm/arch/mc68881/s_scalbn.S
@@ -0,0 +1,55 @@
+/*-
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * the Systems Programming Group of the University of Utah Computer
+ * Science Department.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/asm.h>
+
+;_sccsid:
+;.asciz "from: @(#)support.s 5.2 (Berkeley) 5/17/90"
+
+RCSID("$NetBSD: s_scalbn.S,v 1.3 1995/05/09 03:01:41 jtc Exp $")
+
+| scalbn(x, N)
+| returns x * (2**N), for integer values N.
+ENTRY(scalbn)
+ fmoved sp@(4),fp0
+ fbeq Ldone
+ fscalel sp@(12),fp0
+Ldone:
+ fmoved fp0,sp@-
+ movel sp@+,d0
+ movel sp@+,d1
+ rts
diff --git a/lib/libm/arch/mc68881/s_sin.S b/lib/libm/arch/mc68881/s_sin.S
new file mode 100644
index 00000000000..3bb264a6028
--- /dev/null
+++ b/lib/libm/arch/mc68881/s_sin.S
@@ -0,0 +1,50 @@
+/*-
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * the Systems Programming Group of the University of Utah Computer
+ * Science Department.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/asm.h>
+
+;_sccsid:
+;.asciz "from: @(#)sincos.s 5.1 (Berkeley) 5/17/90"
+
+RCSID("$NetBSD: s_sin.S,v 1.3 1995/05/10 20:44:22 jtc Exp $")
+
+ENTRY(sin)
+ fsind sp@(4),fp0
+ fmoved fp0,sp@-
+ movel sp@+,d0
+ movel sp@+,d1
+ rts
diff --git a/lib/libm/arch/mc68881/s_tan.S b/lib/libm/arch/mc68881/s_tan.S
new file mode 100644
index 00000000000..d55fadb84d7
--- /dev/null
+++ b/lib/libm/arch/mc68881/s_tan.S
@@ -0,0 +1,50 @@
+/*-
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * the Systems Programming Group of the University of Utah Computer
+ * Science Department.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/asm.h>
+
+;_sccsid:
+;.asciz "from: @(#)tan.s 5.1 (Berkeley) 5/17/90"
+
+RCSID("$NetBSD: s_tan.S,v 1.3 1995/05/10 20:44:25 jtc Exp $")
+
+ENTRY(tan)
+ ftand sp@(4),fp0
+ fmoved fp0,sp@-
+ movel sp@+,d0
+ movel sp@+,d1
+ rts
diff --git a/lib/libm/arch/mc68881/s_tanh.S b/lib/libm/arch/mc68881/s_tanh.S
new file mode 100644
index 00000000000..2d4a153d203
--- /dev/null
+++ b/lib/libm/arch/mc68881/s_tanh.S
@@ -0,0 +1,50 @@
+/*-
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * the Systems Programming Group of the University of Utah Computer
+ * Science Department.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/asm.h>
+
+;_sccsid:
+;.asciz "from: @(#)tanh.s 5.1 (Berkeley) 5/17/90"
+
+RCSID("$NetBSD: s_tanh.S,v 1.3 1995/05/10 20:44:26 jtc Exp $")
+
+ENTRY(tanh)
+ ftanhd sp@(4),fp0
+ fmoved fp0,sp@-
+ movel sp@+,d0
+ movel sp@+,d1
+ rts
diff --git a/lib/libm/arch/vax/n_argred.S b/lib/libm/arch/vax/n_argred.S
new file mode 100644
index 00000000000..a25922b26cf
--- /dev/null
+++ b/lib/libm/arch/vax/n_argred.S
@@ -0,0 +1,792 @@
+/* $NetBSD: n_argred.S,v 1.1 1995/10/10 23:40:21 ragge Exp $ */
+/*
+ * Copyright (c) 1985, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)argred.s 8.1 (Berkeley) 6/4/93
+ */
+
+/*
+ * libm$argred implements Bob Corbett's argument reduction and
+ * libm$sincos implements Peter Tang's double precision sin/cos.
+ *
+ * Note: The two entry points libm$argred and libm$sincos are meant
+ * to be used only by _sin, _cos and _tan.
+ *
+ * method: true range reduction to [-pi/4,pi/4], P. Tang & B. Corbett
+ * S. McDonald, April 4, 1985
+ */
+ .globl libm$argred
+ .globl libm$sincos
+ .text
+ .align 1
+
+libm$argred:
+/*
+ * Compare the argument with the largest possible that can
+ * be reduced by table lookup. r3 := |x| will be used in table_lookup .
+ */
+ movd r0,r3
+ bgeq abs1
+ mnegd r3,r3
+abs1:
+ cmpd r3,$0d+4.55530934770520019583e+01
+ blss small_arg
+ jsb trigred
+ rsb
+small_arg:
+ jsb table_lookup
+ rsb
+/*
+ * At this point,
+ * r0 contains the quadrant number, 0, 1, 2, or 3;
+ * r2/r1 contains the reduced argument as a D-format number;
+ * r3 contains a F-format extension to the reduced argument;
+ * r4 contains a 0 or 1 corresponding to a sin or cos entry.
+ */
+libm$sincos:
+/*
+ * Compensate for a cosine entry by adding one to the quadrant number.
+ */
+ addl2 r4,r0
+/*
+ * Polyd clobbers r5-r0 ; save X in r7/r6 .
+ * This can be avoided by rewriting trigred .
+ */
+ movd r1,r6
+/*
+ * Likewise, save alpha in r8 .
+ * This can be avoided by rewriting trigred .
+ */
+ movf r3,r8
+/*
+ * Odd or even quadrant? cosine if odd, sine otherwise.
+ * Save floor(quadrant/2) in r9 ; it determines the final sign.
+ */
+ rotl $-1,r0,r9
+ blss cosine
+sine:
+ muld2 r1,r1 # Xsq = X * X
+ cmpw $0x2480,r1 # [zl] Xsq > 2^-56?
+ blss 1f # [zl] yes, go ahead and do polyd
+ clrq r1 # [zl] work around 11/780 FPA polyd bug
+1:
+ polyd r1,$7,sin_coef # Q = P(Xsq) , of deg 7
+ mulf3 $0f3.0,r8,r4 # beta = 3 * alpha
+ mulf2 r0,r4 # beta = Q * beta
+ addf2 r8,r4 # beta = alpha + beta
+ muld2 r6,r0 # S(X) = X * Q
+/* cvtfd r4,r4 ... r5 = 0 after a polyd. */
+ addd2 r4,r0 # S(X) = beta + S(X)
+ addd2 r6,r0 # S(X) = X + S(X)
+ brb done
+cosine:
+ muld2 r6,r6 # Xsq = X * X
+ beql zero_arg
+ mulf2 r1,r8 # beta = X * alpha
+ polyd r6,$7,cos_coef /* Q = P'(Xsq) , of deg 7 */
+ subd3 r0,r8,r0 # beta = beta - Q
+ subw2 $0x80,r6 # Xsq = Xsq / 2
+ addd2 r0,r6 # Xsq = Xsq + beta
+zero_arg:
+ subd3 r6,$0d1.0,r0 # C(X) = 1 - Xsq
+done:
+ blbc r9,even
+ mnegd r0,r0
+even:
+ rsb
+
+.data
+.align 2
+
+sin_coef:
+ .double 0d-7.53080332264191085773e-13 # s7 = 2^-29 -1.a7f2504ffc49f8..
+ .double 0d+1.60573519267703489121e-10 # s6 = 2^-21 1.611adaede473c8..
+ .double 0d-2.50520965150706067211e-08 # s5 = 2^-1a -1.ae644921ed8382..
+ .double 0d+2.75573191800593885716e-06 # s4 = 2^-13 1.71de3a4b884278..
+ .double 0d-1.98412698411850507950e-04 # s3 = 2^-0d -1.a01a01a0125e7d..
+ .double 0d+8.33333333333325688985e-03 # s2 = 2^-07 1.11111111110e50
+ .double 0d-1.66666666666666664354e-01 # s1 = 2^-03 -1.55555555555554
+ .double 0d+0.00000000000000000000e+00 # s0 = 0
+
+cos_coef:
+ .double 0d-1.13006966202629430300e-11 # s7 = 2^-25 -1.8D9BA04D1374BE..
+ .double 0d+2.08746646574796004700e-09 # s6 = 2^-1D 1.1EE632650350BA..
+ .double 0d-2.75573073031284417300e-07 # s5 = 2^-16 -1.27E4F31411719E..
+ .double 0d+2.48015872682668025200e-05 # s4 = 2^-10 1.A01A0196B902E8..
+ .double 0d-1.38888888888464709200e-03 # s3 = 2^-0A -1.6C16C16C11FACE..
+ .double 0d+4.16666666666664761400e-02 # s2 = 2^-05 1.5555555555539E
+ .double 0d+0.00000000000000000000e+00 # s1 = 0
+ .double 0d+0.00000000000000000000e+00 # s0 = 0
+
+/*
+ * Multiples of pi/2 expressed as the sum of three doubles,
+ *
+ * trailing: n * pi/2 , n = 0, 1, 2, ..., 29
+ * trailing[n] ,
+ *
+ * middle: n * pi/2 , n = 0, 1, 2, ..., 29
+ * middle[n] ,
+ *
+ * leading: n * pi/2 , n = 0, 1, 2, ..., 29
+ * leading[n] ,
+ *
+ * where
+ * leading[n] := (n * pi/2) rounded,
+ * middle[n] := (n * pi/2 - leading[n]) rounded,
+ * trailing[n] := (( n * pi/2 - leading[n]) - middle[n]) rounded .
+ */
+trailing:
+ .double 0d+0.00000000000000000000e+00 # 0 * pi/2 trailing
+ .double 0d+4.33590506506189049611e-35 # 1 * pi/2 trailing
+ .double 0d+8.67181013012378099223e-35 # 2 * pi/2 trailing
+ .double 0d+1.30077151951856714215e-34 # 3 * pi/2 trailing
+ .double 0d+1.73436202602475619845e-34 # 4 * pi/2 trailing
+ .double 0d-1.68390735624352669192e-34 # 5 * pi/2 trailing
+ .double 0d+2.60154303903713428430e-34 # 6 * pi/2 trailing
+ .double 0d-8.16726343231148352150e-35 # 7 * pi/2 trailing
+ .double 0d+3.46872405204951239689e-34 # 8 * pi/2 trailing
+ .double 0d+3.90231455855570147991e-34 # 9 * pi/2 trailing
+ .double 0d-3.36781471248705338384e-34 # 10 * pi/2 trailing
+ .double 0d-1.06379439835298071785e-33 # 11 * pi/2 trailing
+ .double 0d+5.20308607807426856861e-34 # 12 * pi/2 trailing
+ .double 0d+5.63667658458045770509e-34 # 13 * pi/2 trailing
+ .double 0d-1.63345268646229670430e-34 # 14 * pi/2 trailing
+ .double 0d-1.19986217995610764801e-34 # 15 * pi/2 trailing
+ .double 0d+6.93744810409902479378e-34 # 16 * pi/2 trailing
+ .double 0d-8.03640094449267300110e-34 # 17 * pi/2 trailing
+ .double 0d+7.80462911711140295982e-34 # 18 * pi/2 trailing
+ .double 0d-7.16921993148029483506e-34 # 19 * pi/2 trailing
+ .double 0d-6.73562942497410676769e-34 # 20 * pi/2 trailing
+ .double 0d-6.30203891846791677593e-34 # 21 * pi/2 trailing
+ .double 0d-2.12758879670596143570e-33 # 22 * pi/2 trailing
+ .double 0d+2.53800212047402350390e-33 # 23 * pi/2 trailing
+ .double 0d+1.04061721561485371372e-33 # 24 * pi/2 trailing
+ .double 0d+6.11729905311472319056e-32 # 25 * pi/2 trailing
+ .double 0d+1.12733531691609154102e-33 # 26 * pi/2 trailing
+ .double 0d-3.70049587943078297272e-34 # 27 * pi/2 trailing
+ .double 0d-3.26690537292459340860e-34 # 28 * pi/2 trailing
+ .double 0d-1.14812616507957271361e-34 # 29 * pi/2 trailing
+
+middle:
+ .double 0d+0.00000000000000000000e+00 # 0 * pi/2 middle
+ .double 0d+5.72118872610983179676e-18 # 1 * pi/2 middle
+ .double 0d+1.14423774522196635935e-17 # 2 * pi/2 middle
+ .double 0d-3.83475850529283316309e-17 # 3 * pi/2 middle
+ .double 0d+2.28847549044393271871e-17 # 4 * pi/2 middle
+ .double 0d-2.69052076007086676522e-17 # 5 * pi/2 middle
+ .double 0d-7.66951701058566632618e-17 # 6 * pi/2 middle
+ .double 0d-1.54628301484890040587e-17 # 7 * pi/2 middle
+ .double 0d+4.57695098088786543741e-17 # 8 * pi/2 middle
+ .double 0d+1.07001849766246313192e-16 # 9 * pi/2 middle
+ .double 0d-5.38104152014173353044e-17 # 10 * pi/2 middle
+ .double 0d-2.14622680169080983801e-16 # 11 * pi/2 middle
+ .double 0d-1.53390340211713326524e-16 # 12 * pi/2 middle
+ .double 0d-9.21580002543456677056e-17 # 13 * pi/2 middle
+ .double 0d-3.09256602969780081173e-17 # 14 * pi/2 middle
+ .double 0d+3.03066796603896507006e-17 # 15 * pi/2 middle
+ .double 0d+9.15390196177573087482e-17 # 16 * pi/2 middle
+ .double 0d+1.52771359575124969107e-16 # 17 * pi/2 middle
+ .double 0d+2.14003699532492626384e-16 # 18 * pi/2 middle
+ .double 0d-1.68853170360202329427e-16 # 19 * pi/2 middle
+ .double 0d-1.07620830402834670609e-16 # 20 * pi/2 middle
+ .double 0d+3.97700719404595604379e-16 # 21 * pi/2 middle
+ .double 0d-4.29245360338161967602e-16 # 22 * pi/2 middle
+ .double 0d-3.68013020380794313406e-16 # 23 * pi/2 middle
+ .double 0d-3.06780680423426653047e-16 # 24 * pi/2 middle
+ .double 0d-2.45548340466059054318e-16 # 25 * pi/2 middle
+ .double 0d-1.84316000508691335411e-16 # 26 * pi/2 middle
+ .double 0d-1.23083660551323675053e-16 # 27 * pi/2 middle
+ .double 0d-6.18513205939560162346e-17 # 28 * pi/2 middle
+ .double 0d-6.18980636588357585202e-19 # 29 * pi/2 middle
+
+leading:
+ .double 0d+0.00000000000000000000e+00 # 0 * pi/2 leading
+ .double 0d+1.57079632679489661351e+00 # 1 * pi/2 leading
+ .double 0d+3.14159265358979322702e+00 # 2 * pi/2 leading
+ .double 0d+4.71238898038468989604e+00 # 3 * pi/2 leading
+ .double 0d+6.28318530717958645404e+00 # 4 * pi/2 leading
+ .double 0d+7.85398163397448312306e+00 # 5 * pi/2 leading
+ .double 0d+9.42477796076937979208e+00 # 6 * pi/2 leading
+ .double 0d+1.09955742875642763501e+01 # 7 * pi/2 leading
+ .double 0d+1.25663706143591729081e+01 # 8 * pi/2 leading
+ .double 0d+1.41371669411540694661e+01 # 9 * pi/2 leading
+ .double 0d+1.57079632679489662461e+01 # 10 * pi/2 leading
+ .double 0d+1.72787595947438630262e+01 # 11 * pi/2 leading
+ .double 0d+1.88495559215387595842e+01 # 12 * pi/2 leading
+ .double 0d+2.04203522483336561422e+01 # 13 * pi/2 leading
+ .double 0d+2.19911485751285527002e+01 # 14 * pi/2 leading
+ .double 0d+2.35619449019234492582e+01 # 15 * pi/2 leading
+ .double 0d+2.51327412287183458162e+01 # 16 * pi/2 leading
+ .double 0d+2.67035375555132423742e+01 # 17 * pi/2 leading
+ .double 0d+2.82743338823081389322e+01 # 18 * pi/2 leading
+ .double 0d+2.98451302091030359342e+01 # 19 * pi/2 leading
+ .double 0d+3.14159265358979324922e+01 # 20 * pi/2 leading
+ .double 0d+3.29867228626928286062e+01 # 21 * pi/2 leading
+ .double 0d+3.45575191894877260523e+01 # 22 * pi/2 leading
+ .double 0d+3.61283155162826226103e+01 # 23 * pi/2 leading
+ .double 0d+3.76991118430775191683e+01 # 24 * pi/2 leading
+ .double 0d+3.92699081698724157263e+01 # 25 * pi/2 leading
+ .double 0d+4.08407044966673122843e+01 # 26 * pi/2 leading
+ .double 0d+4.24115008234622088423e+01 # 27 * pi/2 leading
+ .double 0d+4.39822971502571054003e+01 # 28 * pi/2 leading
+ .double 0d+4.55530934770520019583e+01 # 29 * pi/2 leading
+
+twoOverPi:
+ .double 0d+6.36619772367581343076e-01
+ .text
+ .align 1
+
+table_lookup:
+ muld3 r3,twoOverPi,r0
+ cvtrdl r0,r0 # n = nearest int to ((2/pi)*|x|) rnded
+ mull3 $8,r0,r5
+ subd2 leading(r5),r3 # p = (|x| - leading n*pi/2) exactly
+ subd3 middle(r5),r3,r1 # q = (p - middle n*pi/2) rounded
+ subd2 r1,r3 # r = (p - q)
+ subd2 middle(r5),r3 # r = r - middle n*pi/2
+ subd2 trailing(r5),r3 # r = r - trailing n*pi/2 rounded
+/*
+ * If the original argument was negative,
+ * negate the reduce argument and
+ * adjust the octant/quadrant number.
+ */
+ tstw 4(ap)
+ bgeq abs2
+ mnegf r1,r1
+ mnegf r3,r3
+/* subb3 r0,$8,r0 ...used for pi/4 reduction -S.McD */
+ subb3 r0,$4,r0
+abs2:
+/*
+ * Clear all unneeded octant/quadrant bits.
+ */
+/* bicb2 $0xf8,r0 ...used for pi/4 reduction -S.McD */
+ bicb2 $0xfc,r0
+ rsb
+/*
+ * p.0
+ */
+ .text
+ .align 2
+/*
+ * Only 256 (actually 225) bits of 2/pi are needed for VAX double
+ * precision; this was determined by enumerating all the nearest
+ * machine integer multiples of pi/2 using continued fractions.
+ * (8a8d3673775b7ff7 required the most bits.) -S.McD
+ */
+ .long 0
+ .long 0
+ .long 0xaef1586d
+ .long 0x9458eaf7
+ .long 0x10e4107f
+ .long 0xd8a5664f
+ .long 0x4d377036
+ .long 0x09d5f47d
+ .long 0x91054a7f
+ .long 0xbe60db93
+bits2opi:
+ .long 0x00000028
+ .long 0
+/*
+ * Note: wherever you see the word `octant', read `quadrant'.
+ * Currently this code is set up for pi/2 argument reduction.
+ * By uncommenting/commenting the appropriate lines, it will
+ * also serve as a pi/4 argument reduction code.
+ */
+
+/* p.1
+ * Trigred preforms argument reduction
+ * for the trigonometric functions. It
+ * takes one input argument, a D-format
+ * number in r1/r0 . The magnitude of
+ * the input argument must be greater
+ * than or equal to 1/2 . Trigred produces
+ * three results: the number of the octant
+ * occupied by the argument, the reduced
+ * argument, and an extension of the
+ * reduced argument. The octant number is
+ * returned in r0 . The reduced argument
+ * is returned as a D-format number in
+ * r2/r1 . An 8 bit extension of the
+ * reduced argument is returned as an
+ * F-format number in r3.
+ * p.2
+ */
+trigred:
+/*
+ * Save the sign of the input argument.
+ */
+ movw r0,-(sp)
+/*
+ * Extract the exponent field.
+ */
+ extzv $7,$7,r0,r2
+/*
+ * Convert the fraction part of the input
+ * argument into a quadword integer.
+ */
+ bicw2 $0xff80,r0
+ bisb2 $0x80,r0 # -S.McD
+ rotl $16,r0,r0
+ rotl $16,r1,r1
+/*
+ * If r1 is negative, add 1 to r0 . This
+ * adjustment is made so that the two's
+ * complement multiplications done later
+ * will produce unsigned results.
+ */
+ bgeq posmid
+ incl r0
+posmid:
+/* p.3
+ *
+ * Set r3 to the address of the first quadword
+ * used to obtain the needed portion of 2/pi .
+ * The address is longword aligned to ensure
+ * efficient access.
+ */
+ ashl $-3,r2,r3
+ bicb2 $3,r3
+ subl3 r3,$bits2opi,r3
+/*
+ * Set r2 to the size of the shift needed to
+ * obtain the correct portion of 2/pi .
+ */
+ bicb2 $0xe0,r2
+/* p.4
+ *
+ * Move the needed 128 bits of 2/pi into
+ * r11 - r8 . Adjust the numbers to allow
+ * for unsigned multiplication.
+ */
+ ashq r2,(r3),r10
+
+ subl2 $4,r3
+ ashq r2,(r3),r9
+ bgeq signoff1
+ incl r11
+signoff1:
+ subl2 $4,r3
+ ashq r2,(r3),r8
+ bgeq signoff2
+ incl r10
+signoff2:
+ subl2 $4,r3
+ ashq r2,(r3),r7
+ bgeq signoff3
+ incl r9
+signoff3:
+/* p.5
+ *
+ * Multiply the contents of r0/r1 by the
+ * slice of 2/pi in r11 - r8 .
+ */
+ emul r0,r8,$0,r4
+ emul r0,r9,r5,r5
+ emul r0,r10,r6,r6
+
+ emul r1,r8,$0,r7
+ emul r1,r9,r8,r8
+ emul r1,r10,r9,r9
+ emul r1,r11,r10,r10
+
+ addl2 r4,r8
+ adwc r5,r9
+ adwc r6,r10
+/* p.6
+ *
+ * If there are more than five leading zeros
+ * after the first two quotient bits or if there
+ * are more than five leading ones after the first
+ * two quotient bits, generate more fraction bits.
+ * Otherwise, branch to code to produce the result.
+ */
+ bicl3 $0xc1ffffff,r10,r4
+ beql more1
+ cmpl $0x3e000000,r4
+ bneq result
+more1:
+/* p.7
+ *
+ * generate another 32 result bits.
+ */
+ subl2 $4,r3
+ ashq r2,(r3),r5
+ bgeq signoff4
+
+ emul r1,r6,$0,r4
+ addl2 r1,r5
+ emul r0,r6,r5,r5
+ addl2 r0,r6
+ brb addbits1
+
+signoff4:
+ emul r1,r6,$0,r4
+ emul r0,r6,r5,r5
+
+addbits1:
+ addl2 r5,r7
+ adwc r6,r8
+ adwc $0,r9
+ adwc $0,r10
+/* p.8
+ *
+ * Check for massive cancellation.
+ */
+ bicl3 $0xc0000000,r10,r6
+/* bneq more2 -S.McD Test was backwards */
+ beql more2
+ cmpl $0x3fffffff,r6
+ bneq result
+more2:
+/* p.9
+ *
+ * If massive cancellation has occurred,
+ * generate another 24 result bits.
+ * Testing has shown there will always be
+ * enough bits after this point.
+ */
+ subl2 $4,r3
+ ashq r2,(r3),r5
+ bgeq signoff5
+
+ emul r0,r6,r4,r5
+ addl2 r0,r6
+ brb addbits2
+
+signoff5:
+ emul r0,r6,r4,r5
+
+addbits2:
+ addl2 r6,r7
+ adwc $0,r8
+ adwc $0,r9
+ adwc $0,r10
+/* p.10
+ *
+ * The following code produces the reduced
+ * argument from the product bits contained
+ * in r10 - r7 .
+ */
+result:
+/*
+ * Extract the octant number from r10 .
+ */
+/* extzv $29,$3,r10,r0 ...used for pi/4 reduction -S.McD */
+ extzv $30,$2,r10,r0
+/*
+ * Clear the octant bits in r10 .
+ */
+/* bicl2 $0xe0000000,r10 ...used for pi/4 reduction -S.McD */
+ bicl2 $0xc0000000,r10
+/*
+ * Zero the sign flag.
+ */
+ clrl r5
+/* p.11
+ *
+ * Check to see if the fraction is greater than
+ * or equal to one-half. If it is, add one
+ * to the octant number, set the sign flag
+ * on, and replace the fraction with 1 minus
+ * the fraction.
+ */
+/* bitl $0x10000000,r10 ...used for pi/4 reduction -S.McD */
+ bitl $0x20000000,r10
+ beql small
+ incl r0
+ incl r5
+/* subl3 r10,$0x1fffffff,r10 ...used for pi/4 reduction -S.McD */
+ subl3 r10,$0x3fffffff,r10
+ mcoml r9,r9
+ mcoml r8,r8
+ mcoml r7,r7
+small:
+/* p.12
+ *
+ * Test whether the first 29 bits of the ...used for pi/4 reduction -S.McD
+ * Test whether the first 30 bits of the
+ * fraction are zero.
+ */
+ tstl r10
+ beql tiny
+/*
+ * Find the position of the first one bit in r10 .
+ */
+ cvtld r10,r1
+ extzv $7,$7,r1,r1
+/*
+ * Compute the size of the shift needed.
+ */
+ subl3 r1,$32,r6
+/*
+ * Shift up the high order 64 bits of the
+ * product.
+ */
+ ashq r6,r9,r10
+ ashq r6,r8,r9
+ brb mult
+/* p.13
+ *
+ * Test to see if the sign bit of r9 is on.
+ */
+tiny:
+ tstl r9
+ bgeq tinier
+/*
+ * If it is, shift the product bits up 32 bits.
+ */
+ movl $32,r6
+ movq r8,r10
+ tstl r10
+ brb mult
+/* p.14
+ *
+ * Test whether r9 is zero. It is probably
+ * impossible for both r10 and r9 to be
+ * zero, but until proven to be so, the test
+ * must be made.
+ */
+tinier:
+ beql zero
+/*
+ * Find the position of the first one bit in r9 .
+ */
+ cvtld r9,r1
+ extzv $7,$7,r1,r1
+/*
+ * Compute the size of the shift needed.
+ */
+ subl3 r1,$32,r1
+ addl3 $32,r1,r6
+/*
+ * Shift up the high order 64 bits of the
+ * product.
+ */
+ ashq r1,r8,r10
+ ashq r1,r7,r9
+ brb mult
+/* p.15
+ *
+ * The following code sets the reduced
+ * argument to zero.
+ */
+zero:
+ clrl r1
+ clrl r2
+ clrl r3
+ brw return
+/* p.16
+ *
+ * At this point, r0 contains the octant number,
+ * r6 indicates the number of bits the fraction
+ * has been shifted, r5 indicates the sign of
+ * the fraction, r11/r10 contain the high order
+ * 64 bits of the fraction, and the condition
+ * codes indicate where the sign bit of r10
+ * is on. The following code multiplies the
+ * fraction by pi/2 .
+ */
+mult:
+/*
+ * Save r11/r10 in r4/r1 . -S.McD
+ */
+ movl r11,r4
+ movl r10,r1
+/*
+ * If the sign bit of r10 is on, add 1 to r11 .
+ */
+ bgeq signoff6
+ incl r11
+signoff6:
+/* p.17
+ *
+ * Move pi/2 into r3/r2 .
+ */
+ movq $0xc90fdaa22168c235,r2
+/*
+ * Multiply the fraction by the portion of pi/2
+ * in r2 .
+ */
+ emul r2,r10,$0,r7
+ emul r2,r11,r8,r7
+/*
+ * Multiply the fraction by the portion of pi/2
+ * in r3 .
+ */
+ emul r3,r10,$0,r9
+ emul r3,r11,r10,r10
+/*
+ * Add the product bits together.
+ */
+ addl2 r7,r9
+ adwc r8,r10
+ adwc $0,r11
+/*
+ * Compensate for not sign extending r8 above.-S.McD
+ */
+ tstl r8
+ bgeq signoff6a
+ decl r11
+signoff6a:
+/*
+ * Compensate for r11/r10 being unsigned. -S.McD
+ */
+ addl2 r2,r10
+ adwc r3,r11
+/*
+ * Compensate for r3/r2 being unsigned. -S.McD
+ */
+ addl2 r1,r10
+ adwc r4,r11
+/* p.18
+ *
+ * If the sign bit of r11 is zero, shift the
+ * product bits up one bit and increment r6 .
+ */
+ blss signon
+ incl r6
+ ashq $1,r10,r10
+ tstl r9
+ bgeq signoff7
+ incl r10
+signoff7:
+signon:
+/* p.19
+ *
+ * Shift the 56 most significant product
+ * bits into r9/r8 . The sign extension
+ * will be handled later.
+ */
+ ashq $-8,r10,r8
+/*
+ * Convert the low order 8 bits of r10
+ * into an F-format number.
+ */
+ cvtbf r10,r3
+/*
+ * If the result of the conversion was
+ * negative, add 1 to r9/r8 .
+ */
+ bgeq chop
+ incl r8
+ adwc $0,r9
+/*
+ * If r9 is now zero, branch to special
+ * code to handle that possibility.
+ */
+ beql carryout
+chop:
+/* p.20
+ *
+ * Convert the number in r9/r8 into
+ * D-format number in r2/r1 .
+ */
+ rotl $16,r8,r2
+ rotl $16,r9,r1
+/*
+ * Set the exponent field to the appropriate
+ * value. Note that the extra bits created by
+ * sign extension are now eliminated.
+ */
+ subw3 r6,$131,r6
+ insv r6,$7,$9,r1
+/*
+ * Set the exponent field of the F-format
+ * number in r3 to the appropriate value.
+ */
+ tstf r3
+ beql return
+/* extzv $7,$8,r3,r4 -S.McD */
+ extzv $7,$7,r3,r4
+ addw2 r4,r6
+/* subw2 $217,r6 -S.McD */
+ subw2 $64,r6
+ insv r6,$7,$8,r3
+ brb return
+/* p.21
+ *
+ * The following code generates the appropriate
+ * result for the unlikely possibility that
+ * rounding the number in r9/r8 resulted in
+ * a carry out.
+ */
+carryout:
+ clrl r1
+ clrl r2
+ subw3 r6,$132,r6
+ insv r6,$7,$9,r1
+ tstf r3
+ beql return
+ extzv $7,$8,r3,r4
+ addw2 r4,r6
+ subw2 $218,r6
+ insv r6,$7,$8,r3
+/* p.22
+ *
+ * The following code makes an needed
+ * adjustments to the signs of the
+ * results or to the octant number, and
+ * then returns.
+ */
+return:
+/*
+ * Test if the fraction was greater than or
+ * equal to 1/2 . If so, negate the reduced
+ * argument.
+ */
+ blbc r5,signoff8
+ mnegf r1,r1
+ mnegf r3,r3
+signoff8:
+/* p.23
+ *
+ * If the original argument was negative,
+ * negate the reduce argument and
+ * adjust the octant number.
+ */
+ tstw (sp)+
+ bgeq signoff9
+ mnegf r1,r1
+ mnegf r3,r3
+/* subb3 r0,$8,r0 ...used for pi/4 reduction -S.McD */
+ subb3 r0,$4,r0
+signoff9:
+/*
+ * Clear all unneeded octant bits.
+ *
+ * bicb2 $0xf8,r0 ...used for pi/4 reduction -S.McD */
+ bicb2 $0xfc,r0
+/*
+ * Return.
+ */
+ rsb
diff --git a/lib/libm/arch/vax/n_atan2.S b/lib/libm/arch/vax/n_atan2.S
new file mode 100644
index 00000000000..a3c271a9640
--- /dev/null
+++ b/lib/libm/arch/vax/n_atan2.S
@@ -0,0 +1,219 @@
+/* $NetBSD: n_atan2.S,v 1.1 1995/10/10 23:40:25 ragge Exp $ */
+/*
+ * Copyright (c) 1985, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)atan2.s 8.1 (Berkeley) 6/4/93
+ */
+
+/*
+ * ATAN2(Y,X)
+ * RETURN ARG (X+iY)
+ * VAX D FORMAT (56 BITS PRECISION)
+ * CODED IN VAX ASSEMBLY LANGUAGE BY K.C. NG, 4/16/85;
+ *
+ *
+ * Method :
+ * 1. Reduce y to positive by atan2(y,x)=-atan2(-y,x).
+ * 2. Reduce x to positive by (if x and y are unexceptional):
+ * ARG (x+iy) = arctan(y/x) ... if x > 0,
+ * ARG (x+iy) = pi - arctan[y/(-x)] ... if x < 0,
+ * 3. According to the integer k=4t+0.25 truncated , t=y/x, the argument
+ * is further reduced to one of the following intervals and the
+ * arctangent of y/x is evaluated by the corresponding formula:
+ *
+ * [0,7/16] atan(y/x) = t - t^3*(a1+t^2*(a2+...(a10+t^2*a11)...)
+ * [7/16,11/16] atan(y/x) = atan(1/2) + atan( (y-x/2)/(x+y/2) )
+ * [11/16.19/16] atan(y/x) = atan( 1 ) + atan( (y-x)/(x+y) )
+ * [19/16,39/16] atan(y/x) = atan(3/2) + atan( (y-1.5x)/(x+1.5y) )
+ * [39/16,INF] atan(y/x) = atan(INF) + atan( -x/y )
+ *
+ * Special cases:
+ * Notations: atan2(y,x) == ARG (x+iy) == ARG(x,y).
+ *
+ * ARG( NAN , (anything) ) is NaN;
+ * ARG( (anything), NaN ) is NaN;
+ * ARG(+(anything but NaN), +-0) is +-0 ;
+ * ARG(-(anything but NaN), +-0) is +-PI ;
+ * ARG( 0, +-(anything but 0 and NaN) ) is +-PI/2;
+ * ARG( +INF,+-(anything but INF and NaN) ) is +-0 ;
+ * ARG( -INF,+-(anything but INF and NaN) ) is +-PI;
+ * ARG( +INF,+-INF ) is +-PI/4 ;
+ * ARG( -INF,+-INF ) is +-3PI/4;
+ * ARG( (anything but,0,NaN, and INF),+-INF ) is +-PI/2;
+ *
+ * Accuracy:
+ * atan2(y,x) returns the exact ARG(x+iy) nearly rounded.
+ */
+
+ .text
+ .align 1
+ .globl _atan2
+_atan2 :
+ .word 0x0ff4
+ movq 4(ap),r2 # r2 = y
+ movq 12(ap),r4 # r4 = x
+ bicw3 $0x7f,r2,r0
+ bicw3 $0x7f,r4,r1
+ cmpw r0,$0x8000 # y is the reserved operand
+ jeql resop
+ cmpw r1,$0x8000 # x is the reserved operand
+ jeql resop
+ subl2 $8,sp
+ bicw3 $0x7fff,r2,-4(fp) # copy y sign bit to -4(fp)
+ bicw3 $0x7fff,r4,-8(fp) # copy x sign bit to -8(fp)
+ cmpd r4,$0x4080 # x = 1.0 ?
+ bneq xnot1
+ movq r2,r0
+ bicw2 $0x8000,r0 # t = |y|
+ movq r0,r2 # y = |y|
+ brb begin
+xnot1:
+ bicw3 $0x807f,r2,r11 # yexp
+ jeql yeq0 # if y=0 goto yeq0
+ bicw3 $0x807f,r4,r10 # xexp
+ jeql pio2 # if x=0 goto pio2
+ subw2 r10,r11 # k = yexp - xexp
+ cmpw r11,$0x2000 # k >= 64 (exp) ?
+ jgeq pio2 # atan2 = +-pi/2
+ divd3 r4,r2,r0 # t = y/x never overflow
+ bicw2 $0x8000,r0 # t > 0
+ bicw2 $0xff80,r2 # clear the exponent of y
+ bicw2 $0xff80,r4 # clear the exponent of x
+ bisw2 $0x4080,r2 # normalize y to [1,2)
+ bisw2 $0x4080,r4 # normalize x to [1,2)
+ subw2 r11,r4 # scale x so that yexp-xexp=k
+begin:
+ cmpw r0,$0x411c # t : 39/16
+ jgeq L50
+ addl3 $0x180,r0,r10 # 8*t
+ cvtrfl r10,r10 # [8*t] rounded to int
+ ashl $-1,r10,r10 # [8*t]/2
+ casel r10,$0,$4
+L1:
+ .word L20-L1
+ .word L20-L1
+ .word L30-L1
+ .word L40-L1
+ .word L40-L1
+L10:
+ movq $0xb4d9940f985e407b,r6 # Hi=.98279372324732906796d0
+ movq $0x21b1879a3bc2a2fc,r8 # Lo=-.17092002525602665777d-17
+ subd3 r4,r2,r0 # y-x
+ addw2 $0x80,r0 # 2(y-x)
+ subd2 r4,r0 # 2(y-x)-x
+ addw2 $0x80,r4 # 2x
+ movq r2,r10
+ addw2 $0x80,r10 # 2y
+ addd2 r10,r2 # 3y
+ addd2 r4,r2 # 3y+2x
+ divd2 r2,r0 # (2y-3x)/(2x+3y)
+ brw L60
+L20:
+ cmpw r0,$0x3280 # t : 2**(-28)
+ jlss L80
+ clrq r6 # Hi=r6=0, Lo=r8=0
+ clrq r8
+ brw L60
+L30:
+ movq $0xda7b2b0d63383fed,r6 # Hi=.46364760900080611433d0
+ movq $0xf0ea17b2bf912295,r8 # Lo=.10147340032515978826d-17
+ movq r2,r0
+ addw2 $0x80,r0 # 2y
+ subd2 r4,r0 # 2y-x
+ addw2 $0x80,r4 # 2x
+ addd2 r2,r4 # 2x+y
+ divd2 r4,r0 # (2y-x)/(2x+y)
+ brb L60
+L50:
+ movq $0x68c2a2210fda40c9,r6 # Hi=1.5707963267948966135d1
+ movq $0x06e0145c26332326,r8 # Lo=.22517417741562176079d-17
+ cmpw r0,$0x5100 # y : 2**57
+ bgeq L90
+ divd3 r2,r4,r0
+ bisw2 $0x8000,r0 # -x/y
+ brb L60
+L40:
+ movq $0x68c2a2210fda4049,r6 # Hi=.78539816339744830676d0
+ movq $0x06e0145c263322a6,r8 # Lo=.11258708870781088040d-17
+ subd3 r4,r2,r0 # y-x
+ addd2 r4,r2 # y+x
+ divd2 r2,r0 # (y-x)/(y+x)
+L60:
+ movq r0,r10
+ muld2 r0,r0
+ polyd r0,$12,ptable
+ muld2 r10,r0
+ subd2 r0,r8
+ addd3 r8,r10,r0
+ addd2 r6,r0
+L80:
+ movw -8(fp),r2
+ bneq pim
+ bisw2 -4(fp),r0 # return sign(y)*r0
+ ret
+L90: # x >= 2**25
+ movq r6,r0
+ brb L80
+pim:
+ subd3 r0,$0x68c2a2210fda4149,r0 # pi-t
+ bisw2 -4(fp),r0
+ ret
+yeq0:
+ movw -8(fp),r2
+ beql zero # if sign(x)=1 return pi
+ movq $0x68c2a2210fda4149,r0 # pi=3.1415926535897932270d1
+ ret
+zero:
+ clrq r0 # return 0
+ ret
+pio2:
+ movq $0x68c2a2210fda40c9,r0 # pi/2=1.5707963267948966135d1
+ bisw2 -4(fp),r0 # return sign(y)*pi/2
+ ret
+resop:
+ movq $0x8000,r0 # propagate the reserved operand
+ ret
+ .align 2
+ptable:
+ .quad 0xb50f5ce96e7abd60
+ .quad 0x51e44a42c1073e02
+ .quad 0x3487e3289643be35
+ .quad 0xdb62066dffba3e54
+ .quad 0xcf8e2d5199abbe70
+ .quad 0x26f39cb884883e88
+ .quad 0x135117d18998be9d
+ .quad 0x602ce9742e883eba
+ .quad 0xa35ad0be8e38bee3
+ .quad 0xffac922249243f12
+ .quad 0x7f14ccccccccbf4c
+ .quad 0xaa8faaaaaaaa3faa
+ .quad 0x0000000000000000
diff --git a/lib/libm/arch/vax/n_cabs.S b/lib/libm/arch/vax/n_cabs.S
new file mode 100644
index 00000000000..10676fafe32
--- /dev/null
+++ b/lib/libm/arch/vax/n_cabs.S
@@ -0,0 +1,133 @@
+/* $NetBSD: n_cabs.S,v 1.1 1995/10/10 23:40:26 ragge Exp $ */
+/*
+ * Copyright (c) 1985, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)cabs.s 8.1 (Berkeley) 6/4/93
+ */
+
+/*
+ * double precision complex absolute value
+ * CABS by W. Kahan, 9/7/80.
+ * Revised for reserved operands by E. LeBlanc, 8/18/82
+ * argument for complex absolute value by reference, *4(ap)
+ * argument for cabs and hypot (C fcns) by value, 4(ap)
+ * output is in r0:r1 (error less than 0.86 ulps)
+ */
+
+ .text
+ .align 1
+ .globl _cabs
+ .globl _hypot
+ .globl _z_abs
+ .globl libm$cdabs_r6
+ .globl libm$dsqrt_r5
+
+/* entry for c functions cabs and hypot */
+_cabs:
+_hypot:
+ .word 0x807c # save r2-r6, enable floating overflow
+ movq 4(ap),r0 # r0:1 = x
+ movq 12(ap),r2 # r2:3 = y
+ jmp cabs2
+/* entry for Fortran use, call by: d = abs(z) */
+_z_abs:
+ .word 0x807c # save r2-r6, enable floating overflow
+ movl 4(ap),r2 # indirect addressing is necessary here
+ movq (r2)+,r0 # r0:1 = x
+ movq (r2),r2 # r2:3 = y
+
+cabs2:
+ bicw3 $0x7f,r0,r4 # r4 has signed biased exp of x
+ cmpw $0x8000,r4
+ jeql return # x is a reserved operand, so return it
+ bicw3 $0x7f,r2,r5 # r5 has signed biased exp of y
+ cmpw $0x8000,r5
+ jneq cont /* y isn't a reserved operand */
+ movq r2,r0 /* return y if it's reserved */
+ ret
+
+cont:
+ bsbb regs_set # r0:1 = dsqrt(x^2+y^2)/2^r6
+ addw2 r6,r0 # unscaled cdabs in r0:1
+ jvc return # unless it overflows
+ subw2 $0x80,r0 # halve r0 to get meaningful overflow
+ addd2 r0,r0 # overflow; r0 is half of true abs value
+return:
+ ret
+
+libm$cdabs_r6: # ENTRY POINT for cdsqrt
+ # calculates a scaled (factor in r6)
+ # complex absolute value
+
+ movq (r4)+,r0 # r0:r1 = x via indirect addressing
+ movq (r4),r2 # r2:r3 = y via indirect addressing
+
+ bicw3 $0x7f,r0,r5 # r5 has signed biased exp of x
+ cmpw $0x8000,r5
+ jeql cdreserved # x is a reserved operand
+ bicw3 $0x7f,r2,r5 # r5 has signed biased exp of y
+ cmpw $0x8000,r5
+ jneq regs_set /* y isn't a reserved operand either? */
+
+cdreserved:
+ movl *4(ap),r4 # r4 -> (u,v), if x or y is reserved
+ movq r0,(r4)+ # copy u and v as is and return
+ movq r2,(r4) # (again addressing is indirect)
+ ret
+
+regs_set:
+ bicw2 $0x8000,r0 # r0:r1 = dabs(x)
+ bicw2 $0x8000,r2 # r2:r3 = dabs(y)
+ cmpw r0,r2
+ jgeq ordered
+ movq r0,r4
+ movq r2,r0
+ movq r4,r2 # force y's exp <= x's exp
+ordered:
+ bicw3 $0x7f,r0,r6 # r6 = exponent(x) + bias(129)
+ jeql retsb # if x = y = 0 then cdabs(x,y) = 0
+ subw2 $0x4780,r6 # r6 = exponent(x) - 14
+ subw2 r6,r0 # 2^14 <= scaled x < 2^15
+ bitw $0xff80,r2
+ jeql retsb # if y = 0 return dabs(x)
+ subw2 r6,r2
+ cmpw $0x3780,r2 # if scaled y < 2^-18
+ jgtr retsb # return dabs(x)
+ emodd r0,$0,r0,r4,r0 # r4 + r0:1 = scaled x^2
+ emodd r2,$0,r2,r5,r2 # r5 + r2:3 = scaled y^2
+ addd2 r2,r0
+ addl2 r5,r4
+ cvtld r4,r2
+ addd2 r2,r0 # r0:1 = scaled x^2 + y^2
+ jmp libm$dsqrt_r5 # r0:1 = dsqrt(x^2+y^2)/2^r6
+retsb:
+ rsb # error < 0.86 ulp
diff --git a/lib/libm/arch/vax/n_cbrt.S b/lib/libm/arch/vax/n_cbrt.S
new file mode 100644
index 00000000000..37fc12cd82a
--- /dev/null
+++ b/lib/libm/arch/vax/n_cbrt.S
@@ -0,0 +1,101 @@
+/* $NetBSD: n_cbrt.S,v 1.1 1995/10/10 23:40:26 ragge Exp $ */
+/*
+ * Copyright (c) 1985, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)cbrt.s 8.1 (Berkeley) 6/4/93
+ */
+
+/*
+ * double cbrt(double arg)
+ * W. Kahan, 10/13/80. revised 1/13/84 for keeping sign symmetry
+ * error check by E LeBlanc, 8/18/82
+ * Revised and tested by K.C. Ng, 5/2/85
+ * Max error less than 0.667 ulps (unit in the last places)
+ */
+
+ .globl _cbrt
+ .globl _d_cbrt
+ .globl _dcbrt_
+ .text
+ .align 1
+
+_cbrt:
+_d_cbrt:
+ .word 0x00fc # save r2 to r7
+ movq 4(ap),r0 # r0 = argument x
+ jmp dcbrt2
+_dcbrt_:
+ .word 0x00fc # save r2 to r7
+ movq *4(ap),r0 # r0 = argument x
+
+dcbrt2: bicw3 $0x807f,r0,r2 # biased exponent of x
+ jeql return # dcbrt(0)=0 dcbrt(res)=res. operand
+ bicw3 $0x7fff,r0,ap # ap has sign(x)
+ xorw2 ap,r0 # r0 is abs(x)
+ movl r0,r2 # r2 has abs(x)
+ rotl $16,r2,r2 # r2 = |x| with bits unscrambled
+ divl2 $3,r2 # rough dcbrt with bias/3
+ addl2 B,r2 # restore bias, diminish fraction
+ rotl $16,r2,r2 # r2=|q|=|dcbrt| to 5 bits
+ mulf3 r2,r2,r3 # r3 =qq
+ divf2 r0,r3 # r3 = qq/x
+ mulf2 r2,r3
+ addf2 C,r3 # r3 = s = C + qqq/x
+ divf3 r3,D,r4 # r4 = D/s
+ addf2 E,r4
+ addf2 r4,r3 # r3 = s + E + D/s
+ divf3 r3,F,r3 # r3 = F / (s + E + D/s)
+ addf2 G,r3 # r3 = G + F / (s + E + D/s)
+ mulf2 r3,r2 # r2 = qr3 = new q to 23 bits
+ clrl r3 # r2:r3 = q as double float
+ muld3 r2,r2,r4 # r4:r5 = qq exactly
+ divd2 r4,r0 # r0:r1 = x/(q*q) rounded
+ subd3 r2,r0,r6 # r6:r7 = x/(q*q) - q exactly
+ movq r2,r4 # r4:r5 = q
+ addw2 $0x80,r4 # r4:r5 = 2 * q
+ addd2 r0,r4 # r4:r5 = 2*q + x/(q*q)
+ divd2 r4,r6 # r6:r7 = (x/(q*q)-q)/(2*q+x/(q*q))
+ muld2 r2,r6 # r6:r7 = q*(x/(q*q)-q)/(2*q+x/(q*q))
+ addd3 r6,r2,r0 # r0:r1 = q + r6:r7
+ bisw2 ap,r0 # restore the sign bit
+return:
+ ret # error less than 0.667 ulps
+
+.data
+.align 2
+B : .long 721142941 # (86-0.03306235651)*(2^23)
+C : .float 0f0.5428571429 # 19/35
+D : .float 0f-0.7053061224 # -864/1225
+E : .float 0f1.414285714 # 99/70
+F : .float 0f1.607142857 # 45/28
+G : .float 0f0.3571428571 # 5/14
+
diff --git a/lib/libm/arch/vax/n_infnan.S b/lib/libm/arch/vax/n_infnan.S
new file mode 100644
index 00000000000..d6f8adbbf6b
--- /dev/null
+++ b/lib/libm/arch/vax/n_infnan.S
@@ -0,0 +1,62 @@
+/* $NetBSD: n_infnan.S,v 1.1 1995/10/10 23:40:27 ragge Exp $ */
+/*
+ * Copyright (c) 1985, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)infnan.s 8.1 (Berkeley) 6/4/93
+ */
+ .data
+ .align 2
+_sccsid:
+.asciz "@(#)infnan.s 1.1 (Berkeley) 8/21/85; 8.1 (ucb.elefunt) 6/4/93"
+
+/*
+ * infnan(arg) int arg;
+ * where arg := EDOM if result is NaN
+ * := ERANGE if result is +INF
+ * := -ERANGE if result is -INF
+ *
+ * The Reserved Operand Fault is generated inside of this routine.
+ */
+ .globl _infnan
+ .set EDOM,33
+ .set ERANGE,34
+ .text
+ .align 1
+_infnan:
+ .word 0x0
+ cmpl 4(ap),$ERANGE
+ bneq 1f
+ movl $ERANGE,_errno
+ brb 2f
+1: movl $EDOM,_errno
+2: emodd $0,$0,$0x8000,r0,r0 # generates the reserved operand fault
+ ret
diff --git a/lib/libm/arch/vax/n_sincos.S b/lib/libm/arch/vax/n_sincos.S
new file mode 100644
index 00000000000..c2f268820b6
--- /dev/null
+++ b/lib/libm/arch/vax/n_sincos.S
@@ -0,0 +1,109 @@
+/* $NetBSD: n_sincos.S,v 1.1 1995/10/10 23:40:28 ragge Exp $ */
+/*
+ * Copyright (c) 1985, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)sincos.s 8.1 (Berkeley) 6/4/93
+ */
+
+/*
+ * This is the implementation of Peter Tang's double precision
+ * sine and cosine for the VAX using Bob Corbett's argument reduction.
+ *
+ * Notes:
+ * under 1,024,000 random arguments testing on [0,2*pi]
+ * sin() observed maximum error = 0.814 ulps
+ * cos() observed maximum error = 0.792 ulps
+ *
+ * double sin(arg)
+ * double arg;
+ * method: true range reduction to [-pi/4,pi/4], P. Tang & B. Corbett
+ * S. McDonald, April 4, 1985
+ */
+
+ .globl _sin
+ .text
+ .align 1
+
+_sin: .word 0xffc # save r2-r11
+ movq 4(ap),r0
+ bicw3 $0x807f,r0,r2
+ beql 1f # if x is zero or reserved operand then return x
+/*
+ * Save the PSL's IV & FU bits on the stack.
+ */
+ movpsl r2
+ bicw3 $0xff9f,r2,-(sp)
+/*
+ * Clear the IV & FU bits.
+ */
+ bicpsw $0x0060
+/*
+ * Entered by sine ; save 0 in r4 .
+ */
+ jsb libm$argred
+ movl $0,r4
+ jsb libm$sincos
+ bispsw (sp)+
+1: ret
+
+/*
+ * double cos(arg)
+ * double arg;
+ * method: true range reduction to [-pi/4,pi/4], P. Tang & B. Corbett
+ * S. McDonald, April 4, 1985
+ */
+ .globl _cos
+ .text
+ .align 1
+
+_cos: .word 0xffc # save r2-r11
+ movq 4(ap),r0
+ bicw3 $0x7f,r0,r2
+ cmpw $0x8000,r2
+ beql 1f # if x is reserved operand then return x
+/*
+ * Save the PSL's IV & FU bits on the stack.
+ */
+ movpsl r2
+ bicw3 $0xff9f,r2,-(sp)
+/*
+ * Clear the IV & FU bits.
+ */
+ bicpsw $0x0060
+/*
+ * Entered by cosine ; save 1 in r4 .
+ */
+ jsb libm$argred
+ movl $1,r4
+ jsb libm$sincos
+ bispsw (sp)+
+1: ret
diff --git a/lib/libm/arch/vax/n_sqrt.S b/lib/libm/arch/vax/n_sqrt.S
new file mode 100644
index 00000000000..ec3269c0f3d
--- /dev/null
+++ b/lib/libm/arch/vax/n_sqrt.S
@@ -0,0 +1,121 @@
+/* $NetBSD: n_sqrt.S,v 1.1 1995/10/10 23:40:29 ragge Exp $ */
+/*
+ * Copyright (c) 1985, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)sqrt.s 8.1 (Berkeley) 6/4/93
+ */
+
+/*
+ * double sqrt(arg) revised August 15,1982
+ * double arg;
+ * if(arg<0.0) { _errno = EDOM; return(<a reserved operand>); }
+ * if arg is a reserved operand it is returned as it is
+ * W. Kahan's magic square root
+ * coded by Heidi Stettner and revised by Emile LeBlanc 8/18/82
+ *
+ * entry points:_d_sqrt address of double arg is on the stack
+ * _sqrt double arg is on the stack
+ */
+ .text
+ .align 1
+ .globl _sqrt
+ .globl _d_sqrt
+ .globl libm$dsqrt_r5
+ .set EDOM,33
+
+_d_sqrt:
+ .word 0x003c # save r5,r4,r3,r2
+ movq *4(ap),r0
+ jmp dsqrt2
+_sqrt:
+ .word 0x003c # save r5,r4,r3,r2
+ movq 4(ap),r0
+dsqrt2: bicw3 $0x807f,r0,r2 # check exponent of input
+ jeql noexp # biased exponent is zero -> 0.0 or reserved
+ bsbb libm$dsqrt_r5
+noexp: ret
+
+/* **************************** internal procedure */
+
+libm$dsqrt_r5: /* ENTRY POINT FOR cdabs and cdsqrt */
+ /* returns double square root scaled by */
+ /* 2^r6 */
+
+ movd r0,r4
+ jleq nonpos # argument is not positive
+ movzwl r4,r2
+ ashl $-1,r2,r0
+ addw2 $0x203c,r0 # r0 has magic initial approximation
+/*
+ * Do two steps of Heron's rule
+ * ((arg/guess) + guess) / 2 = better guess
+ */
+ divf3 r0,r4,r2
+ addf2 r2,r0
+ subw2 $0x80,r0 # divide by two
+
+ divf3 r0,r4,r2
+ addf2 r2,r0
+ subw2 $0x80,r0 # divide by two
+
+/* Scale argument and approximation to prevent over/underflow */
+
+ bicw3 $0x807f,r4,r1
+ subw2 $0x4080,r1 # r1 contains scaling factor
+ subw2 r1,r4
+ movl r0,r2
+ subw2 r1,r2
+
+/* Cubic step
+ *
+ * b = a + 2*a*(n-a*a)/(n+3*a*a) where b is better approximation,
+ * a is approximation, and n is the original argument.
+ * (let s be scale factor in the following comments)
+ */
+ clrl r1
+ clrl r3
+ muld2 r0,r2 # r2:r3 = a*a/s
+ subd2 r2,r4 # r4:r5 = n/s - a*a/s
+ addw2 $0x100,r2 # r2:r3 = 4*a*a/s
+ addd2 r4,r2 # r2:r3 = n/s + 3*a*a/s
+ muld2 r0,r4 # r4:r5 = a*n/s - a*a*a/s
+ divd2 r2,r4 # r4:r5 = a*(n-a*a)/(n+3*a*a)
+ addw2 $0x80,r4 # r4:r5 = 2*a*(n-a*a)/(n+3*a*a)
+ addd2 r4,r0 # r0:r1 = a + 2*a*(n-a*a)/(n+3*a*a)
+ rsb # DONE!
+nonpos:
+ jneq negarg
+ ret # argument and root are zero
+negarg:
+ pushl $EDOM
+ calls $1,_infnan # generate the reserved op fault
+ ret
diff --git a/lib/libm/arch/vax/n_support.S b/lib/libm/arch/vax/n_support.S
new file mode 100644
index 00000000000..341d353498e
--- /dev/null
+++ b/lib/libm/arch/vax/n_support.S
@@ -0,0 +1,230 @@
+/* $NetBSD: n_support.S,v 1.1 1995/10/10 23:40:30 ragge Exp $ */
+/*
+ * Copyright (c) 1985, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)support.s 8.1 (Berkeley) 6/4/93
+ */
+ .data
+ .align 2
+_sccsid:
+.asciz "@(#)support.s 1.3 (Berkeley) 8/21/85; 8.1 (ucb.elefunt) 6/4/93"
+
+/*
+ * copysign(x,y),
+ * logb(x),
+ * scalb(x,N),
+ * finite(x),
+ * drem(x,y),
+ * Coded in vax assembly language by K.C. Ng, 3/14/85.
+ * Revised by K.C. Ng on 4/9/85.
+ */
+
+/*
+ * double copysign(x,y)
+ * double x,y;
+ */
+ .globl _copysign
+ .text
+ .align 1
+_copysign:
+ .word 0x4
+ movq 4(ap),r0 # load x into r0
+ bicw3 $0x807f,r0,r2 # mask off the exponent of x
+ beql Lz # if zero or reserved op then return x
+ bicw3 $0x7fff,12(ap),r2 # copy the sign bit of y into r2
+ bicw2 $0x8000,r0 # replace x by |x|
+ bisw2 r2,r0 # copy the sign bit of y to x
+Lz: ret
+
+/*
+ * double logb(x)
+ * double x;
+ */
+ .globl _logb
+ .text
+ .align 1
+_logb:
+ .word 0x0
+ bicl3 $0xffff807f,4(ap),r0 # mask off the exponent of x
+ beql Ln
+ ashl $-7,r0,r0 # get the bias exponent
+ subl2 $129,r0 # get the unbias exponent
+ cvtld r0,r0 # return the answer in double
+ ret
+Ln: movq 4(ap),r0 # r0:1 = x (zero or reserved op)
+ bneq 1f # simply return if reserved op
+ movq $0x0000fe00ffffcfff,r0 # -2147483647.0
+1: ret
+
+/*
+ * long finite(x)
+ * double x;
+ */
+ .globl _finite
+ .text
+ .align 1
+_finite:
+ .word 0x0000
+ bicw3 $0x7f,4(ap),r0 # mask off the mantissa
+ cmpw r0,$0x8000 # to see if x is the reserved op
+ beql 1f # if so, return FALSE (0)
+ movl $1,r0 # else return TRUE (1)
+ ret
+1: clrl r0
+ ret
+
+/*
+ * double scalb(x,N)
+ * double x; double N;
+ */
+ .globl _scalb
+ .set ERANGE,34
+ .text
+ .align 1
+_scalb:
+ .word 0x3c
+ movq 4(ap),r0
+ bicl3 $0xffff807f,r0,r3
+ beql ret1 # 0 or reserved operand
+ movq 12(ap),r4
+ cvtdl r4, r2
+ cmpl r2,$0x12c
+ bgeq ovfl
+ cmpl r2,$-0x12c
+ bleq unfl
+ ashl $7,r2,r2
+ addl2 r2,r3
+ bleq unfl
+ cmpl r3,$0x8000
+ bgeq ovfl
+ addl2 r2,r0
+ ret
+ovfl: pushl $ERANGE
+ calls $1,_infnan # if it returns
+ bicw3 $0x7fff,4(ap),r2 # get the sign of input arg
+ bisw2 r2,r0 # re-attach the sign to r0/1
+ ret
+unfl: movq $0,r0
+ret1: ret
+
+/*
+ * DREM(X,Y)
+ * RETURN X REM Y =X-N*Y, N=[X/Y] ROUNDED (ROUNDED TO EVEN IN THE HALF WAY CASE)
+ * DOUBLE PRECISION (VAX D format 56 bits)
+ * CODED IN VAX ASSEMBLY LANGUAGE BY K.C. NG, 4/8/85.
+ */
+ .globl _drem
+ .set EDOM,33
+ .text
+ .align 1
+_drem:
+ .word 0xffc
+ subl2 $12,sp
+ movq 4(ap),r0 #r0=x
+ movq 12(ap),r2 #r2=y
+ jeql Rop #if y=0 then generate reserved op fault
+ bicw3 $0x007f,r0,r4 #check if x is Rop
+ cmpw r4,$0x8000
+ jeql Ret #if x is Rop then return Rop
+ bicl3 $0x007f,r2,r4 #check if y is Rop
+ cmpw r4,$0x8000
+ jeql Ret #if y is Rop then return Rop
+ bicw2 $0x8000,r2 #y := |y|
+ movw $0,-4(fp) #-4(fp) = nx := 0
+ cmpw r2,$0x1c80 #yexp ? 57
+ bgtr C1 #if yexp > 57 goto C1
+ addw2 $0x1c80,r2 #scale up y by 2**57
+ movw $0x1c80,-4(fp) #nx := 57 (exponent field)
+C1:
+ movw -4(fp),-8(fp) #-8(fp) = nf := nx
+ bicw3 $0x7fff,r0,-12(fp) #-12(fp) = sign of x
+ bicw2 $0x8000,r0 #x := |x|
+ movq r2,r10 #y1 := y
+ bicl2 $0xffff07ff,r11 #clear the last 27 bits of y1
+loop:
+ cmpd r0,r2 #x ? y
+ bleq E1 #if x <= y goto E1
+ /* begin argument reduction */
+ movq r2,r4 #t =y
+ movq r10,r6 #t1=y1
+ bicw3 $0x807f,r0,r8 #xexp= exponent of x
+ bicw3 $0x807f,r2,r9 #yexp= exponent fo y
+ subw2 r9,r8 #xexp-yexp
+ subw2 $0x0c80,r8 #k=xexp-yexp-25(exponent bit field)
+ blss C2 #if k<0 goto C2
+ addw2 r8,r4 #t +=k
+ addw2 r8,r6 #t1+=k, scale up t and t1
+C2:
+ divd3 r4,r0,r8 #x/t
+ cvtdl r8,r8 #n=[x/t] truncated
+ cvtld r8,r8 #float(n)
+ subd2 r6,r4 #t:=t-t1
+ muld2 r8,r4 #n*(t-t1)
+ muld2 r8,r6 #n*t1
+ subd2 r6,r0 #x-n*t1
+ subd2 r4,r0 #(x-n*t1)-n*(t-t1)
+ brb loop
+E1:
+ movw -4(fp),r6 #r6=nx
+ beql C3 #if nx=0 goto C3
+ addw2 r6,r0 #x:=x*2**57 scale up x by nx
+ movw $0,-4(fp) #clear nx
+ brb loop
+C3:
+ movq r2,r4 #r4 = y
+ subw2 $0x80,r4 #r4 = y/2
+ cmpd r0,r4 #x:y/2
+ blss E2 #if x < y/2 goto E2
+ bgtr C4 #if x > y/2 goto C4
+ cvtdl r8,r8 #ifix(float(n))
+ blbc r8,E2 #if the last bit is zero, goto E2
+C4:
+ subd2 r2,r0 #x-y
+E2:
+ xorw2 -12(fp),r0 #x^sign (exclusive or)
+ movw -8(fp),r6 #r6=nf
+ bicw3 $0x807f,r0,r8 #r8=exponent of x
+ bicw2 $0x7f80,r0 #clear the exponent of x
+ subw2 r6,r8 #r8=xexp-nf
+ bgtr C5 #if xexp-nf is positive goto C5
+ movw $0,r8 #clear r8
+ movq $0,r0 #x underflow to zero
+C5:
+ bisw2 r8,r0 /* put r8 into x's exponent field */
+ ret
+Rop: #Reserved operand
+ pushl $EDOM
+ calls $1,_infnan #generate reserved op fault
+ ret
+Ret:
+ movq $0x8000,r0 #propagate reserved op
+ ret
diff --git a/lib/libm/arch/vax/n_tan.S b/lib/libm/arch/vax/n_tan.S
new file mode 100644
index 00000000000..f5099856681
--- /dev/null
+++ b/lib/libm/arch/vax/n_tan.S
@@ -0,0 +1,95 @@
+/* $NetBSD: n_tan.S,v 1.1 1995/10/10 23:40:31 ragge Exp $ */
+/*
+ * Copyright (c) 1985, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)tan.s 8.1 (Berkeley) 6/4/93
+ */
+
+/* This is the implementation of Peter Tang's double precision
+ * tangent for the VAX using Bob Corbett's argument reduction.
+ *
+ * Notes:
+ * under 1,024,000 random arguments testing on [0,2*pi]
+ * tan() observed maximum error = 2.15 ulps
+ *
+ * double tan(arg)
+ * double arg;
+ * method: true range reduction to [-pi/4,pi/4], P. Tang & B. Corbett
+ * S. McDonald, April 4, 1985
+ */
+ .globl _tan
+ .text
+ .align 1
+
+_tan: .word 0xffc # save r2-r11
+ movq 4(ap),r0
+ bicw3 $0x807f,r0,r2
+ beql 1f # if x is zero or reserved operand then return x
+/*
+ * Save the PSL's IV & FU bits on the stack.
+ */
+ movpsl r2
+ bicw3 $0xff9f,r2,-(sp)
+/*
+ * Clear the IV & FU bits.
+ */
+ bicpsw $0x0060
+ jsb libm$argred
+/*
+ * At this point,
+ * r0 contains the quadrant number, 0, 1, 2, or 3;
+ * r2/r1 contains the reduced argument as a D-format number;
+ * r3 contains a F-format extension to the reduced argument;
+ *
+ * Save r3/r0 so that we can call cosine after calling sine.
+ */
+ movq r2,-(sp)
+ movq r0,-(sp)
+/*
+ * Call sine. r4 = 0 implies sine.
+ */
+ movl $0,r4
+ jsb libm$sincos
+/*
+ * Save sin(x) in r11/r10 .
+ */
+ movd r0,r10
+/*
+ * Call cosine. r4 = 1 implies cosine.
+ */
+ movq (sp)+,r0
+ movq (sp)+,r2
+ movl $1,r4
+ jsb libm$sincos
+ divd3 r0,r10,r0
+ bispsw (sp)+
+1: ret