PROC.ASM 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. ;
  2. ; Command & Conquer Red Alert(tm)
  3. ; Copyright 2025 Electronic Arts Inc.
  4. ;
  5. ; This program is free software: you can redistribute it and/or modify
  6. ; it under the terms of the GNU General Public License as published by
  7. ; the Free Software Foundation, either version 3 of the License, or
  8. ; (at your option) any later version.
  9. ;
  10. ; This program is distributed in the hope that it will be useful,
  11. ; but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ; GNU General Public License for more details.
  14. ;
  15. ; You should have received a copy of the GNU General Public License
  16. ; along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. ;
  18. ; $Header: g:/library/wwlib32/system/rcs/opsys.asm 1.1 1994/04/18 09:14:12 jeff_wilson Exp $
  19. ;***************************************************************************
  20. ;** C O N F I D E N T I A L --- W E S T W O O D A S S O C I A T E S **
  21. ;***************************************************************************
  22. ;* *
  23. ;* Project Name : Operating System Flags *
  24. ;* *
  25. ;* File Name : OPSYS.ASM *
  26. ;* *
  27. ;* Programmer : Scott Bowen *
  28. ;* *
  29. ;* Start Date : January 26, 1993 *
  30. ;* *
  31. ;* Last Update : January 26, 1993 [SB] *
  32. ;* *
  33. ;* Updated to 32bit protected mode JAW *
  34. ;* *
  35. ;*-------------------------------------------------------------------------*
  36. ;* Functions: *
  37. ;* Operating_System -- Determines what the operating system is. *
  38. ;* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
  39. IDEAL
  40. P386
  41. MODEL USE32 FLAT
  42. GLOBAL Get_CPU :NEAR
  43. DATASEG
  44. OperatingSystem dw 0
  45. CODESEG
  46. ;***************************************************************************
  47. ;* Operating_System -- Determines what the operating system is. *
  48. ;* *
  49. ;* INPUT: NONE. *
  50. ;* *
  51. ;* OUTPUT: *
  52. ;* *
  53. ;* WARNINGS: *
  54. ;* *
  55. ;* HISTORY: *
  56. ;* 01/26/1993 SB : Created. *
  57. ;*=========================================================================*
  58. PROC Get_CPU C near
  59. USES ebx,ecx,edx,es,edi
  60. IF 0
  61. xor eax,eax
  62. mov ax,1
  63. pushf
  64. pop bx
  65. and bh,0fh
  66. push bx
  67. popf
  68. pushf
  69. pop cx
  70. and ch,0f0h
  71. cmp ch,0f0h
  72. je @@1 ;8086 or below 80286
  73. inc ax
  74. or bh,0f0h
  75. push bx
  76. popf
  77. pushf
  78. pop cx
  79. and ch,0f0h
  80. je @@1 ;80286
  81. ENDIF
  82. mov eax,3
  83. mov ebx,esp
  84. and esp,0fffffffch
  85. pushfd
  86. pop edx
  87. mov ecx,edx
  88. xor edx,000040000h
  89. push edx
  90. popfd
  91. pushfd
  92. pop edx
  93. push ecx
  94. popfd
  95. xor edx,ecx
  96. and edx,000040000h ;test alignment check bit
  97. mov esp,ebx
  98. jz @@1 ;80386
  99. ;.486
  100. inc eax
  101. pushfd
  102. pop edx
  103. mov ecx,edx
  104. xor edx,000200000h
  105. push edx
  106. popfd
  107. pushfd
  108. pop edx
  109. push ecx
  110. popfd
  111. xor edx,ecx ;test id bit
  112. jz @@1 ;80486
  113. P586
  114. mov eax,1
  115. ;.586 or higher, cpuid returns cpu generation number in ax bits 8-11
  116. cpuid
  117. and eax,0f00h
  118. shr eax,8
  119. P386
  120. @@1: ret
  121. ENDP Get_CPU
  122. ;----------------------------------------------------------------------------
  123. END
  124.