source: trunk/minix/lib/ack/fphook/adder.fc@ 9

Last change on this file since 9 was 9, checked in by Mattia Monga, 13 years ago

Minix 3.1.2a

File size: 1.1 KB
Line 
1/*
2 (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
3 See the copyright notice in the ACK home directory, in the file "Copyright".
4*/
5
6/* $Header: /cvsup/minix/src/lib/ack/fphook/adder.fc,v 1.1 2005/10/10 15:27:43 beng Exp $ */
7
8/*
9 * these are the routines the routines to do 32 and 64-bit addition
10 */
11
12# ifdef EXT_DEBUG
13# include <stdio.h>
14# endif
15
16# include "FP_types.h"
17# define UNKNOWN -1
18# define TRUE 1
19# define FALSE 0
20# define MAXBIT 0x80000000L
21
22 /*
23 * add 64 bits
24 */
25int
26b64_add(e1,e2)
27 /*
28 * pointers to 64 bit 'registers'
29 */
30register B64 *e1,*e2;
31{
32 register int overflow;
33 int carry;
34
35 /* add higher pair of 32 bits */
36 overflow = ((unsigned long) 0xFFFFFFFF - e1->h_32 < e2->h_32);
37 e1->h_32 += e2->h_32;
38
39 /* add lower pair of 32 bits */
40 carry = ((unsigned long) 0xFFFFFFFF - e1->l_32 < e2->l_32);
41 e1->l_32 += e2->l_32;
42# ifdef EXT_DEBUG
43 printf("\t\t\t\t\tb64_add: overflow (%d); internal carry(%d)\n",
44 overflow,carry);
45 fflush(stdout);
46# endif
47 if ((carry) && (++e1->h_32 == 0))
48 return(TRUE); /* had a 64 bit overflow */
49 return(overflow); /* return status from higher add */
50}
Note: See TracBrowser for help on using the repository browser.