sys_wina.s 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. /*
  2. Copyright (C) 1996-1997 Id Software, Inc.
  3. This program is free software; you can redistribute it and/or
  4. modify it under the terms of the GNU General Public License
  5. as published by the Free Software Foundation; either version 2
  6. of the License, or (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  10. See the GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program; if not, write to the Free Software
  13. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  14. */
  15. //
  16. // sys_wina.s
  17. // x86 assembly-language Win-dependent routines.
  18. #include "asm_i386.h"
  19. #include "quakeasm.h"
  20. //@@@ should be id386-dependent, and have an equivalent C path
  21. .data
  22. .align 4
  23. fpenv:
  24. .long 0, 0, 0, 0, 0, 0, 0, 0
  25. .text
  26. .globl C(MaskExceptions)
  27. C(MaskExceptions):
  28. fnstenv fpenv
  29. orl $0x3F,fpenv
  30. fldenv fpenv
  31. ret
  32. #if 0
  33. .globl C(unmaskexceptions)
  34. C(unmaskexceptions):
  35. fnstenv fpenv
  36. andl $0xFFFFFFE0,fpenv
  37. fldenv fpenv
  38. ret
  39. #endif
  40. .data
  41. .align 4
  42. .globl ceil_cw, single_cw, full_cw, cw, pushed_cw
  43. ceil_cw: .long 0
  44. single_cw: .long 0
  45. full_cw: .long 0
  46. cw: .long 0
  47. pushed_cw: .long 0
  48. .text
  49. .globl C(Sys_LowFPPrecision)
  50. C(Sys_LowFPPrecision):
  51. fldcw single_cw
  52. ret
  53. .globl C(Sys_HighFPPrecision)
  54. C(Sys_HighFPPrecision):
  55. fldcw full_cw
  56. ret
  57. .globl C(Sys_PushFPCW_SetHigh)
  58. C(Sys_PushFPCW_SetHigh):
  59. fnstcw pushed_cw
  60. fldcw full_cw
  61. ret
  62. .globl C(Sys_PopFPCW)
  63. C(Sys_PopFPCW):
  64. fldcw pushed_cw
  65. ret
  66. .globl C(Sys_SetFPCW)
  67. C(Sys_SetFPCW):
  68. fnstcw cw
  69. movl cw,%eax
  70. #if id386
  71. andb $0xF0,%ah
  72. orb $0x03,%ah // round mode, 64-bit precision
  73. #endif
  74. movl %eax,full_cw
  75. #if id386
  76. andb $0xF0,%ah
  77. orb $0x0C,%ah // chop mode, single precision
  78. #endif
  79. movl %eax,single_cw
  80. #if id386
  81. andb $0xF0,%ah
  82. orb $0x08,%ah // ceil mode, single precision
  83. #endif
  84. movl %eax,ceil_cw
  85. ret