flat assembler
Message board for the users of flat assembler.
 Home   FAQ   Search   Register 
 Profile   Log in to check your private messages   Log in 
flat assembler > Windows > test CPUID code

Author
Thread Post new topic Reply to topic
catafest



Joined: 05 Aug 2010
Posts: 97

test CPUID code

I make a test CPUID , any idea to solve this issue ?
I wanted to improve it with other tasks or to find other solutions to solve these issues of displaying hardware information in the CPU and beyond.

Code:
format PE GUI 4.0
entry start 

include 'win32ax.inc' 

section '.code' code readable executable 

    start

        ; INVOKE CPUID FUNCTION 0x00000000 

        xor     eax,eax 
        cpuid 

        ; EXTRACT VENDOR STRING FROM

        mov     [out_buffer.vendor_ebx],ebx
        mov     [out_buffer.vendor_edx],edx
        mov     [out_buffer.vendor_ecx],ecx

        ; CHECK FOR FUNCTION 0x00000001 

        cmp     eax,0x00000001 
        jl      .NoCPUID_FN1 

        ; INVOKE CPUID FUNCTION 0x00000001 

        mov     eax,0x00000001 
        cpuid 
        ; TEST FOR HTT  Hyper-Threading Technology

        test    edx,00010000000000000000000000000000b
        jz      .NoHTT
        mov     [out_buffer.htt_arch4],'YES '
    .NoHTT:

        ; TEST FOR MMX

        test    edx,00000000100000000000000000000000b 
        jz      .NoMMX 
        mov     [out_buffer.mmx_ach4],'YES '
    .NoMMX

        ; TEST FOR SSE 

        test    edx,00000010000000000000000000000000b 
        jz      .NoSSE 
        mov     [out_buffer.sse_ach4],'YES '
    .NoSSE

        ; TEST FOR SSE2 

        test    edx,00000100000000000000000000000000b 
        jz      .NoSSE2 
        mov     [out_buffer.sse2_ach4],'YES '
    .NoSSE2

        ; TEST FOR SSE3 

        test    ecx,00000000000000000000000000000001b 
        jz      .NoSSE3 
        mov     [out_buffer.sse3_ach4],'YES '
    .NoSSE3

    .NoCPUID_FN1

        ; DISPLAY RESULTS AND QUIT 

        invoke  MessageBox,NULL,out_buffer,'CPUID',MB_OK+MB_ICONINFORMATION
        invoke  ExitProcess,0 
        jmp     $ 

;---  SECTION DATA STRUCTURE FOR MESSAGE BOX

section '.data' data readable writeable 

    out_buffer:
                        db 'VENDOR',2,9,'- '
      .vendor_ebx       dd 0 
      .vendor_edx       dd 0 
      .vendor_ecx       dd 0 
                        db 9,13,10

                        db 'NoHTT',2,9,'- '
      .htt_arch4        dd 'NO  '
                        db 9,10

                        db 'MMX',2,9,'- '
      .mmx_ach4         dd 'NO  ' 
                        db 9,10

                        db 'SSE',2,9,'- '
      .sse_ach4         dd 'NO  ' 
                        db 9,10

                        db 'SSE2',2,9,'- '
      .sse2_ach4        dd 'NO  ' 
                        db 9,10

                        db 'SSE3',2,9,'- '
      .sse3_ach4        dd 'NO  ' 
                        db 9,10

                        db 0 ; end out_buffer

;---  DEFAULT DATA INCLUDES

section '.idata' import data readable 

    library kernel32,'kernel32.dll',\ 
            user32,'user32.dll' 

    include 'api\kernel32.inc' 
    include 'api\user32.inc' 



Last edited by catafest on 13 Dec 2017, 07:46; edited 1 time in total
Post 07 Dec 2017, 15:54
View user's profile Send private message Visit poster's website Yahoo Messenger Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 15731
Location: Crossing the Cauchy horizon

Re: test CPUID code


catafest wrote:
... any idea to solve this issue ?

What is the issue?
Post 07 Dec 2017, 16:03
View user's profile Send private message Visit poster's website Reply with quote
catafest



Joined: 05 Aug 2010
Posts: 97

so show infos about CPUID ( or CPU) .
Post 07 Dec 2017, 16:08
View user's profile Send private message Visit poster's website Yahoo Messenger Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 15731
Location: Crossing the Cauchy horizon

What does it display now?
Post 07 Dec 2017, 16:10
View user's profile Send private message Visit poster's website Reply with quote
catafest



Joined: 05 Aug 2010
Posts: 97

Just testing with fasm . Why ?
Post 07 Dec 2017, 18:16
View user's profile Send private message Visit poster's website Yahoo Messenger Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 15731
Location: Crossing the Cauchy horizon

