summaryrefslogtreecommitdiffstats
path: root/arch/i386/math-emu/reg_convert.c
blob: 45a258752703fd1ce42e18d54bf840afcaa44cd4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/*---------------------------------------------------------------------------+
 |  reg_convert.c                                                            |
 |                                                                           |
 |  Convert register representation.                                         |
 |                                                                           |
 | Copyright (C) 1992,1993,1994,1996,1997                                    |
 |                  W. Metzenthen, 22 Parker St, Ormond, Vic 3163, Australia |
 |                  E-mail   billm@suburbia.net                              |
 |                                                                           |
 |                                                                           |
 +---------------------------------------------------------------------------*/

#include "exception.h"
#include "fpu_emu.h"


int FPU_to_exp16(FPU_REG const *a, FPU_REG *x)
{
  int sign = getsign(a);

  *(long long *)&(x->sigl) = *(const long long *)&(a->sigl);

  /* Set up the exponent as a 16 bit quantity. */
  setexponent16(x, exponent(a));

  if ( exponent16(x) == EXP_UNDER )
    {
      /* The number is a de-normal or pseudodenormal. */
      /* We only deal with the significand and exponent. */

      if (x->sigh & 0x80000000)
	{
	  /* Is a pseudodenormal. */
	  /* This is non-80486 behaviour because the number
	     loses its 'denormal' identity. */
	  addexponent(x, 1);
	}
      else
	{
	  /* Is a denormal. */
	  addexponent(x, 1);
	  FPU_normalize_nuo(x);
	}
    }

  if ( !(x->sigh & 0x80000000) )
    {
      EXCEPTION(EX_INTERNAL | 0x180);
    }

  return sign;
}

OpenPOWER on IntegriCloud