1/* 2 * Copyright (c) 1992, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * This software was developed by the Computer Systems Engineering group 6 * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and 7 * contributed to Berkeley. 8 * --- 30 unchanged lines hidden (view full) --- 39 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 40 * SUCH DAMAGE. 41 * 42 * @(#)fpu_implode.c 8.1 (Berkeley) 6/11/93 43 * $NetBSD: fpu_implode.c,v 1.8 2001/08/26 05:44:46 eeh Exp $ 44 */ 45 46#include <sys/cdefs.h> |
47__FBSDID("$FreeBSD: head/lib/libc/sparc64/fpu/fpu_implode.c 95587 2002-04-27 21:56:28Z jake $"); |
48 49/* 50 * FPU subroutines: `implode' internal format numbers into the machine's 51 * `packed binary' format. 52 */ 53 54#include <sys/param.h> 55 56#include <machine/frame.h> 57#include <machine/fp.h> 58#include <machine/fsr.h> 59#include <machine/ieee.h> 60#include <machine/instr.h> 61 62#include "fpu_arith.h" 63#include "fpu_emu.h" 64#include "fpu_extern.h" |
65#include "__sparc_utrap_private.h" |
66 67static int round(struct fpemu *, struct fpn *); 68static int toinf(struct fpemu *, int); 69 70/* 71 * Round a number (algorithm from Motorola MC68882 manual, modified for 72 * our internal format). Set inexact exception if rounding is required. 73 * Return true iff we rounded up. --- 276 unchanged lines hidden (view full) --- 350 (fe->fe_fsr & (FSR_UF << FSR_TEM_SHIFT))) 351 fe->fe_cx |= FSR_UF; 352 return (sign | SNG_EXP(0) | fp->fp_mant[3]); 353 } 354 /* -FP_NG for g,r; -1 for implied 1; -SNG_FRACBITS for fraction */ 355 (void) __fpu_shr(fp, FP_NMANT - FP_NG - 1 - SNG_FRACBITS); 356#ifdef DIAGNOSTIC 357 if ((fp->fp_mant[3] & SNG_EXP(1 << FP_NG)) == 0) |
358 __utrap_panic("fpu_ftos"); |
359#endif 360 if (round(fe, fp) && fp->fp_mant[3] == SNG_EXP(2)) 361 exp++; 362 if (exp >= SNG_EXP_INFNAN) { 363 /* overflow to inf or to max single */ 364 fe->fe_cx |= FSR_OF | FSR_NX; 365 if (toinf(fe, sign)) 366 return (sign | SNG_EXP(SNG_EXP_INFNAN)); --- 158 unchanged lines hidden (view full) --- 525 break; 526 527 case FTYPE_EXT: 528 /* funky rounding precision options ?? */ 529 space[0] = __fpu_ftoq(fe, fp, space); 530 break; 531 532 default: |
533 __utrap_panic("fpu_implode"); |
534 } 535 DPRINTF(FPE_REG, ("fpu_implode: %x %x %x %x\n", 536 space[0], space[1], space[2], space[3])); 537} |