views:

385

answers:

2

Hi,

I would like to know if somebody around here has some good examples of a C++ CPUID implementation that can be referenced from any of the managed .net languages.

Also, should this not be the case, should I be aware of certain implementation differences between X86 and X64?

I would like to use CPUID to get info on the machine my software is running on (crashreporting etc...) and I want to keep everything as widely compatible as possible.

Primary reason I ask is because I am a total noob when it comes to writing what will probably be all machine instructions though I have basic knowledge about CPU registers and so on...

Before people start telling me to Google: I found some examples online, but usually they were not meant to allow interaction from managed code and none of the examples was aimed at both X86 and X64. Most examples appeared to be X86 specific.

Cheers,

Kris

+1  A: 

Might not be exactly what you are looking for, but Intel have a good article and sample code for enumerating IA64 platform architectures (processor, cache, etc.) which also seems to cover 32 bit x86 processors.

Stephen Doyle
I saw this one already, there are some more on intel.com as well as MSDN. But particularly for the one you referenced: for the life of me, I would not be able to figure out how to compile this properly into some native dll's that I could call from my C# code... I am busy trying to learn all things programming beyond managed environments, but the learning curves are steep :)
Kris
IA64 is actually Itanium, whereas that article refers to "Intel 64" which is more commonly called x86_64.
kdt
+1  A: 

So I found this just now.

I think I can definitely use this but I have some remaining questions:

How do I compile this in either VS2008 or 2010b2? I'll probably need MASM or similar tools but I am not sure I know how to use it properly. Also, how can I use this code to compile either an x86 or an x64 dll???

Kris