Annotation of 43BSDTahoe/ucb/lisp/franz/68k/mulbig.c, revision 1.1.1.1

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

unix.superglobalmegacorp.com

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