       .TITLE .DD    COMPUTE ARCTANGENT FOR ARG IN FLOATING ACCUMULATOR
/ 
/ 
/                   FIRST PRINTING, FEBRUARY 1974
/ 
/ THE INFORMATION IN THIS DOCUMENT IS SUBJECT TO 
/ CHANGE WITHOUT NOTICE AND SHOULD NOT BE CONSTRUED
/ AS A COMMITMENT BY DIGITAL EQUIPMENT CORPORATION.
/ DIGITAL EQUIPMENT CORPORATION ASSUMES NO RESPON-
/ SIBILITY FOR ANY ERRORS THAT MAY APPEAR IN THIS
/ DOCUMENT.
/ 
/ THE SOFTWARE DESCRIBED IN THIS DOCUMENT IS FUR-
/ NISHED TO THE PURCHASER UNDER A LICENSE FOR USE ON
/ A SINGLE COMPUTER SYSTEM AND CAN BE COPIED (WITH
/ INCLUSION OF DIGITAL'S COPYRIGHT NOTICE) ONLY FOR 
/ USE IN SUCH SYSTEM, EXCEPT AS MAY OTHERWISE BE PRO-
/ VIDED IN WRITING BY DIGITAL.
/ 
/ DIGITAL EQUIPMENT CORPORATION ASSUMES NO RESPONSIBILITY
/ FOR THE USE OR RELIABILITY OF ITS SOFTWARE ON EQUIP-
/ MENT THAT IS NOT SUPPLIED BY DIGITAL.
/ 
/ COPYRIGHT (C) 1974, BY DIGITAL EQUIPMENT CORPORATION
/ 
/ 
        .EJECT
/COPYRIGHT 1970,1971,1973 DIGITAL EQUIPMENT CORP., MAYNARD, MASS. 01754
/FOR HARDWARE FLOATING POINT PROCESSOR (FPP), DEFINE %FPP,
/EDIT 6   1 JUNE 73
       .GLOBL .DD,.DC,.DB
	.IFUND %FPP
	.GLOBL .AA,.AB,.AV,.AU,.AP
	.GLOBL .AO,.AR,.AS,.AQ
	.GLOBL .AT
	.ENDC
	.IFUND %FPP
	.DEFIN DLD%,A
	JMS* A			/DOUBLE LOAD (.AO)
	.ENDM
	.ENDC
	.IFDEF %FPP
DLD=713150
	.DEFIN DLD%
	DLD
	.ENDM
	.ENDC
	.IFUND %FPP
	.DEFIN DSB%,A		/DOUBLE SUBTRACT (.AR)
	JMS* A
	.ENDM
	.ENDC
	.IFDEF %FPP
DSB=710540
	.DEFIN DSB%
	DSB
	.ENDM
	.ENDC
	.IFUND %FPP
	.DEFIN DMP%,A
	JMS* A			/DOUBLE MULTIPLY (.AS)
	.ENDM
	.ENDC
	.IFDEF %FPP
DMP=711540
	.DEFIN DMP%
	DMP
	.ENDM
	.ENDC
	.IFUND %FPP
	.DEFIN DAD%,A		/DOUBLE ADD (.AQ)
	JMS* A
	.ENDM
	.ENDC
	.IFDEF %FPP
DAD=716140
	.DEFIN DAD%
	DAD
	.ENDM
	.ENDC
	.IFUND %FPP
	.DEFIN UNDST%,A		/UNNORMALIZED
	JMS* A			/DOUBLE STORE (.AP)
	.ENDM
	.ENDC
	.IFDEF %FPP
UNDST=713770
	.DEFIN UNDST%
	UNDST
	.ENDM
	.ENDC
	.IFUND %FPP
	.DEFIN DRS%,A		/DOUBLE REVERSE SUBTRACT
	JMS* A			/(.AV)
	.ENDM
	.ENDC
	.IFDEF %FPP
DRS=711140
	.DEFIN DRS%
	DRS
	.ENDM
	.ENDC
	.IFUND %FPP
	.DEFIN DRD%,A		/DOUBLE REVERSE DIVIDE
	JMS* A			/(.AV)
	.ENDM
	.ENDC
	.IFDEF %FPP
DRD=712540
	.DEFIN DRD%
	DRD
	.ENDM
	.ENDC
	.IFUND %FPP
	.DEFIN DDV%,A		/DOUBLE DIVIDE (.AT)
	JMS* A
	.ENDM
	.ENDC
	.IFDEF %FPP
DDV=712140
	.DEFIN DDV%
	DDV
	.ENDM
	.ENDC
/             CALLING SEQUENCE          (DOUBLE PRECISION)
/      JMS*   (.DD)           SUBR CALL (ARG IN FLOAT ACC)
/      NEXT   INSTRUCTION     SUBR RETURN (RESULT IN FLOAT ACC)
/FPP INSTR. ASS.
	.IFDEF %FPP
FAB=713271		/MAKE FPP AC POS.
FCM=713273		/COMPL. FPP AC
	.ENDC
/
.DD    CAL    0              /ENTRY-EXIT
	.IFDEF %FPP
	UNDST		/STR.
	ARCT25
	LAC ARCT26
	DAC ARCT02
	FAB		/MAKE FPP AC
	0		/POS.
	LAC ARCT25
	DAC ARCT05
	.ENDC
	.IFUND	%FPP
       LAC*   .AB            /GET SIGN WORD (.AB)
       DAC    ARCT02         /SAVE AS ANS SIGN
       AND    ARCT03         /STRIP SIGN
       DAC*   .AB            /RESTORE IN (.AB)
       LAC*   .AA            /GET EXPONENT (.AA)
       DAC    ARCT05         /SAVE FOR LATER TEST
	.ENDC
       SNA!SPA               /IF EXP .GT. ZE96 (ARG .GT. 1) TAKE 1/ARG
       JMP    ARCT06         /OR SKIP TO POLY EVALUATE
       DRD%   .AV            /REVERSE DIVIDE DOUBLE (.AV)
       .DSA   ARCT08         / (1/ARG)
ARCT06	UNDST% .AP	/SAVE ARGUMENT
	.DSA ARCT20
	JMS* .DC	/POLYNOMIAL EVALUATE (.DC)
	.DSA ARCT11	/(FWA OF CALLING SEQUENCE)
	UNDST% .AP	/SAVE INTERMEDIATE ANGLE
	.DSA ARCT21
	JMS* .DB	/CALCULATE TANGENT OF INTERMEDIATE ANGLE
	UNDST% .AP	/TAN (A)=SIN (A)/SIN ((PI/2)-A)
	.DSA ARCT22
	DLD% .AO
	.DSA ARCT14
	DSB% .AR
	.DSA ARCT21
	JMS* .DB
	DRD% .AV
	.DSA ARCT22
	UNDST% .AP	/SAVE TANGENT OF INTERMEDIATE ANGLE
	.DSA ARCT22
	DMP% .AS	/CALCULATE CORRECTION ANGLE TO BRING
	.DSA ARCT20	/INTERMEDIATE ANGLE TO DESIRED ACCURACY
	DAD% .AQ	/C.A.=(ARG-TAN(A))/(1+ARG*TAN(A))
	.DSA ARCT08
	UNDST% .AP
	.DSA ARCT24
	DLD% .AO
	.DSA ARCT20
	DSB% .AR
	.DSA ARCT22
	DDV% .AT	/C.A. NOW IN FLOATING AC
	.DSA ARCT24
	DAD% .AQ	/ADD INTERMEDIATE ANGLE TO CORRECTION
	.DSA ARCT21	/ANGLE TO GET FINAL ANGLE
       LAC    ARCT05         /TEST ARG AGAIN IF .GT. 1 (EXP .GT. 0)
       SNA!SPA               / (EXP POSITIVE AND NON-ZERO)
       JMP    ARCT12         /IS NOT .GT. 1, SKIP
       DRS%   .AU            /REVERSE SUBTRACT DOUBLE (.AU)
       .DSA   ARCT14         / (PI/2-ANS)
ARCT12 LAC    ARCT02         /GET ORIGINAL SIGN WORD
	.IFDEF %FPP
	SPA
	FCM		/COMPL. FPP AC
	NOP		/FALL THRO
	.ENDC
	.IFUND %FPP
       AND    ARCT09         /KEEP B0 ONLY
       XOR*   .AB            /SET SIGN WORD WITH NEW SIGN (.AB)
	SAD ARCT09		/CHECK FOR -0.0 CASE
	CLA		/YES.  MAKE -0.0 A 0.0
       DAC*   .AB            /RESTORE SIGN WORD (.AB)
	.ENDC
       JMP*   .DD            /EXIT
ARCT02 CAL    0              /ANS SIGN
ARCT03        377777
ARCT05 CAL    0              /EXP STORAGE
ARCT08        1              /FLOATING 1 (1)
              200000         /           (2)
              0              /           (3)
ARCT09        400000
ARCT14        1              / PI/2 (1)  (1.57079632679)
              311037         /      (2)
              552421         /      (3)
	.IFDEF %FPP
ARCT25	0		/TEMP STOR.
ARCT26	0		/FOR FPP AC
	0
	.ENDC
ARCT20 .BLOCK 3         /TEMP STORAGE
ARCT21 .BLOCK 3
ARCT22 .BLOCK 3
ARCT24 .BLOCK 3
ARCT11        777775         / -N+1 (NO OF COEFFICIENTS) (4)
       777774; 637556; 023444 /-0.389929D-1
       777776; 225623; 041646 /0.1462766D0
       777777; 644343; 720712 /-0.3211819D0
       000000; 377631; 067426 /0.9992150D0
       .END
