| Rev | Line | |
|---|
| [9] | 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/float/adder.c,v 1.1.1.1 2005/04/21 14:56:10 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 | */
|
|---|
| 25 | int
|
|---|
| 26 | b64_add(e1,e2)
|
|---|
| 27 | /*
|
|---|
| 28 | * pointers to 64 bit 'registers'
|
|---|
| 29 | */
|
|---|
| 30 | register 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.