summaryrefslogtreecommitdiff
path: root/sys/arch
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2000-02-27 05:25:02 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2000-02-27 05:25:02 +0000
commitce97acbbd054d08bb0bd7accaeac8026af6bb3dd (patch)
treeb06db1ddd5d9a2b932cef115fb0984d086edc7af /sys/arch
parent1984e623cb949faaacf5ef0e3b1435c49715ac15 (diff)
repair some gotchas in the .{u,}{mul,div,rem} replacement routines, out of a conversation with torek
Diffstat (limited to 'sys/arch')
-rw-r--r--sys/arch/sparc/sparc/locore.s34
1 files changed, 26 insertions, 8 deletions
diff --git a/sys/arch/sparc/sparc/locore.s b/sys/arch/sparc/sparc/locore.s
index f52137a6139..f9f38a40298 100644
--- a/sys/arch/sparc/sparc/locore.s
+++ b/sys/arch/sparc/sparc/locore.s
@@ -1,4 +1,4 @@
-/* $OpenBSD: locore.s,v 1.36 2000/02/23 16:43:42 deraadt Exp $ */
+/* $OpenBSD: locore.s,v 1.37 2000/02/27 05:25:01 deraadt Exp $ */
/* $NetBSD: locore.s,v 1.73 1997/09/13 20:36:48 pk Exp $ */
/*
@@ -5918,37 +5918,52 @@ ENTRY(ffs)
add %o0, 24, %o0
/*
- * V8 sparc {,u}{mul,div,rem} replacements.
+ * V8 sparc .{,u}{mul,div,rem} replacements.
+ * We try to mimic them 100%. Full 64 bit sources or outputs, and
+ * these routines are required to update the condition codes.
*/
.globl __mulreplace, __mulreplace_end
__mulreplace:
+ smulcc %o0, %o1, %o0
retl
- smulcc %o0, %o1, %o0
+ rd %y, %o1
__mulreplace_end:
.globl __umulreplace, __umulreplace_end
__umulreplace:
+ umulcc %o0, %o1, %o0
retl
- umulcc %o0, %o1, %o0
+ rd %y, %o1
__umulreplace_end:
.globl __divreplace, __divreplace_end
__divreplace:
- mov %g0, %y
+ sra %o0, 31, %g1
+ wr %g1, 0, %y
+ nop
+ nop
+ nop
retl
sdivcc %o0, %o1, %o0
__divreplace_end:
.globl __udivreplace, __udivreplace_end
__udivreplace:
- mov %g0, %y
+ wr %g0, 0, %y
+ nop
+ nop
+ nop
retl
udivcc %o0, %o1, %o0
__udivreplace_end:
.globl __remreplace, __remreplace_end
__remreplace:
- mov %g0, %y
+ sra %o0, 31, %g1
+ wr %g1, 0, %y
+ nop
+ nop
+ nop
sdiv %o0, %o1, %o2
smul %o1, %o2, %o2
retl
@@ -5957,7 +5972,10 @@ __remreplace_end:
.globl __uremreplace, __uremreplace_end
__uremreplace:
- mov %g0, %y
+ wr %g0, 0, %y
+ nop
+ nop
+ nop
udiv %o0, %o1, %o2
umul %o1, %o2, %o2
retl