Page 1 of 1

MMX CPU detection

Posted: Mon May 26, 2003 10:51 am
by Denis
Hi All,

I'm not a WIndows OS specialist nor CPU of the family 80x86.. .
I'm looking for a way to detect (with running code, not when PB is compiling) if the CPU has MMX instruction set and then use functions with MMX instructions or not from own libs.


Thanks for help.


Denis

Posted: Mon May 26, 2003 11:25 am
by El_Choni
Check this:

Code: Select all

Procedure IsMMXSupported() ; Returns 8388608 if supported, 0 if not supported
  result = 0
  XOR EDX, EDX        ; Set edx to 0 just in case CPUID is disabled, not to get wrong results
  MOV eax, 1          ; CPUID level 1
  !CPUID              ; EDX = feature flag 
  AND edx, $800000    ; test bit 23 of feature flag
  MOV result, edx     ; <>0 If MMX is supported
  ProcedureReturn result
EndProcedure
The code is not mine, I found it at:

http://board.win32asmcommunity.net/show ... eadid=1010

Here's some more info about CPUID:

http://www.sandpile.org/ia32/cpuid.htm

Hope it helps, bye.

Posted: Mon May 26, 2003 12:41 pm
by Denis
Hi El_Choni,

Many many thanks for your answer. :D :D
I will try it soon.


Denis

Posted: Wed Sep 07, 2005 11:51 am
by va!n
hi el_choni!
nice codesnip! i have modified your version a little bit... i hope my version works fine too!? maybe some ppl can give their feedback..

Code: Select all

Procedure TestMMX()
 result = 0
 MOV    eax, 1               
 !cpuid                       
 MOV    eax, edx           
 SHR    eax, 23              
 And    eax, 1                   
 MOV result, eax
 ProcedureReturn result
EndProcedure

Debug TestMMX()
i found it at http://www.programmersheaven.com/2/mmx