added cpuid helper func

This commit is contained in:
David Anderson 2006-03-18 08:56:58 +00:00
parent ff61158491
commit a1956bc83b
4 changed files with 68 additions and 1 deletions

51
amxmodx/helpers-x86.asm Normal file
View File

@ -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

View File

@ -1084,12 +1084,22 @@
<File
RelativePath="..\amxjitsn.asm">
</File>
<File
RelativePath="..\helpers-x86.asm">
</File>
<File
RelativePath="..\natives-amd64.asm">
</File>
<File
RelativePath="..\natives-x86.asm">
</File>
<Filter
Name="Builds"
Filter="">
<File
RelativePath="..\Jit\helpers-x86.obj">
</File>
</Filter>
</Filter>
<Filter
Name="SDK"

View File

@ -99,7 +99,12 @@ void _Setup_Optimizer_Stage2(AMX *amx, cell *oplist, cell *cip)
}
if (g_opt_level & 2)
{
FIND_NATIVE("floatcmp", N_Float_Cmp);
if (amxx_CpuSupport())
{
FIND_NATIVE("floatcmp", N_Float_Cmp);
} else {
g_opt_level &= ~(2);
}
}
//we don't do these yet because of radix stuff >:\
//FIND_NATIVE("floatsin", N_Float_Sin);

View File

@ -22,6 +22,7 @@ struct optimizer_s
};
void SetupOptimizer(AMX *amx);
extern "C" int amxx_CpuSupport();
extern int g_opt_level;