Original Post
I use VC++ and streaming SIMD functions. Does this class and function exists on UNIX?
// FPU:
#define PF_FPU 1<<0
// MMX:
#define PF_MMX 1<<1
// AMD MMX:
#define PF_EMMX 1<<2
// 3DNow!:
#define PF_3DNOW 1<<3
// 3DNow Extensions:
#define PF_E3DNOW 1<<4
// SIMD:
#define PF_SSE 1<<5
BOOL GetCPUFeatures(char* szMan, DWORD dwFeatures)
{
BOOL bHasCPUID = FALSE;
DWORD dwStdFeatures = 0;
DWORD dwExFeatures = 0;
szMan[12] = 0;
dwFeatures = 0;
_asm
{
// First check for a CPUID instruction (at least a 486) //
pushfd
pop eax
mov edx, eax
xor eax, 1<<21
push eax
popfd
pushfd
pop eax
xor eax,edx
jz short done
mov [bHasCPUID], 1
// Get Manufacturer //
mov eax, 0 // CPUID function 0 : Manufacturer + highest CPUID
cpuid
mov dword ptr szMan, ebx
mov dword ptr szMan+4, edx
mov dword ptr szMan+8, ecx
// AMD ('AuthenticAMD')? //
cmp ebx, 'htuA'
jne short not_amd
cmp edx, 'itne'
jne short not_amd
cmp ecx, 'DMAc'
je get_features
not_amd:
// Intel ('GenuineIntel')? //
cmp ebx, 'uneG'
jne short not_intel
cmp edx, 'Ieni'
jne short not_intel
cmp ecx, 'letn'
je get_features
not_intel:
// Cyrix ('CyrixInstead')? //
cmp ebx, 'iryC'
jne short not_cyrix
cmp edx, 'snIx'
jne short not_cyrix
cmp ecx, 'deat'
je get_features
not_cyrix:
get_features:
cmp eax, 1
jb short done
mov eax, 1 // CPUID function 1 : Features + Version
cpuid
mov [dwStdFeatures], edx
// Next find out which extended features are present (if any) //
mov eax, 0x80000000 // CPUID 80000000 : how many extended features
cpuid
cmp eax, 0x80000001 // check for at least 1 extended function
jb short done
mov eax, 0x80000001 // CPUID 80000001 : Extended features list
cpuid
mov [dwExFeatures], edx
done:
}
if(!bHasCPUID)
return FALSE;
// FPU (Floating Point Unit) //
if(dwStdFeatures & 1<<0)
dwFeatures |= PF_FPU;
else
return FALSE;
// MMX (Multi Media eXtensions) //
if(dwStdFeatures & 1<<23)
dwFeatures |= PF_MMX;
// AMD MMX Extensions //
if(dwExFeatures & 1<<22)
dwFeatures |= PF_EMMX;
// AMD 3DNow! present //
if(dwExFeatures & 1<<31)
dwFeatures |= PF_3DNOW;
// AMD 3DNow! Extensions //
if(dwExFeatures & 1<<30)
dwFeatures |= PF_E3DNOW;
// SSE present //
if(dwStdFeatures & 1<<25)
dwFeatures |= PF_SSE;
return TRUE;
}

This topic has been locked by a moderator. New replies are not allowed.
With your permission, GameDev.net uses analytics cookies to understand how people use the platform. You can accept analytics or continue with necessary cookies only. Learn more