Example 3-6, Identification of sse3 with cpuid -7 – Intel ARCHITECTURE IA-32 User Manual

Page 187

Advertising
background image

Coding for SIMD Architectures

3

3-7

Example 3-6

Identification of SSE3 with

cpuid

SSE3 requires the same support from the operating system as SSE. To
find out whether the operating system supports SSE3 (FISTTP and 10 of
the SIMD instructions in SSE3), execute an SSE3 instruction and trap
for an exception if one occurs. Catching the exception in a simple
try/except clause (using structured exception handling in C++) and
checking whether the exception code is an invalid opcode will give you
the answer. See Example 3-7.

Detecting the availability of MONITOR and MWAIT instructions
can be done using a code sequence similar to

Example 3-6, the

availability of

MONITOR and MWAIT is indicated by bit 3 of the

returned value in ECX.

Software must check for support of MONITOR and MWAIT before
attempting to use MONITOR and MWAIT. Checking for support of
MONITOR and MWAIT can be done by executing the MONITOR
execution and trap for an exception similar to the sequence shown in

Example 3-7.

…identify existence of cpuid instruction

; identify signature is genuine intel

mov eax, 1

; request for feature flags

cpuid

; 0Fh, 0A2h cpuid instruction

test ECX, 000000001h

; bit 0 in feature flags equal to 1

jnz

Found

Advertising