ack/mach/proto/fp/adder.c

51 lines
1.1 KiB
C
Raw Normal View History

1988-04-07 11:40:46 +00:00
/*
(c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
See the copyright notice in the ACK home directory, in the file "Copyright".
*/
/* $Header$ */
1988-04-07 10:57:49 +00:00
/*
* these are the routines the routines to do 32 and 64-bit addition
*/
# ifdef EXT_DEBUG
1988-04-07 10:57:49 +00:00
# include <stdio.h>
# endif
1993-01-05 12:06:58 +00:00
# include "FP_types.h"
1988-04-07 10:57:49 +00:00
# define UNKNOWN -1
# define TRUE 1
# define FALSE 0
# define MAXBIT 0x80000000L
/*
* add 64 bits
*/
1993-01-05 12:06:58 +00:00
int
1988-04-07 10:57:49 +00:00
b64_add(e1,e2)
/*
* pointers to 64 bit 'registers'
*/
register B64 *e1,*e2;
{
register int overflow;
int carry;
1988-04-07 10:57:49 +00:00
/* add higher pair of 32 bits */
1988-08-11 14:50:18 +00:00
overflow = ((unsigned long) 0xFFFFFFFF - e1->h_32 < e2->h_32);
e1->h_32 += e2->h_32;
1988-04-07 10:57:49 +00:00
/* add lower pair of 32 bits */
1988-08-11 14:50:18 +00:00
carry = ((unsigned long) 0xFFFFFFFF - e1->l_32 < e2->l_32);
e1->l_32 += e2->l_32;
# ifdef EXT_DEBUG
1988-04-07 10:57:49 +00:00
printf("\t\t\t\t\tb64_add: overflow (%d); internal carry(%d)\n",
overflow,carry);
fflush(stdout);
# endif
if ((carry) && (++e1->h_32 == 0))
return(TRUE); /* had a 64 bit overflow */
1993-01-05 12:06:58 +00:00
return(overflow); /* return status from higher add */
1988-04-07 10:57:49 +00:00
}