MMX CPU detection

For everything that's not in any way related to PureBasic. General chat etc...
Denis
Enthusiast
Enthusiast
Posts: 779
Joined: Fri Apr 25, 2003 5:10 pm
Location: Doubs - France

MMX CPU detection

Post 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
A+
Denis
El_Choni
TailBite Expert
TailBite Expert
Posts: 1007
Joined: Fri Apr 25, 2003 6:09 pm
Location: Spain

Post 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.
El_Choni
Denis
Enthusiast
Enthusiast
Posts: 779
Joined: Fri Apr 25, 2003 5:10 pm
Location: Doubs - France

Post by Denis »

Hi El_Choni,

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


Denis
A+
Denis
va!n
Addict
Addict
Posts: 1104
Joined: Wed Apr 20, 2005 12:48 pm

Post 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
va!n aka Thorsten

Intel i7-980X Extreme Edition, 12 GB DDR3, Radeon 5870 2GB, Windows7 x64,
Post Reply