BSD 4_3_Reno development
authorCSRG <csrg@ucbvax.Berkeley.EDU>
Sun, 5 Jan 1986 11:51:21 +0000 (03:51 -0800)
committerCSRG <csrg@ucbvax.Berkeley.EDU>
Sun, 5 Jan 1986 11:51:21 +0000 (03:51 -0800)
Work on file usr/src/sys/tahoemath/Kaddd.s
Work on file usr/src/sys/tahoemath/Katanf.s
Work on file usr/src/sys/tahoemath/Kcmpd.s
Work on file usr/src/sys/tahoemath/Kaddf.s
Work on file usr/src/sys/tahoemath/Kcmpf.s
Work on file usr/src/sys/tahoemath/Kcvtfl.s
Work on file usr/src/sys/tahoemath/Kcvtdl.s
Work on file usr/src/sys/tahoemath/Kcvtld.s
Work on file usr/src/sys/tahoemath/Kcvtlf.s
Work on file usr/src/sys/tahoemath/Kdivd.s
Work on file usr/src/sys/tahoemath/Kdivf.s
Work on file usr/src/sys/tahoemath/Kfp_exp.s
Work on file usr/src/sys/tahoemath/Kfnorm.s
Work on file usr/src/sys/tahoemath/Kexpf.s
Work on file usr/src/sys/tahoemath/Kfp_mvtoacc.s
Work on file usr/src/sys/tahoemath/Kldexpf.s
Work on file usr/src/sys/tahoemath/Kfrexpd.s
Work on file usr/src/sys/tahoemath/Kmodf.s
Work on file usr/src/sys/tahoemath/Kfrexpf.s
Work on file usr/src/sys/tahoemath/Klogf.s
Work on file usr/src/sys/tahoemath/Ksfnorm.s
Work on file usr/src/sys/tahoemath/Knegd.s
Work on file usr/src/sys/tahoemath/Kmulf.s
Work on file usr/src/sys/tahoemath/Kmuld.s
Work on file usr/src/sys/tahoemath/Knegf.s
Work on file usr/src/sys/tahoemath/Ksfp_exp.s
Work on file usr/src/sys/tahoemath/Ksubf.s
Work on file usr/src/sys/tahoemath/Ksinfcosf.s
Work on file usr/src/sys/tahoemath/Ksubd.s
Work on file usr/src/sys/tahoemath/Ksqrtf.s

Synthesized-from: CSRG/cd2/4.3reno

30 files changed:
usr/src/sys/tahoemath/Kaddd.s [new file with mode: 0644]
usr/src/sys/tahoemath/Kaddf.s [new file with mode: 0644]
usr/src/sys/tahoemath/Katanf.s [new file with mode: 0644]
usr/src/sys/tahoemath/Kcmpd.s [new file with mode: 0644]
usr/src/sys/tahoemath/Kcmpf.s [new file with mode: 0644]
usr/src/sys/tahoemath/Kcvtdl.s [new file with mode: 0644]
usr/src/sys/tahoemath/Kcvtfl.s [new file with mode: 0644]
usr/src/sys/tahoemath/Kcvtld.s [new file with mode: 0644]
usr/src/sys/tahoemath/Kcvtlf.s [new file with mode: 0644]
usr/src/sys/tahoemath/Kdivd.s [new file with mode: 0644]
usr/src/sys/tahoemath/Kdivf.s [new file with mode: 0644]
usr/src/sys/tahoemath/Kexpf.s [new file with mode: 0644]
usr/src/sys/tahoemath/Kfnorm.s [new file with mode: 0644]
usr/src/sys/tahoemath/Kfp_exp.s [new file with mode: 0644]
usr/src/sys/tahoemath/Kfp_mvtoacc.s [new file with mode: 0644]
usr/src/sys/tahoemath/Kfrexpd.s [new file with mode: 0644]
usr/src/sys/tahoemath/Kfrexpf.s [new file with mode: 0644]
usr/src/sys/tahoemath/Kldexpf.s [new file with mode: 0644]
usr/src/sys/tahoemath/Klogf.s [new file with mode: 0644]
usr/src/sys/tahoemath/Kmodf.s [new file with mode: 0644]
usr/src/sys/tahoemath/Kmuld.s [new file with mode: 0644]
usr/src/sys/tahoemath/Kmulf.s [new file with mode: 0644]
usr/src/sys/tahoemath/Knegd.s [new file with mode: 0644]
usr/src/sys/tahoemath/Knegf.s [new file with mode: 0644]
usr/src/sys/tahoemath/Ksfnorm.s [new file with mode: 0644]
usr/src/sys/tahoemath/Ksfp_exp.s [new file with mode: 0644]
usr/src/sys/tahoemath/Ksinfcosf.s [new file with mode: 0644]
usr/src/sys/tahoemath/Ksqrtf.s [new file with mode: 0644]
usr/src/sys/tahoemath/Ksubd.s [new file with mode: 0644]
usr/src/sys/tahoemath/Ksubf.s [new file with mode: 0644]

