Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0
0002 /*---------------------------------------------------------------------------+
0003  |  reg_convert.c                                                            |
0004  |                                                                           |
0005  |  Convert register representation.                                         |
0006  |                                                                           |
0007  | Copyright (C) 1992,1993,1994,1996,1997                                    |
0008  |                  W. Metzenthen, 22 Parker St, Ormond, Vic 3163, Australia |
0009  |                  E-mail   billm@suburbia.net                              |
0010  |                                                                           |
0011  |                                                                           |
0012  +---------------------------------------------------------------------------*/
0013 
0014 #include "exception.h"
0015 #include "fpu_emu.h"
0016 
0017 int FPU_to_exp16(FPU_REG const *a, FPU_REG *x)
0018 {
0019     int sign = getsign(a);
0020 
0021     *(long long *)&(x->sigl) = *(const long long *)&(a->sigl);
0022 
0023     /* Set up the exponent as a 16 bit quantity. */
0024     setexponent16(x, exponent(a));
0025 
0026     if (exponent16(x) == EXP_UNDER) {
0027         /* The number is a de-normal or pseudodenormal. */
0028         /* We only deal with the significand and exponent. */
0029 
0030         if (x->sigh & 0x80000000) {
0031             /* Is a pseudodenormal. */
0032             /* This is non-80486 behaviour because the number
0033                loses its 'denormal' identity. */
0034             addexponent(x, 1);
0035         } else {
0036             /* Is a denormal. */
0037             addexponent(x, 1);
0038             FPU_normalize_nuo(x);
0039         }
0040     }
0041 
0042     if (!(x->sigh & 0x80000000)) {
0043         EXCEPTION(EX_INTERNAL | 0x180);
0044     }
0045 
0046     return sign;
0047 }