MODULE TRAN9511;

EXTERNAL PROCEDURE @ERR(AN_ERROR:BOOLEAN; ERRNUM:INTEGER);


EXTERNAL PROCEDURE @AMD(FUNC:INTEGER;VAR ARG:REAL;VAR STATUS:INTEGER);
{THE PROCEDURE @AMD,INTERFACES TO THE AMD9511 ARITHMETIC PROCESSING UNIT (APU).
THE FIRST ARGUMENT IS THE FUNCTION CODE (AND IS STRAIGHT FROM 
THE AM9511 LITERATURE).  THE SECOND IS THE ADDRESS OF ARG, A
REAL VARIABLE, THE FUNTION ARGUMENT IS IN ARG, AND THE RESULT 
IS RETURNED IN ARG.  THE THIRD ARGUMENT IS THE ADDRESS WHERE 
THE APU STATUS IS RETURNED.}

FUNCTION SIN(ARG:REAL):REAL; {SINE FUNCTION}
VAR	STATUS:INTEGER;
BEGIN
	@AMD($02,ARG,STATUS);
	SIN:=ARG;
END;

FUNCTION COS(ARG:REAL):REAL; {COSINE FUNCTION}
VAR	STATUS:INTEGER;
BEGIN
	@AMD($03,ARG,STATUS);
	COS:=ARG;
END;


FUNCTION EXP(ARG:REAL):REAL; {E TO THE X FUNCTION}
VAR	STATUS:INTEGER;
BEGIN
	@AMD($0A,ARG,STATUS);
	IF (STATUS & $1E) = $18 THEN BEGIN
	  @ERR(TRUE,7);	(* TRANCENDENTAL OUT OF RANGE *)
	END;
	EXP:=ARG;
END;

FUNCTION LN(ARG:REAL):REAL; {NATURAL LOGARITHM FUNCTION}
VAR	STATUS:INTEGER;
BEGIN
	@AMD($09,ARG,STATUS);
	IF (STATUS & $1E) = $8 THEN BEGIN
	  @ERR(TRUE,7);
	END;
	LN:=ARG;
END;

FUNCTION ARCTAN(ARG:REAL):REAL; {INVERSE TANGENT FUNCTION}
VAR	STATUS:INTEGER;
BEGIN
	@AMD($07,ARG,STATUS);
	ARCTAN:=ARG;
END;

MODEND.
