home *** CD-ROM | disk | FTP | other *** search
/ High Voltage Shareware / high1.zip / high1 / DIR13 / OS2ASM.ZIP / FLTHEAD.ASM < prev    next >
Assembly Source File  |  1991-08-10  |  3KB  |  139 lines

  1. sgn             equ      80000000h      ;mask for sign bit
  2. sgn_mask        equ      7fffffffh      ;Mask off sign bit
  3. shortexp        equ      7F800000h      ;mask for short exponent
  4. shorthid        equ      00800000h      ;mask for hidden bit
  5. shortbias       equ            7Fh      ;exponent bias
  6. short_qnan      equ      7FC00000h      ;short quit NaN
  7. fqnan_bit       equ        400000h      ;Quite NaN bit for float
  8. short_infinity  equ      7F800000h
  9.  
  10. longexp         equ      7FF00000h      ;mask for long exponent
  11. longhid         equ      00100000h      ;mask for hidden bit
  12. mantisa_mask    equ      000fffffh      ;mask out Mantisa
  13. longbias        equ           3FFh      ;exponent bias
  14. long_qnan       equ      7FF80000h      ;quiet NaN
  15. dqnan_bit       equ         80000h      ;Quite NaN bit for double
  16. long_infinity   equ      7FF00000h
  17.  
  18.  
  19.  
  20. dtype_other    equ    00h
  21. dtype_zero    equ    01h
  22. dtype_infinite    equ    02h
  23. dtype_snan    equ    03h        ;signaling NaN index
  24. dtype_qnan    equ    04h        ;quite NaN index
  25. dtype_base    equ    5
  26.  
  27. FP_NANS         equ     0
  28. FP_NANQ         equ     1
  29. FP_INFINITE     equ     2
  30. FP_NORMAL       equ     3
  31. FP_SUBNORMAL    equ     4
  32. FP_ZERO         equ     5
  33.  
  34.  
  35.  
  36. ; Exceptions
  37. FE_INVALID    equ    1
  38. FE_DENORMAL    equ    2
  39. FE_DIVBYZERO    equ    4
  40. FE_OVERFLOW    equ    8
  41. FE_UNDERFLOW    equ    10h
  42. FE_INEXACT    equ    20h
  43. FE_ALL_EXCEPT    equ    3Fh
  44.  
  45. ; Rounding directions
  46. FE_TONEAREST    equ    0
  47. FE_DOWNWARD    equ    400h
  48. FE_UPWARD    equ    800h
  49. FE_TOWARDZERO    equ    0C00h
  50.  
  51. ; Rounding precision
  52. FE_FLTPREC    equ    0
  53. FE_DBLPREC    equ    200h
  54. FE_LDBLPREC    equ    300h
  55.  
  56. sh32StyRBy8       macro
  57.         local   notSticky32
  58.         or    AL,AL
  59.         je      notSticky32
  60.         or    AH,1
  61.  
  62. notSticky32:
  63.         shr     EAX,8
  64.     endm
  65.  
  66. xChgReg64 macro
  67.         xchg    EDX,ECX
  68.         xchg    EAX,EBX
  69.     endm
  70.  
  71. neg64   macro
  72.     neg    EDX
  73.     neg    EAX
  74.     sbb    EDX,0
  75.     endm
  76.  
  77. shl64    macro    r1,r2
  78.     shl    r2,1
  79.     rcl    r1,1
  80.     endm
  81.  
  82. shr64    macro    r1,r2
  83.     shr    r1,1
  84.     rcr    r2,1
  85.     endm
  86.  
  87. sh64LBy8  macro
  88.     shld    EDX,EAX,8
  89.     shl    EAX,8
  90.     endm
  91.  
  92. sh64RBy8  macro
  93.         shrd    EAX,EDX,8
  94.     shr    EDX,8
  95.     endm
  96.  
  97.  
  98. sh64StyRBy8       macro
  99.         or      AH,AL
  100.         shrd    EAX,EDX,8
  101.     shr    EDX,8
  102.         endm
  103.  
  104. ; Floating point environment
  105. fenv_t    struc
  106.     ;Mimic 8087 status
  107.     ;load with default values
  108.     status    dw    0
  109.     control    dw    1000h or FE_TONEAREST or FE_LDBLPREC or FE_ALL_EXCEPT
  110.     round    dw    FE_TONEAREST
  111.     res1    dw    0        ;reserved
  112.     res2    dw    0        ;reserved
  113. fenv_t    ends
  114.  
  115. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  116. ; Set floating point exception bits
  117.  
  118. feexcept macro    bits
  119.     ifdef _MT
  120.     push    bits
  121.     call    __FEEXCEPT
  122.     else
  123.     or    __fe_cur_env.status,bits
  124.     endif
  125.     endm
  126.  
  127. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  128. ; Get rounding mode in EAX
  129.  
  130. feround    macro
  131.     ifdef _MT
  132.     call    __FEROUND
  133.     else
  134.     movzx    EAX,__fe_cur_env.round
  135.     endif
  136.     endm
  137.  
  138.  
  139.