News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

CPUID test piece.

Started by hutch--, April 23, 2010, 06:27:50 AM

Previous topic - Next topic

Magnum

I get this on a P-3 Coppermine.

Model ID string = Pentium Pro, II or Celeron Processor

Supported Instruction Sets
SSE4.2 NO
SSE4.1 NO
SSE3   NO
SSE2   NO
SSE    YES
MMX    YES
Have a great day,
                         Andy

MichaelW

Now on my Slot-1 P3 I get:

Manufacturer = GenuineIntel

Model ID string = Pentium Pro, II or Celeron Processor

Supported Instruction Sets
SSE4.2 NO
SSE4.1 NO
SSE3   NO
SSE2   NO
SSE    YES
MMX    YES
eschew obfuscation

hutch--

It looks like with the PIII results that 80000000 return function with the value 00000002h is wrong. It is suposed to return 00000003h for a PIII.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

sinsi

The processor serial number can be switched off in the BIOS, but I don't know whether the PSN bit is still cleared.
(If this is what you mean by a value of 00000003).
Light travels faster than sound, that's why some people seem bright until you hear them.

MichaelW

I think after all the bad press the processor serial number is switched off by default for most BIOSes.

Back when I did this, for the Intel processors I identified the specific processor by using the "brand index" returned in EBX bits 7-0 by CPUID function 1 to index a table of strings extracted from the Intel manual, specifically 25366615.pdf, "Mapping of Brand Indices and IA-32 Processor Brand Strings". It worked for the Intel processors that I had access to at the time. It did not work for some of the later processors, and I recall the conclusion that I came to was that Intel had switched directions somewhere after the Pentium 4 was introduced and adopted the AMD method (possibly hanging it off of a different set of extended functions, I never took the time to check this out). For the AMD method the processor brand string returned by extended functions 80000002-80000004 specified the processor name, and it worked correctly at least back to the K5.
eschew obfuscation

Magnum

Quote from: hutch-- on April 26, 2010, 05:31:05 AM
It looks like with the PIII results that 80000000 return function with the value 00000002h is wrong. It is suposed to return 00000003h for a PIII.

I had my serial number disabled. When I enabled it I got this.

When I ran cpufix.exe, the debugger came up and stopped at mov edi, dword ptr ds:[eax]. ??

Manufacturer = GenuineIntel

Model ID string = Pentium III Processor

Supported Instruction Sets
SSE4.2 NO
SSE4.1 NO
SSE3   NO
SSE2   NO
SSE    YES
MMX    YES
Press any key to continue ...

Have a great day,
                         Andy

dedndave

#36
CPUID leaf 80000000h returns the largest supported extended leaf
to ID the Pentium 1/Pro/2/3's, use the Processor Signature from leaf 00000001h EAX register
the Intel document 241618.pdf has quite a few errors in the Signature table
i have corrected most, if not all, of these errors in the Signature table pic...

http://www.4shared.com/file/WHXNrzwq/Signature.html

the Signature table in the pdf mentioned above has a number of small mistakes
if you read the footnotes, it points you to the individual update pdf's for the Pentium 1/Pro/2/3 Family/Models
this is primarily where i got the correct info, along with sites like cpuworld, etc, that have partial CPUID dumps

you may also want the Brand Index and L2 Cache type to identify specific chips
i think, for your level of identification, the Processor Signature Family and Model values should be enough
the Family and Model values are combined in the low-order byte of the 00000001h leaf EAX Signature (AL)
for later 486's that support CPUID, the Family bits are 0100
for the Pentium I's, the Family bits are 0101
all the Pentium Pro/2/3's are in Family 0110 - use the low 4 bits (Model) to sort them out

Igor

@hutch--
Intel docs "Intel Processor Identification and the CPUID Instruction (AP-485)" say that you first need to check for presence of cpuid instruction by checking ability to set bit 21 in EFLAGS, my understanding is that 386 or earlier don't have cpuid and only some 486 have cpuid instruction. I guess it's not needed if you are sure that your code won't be run on 386 and 486, which possibly includes users with Win95 (minimum 386 cpu), Win98 (minimum 486) and WinNT (minimum 486).

