/ 
/ 
/                   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 1971, 1973 DIGITAL EQUIPMENT CORP., MAYNARD MASS
/EDIT #010, 8 JAN 73  T.A.M.
/           5-24-71  *REF*
	.TITLE	.BD	/DOUBLE PREC BASE(A) TO INT (AND DBL INT) POWERS(B)
/CALLING SEQUENCE:
/SINGLE INTEGER POWER
/	JMS* .BD	BASE IN FAC(FPP AC))
/	ADDR		ADDR OF B(XCT ADDR IF INDIRECT)
/	NEXT INSTR.	SUBR. RETURN(RESULT IN FAC(FPP AC))
/DOUBLE(EXTENDED) INTEGER POWER
/	JMS* .BM	BASE IN FAC(FPP AC)
/	ADDR		ADDR OF B(XCT ADDR IF INDIRECT)
/	NEXT INSTR.	SUBR. REUTRN(RESULT IN FAC(FPP AC))
	.DEFIN	FOPDEF,NAME,SUBR,INST
	.IFDEF	%FPP
	.DEFIN	NAME
	INST
	.ENDM
	.ENDC
	.IFUND	%FPP
	.GLOBL	SUBR
	.DEFIN	NAME
	JMS*	SUBR
	.ENDM
	.ENDC
	.ENDM
	.GLOBL	.BD,.BM
	FOPDEF	DLD%,.AO,713150
	FOPDEF	UNDST%,.AP,713770
	FOPDEF	DMP%,.AS,711540
	FOPDEF	DDV%,.AT,712140
/
.BD	CAL	0		/D**I
	LAC	.BD
	CLL		/INDICATE EXPONENT IS INTEGER
	JMP	.+4
.BM	CAL	0		/D**J
	CLL!CML		/INDICATE EXPONENT IS D.I.
	LAC	.BM
	DAC	R	/SAVE RETURN ADDRESS
	LAC*	R
	DAC	A
	SPA
	LAC*	A
	DAC	A
	LAC*	A	/GET HIGH ORDER EXP
	ISZ	R
	DAC	E1
	ISZ	A
	SZL		/AVIOD GETTING 2ND WORD IF NOT D.I.-MAY CAUSE NEXM
	LAC*	A
	LMQ		/LOW ORDER EXP INTO MQ
	LAC	E1
	SNL		/IF EXPONENT IS AN INTEGER,
	LRSS	22	/MAKE IT A DOUBLE INTEGER
	SMA!CLL
	JMP	.+3
	CMQ		/IF EXP NEGATIVE, SET IT POSITIVE
	CMA!CML
	DAC	E1	/THIS IS, WITHOUT A DOUBT
	LACQ
	DAC	E2	/THE UGLIEST ROUTINE TO DO A TWO'S COMPLEMENT
	SZL
	ISZ	E2	/THAT I HAVE EVER WRITTEN.
	SKP
	ISZ	E1
	NOP		/THE DREADFUL DEED IS DONE!
	GLK
	DAC	MDIV	/LINK BECOMES MULTIPLY/DIVIDE FLAG
	UNDST%
	.DSA	BASE
	DLD%
	.DSA	ONE	/INITIALIZE RESULT TO 1
.BLOOP	LAC	E1
	RCR		/HERE WE GO LOOP DE LOOP
	DAC	E1
	LAC	E2
	RAR
	DAC	E2
	SNL		/LOW ORDER BIT ZERO?
	JMP	.BTEST	/YES - DON'T CHANGE RESULT
	LAC	MDIV
	SNA
	JMP	.BMULT	/DECIDE WHETHER TO MULTIPLY OR DIVIDE
	DDV%
	.DSA	BASE
	JMP	.BTEST
.BMULT	DMP%
	.DSA	BASE
.BTEST	LAC	E1
	SNA
	LAC	E2
	SNA!CLA		/IF BOTH HALVES OF THE EXPONENT ARE 0,..
	JMP*	R	/CALL IT A DAY
	UNDST%
	.DSA	TEMP	/SAVE THE RESULT TEMPORARILY
	DLD%
	.DSA	BASE	/SO WE CAN SQUARE THE BASE
	DMP%
	.DSA	BASE
	UNDST%
	.DSA	BASE
	DLD%
	.DSA	TEMP	/NOW RELOAD THE RESULT
	JMP	.BLOOP	/LOOP TILL EXPONENT ZERO
BASE	.BLOCK	3
TEMP	.BLOCK	3
ONE	1
	200000
	0
R	0
A	0
E1	0
E2	0
MDIV	0
	.END
