
The MMX instructions
are supported by every x86 processor introduced in the market after the
venerable Intel Pentium MMX, so it should be fairly safe to assume that
the processor that your code is running on has MMX instructions. But checking
for MMX instructions is really simple and it avoids embarassing crashes
due to unsupported opcodes!
The following C function checks for MMX:
bool isMMXSupported()
{
int fSupported;
__asm
{
mov eax,1 // CPUID level 1
cpuid // EDX = feature flag
and edx,0x800000 // test bit 23 of feature flag
mov fSupported,edx // != 0 if MMX is supported
}
if (fSupported != 0)
return true;
else
return false;
}

I call ISSE the
integer subset of the SSE instruction set that enhances
MMX. Click here to see what processors
support ISSE.
The following C function works on both
Intel and AMD chips:
bool isISSESupported()
{
int processor;
int features;
int ext_features = 0;
__asm {
pusha
mov eax,1
cpuid
mov processor,eax //
Store processor family/model/step
mov features,edx
// Store features bits
mov eax,080000000h
cpuid
// Check which extended functions can be called
cmp eax,080000001h
// Extended Feature Bits
jb no_features
// jump if not supported
mov eax,080000001h
// Select function 0x80000001
cpuid
mov ext_features,edx // Store extended
features bits
no_features:
popa
}
if (((features >> 25) & 1) != 0)
return true;
else
if (((ext_features >> 22) & 1) != 0)
return true;
else
return false;
}
