|  | DataMuseum.dkPresents historical artifacts from the history of: RegneCentralen RC700 "Piccolo" | 
This is an automatic "excavation" of a thematic subset of
 See our Wiki for more about RegneCentralen RC700 "Piccolo" Excavated with: AutoArchaeologist - Free & Open Source Software. | 
top - metrics - download
    Length: 2560 (0xa00)
    Types: TextFile
    Names: »LONG.C«
└─⟦b35f94715⟧ Bits:30003295 BDS C version 1.50 arbejdsdiskette til RC703 Piccolo
└─⟦b35f94715⟧ Bits:30005324 BDS C version 1.50 arbejdsdiskette til RC703 Piccolo
    └─⟦this⟧ »LONG.C« 
/*	C-Source for Long (32-bit signed) Integer Package
 *	Rob Shostak
 *	August, 1982			
 */
        
char *itol(result,n)			/* integer to long */
char *result;
int n;
æ
return(long(0,result,n));
å
int ltoi(l)				/* converts long to integer */
char lÆÅ;
æ
return(lÆ3Å + (lÆ2Å << 8));
å
lcomp(op1,op2)				/* compares two longs */
char *op1,*op2;
æ
return(long(1,op1,op2));
å
char *ladd(result,op1,op2)		/* adds two longs */
char *result,*op1,*op2;
æ
return(long(2,result,op1,op2));
å
char *lsub(result,op1,op2)		/* subtracts two longs */
char *result,*op1,*op2;
æ
return(long(3,result,op1,op2));
å
char *lmul(result,op1,op2)		/* multiplies two longs */
char *result,*op1,*op2;
æ
return(long(4,result,op1,op2));
å
char *ldiv(result,op1,op2)		/* "long" division */
char *result,*op1,*op2;
æ
return(long(5,result,op1,op2));
å
char *lmod(result,op1,op2)		/* long multiplication */
char *result,*op1,*op2;
æ
return(long(6,result,op1,op2));
å
char *atol(result,s)			/* ascii to long */
char *result,*s;
æ
char tenÆ4Å, tempÆ4Å, sign;
itol(ten,10); itol(result,0);
if(sign=(*s == '-')) s++;
while(isdigit(*s))
  ladd(result,lmul(result,result,ten),itol(temp,*s++ - '0'));
return(sign? lsub(result,itol(temp,0),result) : result);
å
char *ltoa(result,op1)				/* long to ascii string */
char *result,*op1;
æ
char absvalÆ4Å, tempÆ4Å;
char workÆ15Å, *workptr, sign;
char tenÆ4Å, zeroÆ4Å, *rptr;
rptr = result;
itol(ten,10); itol(zero,0);			/* init these */
if(sign = *op1 & 0x80)				/* negative operand */
  æ
  *rptr++ = '-';
  lsub(absval,zero,op1);
  å
else lassign(absval,op1);
*(workptr = work+14) = 'Ø0';		/* generate digits in reverse order */
do					
  *(--workptr) = '0'+ *(lmod(temp,absval,ten) + 3);
while
  (lcomp(ldiv(absval,absval,ten),zero) > 0);
strcpy(rptr,workptr);
return(result);
å
/* lassign(ldest,lsource) assigns long lsource to ldest, returns
   ptr to ldest */
char *lassign(ldest,lsource)
unsigned *ldest, *lsource;
æ
*ldest++ = *lsource++;	/* copy first two bytes */
*ldest = *lsource;	/* then last two */
return(ldest);
å
/* ltou(l) converts long l to an unsigned (by truncating) */
unsigned ltou(l)
char lÆÅ;
æ
return(lÆ3Å + (lÆ2Å << 8));
å
/* utol(l,u) converts unsigned to long */
utol(l,u)
char lÆÅ;
unsigned u;
æ
itol(l, u & 0x7FFF);			/* convert integer part */
if(u > 0x7FFF) lÆ2Å += 0x80;		/* take care of leftmost bit */
return(l);
å
«eof»