Solved

Checking for RDTSC support

Posted on 1998-01-02
2
275 Views
Last Modified: 2013-12-03
Is there a quick check you can do to find out if the RDTSC (time stamp)
instruction
is supported on the particular CPU that you're running on?

I know you can back this out by doing a bunch of tests to see what brand
and model
CPU you have, and then figuring out from that info if the RDTSC
instruction is supported,
but I'm hoping to have a simpler runtime check that doesn't require us
to keep track
of every CPU brand and model.

Currently if you execute the RDTSC on cpu's that don't support it, Win95
pops up a
box about an illegal instruction. Is there some way you can attempt to
execute the
RDTSC and then catch the fact that its not supported before Win95 gets
upset
about it? If so, will this work on NT also?

Thanks for any help you can give me-
Paul Titchener

0
Comment
Question by:titchener
2 Comments
 
LVL 1

Accepted Solution

by:
Arkadiy earned 100 total points
ID: 1409811
You probably should use structured exceptions. Something like this:
BOOL bCommandAccessible = TRUE;
__try
{
   asm{RDTSC ...}
}
__except(1)
{
  //the command is not accessible
  bCommandAccessible = FALSE;
  ASSERT(_exception_code() == 6); //6 means invalid instruction
}

That code applies to Visual C++. If you use something els, see help on _structured_ (not C++) exception handling.
P.S. I never tried this code to catch a bad command exception. I use it mostly for code 5 (GPF)
0
 

Author Comment

by:titchener
ID: 1409812
I didn't try the suggested approach in the answer yet, but
it makes sense and looks like it will probably work well.

Thanks,

Paul Titchener
0

Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article describes how to add a user-defined command button to the Windows 7 Explorer toolbar.  In the previous article (http://www.experts-exchange.com/A_2172.html), we saw how to put the Delete button back there where it belongs.  "Delete" is …
For a while now I'v been searching for a circular progress control, much like the one you get when first starting your Silverlight application. I found a couple that were written in WPF and there were a few written in Silverlight, but all appeared o…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question