What is it about?

[next] [tail] [up]

### 5.1 What is it about?

Free Pascal supports the new MMX (Multi-Media extensions) instructions of Intel processors. The idea of MMX is to process multiple data with one instruction, for example the processor can add simultaneously 4 words. To implement this efficiently, the Pascal language needs to be extended. So Free Pascal allows to add for example two array[0..3] of word, if MMX support is switched on. The operation is done by the MMX unit and allows people without assembler knowledge to take advantage of the MMX extensions.

Here is an example:

uses
MMX; { include some predefined data types }
const
{ tmmxword = array[0..3] of word;, declared by unit MMX }
w1 : tmmxword = (111,123,432,4356);
w2 : tmmxword = (4213,63456,756,4);
var
w3 : tmmxword;
l : longint;
begin
if is_mmx_cpu then { is_mmx_cpu is exported from unit mmx }
begin
{$mmx+} { turn mmx on }
w3:=w1+w2;
{$mmx-}
end
else
begin
for i:=0 to 3 do
w3[i]:=w1[i]+w2[i];
end;
end.

[next] [front] [up]