sys_dosa.s 1.2 KB

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