Author Topic: My version of a CPU identification utility  (Read 23042 times)

Mark44

  • Regular Member
  • *
  • Posts: 40
My version of a CPU identification utility
« on: February 22, 2014, 04:08:06 AM »
I've noticed several posts with code on how to identify which CPU you're running. I've recently been learning about the various SSE technologies as well as AVX, and I needed to be able to tell which of these technologies was supported on my Intel i7 processor. I've attached my own take on a CPU ID utility.

Here's an example of the info that it provides.
Code: [Select]
C:\Users\Mark\Documents\Visual Studio 2010\Projects\CPUInfo\Debug>cpuinfo
Extended + family ID: 06
Extended + model ID: 3a
Stepping: 9
Microarchiture: Ivy Bridge

CPU has FP unit.
CPU has MMX.
CPU has SSE.
CPU has SSE2.
CPU has SSE3.
CPU has SSE 4.1.
CPU has SSE 4.2.
CPU has AVX.
CPU does not have AVX2.


One feature of my code that I haven't seen elsewhere is that it displays the (Intel-specific) microarchitecture, which is useful to know if you're reading the Intel documentation. A shortcoming is that the code I wrote was a quick-and-dirty utility that works on the one machine I tested it on.

Gunther

  • Member
  • *****
  • Posts: 3722
  • Forgive your enemies, but never forget their names
Re: My version of a CPU identification utility
« Reply #1 on: February 22, 2014, 04:26:54 AM »
Mark,

good approach. You would have presumably more answers if you would write an additional version with an external assembler. Apart from that it's a solid work.

Gunther
Get your facts first, and then you can distort them.

TWell

  • Member
  • ****
  • Posts: 748
Re: My version of a CPU identification utility
« Reply #2 on: February 22, 2014, 04:43:16 AM »
Binary compiled with msvc2010 sp1 using msvcrt.dll

dedndave

  • Member
  • *****
  • Posts: 8829
  • Still using Abacus 2.0
    • DednDave
Re: My version of a CPU identification utility
« Reply #3 on: February 22, 2014, 04:45:53 AM »
Jochen, Hutch, and I, and many others have written various versions of CPU ID routines
search the old forum


dedndave

  • Member
  • *****
  • Posts: 8829
  • Still using Abacus 2.0
    • DednDave
Re: My version of a CPU identification utility
« Reply #4 on: February 22, 2014, 04:51:31 AM »
i am running XP SP3
for the EXE that Timppa compiled...



never saw that one before - lol

GoneFishing

  • Member
  • *****
  • Posts: 1071
  • Gone fishing
Re: My version of a CPU identification utility
« Reply #5 on: February 22, 2014, 04:54:11 AM »
Here's the output for my CPU:
Quote
Extended + family ID: 06
Extended + model ID: 17
Stepping: a
Microarchiture: Enhanced Intel Core Microarchitecture

CPU has FP unit.
CPU has MMX.
CPU has SSE.
CPU has SSE2.
CPU has SSE3.
CPU does not have SSE 4.1.
CPU does not have SSE 4.2.
CPU does not have AVX.
Compiles and runs nicely here  :t

GoneFishing

  • Member
  • *****
  • Posts: 1071
  • Gone fishing
Re: My version of a CPU identification utility
« Reply #6 on: February 22, 2014, 04:56:07 AM »
i am running XP SP3
for the EXE that Timppa compiled...



never saw that one before - lol
Probably you don't have right version of msvcrt.dll

dedndave

  • Member
  • *****
  • Posts: 8829
  • Still using Abacus 2.0
    • DednDave
Re: My version of a CPU identification utility
« Reply #7 on: February 22, 2014, 04:58:07 AM »
you think ?

GoneFishing

  • Member
  • *****
  • Posts: 1071
  • Gone fishing
Re: My version of a CPU identification utility
« Reply #8 on: February 22, 2014, 04:58:40 AM »
shure
check the imports
[EDIT]: Hmm ... strange ,  maybe it's Win XP's kernel32.dll that throws an error ?

Gunther

  • Member
  • *****
  • Posts: 3722
  • Forgive your enemies, but never forget their names
Re: My version of a CPU identification utility
« Reply #9 on: February 22, 2014, 04:59:04 AM »
Dave,

i am running XP SP3
for the EXE that Timppa compiled...



never saw that one before - lol

that's very strange.

Mark,

works fine under Windows XP (emulation) and native Windows 7 (64 bit). Here is the output:
Code: [Select]
Extended + family ID: 06
Extended + model ID: 3a
Stepping: 9
Microarchiture: Ivy Bridge

CPU has FP unit.
CPU has MMX.
CPU has SSE.
CPU has SSE2.
CPU has SSE3.
CPU has SSE 4.1.
CPU has SSE 4.2.
CPU has AVX.
CPU does not have AVX2.

F:\MatMul>

Gunther
Get your facts first, and then you can distort them.

Mark44

  • Regular Member
  • *
  • Posts: 40
Re: My version of a CPU identification utility
« Reply #10 on: February 22, 2014, 05:14:49 AM »
Mark,

good approach. You would have presumably more answers if you would write an additional version with an external assembler. Apart from that it's a solid work.

Gunther
At the moment, all I have is the MS assembler in VS 10. I will look into downloading one of the other assemblers I've seen described here.

jj2007

  • Member
  • *****
  • Posts: 11450
  • Assembler is fun ;-)
    • MasmBasic
Re: My version of a CPU identification utility
« Reply #11 on: February 22, 2014, 05:28:45 AM »
i am running XP SP3
for the EXE that Timppa compiled...

Same problem here, XP SP3 & can't find the entry point :(

TWell

  • Member
  • ****
  • Posts: 748
Re: My version of a CPU identification utility
« Reply #12 on: February 22, 2014, 05:32:05 AM »
My bad, now corrected. :icon_redface:

i am running XP SP3
for the EXE that Timppa compiled...



never saw that one before - lol
I forgot to link msvcrt_winxp.obj from WDDK when using msvcrt.lib/msvcrt.dll

Gunther

  • Member
  • *****
  • Posts: 3722
  • Forgive your enemies, but never forget their names
Re: My version of a CPU identification utility
« Reply #13 on: February 22, 2014, 05:41:00 AM »
Hi Mark,

At the moment, all I have is the MS assembler in VS 10. I will look into downloading one of the other assemblers I've seen described here.

that's a good idea. In the upper right corner of the forum you'll find MASM32 download link. A nearly 100% MASM compatible assembler is jWasm, which I would strongly recommend. It's fast, lean and well maintained by our forum member Japheth. Moreover, some MASM bugs are eliminated. Another similar tool is the Solar Assembler, which is written and maintained by forum member and Global Moderator BogdanOntanu.

In the other direction you have the NASM like tools like NASM and YASM, both not bad and worth a try. Another alternative is FASM.

I've installed in parallel MASM, jWasm, YASM and GAS for Windows XP, Windows 7, Linux and BSD. That's not a problem. Have fun and happy installing.

Gunther
Get your facts first, and then you can distort them.

Mark44

  • Regular Member
  • *
  • Posts: 40
Re: My version of a CPU identification utility
« Reply #14 on: February 22, 2014, 06:30:09 AM »
Gunther,
I'll check those out. jWasm and Solar sound interesting, from what I've read about them on this forum.

Back about 20 years ago I was a co-author of a book on targeting DOS using assembly, and did a lot of work with Borland's Turbo Assembler (TASM). I did all of the compiling/assembling and linking from the command line. At the moment I'm doing everything through VS, and the switches for MASM (via VS) are something of a mystery to me, although I'm coming along.