BSD 4_3_Net_2 development
authorCSRG <csrg@ucbvax.Berkeley.EDU>
Wed, 23 Mar 1983 15:33:06 +0000 (07:33 -0800)
committerCSRG <csrg@ucbvax.Berkeley.EDU>
Wed, 23 Mar 1983 15:33:06 +0000 (07:33 -0800)
Work on file usr/src/usr.bin/lisp/franz/68k/calqhat.c
Work on file usr/src/usr.bin/lisp/franz/68k/dmlad.s
Work on file usr/src/usr.bin/lisp/franz/68k/dodiv.c
Work on file usr/src/usr.bin/lisp/franz/68k/fixbits.c
Work on file usr/src/usr.bin/lisp/franz/68k/ediv.s
Work on file usr/src/usr.bin/lisp/franz/68k/inewint.c
Work on file usr/src/usr.bin/lisp/franz/68k/nargs.c

Synthesized-from: CSRG/cd2/net.2

usr/src/usr.bin/lisp/franz/68k/calqhat.c [new file with mode: 0644]
usr/src/usr.bin/lisp/franz/68k/dmlad.s [new file with mode: 0644]
usr/src/usr.bin/lisp/franz/68k/dodiv.c [new file with mode: 0644]
usr/src/usr.bin/lisp/franz/68k/ediv.s [new file with mode: 0644]
usr/src/usr.bin/lisp/franz/68k/fixbits.c [new file with mode: 0644]
usr/src/usr.bin/lisp/franz/68k/inewint.c [new file with mode: 0644]
usr/src/usr.bin/lisp/franz/68k/nargs.c [new file with mode: 0644]

