adder.c

来自「操作系统源代码」· C语言 代码 · 共 51 行

C
51
字号
/*  (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.  See the copyright notice in the ACK home directory, in the file "Copyright".*//* $Header: adder.c,v 1.6 93/01/05 12:03:17 ceriel Exp $ *//* *	these are the routines the routines to do 32 and  64-bit addition */# ifdef	EXT_DEBUG# include <stdio.h># endif# include "FP_types.h"# define	UNKNOWN -1# define	TRUE	 1# define	FALSE	 0# define	MAXBIT	0x80000000L	/*	 *	add 64 bits	 */intb64_add(e1,e2)		/*		 * pointers to 64 bit 'registers'		 */register	B64	*e1,*e2;{		register	int	overflow;				int	carry;			/* add higher pair of 32 bits */	overflow = ((unsigned long) 0xFFFFFFFF - e1->h_32 < e2->h_32);	e1->h_32 += e2->h_32;			/* add lower pair of 32 bits */	carry = ((unsigned long) 0xFFFFFFFF - e1->l_32 < e2->l_32);	e1->l_32 += e2->l_32;# ifdef	EXT_DEBUG	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 */	return(overflow);		/* return status from higher add */}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?