Quote from: dedndave on April 23, 2010, 05:38:55 PM
the documentation states that a 486 is required for windows 95, but i seem to remember installing it on a 386
my memory is not what it used to be, so the documentation could be right
System requirements for installing Windows 95: Personal computer with a 386DX or higher processor (486 recommended)
http://support.microsoft.com/kb/138349

hutch--

Igor,

This is the version I use to test for CPUID.

The structure used.


    X86ST STRUCT
      sse4a dd ?
      sse42 dd ?
      sse41 dd ?
      ssse3 dd ?
      sse3  dd ?
      sse2  dd ?
      sse   dd ?
      mmx   dd ?
      mmxx  dd ?
      amd3D dd ?
      amd3x dd ?
    X86ST ENDS


The procedure.


; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

; "mmi" Multi media Instructions

OPTION PROLOGUE:NONE
OPTION EPILOGUE:NONE

mmi proc pStruct:DWORD

  ; returns 0 if no CPUID, 1 if it is supported.
  ; if supported tests from MMX to SSE4.2 and
  ; writes results to structure

  ; -------------------------------------------------
  ; test for CPUID so it does not crash on old timers
  ; -------------------------------------------------
    pushfd
    pop eax

    mov ecx, eax
    xor eax, 00000000001000000000000000000000b          ; set bit 21 of eflags
    push eax
    popfd
    pushfd
    pop eax

    xor eax, ecx            ; test if its changed
    jnz exists              ; if changed then CPUID
    xor eax, eax            ; returns 0 if no CPUID
    ret 4
  ; -------------------------------------------------

  exists:
  ; -------------------
  ; zero fill structure
  ; -------------------
    mov ecx, SIZEOF X86ST / 4

    mov eax, [esp+4]        ; pStruct
  @@:
    mov DWORD PTR [eax], 0
    add eax, 4
    sub ecx, 1
    jnz @B

  ; INTEL

    mov eax, 1
    cpuid

    mov eax, [esp+4]                                ; pStruct

    bt ecx, 20                                      ; sse4.2
    setc BYTE PTR (X86ST PTR [eax]).sse42

    bt ecx, 19                                      ; sse4.1
    setc BYTE PTR (X86ST PTR [eax]).sse41

    bt ecx, 9                                       ; ssse3
    setc BYTE PTR (X86ST PTR [eax]).ssse3

    bt ecx, 0                                       ; sse3
    setc BYTE PTR (X86ST PTR [eax]).sse3

    bt edx, 26                                      ; sse2
    setc BYTE PTR (X86ST PTR [eax]).sse2

    bt edx, 25                                      ; sse
    setc BYTE PTR (X86ST PTR [eax]).sse

    bt edx, 23                                      ; mmx
    setc BYTE PTR (X86ST PTR [eax]).mmx

  ; AMD

    mov eax, 80000001h
    cpuid

    mov eax, [esp+4]                                ; pStruct

    bt edx, 22                                      ; AMD mmx extended
    setc BYTE PTR (X86ST PTR [eax]).mmxx

    bt ecx, 6                                       ; AMD sse4a
    setc BYTE PTR (X86ST PTR [eax]).sse4a

    bt edx, 31                                      ; AMD 3DNow
    setc BYTE PTR (X86ST PTR [eax]).amd3D

    bt edx, 30                                      ; AMD 3DNowExt
    setc BYTE PTR (X86ST PTR [eax]).amd3x

    mov eax, 1
    ret 4

mmi endp

OPTION PROLOGUE:PrologueDef
OPTION EPILOGUE:EpilogueDef

; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

Igor

OK then, I didn't see it in the code that you uploaded so I thought I should mention it.


frktons

Hi Hutch. I have a question about your CPU identification code.
Do you consider the SSSE3 just a subset of SSE3 and for this reason
you don't display it?