diff --git a/usr/src/usr.bin/lisp/franz/68k/calqhat.c b/usr/src/usr.bin/lisp/franz/68k/calqhat.c
new file mode 100644 (file)
index 0000000..529f7aa
--- /dev/null
@@ -0,0 +1,41 @@
+/* Copyright (c) 1982, Regents, University of California */
+struct vl      { long high; long low; };
+calqhat(uj,v1)
+register long *uj, *v1;
+{
+       struct vl work1, work2;
+       register handy, handy2;
+       register qhat, rhat;
+       char err;
+       if(*v1==*uj) {
+               /* set qhat to b-1
+                * rhat is easily calculated since if we substite b-1
+                * for qhat in the formula below, one gets (u[j+1] + v[1])
+                */
+                qhat = 0x3fffffff;
+                rhat = uj[1] + *v1;
+       } else {
+               /* work1 = u[j]b + u[j+1]; */
+               handy2 = uj[1];
+               handy = *uj;
+               if(handy & 1) handy2 |= 0x40000000;
+               if(handy & 2) handy2 |= 0x80000000;
+               handy >>= 2;
+               work1.low = handy2; work1.high = handy;
+               qhat = ediv(&work1,*v1,&err);
+               /* rhat = work1 - qhat*v[1]; */
+               rhat = work1.high;
+       }
+again:
+       /* check if v[2]*qhat > rhat*b+u[j+2] */
+       emul(qhat,v1[1],0,&work1);
+       /* work2 = rhat*b+u[j+2]; */
+       { handy2 = uj[2]; handy = rhat;
+       if(handy & 1) handy2 |= 0x40000000;
+       if(handy & 2) handy2 |= 0x80000000;
+       handy >>= 2; work2.low = handy2; work2.high = handy; }
+       vlsub(&work1,&work2);
+       if(work1.high <= 0) return(qhat);
+       qhat--; rhat += *v1;
+       goto again;
+}
diff --git a/usr/src/usr.bin/lisp/franz/68k/dmlad.s b/usr/src/usr.bin/lisp/franz/68k/dmlad.s
new file mode 100644 (file)
index 0000000..4f7b7a7
--- /dev/null
@@ -0,0 +1,101 @@
+| /* Copyright (c) 1982, Regents, University of California */
+       .data
+       .text
+       .globl  _dmlad
+_dmlad:
+       link    a6,#-.F1
+       tstb    sp@(-132)
+       moveml  #.S1,a6@(-.F1)
+       movl    a6@(12),d7
+       movl    a6@(16),d6
+|l 8
+       movl    a6@(8),a5
+|e 8
+.L15:
+|l 12
+       pea     a6@(0xfffffff8)
+       movl    d6,sp@-
+       movl    d7,sp@-
+       movl    a5@,sp@-
+       jsr     _emul
+       addl    #16,sp
+|e 12
+|l 13
+       movl    a6@(0xfffffff8),d6
+|e 13
+|l 14
+       asll    #2,d6
+|e 14
+|l 15
+       tstl    a6@(0xfffffffc)
+       bge     .L17
+|e 15
+|l 15
+       addql   #2,d6
+|e 15
+.L17:
+|l 16
+       movl    a6@(0xfffffffc),d0
+       asll    #1,d0
+       tstl    d0
+       bge     .L18
+|e 16
+|l 16
+       addql   #1,d6
+|e 16
+.L18:
+|l 17
+       movl    a6@(0xfffffffc),d0
+       andl    #0x3fffffff,d0
+       movl    d0,a5@
+|e 17
+|l 18
+       tstl    a5@(4)
+       bne     .L19
+|e 18
+       bra     .L14
+.L19:
+|l 19
+       movl    a5@(4),a5
+|e 19
+.L13:
+       bra     .L15
+.L14:
+|l 21
+       tstl    d6
+       beq     .L20
+|e 21
+|l 24
+       cmpl    #0xffffffff,d6
+       bne     .L22
+|e 24
+|l 25
+       orl     #0xc0000000,a5@
+|e 25
+       bra     .L23
+.L22:
+|l 27
+       jsr     _newdot
+       movl    d0,a5@(4)
+       movl    a5@(4),a5
+|e 27
+|l 28
+       movl    d6,a5@
+|e 28
+|l 29
+       clrl    a5@(4)
+|e 29
+.L23:
+.L20:
+|l 32
+       movl    a6@(8),d0
+|e 32
+       bra     .L12
+       bra     .L12
+.L12:  moveml  a6@(-.F1),#0x20c0
+       unlk    a6
+       rts
+.F1 = 20
+.S1 = 0x20c0
+| end
+       .data
diff --git a/usr/src/usr.bin/lisp/franz/68k/dodiv.c b/usr/src/usr.bin/lisp/franz/68k/dodiv.c
new file mode 100644 (file)
index 0000000..3434882
--- /dev/null
@@ -0,0 +1,40 @@
+/* Copyright (c) 1982, Regents, University of California */
+
+struct sdot    { long I; struct sdot *CDR; };
+struct vl      { long high; long low; };
+
+long dodiv(top,bottom)
+long *top, *bottom; /* top least significant; bottom most */
+{
+       struct vl work;
+       char error;
+       long rem = 0, ediv();
+       register long *p = bottom;
+
+       for(;p <= top;p++)
+       {
+               emul(0x40000000,rem,*p,&work);
+               *p = ediv(&work,1000000000,&error);
+               rem = work.high;
+       }
+       return(rem);
+}
+
+long dsneg(top,bottom)
+long *top, *bottom;
+{
+       register long *p = top;
+       register carry = 0;
+       register digit;
+
+       while(p >= bottom)
+       {
+               digit = carry - *p;
+               /* carry = digit >> 30; is slow on 68K */
+               if(digit < 0) carry = -2;
+               if(digit & 0x40000000) carry += 1;
+               *p-- = digit & 0x3fffffff;
+       }
+}
+
+
diff --git a/usr/src/usr.bin/lisp/franz/68k/ediv.s b/usr/src/usr.bin/lisp/franz/68k/ediv.s
new file mode 100644 (file)
index 0000000..a3e6608
--- /dev/null
@@ -0,0 +1,86 @@
+| /* Copyright (c) 1982, Regents, University of California */
+       .text
+       .globl  _ediv
+_ediv:
+       link    a6,#-.F1
+       tstb    sp@(-132)
+       moveml  #.S1,a6@(-.F1)
+       movl    a6@(8),a5
+       movl    a5@,d7
+       movl    a5@(4),d6
+       moveq   #0,d5
+       moveq   #0,d4
+       movl    a6@(0xc),d3
+       clrb    a6@(0xfffffffd)
+       clrb    a6@(0xfffffffb)
+       movl    d7,a6@(0xfffffff4)
+       jge     .L13
+       eorb    #1,a6@(0xfffffffd)
+       negl    d6
+       negxl   d7
+.L13:
+       tstl    d3
+       jge     .L16
+       eorb    #1,a6@(0xfffffffd)
+       negl    d3
+.L16:
+       tstl    d3
+       jne     .L17
+       clrl    a5@
+       movl    a6@(0x10),a0
+       movb    #1,a0@
+       movl    d6,d0
+       jra     .L12
+.L17:
+       movw    #0x20,a6@(0xfffffffe)
+       jra     .L20
+.L20001:
+       lsll    #1,d3
+       addqw   #1,a6@(0xfffffffe)
+       addql   #1,d5
+.L20:
+       cmpl    #0x40000000,d3
+       jcs     .L20001
+       cmpl    d3,d7
+       jcs     .L24
+       subl    d3,d7
+       addql   #1,d4
+       jra     .L24
+.L20003:
+       lsll    #1,d6
+       roxll   #1,d7
+       asll    #1,d4
+       cmpl    d3,d7
+       jcs     .L26
+       subl    d3,d7
+       addql   #1,d4
+.L26:
+       tstl    d4
+       jge     .L22
+       movl    a6@(0x10),a0
+       movb    #1,a0@
+.L22:
+       subqw   #1,a6@(0xfffffffe)
+.L24:
+       tstw    a6@(0xfffffffe)
+       jne     .L20003
+       lsrl    d5,d7
+       tstl    a6@(0xfffffff4)
+       jge     .L28
+       negl    d7
+.L28:
+       movl    d7,a5@
+       andl    #0x7fffffff,d4
+       tstb    a6@(0xfffffffd)
+       jeq     .L29
+       negl    d4
+.L29:
+       movl    d4,d0
+.L12:
+       moveml  a6@(-.F1),#0x20f8
+       unlk    a6
+       rts
+.F1 = 36
+.S1 = 0x20f8
+| end
+       .data
diff --git a/usr/src/usr.bin/lisp/franz/68k/fixbits.c b/usr/src/usr.bin/lisp/franz/68k/fixbits.c
new file mode 100644 (file)
index 0000000..db95fc6
--- /dev/null
@@ -0,0 +1,16 @@
+/* Copyright (c) 1982, Regents, University of California */
+fixbits(from,to)
+register char *from, *to;
+{
+       register char save;
+       
+       while(from <= to) {
+               save = from[3];
+               from[3] = from[0];
+               from[0] = save;
+               save = from[2];
+               from[2] = from[1];
+               from[1] = save;
+               from += 4;
+       }
+}
diff --git a/usr/src/usr.bin/lisp/franz/68k/inewint.c b/usr/src/usr.bin/lisp/franz/68k/inewint.c
new file mode 100644 (file)
index 0000000..69aaf1e
--- /dev/null
@@ -0,0 +1,18 @@
+/* Copyright (c) 1982, Regents, University of California */
+
+extern int Fixzero[];
+int *inewint(n)
+{
+       register int *ip;
+       int *newint();
+       if(n < 1024 && n >= -1024) return (Fixzero+n);
+       ip = newint();
+       *ip = n;
+       return(ip);
+}
+blzero(where,howmuch)
+register char *where;
+{
+       register char *p;
+       for(p = where + howmuch; p > where; ) *--p = 0;
+}
diff --git a/usr/src/usr.bin/lisp/franz/68k/nargs.c b/usr/src/usr.bin/lisp/franz/68k/nargs.c
new file mode 100644 (file)
index 0000000..24a5c74
--- /dev/null
@@ -0,0 +1,54 @@
+/* Copyright (c) 1982, Regents, University of California */
+#define ADDQ 5
+#define ADD 13
+#define IMMED 074
+/* These structures are here for looks, only */
+struct add { short op:4, reg:3, mode:3, ea:6; } x;
+struct addq { short op:4, data:3, size:3, ea:6; } y;
+nargs(arg)
+long arg; /* this is only here for address calculation */
+{
+       register long *a5;
+       register handy;
+       register char reg, mode, ea;
+#define size mode
+#define data reg
+
+       a5 = (&arg) - 2; /* this points to old a6 */
+       a5 = (long *) *a5; /* a5 now = my parents a6 */
+       a5 = (long *) a5[1]; /* pick up return address into a5 */
+
+       handy = * (short *)a5;
+       ea = handy & 077; handy >>= 6;
+       mode = handy & 07; handy >>= 3;
+       reg = handy & 07; handy >>= 3;
+       /* op = handy & 017; */
+       switch(handy & 017) {
+       case ADD:
+               if(reg!=7)
+                       return(0); /* this instruction doesn't adjust the sp */
+               if(ea!=IMMED)
+                       return(0); /* too hard to decode adjustment */
+               handy = (long) (1 + (short *) a5);
+               if(mode==03) {  /* addw #n,a7 */
+                       handy = *(short *)handy;
+                       return(handy >> 2);
+               }
+               if(mode==07) { /* addl #n,a7 */
+                       handy = *(long *)handy;
+                       return(handy >> 2);
+               }
+               else return(0); /* this was doing something to d7 */
+       case ADDQ:
+               if(ea!=017)
+                       return(0); /* this doesn't adjust a7 */
+               if(size!=02)
+                       return(0); /* should complain -- we are doing
+                                     addq[bw] something,a7 */
+               switch(data) {
+               case 0: return(2);
+               case 4: return(1);
+               }
+       }
+       return(0);
+}