13. The MMX unit

This chapter describes the MMX unit. This unit allows you to use the MMX capabilities of the Free Pascalcompiler. It was written by Florian Klämpfl for the I386 processor. It should work on all platforms that use the Intel processor.

13.1 Variables, Types and constants

The following types are defined in the MMX unit:
tmmxshortint = array[0..7] of shortint;
tmmxbyte = array[0..7] of byte;
tmmxword = array[0..3] of word;
tmmxinteger = array[0..3] of integer;
tmmxfixed = array[0..3] of fixed16;
tmmxlongint = array[0..1] of longint;
tmmxcardinal = array[0..1] of cardinal;
{ for the AMD 3D }
tmmxsingle = array[0..1] of single;
And the following pointers to the above types:
pmmxshortint = ^tmmxshortint;
pmmxbyte = ^tmmxbyte;
pmmxword = ^tmmxword;
pmmxinteger = ^tmmxinteger;
pmmxfixed = ^tmmxfixed;
pmmxlongint = ^tmmxlongint;
pmmxcardinal = ^tmmxcardinal;
{ for the AMD 3D }
pmmxsingle = ^tmmxsingle;
The following initialized constants allow you to determine if the computer has MMX extensions. They are set correctly in the unit's initialization code.
is_mmx_cpu : boolean = false;
is_amd_3d_cpu : boolean = false;

13.2 Functions and Procedures

13.2.1 Emms

Procedure Emms ;

Emms sets all floating point registers to empty. This procedure must be called after you have used any MMX instructions, if you want to use floating point arithmetic. If you just want to move floating point data around, it isn't necessary to call this function, the compiler doesn't use the FPU registers when moving data. Only when doing calculations, you should use this function.

See also
Programmers' guide
Program MMXDemo;
uses mmx;
   d1 : double;
   a : array[0..10000] of double;
   i : longint;
   { floating point data is used, but we do _no_ arithmetic }
   for i:=0 to 10000 do
     a[i]:=d2;  { this is done with 64 bit moves }
   emms;   { clear fpu }
   { now we can do floating point arithmetic again }