reg_convert.c 1.6 KB

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