×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Detecting an MMX processor

Detecting an MMX processor

Detecting an MMX processor

(OP)
Hello,

I'm programming a program in Turbo Pascal and would like to be able to tell whether the processor being used has support for MMX.

I understood this needs to be done in Assembley.

I hereby ask anyone who has the knowledge to tell me how to do that. I know little in ASM, and would very much appreciate it if someone could give me the code to detect it.

I understood this needs to be done using the CPU identity registers(!?).

Any help would be greatly appreciated!

RE: Detecting an MMX processor

Use 'CPUID' something like:

pushfd
pop eax
and eax,0200000h
je noCPUID
mov eax,01h
cpuid
and edx,0800000h
je noMMX

to get full benifit download manual volume 2 (located in FAQ) and view pages 153-166. Here you can see full usage of mnemonic. CPUID returns alot more information!

This command will only work if available. You need to examine bit 021h in the eflags register. If hard coded to ON then you can use CPUID.

to get full benifit download manual volume 2 (located in FAQ) and view pages 153-166. Here you can see full usage of mnemonic.

Straiph

"People who have nothing to say, say it too loud and have little knowledge. It's the quiet ones you need to worry about!"

RE: Detecting an MMX processor

I was aware that there are few people here but now I'm getting an echo!

I was aware that there are few people here but now I'm getting an echo!

PS: about the manuals, I swear by them, if fact I swear at them all the time!

"People who have nothing to say, say it too loud and have little knowledge. It's the quiet ones you need to worry about!"

RE: Detecting an MMX processor

ID flag is bit 21 decimal, 21h would be bit 33.
In the (currently available) 2002 edition, CPUID is discussed on page 3-113 (PDF: page 155).

Regards,
Bert Vingerhoets
vingerhoetsbert@hotmail.com
http://student.vub.ac.be/~bvingerh/
Don't worry what people think about you. They're too busy wondering what you think about them.

RE: Detecting an MMX processor

yes, it should read 21 and not 021h.

"People who have nothing to say, say it too loud and have little knowledge. It's the quiet ones you need to worry about!"

RE: Detecting an MMX processor

(OP)
I could not find the document you are referring to.

However, I found a much easier way, if I know the family ID of the processor - I'll know whether it supports MMX or not.

Does anyone happen to know (or tell me where to see) what bits in what register have the family ID info?

I know how to detect the processor generation, and as I know:

Generations 0-4 : no MMX (old processors, of course).
Generation 5: only on 2 families (Pentium MMX, and CyrixMMX)
Generation 6: all of them besides families 0+1 (pentium pro)


Thanks

RE: Detecting an MMX processor

(OP)
Ignore my last post, that work around doesn't work - some non-MMX and MMX-compatible processors share the same values (such as Pentium Pro and AMD Athlon).

What I found out is that when I call the CPUID instruction with AX = 1 then the 23rd bit in EDX is the MMX flag (0=no mmx, 1=mmx supported).

But I'm programming in Turbo Pascal and the program won't let me access EDX (only DX), and I need the bits with the higher values for that matter.

Is there any workaround, in Pascal or ASM to access that 23rd bit of EDX, without being able to call that register (only the 16bit reg's are available)?

RE: Detecting an MMX processor

Although it's a language for 16 bit DOS, you can do everything in Turbo Pascal, even using 32 bit registers.
Try to find a 32 bit version of debug (the 16 bit version comes with DOS) or mail me if you want it. In this tool, you can type any 32 bit instruction and get the hexadecimal machine code equivalent. This hexadecimal number can be inserted in your Pascal source using the reserved function inline.
Example (to store EFLAGS in a Pascal longint):
VAR eflags : longint;
    s,o : word;

BEGIN
  s:=seg(eflags); {get segment part of eflags}
  o:=ofs(eflags); {get offset part of eflags}
  asm {use inline assembler}
    MOV  ES,s
    MOV  DI,o
  end; {ES:DI -> eflags}
  inline($66/$9C/         {PUSHFD}
         $66/$58/         {POP EAX}
         $26/$66/$89/$05) {MOV [ES:DI],EAX}
END.

Note that an invalid opcode error will occur when using this routine on a 80286 or older.

Regards,
Bert Vingerhoets
vingerhoetsbert@hotmail.com
http://student.vub.ac.be/~bvingerh/
Don't worry what people think about you. They're too busy wondering what you think about them.

RE: Detecting an MMX processor

If you can only pass 16bit registers then as a work-a-round and if you are not interested in the values of other registers you can get the high-order word by doing the following in your assembly:

push edx
pop dx
pop ax

now within pascal you can access the whole 32bit register value of edx.
Also there are plenty of free 32bit assemblers to download. You can get both TASM for dos and NASM for free just search the net for these names.

Cant you define eregs in pascal? I'll have to check!

The manual: there are 3 FAQ here last time I looked, its the technical references one! The link inside takes you to the Intel website where you can download 3 manuals for program assembly. download number 2 and find CPUID.

"People who have nothing to say, say it too loud and have little knowledge. It's the quiet ones you need to worry about!"

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close