Page 1 of 1
CPUID ALL in ASM
Posted: Mon Jan 21, 2008 12:47 am
by michaeled314
Code: Select all
CPUName.s = Space(12)
pCPUName.l = @CPUName
FPU.l
VME.l
!XOR eax,eax
!CPUID
MOV eax,pCPUName
MOV [eax],ebx
MOV [eax+4],edx
MOV [eax+8],ecx
MOV CPUName,eax
MOV eax,1
!CPUID
BT eax,0
ADC FPU,0
BT eax,1
ADC VME,0

Posted: Mon Jan 21, 2008 11:28 am
by Blue
Nice work.
Thanks for passing it on.
Posted: Mon Jan 21, 2008 8:44 pm
by superadnim
Well I tried to make it work but somethings wrong with it:
Code: Select all
CPUName.s = Space(12)
pCPUName.l = @CPUName
FPU.l
VME.l
!XOR eax,eax
!CPUID
!MOV eax,[v_pCPUName]
!MOV [eax],ebx
!MOV [eax+4],edx
!MOV [eax+8],ecx
!MOV [v_CPUName],eax
!MOV eax,1
!CPUID
!BT eax,0
!ADC [v_FPU],0
!BT eax,1
!ADC [v_VME],0
Debug CPUName
Debug FPU
Debug VME
Posted: Mon Jan 21, 2008 9:23 pm
by LuCiFeR[SD]
Code: Select all
Procedure.s GetCPUName()
Protected Buffer.s
Protected Pointer1.l, Pointer2.l, Pointer3.l, Pointer4.l
!MOV eax, $80000002
!CPUID
!MOV [p.v_Pointer1], EAX
!MOV [p.v_Pointer2], EBX
!MOV [p.v_Pointer3], ECX
!MOV [p.v_Pointer4], EDX
Buffer = PeekS(@Pointer1, 4, #PB_Ascii)
Buffer + PeekS(@Pointer2, 4, #PB_Ascii)
Buffer + PeekS(@Pointer3, 4, #PB_Ascii)
Buffer + PeekS(@Pointer4, 4, #PB_Ascii)
!MOV eax, $80000003
!CPUID
!MOV [p.v_Pointer1], EAX
!MOV [p.v_Pointer2], EBX
!MOV [p.v_Pointer3], ECX
!MOV [p.v_Pointer4], EDX
Buffer + PeekS(@Pointer1, 4, #PB_Ascii)
Buffer + PeekS(@Pointer2, 4, #PB_Ascii)
Buffer + PeekS(@Pointer3, 4, #PB_Ascii)
Buffer + PeekS(@Pointer4, 4, #PB_Ascii)
!MOV eax, $80000004
!CPUID
!MOV [p.v_Pointer1], EAX
!MOV [p.v_Pointer2], EBX
!MOV [p.v_Pointer3], ECX
!MOV [p.v_Pointer4], EDX
Buffer + PeekS(@Pointer1, 4, #PB_Ascii)
Buffer + PeekS(@Pointer2, 4, #PB_Ascii)
Buffer + PeekS(@Pointer3, 4, #PB_Ascii)
Buffer + PeekS(@Pointer4, 4, #PB_Ascii)
ProcedureReturn Buffer
EndProcedure
Debug GetCPUName()
I cant remember where the hell I came accross this bit of code.... maybe purearea? Either way, does the job.
Posted: Tue Jan 22, 2008 11:39 am
by superadnim
yep thanks, although it looks quite messy to be frank with you

Posted: Tue Jan 22, 2008 3:07 pm
by LuCiFeR[SD]
LOL, yeah, it is a little messy. Lets see what can be done about that

Posted: Wed Jan 23, 2008 8:42 pm
by Thunder93
Nice...!
Though using LuCiFeR[SD] code, the CPU Specification retrieved and not the actual CPU name.

Posted: Thu Jan 24, 2008 11:56 am
by breeze4me
Posted: Thu Jan 24, 2008 2:50 pm
by superadnim
yes, the actual x86 reference manual hosts a whopping 29 pages dedicated to this instruction only... I got lost at the second one

Posted: Thu Jan 31, 2008 4:14 pm
by Shardik
LuCiFeR[SD] wrote:
I cant remember where the hell I came accross this bit of code.... maybe purearea?
The original posting was from ts-soft:
http://www.purebasic.fr/english/viewtop ... 29&start=3
Another ASM code example from the German forum by Helle:
http://www.purebasic.fr/german/viewtopic.php?t=13408
and
http://www.purebasic.fr/german/viewtopi ... 08&start=4 (returns unicode string)