%
%   $Id: emu387.tex,v 1.1 2000/07/13 09:10:03 michael Exp $
%   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 EMU387 unit}
The \file{emu387} unit was written by Pierre M\"uller for \dos. It
sets up the coprocessor emulation for FPC under \dos. It is not necessary to
use this unit on other OS platforms because they either simply do not run on 
a machine without coprocessor, or they provide the coprocessor emulation 
themselves.

It shouldn't be necessary to use the function in this unit, it should be
enough to place this unit in the \var{uses} clause of your program to
enable the coprocessor emulation under \dos. The unit initialization
code will try and load the coprocessor emulation code and initialize it.

\section{Functions and procedures}
\begin{function}{npxsetup}
\Declaration
procedure npxsetup(prog\_name : string);
\Description
\var{npxsetup} checks whether a coprocessor is found. If not, it loads the 
file \file{wmemu387.dxe} into memory and initializes the code in it.

If the environment variable \var{387} is set to \var{N}, then the emulation
will be loaded, even if there is a coprocessor present. If the variable
doesn't exist, or is set to any other value, the unit will try to detect 
the presence of a coprocessor unit.

The function searches the file \file{wmemu387.dxe} in the following way:
\begin{enumerate}
\item If the environment variable \var{EMU387} is set, then it is assumed
to point at the \file{wmemu387.dxe} file.
\item if the environment variable \var{EMU387} does not exist, then the 
function will take the path part of  \var{prog\_name} and look in that
directory for the file \file{wmemu387.dxe}.
\end{enumerate}

It should never be necessary to call this function, because the
initialization code of the unit contains a call to the function with
as an argument \var{paramstr(0)}. This means that you should deliver the
file \var{wmemu387.dxe} together with your program.
\Errors
If there is an error, an error message is printed to standard error, and
the program is halted, since any floating-point code is bound to fail anyhow.
\end{function}
