Stefano Tommesani

  • Increase font size
  • Default font size
  • Decrease font size
Home Programming Detecting MMX and SSE

Detecting MMX and SSE


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;
   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;
   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 {
    mov eax,1
    mov processor,eax     // Store processor family/model/step
    mov features,edx      // Store features bits

    mov eax,080000000h
    // 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
    mov ext_features,edx  // Store extended features bits

   if (((features >> 25) & 1) != 0)
    return true;
    if (((ext_features >> 22) & 1) != 0)
     return true;
     return false;


Latest Articles

Easily upload videos of security cameras to YouTube
In this example, we will import video from a Yi security camera into YouTube. The same process, with eventual adjustment to the naming of directories in the SD card used by the camera to record videos, will also apply to other
A software to stand out 27 January 2018, 14.35 Web
A software to stand out
Standing out of the pack starts by being visible, and being noticed by the right group of professionals. No matter how good your profile is, it is lost in a sea of similar profiles, so you need to show up and start attracting
Web page scraping, the easy way 07 January 2018, 00.46 Web
Web page scraping, the easy way
There are many ways to extract data elements from web pages, almost all of them prettier and cooler than the method proposed here, but as we are in an hurry, let's get that data quickly, ok? Suppose we have to extract the
Scraping dynamic page content 06 January 2018, 23.57 Web
Scraping dynamic page content
One of the most common roadblocks when scraping the content of web sites is getting the full contents of the page, including JS-generated data elements (probably, the ones you are looking for). So, when using CEFSharp to scrape
Unit-testing file I/O 26 November 2017, 12.09 Testing
Unit-testing file I/O
Two good news: file I/O is unit-testable, and it is surprisingly easy to do. Let's see how it works! A software no-one asked for First, we need a piece of software that deals with files and that has to be unit-tested. The