I can't run your code right now from where I am, so you will need to explain more about what you see. Does it display anything? Does it only display a partial message? Does it crash? Something else?
Post 08 Dec 2017, 00:11
View user's profile Send private message Visit poster's website Reply with quote
catafest



Joined: 05 Aug 2010
Posts: 97

Running well .
I wanted to improve it with other tasks or to find other solutions to solve these issues of displaying hardware information in the CPU and beyond.
Post 13 Dec 2017, 07:45
View user's profile Send private message Visit poster's website Yahoo Messenger Reply with quote
donn



Joined: 05 Mar 2010
Posts: 100

Hi, maybe a test for threading capabilities such as number of logical processors?

You have a Hyper-Threading enabled check, but the number of cores could extend this. It could be a precursor check so that a multithreading engine could scale correctly, for example.

I think there are legacy and extended methods. I was interested in running a check for this just between two local test environments and think it's something like:


Code:

mov eax10000000000000000000000000001000b              ; Function Fn8000_0008h
cpuid                                                   ; 1111b,10100010b / 0F,A2       cpuid
mov rdx0
mov edxcl                                             ; 7:0 Num cores-1
mov rcx1b
add rcxrdx 




but haven't run it yet. This wouldn't be very proper probably since it doesn't cover every case, but if it returns the number of logical processors on my chips, would be good enough for now....
Post 17 Dec 2017, 20:19
View user's profile Send private message Reply with quote
catafest



Joined: 05 Aug 2010
Posts: 97

Is a good example on this thread : https://board.flatassembler.net/topic.php?p=158513
I try to test your code , I get en error on mov rdx, 0 (illegal intruction)
Where is the documentation for: this Function Fn8000_0008h ?

donn wrote:
Hi, maybe a test for threading capabilities such as number of logical processors?

You have a Hyper-Threading enabled check, but the number of cores could extend this. It could be a precursor check so that a multithreading engine could scale correctly, for example.

I think there are legacy and extended methods. I was interested in running a check for this just between two local test environments and think it's something like:


Code:

mov eax10000000000000000000000000001000b              ; Function Fn8000_0008h
cpuid                                                   ; 1111b,10100010b / 0F,A2       cpuid
mov rdx0
mov edxcl                                             ; 7:0 Num cores-1
mov rcx1b
add rcxrdx 




but haven't run it yet. This wouldn't be very proper probably since it doesn't cover every case, but if it returns the number of logical processors on my chips, would be good enough for now....

Post 18 Dec 2017, 10:57
View user's profile Send private message Visit poster's website Yahoo Messenger Reply with quote
donn



Joined: 05 Mar 2010
Posts: 100

Ah sorry, probably 64-bit:


Code:

mov eax10000000000000000000000000001000b              ; Function Fn8000_0008h 
cpuid                                                   ; 1111b,10100010b / 0F,A2       cpuid 
mov edx0 
mov dlcl                                             ; 7:0 Num cores-1 
mov ecx1b 
add ecxedx  




http://support.amd.com/TechDocs/24594.pdf on pgs. 614 (E.4.7) & 624 (E.5).[/code]
Post 18 Dec 2017, 19:44
View user's profile Send private message Reply with quote
catafest



Joined: 05 Aug 2010
Posts: 97

@donn: no, wrong again , even the pages are wrongs...
is anyone moderating this forum?
Post 19 Dec 2017, 11:45
View user's profile Send private message Visit poster's website Yahoo Messenger Reply with quote
Furs



Joined: 04 Mar 2016
Posts: 1128

Pages? What? You're being pretty vague on what "doesn't work". Is it just the snippet or full code or what.
Post 19 Dec 2017, 13:02
View user's profile Send private message Reply with quote
donn



Joined: 05 Mar 2010
Posts: 100

He probably meant the pgs from the link I posted. My docs are pretty old so the pages have changed for the same sections. I have the June 2015 version locally and thought it would be better to post a URL. Pages are now 622-3 and 633.

Sorry about that. Feel like I've been posting too much lately anyway... have FASM on the mind...!
Post 20 Dec 2017, 01:32
View user's profile Send private message Reply with quote
rugxulo



Joined: 09 Aug 2005
Posts: 2279
Location: Usono (aka, USA)

I'm not directly familiar with this myself, but beware that the HTT flag probably isn't what you think it is. I think it's the capability of SMP for your machine, not the current existence of it.

HTT Means Hyper-Threading, Right?
Post 20 Dec 2017, 22:31
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >

Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Main index   Download   Documentation   Examples   Message board
Copyright © 2004-2018, Tomasz Grysztar.
Powered by rwasa.