Manufacturer = GenuineIntel

Model ID string = Intel(R) Core(TM)2 CPU          6600  @ 2.40GHz

Supported Instruction Sets
SSE4.2 NO
SSE4.1 NO
SSE3   YES
SSE2   YES
SSE    YES
MMX    YES



Frank
Mind is like a parachute. You know what to do in order to use it :-)

dedndave

hiyas Frank

the percentage of computers in use that support SSSE3 is not that high (i think Core2's and i7's at this time)
therefore, it isn't used that often in software
SSE4, of some flavour, is probably more common
that's probably why Hutch left it out   :P

not too many instructions in SSSE3:
http://softpixel.com/~cwright/programming/simd/ssse3.php

i think if you want to use SSE3 or above, you should probably provide some fall-back option for older CPU's
that means writing seperate routines to support different processors

frktons

Quote from: dedndave on November 13, 2010, 01:42:05 PM
hiyas Frank

the percentage of computers in use that support SSSE3 is not that high (i think Core2's and i7's at this time)
therefore, it isn't used that often in software
SSE4, of some flavour, is probably more common
that's probably why Hutch left it out   :P

not too many instructions in SSSE3:
http://softpixel.com/~cwright/programming/simd/ssse3.php

i think if you want to use SSE3 or above, you should probably provide some fall-back option for older CPU's
that means writing seperate routines to support different processors

Thanks for the insight Dave  :U

Frank
Mind is like a parachute. You know what to do in order to use it :-)

hutch--

The original topis was a test piece, check the last algo I posted that handles all up to sse4.2.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

clive

AMD with SSE4A
AuthenticAMD
AMD Athlon(tm) II X2 215 Processor
0 SSE 4.2
0 SSE 4.1
1 SSE 3
1 SSE 2
1 SSE
1 MMX


Processor 1 ID = 0
Number of cores 2 (max 2)
Number of threads 2 (max 2)
Name AMD Athlon II X2 215
Codename Regor
Specification AMD Athlon(tm) II X2 215 Processor
Package Socket AM3 (938)
CPUID F.6.2
Extended CPUID 10.6
Brand ID 12
Core Stepping DA-C2
Technology 45 nm
Core Speed 803.6 MHz
Multiplier x FSB 4.0 x 200.9 MHz
HT Link speed 803.6 MHz
Stock frequency 2700 MHz
Instructions sets MMX (+), 3DNow! (+), SSE, SSE2, SSE3, SSE4A, x86-64, AMD-V
L1 Data cache 2 x 64 KBytes, 2-way set associative, 64-byte line size
L1 Instruction cache 2 x 64 KBytes, 2-way set associative, 64-byte line size
L2 cache 2 x 512 KBytes, 16-way set associative, 64-byte line size
FID/VID Control yes
FID range 4.0x - 13.5x
Max VID 1.350 V
P-State FID 0xB - VID 0x10 - IDD 23 (13.5x - 1.350 V)
P-State FID 0x5 - VID 0x18 - IDD 17 (10.5x - 1.250 V)
P-State FID 0x10E - VID 0x20 - IDD 15 (7.5x - 1.150 V)
P-State FID 0x100 - VID 0x2C - IDD 8 (4.0x - 1.000 V)

Package Type 0x1
Model 15
String 1 0x3
String 2 0x6
Page 0x0
CmpCap 2
TDP Limit 62 Watts
TDC Limit 46 Amps
Attached device PCI device at bus 0, device 24, function 0
Attached device PCI device at bus 0, device 24, function 1
Attached device PCI device at bus 0, device 24, function 2
Attached device PCI device at bus 0, device 24, function 3
Attached device PCI device at bus 0, device 24, function 4


Thread dumps
-------------------------------------------------------------------------

CPU Thread 0
APIC ID 0
Topology Processor ID 0, Core ID 0, Thread ID 0
Type 0200400Bh
Max CPUID level 00000005h
Max CPUID ext. level 8000001Bh
Cache descriptor Level 1, I, 64 KB, 1 thread(s)
Cache descriptor Level 1, D, 64 KB, 1 thread(s)
Cache descriptor Level 2, U, 512 KB, 1 thread(s)

