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

Defined functions

adbig defined in line 13; never used

Defined struct's

s_dot defined in line 10; used 10 times
vl defined in line 11; never used
Last modified: 1985-08-14
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 726
Valid CSS Valid XHTML 1.0 Strict