sys_wina.s 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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. #define GLQUAKE 1 // don't include unneeded defs
  19. #include "asm_i386.h"
  20. #include "quakeasm.h"
  21. // LATER should be id386-dependent, and have an equivalent C path
  22. .data
  23. .align 4
  24. fpenv:
  25. .long 0, 0, 0, 0, 0, 0, 0, 0
  26. .text
  27. .globl C(MaskExceptions)
  28. C(MaskExceptions):
  29. fnstenv fpenv
  30. orl $0x3F,fpenv
  31. fldenv fpenv
  32. ret
  33. #if 0
  34. .globl C(unmaskexceptions)
  35. C(unmaskexceptions):
  36. fnstenv fpenv
  37. andl $0xFFFFFFE0,fpenv
  38. fldenv fpenv
  39. ret
  40. #endif
  41. .data
  42. .align 4
  43. .globl ceil_cw, single_cw, full_cw, cw, pushed_cw
  44. ceil_cw: .long 0
  45. single_cw: .long 0
  46. full_cw: .long 0
  47. cw: .long 0
  48. pushed_cw: .long 0
  49. .text
  50. .globl C(Sys_LowFPPrecision)
  51. C(Sys_LowFPPrecision):
  52. fldcw single_cw
  53. ret
  54. .globl C(Sys_HighFPPrecision)
  55. C(Sys_HighFPPrecision):
  56. fldcw full_cw
  57. ret
  58. .globl C(Sys_PushFPCW_SetHigh)
  59. C(Sys_PushFPCW_SetHigh):
  60. fnstcw pushed_cw
  61. fldcw full_cw
  62. ret
  63. .globl C(Sys_PopFPCW)
  64. C(Sys_PopFPCW):
  65. fldcw pushed_cw
  66. ret
  67. .globl C(Sys_SetFPCW)
  68. C(Sys_SetFPCW):
  69. fnstcw cw
  70. movl cw,%eax
  71. #if id386
  72. andb $0xF0,%ah
  73. orb $0x03,%ah // round mode, 64-bit precision
  74. #endif
  75. movl %eax,full_cw
  76. #if id386
  77. andb $0xF0,%ah
  78. orb $0x0C,%ah // chop mode, single precision
  79. #endif
  80. movl %eax,single_cw
  81. #if id386
  82. andb $0xF0,%ah
  83. orb $0x08,%ah // ceil mode, single precision
  84. #endif
  85. movl %eax,ceil_cw
  86. ret