Skip to content

Instantly share code, notes, and snippets.

@RobinDavid
Created January 18, 2015 20:15
Show Gist options
  • Save RobinDavid/65d781e6edfd5ffeb379 to your computer and use it in GitHub Desktop.
Save RobinDavid/65d781e6edfd5ffeb379 to your computer and use it in GitHub Desktop.
Retrieve MMX and SSE support using the CPUID assembly command.
#include <iostream>
using namespace std;
int main(int argc,char* argv[])
{
unsigned int cpeinfo;
unsigned int cpsse3;
__asm__(
"mov $01,%%eax;"
"cpuid;"
"mov %%edx,%0;"
"mov %%ecx,%1"
:"=r"(cpeinfo),"=r"(cpsse3)
);
cout << "1 - Instruction set is supported by CPU\n";
cout << "0 - Instruction set not supported\n";
cout << "--------------------------------\n";
cout << "MMX: " << ((cpeinfo >> 23) & 0x1 ) << "\tSSE: " << ((cpeinfo >> 25) & 0x1 ) << "\tSSE2: " << ((cpeinfo >> 26) & 0x1 ) << "\n";
cout << "SSE3: " << ((cpsse3 ) & 0x1 );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment