summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorMiod Vallat <miod@cvs.openbsd.org>2013-06-07 17:31:32 +0000
committerMiod Vallat <miod@cvs.openbsd.org>2013-06-07 17:31:32 +0000
commit4d536be368ceb6ab24e88330ed0aecc489be7945 (patch)
treecd379bb00944253de8b64a732677bf324ad0dede /sys
parentfb5755809e7db58c1fac402988fd532351d5e50d (diff)
Add {,u}{div,mod}si3 to libkern and to the kernel as well.
Diffstat (limited to 'sys')
-rw-r--r--sys/arch/m88k/conf/files.m88k7
-rw-r--r--sys/lib/libkern/arch/m88k/divsi3.S61
-rw-r--r--sys/lib/libkern/arch/m88k/modsi3.S64
-rw-r--r--sys/lib/libkern/arch/m88k/udivsi3.S34
-rw-r--r--sys/lib/libkern/arch/m88k/umodsi3.S36
5 files changed, 201 insertions, 1 deletions
diff --git a/sys/arch/m88k/conf/files.m88k b/sys/arch/m88k/conf/files.m88k
index a5662f57978..82a36c01148 100644
--- a/sys/arch/m88k/conf/files.m88k
+++ b/sys/arch/m88k/conf/files.m88k
@@ -1,4 +1,4 @@
-# $OpenBSD: files.m88k,v 1.24 2010/12/31 21:38:08 miod Exp $
+# $OpenBSD: files.m88k,v 1.25 2013/06/07 17:31:31 miod Exp $
file arch/m88k/m88k/atomic.S multiprocessor
file arch/m88k/m88k/db_disasm.c ddb
@@ -29,6 +29,11 @@ file arch/m88k/m88k/vm_machdep.c
file arch/m88k/m88k/m88110_fp.c m88110
file lib/libkern/softfloat.c m88110
+file lib/libkern/arch/m88k/divsi3.S
+file lib/libkern/arch/m88k/modsi3.S
+file lib/libkern/arch/m88k/udivsi3.S
+file lib/libkern/arch/m88k/umodsi3.S
+
# quad support is necessary for 32 bit architectures
file lib/libkern/adddi3.c
file lib/libkern/anddi3.c
diff --git a/sys/lib/libkern/arch/m88k/divsi3.S b/sys/lib/libkern/arch/m88k/divsi3.S
new file mode 100644
index 00000000000..4a1a4f84cc5
--- /dev/null
+++ b/sys/lib/libkern/arch/m88k/divsi3.S
@@ -0,0 +1,61 @@
+/* $OpenBSD: divsi3.S,v 1.1 2013/06/07 17:31:31 miod Exp $ */
+
+/*
+ * Copyright (c) 2013 Miodrag Vallat.
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+
+#include <machine/asm.h>
+
+/*
+ * int __divsi3(int n, int d);
+ */
+
+ENTRY(__divsi3)
+ /* if divider is zero, trap */
+ bcnd ne0, %r3, 1f
+ tb0 0, %r0, 503
+1:
+
+ bb1 31, %r2, 1f
+ bb1 31, %r3, 2f
+
+ /* both operands are positive */
+ jmp.n %r1
+ divu %r2, %r2, %r3
+
+1:
+ bb1 31, %r3, 3f
+
+ /* r2 is negative, r3 is positive */
+ subu %r4, %r0, %r2
+ divu %r5, %r4, %r3
+ jmp.n %r1
+ subu %r2, %r0, %r5
+
+2:
+ /* r2 is positive, r3 is negative */
+ subu %r5, %r0, %r3
+ divu %r4, %r2, %r5
+ jmp.n %r1
+ subu %r2, %r0, %r4
+
+3:
+ /* both operands are negative */
+ subu %r4, %r0, %r2
+ subu %r5, %r0, %r3
+ jmp.n %r1
+ divu %r2, %r4, %r5
+END(__divsi3)
diff --git a/sys/lib/libkern/arch/m88k/modsi3.S b/sys/lib/libkern/arch/m88k/modsi3.S
new file mode 100644
index 00000000000..eb72ca97024
--- /dev/null
+++ b/sys/lib/libkern/arch/m88k/modsi3.S
@@ -0,0 +1,64 @@
+/* $OpenBSD: modsi3.S,v 1.1 2013/06/07 17:31:31 miod Exp $ */
+
+/*
+ * Copyright (c) 2013 Miodrag Vallat.
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+
+#include <machine/asm.h>
+
+/*
+ * int __modsi3(int n, int d);
+ */
+
+ENTRY(__modsi3)
+ /* if divider is zero, trap */
+ bcnd ne0, %r3, 1f
+ tb0 0, %r0, 503
+1:
+
+ bb1 31, %r2, 1f
+ bb1 31, %r3, 2f
+
+ /* both operands are positive */
+ divu %r4, %r2, %r3
+9:
+ mul %r5, %r4, %r3
+ jmp.n %r1
+ subu %r2, %r2, %r5
+
+1:
+ bb1 31, %r3, 3f
+
+ /* r2 is negative, r3 is positive */
+ subu %r4, %r0, %r2
+ divu %r5, %r4, %r3
+ subu %r4, %r0, %r5
+ br 9b
+
+2:
+ /* r2 is positive, r3 is negative */
+ subu %r5, %r0, %r3
+ divu %r4, %r2, %r5
+ subu %r4, %r0, %r4
+ br 9b
+
+3:
+ /* both operands are negative */
+ subu %r4, %r0, %r2
+ subu %r5, %r0, %r3
+ divu %r4, %r4, %r5
+ br 9b
+END(__modsi3)
diff --git a/sys/lib/libkern/arch/m88k/udivsi3.S b/sys/lib/libkern/arch/m88k/udivsi3.S
new file mode 100644
index 00000000000..96b8ab554a7
--- /dev/null
+++ b/sys/lib/libkern/arch/m88k/udivsi3.S
@@ -0,0 +1,34 @@
+/* $OpenBSD: udivsi3.S,v 1.1 2013/06/07 17:31:31 miod Exp $ */
+
+/*
+ * Copyright (c) 2013 Miodrag Vallat.
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+
+#include <machine/asm.h>
+
+/*
+ * uint __udivsi3(uint n, uint d);
+ */
+
+ENTRY(__udivsi3)
+ /* if divider is zero, trap */
+ bcnd ne0, %r3, 1f
+ tb0 0, %r0, 503
+1:
+
+ jmp.n %r1
+ divu %r2, %r2, %r3
+END(__udivsi3)
diff --git a/sys/lib/libkern/arch/m88k/umodsi3.S b/sys/lib/libkern/arch/m88k/umodsi3.S
new file mode 100644
index 00000000000..c23b20decc7
--- /dev/null
+++ b/sys/lib/libkern/arch/m88k/umodsi3.S
@@ -0,0 +1,36 @@
+/* $OpenBSD: umodsi3.S,v 1.1 2013/06/07 17:31:31 miod Exp $ */
+
+/*
+ * Copyright (c) 2013 Miodrag Vallat.
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+
+#include <machine/asm.h>
+
+/*
+ * uint __umodsi3(uint n, uint d);
+ */
+
+ENTRY(__umodsi3)
+ /* if divider is zero, trap */
+ bcnd ne0, %r3, 1f
+ tb0 0, %r0, 503
+1:
+
+ divu %r4, %r2, %r3
+ mulu %r5, %r4, %r3
+ jmp.n %r1
+ subu %r2, %r2, %r5
+END(__umodsi3)