# CPUID Sample: Determines CPU Capabilities

The CPUID sample provides a routine that uses the CPUID instruction to determine the capabilities of the CPU being run.

The sample provides the function `int _cpuid(_p_info *pinfo)`, which returns data about the CPU. The `int` return value is a bitmask of flags for major processor features. The bits that might be set are:

- `#define _CPU_FEATURE_MMX 0x0001`

- `#define _CPU_FEATURE_SSE 0x0002`

- `#define _CPU_FEATURE_SSE2 0x0004`

- `#define _CPU_FEATURE_3DNOW 0x0008`

Security Note
This sample code is provided to illustrate a concept and should not be used in applications or Web sites, as it may not illustrate the safest coding practices.

# Building and Running the Sample

Note
If you are running Visual C++ Express Edition, you might need to install the Platform SDK before running this sample. For information on how to do this, see How to: Use Visual C++ Express Edition with the Microsoft Platform SDK.

#### To build and run this sample

1. Open the solution cpuid.sln.

2. From the Build menu, click Build.

3. From the Debug menu, select Start Without Debugging.

# Example Program Output

The sample includes a test.cpp file that trivially calls `_cpuid` and outputs the values in the resulting `_p_info` struct. For example, on a Pentium III computer that supports MMX and SSE, the program output would look something like this:

    C:\work\cpuid>test
    v_name:         GenuineIntel
    model:          INTEL Pentium-III
    family:         6
    model:          8
    stepping:       3
    feature:        00000003
            yes     _CPU_FEATURE_MMX
            yes     _CPU_FEATURE_SSE
            no      _CPU_FEATURE_SSE2
            no      _CPU_FEATURE_3DNOW
    os_support:     00000003
            yes     _CPU_FEATURE_MMX
            yes     _CPU_FEATURE_SSE
            no      _CPU_FEATURE_SSE2
            no      _CPU_FEATURE_3DNOW
    checks:         0000000f