D9xOSSupXMM.asm 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. ;//==========================================================================
  2. ;//
  3. ;// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
  4. ;// KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  5. ;// IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
  6. ;// PURPOSE.
  7. ;//
  8. ;// Copyright (c) 1999 - 2001 On2 Technologies Inc. All Rights Reserved.
  9. ;//
  10. ;//--------------------------------------------------------------------------
  11. ;
  12. ; **-Does9xOSSupportXMM
  13. ;
  14. ; This function will verify if the operating system supports the XMM
  15. ; instructions. According to Intel documentation
  16. ;
  17. ; Intel Architecture
  18. ; Software Developer
  19. ; Manual
  20. ; Volume 1:
  21. ; Basic Architecture
  22. ;
  23. ; The following needs to be true for the OS to suppor the XMM instructions
  24. ;
  25. ; CR0.EM(bit 2) = 0 (emulation disabled)
  26. ; CR4.OSFXSR(bit 9) = 1 (OS supports saving SIMD floating-point state during context
  27. ; switches)
  28. ;
  29. ; * * * N O T E * * * * * * N O T E * * * * * * N O T E * * * * * * N O T E * * * * * * N O T E * * * * * * N O T E * * *
  30. ;
  31. ; This function will NOT run on windows NT systems. The function reads control registers
  32. ; which are protected under Windows NT. If you attempt to run this function under Windows NT a
  33. ; protected mode access violation will be generated.
  34. ;
  35. ; * * * N O T E * * * * * * N O T E * * * * * * N O T E * * * * * * N O T E * * * * * * N O T E * * * * * * N O T E * * *
  36. ;
  37. ; Assumptions:
  38. ; Access to system control registers CR0 and CR4 are not protected
  39. ;
  40. ; Input:
  41. ; None
  42. ;
  43. ; Output:
  44. ; 1 Returned if OS supports XMM instructions
  45. ; 0 Returned if OS does not support XMM instructions
  46. ;
  47. ;
  48. .586
  49. .MODEL flat, SYSCALL, os_dos
  50. .DATA
  51. NAME x86cpuid
  52. PUBLIC Does9xOSSupportXMM_
  53. PUBLIC _Does9xOSSupportXMM
  54. .CODE
  55. ; int Does9xOSSupportXMM( void )
  56. Does9xOSSupportXMM_:
  57. _Does9xOSSupportXMM:
  58. push esi ;safety sh*&
  59. push edi
  60. push ebp
  61. push ebx
  62. push ecx
  63. push edx
  64. ; check to see if OS supports SIMD instructions
  65. mov edx,cr0
  66. bt edx,2 ; ensure no emulation
  67. jnae NoXMMSupport
  68. mov edx,cr4
  69. bt edx,9 ; OS support SIMD
  70. jnc NoXMMSupport
  71. ; we support XMM instructions
  72. mov eax,1
  73. jmp Exit
  74. NoXMMSupport:
  75. ; mov eax,0 ; OS does not support XMM instructions
  76. Exit:
  77. pop edx ;safety sh*&
  78. pop ecx
  79. pop ebx
  80. pop ebp
  81. pop edi
  82. pop esi
  83. ret
  84. ;************************************************
  85. END