From 4e0a99ef384105af31b0b8ea20f15a055239edaf Mon Sep 17 00:00:00 2001 From: ceriel Date: Thu, 3 Oct 1991 15:45:13 +0000 Subject: [PATCH] Fixes and additions --- mach/sparc/libem/LIST | 1 + mach/sparc/libem/cfu.s | 62 ++++++++++++++++++++++++++++++++++ mach/sparc/libem/dvu.s | 77 +++++++++++++++++++++++++++++++++++++++--- 3 files changed, 136 insertions(+), 4 deletions(-) create mode 100644 mach/sparc/libem/cfu.s diff --git a/mach/sparc/libem/LIST b/mach/sparc/libem/LIST index f956f612e..520c86ce4 100644 --- a/mach/sparc/libem/LIST +++ b/mach/sparc/libem/LIST @@ -9,3 +9,4 @@ fef.s nop.s shp.s trp.s +cfu.s diff --git a/mach/sparc/libem/cfu.s b/mach/sparc/libem/cfu.s new file mode 100644 index 000000000..a07780285 --- /dev/null +++ b/mach/sparc/libem/cfu.s @@ -0,0 +1,62 @@ +.global cfu4, cfu8 + +.align 8 +Fdmaxint: +.double 0r2147483648 +Fsmaxint: +.single 0r2147483648 +maxint: +.word 0x80000000 + +cfu4: + ld [%l0], %f0 + set Fsmaxint, %o0 + ld [%o0], %f1 + fcmps %f0, %f1 + nop + fbul 1f + nop + fsubs %f0, %f1, %f0 + fstoi %f0, %f1 + st %f1,[%l0] + ld [%l0],%o0 + set maxint, %o1 + ld [%o1],%o2 + add %o0, %o2, %o0 + ba 2f + nop +1: + fstoi %f0, %f1 + st %f1,[%l0] + ld [%l0],%o0 +2: + inc 4,%l0 + retl + nop + +cfu8: + ld [%l0], %f0 + ld [%l0+4], %f1 + set Fdmaxint, %o0 + ldd [%o0], %f2 + fcmpd %f0, %f2 + nop + fbul 1f + nop + fsubd %f0, %f2, %f0 + fdtoi %f0, %f2 + st %f2,[%l0] + ld [%l0],%o0 + set maxint, %o1 + ld [%o1],%o2 + add %o0, %o2, %o0 + ba 2f + nop +1: + fdtoi %f0, %f2 + st %f2,[%l0] + ld [%l0],%o0 +2: + inc 8,%l0 + retl + nop diff --git a/mach/sparc/libem/dvu.s b/mach/sparc/libem/dvu.s index 7e77c1059..ed85fbb93 100644 --- a/mach/sparc/libem/dvu.s +++ b/mach/sparc/libem/dvu.s @@ -1,5 +1,74 @@ .global dvu4 .global dvi4 +.global mathdvi4 + +dvi4: +! %o0' = %o0 / %o1 +! %o1' = %o0 % %o1 + tst %o1 + be 0f + clr %o5 + tst %o0 + bge 1f + nop + neg %o0 + xor %o5, 1, %o5 +1: + tst %o1 + bge 3f + nop + neg %o1 + xor %o5, 2, %o5 + +3: /* div common */ + clr %o2 + mov %o1, %o3 + clr %o4 + +4: + cmp %o1, %o0 + bgeu 5f + nop + inc %o4 + sll %o1, 1, %o1 + b 4b + nop + +5: + sll %o2, 1, %o2 + subcc %o0, %o1, %o0 + bgeu 3f + nop + add %o0, %o1, %o0 + b 4f + nop +3: + inc %o2 +4: + srl %o1, 1, %o1 + tst %o4 + bz 5f + nop + dec %o4 + b 5b + nop + +5: + andcc %o5, 1, %g0 + bz 6f + nop + neg %o0 + neg %o2 +6: + andcc %o5, 2, %g0 + bz 8f + nop + neg %o2 +8: + mov %o0, %o1 + mov %o2, %o0 + retl + nop dvu4: ! %o0' = %o0 / %o1 @@ -24,9 +93,9 @@ dvu4: nop -dvi4: -! %o2 = %o0 / %o1 -! %o3 = %o0 % %o1 +mathdvi4: +! %o0' = %o0 / %o1 +! %o1' = %o0 % %o1 tst %o1 be 0f clr %o5 @@ -49,7 +118,7 @@ dvi4: 4: cmp %o1, %o0 - bgu 5f + bgeu 5f nop inc %o4 sll %o1, 1, %o1