Annotation of 42BSD/ucb/lisp/franz/68k/mulbig.c, revision 1.1

1.1     ! root        1: /* Copyright (c) 1982, Regents, University of California */
        !             2: 
        !             3: struct sdot    { long I; struct sdot *CDR; };
        !             4: struct vl      { long high; long low; };
        !             5: 
        !             6: struct sdot *mulbig(a,b)
        !             7: struct sdot *a, *b;
        !             8: {
        !             9:        int la = 1, lb = 1;
        !            10:        long *sa, *sb, *sc, *base, *alloca();
        !            11:        struct sdot *export();
        !            12:        register struct sdot *p;
        !            13:        register int *q, *r, *s;
        !            14:        long carry = 0, test;
        !            15:        struct vl work;
        !            16: 
        !            17:        /* compute lengths */
        !            18:        
        !            19:        for(p = a; p->CDR; p = p->CDR) la++;
        !            20:        for(p = b; p->CDR; p = p->CDR) lb++;
        !            21: 
        !            22:        /* allocate storage areas on the stack */
        !            23: 
        !            24:        base = alloca((la + la + lb + lb + 1)*sizeof(long));
        !            25:        sc = base + la + lb + 1;
        !            26:        sb = sc + lb;
        !            27:        sa = sb + la;
        !            28:        q  = sa;
        !            29: 
        !            30:        /* copy sdots onto stack */
        !            31:        p = a;
        !            32:        do { *--q = p->I; p = p->CDR; } while (p);
        !            33:        p = b;
        !            34:        do { *--q = p->I; p = p->CDR; } while (p);
        !            35:        while(q > base) *--q = 0;  /* initialize target */
        !            36: 
        !            37:        /* perform the multiplication */
        !            38:        for(q = sb; q > sc; *--s = carry)
        !            39:            for((r = sa, s = (q--) - lb, carry = 0); r > sb;)
        !            40:            {
        !            41:                    carry += *--s;
        !            42:                    emul(*q,*--r,carry,&work);
        !            43:                    test = work.low;
        !            44:                    carry = work.high << 2;
        !            45:                    if(test < 0) carry += 2;
        !            46:                    if(test & 0x40000000) carry +=1;
        !            47:                    *s = test & 0x3fffffff;
        !            48:            }
        !            49: 
        !            50:        return(export(sc,base));
        !            51: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.