CMP Game Media Group Presents: Home
  JoinHelpContact UsShop

Newswire
Features
Connection
Job Search
Directories
By Rob Wyatt
Gamasutra
May 28, 1999
Vol. 3: Issue 21

Features
Wyatt's World

Cracking Open The Pentium III

Contents

What is all the fuss about?

How do I detect the new instructions?

What operating system support is required for the Pentium III?

What are these new SIMD instructions?

How do I make use of the new instructions?

How do I debug code with the new instructions?

How do I read the new Pentium III serial number?

Is there any new performance/ profiling information?

How do I detect the new instructions?

You detect the Streaming SIMD Instructions in the same way as you detect MMX. You issue the CPUID instruction with EAX=1 and check the SIMD bit (bit 25) in the feature flags (EDX). Don’t forget to first check for the presence of the CPUID instruction! Here is code for detecting the new instructions:

bool DetectSIMD()
{

bool found_simd;
_asm

{

pushfd
pop eax // get EFLAGS into eax
mov ebx,eax // keep a copy
xor eax,0x200000
// toggle CPUID bit

push eax
popfd // set new EFLAGS
pushfd
pop eax // EFLAGS back into eax

xor eax,ebx
// have we changed the ID bit?

je NO_SIMD
// No, no CPUID instruction

// we could toggle the
// ID bit so CPUID is present
mov eax,1

cpuid // get processor features
test edx,1<<25 // check the SIMD bit
jz NO_SIMD
mov found_simd,1
jmp DONE
NO_SIMD:
mov found_simd,0
DONE:
}

return found_simd;

}

This function simply returns true when SIMD instructions are present. Ideally, you should always protect detection code with a __try/__except block, so if things go wrong you do not quit the application with an illegal opcode. Here’s how to implement the __try/__except block:

bool simd_present = false;
__try

{

simd_present = DetectSIMD();

}

__except(EXCEPTION_EXECUTE_HANDLER)

{
// If the DetectSIMD() function generates any sort
// of exception we
will end up here and then we
// assume there are no SIMD instructions.

simd_present = false;

}

The above code will function correctly on any make of processor. Be aware that even if you detect the presence of a Pentium III (Family 6, Model 7), don’t assume that it supports Streaming SIMD instructions. Other manufacturers such as AMD or Cyrix may release processors with Streaming SIMD support, or future Intel processors may not support Streaming SIMD, and that could jeopardize your game if it requires this support.

Be aware that successfully implementing the above code could be a problem if you are using Microsoft Visual C++. If you put the __try/__except block around the assembly listing and then call the function using bool simd_present = DetectSIMD(), Visual C++ 6.0 will not allow it. Visual C++ balks at the fact that the destination of the jump instructions are within a __try block, even though the source of the jump is within the same block. It appears that this is a limitation of inline assembly language within __try/__except blocks, but fortunately this problem is remedied if you use the Intel C/C++ reference compiler in conjunction with Visual C++.


What operating system support is required for the Pentium III?
 


Home | Join | Help | Contact Us | Shop | Newswire | Site Map | Calendar
Write for Us | Features | Connection | Job Search | Directories


Copyright © 2000 CMP Media Inc. All rights reserved.
Privacy Policy