Jump to content
Welcome, welcome! Come in and register, and have some developer coffee. 👨‍💻 ×

A message box to display processor name


Recommended Posts

According to AMD CPUID technical specification, a processor name is 48 characters long.

CPU.PNG.394d58a313a5f7148fa12a7e7526287d.PNG

Again , I give away the Assembly source code for free (as long as you retain my copyright notice)

; Processor Name
;
; CPUNAME.ASM
; Copyright (C) 2021 Boo Khan Ming
;
; MIT license apply
;
format PE GUI 4.0
entry start

include 'win32a.inc'

section '.data' readable writable

        _caption        db 'Processor Name',0
        _cpuid1         dd ?
        _cpuid2         dd ?
        _cpuid3         dd ?
        _cpuid4         dd ?
        _counter        dd ?
        _offset         dd ?
        _func           dd 80000002h

section '.code' code readable writable executable

        _name           rb 48
        _null           db 0

start:
        mov     dword [_counter],0

.loop:
        mov     eax, dword [_func]
        cpuid
        mov     dword [_cpuid1],eax
        mov     dword [_cpuid2],ebx
        mov     dword [_cpuid3],ecx
        mov     dword [_cpuid4],edx

        mov     ecx, dword [_counter]
        xor     eax,eax
        mov     ebx,dword [_cpuid1]
.redo1:
        push    ebx
        and     ebx,000000ffh
        mov     byte [_name + ecx + eax], bl
        pop     ebx
        shr     ebx,8
        inc     eax
        cmp     eax,4
        jne      .redo1

        mov     ebx,dword [_cpuid2]
.redo2:
        push    ebx
        and     ebx,000000ffh
        mov     byte [_name + ecx + eax], bl
        pop     ebx
        shr     ebx,8
        inc     eax
        cmp     eax,8
        jne      .redo2

        mov     ebx,dword [_cpuid3]
.redo3:
        push    ebx
        and     ebx,000000ffh
        mov     byte [_name + ecx + eax], bl
        pop     ebx
        shr     ebx,8
        inc     eax
        cmp     eax,12
        jne      .redo3

        mov     ebx,dword [_cpuid4]
.redo4:
        push    ebx
        and     ebx,000000ffh
        mov     byte [_name + ecx + eax], bl
        pop     ebx
        shr     ebx,8
        inc     eax
        cmp     eax,16
        jne      .redo4

        add     dword [_func],1
        cmp     dword [_func], 80000005h
        je      show
        add     dword [_counter],16
        jmp     .loop

show:
        ;mov     byte [_name + 48],0
        push    0x40
        push    _caption
        push    _name
        push    0
        call    [MessageBox]

        push    0
        call    [ExitProcess]

section '.idata' import readable writable

       library kernel,'KERNEL32.DLL',\
               user,'USER32.DLL'

       import kernel,\
              ExitProcess,'ExitProcess'

       import user,\
              MessageBox,'MessageBoxA'

When you run the CPUNAME.exe (attached in CPUNAME.zip below), it will displays the processor name:

CPUID.PNG.8ec03b76ec83f5be17902599ca65f5d1.PNG

 

Please sign in to download the tiny Windows executable, Assembly source file is also included as part of the package.

MIT license apply.

 

 

CPUNAME.zip

Link to post
Share on other sites

This is a shorter and better version:

 

; Processor Name v3
;
; CPUNAME.ASM
; Copyright (C) 2021 Boo Khan Ming
;
; MIT license apply
;
format PE GUI 4.0
entry start

include 'win32a.inc'

section '.data' readable writable

        _caption        db 'Processor Name',0

section '.code' code readable writable executable

        _name           rb 48

start:
        mov     eax, 0x80000002
        cpuid
        mov     dword [_name], eax
        mov     dword [_name + 4], ebx
        mov     dword [_name + 8], ecx
        mov     dword [_name + 12], edx
        mov     eax, 0x80000003
        cpuid
        mov     dword [_name + 16], eax
        mov     dword [_name + 20], ebx
        mov     dword [_name + 24], ecx
        mov     dword [_name + 28], edx
        mov     eax, 0x80000004
        cpuid
        mov     dword [_name + 32], eax
        mov     dword [_name + 36], ebx
        mov     dword [_name + 40], ecx
        mov     dword [_name + 44], edx

.show:
        push    0x40
        push    _caption
        push    _name
        push    0
        call    [MessageBox]

        push    0
        call    [ExitProcess]

section '.idata' import readable writable

       library kernel,'KERNEL32.DLL',\
               user,'USER32.DLL'

       import kernel,\
              ExitProcess,'ExitProcess'

       import user,\
              MessageBox,'MessageBoxA'

 

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...