       .TITLE .EF    COMPUTE NATURAL EXPONENTIAL (**ARG) (SINGLE PREC)
/ 
/ 
/                   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 1972, DIGITAL EQUIPMENT CORP., MAYNARD, MASS. 01754
/EDIT #008  12-1-71
/FOR HARDWARE FLOATING POINT PROCESSOR (FPP), DEFINE %FPP,
	.GLOBL .EF,.AX,.ER,.AW
	.IFUND %FPP
	.GLOBL .AA,.AB,.AK,.AN,.AH
	.GLOBL .AM,.AG,.AI
	.ENDC
	.IFUND %FPP
	.DEFIN FRS%,A		/FLOATING REVERSE SUBTRACT
	JMS* A			/(.AM)
	.ENDM
	.ENDC
	.IFDEF %FPP
FRS=711040
	.DEFIN FRS%
	FRS
	.ENDM
	.ENDC
	.IFUND %FPP
	.DEFIN FLD%,A		/FLOATING LOAD (.AG)
	JMS* A
	.ENDM
	.ENDC
	.IFDEF %FPP
FLD=713050
	.DEFIN FLD%
	FLD
	.ENDM
	.ENDC
	.IFUND %FPP
	.DEFIN FRD%,A		/FLOATING REVERSE DIVIDE
	JMS* A			/(.AN)
	.ENDM
	.ENDC
	.IFDEF %FPP
FRD=712440
	.DEFIN FRD%
	FRD
	.ENDM
	.ENDC
	.IFUND %FPP
	.DEFIN FAD%,A		/FLOATING ADD (.AI)
	JMS* A
	.ENDM
	.ENDC
	.IFDEF %FPP
FAD=716040
	.DEFIN FAD%
	FAD
	.ENDM
	.ENDC
	.IFUND %FPP
	.DEFIN FST%,A		/FLOATING STORE (.AH)
	JMS* A
	.ENDM
	.ENDC
	.IFDEF %FPP
FST=713640
	.DEFIN FST%
	FST
	.ENDM
	.ENDC
	.IFUND %FPP
	.DEFIN FMP%,A
	JMS* A			/FLOATING MULTIPLY (.AK)
	.ENDM
	.ENDC
	.IFDEF %FPP
FMP=711440
	.DEFIN FMP%
	FMP
	.ENDM
	.ENDC
/             CALLING SEQUENCE
/      JMS*   (.EF)           SUBR CALL (ARG IN FLOATING ACC)
/      NEXT   INSTRUCTION     SUBR RETURN (RESULT IN FLOATING ACC)
/FPP INSTR. ASS.
	.IFDEF %FPP
BPA=716604			/BR ON POS. FPP AC
FAB=713271			/MAKE FPP AC POS.
URFST=713650		/UNRD. FLT. STORE
UNFLD=713070		/UNN. FLT. LOAD
	.ENDC
/
.EF    CAL    0              /ENTRY-EXIT
	.IFDEF %FPP
	BPA
	EF22
	CLC			/NEG
	DAC EF09
EF22	FAB
	0			/NOT USED
	.ENDC
	.IFUND %FPP
       LAC*   .AB            /GET SIGN WORD (.AB)
       DAC    EF09           /SAVE SIGN OF ARG
       AND    (377777)       /MAKE FAC POSITIVE
       DAC*   .AB
	.ENDC
       FMP%   .AK            /MULTIPLY REAL (.AK)
       .DSA   EF02           / (ARG * LOG2(E))
       FST%   .AH            /STORE REAL (.AH)
       .DSA   EF04           / (TEMP)
       JMS*   .AX            /FIX (.AX)
       DAC    EF06           /STORE INTEGER AS ANSWER EXP
	TAD	(-377		/IF EXPONENT OVERFLOWS,
	SMA
	SKP			/SET EXPONENT IN FLOAT AC
	JMP	NORMAL
	.IFUND %FPP
	LAC	(440		/TO OVERFLOW VALUE
	DAC*	.AA
	.ENDC
	.IFDEF %FPP
	FLD% .AG
	.DSA OVERFL
	FMP% .AK
	.DSA	OVERFL
	.ENDC
	JMP	RECIP		/AND EXIT
NORMAL	LAC	EF06
	ISZ	EF06		/BUMP EXPONENT FOR .5 SCALING
       JMS*   .AW            /FLOAT INTEGER (.AW)
       FRS%   .AM            /REVERSE SUBTRACT REAL (.AM)
       .DSA   EF04           / (TEMP-ACC) FRACTION ONLY (F)
       FST%   .AH            /STORE REAL (.AH)
       .DSA   EF04           / (F) INTO TEMP
	LAC	EF06
	TAD	(-400
	SPA
	JMP	.+3
	LAC	(400000
	DAC	EF06
       LAW    -6             /SET ITERATION COUNT FOR 7 TERMS
       DAC    EF11           /STORE COUNTER
       LAC    EF21           /GET ADDR OF C7
       DAC    EF14           /STORE INTO POINTER
       FLD%   .AG            /LOAD REAL (.AG)
       .DSA   EF20           / (C7 AS TERM)
EF12   FMP%   .AK            /MULTIPLY REAL (.AK)
       .DSA   EF04           / ((F) * TERM)
EF13   ISZ    EF14           /BUMP POINTER TO NEXT C
       ISZ    EF14
       FAD%   .AI            /ADD REAL
       .DSA   EF14+400000    / (C + (F + TERM) AS TERM
       ISZ    EF11           /CNTR = CNTR + 1
       JMP    EF12           /CYCLE
	.IFDEF %FPP
	URFST		/COUNTER RD. UP ERROR IN LOOP
	EF04
	UNFLD		/RELOAD FPP AC TO RID LOW ORDER BITS
	EF04		/HARD. WARE SHOULD DO IT ON URFST!!!,BUT DOESN'T
	.ENDC
	.IFUND %FPP
	JMS* .AH		/STORE TEMP.
	EF04
	.ENDC
       FMP%   .AK            /MULTIPLY REAL (.AK)
       .DSA   EF04           / (RESULT * RESULT = RESULT**2)
       FMP%   .AK            /MULTIPLY REAL
       .DSA   EF06           /(EXPONENT * FINAL RESULT)
RECIP	LAC	EF09		/IF ARG WAS NEGATIVE,
	.IFDEF %FPP
	DZM EF09
	.ENDC
	SMA			/TAKE RECIPROCAL OF
       JMP*   .EF            /ANSWER BEFORE EXIT
       FRD%   .AN
       .DSA   EF21-2
       JMP*   .EF
EF09   .DSA   0
EF04   CAL    0              /TEMP (1)
       CAL    0              /     (2)
EF06   CAL    0              /ANS EXP
              200000         /EXP STORAGE (2)
EF11   CAL    0              /CNTR
EF14   CAL    0              /PTR
EF02   .DSA   355001	/LOG2(E) (1) (+1.442695041E0)
       .DSA   270524	/ (2)
EF20          760756         /C7 (1)  ( 0.241E-5)
              241566         /   (2)
              512762         /C6 (1)  ( 0.4167E-4)
              256615         /   (2)
              233766         /C5 (1)  ( 0.60113E-3)
              235452         /   (2)
              374771         /C4 (1)  ( 0.693801E-2)
              343260         /   (2)
              703774         /C3 (1)  ( 0.06005663)
              365773         /   (2)
              140777         /C2 (1)  ( 0.34657359)
              261344         /   (2)
              1              /C1 (1)  ( 1.0)
              200000         /   (2)
EF21   .DSA   EF20           /ADDR OF C7
OVERFL	.DSA	777377
	.DSA	377777
       .END