CPUID
0x00000000 0x00000005 0x68747541 0x444D4163 0x69746E65
0x00000001 0x00100F62 0x00020800 0x00802009 0x178BFBFF
0x00000002 0x00000000 0x00000000 0x00000000 0x00000000
0x00000003 0x00000000 0x00000000 0x00000000 0x00000000
0x00000004 0x00000000 0x00000000 0x00000000 0x00000000
0x00000005 0x00000040 0x00000040 0x00000003 0x00000000
0x80000000 0x8000001B 0x68747541 0x444D4163 0x69746E65
0x80000001 0x00100F62 0x100018F6 0x000037FF 0xEFD3FBFF
0x80000002 0x20444D41 0x6C687441 0x74286E6F 0x4920296D
0x80000003 0x32582049 0x35313220 0x6F725020 0x73736563
0x80000004 0x0000726F 0x00000000 0x00000000 0x00000000
0x80000005 0xFF30FF10 0xFF30FF20 0x40020140 0x40020140
0x80000006 0x20800000 0x42004200 0x02008140 0x00000000
0x80000007 0x00000000 0x00000000 0x00000000 0x000001F9
0x80000008 0x00003030 0x00000000 0x00002001 0x00000000
0x80000009 0x00000000 0x00000000 0x00000000 0x00000000
0x8000000A 0x00000001 0x00000040 0x00000000 0x0000000F
0x8000000B 0x00000000 0x00000000 0x00000000 0x00000000
0x8000000C 0x00000000 0x00000000 0x00000000 0x00000000
0x8000000D 0x00000000 0x00000000 0x00000000 0x00000000
0x8000000E 0x00000000 0x00000000 0x00000000 0x00000000
0x8000000F 0x00000000 0x00000000 0x00000000 0x00000000
0x80000010 0x00000000 0x00000000 0x00000000 0x00000000
0x80000011 0x00000000 0x00000000 0x00000000 0x00000000
0x80000012 0x00000000 0x00000000 0x00000000 0x00000000
0x80000013 0x00000000 0x00000000 0x00000000 0x00000000
0x80000014 0x00000000 0x00000000 0x00000000 0x00000000
0x80000015 0x00000000 0x00000000 0x00000000 0x00000000
0x80000016 0x00000000 0x00000000 0x00000000 0x00000000
0x80000017 0x00000000 0x00000000 0x00000000 0x00000000
0x80000018 0x00000000 0x00000000 0x00000000 0x00000000
0x80000019 0xF0300000 0x60100000 0x00000000 0x00000000
0x8000001A 0x00000003 0x00000000 0x00000000 0x00000000
0x8000001B 0x0000001F 0x00000000 0x00000000 0x00000000

MSR 0x0000001B 0x00000000 0xFEE00900
MSR 0xC0010114 0x00000000 0x00000008
MSR 0xC0010061 0x00000000 0x00000030
MSR 0xC0010062 0x00000000 0x00000003
MSR 0xC0010063 0x00000000 0x00000003
MSR 0xC0010064 0x800001E1 0x3C00200B
MSR 0xC0010065 0x800001AB 0x3C003005
MSR 0xC0010066 0x8000019A 0x3C00404E
MSR 0xC0010067 0x8000014B 0x3C005840
MSR 0xC0010068 0x0000014B 0x3C005840
MSR 0xC0010071 0x30B60083 0x3C035840
MSR 0xC0010015 0x00000000 0x01000010
MSR 0xC001001F 0x42584000 0x00000008
MSR 0xC0010058 0x00000000 0xFC000015
MSR 0xC0010004 0x00006AD0 0x738643CB
MSR 0xC0010071 0x30B60083 0x3C00200B
MSR 0xC0010070 0x00000000 0x3C00200B
It could be a random act of randomness. Those happen a lot as well.