Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Detecting an MMX processor

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
0
0
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!
 
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!"
 
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!"
 
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
Don't worry what people think about you. They're too busy wondering what you think about them.
 
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!"
 
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
 
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)?
 
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):
Code:
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
Don't worry what people think about you. They're too busy wondering what you think about them.
 
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!"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top