Annotation of 42BSD/ucb/lisp/franz/68k/adbig.c, revision 1.1.1.1

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

unix.superglobalmegacorp.com

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