
	.TITLE FPOINT-EAE
/COPYRIGHT 1969, DIGITAL EQUIPMENT CORP., MAYNARD, MASS.
/GENERAL FLOATING POINT ARITHMETIC
/
/	FLOATING POINT MATH (EAE)
/
/
/	%FLOT.		FLOAT INTEGER TO FLOATING ACCUMULATOR.
/	%FUNF.		UNFLOAT SECOND. 10L
/	FNEG.		NEGATE THE FLOATING ACCUMULATOR
/	%FG.		SHORT GET ARGUMENT (ADDRESS)
/	%FNOR.		NORMALIZE THE FLOATING ACCUMULATOR
/	%FH		/HOLD THE FLOATING ACCUMULATOR
/	%FIR.		ROUND RESULT AND INSERT SIGN
/	%FS.		SIGN CONTROL
/	%ANEG.		NEGATE A-NEG.
/	%SWICH		SWITCH THE FLOATING AND HELD ACC'S.
/
/	%FA.		GENERAL FLOATING ADD
/	%FM.		GENERAL FLOATING MULTIPLY
/	%FD.		GENERAL FLOATING DIVIDE
/
/
/TERMS:
/	%FAC1		EXPONENT-FLOATING POINT ACCUMULATOR
/	%FAC2		SIGN+HIGH-ORDER MANTISSA-FLT ACC
/	%FAC3		LOW-ORDER MANTISSA-FLT ACC
/
/	%HAC1		EXPONENT-HELD ACCUMULATOR
/	%HAC2		SIGN+HIGH-ORDER MANTISSA-HELD ACC
/	%HAC3		LOW-ORDER MANTISSA
/	A-REG		HARDWARE ACCUMULATOR(AC)
/
/
/-------------------------
/
/NEGATE THE A-REG
/
/
%ANEG.	0
	CMA!CLL
	TAD	(1
	JMP*	%ANEG.
/
/-------------------------
/
/FLOAT INTEGER TO FLOATING ACCUMULATOR (%FLOT.)
/CALLING SEQUENCE:
/	JMS	%FLOT.	/SUBR CALL(INTEGER IN A-REG)
/	NEXT INSTRUCTION	/RETURN(INTEGER NORMALIZED IN FLT ACC)
/			/A-REG IS UNCHANGED
/
%FLOT.	0
	DAC	%FUNF.	/SAVE FOR SIGN, USE FUNF FOR WORKING STORAGE
	SMA		/IF MINUS TAKE 2'S COMPLEMENT
	JMP	%FLOTA	/POSITIVE, STORE INTEGER AND ITS NEW EXPONENT
	JMS	%ANEG.	/2'S COMP OF HARDWARE ACCUMULATOR
	SPA		/TEST FOR CASE: AC=400 00
	CLA		/YES...CLEAR OUT MINUS 0.
/
/STORE INTEGER AS THE UNNORMALIZED HIGH-ORDER MANTISSA. CLEAR OUT
/THE LOW-ORDER MANTISSA WORD AND STORE 17 AS THE EXPONENT OF THE
/FLOATING POINT NUMBER.  NORMALIZE THE VALUE, INSERT THE SIGN,
/AND EXIT WITH THE A-REG (HARDWARE ACCUMULATOR) RESTORED.
/
%FLOTA	DAC	%FAC2	/2ND WORD OF FLOATING ACC HIGH-ORDER MANTISSA
	DZM	%FAC3	/3RD WORD CLEAR OUT GARBARGE
	LAC	(21	/EXPONENT OF NEW FLOATING POINT VALUE
	DAC	%FAC1	/1ST WORD OF FLOATING ACC
	JMS	%FNOR.	/NORMALIZE THE INTEG2N
	LAC	%FUNF.	/GET ORIGINAL INTEGER
	AND	(400000	/KEEP ONLY THE SIGN
	XOR	%FAC2	/COMBINE SIGN AND FRACTION
	DAC	%FAC2	/STORE COMPLETED FLOATING POINT NUMBER
	LAC	%FUNF.	/RESTORE A-REG
	JMP*	%FLOT.	/EXIT
/
/-------------------------
/
/UNFLOAT THE FLOATING ACCUMULATOR	(%FUNF.)
/CALLING SEQUENCE:
/	JMS	%FUNF.	/CALL (VALUE IN FLOATING ACC
/	NEXT INSTRUCTION	/RETURN (INTEGER OF VALUE IN S-REG)
/
/
/THE VALUE IN WORD 2 OF THE FLOATING POINT ACCUMULATOR IS
/CONVERTED TO AN INTEGER.  IF THE EXPONENT IS NEGATIVE THE VALUE
/RETURNED IN THE A-REG IS 0.
/
%FUNF.	0
	LAC	%FAC2	/GET HIGH-ORDER MANTISSA OF VALUE
	AND	(400000	/KEEP ONLY THE SIGN
	DAC	%FLOT.	/STORE SIGN
	LAC	%FAC2
	AND	(377777
	DAC	%FAC2
	LAC	%FAC1	/GET EXPONENT
	SPA!SNA		/IF POSITIVE THE NUMBER DOES HAVE AN INTEGER PORTION
	JMP	%FUNFB	/ACC IS A FRACTION, IT HAS NO INTEGER.
	TAD	(-21	/EXP-17
	DAC	%FNEG.	/STORE NUMBER OF SHIFTS
	SNA		/IF EXPONENT IS NOT EQUAL TO
	JMP	%FUNFC	/TAKE THE INTEGER AS IS
	SMA		/IF EXP. GE. 17
	JMP	%FUNFB+2	/SET A-REG = ERROR 2
/
/THE NUMBER IS IN THE RANGE WHERE THE VAUE CAN BE SHIFTED
/RIGHT (FLAC) NUMBER OF TIMES TO PICK UP THE INTEGER
/
	LAC	%FAC2	/GET ORIGINAL VALUE
	RCR		/ROTATE RIGHT
	ISZ	%FNEG.	/ARE WE FINISHED?
	JMP	.-2	/NO..KEEP SHIFTING
/
/INSERT THE SIG AND EXIT
/
%FUNFA	XOR	%FLOT.	/SIGN THE RESULT
	SMA		/IF NEGATIVE TAKE TWO'S COMPLEMENT
	JMP	%FUNB	/EXIT
	AND	(377777	/STRIP PHONY SIGN
	JMS	%ANEG.	/NEGATE
%FUNB	ISZ	%FUNF.	/NORMAL EXIT
	JMP*	%FUNF.	/EXIT
/IF THE EXPONENT WAS LESS THAN ZERO THE NUMBER DOES NOT HAVE
/A FRACTION. ABSOLUTE ZERO IS RETURNED IN THE A-REG.
/
%FUNFB	CLA		/ACC WAS A FRACTION, ZERO AND
	JMP	%FUNB	/EXIT (EXP .LE.0
/
/IF THE EXPONENT IS GREATER THAN 17 THE INTEGER IS TO BIG TO BE
/EXPRESSED IN THE ACCUMULATOR.    INSERT ERROR 2
	LAC	(2	/ACC WAS .GT. LARGEST POSSIBLE INTEGER
	JMP*	%FUNF.	/ERROR 2 ..EXIT
/
/IF THE EXPONENT EQUALS 17 THE NUMBER IS ALREADY AN INTEGER
/
%FUNFC	LAC	%FAC2	/OK AS IS
	JMP	%FUNFA	/GET SIGN
/
/-------------------------
/
/NEGATE THE FLOATING ACCUMULATOR (%FNEG.)
/CALLING SEQUENCE:
/	JMS	%FNEG	/SUBR CALL (CHANGE SIGN OF NORMALIZED FLT ACC.)
/	NEXT INSTRUCTION	/RETURN WITH SIGN OF FLT ACC CHARGED.
%FNEG.	0		/ENTRY-EXIT
	LAC	%FAC2	/SIGN WORD OF FLOATING ACCUMULATOR
	SZA		/IF ABSOLUTE ZERO DO NOT NEGATE
	XOR	(400000	/CHANGE SIGN
	DAC	%FAC2	/RESTORE
	JMP*	%FNEG.	/EXIT
/
/-------------------------
/
/SORT GET ARGUMENT ROUTINE (%FG.)
/CALLING SEQUENCE:
/		(PC-1)	0		/A DRESS OF ARG IN USERS PROG.
/		(PC)	JMS	%FG.	/SUBR CALL
/		(PC+1)	0		/(STORE ADDRESS HERE)
/		(PC+2)	NEXT INSTRUCTION	/RETURN HERE
/
/SUBROUTINE %FG. GOES BACK TWO LEVELS (THREE IF INDIRECT)
/TO GET THE ADDRESS OF AN ARGUMENT AND STORES IT AT PC+1
/OF THE CALLING PROGRAM.
/
/
%FG.	0		/ENTRY-EXIT
	LAC	%FG.	/MASK OF POSSIBLE
	AND	(77777	/SIGN BIT SET FROM
	DAC	%FG.	/LINK DURING JMS
	LAW	-2	/GET CALLERS EXIT
	TAD	%FG.	/AC=(PC-1) FROM CALLING PROGRAM
	DAC	%J5	/SAVE FIRST LEVEL
/SECOND LEVEL
	LAC*	%J5	/GET (ARG ADDR) ADDR
	ISZ*	%J5	/BUMP CALLERS EXIT
	DAC	%J5	/SAVE ARG ADDR
	LAC*	%J5	/GET ARG ADDR
	DAC	%J5	/END OF 2ND LEVEL
	SPA		/IF 0 BIT IS ON ADDRESS IS INDIRECT
	LAC*	%J5	/ACCESS AGAIN
	DAC*	%FG.	/STORE ARG ADDR IN CALLING POINT
	ISZ	%FG.	/BUMP EXIT
	JMP*	%FG.	/EXIT
/
/-------------------------
/
/NORMALIZE FLOATING ACCU
ULATOR (%FNOR.)
/CALLING SEQUENCE:
/	JMS	%FNOR	/SUBR CALL
/	NEXT INSTRUCTION	/SUBR RETURN
/
/
/NORMALIZE FLOATING ACCUMULATOR (.CD)(EAE)
/CALLING SEQUENCE
/	JMS	%FNOR.	SUBR CALL (VALUE IN FLT ACC)
/NEXT INSTRUCTION	(VALUE NORMALIZEED IN FLOAT ACC
/
%FNOR.	0
	LAC	%FAC3
	SAD	%FAC2	/IF FLOATING ACUMULATOR
	SZA!CLL		/IS ZERO, CLEAR EXPONENT
	JMP	%FNORA	/AND SIGN
	DZM	%FAC1	/AND EXIT IMMEDIATELY
	DZM	%FSIGN
	DZM	%J4
	JMP*	%FNOR.
%FNORA	LMQ		/SET UP FLOATING ACCUMULATOR
	LAC	%FAC2	/FOR NORMALIZATION
	CLL
	NORM
	DAC	%FAC2
	LACQ
	DAC	%FAC3
	LACS
	TAD	(-000035)
	CMA
	TAD	%FAC1	/ADJUST EXPONENT BY
	DAC	%FAC1	/AMOUNT OF NORMALIZATION
	JMP*	%FNOR.
/
/-------------------------
/
/HOLD THE FLOATING ACCUMULATOR (%FH.)
/CALLING SEQUENCE:
/	JMS	%FH		/CALL (VALUE IN FLOATING ACC)
/	NEXT INSTRUCTION		/RETURN (VALUE IN FLOATING ACC AND HELD AC
/
/
/
%FH.	0
	LAC	%FAC1	/EXPONENT
	DAC	%HAC1
	LAC	%FAC2	/HIGH-ORDER MANTISSA
	DAC	%HAC2
	LAC	%FAC3	/LOW-ORDER MANTISSA
	DAC	%HAC3
	JMP*	%FH.	/EXIT
/
/-------------------------
/
/ROUND AND INSERT SIGN (%FIR.)
/CALLING SEQUENCE:
/	JMS	%FIR.		/SUBR CALL
/		400/1		/ROUNDOFF BIT
/		777000/777776	/EXTRACT MASK
/	NEXT INSTRUCTION		/SUBR RETURN
/
/
/THE RESULT IN THE FLOATING ACCUMULATOR IS ROUNDED ACCORDING
/TO THE MODE (SINGLE/DOUBLE PRECISION), AND THE SIGN (%FSIGN)
/IS INSERTE.
/
/
%FIR.	0
	CLL
	LAC*	%FIR.	/GET ROUNDOFF BIT.
	ISZ	%FIR.	/POINT TO MASK.
	TAD	%FAC3	/ADD TO LOW-ORDER RESULT TO PERFORM ROUNDOFF.
	AND*	%FIR.	/MASK OF INSIGNIFICANT PORTION.
	DAC	%FAC3	/KEEP LOW-ORDER RESULT.
	GLK		/GET OVERFLOW BIT.
	TAD	%FAC2	/ADD TO HIGH-ORDER RESULT.
	SMA		/OVERFLOW INTO SIGN BIT?
	JMP	%FIRA	/NO...INSERT SIGN AND EXIT
/
/ROUND-OFF CAUSED NUMBER TO OVERFLOW INTO SIGN BIT.
/ROTATE %FAC2,%FAC3 RIGHT ONE BIT AND INCREMENT EXPONENT.
/
	RCR
	DAC	%FAC2
	LAC	%FAC3
	RAR
	AND*	%FIR.	/TRUNCATE
	DAC	%FAC3
	LAC	%FAC2	/PREPARE TO INSERT SIGN
	ISZ	%FAC1	/INCREMENT EXPONENT
	NOP
%FIRA	XOR	%FSIGN	/INSERT SIGN
	DAC	%FAC2	/END OF ROUNDOFF
	ISZ	%FIR.	/POINT TO RETURN ADDRESS
	JMP*	%FIR.	/EXIT
/
/-------------------------
/
/SIGN CONTROL (STRIP SIGNS) (%FS.)
/CALLING SEQUENCQ:
/	JMS	%FS.	/CALL
/	NEXT INSTRUCTION	/RETURN
/
/THE SIGN BIT OF THE FLOATING ACC IS STORED IN BIT 0 OF
/STORAGE WORD %J4. THE SIGN TBIT OF TH HELD ACC IS
/EXCLUSIVE OR'ED WITH IT AND THAT VALUE IS STORED IN BIT 0 OF
/%FSIGN. RETURN IS MADE WITH BIT 0 OF BOTH THE
/HELD ACC AND THE FLOATING ACC SET TO ZERO.
/
/
%FS.	0
	LAC	%FAC2	/SIGN WORD OF FLOATING ACCUMULATOR
	AND	?(400000	/KEEP ONLY THE SIGN
	DAC	%J4	/STIRE IT
	LAC	%FAC2	/GET SIGN
	AND	(377777	/WORD AGAIN AND KEEP
	DAC	%FAC2	/ONLY THE ABSOLUTE VALUE
	LAC	%HAC2	/SIGN WORD OF HELD ACCUMULATOR
	XOR	%J4	/LIKE SIGNS=0, UNLIKE SIGN=1
	AND	(400000	/KEEP ONLY THE SIGN AND
	DAC	%FSIGN	/SAVE IT
	LAC	%HAC2	/GET THE SIGN WORD.
	AND	(377777	/OF THE HEALD ACC AND.
	DAC	%HAC2	/STRIP OFF THE SIGN.
	JMP*	%FS.	/EXIT
/
/-------------------------
/
/SWITCH THE FLOATING POINT ACCUMULATOR
/AND THE HELD ACCUMULATOR.
/CALLING SEQUENCE:
/	JMS	%SWICH	/SUBR CALL
/	NEXT INSTRUCTION	/RETURN
/
/THE ACCUMULATOR AND LINK ARE CLOBBERED BY
/THIS SUBROUTINE. TEMPORARY STORAGE WORD %J5 IS ALSO
/CLOBBERED.
/
%SWICH	0
	LAC	%FAC1	/EXPONENTS.
	DAC	%FS.	/USE TEMPORARILY FREE
	LAC	%HAC1	/STOARGE FOR
	DAC	%FAC1
	LAC	%FS.	/WORD MANIPULATION
	DAC	%HAC1
/			/HIGH-ORDER MANTISSAE.
	LAC	%FAC2
	DAC	%FS.
	LAC	%HAC2
	DAC	%FAC2
	LAC	%FS.
	DAC	%HAC2
/			/LOW-ORDER MANTISSAE
	LAC	%FAC3
	DAC	%FS.
	LAC	%HAC3
	DAC	%FAC3
	LAC	%FS.
	DAC	%HAC3
	JMP*	%SWICH
/
/-------------------------
/
/GENERAL FLOATING ADD (EAE)
/CALLING SEQUENCE:
/	JMS	%FA.	/CALL(AUGEND INFLOAT A C. ADDEN IN HELD ACC)
/	32/42		/MAXIMUN SHIFT (26 S.P., 34 D.P.)
/	NEXT INSTRUCTION	/SUBR RETURN
/
/
/
%FA.	0
	LAC	%FAC1	/DETERMINE EXPONENT DIFERENCE
	CMA		/(ADDEND-AUGEND-1)
	TAD	%HAC1
	DAC	%J5
	SPA		/IF MINUS DO NOT SWITCH
	JMP	%FAA
	JMS	%SWICH
	JMP	%FA.+1
%FAA	JMS	%FS.	/STRIP SIGNS, ABSOLUTIZE
	LAC	%J5	/SAVE COUNT
	TAD*	%FA.	/IS THIS MAX MORE THAN ALLOWED?
	SPA!CLA
	JMP	%FAE	/YES...EXIT WITH SUM IN FLOATING ACC
/
/SHIFT THE ADDEND RIGHT DELTA +1 TIMES.
/
	LAC	%J5
	JMS	%ANEG.
	XOR	(640500	/GENERATE SHIFT COMMAND
	DAC	%FAB
	LAC	%HAC3
	LMQ
	LAC	%HAC2
	CLL
%FAB	LRS		/SHIFT RIGHT
	DAC	%HAC2	/RESTORE HI-MANTISSA
	LACQ
	DAC	%HAC3	/RESTORE LO-MANTISSA
/
/THE EXPONENTS ARE NOW EQUAL. IF THE SIGNS ARE UNLIKE
/NEGATE THE ADDEND BEFORE ADDING. AFTER ADDING IF THE
/SUM IS NEGATIVE THE ADDEND MUST BE LARGER. THE SIGN OF
/THE SUM WOULD THEN BE THAT OF THE ADDEND
/
	LAC	%FSIGN
	SMA		/NEGATE ADDEND
	JMP	%FAC	/DO NOT NEGATE ADDEND
	LAC	%HAC3
	JMS	%ANEG.
	DAC	%HAC3	/NEGATED LOW-ORDER ADDEND
	LAC	%HAC2	/HIGH-ORDER ADDEND
	CMA!SZL		/IF OVER FLOW FROM
	TAD	(1	/NEGATE LOW-ORDER ADDEND
	DAC	%HAC2	/END OF NEGATION
/WHEN COMPUTING THE EXPONENT THE ONE'S COMPLEMENT WAS USED
/INSTEAD OF THE TWO'S COMPLEMENT, THIS WAS TO FORCE A RIGHT SHIFT
/OF THE AUGEND SO THAT OVERLFOW WOULD NOT INTERFERE WITH SUM
/SIGN DETERMINATION
/
/
%FAC	LAC	%FAC2		/HIGH-ORDER AUGEND
	RCR			/1-BIT RIGHT
	DAC	%FAC2
	LAC	%FAC3
	RAR			/LOW-ORDER AUGEND
	CLL			/RIGHTMOST BIT DROPS OFF.
/
/BEGIN THE ADDITION.
/
	TAD	%HAC3
	DAC	%FAC3		/LOW-ORDER SUM
	GLK			/IF OVERFLOW FROM ADDITION
	TAD	%FAC2
	TAD	%HAC2
	DAC	%FAC2		/HIGH-ORDER SUM
/
/IF SUM IS NEGATIVE, COMPLEMENT THE ANSWER AND THE SIGN OF
/THE SUM.
/
	SMA
	JMP	%FAD
	LAC	%FAC3
	JMS	%ANEG.
	DAC	%FAC3
	LAC	%FAC2
	CMA!ZL
	TAD	(1
	DAC	%FAC2
	LAC	(400000		/SET SIGN BIT
/
%FAD	ISZ	%FAC1		/INCREMENT EXPONENT BECAUSE
	NOP			/OF SHIFT %FAC
%FAE	XOR	%J4		/DETERMINE ANSWER SIGN
	AND	(400000
	DAC	%FSIGN
	JMS	%FNOR.
	ISZ	%FA.
	JMP*	%FA.		/BUMP FOR EXIT
/
/-------------------------
/
/GENERAL FLOATING MULTIPLY (%FM.) EAE
/CALLING SEQUENCE:
/	JMS	%FM.	/CALL
/	NEXT INSTRUCTION	/RETURN
/
/
/
/THE ARGUMENTS ARE IN THE FLOATING (%FAC1-3) AND
/HELD ACCUMULATORS (%HAC1-3). THE FLOATING ACCUMULATOR IS
/THE MULTIPLICAND AND THE HELD ACCUMULATOR THE MULTIPLIER.
/IF EITHER ARE ZERO, RETURN IS MADE WITH 0 IN THE FLOATING
/ACC. THE EXPONENT IS COMPUTED FIRST.
/
%FM.	0
	LAW	-1
	TAD	%FAC1	/COMPUTE PRODUCT EXPONENT AS
	TAD	%HAC1	/SUM OF MULTIPLIER AND
	DAC	%FAC1	/MULTIPLICAND EXPONENTS
	JMS	%FS.	/COMPUTE PRODUCT SIGN AND
	LAC	%FAC3	/ABSOLUTIZE ARGUMENTS
	LMQ
	LAC	%FAC2
	SNA!CLL
	JMP	%FME
	LLS	1
	DAC	%FMB
	DAC	%FMC
	LACQ
	DAC	%FMA
	LAC	%HAC3
	LMQ
	LAC	%HAC2
	SNA
	JMP	%FME	/MULTIPLIER=0
	LLS	1
	DAC	%HAC2
	LACQ
	DAC	%HAC3
	LAC	%HAC2
	MUL		/A2*B1
%FMA	0
	DAC	%FAC3
	LACQ
	DAC	%J1
	LAC	%HAC3
	MUL		/A1*B2
%FMB	0
	DAC	%FAC2
	LACQ
	TAD	%J1
	GLK
	DZM	%J1	/DETERMINE CARRY INTO
	TAD	%FAC2	/LEAST SIGNIFICANT PORTION
	SZL!CLL		/OF PRODUCT
	ISZ	%J1
	TAD	%FAC3
	SZL!CLL
	ISZ	%J1
	DAC	%FAC3
	LAC	%HAC2
	MUL	?	/A1*B1
%FMC	0
	DAC	%FAC2
	LACQ
	TAD	%FAC3	/DETERMINE CARRY INTO
	SZL!CLL		/MOST SIGNIFICANT PORTION
	ISZ	%J1	/OF PRODUCT
	LMQ
	LAC	%J1
	TAD	%FAC2	/IF CARRY OUT OF MOST
	SMA		/SIGNIFICANT PORTION,
	JMP	%FMD	/REPLACE MISSING BIT,
	IS	%FAC1	/RE-NORMALIZE, AND
	NOP		/ADJUST PRODUCT EXPONENT
	LRS	1
%FMD	DAC	%FAC2
	LACQ		/RETURN PRODUCT TO FLOATING AC
	DAC	%FAC3
	JMS	%FNOR.
	JMP*	%FM.	/EXIT
%FME	DZM	%FSIGN	/COME HERE ON 0
	DZM	%FAC1	/MULTIPLIER AND
	DZM	%FAC2	/ACCUMULATORS
	DZM	%FAC3
	DZM	%J4
	JMP*	%FM.	/EXIT
/
/-------------------------
/
/GENERAL FLOATING DIVIDE (%FD.) EAE
/CALLING SEQUENCE:
/
/	JMS	%FD.	/CALL
/	NOP		/NO OF BITS TO GENERATE
/	NOP		/LEAST SIGNIFICAT QUOTIENT BIT
/	NEXT INSTRUCTION	/RETURN HERE
/
/UPON ENTRY TO THE SUBROUTINE THE ARGUMENTS WERE STORED IN THE
/FLOATING POINT REGISTER (%FAC1-3), AND THE HELD ACCUMULATOR (%HAC1-3).
/RETURN IS MADE TO THE CALLING PROGRAM WITH THE QUOTIENT IN THE
/FLOATING POINT REGISTER. THE DIVISOR IS IN THE FLOATING AC.
/
/GENERAL FLOATING DIVIDE(%FD.)
/	CALLING SEQUENCE--
/	JMS	%FD.	ENTRY--DIVIDEND IN HAC, DIVISR IN EAC.
/	NOP		DUMMY WORD--IGNORED.
/	NOP		DUMMY WORD--IGNORED.
/	NEXT INSTRUCTION	RETURN--ABS QUOTIENT IN FAC, SIGN IT .CE
/
%FD.	0
	ISZ	%FD.	/INCREMENT RETURN ADDRESS TO PASS OVER
	ISZ	%FD.	/DUMMY WORDS.
	JMS	%FS.	/SIGN CONTROL
	LAC	%FAC3	/ABSOLUTE FAC AND HAC.
	RAL
	LAC	%FAC2	/SHIFT DIVISOR 1 LEFT TO MAKE SURE IT IS
	SNA		/GREATER THAN DIVIDEND AND STORE FOR
	JMP	%FDF	/USE BY EAE DIVIDE INSTRUCTIONS.
	RAL		/(A1+A2)/(B1+B2)=(Q1+Q2)(1-Q3+Q3**2----)
	DAC	%FDA	/WHERE-Q1=(A1+A2)/B1 FIRST 18 BITS
	DAC	%FDB	/Q=2(A1+A2)/B1 SECOND 18 BITS
	DAC	%FDC	/Q3=B2/B1
	LAC	%FAC1	/SUBTRACT DIVISOR EXPONENT FROM DIVIDEND
	JMS	%ANEG.	/EXPONENT TO GET QUOTIENT EXPONENT.
	TAD	%HAC1
	DAC	%FAC1
	LAC	%HAC3	/LOAD AC+MQ WITH A1+A2
	LMQ
	LAC	%HAC2
	SNA!CLL
	JMP	%FDF
	DIV		/GET FIRST 18 BITS OF (A1+A2)/B1
%FDA	0
	DAC	%J1	/SAVE REMAINDER
	LACQ		/GET Q1 FROM MQ.
	DAC	%FDD
	LAC	%J1	/RELOAD AC WITH REMAINDER
	FRDIV		/GET SECOND 18 BITS OF (A1+A2)/B1.
%FDB	0
	LACQ		/GET Q2 FROM MQ.
	DAC	%J1	/SAVE Q2.
	LAC	%FAC3	/CLEAR BIT0 OF B2 (IT WAS SHIFTED INTO B1
	AND	(377777	/TO ENSURE THAT ITS SMALLER THAN B1.
	FRDIV		/GET B2/B1.
%FDC	0
	LACQ		/GET Q3 FROM MQ.
	DAC	%FDA	/SAVE Q3.
	SPA!CLA		/IF BIT0 OF Q3 IS SET, IT IS LARGE ENOUGH
	LAW	-1	/FOR THE Q3**2 TERM OF THE SERIES TO BE
	TAD	%FDA	/SIGNIFICANT AND Q3 IS REDUCED BY ONE
	CLL		/TO COMPENSATE.
	MUL		/GET (Q1+Q2)*(Q3-Q3**2)=Q1*Q3 APPROX.
%FDD	0
	DZM	%FDA	/SAVE BIT0 OF Q1*Q3 AND THEN SHIFT AC+MQ
	SPA		/LEFT 1 TO ALIGN Q1*Q3 WITH Q2.
	ISZ	%FDA
	LLS	1
	DAC	%FDB
	LACQ		/ROUND PER HIGH MQ BIT
	SPA
	ISZ	%FDB
	SKP
	ISZ	%FDA	/BUMP IF OVERFOLW FROM ROUNDING
	LAC	%J1
	LMQ
	LAC	%FDB	/SUBTRACT FROM (Q1+Q2). FIRST
	SNA
	JMP	%FDG
	JMS	%ANEG.	/SUBTRACT FORM Q2 AND PLACE ANSWER
	STL		/IN MQ.
	TAD	%J1
	LMQ
	SZL		/BUMP C102 IF A BORROW IS GENERATED FROM
		SZ	%FDA	/MQ-C103
%FDG	LAC	%FDA	/SUBTRACT C102 FROM M1 AND LEAVE ANSWER
	JMS	%ANEG.	/IN AC.
	TAD	%FDD
	SMA!CLL		/IF RESULT IN AC+MQ HAS AC BIT0 SET;
	JMP	%FDE	/NORMALIZE BY SHIFTING AC+MQ RIGHT
	LRS	1	/ONE AND BUMPING EXPOINET.
	ISZ	%FAC1
	NOP
%FDE	DAC	%FAC2	/NORMAL EXIT - TRANSFER AC+MQ TO FAC. FAC
	LACQ		/IS ROUNDED AND UNSIGNED
	DAC	%FAC3
	JMP*	%FD.
%FDF	DZM	%FAC1	/DEFAULT EXIT--CLEAR FAC AND SIGN. THIS
	DZM	%FAC2	/EXIT TAKEN IF EITHER DIVIDOR OR DIVI-
	DZM	%FAC3	/DENT IS ZERO.
	DZM	%FSIGN
	DZM	%J4
	JMP*	%FD.
/
/-------------------------
/
/	TEMPORARY STORAGE
/
%FAC1	0
%FAC2	0
%FAC3	0
%HAC1	0
%HAC2	0
%HAC3	0
%J1	0
%J2	0
%J3	0
%J4	0
%J5	0
%FSIGN	0	/SIGN OF FLOATING ACC
/
/-------------------------
/
	.EOT
--------
/
/	TEMPORARY STORAGE
/
%FAC1	0
%FAC2	0
%FAC3	0
%HAC1	0
%HAC2	0
%HAC3	0
%J1	0
%J2	0
%J3	0
%J4	0
%J5	0
%FSIGN	0	/SIGN OF FLOATING ACC
/
/-------------------------
/
	.EOT
