|
|
1.1 ! root 1: /* ! 2: * ! 3: * Copyright (c) 1982, Regents, University of California ! 4: * ! 5: * stolen from 68k port by P. S. Housel 05/03/86 ! 6: */ ! 7: #include "global.h" ! 8: ! 9: struct s_dot ! 10: { ! 11: long I; ! 12: struct s_dot *CDR; ! 13: }; ! 14: struct vl ! 15: { ! 16: long high; ! 17: long low; ! 18: }; ! 19: ! 20: ! 21: struct s_dot *adbig(a,b) ! 22: struct s_dot *a, *b; ! 23: { ! 24: int la = 1, lb = 1; ! 25: long *sa, *sb, *sc, *base, *alloca(); ! 26: struct s_dot *export(); ! 27: register struct s_dot *p; ! 28: register int *q, *r, *s; ! 29: register carry = 0; ! 30: Keepxs(); ! 31: ! 32: /* compute lengths */ ! 33: ! 34: for(p = a; p->CDR; p = p->CDR) la++; ! 35: for(p = b; p->CDR; p = p->CDR) lb++; ! 36: if(lb > la) la = lb; ! 37: ! 38: /* allocate storage areas on the stack */ ! 39: ! 40: base = alloca((3*la+1)*sizeof(long)); ! 41: sc = base + la +1; ! 42: sb = sc + la; ! 43: sa = sb + la; ! 44: q = sa; ! 45: ! 46: /* copy s_dots onto stack */ ! 47: p = a; ! 48: do { *--q = p->I; p = p->CDR; } while (p); ! 49: while(q > sb) *--q = 0; ! 50: p = b; ! 51: do { *--q = p->I; p = p->CDR; } while (p); ! 52: while(q > sc) *--q = 0; ! 53: ! 54: /* perform the addition */ ! 55: for(q = sa, r = sb, s = sc; q > sb;) ! 56: { ! 57: carry += *--q + *--r; ! 58: *--s = carry & 0x3fffffff; ! 59: carry >>= 30; ! 60: } ! 61: *--s = carry; ! 62: ! 63: p = export(sc,base); ! 64: Freexs(); ! 65: return(p); ! 66: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.