fpc/docs/mmx.tex
1998-03-30 16:01:34 +00:00

93 lines
3.0 KiB
TeX

%
% $Id$
% This file is part of the FPC documentation.
% Copyright (C) 1997, by Michael Van Canneyt
%
% The FPC documentation is free text; you can redistribute it and/or
% modify it under the terms of the GNU Library General Public License as
% published by the Free Software Foundation; either version 2 of the
% License, or (at your option) any later version.
%
% The FPC Documentation is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
% Library General Public License for more details.
%
% You should have received a copy of the GNU Library General Public
% License along with the FPC documentation; see the file COPYING.LIB. If not,
% write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
% Boston, MA 02111-1307, USA.
%
\chapter{The MMX unit}
This chapter describes the \file{MMX} unit. This unit allows you to use the
\var{MMX} capabilities of the \fpc compiler. It was written by Florian
Kl\"ampfl for the \var{I386} processor.
\section{Variables, Types and constants}
The following types are defined in the \var{MMX} unit:
\begin{verbatim}
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;
\end{verbatim}
And the following pointers to the above types:
\begin{verbatim}
pmmxshortint = ^tmmxshortint;
pmmxbyte = ^tmmxbyte;
pmmxword = ^tmmxword;
pmmxinteger = ^tmmxinteger;
pmmxfixed = ^tmmxfixed;
pmmxlongint = ^tmmxlongint;
pmmxcardinal = ^tmmxcardinal;
{ for the AMD 3D }
pmmxsingle = ^tmmxsingle;
\end{verbatim}
The following initialized constants allow you to determine if the computer
has \var{MMX} extensions. They are set correctly in the unit's
initialization code.
\begin{verbatim}
is_mmx_cpu : boolean = false;
is_amd_3d_cpu : boolean = false;
\end{verbatim}
\section{Functions and Procedures}
\Procedure{Emms}
{\var{Emms} sets all floating point registers to empty. This procedure must
be called after you have used any \var{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.
}
{None.}
{ \progref }
\begin{FPCList}
\item[Example:]
\begin{verbatim}
Program MMXDemo;
uses mmx;
var
d1 : double;
a : array[0..10000] of double;
i : longint;
begin
d1:=1.0;
{$mmx+}
{ 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 }
{$mmx-}
emms; { clear fpu }
{ now we can do floating point arithmetic again }
end.
\end{verbatim}
\end{FPCList}