News:

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

CPUID Library test

Started by hutch--, April 25, 2010, 07:14:32 AM

Previous topic - Next topic

hutch--

The idea in the first place was to make re-usable routines that could be used to determine if later SSE instruction sets could be used in a program that is running on a particular processor. The test piece is a simple dialog interface that tests if CPUID is available, if it is it gets the brand and CPU strings and tests the Intel specs of SSE 4.2 down to MMX. Form looking at what is available it would appear that a detect rountine for AMD hardware needs to be done seperately as there is enough divergence in capacity to warrant doing it this way.

From the brand string it is easy enough to determine if the processor is Intel or AMD then switch to the rountine that handles specific instruction sets for each processor. In the library there is a procedure "intel_mm_set" that works according to the Intel specification,what I had in mind was another routine "amd_mm_set" that checked for specific AMD sets like 3Dnow and sse4a.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

sinsi

I get nothing - isn't a dialog supposed to show?
Light travels faster than sound, that's why some people seem bright until you hear them.

Vortex

Hi Hutch,

Project.exe does not display a GUI. No any output.

dedndave

don't use the Brand String to determine the vendor, Hutch
instead, use the Vendor ID String, which is supported on all CPU's that support CPUID except, perhaps, the 486's
there are a dozen or so Vendor ID strings to contend with

as i posted in the other thread, a few non-AMD parts support 3DNow!
while most of those do not support 3DNow!+, bit 30 is reserved on those processors for that purpose

there is one or two feature bits that are Intel only, also

so, for the reduced set of feature bits that you are shooting for, there are probably only 3 or 4 masks to contend with
you can combine the extracted feature bits into a single dword before masking
that way, each vendor-dependant mask is a single dword

hutch--

Now I am confused, I downloaded it to check if there was any damage to the zip file but it runs correctly here. A simple dialog interface with 2 buttons and a set of static controls to display the data. It should not matter but it has a 64 pixel square RGB/a icon that is displayed on the dialog.

I am running on XP SP3 which works correctly.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

Vortex

Hi Hutch,

My system is XP SP3. I removed the line :

1 MANIFEST "manifest.xml"

from rsrc.rc and rebuilt the project. Now, the application works fine. Not 100% sure if it's a resource problem but could you check the manifest and resource files?

dedndave

it runs fine here, Hutch
just can't copy/paste the result   :P
i am running XP Pro SP2 with a prescott
is that your mother ?



the info is correct

ecube

works fine for me on xp sp2 but heres vendor code by tedd


.586
.model flat, stdcall
option casemap:none
include \masm32\include\windows.inc
include \masm32\include\kernel32.inc
includelib \masm32\lib\kernel32.lib
include \masm32\include\user32.inc
includelib \masm32\lib\user32.lib

;***************************************************************************************************

.data
mbTitle     db "Vendor String",0

.data?
buff        db 256 dup (?)

.code
start:
    mov eax,80000000h
    cpuid
    .IF (eax>=80000005h)
        push edi
        lea edi,[buff]
        mov eax,80000002h
        cpuid
        mov [edi+00h],eax
        mov [edi+04h],ebx
        mov [edi+08h],ecx
        mov [edi+0Ch],edx
        mov eax,80000003h
        cpuid
        mov [edi+10h],eax
        mov [edi+14h],ebx
        mov [edi+18h],ecx
        mov [edi+1Ch],edx
        mov eax,80000004h
        cpuid
        mov [edi+20h],eax
        mov [edi+24h],ebx
        mov [edi+28h],ecx
        mov [edi+2Ch],edx
        mov eax,80000005h
        cpuid
        mov [edi+30h],eax
        mov [edi+34h],ebx
        mov [edi+38h],ecx
        mov [edi+3Ch],edx
        invoke MessageBox, NULL,edi,ADDR mbTitle,MB_OK or MB_ICONINFORMATION
        pop edi
    .ENDIF
    invoke ExitProcess, NULL
end start

dedndave

that is the Brand String, Cube - not the Vendor String
the Vendor String on mine is "GenuineIntel"
for most AMD parts, it is "AuthenticAMD"

hutch--

Dave,

That looks correct for the prescott you use. The image is a Raphael painting from the 15th century.

Erol, I am not sure what is going on with the manifest, I have tested the exe on win2000, xp sp3 and win7 64 and it runs correctly with that manifest. have you got some form of security software that may rejest the exe with that manifest ?

Cube, thanks for Tedd's code but I had already worked that one out myself.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

ecube

ok, he was calling it the vendor string so idk, also it works fine for me on win7 in vmware aswell, can more people test this please to make sure its alright?

hutch--

Cube,

It looks fine, I would be tempted to put it in a seperate proc so it can be used from any app. Just pass a buffer to it and write to the buffer.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

dedndave

Vendor Strings
"GenuineIntel" Intel processor

"AuthenticAMD" AMD processor
"AMDisbetter!" AMD engineering samples
"AMD ISBETTER" AMD engineering samples
"Geode by NSC" National Semiconductor (now AMD) (embedded systems)

"CyrixInstead" Cyrix

"VIA VIA VIA " VIA
"CentaurHauls" Centaur (includes IDT/WinChip 2)

"UMC UMC UMC " UMC

"NexGenDriven" NexGen

"RiseRiseRise" Rise Technology

"SiS SiS SiS " SiS

"GenuineTMx86" Transmeta
"TransmetaCPU" Transmeta

EDIT - WinChip - the company has changed hands so many times
possible WinChip Vendor strings: CentaurHauls, GenuineIntel, AuthenticAMD, CyrixInstead
stuff like that makes using CPUID a pain in the ass

processors that support 3DNow! and 3DNow!+ bits

All AMD processors after K6-2 (inclusive)
National Semiconductor Geode, later AMD Geode.
VIA C3 (also known as Cyrix III) "Samuel", "Ezra", and "Eden" cores.
IDT Winchip 2

hutch--

Dave,

Now you know why I don't particularly want to deal with the legacy stuff, as long as it will run on the old stuf without an invalid opcode exception and will show the vendor string it will do the job. The real action is in late Intel and AMD processors and what instruction sets they can use.

If you get no to everything its integer instructions only, then in ascending order, MMX SSE SSE2/3/4.1/2 and when I track it down for AMD the 3Dnow and later stuff.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

Vortex

Hi Hutch,

I tried the original executable on my other computer running XP SP3. No any security software and no any display. Removing the manifest worked on my laptop too.