From a1956bc83b2abd5813faa1f7729866d238de91a4 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Sat, 18 Mar 2006 08:56:58 +0000 Subject: [PATCH] added cpuid helper func --- amxmodx/helpers-x86.asm | 51 ++++++++++++++++++++++++++++++++++ amxmodx/msvc/amxmodx_mm.vcproj | 10 +++++++ amxmodx/optimizer.cpp | 7 ++++- amxmodx/optimizer.h | 1 + 4 files changed, 68 insertions(+), 1 deletion(-) create mode 100644 amxmodx/helpers-x86.asm diff --git a/amxmodx/helpers-x86.asm b/amxmodx/helpers-x86.asm new file mode 100644 index 00000000..3039cf2c --- /dev/null +++ b/amxmodx/helpers-x86.asm @@ -0,0 +1,51 @@ +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; (C)2006 by David "BAILOPAN" Anderson ; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +;;Licensed under the GNU General Public License, version 2 +;;This is a portion of AMX Mod X +;; and is maintained by the AMX Mod X development team. + +section .text + +global amxx_CpuSupport, _amxx_CpuSupport + +amxx_CpuSupport: +_amxx_CpuSupport: + push ebp + mov ebp, esp + + push ebx + + mov eax, 0 + cpuid + cmp eax, 1 + jl .fail + + mov eax, 1 + cpuid + ;check if family == 5 or 4 + and eax, 0780h ;family mask + shr eax, 7 ;family shift + cmp eax, 5 + je .fail + cmp eax, 4 + je .fail + ;check if CMOV exists + shr edx, 15 + and edx, 1 + cmp edx, 0 + je .fail + + mov eax, 1 + jmp .end + +.fail: + xor eax, eax + +.end + + pop ebx + + pop ebp + ret diff --git a/amxmodx/msvc/amxmodx_mm.vcproj b/amxmodx/msvc/amxmodx_mm.vcproj index 0ebc4558..6ffb3720 100755 --- a/amxmodx/msvc/amxmodx_mm.vcproj +++ b/amxmodx/msvc/amxmodx_mm.vcproj @@ -1084,12 +1084,22 @@ + + + + + + :\ //FIND_NATIVE("floatsin", N_Float_Sin); diff --git a/amxmodx/optimizer.h b/amxmodx/optimizer.h index 76690ffd..853d5a04 100644 --- a/amxmodx/optimizer.h +++ b/amxmodx/optimizer.h @@ -22,6 +22,7 @@ struct optimizer_s }; void SetupOptimizer(AMX *amx); +extern "C" int amxx_CpuSupport(); extern int g_opt_level;