Solved

Checking for RDTSC support

Posted on 1998-01-02
2
274 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

As more and more people are shifting to the latest .Net frameworks, the windows presentation framework is gaining importance by the day. Many people are now turning to WPF controls to provide a rich user experience. I have been using WPF controls fo…
With most software applications trying to cater to multiple user needs nowadays, the focus is to make them as configurable as possible. For e.g., when creating Silverlight applications which will connect to WCF services, the service end point usuall…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
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…

785 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