diff --git a/usr/src/sys/tahoemath/Kaddd.s b/usr/src/sys/tahoemath/Kaddd.s
new file mode 100644 (file)
index 0000000..08c5fee
--- /dev/null
@@ -0,0 +1,163 @@
+/*     Kaddd.s 1.3     86/01/05        */
+
+#include "../tahoemath/fp.h"
+#include "../tahoe/SYS.h"
+
+/*
+ * _Kaddd(acc_most,acc_least,op_most,op_least,hfs)
+ */
+
+ENTRY(Kaddd, R10|R9|R8|R7|R6|R5|R4|R3|R2)
+/*
+ * see which operand has a greater exponent
+ * The greater one will be fetched into r0,r1,r2,r3.
+ * r0,r1 - 'pure' fraction, r2 - exponent, r3 - sign).
+ * The smaller operand will be fetched into r4,r5,r6,r7.
+ */
+       tstl    4(fp)   # handle (a+b) where a and/or b = 0.0
+       jneq    next
+       movl    16(fp),r1
+       movl    12(fp),r0
+       ret
+next:
+       tstl    12(fp)
+       jneq    doit
+       movl    8(fp),r1
+       movl    4(fp),r0
+       ret
+doit:
+       andl3   $EXPMASK,4(fp),r0
+       andl3   $EXPMASK,12(fp),r1
+       cmpl    r0,r1
+       jgtr    first_greater
+
+       movl    12(fp),r0       # bigger operand to r0,r1
+       movl    16(fp),r1
+
+       movl    4(fp),r4        # smaller operand to r4,r5
+       movl    8(fp),r5
+       jmp     expo
+
+first_greater:
+       movl    4(fp),r0        # bigger operand to r0,r1
+       movl    8(fp),r1
+
+       movl    12(fp),r4       # smaller operand to r4,r5
+       movl    16(fp),r5
+
+
+/*
+ * Compute exponents:
+ */
+expo:
+       andl3   $EXPMASK,r0,r2  # r2 will hold the exponent.
+       shrl    $EXPSHIFT,r2,r2
+       andl3   $EXPMASK,r4,r6  # r6 will hold the exponent.
+       shrl    $EXPSHIFT,r6,r6
+/*
+ * Compare the exponents:
+ */
+       subl3   r6,r2,r8
+       jeql    signs
+       cmpl    r8,$MAX_EXP_DIF
+       jleq    signs
+       ret                     # return the bigger number.
+/*
+ * Remember the signs:
+ */
+signs:
+       clrl    r3
+       bbc     $31,r0,sign2    # if negative remember it.
+       incl    r3
+sign2:
+       clrl    r7
+       bbc     $31,r4,frac     # if negative remember it.
+       incl    r7
+/*
+ * Compute 'pure' fraction:
+ */
+frac:
+                               # clear the non fraction parts.
+       andl2   $(0!(EXPMASK | SIGNBIT)),r0
+                               # add the hidden bit.
+       orl2    $(0!CLEARHID),r0
+                               # clear the non fraction parts.
+       andl2   $(0!(EXPMASK | SIGNBIT)),r4
+                               # add the hidden bit.
+       orl2    $(0!CLEARHID),r4
+
+/*
+ * Shift the smaller operand:
+ */
+       shrq    r8,r4,r4
+eql_exps:
+       cmpl    r3,r7
+       jeql    add
+       bbc     $0,r3,negr4r5
+/*
+ * Negate the pair r0,r1:
+ */
+       clrl    r3
+       mcoml   r1,r1
+       clrl    r9              # r9 - carry flag.
+       incl    r1
+       bcc     comr0
+       incl    r9              # remember the carry.
+comr0: mcoml   r0,r0
+       bbc     $0,r9,add
+       incl    r0
+
+/*
+ * Add the fractions:
+ */
+add:
+       clrl    r10             # to remember the sign of the result.
+       addl2   r5,r1
+       adwc    r4,r0
+       jgeq    norm            # if positive go to normelize.
+       incl    r10             # else remember it and negate the result.
+/*
+ * Negate the pair r0,r1:
+ */
+       clrl    r3
+       mcoml   r1,r1
+       clrl    r9              # r9 - carry flag.
+       incl    r1
+       bcc     comr00
+       incl    r9              # remember the carry.
+comr00:        mcoml   r0,r0
+       bbc     $0,r9,norm
+       incl    r0
+norm:  pushl   20(fp)          # addr of returnen exception.
+       callf   $8,_Kfnorm
+/*
+ * Add the sign bit
+ */
+       bbs     $0,r10,negative
+       bbs     $0,r3,negative
+       ret
+negative:
+       orl2    $SIGNBIT,r0
+       ret
+/*
+ * Negate the pair r4,r5:
+ */
+negr4r5:
+       clrl    r7
+       mcoml   r5,r5
+       clrl    r9              # r9 - carry flag.
+       incl    r5
+       bcc     comr4
+       incl    r9              # remember the carry.
+comr4: mcoml   r4,r4
+       bbc     $0,r9,add
+       incl    r4
+       jmp     add
+       movl    r4,r0           # return the  smaller operand.
+       movl    r5,r1
+       ret
diff --git a/usr/src/sys/tahoemath/Kaddf.s b/usr/src/sys/tahoemath/Kaddf.s
new file mode 100644 (file)
index 0000000..3890ce8
--- /dev/null
@@ -0,0 +1,165 @@
+/*     Kaddf.s 1.3     86/01/05        */
+
+#include "../tahoemath/fp.h"
+#include "../tahoe/SYS.h"
+
+/*
+ * _Kaddf(acc_most,acc_least,op_most,op_least,hfs)
+ */
+       .text
+ENTRY(Kaddf, R10|R9|R8|R7|R6|R5|R4|R3|R2)
+/*
+ * see which operand has a greater exponent
+ * The greater one will be fetched into r0,r1,r2,r3.
+ * r0,r1 - 'pure' fraction, r2 - exponent, r3 - sign).
+ * The smaller operand will be fetched into r4,r5,r6,r7.
+ */
+       tstl    4(fp)   # handle (a+b) where a and/or b = 0.0
+       jneq    next
+       movl    $0,r1
+       movl    12(fp),r0
+       ret
+next:
+       tstl    12(fp)
+       jneq    doit
+       movl    $0,r1
+       movl    4(fp),r0
+       ret
+doit:
+       andl3   $EXPMASK,4(fp),r0
+       andl3   $EXPMASK,12(fp),r1
+       cmpl    r0,r1
+       jgtr    first_greater
+
+       movl    12(fp),r0       # bigger operand to r0,r1
+       movl    16(fp),r1
+
+       movl    4(fp),r4        # smaller operand to r4,r5
+       movl    8(fp),r5
+       jmp     expo
+
+first_greater:
+       movl    4(fp),r0        # bigger operand to r0,r1
+       movl    8(fp),r1
+
+       movl    12(fp),r4       # smaller operand to r4,r5
+       movl    16(fp),r5
+
+
+ #
+ #compute exponents:
+ #
+expo:
+       andl3   $EXPMASK,r0,r2  # r2 will hold the exponent.
+       shrl    $EXPSHIFT,r2,r2
+       andl3   $EXPMASK,r4,r6  # r6 will hold the exponent.
+       shrl    $EXPSHIFT,r6,r6
+ #
+ #compare the exponents:
+ #
+       subl3   r6,r2,r8
+       jeql    signs
+       cmpl    r8,$MAX_EXP_DIF
+       jlss    signs
+       ret                     # return the bigger number.
+ #
+ #remember the signs:
+ #
+signs:
+       clrl    r3
+       bbc     $31,r0,sign2    # if negative remember it.
+       incl    r3
+sign2:
+       clrl    r7
+       bbc     $31,r4,frac     # if negative remember it.
+       incl    r7
+ #
+ #compute 'pure' fraction:
+ #
+frac:
+                               # clear the non fraction parts.
+       andl2   $(0!(EXPMASK | SIGNBIT)),r0
+                               # add the hidden bit.
+       orl2    $(0!CLEARHID),r0
+                               # clear the non fraction parts.
+       andl2   $(0!(EXPMASK | SIGNBIT)),r4
+                               # add the hidden bit.
+       orl2    $(0!CLEARHID),r4
+
+ #
+ #shift the smaller operand:
+ #
+       shrq    r8,r4,r4
+eql_exps:
+       cmpl    r3,r7
+       jeql    add
+       bbc     $0,r3,negr4r5
+ #
+ #negate the pair r0,r1:
+ #
+       clrl    r3
+       mcoml   r1,r1
+       clrl    r9              # r9 - carry flag.
+       incl    r1
+       bcc     comr0
+       incl    r9              # remember the carry.
+comr0: mcoml   r0,r0
+       bbc     $0,r9,add
+       incl    r0
+
+ #
+ #add the fractions:
+ #
+add:
+       clrl    r10             # to remember the sign of the result.
+       addl2   r5,r1
+       adwc    r4,r0
+       jgeq    norm            # if positive go to normelize.
+       incl    r10             # else remember it and negate the result.
+ #
+ #negate the pair r0,r1:
+ #
+       clrl    r3
+       mcoml   r1,r1
+       clrl    r9              # r9 - carry flag.
+       incl    r1
+       bcc     comr00
+       incl    r9              # remember the carry.
+comr00:        mcoml   r0,r0
+       bbc     $0,r9,norm
+       incl    r0
+norm:  pushl   20(fp)          # addr of returnen exception.
+       callf   $8,_Kfnorm
+ #
+ #add the sign bit
+ #
+       bbs     $0,r10,negative
+       bbs     $0,r3,negative
+       ret
+negative:
+       orl2    $SIGNBIT,r0
+       ret
+ #
+ #negate the pair r4,r5:
+ #
+negr4r5:
+       clrl    r7
+       mcoml   r5,r5
+       clrl    r9              # r9 - carry flag.
+       incl    r5
+       bcc     comr4
+       incl    r9              # remember the carry.
+comr4: mcoml   r4,r4
+       bbc     $0,r9,add
+       incl    r4
+       jmp     add
+       movl    r4,r0           # return the  smaller operand.
+       movl    r5,r1
+       ret
+
diff --git a/usr/src/sys/tahoemath/Katanf.s b/usr/src/sys/tahoemath/Katanf.s
new file mode 100644 (file)
index 0000000..2785d1e
--- /dev/null
@@ -0,0 +1,145 @@
+/*     Katanf.s        1.3     86/01/05        */
+
+#include "../tahoe/SYS.h"
+
+       .text
+ENTRY(Katanf, 0)
+       tstl    4(fp)                   # if (arg > 0)
+       jleq    1f
+       pushl   20(fp)                  # hfs
+       pushl   8(fp)
+       pushl   4(fp)
+       callf   $16,satan
+       ret                             # return(satan(arg));
+1:                                     # else
+       pushl   20(fp)                  # hfs
+       lnd     4(fp)
+       pushd
+       callf   $16,satan
+       lnf     r0
+       stf     r0
+       ret                             # return(-satan(-arg));
+
+ASENTRY(satan, R2|R3)
+       subl3   $60,fp,sp
+       cmpd2   4(fp),_sq2m1            # if (arg < sq2m1)
+       jgeq    1f
+       pushl   12(fp)                  # hfs
+       pushl   8(fp)
+       pushl   4(fp)
+       callf   $16,xatan
+       ret                             # return(xatan(arg));
+1:
+       cmpd2   4(fp),_sq2p1            # else if (arg > sq2p1)
+       jgtr    9f
+       pushl   12(fp)                  # hfs
+       ldd     one; pushd
+       ldd     4(fp); pushd
+       callf   $24,_Kaddd              # (arg+1.0)
+       pushl   12(fp)                  # hfs of _Kdivd
+       pushl   r1
+       pushl   r0
+       pushl   12(fp)                  # hfs
+       ldd     one; pushd
+       ldd     4(fp); pushd
+       callf   $24,_Ksubd              # (arg-1.0)
+       pushl   r1
+       pushl   r0
+       callf   $24,_Kdivd              # (arg-1.0)/(arg+1.0)
+       pushl   12(fp)                  # hfs
+       pushl   r1
+       pushl   r0
+       callf   $16,xatan               # xatan((ag-1.0)/(arg+1.0))
+       pushl   12(fp)                  # hfs
+       pushl   r1
+       pushl   r0
+       ldd     _pio4; pushd
+       callf   $24,_Kaddd
+       ldd     r0; cvdf; stf r0
+       ret                             # return(pio4+xatan((xatan(...)));
+
+9:
+       pushl   12(fp)  
+       ldd     4(fp); pushd
+       ldd     one; pushd
+       callf   $24,_Kdivd              # (1.0/arg)
+       pushl   12(fp)                  # hfs
+       ldd     r0; pushd
+       callf   $16,xatan
+                                       # clrl  -60+4(fp)
+                                       # movl  r0,-60(fp)
+       pushl   12(fp)                  # hfs
+       ldd     r0; pushd
+       ldd     _pio2; pushd
+       callf   $24,_Ksubd
+       ldd     r0; cvdf; stf r0
+       ret
+
+ASENTRY(xatan, 0)
+       subl3   $68,fp,sp
+       pushl   12(fp)                  # hfs
+       ldd     4(fp); pushd; pushd
+       callf   $24,_Kmuld              # argsq = arg*arg;
+       ldd     r0
+       std     -60(fp)                 # argsq
+       pushl   12(fp)                  # hfs
+       pushd                   
+       ldd     _p5; pushd
+       callf   $24,_Kmuld              # p5*argsq
+       pushl   12(fp)                  # hfs
+       ldd     _p4; pushd                      
+       ldd     r0; pushd
+       callf   $24,_Kaddd              # (p5*argsq+p4)
+       pushl   12(fp)                  # hfs
+       ldd     -60(fp); pushd
+       ldd     r0; pushd
+       callf   $24,_Kmuld              # (p5*argsq+p4)*argsq
+       pushl   12(fp)                  # hfs
+       ldd     _p3; pushd                      
+       ldd     r0; pushd
+       callf   $24,_Kaddd              # ((p5*argsq+p4)*argsq+p3)
+       pushl   12(fp)                  # hfs
+       ldd     -60(fp); pushd
+       ldd     r0; pushd
+       callf   $24,_Kmuld              # (..)*argsq
+       pushl   12(fp)                  # hfs
+       ldd     _p2; pushd                      
+       ldd     r0; pushd
+       callf   $24,_Kaddd              # (..)*argsq+p2)
+       pushl   12(fp)                  # hfs
+       ldd     -60(fp); pushd
+       ldd     r0; pushd
+       callf   $24,_Kmuld              # ((..)*argsq+p2)*argsq
+       pushl   12(fp)                  # hfs
+       ldd     _p1; pushd                      
+       ldd     r0; pushd
+       callf   $24,_Kaddd              # ((..)*argsq+p2)*argsq+p1)
+       pushl   12(fp)                  # hfs
+       ldd     -60(fp); pushd
+       ldd     r0; pushd
+       callf   $24,_Kmuld              # (..)*argsq
+       pushl   12(fp)                  # hfs
+       ldd     _p0; pushd                      
+       ldd     r0; pushd
+       callf   $24,_Kaddd              # ((..)*argsq+p1)*argsq+p0)
+       pushl   12(fp)                  # hfs
+       ldd     4(fp); pushd
+       ldd     r0; pushd
+       callf   $24,_Kmuld              # (..)*arg
+       ldd     r0
+       std     -68(fp); cvdf; stf r0   # value
+       ret
+
+       .data
+       .align  2
+_sq2p1:        .long   0x411A8279, 0x99FCEF31 # .double 2.414213562373095
+_sq2m1:        .long   0x3FD413CC, 0xCFE77990 # .double .41421356237309503
+_pio2: .long   0x40C90FDA, 0xA22168C1 # .double 1.5707963267948966
+_pio4: .long   0x40490FDA, 0xA22168C1 # .double .78539816339744829
+_p0:   .long   0x407FFFFF, 0xFD687A4B # .double .99999999939652999
+_p1:   .long   0xBFAAAAA2, 0x09F9DBF2 # .double -.3333330762079
+_p2:   .long   0x3F4CC820, 0x0670059B # .double .199982166665
+_p3:   .long   0xBF11D182, 0x6601878B # .double -.142400777317
+_p4:   .long   0x3ED88B47, 0x4EFC9AF9 # .double .10573440275
+_p5:   .long   0xBE772E4B, 0x0E689AEB # .double -.060346883
+one:   .long   0x40800000, 0x00000000 # .double 1
diff --git a/usr/src/sys/tahoemath/Kcmpd.s b/usr/src/sys/tahoemath/Kcmpd.s
new file mode 100644 (file)
index 0000000..d7286db
--- /dev/null
@@ -0,0 +1,79 @@
+/*     Kcmpd.s 1.3     86/01/05        */
+
+#include "../tahoe/SYS.h"
+
+/*
+ * cmpd(hi1, lo1, hi2, lo2)
+ *     register hi1, hi2;
+ *     register unsigned lo1, lo2;
+ *{
+ *     if(hi1 < 0) {
+ *             hi1 ^= 0x80000000;
+ *             if(lo1) {
+ *                     lo1 = -lo1;
+ *                     hi1 = ~hi1;
+ *             } else
+ *                     hi1 = -hi1;
+ *     }
+ *     if(hi2 < 0) {
+ *             hi2 ^= 0x80000000;
+ *             if(lo2) {
+ *                     lo2 = -lo2;
+ *                     hi2 = ~hi2;
+ *             } else
+ *                     hi2 = -hi2;
+ *     }
+ *     if(hi1 != hi2)
+ *             return(hi1>hi2 ? 1 : -1);
+ *     if(lo1 != lo2)
+ *             return(lo1>lo2 ? 1 : -1);
+ *     return(0);
+ *}
+ */
+       .text
+ENTRY(Kcmpd, 0)
+       movl    8(fp),r3
+       movl    12(fp),r4
+       movl    16(fp),r2
+       movl    4(fp),r5
+       jgeq    1f
+       xorl2   $0x80000000,r5
+       tstl    r3
+       jeql    2f
+       mnegl   r3,r3
+       mcoml   r5,r5
+       jbr     1f
+2:
+       mnegl   r5,r5
+1:
+       tstl    r4
+       jgeq    1f
+       xorl2   $0x80000000,r4
+       tstl    r2
+       jeql    2f
+       mnegl   r2,r2
+       mcoml   r4,r4
+       jbr     1f
+2:
+       mnegl   r4,r4
+1:
+       cmpl    r5,r4
+       jeql    1f
+       jleq    2f
+       movl    $1,r0
+       ret
+2:
+       mnegl   $1,r0
+       ret
+1:
+       cmpl    r3,r2
+       jeql    1f
+       jlequ   2f
+       movl    $1,r0
+       ret
+2:
+       mnegl   $1,r0
+       ret
+1:
+       clrl    r0
+       ret
diff --git a/usr/src/sys/tahoemath/Kcmpf.s b/usr/src/sys/tahoemath/Kcmpf.s
new file mode 100644 (file)
index 0000000..4a4c302
--- /dev/null
@@ -0,0 +1,41 @@
+/*     Kcmpf.s 1.3     86/01/05        */
+
+#include "../tahoe/SYS.h"
+
+/*
+ * cmpf(o1, o2)
+ *     register o1, o2;
+ *{
+ *     if(o1 < 0) {
+ *             o1 ^= 0x80000000;
+ *             o1 = -o1;
+ *     }
+ *     if(o2 < 0) {
+ *             o2 ^= 0x80000000;
+ *             o2 = -o2;
+ *     }
+ *     if(o1 != o2)
+ *             return(o1>o2 ? 1 : -1);
+ *     return(0);
+ *}
+ */
+       .text
+ENTRY(Kcmpf, 0)
+       movl    4(fp),r12
+       jgeq    1f
+       xorl2   $0x80000000,r12
+       mnegl   r12,r12
+1:
+       movl    12(fp),r11
+       jgeq    1f
+       xorl2   $0x80000000,r11
+       mnegl   r11,r11
+1:
+       cmpl    r12,r11
+       jneq    1f
+       clr     r0; ret
+1:
+       jleq    1f
+       movl    $1,r0; ret
+1:
+       mnegl   $1,r0; ret
diff --git a/usr/src/sys/tahoemath/Kcvtdl.s b/usr/src/sys/tahoemath/Kcvtdl.s
new file mode 100644 (file)
index 0000000..6c0995b
--- /dev/null
@@ -0,0 +1,59 @@
+/*     Kcvtdl.s        1.3     86/01/05        */
+
+#include "../tahoemath/fp.h"
+#include "../tahoemath/Kfp.h"
+#include "../tahoe/SYS.h"
+
+       .text
+       .globl  _Kcvtdl
+       .globl  _Kcvtdu
+_Kcvtdu:
+_Kcvtdl:
+       .word   R5|R4|R3|R2
+
+ #
+ #Some initializations:
+ #
+       clrl    r3              # r3 - negative flag.
+       movl    4(fp),r0        # fetch operand.
+       movl    8(fp),r1        
+ #
+ #get exponent
+ #
+       andl3   $EXPMASK,r0,r2  # r2 will hold the exponent.
+       jeql    retzero 
+       cmpl    $TWO_EXP,r2     # if exponent is less then -2,return zero.
+       jgtr    retzero
+       andl2   $0!EXPSIGN,r2   # turn off biased exponent sign
+       shrl    $EXPSHIFT,r2,r2
+ #
+ #get fraction
+ #
+       bbc     $31,r0,positive # if negative remember it.
+       incl    r3
+positive:
+                               # clear the non fraction parts.
+       andl2   $(0!(EXPMASK | SIGNBIT)),r0
+                               # add the hidden bit.
+       orl2    $(0!CLEARHID),r0
+       subl2   $24,r2          # compute the shift.
+       jgtr    shift_left
+       mnegl   r2,r2
+       shrl    r2,r0,r0        # shift right.
+       jmp     shifted
+shift_left:
+       cmpl    r2,$7
+       jgtr    overflow
+go_on: shlq    r2,r0,r0        # shift right.
+shifted:
+       bbc     $0,r3,done      # check for negative
+       mnegl   r0,r0
+done:  
+       ret
+
+retzero:
+       clrl    r0
+       ret
+overflow:
+       ret
diff --git a/usr/src/sys/tahoemath/Kcvtfl.s b/usr/src/sys/tahoemath/Kcvtfl.s
new file mode 100644 (file)
index 0000000..aaa72c6
--- /dev/null
@@ -0,0 +1,58 @@
+/*     Kcvtfl.s        1.3     86/01/05        */
+
+#include "../tahoemath/fp.h"
+#include "../tahoe/SYS.h"
+
+       .text
+ENTRY(Kcvtfl, R5|R4|R3|R2)
+       clrl    r1
+       clrl    r4              # r4 - negative flag.
+       clrl    r2              # r2 - exponent.
+       movl    4(fp),r0        # fetch operand.
+       movl    r0,r5           # need another copy.
+       jeql    retzero         # return zero.
+       jgtr    positive
+       mnegl   r0,r0
+       jvs     retmin          # return minimum integer.
+       incl    r4              # remember it was negative.
+       movl    r0,r5           # remember the negated value.
+ #
+ #Compute exponent:
+ #
+positive:
+       ffs     r0,r1
+       incl    r1
+       addl2   r1,r2
+       shrl    r1,r0,r0
+       jneq    positive        # look for more set bits.
+ #
+ #we have the exponent in r2.
+ #
+       movl    r5,r0           # r0 will hold the resulting f.p. number.
+ #
+ #Shift the fraction part to its proper place:
+ #
+       subl3   r2,$HID_POS,r3
+       jlss    shiftr          # if less then zero we have to shift right.
+       shll    r3,r0,r0        # else we shift left.
+       jmp     shifted
+shiftr:
+       mnegl   r3,r3
+       shrl    r3,r0,r0
+shifted:
+       andl2   $CLEARHID,r0    # clear the hidden bit.
+       shal    $EXPSHIFT,r2,r2 # shift the exponent to its proper place.
+       orl2    $EXPSIGN,r2     # set the exponent sign bit(to bias it).
+       orl2    r2,r0           # combine exponent & fraction.
+       bbc     $0,r4,sign_ok   # do we  have to set the sign bit?
+       orl2    $SIGNBIT,r0     # yes...
+sign_ok:
+       ret
+
+retzero:
+       clrl    r0
+       ret
+
+retmin:
+       movl    $0xd0000000,r0
+       ret
diff --git a/usr/src/sys/tahoemath/Kcvtld.s b/usr/src/sys/tahoemath/Kcvtld.s
new file mode 100644 (file)
index 0000000..9c462ce
--- /dev/null
@@ -0,0 +1,64 @@
+/*     Kcvtld.s        1.3     86/01/05        */
+
+#include "../tahoemath/fp.h"
+#include "../tahoemath/Kfp.h"
+#include "../tahoe/SYS.h"
+
+       .text
+ENTRY(Kcvtld, R5|R4|R3|R2)
+       clrl    r4              # r4 - negative flag.
+       clrl    r2              # r2 - exponent.
+       movl    12(fp),r0       # fetch operand.
+       movl    r0,r5           # need another copy.
+       jeql    retzero         # return zero.
+       jgtr    positive
+       mnegl   r0,r0
+       jvs     retmin          # return minimum integer.
+       incl    r4              # remember it was negative.
+       movl    r0,r5           # remember the negated value.
+ #
+ #Compute exponent:
+ #
+positive:
+       ffs     r0,r1
+       incl    r1
+       addl2   r1,r2
+       shrl    r1,r0,r0
+       jneq    positive        # look for more set bits.
+ #
+ #we have the exponent in r2.
+ #
+       movl    r5,r0           # r0,r1 will hold the resulting f.p. number.
+       clrl    r1
+ #
+ #Shift the fraction part to its proper place:
+ #
+       subl3   r2,$HID_POS,r3
+       jlss    shiftr          # if less then zero we have to shift right.
+       shll    r3,r0,r0        # else we shift left.
+       jmp     shifted
+shiftr:
+       mnegl   r3,r3
+       shrq    r3,r0,r0
+shifted:
+       andl2   $CLEARHID,r0    # clear the hidden bit.
+       shal    $EXPSHIFT,r2,r2 # shift the exponent to its proper place.
+       orl2    $EXPSIGN,r2     # set the exponent sign bit(to bias it).
+       orl2    r2,r0           # combine exponent & fraction.
+       bbc     $0,r4,sign_ok   # do we  have to set the sign bit?
+       orl2    $SIGNBIT,r0     # yes...
+sign_ok:
+       ret
+
+retzero:
+       clrl    r0
+       clrl    r1
+       ret
+
+retmin:
+       movl    $0xd0000000,r0
+       clrl    r1
+       ret
+
+
+       
diff --git a/usr/src/sys/tahoemath/Kcvtlf.s b/usr/src/sys/tahoemath/Kcvtlf.s
new file mode 100644 (file)
index 0000000..793cfec
--- /dev/null
@@ -0,0 +1,59 @@
+/*     Kcvtlf.s        1.3     86/01/05        */
+
+#include "../tahoemath/fp.h"
+#include "../tahoemath/Kfp.h"
+#include "../tahoe/SYS.h"
+
+       .text
+ENTRY(Kcvtlf, R5|R4|R3|R2)
+       clrl    r1
+       clrl    r4              # r4 - negative flag.
+       clrl    r2              # r2 - exponent.
+       movl    12(fp),r0       # fetch operand.
+       movl    r0,r5           # need another copy.
+       jeql    retzero         # return zero.
+       jgtr    positive
+       mnegl   r0,r0
+       jvs     retmin          # return minimum integer.
+       incl    r4              # remember it was negative.
+       movl    r0,r5           # remember the negated value.
+ #
+ #Compute exponent:
+ #
+positive:
+       ffs     r0,r1
+       incl    r1
+       addl2   r1,r2
+       shrl    r1,r0,r0
+       jneq    positive        # look for more set bits.
+ #
+ #we have the exponent in r2.
+ #
+       movl    r5,r0           # r0 will hold the resulting f.p. number.
+ #
+ #Shift the fraction part to its proper place:
+ #
+       subl3   r2,$HID_POS,r3
+       jlss    shiftr          # if less then zero we have to shift right.
+       shll    r3,r0,r0        # else we shift left.
+       jmp     shifted
+shiftr:
+       mnegl   r3,r3
+       shrl    r3,r0,r0
+shifted:
+       andl2   $CLEARHID,r0    # clear the hidden bit.
+       shal    $EXPSHIFT,r2,r2 # shift the exponent to its proper place.
+       orl2    $EXPSIGN,r2     # set the exponent sign bit(to bias it).
+       orl2    r2,r0           # combine exponent & fraction.
+       bbc     $0,r4,sign_ok   # do we  have to set the sign bit?
+       orl2    $SIGNBIT,r0     # yes...
+sign_ok:
+       ret
+
+retzero:
+       clrl    r0
+       ret
+
+retmin:
+       movl    $0xd0000000,r0
+       ret
diff --git a/usr/src/sys/tahoemath/Kdivd.s b/usr/src/sys/tahoemath/Kdivd.s
new file mode 100644 (file)
index 0000000..7e81ef4
--- /dev/null
@@ -0,0 +1,93 @@
+/*     Kdivd.s 1.3     86/01/05        */
+
+#include "../tahoemath/fp.h"
+#include "../tahoemath/Kfp.h"
+#include "../tahoe/SYS.h"
+
+#define        HIDDEN  23              # here we count from 0 not from 1 as in fp.h
+
+       .text
+ENTRY(Kdivd, R9|R8|R7|R6|R5|R4|R3|R2)
+       clrl    r3              # r3 - sign: 0 for positive,1 for negative.
+       movl    4(fp),r0
+       jgeq    1f
+       movl    $1,r3
+1:     movl    12(fp),r2
+       jgeq    2f
+       bbc     $0,r3,1f        # seconed operand is negative.
+       clrl    r3              # if first was negative, make result positive.
+       jmp     2f
+1:     movl    $1,r3           # if first was positive, make result negative.
+2:     andl2   $EXPMASK,r0     # compute first 'pure'exponent.
+       jeql    retz
+       shrl    $EXPSHIFT,r0,r0
+       subl2   $BIAS,r0        
+       andl2   $EXPMASK,r2     # compute seconed 'pure'exponent.
+       jeql    retz2
+       shrl    $EXPSHIFT,r2,r2
+       subl2   $BIAS,r2
+       subl3   r2,r0,r2        # subtruct the exponents.
+       addl2   $BIAS,r2
+       jleq    underf
+                               # normalization can make the exp. smaller.
+ #
+ #     We have the sign in r3,the exponent in r2,now is the time to
+ #     perform the division...
+ #
+       # fetch dividend. (r4,r5)
+       andl3   $(0!(EXPMASK | SIGNBIT)),4(fp),r4
+       orl2    $(0!CLEARHID),r4
+       movl    8(fp),r5
+       # fetch divisor : (r6,r7)
+       andl3   $(0!(EXPMASK | SIGNBIT)),12(fp),r6
+       orl2    $(0!CLEARHID),r6
+       movl    16(fp),r7
+
+       movl    $0,r0           # init r0,r1 to be zeros
+       movl    $0,r1
+       movl    $(0!CLEARHID),r8# r8 first bit to set (if).
+       shll    $1,r8,r8        # to have one more bit,because we might
+                               # have to shift left to normelize.
+       movl    $0,r9
+
+2:
+       subl2   r7,r5
+       sbwc    r6,r4
+       jgeq    1f
+       addl2   r7,r5
+       adwc    r6,r4
+       shlq    $1,r4,r4
+       shrq    $1,r8,r8
+       jeql    over
+       jmp     2b
+1:     
+       orl2    r8,r0
+       orl2    r9,r1
+       shlq    $1,r4,r4
+       shrq    $1,r8,r8
+       jneq    2b
+       
+over:
+       pushl   20(fp)
+       callf   $8,_Kfnorm
+sign:
+1:     bbc     $0,r3,done
+       orl2    $SIGNBIT,r0
+done:  ret
+
+retz:
+         clrl  r0
+         clrl  r1
+         ret
+
+retz2: bbc     $31,12(fp),z_div
+         clrl  r0
+         clrl  r1
+         ret
+underf:
+       orl2    $HFS_UNDF,*20(fp)       
+       ret
+z_div:
+       orl2    $HFS_DIVZ,*20(fp)
+       ret
diff --git a/usr/src/sys/tahoemath/Kdivf.s b/usr/src/sys/tahoemath/Kdivf.s
new file mode 100644 (file)
index 0000000..4abec98
--- /dev/null
@@ -0,0 +1,76 @@
+/*     Kdivf.s 1.3     86/01/05        */
+
+#include "../tahoemath/fp.h"
+#include "../tahoemath/Kfp.h"
+#include "../tahoe/SYS.h"
+
+#define        HIDDEN  23              # here we count from 0 not from 1 as in fp.h
+
+       .text
+ENTRY(Kdivf, R9|R8|R7|R6|R5|R4|R3|R2)
+       clrl    r1
+       clrl    r3              # r3 - sign: 0 for positive,1 for negative.
+       movl    4(fp),r0
+       jgeq    1f
+       movl    $1,r3
+1:     movl    12(fp),r2
+       jgeq    2f
+       bbc     $0,r3,1f        # seconed operand is negative.
+       clrl    r3              # if first was negative, make result positive.
+       jmp     2f
+1:     movl    $1,r3           # if first was positive, make result negative.
+2:     andl2   $EXPMASK,r0     # compute first 'pure'exponent.
+       jeql    retz
+       shrl    $EXPSHIFT,r0,r0
+       subl2   $BIAS,r0        
+       andl2   $EXPMASK,r2     # compute seconed 'pure'exponent.
+       jeql    retz2
+       shrl    $EXPSHIFT,r2,r2
+       subl2   $BIAS,r2
+       subl3   r2,r0,r2        # subtruct the exponents.
+       addl2   $BIAS,r2
+       jleq    underf
+                               # normalization can make the exp. smaller.
+ #
+ #     We have the sign in r3,the exponent in r2,now is the time to
+ #     perform the division...
+ #
+       # fetch dividend. (r0)
+       andl3   $(0!(EXPMASK | SIGNBIT)),4(fp),r0
+       orl2    $(0!CLEARHID),r0
+       clrl    r1
+       # fetch divisor : (r6)
+       andl3   $(0!(EXPMASK | SIGNBIT)),12(fp),r6
+       orl2    $(0!CLEARHID),r6
+
+       shll    $2,r6,r6        # make the divisor bigger so we will not
+                               # get overflow at the divission.
+       ediv    r6,r0,r0,r7     # quo to r0, rem to r7
+       subl2   $6,r2           # to compensate for: normalization (-24),
+                               # ediv (+32), shifting r6 (-2).
+       
+over:
+       pushl   20(fp)
+       callf   $8,_Kfnorm      # we can use fnorm because we have data
+                               # at r1 as well.(sfnorm takes care only 
+                               # of r0).
+sign:
+1:     bbc     $0,r3,done
+       orl2    $SIGNBIT,r0
+done:  ret
+
+retz:
+       clrl    r0
+       ret
+
+retz2: bbc     $31,12(fp),z_div
+       clrl    r0
+       ret
+
+underf:
+       orl2    $HFS_UNDF,*20(fp)       
+       ret
+z_div:
+       orl2    $HFS_DIVZ,*20(fp)
+       ret
diff --git a/usr/src/sys/tahoemath/Kexpf.s b/usr/src/sys/tahoemath/Kexpf.s
new file mode 100644 (file)
index 0000000..601fd4b
--- /dev/null
@@ -0,0 +1,211 @@
+/*     Kexpf.s 1.3     86/01/05        */
+
+#include "../tahoe/SYS.h"
+
+       .text
+ENTRY(Kexpf, R4|R3)
+       subl3   $88,fp,sp
+       tstl    4(fp)
+       jneq    1f
+       movl    one,r0
+       ret
+1:
+       lnd     _maxf
+       cmpd    4(fp)
+       jleq    1f
+       clrl    r0
+       ret
+1:
+       cmpd2   4(fp),_maxf
+       jleq    1f
+       ldd     _HUGE
+       cvdf
+       stf     r0
+       ret
+1:     
+       pushl   20(fp)          # hfs
+       ldd     _log2e; pushd
+       ldd     4(fp); pushd
+       callf   $24,_Kmuld
+       ldd     r0
+       std     4(fp)
+
+       pushl   20(fp)          # hfs
+       pushl   8(fp)
+       pushl   4(fp)
+       callf   $16,_Kfloorf
+       movl    r0,-88(fp)      # (int)ent from Kfloorf
+
+       cvlf    -88(fp)
+       clrl    r1
+       stf     r0
+       pushl   20(fp)          # hfs
+       pushl   r1
+       pushl   r0
+       ldd     4(fp); pushd
+       callf   $24,_Ksubd      # (arg - ent)
+
+       pushl   20(fp)          # hfs
+       ldd     half; pushd
+       ldd     r0; pushd
+       callf   $24,_Ksubd
+       ldd     r0; std -60(fp) # fract
+
+       pushl   20(fp)          # hfs
+       pushd
+       pushd
+       callf   $24,_Kmuld
+       ldd     r0; std -84(fp) # xsq
+
+       pushl   20(fp)          # hfs
+       pushd                   # xsq
+       ldd     _p2; pushd
+       callf   $24,_Kmuld
+
+       pushl   20(fp)          # hfs
+       ldd     _p1; pushd
+       ldd     r0; pushd
+       callf   $24,_Kaddd
+
+       pushl   20(fp)          # hfs
+       ldd     -84(fp); pushd
+       ldd     r0; pushd
+       callf   $24,_Kmuld
+
+       pushl   20(fp)          # hfs
+       ldd     _p0; pushd
+       ldd     r0; pushd
+       callf   $24,_Kaddd
+
+       pushl   20(fp)          # hfs
+       ldd     -60(fp); pushd  # fract
+       ldd     r0; pushd
+       callf   $24,_Kmuld
+       ldd     r0; std -68(fp) # temp1
+
+       pushl   20(fp)          # hfs
+       ldd     -84(fp); pushd  # xsq
+       ldd     _q2; pushd
+       callf   $24,_Kmuld
+
+       pushl   20(fp)          # hfs
+       ldd     _q1; pushd
+       ldd     r0; pushd
+       callf   $24,_Kaddd
+
+       pushl   20(fp)          # hfs
+       ldd     -84(fp); pushd
+       ldd     r0; pushd
+       callf   $24,_Kmuld
+
+       pushl   20(fp)          # hfs
+       ldd     _q0; pushd
+       ldd     r0; pushd
+       callf   $24,_Kaddd
+       ldd     r0; std -76(fp) # temp2
+
+       pushl   20(fp)          # hfs for Kldexpf
+       pushl   -88(fp)         # ent
+
+       pushl   20(fp)          # hfs tor temp2+temp1
+       ldd     -68(fp); pushd  # temp1
+       ldd     -76(fp); pushd  # temp2
+       callf   $24,_Kaddd
+
+       pushl   20(fp)          # hfs
+       ldd     _sqrt2; pushd
+       ldd     r0; pushd       # temp2+temp1
+       callf   $24,_Kmuld
+       ldd     r0; std r2              # sqrt2*(temp2+temp1)
+
+       pushl   20(fp)          # hfs
+       ldd     -68(fp)
+       pushd
+       ldd     -76(fp)
+       pushd
+       callf   $24,_Ksubd      # temp2-temp1
+
+       pushl   20(fp)          # hfs
+       ldd     r0
+       pushd                   # temp2-temp1
+       ldd     r2
+       pushd
+       callf   $24,_Kdivd
+
+       ldd     r0
+       pushd
+       callf   $20,_Kldexpf
+
+       #pushl  20(fp)          # hfs
+       #pushl  $0
+       #pushl  r0              # cvlf  r0
+       #pushl  $0
+       #pushl  $0
+       #callf  $24,_Kcvtld
+
+       #ldd    r0
+       #cvdf
+       #stf    r0
+       ret
+
+/* file : Kfloorf.x
+*/
+       .text
+       .globl  _Kfloorf
+       .data
+       .align  2
+L19:   .long   0x40800000, 0x00000000 # .double 1
+       .text
+       .set    L13,0x0
+       .data
+       .text
+_Kfloorf:
+       .word   L13
+       subl3   $60,fp,sp
+       tstl    4(fp)           # if (d<0.0) {
+       jgeq    L17
+       lnd     4(fp)
+       std     4(fp)           # d = -d;
+       pushl   12(fp)          # hfs
+       addl3   $4,fp,-(sp)     # &d
+       pushl   8(fp)
+       pushl   4(fp)
+       callf   $20,_Kmodf
+       clrl    -60+4(fp)
+       movl    r0,-60(fp)      # fract = modf(d,&d);
+       tstl    r0              # if (fract != 0.0)
+       jeql    L18
+       pushl   12(fp)          # hfs
+       ldd     L19
+       pushd
+       ldd     4(fp)
+       pushd
+       callf   $24,_Kaddd
+       ldd     r0
+       std     4(fp)           # d +=1;
+L18:   lnd     4(fp)
+       std     4(fp)           # d = -d;
+       jbr     L20
+L17:   
+       pushl   12(fp)          # hfs
+       addl3   $4,fp,-(sp)
+       pushl   8(fp)
+       pushl   4(fp)
+       callf   $20,_Kmodf
+L20:   ldd     4(fp)
+       cvdl    r0              # for Kexpf call only!
+       ret
+       
+       .data
+_p0:   .long   0x45BD3D04, 0x7F734DBD # .double 1513.9067990543389
+_p1:   .long   0x42A19DD4, 0x989F60DA # .double 20.202065651286927
+_p2:   .long   0x3DBD2E42, 0xAB70BDA9 # .double .023093347753750233
+_q0:   .long   0x468881B1, 0x7C3A6529 # .double 4368.2116627275583
+_q1:   .long   0x44692F28, 0x7AE89541 # .double 233.18421142748162
+_q2:   .long   0x40800000, 0x00000000 # .double 1
+_log2e:        .long   0x40B8AA3B, 0x295C17F0 # .double 1.4426950408889634
+_sqrt2:        .long   0x40B504F3, 0x33F9DE64 # .double 1.414213562373095
+_maxf: .long   0x471C4000, 0x00000000 # .double 10000
+_HUGE: .long   0x7FFFFFFE, 0xFFFFFFFC # .double 1.701411733192644e+38
+one:   .long   0x40800000 # .float 1
+half:  .long   0x40000000, 0x00000000 # .double .5
diff --git a/usr/src/sys/tahoemath/Kfnorm.s b/usr/src/sys/tahoemath/Kfnorm.s
new file mode 100644 (file)
index 0000000..f61738d
--- /dev/null
@@ -0,0 +1,60 @@
+/*     Kfnorm.s        1.3     86/01/05        */
+
+#include "../tahoemath/fp.h"
+#include "../tahoemath/Kfp.h"
+#include "../tahoe/SYS.h"
+
+       .text
+ENTRY(Kfnorm, R6|R5|R4|R3|R2)
+                               # clrl  r1
+       movl    r0,r4           # copy to temporary.
+       jneq    inr0
+       movl    r1,r5
+       clrl    r3              # r3 - pos of m.s.b
+inr1:  ffs     r5,r6
+       incl    r6
+       addl2   r6,r3
+       shrl    r6,r5,r5
+       jneq    inr1
+       cmpl    $0,r3
+       jeql    retzero
+       jmp     cmpshift
+inr0:  movl    $32,r3
+inr00: ffs     r4,r6
+       incl    r6
+       addl2   r6,r3
+       shrl    r6,r4,r4
+       jneq    inr00
+
+cmpshift:
+                               # compute the shift (r4).
+       subl3   r3,$HID_R0R1,r4
+       jlss    shiftr          # if less then zero we shift right.
+       shlq    r4,r0,r0        # else we shift left.
+       subl2   r4,r2           # uodate exponent.
+       jleq    underflow       # if less then 0 (biased) it is underflow.
+       jmp     combine         # go to combine exponent and fraction.
+shiftr:
+       mnegl   r4,r4
+       shrq    r4,r0,r0        # shift right.
+       addl2   r4,r2           # update exponent
+       cmpl    r2,$256
+       jgeq    overflow        # check for overflow.
+combine:
+       andl2   $CLEARHID,r0    # clear the hidden bit.
+       shal    $EXPSHIFT,r2,r2 # shift the exponent to its proper place.
+       orl2    r2,r0
+       ret
+
+underflow:
+       clrl    r0
+       orl2    $HFS_UNDF,*4(fp)        
+       ret
+
+overflow:
+       orl2    $HFS_OVF,*4(fp)         
+       ret
+retzero:
+       clrl    r0
+       clrl    r1
+       ret
diff --git a/usr/src/sys/tahoemath/Kfp_exp.s b/usr/src/sys/tahoemath/Kfp_exp.s
new file mode 100644 (file)
index 0000000..1a69b06
--- /dev/null
@@ -0,0 +1,19 @@
+/*     Kfp_exp.s       1.3     86/01/05        */
+
+#include "../tahoemath/fp.h"
+#include "../tahoemath/Kfp.h"
+#include "../tahoe/SYS.h"
+
+ENTRY(Kfpover, 0)
+       movl    $HUGE0,r0
+       movl    $HUGE1,r1
+       ret
+
+ENTRY(Kfpunder, 0)
+       clrl    r0
+       clrl    r1
+       ret
+
+ENTRY(Kfpzdiv, 0)
+       divl2   $0,r1           # force division by zero.
+       ret
diff --git a/usr/src/sys/tahoemath/Kfp_mvtoacc.s b/usr/src/sys/tahoemath/Kfp_mvtoacc.s
new file mode 100644 (file)
index 0000000..ffd232f
--- /dev/null
@@ -0,0 +1,24 @@
+/*     Kfp_mvtoacc.s   1.3     86/01/05        */
+
+#include "../tahoemath/fp.h"
+#include "../tahoe/SYS.h"
+
+/*
+ * mvtofacc(value, acc_addr)
+ *
+ * move value to floating point accumulator
+ */
+ENTRY(mvtofacc, 0)
+       movl    4(fp),*12(fp)
+       ret
+
+/*
+ * mvtodacc(value_hi, value_lo, acc_addr)
+ *
+ * move value to double precision accumulator
+ */
+ENTRY(mvtodacc, 0)
+       movl    12(fp),r0       # address of accumulator
+       movl    4(fp),(r0)      # most significant longword
+       movl    8(fp),4(r0)     # least significant longword
+       ret
diff --git a/usr/src/sys/tahoemath/Kfrexpd.s b/usr/src/sys/tahoemath/Kfrexpd.s
new file mode 100644 (file)
index 0000000..1e32d58
--- /dev/null
@@ -0,0 +1,58 @@
+/*     Kfrexpd.s       1.3     86/01/05        */
+
+#include "../tahoe/SYS.h"
+
+       .text
+ENTRY(Kfrexpd, 0)
+       subl3   $60,fp,sp
+       clrl    -60(fp)
+       clrl    -56(fp)
+       tstl    4(fp)
+       jgeq    1f
+       lnd     4(fp)
+       std     4(fp)
+       movl    $1,-56(fp)
+1:
+       cmpd2   4(fp),one
+       jleq    1f
+2:
+       cmpd2   4(fp),one
+       jleq    3f
+       addl2   $1,-60(fp)
+       pushl   16(fp)          # hfs
+       pushl   two+4           # ldd   2.0
+       pushl   two
+       pushl   8(fp)
+       pushl   4(fp)           # acc
+       callf   $24,_Kdivd
+       ldd     r0
+       std     4(fp)
+       jbr     2b
+1:     cmpd2   4(fp),half
+       jlss    2f
+       jbr     3f
+0:
+       subl2   $1,-60(fp)
+       pushl   16(fp)          # hfs
+       ldd     two; pushd      # 2.0
+       ldd     4(fp); pushd    # acc
+       callf   $24,_Kmuld
+       ldd     r0
+       std     4(fp)
+2:
+       cmpd2   4(fp),half
+       jlss    0b
+3:     movl    -60(fp),*12(fp)
+       tstl    -56(fp)
+       jeql    1f
+       lnd     4(fp)
+       std     4(fp)
+1:
+       movl    8(fp),r1
+       movl    4(fp),r0
+       ret
+       .data
+       .align 2
+one:   .long   0x40800000, 0x00000000 # .double 1
+two:   .long   0x41000000, 0x00000000 # .double 2
+half:  .long   0x40000000, 0x00000000 # .double 0.5
diff --git a/usr/src/sys/tahoemath/Kfrexpf.s b/usr/src/sys/tahoemath/Kfrexpf.s
new file mode 100644 (file)
index 0000000..e8c5628
--- /dev/null
@@ -0,0 +1,64 @@
+/*     Kfrexpf.s       1.3     86/01/05        */
+
+#include "../tahoe/SYS.h"
+
+       .text
+ENTRY(Kfrexpf, 0)
+       subl3   $60,fp,sp
+       clrl    -60(fp)         # j=0;
+       clrl    -56(fp)         # neg=0;
+       tstl    4(fp)           # if(x<0){
+       jgeq    1f
+       lnd     4(fp)
+       std     4(fp)           # x = -x;
+       movl    $1,-56(fp)      # neg=1;}
+1:
+       cmpd2   4(fp),one       # if (x>1){
+       jleq    1f
+2:
+       cmpd2   4(fp),one       # while(x>1){
+       jleq    3f
+       addl2   $1,-60(fp)      # j=j+1;
+       pushl   16(fp)          # hfs   
+       ldd     two
+       pushd
+       ldd     4(fp)
+       pushd
+       callf   $24,_Kdivd
+       ldd     r0
+       std     4(fp)           # x= x/2;
+       jbr     2b
+1:
+       cmpd2   4(fp),half      # if(x<0.5){
+       jlss    2f
+       jbr     3f
+0:
+       subl2   $1,-60(fp)      # j = j-1;
+       pushl   16(fp)          # hfs
+       ldd     4(fp)
+       pushd
+       ldd     two
+       pushd
+       callf   $24,_Kmuld
+       ldd     r0
+       std     4(fp)           # x = 2*x;
+2:
+       cmpd2   4(fp),half      # while (x<0.5){
+       jlss    0b
+3:
+       movl    -60(fp),*12(fp) # *i=j;
+       tstl    -56(fp)         # if (neg)
+       jeql    1f
+       lnd     4(fp)
+       std     4(fp)
+1:
+       ldd     4(fp)
+       cvdf
+       stf     r0
+       ret
+
+       .data
+       .align  2
+one:   .long   0x40800000, 0x00000000 # .double 1
+two:   .long   0x41000000, 0x00000000 # .double 2
+half:  .long   0x40000000, 0x00000000 # .double .5
diff --git a/usr/src/sys/tahoemath/Kldexpf.s b/usr/src/sys/tahoemath/Kldexpf.s
new file mode 100644 (file)
index 0000000..8c7f464
--- /dev/null
@@ -0,0 +1,62 @@
+/*     Kldexpf.s       1.3     86/01/05        */
+
+#include "../tahoe/SYS.h"
+#include "../tahoemath/fp.h"
+#include "../tahoemath/Kfp.h"
+
+/* @(*)Kldexpf.s       4.2 (Berkeley) 12/21/80
+ *     Tahoe           2/2/83
+ *
+ * float Kldexpf (op_most, op_least, exp, hfs)
+ *
+ * Ldexp returns value*2**exp, if that result is in range.
+ * If underflow occurs, it returns zero.  If overflow occurs,
+ * it returns a value of appropriate sign and largest
+ * possible magnitude.  In case of either overflow or underflow,
+ * the external int "errno" is set to ERANGE.  Note that errno is
+ * not modified if no error occurs, so if you intend to test it
+ * after you use Kldexpf, you had better set it to something
+ * other than ERANGE first (zero is a reasonable value to use).
+ */
+
+       .text
+ENTRY(Kldexpf, R2)
+       movl    4(fp),r0        /* Fetch "value" */
+       movl    8(fp),r1
+
+       andl3   $EXPMASK,r0,r2  /* r2 := shifted biased exponent */
+       jeql    ld1             /* If it's zero, we're done */
+       shar    $EXPSHIFT,r2,r2 /* shift to get value of exponent  */
+
+       addl2   12(fp),r2       /* r2 := new biased exponent */
+       jleq    under           /* if it's <= 0, we have an underflow */
+       cmpl    r2,$256         /* Otherwise check if it's too big */
+       jgeq    over            /* jump if overflow */
+/*
+ *     Construct the result and return
+ */
+       andl2   $0!EXPMASK,r0   /* clear old exponent */
+       shal    $EXPSHIFT,r2,r2 /* Put the exponent back in the result */
+       orl2    r2,r0
+ld1:   ret
+/*
+ *     Underflow
+ */
+under: clrl    r0              /* Result is zero */
+       clrl    r1
+       orl2    $HFS_UNDF,*16(fp)
+       jmp     err             /* Join general error code */
+/*
+ *     Overflow
+ */
+over:  movl    huge0,r0        /* Largest possible floating magnitude */
+       movl    huge1,r1
+       orl2    $HFS_OVF,*16(fp)
+       orl2    $SIGNBIT,r0     /* If arg < 0, make result negative */
+
+err:   orl2    $HFS_RANGE,*16(fp)      /* Indicate range error */
+       ret
+
+       .data
+huge0: .long   0x7fffffff
+huge1: .long   0xffffffff
diff --git a/usr/src/sys/tahoemath/Klogf.s b/usr/src/sys/tahoemath/Klogf.s
new file mode 100644 (file)
index 0000000..5c88df7
--- /dev/null
@@ -0,0 +1,162 @@
+/*     Klogf.s 1.3     86/01/05        */
+
+#include "../tahoe/SYS.h"
+
+       .text
+ENTRY(Klogf, R5|R4|R3|R2)
+       subl3   $88,fp,sp
+       clrl    8(fp)
+       tstl    4(fp)
+       jgtr    L53
+       movl    small+4,r1
+       movl    small,r0
+       ret
+L53:   pushl   20(fp)                  # hfs
+       subl3   $88,fp,-(sp)            # &exp
+       pushl   8(fp)                   # arg
+       pushl   4(fp)
+       callf   $20,_Kfrexpf
+       ldd     r0
+                                       # movl  r1,-56(fp)
+       std     -60(fp)                 # movl  r0,-60(fp)
+       jbr     L55
+L2000001:
+       pushl   20(fp)                  # hfs
+       ldd     two                     # 2.0
+       pushd
+       ldd     -60(fp)                 # x
+       pushd   
+       callf   $24,_Kmuld
+       ldd     r0
+       std     -60(fp)
+       subl2   $1,-88(fp)
+L55:   cmpd2   -60(fp),half
+       jlss    L2000001
+       cmpd2   -60(fp),_sqrto2
+       jgeq    L59
+       pushl   20(fp)                  # hfs
+       ldd     -60(fp)                 # x
+       pushd
+       ldd     two                     # 2.0
+       pushd
+       callf   $24,_Kmuld
+       ldd     r0
+       std     -60(fp)
+       subl2   $1,-88(fp)
+L59:   pushl   20(fp)                  # hfs
+       ldd     one                     # 1.0
+       pushd
+       ldd     -60(fp)                 # x
+       pushd
+       callf   $24,_Ksubd      
+       ldd     r0
+       std     r2
+       pushl   20(fp)                  # hfs
+       ldd     one                     # 1.0
+       pushd
+       ldd     -60(fp)                 # x
+       pushd
+       callf   $24,_Kaddd
+       ldd     r0
+       std     r4
+       pushl   20(fp)                  # hfs
+       ldd     r4                      # temp result of x-1
+       pushd
+       ldd     r2                      # temp result of x+1
+       pushd
+       callf   $24,_Kdivd
+       ldd     r0
+       std     -68(fp)                 # z
+       pushl   20(fp)                  # hfs
+       pushd                           # z
+       pushd                           # z
+       callf   $24,_Kmuld
+       ldd     r0
+       std     -76(fp)                 # zsq
+       pushl   20(fp)                  # hfs
+       ldd     -76(fp)                 # zsq
+       pushd
+       ldd     _p1                     # p1
+       pushd
+       callf   $24,_Kmuld
+       ldd     r0
+       std     r2
+       pushl   20(fp)                  # hfs
+       ldd     _p0                     # p0
+       pushd
+       ldd     r2
+       pushd
+       callf   $24,_Kaddd
+       ldd     r0
+       std     -84(fp)                 # temp
+       pushl   20(fp)                  # hfs
+       ldd     -76(fp)                 # zsq
+       pushd
+       ldd     _q1
+       pushd
+       callf   $24,_Kmuld
+       ldd     r0
+       std     r2
+       pushl   20(fp)                  # hfs
+       ldd     _q0                     # q0
+       pushd
+       ldd     r2
+       pushd
+       callf   $24,_Kaddd
+       ldd     r0
+       std     r2                      # temp result of (q1*zsq+q0)
+       pushl   20(fp)                  # hfs
+       ldd     r2
+       pushd
+       ldd     -84(fp)                 # temp
+       pushd
+       callf   $24,_Kdivd
+       ldd     r0
+       std     -84(fp)                 # put in temp
+       pushl   20(fp)                  # hfs
+       ldd     -68(fp)                 # z
+       pushd
+       ldd     -84(fp)
+       pushd
+       callf   $24,_Kmuld
+       ldd     r0
+       std     r2
+       pushl   20(fp)                  #hfs
+       pushl   $0                      # 0 pad
+       pushl   -88(fp)                 # exp
+       pushl   $0                      # dummy
+       pushl   $0                      # dummy
+       callf   $24,_Kcvtld
+       pushl   20(fp)                  # hfs
+       ldd     _log2                   # log2
+       pushd
+       pushl   r1                      # exp converted
+       pushl   r0                      
+       callf   $24,_Kmuld
+       ldd     r0
+       std     r4
+       pushl   20(fp)                  # hfs
+       ldd     r2                      # result of temp*z
+       pushd
+       ldd     r4
+       pushd
+       callf   $24,_Kaddd
+       ldd     r0
+       cvdf
+       stf     r0
+       clrl    r1
+       ret
+
+       .data
+       .align  2
+_log2: .long   0x40317217, 0xf7d1cf7a # .double 0.69314718055994531
+_ln10: .long   0x41135d8d, 0xddaaa8ac # .double 2.3025850929940457
+_sqrto2:.long  0x403504f3, 0x33f9de65 # .double 0.70710678118654753
+_p0:   .long   0xc154114d, 0xeb0ba468 # .double -3.31355617479
+_p1:   .long   0x40654226, 0x56bd0c4c # .double 0.89554061525
+_q0:   .long   0xc0d4114c, 0xfdc7df02 # .double -1.65677797691
+_q1:   .long   0x40800000, 0x00000000 # .double 1
+small: .long   0xfffffffe, 0xfffffffe # .double -1.7014117331926443e+38
+half:  .long   0x40000000, 0x00000000 # .double 0.5
+two:   .long   0x41000000, 0x00000000 # .double 2
+one:   .long   0x40800000, 0x00000000 # .double 1
diff --git a/usr/src/sys/tahoemath/Kmodf.s b/usr/src/sys/tahoemath/Kmodf.s
new file mode 100644 (file)
index 0000000..6c043d1
--- /dev/null
@@ -0,0 +1,112 @@
+/*     Kmodf.s 1.3     86/01/05        */
+
+#include "../tahoe/SYS.h"
+#include "../tahoemath/fp.h"
+
+/* 
+ *  float Kmodf (value, iptr, hfs)
+ *  float value, *iptr;
+ *  int hfs;
+ * 
+ *  Modf returns the fractional part of "value",
+ *  and stores the integer part indirectly through "iptr".
+ */ 
+       .text
+ENTRY(Kmodf, R8|R7|R6|R5|R4|R3|R2)
+ /*
+ * Some initializations:
+ */
+       clrl    r3
+       movl    4(fp),r0        /* fetch operand to r0. */
+       movl    8(fp),r1
+       movl    12(fp),r6       /* fetch addr of int to r6. */
+ /*
+  * get exponent
+  */
+       andl3   $EXPMASK,r0,r2  /* r2 will hold the exponent. */
+       shrl    $EXPSHIFT,r2,r2
+       subl2   $BIAS,r2        /* unbias it.  */
+       jleq    allfrac         /* it's int part is  zero. */
+       cmpl    r2,$56
+       jgeq    allint          /* it's fraction part is zero. */
+ /*
+  * get fraction
+  */
+       movl    r0,r4           /* remember the original number. */
+       movl    r1,r5
+       bbc     $31,r0,positive /* if negative remember it. */
+       incl    r3
+positive:
+                               /* clear the non fraction parts. */
+       andl2   $(0!(EXPMASK | SIGNBIT)),r0
+                               /* add the hidden bit. */
+       orl2    $(0!CLEARHID),r0
+
+       cmpl    r2,$HID_POS     /* see if there are bits to clear only in r0 */
+       jgtr    in_r1           /* some bytes in r1     */
+       jeql    onlyallr0       /* all r0 must be cleared. */
+       mnegl   r2,r7           /* r7 - loop counter. */
+       movl    $CLEARHID,r8    /* first bit to clear. */
+1:
+       andl2   r8,r0           /* clear int. bits from fraction part. */
+       shar    $1,r8,r8
+       aoblss  $0,r7,1b
+1:
+       andl2   r8,r4           /* clear frac bits for int calculation: */
+       shar    $1,r8,r8
+       cmpl    $0xffffffff,r8
+       jneq    1b
+       clrl    r5
+       jmp     norm
+
+onlyallr0:
+       clrl    r0
+       clrl    r5
+       jmp     norm
+
+in_r1:
+       clrl    r0
+       subl3   r2,$HID_POS,r7
+       movl    $0x7fffffff,r8
+1:
+       andl2   r8,r1
+       shar    $1,r8,r8
+       orl2    $0x80000000,r8
+       aoblss  $0,r7,1b
+1:
+       andl2   r8,r5
+       shar    $1,r8,r8
+       cmpl    $0xffffffff,r8
+       jneq    1b
+norm:
+       addl2   $BIAS,r2        /* fnorm expects it biased. */
+       pushl   16(fp)          /* hfs */
+       callf   $8,_Kfnorm      /* normelize fraction part. */
+       cmpl    $0,r0
+       jeql    1f
+       bbc     $0,r3,1f
+       orl2    $0x80000000,r0
+1:
+       movl    r4,(r6)         /* put int part in place. */
+       movl    r5,4(r6)
+       ret
+allint:
+       movl    r0,(r6)         /* copy the argument to the int addr. */
+       movl    r1,4(r6)
+       clrl    r0              /* clear the fraction part. */
+       clrl    r1
+       ret
+
+allfrac:
+                               /* the fraction is ready in r0. */
+       clrl    (r6)            /* zero the int part. */
+       clrl    4(r6)
+       ret
+
+ret_zero:
+       clrl    (r6)
+       clrl    4(r6)   
+       clrl    r0
+       clrl    r1
+       ret
diff --git a/usr/src/sys/tahoemath/Kmuld.s b/usr/src/sys/tahoemath/Kmuld.s
new file mode 100644 (file)
index 0000000..7a1c3dc
--- /dev/null
@@ -0,0 +1,109 @@
+/*     Kmuld.s 1.3     86/01/05        */
+
+#include "../tahoemath/fp.h"
+#include "../tahoemath/Kfp.h"
+#include "../tahoe/SYS.h"
+
+#define        HIDDEN  23      /* here we count from 0 not from 1 as in fp.h */
+
+/*
+ * _Kmuld(acc_most,acc_least,op_most,op_least,hfs)
+ */
+       .text
+ENTRY(Kmuld, R9|R8|R7|R6|R5|R4|R3|R2)
+       clrl    r3              /* r3 - sign: 0 for positive,1 for negative. */
+       movl    4(fp),r0
+       jgeq    1f
+       movl    $1,r3
+1:     movl    12(fp),r2
+       jgeq    2f
+       bbc     $0,r3,1f        /* seconed operand is negative. */
+       clrl    r3              /* if first was neg, make result pos */
+       jmp     2f
+1:     movl    $1,r3           /* if first was pos, make result neg */
+2:     andl2   $EXPMASK,r0     /* compute first 'pure'exponent. */
+       jeql    retzero
+       shrl    $EXPSHIFT,r0,r0
+       subl2   $BIASP1,r0      
+       andl2   $EXPMASK,r2     /* compute seconed 'pure'exponent. */
+       jeql    retzero
+       shrl    $EXPSHIFT,r2,r2
+       subl2   $BIASP1,r2
+       addl2   r0,r2           /* add the exponents. */
+       addl2   $(BIASP1+2),r2
+       jleq    underflow
+       cmpl    r2,$258         /* normalization can make the exp. smaller. */
+       jgeq    overflow
+ /*
+  *    We have the sign in r3,the exponent in r2,now is the time to
+  *    perform the multiplication...
+  */
+       /* fetch first fraction: (r0,r1) */
+       andl3   $(0!(EXPMASK | SIGNBIT)),4(fp),r0
+       orl2    $(0!CLEARHID),r0
+       movl    8(fp),r1
+       shlq    $7,r0,r0        /* leave the sign bit cleared. */
+       /* fetch seconed fraction: (r4,r5) */
+       andl3   $(0!(EXPMASK | SIGNBIT)),12(fp),r4
+       orl2    $(0!CLEARHID),r4
+       movl    16(fp),r5
+       shlq    $7,r4,r4        /* leave the sign bit cleared. */
+
+       /* in the following lp1 stands for least significant part of operand 1,
+       *                  lp2 for least significant part of operand 2,
+       *                  mp1 for most significant part of operand 1,
+       *                  mp2 for most significant part of operand 2.
+       */
+       clrl    r6
+       shrl    $1,r1,r1        /* clear the sign bit of the lp1. */
+       jeql    1f
+       emul    r1,r4,$0,r6     /* r6,r7 <-- lp1*mp2 */
+       shlq    $1,r6,r6        /* to compensate for the shift we did to clear the sign bit. */
+1:     shrl    $1,r5,r5        /* clear the sign bit of the lp2. */
+       jeql    1f
+       emul    r0,r5,$0,r8     /* r8,r9 <-- mp1*lp2 */
+       shlq    $1,r8,r8
+       addl2   r9,r7           /* r6,r7 <-- the sum of the products. */
+       adwc    r8,r6
+1:     emul    r0,r4,$0,r0     /* r0,r1 <-- mp1*mp2  */
+       addl2   r6,r1           /* add the most sig. part of the sum. */
+       adwc    $0,r0
+       movl    r0,r4           /* to see how much we realy need to shift. */
+       movl    $6,r5           /* r5 - shift counter. */
+       shrl    $7,r4,r4        /* dummy shift. */
+1:     bbs     $HIDDEN,r4,realshift
+       shll    $1,r4,r4
+       decl    r2              /* update exponent. */
+       jeql    underflow
+       decl    r5              /* update shift counter. */
+       jmp     1b
+realshift:
+       shrq    r5,r0,r0
+       bbc     $0,r1,shiftmore
+       incl    r1              /* rounding. */
+shiftmore:
+       shrq    $1,r0,r0
+comb:
+       andl2   $CLEARHID,r0
+       shll    $EXPSHIFT,r2,r4
+       orl2    r4,r0
+       cmpl    r2,$256
+       jlss    1f
+       orl2    $HFS_OVF,*20(fp)        
+sign:
+1:     bbc     $0,r3,done
+       orl2    $SIGNBIT,r0
+done:  ret
+
+retzero:
+       clrl    r0
+       clrl    r1
+       ret
+overflow:
+       orl2    $HFS_OVF,*20(fp)
+       ret
+underflow:
+       orl2    $HFS_UNDF,*20(fp)
+       ret
diff --git a/usr/src/sys/tahoemath/Kmulf.s b/usr/src/sys/tahoemath/Kmulf.s
new file mode 100644 (file)
index 0000000..88a0702
--- /dev/null
@@ -0,0 +1,93 @@
+/*     Kmulf.s 1.3     86/01/05        */
+
+#include "../tahoemath/fp.h"
+#include "../tahoemath/Kfp.h"
+#include "../tahoe/SYS.h"
+
+#define        HIDDEN  23      /* here we count from 0 not from 1 as in fp.h */
+
+/* 
+ * _Kmulf(acc_most,acc_least,op_most,op_least,hfs)
+ */
+       .text
+ENTRY(Kmulf, R5|R4|R3|R2)
+       clrl    r3              /* r3 - sign: 0 for positive,1 for negative. */
+       movl    4(fp),r0
+       jgeq    1f
+       movl    $1,r3
+1:     movl    12(fp),r2
+       jgeq    2f
+       bbc     $0,r3,1f        /* seconed operand is negative. */
+       clrl    r3              /* if first was negative, make result positive. */
+       jmp     2f
+1:     movl    $1,r3           /* if first was positive, make result negative. */
+2:     andl2   $EXPMASK,r0     /* compute first 'pure'exponent. */
+       jeql    retzero
+       shrl    $EXPSHIFT,r0,r0
+       subl2   $BIASP1,r0      
+       andl2   $EXPMASK,r2     /* compute seconed 'pure'exponent. */
+       jeql    retzero
+       shrl    $EXPSHIFT,r2,r2
+       subl2   $BIASP1,r2
+       addl2   r0,r2           /* add the exponents. */
+       addl2   $(BIASP1+2),r2
+       jleq    underflow
+       cmpl    r2,$258         /* normalization can make the exp. smaller. */
+       jgeq    overflow
+ /*
+ *     We have the sign in r3,the exponent in r2,now is the time to
+ *     perform the multiplication...
+ */
+       /* fetch first fraction: (r0) */
+       andl3   $(0!(EXPMASK | SIGNBIT)),4(fp),r0
+       orl2    $(0!CLEARHID),r0
+       shll    $7,r0,r0        /* leave the sign bit cleared. */
+       /* fetch seconed fraction: (r4) */
+       andl3   $(0!(EXPMASK | SIGNBIT)),12(fp),r4
+       orl2    $(0!CLEARHID),r4
+       shll    $7,r4,r4        /* leave the sign bit cleared. */
+
+       emul    r4,r0,$0,r0
+       movl    r0,r4           /* to see how much we realy need to shift. */
+       movl    $6,r5           /* r5 - shift counter. */
+       shrl    $7,r4,r4        /* dummy shift. */
+1:     bbs     $HIDDEN,r4,realshift
+       shll    $1,r4,r4
+       decl    r2              /* update exponent. */
+       jeql    underflow
+       decl    r5              /* update shift counter. */
+       jmp     1b
+realshift:
+       shrl    r5,r0,r0
+       bbc     $0,r1,shiftmore
+       incl    r1              /* rounding. */
+shiftmore:
+       shrl    $1,r0,r0
+comb:
+       andl2   $CLEARHID,r0
+       shll    $EXPSHIFT,r2,r4
+       orl2    r4,r0
+       cmpl    r2,$256
+       jlss    1f
+       orl2    $HFS_OVF,*20(fp)        
+sign:
+1:     bbc     $0,r3,done
+       orl2    $SIGNBIT,r0
+done:  ret
+
+
+
+  retzero:
+         clrl  r0
+         ret
+  overflow:
+       orl2    $HFS_OVF,*20(fp)        
+       jmp     sign
+  underflow:
+       orl2    $HFS_UNDF,*20(fp)       
+       ret
+
+
+       
diff --git a/usr/src/sys/tahoemath/Knegd.s b/usr/src/sys/tahoemath/Knegd.s
new file mode 100644 (file)
index 0000000..be7cc64
--- /dev/null
@@ -0,0 +1,21 @@
+/*     Knegd.s 1.3     86/01/05        */
+
+#include "../tahoemath/fp.h"
+#include "../tahoemath/Kfp.h"
+#include "../tahoe/SYS.h"
+
+       .text
+ENTRY(Knegd, 0)
+       andl3   $EXPMASK,4(fp),r0       /* check for reserved operand,zero. */
+       beql    retzero
+       movl    4(fp),r0                /* fetch operand. */
+       movl    8(fp),r1
+       bbc     $31,r0,seton
+       andl2   $(0!SIGNBIT),r0         /* turn it off. */
+       ret
+seton: orl2    $SIGNBIT,r0             /* turn it on. */
+       ret
+retzero:
+       clrl    r0
+       clrl    r1
+       ret
diff --git a/usr/src/sys/tahoemath/Knegf.s b/usr/src/sys/tahoemath/Knegf.s
new file mode 100644 (file)
index 0000000..22d17a1
--- /dev/null
@@ -0,0 +1,20 @@
+/*     Knegf.s 1.3     86/01/05        */
+
+#include "../tahoemath/fp.h"
+#include "../tahoemath/Kfp.h"
+#include "../tahoe/SYS.h"
+
+       .text
+ENTRY(Knegf, 0)
+       clrl    r1
+       andl3   $EXPMASK,4(fp),r0       /* check for reserved operand,zero. */
+       beql    retzero
+       movl    4(fp),r0                /* fetch operand. */
+       bbc     $31,r0,seton
+       andl2   $(0!SIGNBIT),r0         /* turn it off. */
+       ret
+seton: orl2    $SIGNBIT,r0             /* turn it on. */
+       ret
+retzero:
+       clrl    r0
+       ret
diff --git a/usr/src/sys/tahoemath/Ksfnorm.s b/usr/src/sys/tahoemath/Ksfnorm.s
new file mode 100644 (file)
index 0000000..bdf40fc
--- /dev/null
@@ -0,0 +1,51 @@
+/*     Ksfnorm.s       1.3     86/01/05        */
+
+#include "../tahoemath/fp.h"
+#include "../tahoemath/Kfp.h"
+#include "../tahoe/SYS.h"
+
+/*
+ * Ksfnorm(hfs)
+ */
+       .text
+ENTRY(Ksfnorm, R6|R5|R4|R3|R2)
+       clrl    r1
+       movl    r0,r4           /* copy to temporary. */
+       jeql    retzero
+       clrl    r3              /* r3 - pos of m.s.b */
+inr00: ffs     r4,r6
+       incl    r6
+       addl2   r6,r3
+       shrl    r6,r4,r4
+       jneq    inr00
+
+cmpshift:
+                               /* compute the shift (r4). */
+       subl3   r3,$HID_POS,r4
+       jlss    shiftr          /* if less then zero we shift right. */
+       shll    r4,r0,r0        /* else we shift left. */
+       subl2   r4,r2           /* uodate exponent. */
+       jleq    underflow       /* if less then 0 (biased) it is underflow. */
+       jmp     combine         /* go to combine exponent and fraction. */
+shiftr:
+       mnegl   r4,r4
+       shrl    r4,r0,r0        /* shift right. */
+       addl2   r4,r2           /* update exponent */
+       cmpl    r2,$256
+       jgeq    overflow        /* check for overflow. */
+combine:
+       andl2   $CLEARHID,r0    /* clear the hidden bit. */
+       shal    $EXPSHIFT,r2,r2 /* shift the exponent to its proper place. */
+       orl2    r2,r0
+       ret
+
+underflow:
+       orl2    $HFS_UNDF,*4(fp)        
+       ret
+
+overflow:
+       orl2    $HFS_OVF,*4(fp)
+       ret
+retzero:
+       clrl    r0
+       ret
diff --git a/usr/src/sys/tahoemath/Ksfp_exp.s b/usr/src/sys/tahoemath/Ksfp_exp.s
new file mode 100644 (file)
index 0000000..12a26b5
--- /dev/null
@@ -0,0 +1,19 @@
+/*     Ksfp_exp.s      1.3     86/01/05        */
+
+#include "../tahoemath/fp.h"
+#include "../tahoemath/Kfp.h"
+#include "../tahoe/SYS.h"
+
+ENTRY(Ksfpover, 0)
+       movl    $HUGE0,r0
+       movl    $HUGE1,r1
+       ret
+
+ENTRY(Ksfpunder, 0)
+       clrl    r0
+       clrl    r1
+       ret
+
+ENTRY(Ksfpzdiv, 0)
+       divl2   $0,r1           # force divission by zero.
+       ret
diff --git a/usr/src/sys/tahoemath/Ksinfcosf.s b/usr/src/sys/tahoemath/Ksinfcosf.s
new file mode 100644 (file)
index 0000000..f8739b6
--- /dev/null
@@ -0,0 +1,219 @@
+/*     Ksinfcosf.s     1.3     86/01/05        */
+
+#include "../tahoe/SYS.h"
+
+       .text
+ENTRY(Kcosf, 0)
+       tstl    4(fp)           # if (arg < 0)
+       jgeq    L23
+       lnd     4(fp)
+       std     4(fp)           # arg = -arg;
+L23:   pushl   20(fp)          #       hfs
+       pushl   $1
+       pushl   8(fp)
+       pushl   4(fp)
+       callf   $20,_sinus
+       ret                     # return(sinus(arg,1));
+
+ENTRY(Ksinf, 0)
+       pushl   20(fp)          # hfs
+       pushl   $0
+       pushl   8(fp)
+       pushl   4(fp)
+       callf   $20,_sinus
+       ret                     # return(sinus(arg, 0));
+
+ENTRY(sinus, 0)
+       subl3   $112,fp,sp
+       movl    8(fp),-80(fp)
+       movl    4(fp),-84(fp)   # x = arg;
+       jgeq    L34             # if (x < 0) {
+       lnd     -84(fp)
+       std     -84(fp)         # x = -x;
+       addl2   $2,12(fp)       # quad = quad + 2;}
+L34:   pushl   16(fp)
+       ldd     _twoopi 
+       pushd
+       ldd     -84(fp)
+       pushd   
+       callf   $24,_Kmuld
+       movl    r1,-88(fp)
+       movl    r0,-84(fp)      # std   -84(fp)  x = x * twoopi;
+       cmpd2   -84(fp),L36     # if (x > 32764) {
+       jleq    L35
+       pushl   16(fp)          # hfs
+       subl3   $60,fp,-(sp)    # &e
+       pushl   -80(fp)
+       pushl   -84(fp)         # x
+       callf   $20,_Kmodf
+       clrl    -92+4(fp)
+       movl    r0,-92(fp)      # y = modf(x, &e);
+       pushl   16(fp)          # hfs
+       pushl   $0
+       pushl   12(fp)          # quad
+       pushl   $0
+       pushl   $0              # dummy acc
+       callf   $24,_Kcvtld
+       pushl   16(fp)          # hfs
+       pushl   r1
+       pushl   r0              # pushd  (double)quad
+       ldd     -60(fp)
+       pushd                   # &e
+       callf   $24,_Kaddd
+       movl    r1,-56(fp)
+       movl    r0,-60(fp)      # std   -60(fp) e = e + quad;
+       pushl   16(fp)          # hfs
+       subl3   $68,fp,-(sp)    # &f
+
+       pushl   16(fp)          # hfs
+       ldd     -60(fp)
+       pushd                   # &e
+       ldd     L37
+       pushd                   # 0.25
+       callf   $24,_Kmuld
+
+       pushl   r1
+       pushl   r0              # pushd  0.25 * e
+       callf   $20,_Kmodf      # modf(0.25 * e, &f);
+       
+       pushl   16(fp)          # hfs
+       movl    r1,-64(fp)
+       movl    r0,-68(fp)      # ldd   -68(fp)  &f
+       pushl   r1
+       pushl   r0              # pushd
+       ldd     L38
+       pushd
+       callf   $24,_Kmuld      # 4*f
+                               # std   r0
+       pushl   16(fp)          # hfs
+       pushl   r1
+       pushl   r0              # pushd 
+       ldd     -60(fp)
+       pushd
+       callf   $24,_Ksubd      # e - 4 * f
+       ldd     r0              # load acc with result of Ksubd
+       cvdl    12(fp)          # quad = (e - 4 * f); }
+       jbr     L39
+L35:   ldd     -84(fp)         # else {
+       cvdl    -96(fp)         # k = x;
+       pushl   16(fp)          # hfs
+       pushl   $0
+       pushl   -96(fp)
+       pushl   $0
+       pushl   $0              # acc
+       callf   $24,_Kcvtld
+                               # std   r0
+       pushl   16(fp)          # hfs
+       pushl   r1
+       pushl   r0              # pushd  (double)k
+       ldd     -84(fp)
+       pushd                   # x
+       callf   $24,_Ksubd
+       movl    r1,-88(fp)
+       movl    r0,-92(fp)      # std   -92(fp) y = x - k;
+       addl3   -96(fp),12(fp),r0
+       andl3   $3,r0,12(fp)    # quad = (quad + k) & 03; }
+L39:   bitl    $1,12(fp)       # if (quad & 01)
+       jeql    L40
+       pushl   16(fp)          # hfs
+       ldd     -92(fp)
+       pushd                   # y
+       ldd     L41
+       pushd                   # 1.0
+       callf   $24,_Ksubd
+       movl    r1,-88(fp)
+       movl    r0,-92(fp)      # std   -92(fp) y = 1 - y;
+L40:   cmpl    12(fp),$1       # if (quad > 1)
+       jleq    L42
+       lnd     -92(fp)
+       std     -92(fp)         # y = -y;
+L42:   pushl   16(fp)          # hfs
+       ldd     -92(fp)
+       pushd
+       pushd
+       callf   $24,_Kmuld      # y*y
+       movl    r1,-72(fp)
+       movl    r0,-76(fp)      # std   -76(fp)  ysq=y*y;
+
+       pushl   16(fp)          # hfs
+       ldd     -76(fp)
+       pushd
+       ldd     _p4
+       pushd
+       callf   $24,_Kmuld      # p4*ysq
+
+       pushl   16(fp)          # hfs
+       pushl   _p3+4
+       pushl   _p3
+       pushl   r1
+       pushl   r0              # pushd
+       callf   $24,_Kaddd      # p4*ysq+p3
+
+       pushl   16(fp)          # hfs
+       pushl   -72(fp)
+       pushl   -76(fp)
+       pushl   r1
+       pushl   r0              # pushd
+       callf   $24,_Kmuld      # (p4*ysq+p3)*ysq
+
+       pushl   16(fp)          # hfs
+       pushl   _p2+4
+       pushl   _p2
+       pushl   r1
+       pushl   r0              # pushd
+       callf   $24,_Kaddd      # (p4*ysq+p3)*ysq+p2
+
+       pushl   16(fp)          # hfs
+       pushl   -72(fp)
+       pushl   -76(fp)
+       pushl   r1
+       pushl   r0              # pushd
+       callf   $24,_Kmuld      # ((p4*ysq+p3)*ysq+p2)*ysq      
+
+       pushl   16(fp)          # hfs
+       pushl   _p1+4
+       pushl   _p1
+       pushl   r1
+       pushl   r0              # pushd
+       callf   $24,_Kaddd      # ((p4*ysq+p3)*ysq+p2)*ysq+p1
+
+       pushl   16(fp)          # hfs
+       pushl   -72(fp)
+       pushl   -76(fp)
+       pushl   r1
+       pushl   r0              # pushd
+       callf   $24,_Kmuld      # (((p4*ysq+p3)*ysq+p2)*ysq+p1)*ysq     
+
+       pushl   16(fp)          # hfs
+       pushl   _p0+4
+       pushl   _p0
+       pushl   r1
+       pushl   r0              # pushd
+       callf   $24,_Kaddd      # (((p4*ysq+p3)*ysq+p2)*ysq+p1)*ysq+p0  
+
+       pushl   16(fp)          # hfs
+       pushl   -88(fp)
+       pushl   -92(fp)
+       pushl   r1
+       pushl   r0              # pushd
+       callf   $24,_Kmuld      # ((((p4*ysq+p3)*ysq+p2)*ysq+p1)*ysq+p0)*y;     
+
+       movl    r1,-100(fp)
+       movl    r0,-104(fp)     # std   -104(fp) temp1
+       ldd     r0
+       cvdf
+       stf     r0
+       ret#1
+
+       .data
+       .align  2
+_twoopi:.long  0x4022F983, 0x6E4E4415 # .double .63661977236758134
+_p0:   .long   0x40C90FDA, 0x90304197 # .double 1.57079631844
+_p1:   .long   0xC0255DE0, 0xB36CEE75 # .double -.645963710599
+_p2:   .long   0x3EA33457, 0xA736E807 # .double .079689678945999999
+_p3:   .long   0xBC992665, 0x5E9A6554 # .double -.0046737666099999999
+_p4:   .long   0x3A1ED7FA, 0xCC54924E # .double .000151485129
+L36:   .long   0x47FFF800, 0x00000000 # .double 32764
+L37:   .long   0x3F800000, 0x00000000 # .double .25
+L38:   .long   0x41800000, 0x00000000 # .double 4
+L41:   .long   0x40800000, 0x00000000 # .double 1
diff --git a/usr/src/sys/tahoemath/Ksqrtf.s b/usr/src/sys/tahoemath/Ksqrtf.s
new file mode 100644 (file)
index 0000000..6ff75b7
--- /dev/null
@@ -0,0 +1,154 @@
+/*     Ksqrtf.s        1.3     86/01/05        */
+
+#include "../tahoe/SYS.h"
+
+       .text
+ENTRY(Ksqrtf, 0)
+       subl3   $76,fp,sp
+       tstl    4(fp)                   # if (arg <= 0.) {
+       jgtr    L18
+       jgeq    L19                     # if (arg < 0.)
+L19:   clrl    r1
+       clrl    r0
+       ret                             # return(0.);}
+L18:   
+       pushl   20(fp)                  # hfs
+       subl3   $72,fp,-(sp)
+       pushl   8(fp)
+       pushl   4(fp)
+       callf   $20,_Kfrexpf
+       clrl    -60+4(fp)
+       movl    r0,-60(fp)              # x = frexp(arg,&exp);
+       jbr     L20
+L2000001:
+       pushl   20(fp)                  # hfs
+       ldd     two
+       pushd
+       ldd     -60(fp)
+       pushd
+       callf   $24,_Kmuld              # x * 2
+       ldd     r0
+       std     -60(fp)                 # x *= 2;
+       decl    -72(fp)                 # exp--;}
+L20:   cmpd2   -60(fp),half            # while(x < 0.5){
+       jlss    L2000001
+       bitl    $1,-72(fp)              # if(exp & 1) {
+       jeql    L24
+       pushl   20(fp)                  # hfs
+       ldd     two
+       pushd
+       ldd     -60(fp)
+       pushd
+       callf   $24,_Kmuld              # x * 2
+       ldd     r0
+       std     -60(fp)                 # x *= 2;
+       decl    -72(fp)                 # exp--;}
+L24:   pushl   20(fp)                  # hfs
+       ldd     -60(fp)
+       pushd
+       ldd     one
+       pushd
+       callf   $24,_Kaddd              # (1.0+x)
+       pushl   20(fp)                  # hfs
+       ldd     r0
+       pushd
+       ldd     half
+       pushd
+       callf   $24,_Kmuld
+       ldd     r0
+       std     -68(fp)                  # temp=0.5*(1.0+x);
+       jbr     L28
+L2000003:
+       pushl   20(fp)                  # hfs
+       ldd     big
+       pushd
+       ldd     -68(fp)
+       pushd
+       callf   $24,_Kmuld              # temp*(1L<<30)
+       ldd     r0
+       std     -68(fp)                 # temp *=(1L<<30);
+       subl2   $60,-72(fp)             # exp -= 60;}
+L28:   cmpl    -72(fp),$60             # while(exp > 60){
+       jleq    L31
+       jbr     L2000003
+L2000005:
+       pushl   20(fp)                  # hfs
+       ldd     big
+       pushd
+       ldd     -68(fp)
+       pushd
+       callf   $24,_Kdivd
+       ldd     r0
+       std     -68(fp)                 # temp /= (1L<<30);
+       addl2   $60,-72(fp)             # exp +=60;}
+L31:   cmpl    -72(fp),$-60            # while(exp < -60) {
+       jlss    L2000005
+       tstl    -72(fp)                 # if(exp >=0)
+       jlss    L34
+       divl3   $2,-72(fp),r0
+       shll    r0,$1,r0
+       pushl   20(fp)                  # hfs
+       pushl   $0
+       pushl   r0
+       pushl   $0
+       pushl   $0
+       callf   $24,_Kcvtld
+       pushl   20(fp)                  # hfs
+       ldd     r0
+       pushd
+       ldd     -68(fp)
+       pushd
+       callf   $24,_Kmuld              # temp * (1L <<(exp/2))
+       jbr     L2000006                # temp *= 1L << (exp/2));
+L34:   mnegl   -72(fp),r0              # -exp
+       divl2   $2,r0                   # -exp/2
+       shll    r0,$1,r0
+       pushl   20(fp)                  # hfs
+       pushl   $0
+       pushl   r0
+       pushl   $0
+       pushl   $0
+       callf   $24,_Kcvtld
+       pushl   20(fp)                  # hfs
+       ldd     r0
+       pushd
+       ldd     -68(fp)
+       pushd
+       callf   $24,_Kdivd              # temp / (1L <<(-exp/2))
+L2000006:
+       ldd     r0
+       std     -68(fp)                 # temp (*/)= 1L << (exp/2));
+       clrl    -76(fp)
+L2000008:
+       pushl   20(fp)                  # hfs
+       ldd     -68(fp)
+       pushd
+       ldd     4(fp)
+       pushd
+       callf   $24,_Kdivd
+       pushl   20(fp)                  # hfs
+       ldd     r0
+       pushd
+       ldd     -68(fp)
+       pushd
+       callf   $24,_Kaddd
+       pushl   20(fp)                  # hfs
+       ldd     r0      
+       pushd
+       ldd     half
+       pushd
+       callf   $24,_Kmuld
+       ldd     r0
+       std     -68(fp)                 # temp=0.5*(temp+arg/temp);
+       aobleq  $3,-76(fp),L2000008
+       ldd     -68(fp)
+       cvdf
+       stf     r0
+       ret
+
+       .data
+       .align  2
+half:  .long   0x40000000, 0x00000000 # .double .5
+two:   .long   0x41000000, 0x00000000 # .double 2
+one:   .long   0x40800000, 0x00000000 # .double 1
+big:   .long   0x4F800000, 0x00000000 # .double (1<<30)
diff --git a/usr/src/sys/tahoemath/Ksubd.s b/usr/src/sys/tahoemath/Ksubd.s
new file mode 100644 (file)
index 0000000..9108509
--- /dev/null
@@ -0,0 +1,35 @@
+/*     Ksubd.s 1.3     86/01/05        */
+
+#include "../tahoe/SYS.h"
+
+/*
+ * double 
+ * Ksubd(d1,d2)
+ * double d1,d2;
+ * {
+ *     return(d1+(-d2));
+ * }
+ */
+       .text
+ENTRY(Ksubd, 0)
+       tstl    4(fp)
+       jneq    next
+       movl    16(fp),r1
+       movl    12(fp),r0
+       lnd     r0
+       std     r0
+       ret
+next:
+       tstl    12(fp)
+       jneq    doit
+       movl    8(fp),r1
+       movl    4(fp),r0
+       ret
+doit:
+       lnd     12(fp)          # -op
+       pushl   20(fp)          # hfs
+       pushd                   # push op_least op_most
+       pushl   8(fp)
+       pushl   4(fp)           # acc
+       callf   $24,_Kaddd
+       ret
diff --git a/usr/src/sys/tahoemath/Ksubf.s b/usr/src/sys/tahoemath/Ksubf.s
new file mode 100644 (file)
index 0000000..2a24e0f
--- /dev/null
@@ -0,0 +1,35 @@
+/*     Ksubf.s 1.3     86/01/05        */
+
+#include "../tahoe/SYS.h"
+
+/*
+ * _Ksubf(acc_most,acc_least,op_most,op_least,hfs)
+ *
+ * subf(d1,d2)
+ * {
+ *     return(d1+(-d2));
+ * }
+ */
+       .text
+ENTRY(Ksubf, 0)
+       tstl    4(fp)   # handle (a-b) where a and/or b = 0.0
+       jneq    next
+       movl    $0,r1
+       movl    12(fp),r0
+       lnd     r0
+       std     r0
+       ret
+next:
+       tstl    12(fp)
+       jneq    doit
+       movl    $0,r1
+       movl    4(fp),r0
+       ret
+doit:
+       lnd     12(fp)  # note: -(0) = 0 by definition!
+       pushl   20(fp)  # hfs
+       pushd   
+       pushl   8(fp)
+       pushl   4(fp)   # acc
+       callf   $24,_Kaddf
+       ret