sys_dosa.s 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. //
  2. // sys_dosa.s
  3. // x86 assembly-language DOS-dependent routines.
  4. #include "qasm.h"
  5. .data
  6. .align 4
  7. fpenv:
  8. .long 0, 0, 0, 0, 0, 0, 0, 0
  9. .text
  10. .globl C(MaskExceptions)
  11. C(MaskExceptions):
  12. fnstenv fpenv
  13. orl $0x3F,fpenv
  14. fldenv fpenv
  15. ret
  16. #if 0
  17. .globl C(unmaskexceptions)
  18. C(unmaskexceptions):
  19. fnstenv fpenv
  20. andl $0xFFFFFFE0,fpenv
  21. fldenv fpenv
  22. ret
  23. #endif
  24. .data
  25. .align 4
  26. .globl ceil_cw, single_cw, full_cw, cw, pushed_cw
  27. ceil_cw: .long 0
  28. single_cw: .long 0
  29. full_cw: .long 0
  30. cw: .long 0
  31. pushed_cw: .long 0
  32. .text
  33. .globl C(Sys_LowFPPrecision)
  34. C(Sys_LowFPPrecision):
  35. fldcw single_cw
  36. ret
  37. .globl C(Sys_HighFPPrecision)
  38. C(Sys_HighFPPrecision):
  39. fldcw full_cw
  40. ret
  41. .globl C(Sys_PushFPCW_SetHigh)
  42. C(Sys_PushFPCW_SetHigh):
  43. fnstcw pushed_cw
  44. fldcw full_cw
  45. ret
  46. .globl C(Sys_PopFPCW)
  47. C(Sys_PopFPCW):
  48. fldcw pushed_cw
  49. ret
  50. .globl C(Sys_SetFPCW)
  51. C(Sys_SetFPCW):
  52. fnstcw cw
  53. movl cw,%eax
  54. #if id386
  55. andb $0xF0,%ah
  56. orb $0x03,%ah // round mode, 64-bit precision
  57. #endif
  58. movl %eax,full_cw
  59. #if id386
  60. andb $0xF0,%ah
  61. orb $0x0C,%ah // chop mode, single precision
  62. #endif
  63. movl %eax,single_cw
  64. #if id386
  65. andb $0xF0,%ah
  66. orb $0x08,%ah // ceil mode, single precision
  67. #endif
  68. movl %eax,ceil_cw
  69. ret