reg_convert.c 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /*---------------------------------------------------------------------------+
  2. | reg_convert.c |
  3. | |
  4. | Convert register representation. |
  5. | |
  6. | Copyright (C) 1992,1993,1994,1996,1997 |
  7. | W. Metzenthen, 22 Parker St, Ormond, Vic 3163, Australia |
  8. | E-mail billm@suburbia.net |
  9. | |
  10. | |
  11. +---------------------------------------------------------------------------*/
  12. #include "exception.h"
  13. #include "fpu_emu.h"
  14. int FPU_to_exp16(FPU_REG const *a, FPU_REG *x)
  15. {
  16. int sign = getsign(a);
  17. *(long long *)&(x->sigl) = *(const long long *)&(a->sigl);
  18. /* Set up the exponent as a 16 bit quantity. */
  19. setexponent16(x, exponent(a));
  20. if (exponent16(x) == EXP_UNDER) {
  21. /* The number is a de-normal or pseudodenormal. */
  22. /* We only deal with the significand and exponent. */
  23. if (x->sigh & 0x80000000) {
  24. /* Is a pseudodenormal. */
  25. /* This is non-80486 behaviour because the number
  26. loses its 'denormal' identity. */
  27. addexponent(x, 1);
  28. } else {
  29. /* Is a denormal. */
  30. addexponent(x, 1);
  31. FPU_normalize_nuo(x);
  32. }
  33. }
  34. if (!(x->sigh & 0x80000000)) {
  35. EXCEPTION(EX_INTERNAL | 0x180);
  36. }
  37. return sign;
  38. }