
	.TITLE FPOINT-NON
/COPYRIGHT 1969, DIGITAL EQUIPMENT CORP., MAYNARD, MASS.
/GENERAL FLOATING POINT ARITHMETIC
/
/	FLOATING POINT MATH (NON-EAE)
/
/
/	%FLOT.		FLOAT INTEGER TO FLOATING ACCUMULATOR.
/	%FUNF.		UNFLOAT SECOND WORD OF FLOATING ACCUMULATOR TO A-REG.
/	%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-REG.
/	%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=400000
	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 ORGINAL 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		/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	/ERROR 2	
/
/THE NUMBER IS IN THE RANGE WHERE THE VALUE 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 SIGN 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.
	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
/
/IF THE EXPONENT IS GREATER THAN 17 THE INTEGER IS TOO BIG TO BE
/EXPRESSED IN THE ACCUMULATOR. THEREFORE, INSERT THE LARGEST
/POSSIBLE NUMBER AND GO TO SIGN INSERTING ROUTINE.
/
	LAC	(2	/ACC WAS .GT. LARGEST POSSIBLE INTEGER
	JMP*	%FUNF.	/INSERT SIGN
/
/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
/
/--------------------
/
/SHORT GET ARGUMENT ROUTINE (%FG.)
/CALLING SEQUENCE:
/		(PC-1)	0		/ADDRESS 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 ACCUMULATOR (%FNOR.)
/CALLING SEQUENCE:
/	JMS	%FNOR	/SUBR CALL
/	NEXT INSTRUCTION	/SUBR RETURN
/
/
/THE FLOATING POINT ACCUMULATOR IS SHIFTED LEFT UNTIL BIT 1 IS
/ON. BEFORE ANY SHIFTING THE NUMBER IS CHECKED FOR
/ZERO. IF IT IS ZERO THE EXPONENT IS CLEARED AND THE
/SIGN WORD SET OFF.
/
%FNOR.	0
	LAC	%FAC2	/IF %FAC2 = %FAC3
	AND	(377777	/STRIP SIGN IN CASE OF
	DAC	%FAC2	/MINUS ZERO.
	SAD	%FAC3	/AND AC=0 CLEAR
	SZA		/THE EXPONENT AND SIGN THE EXIT
	JMP	.+5	/WITH THE FLT ACC IN ABSOLUTE 0 STATE.
	DZM	%FAC1	/CLEAR EXPONT
	DZM	%FSIGN	/CLEAR SIGN
	DZM	%J4
	JMP*	%FNOR.	/EXIT
%FNORA	RCL		/IF BIT 0 IS ON EXIT
	SPA		/IF NOT KEEP ROTATING
	JMP*	%FNOR.
/
/DECREMENT EXPONENT.
/
	LAW	-1
	TAD	%FAC1
	DAC	%FAC1
/
/ROTATE 
/
	LAC	%FAC3
	RCL
	DAC	%FAC3
	LAC	%FAC2
	RAL
	DAC	%FAC2
	JMP	%FNORA
/
/--------------------
/
/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 ACCUMULATION IS ROUNDED ACCORDING
/TO THE MODE (SINGLE/DOUBLE PRECISION), AND THE SIGN (%FSIGN)
/IS INSERTED.
/
/
%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		/OVER FLOW 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 SEQUENCE:
/	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 THE 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	/STORE 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	/STORAGE 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
/CALLING SEQUENCE:
/	JMS	%FA.	/CALL(AUGEND INFLOAT ACC. ADDEN IN HELD ACC)
/	32/42		/MAXIMUM	SHIFT (26 S.P., 34 D.P.)
/	NEXT INSTRUCTION	/SUBR RETURN
/
/
/
%FA.	0
	LAC	%FAC1	/DETERMINE EXPONENT DIFFERENCE
	CMA		/(ADDEND-AUGEND-1)
	TAD	%HAC1
	DAC	%J5
	SPA		/IF MINUS DO NOT SWITCH
	JMP	.+3
	JMS	%SWICH
	JMP	%FA.+1
	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.
/
%FAB	LAC	%HAC2
	RCR
	DAC	%HAC2
	LAC	%HAC3
	RAR
	DAC	%HAC3
	ISZ	%J5	/FINISHED SHIFTING?
	JMP	%FAB	/NO...CYCLE AGAIN
/
/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	/NEGATING 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 OVERFLOW 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!SZL
	TAD	(1
	DAC	%FAC2
	LAC	(400000		/SET SIGN BIT
/
%FAD	ISZ	%FAC1		/INCREMENT EXPONENT BECAUSE OF SHIFT AT %FAC1
	NOP
%FAE	XOR	%J4		/DETERMINE ANSWER SIGN
	AND	(400000
	DAC	%FSIGN
	JMS	%FNOR.
	ISZ	%FA.	/BUMP FOR EXIT
	JMP*	%FA.		/EXIT
/
/
/--------------------
/
/GENERAL FLOATING MULTIPLY (%FM.) NON-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			/ENTRY EXIT
	LAC	%FAC1		/EXPONENT OF MULTIPLICAND
	TAD	%HAC1		/ADD EXPONENT OF MULTIPLIER
	DAC	%FAC1		/SAVE EXPONENT OF PRODUCT.
	JMS	%FS.		/GET SIGN AND ABSOLUTIZE.
/
/CHECK MULTIPICAND FOR ZEROAND SAVE IN WORK AREA.
/
	LAC	%FAC3		/LOW-ORDER MULTIPLICAND
	DZM	%FAC3		/CLEAR FOR SHIFTING IN PRODUCT
	DAC	%J3		/SAVE IT.
	LAC	%FAC2		/HIGH-ORDER MULTIPLICAND
	DZM	%FAC2 		/CLEAR PRODUCT AREA FOR SHIFTING.
	SNA			/IF 0 JUMP TO EXIT ROUTINE
	JMP	%FMC
	DAC	%J2		/NOT 0... SAVE IT
	DZM	%J1		/INITIALIZE CARRY EXTENSIONS
	DZM	%HAC1		/
/
/THE MULTIPLICATION IS PERFORMED BY A SERIES OF ADDS.
/THE MULTIPLICAND IS ADDED TO ITSELF AND SHIFTED FOR EVERY
/1-BIT OF THE MULTIPLIER. THE ADDITION STOPS WHEN THE
/2-WORD MULTIPLIER IS 0.
/
%FMA	LAC	%J2		/SHIFT THREE
	RCR			/WORD MULTIPLICAND
	DAC	%J2		/ONE
	LAC	%J3		/BIT
	RAR			/RIGHT
	DAC	%J3
	LAC	%J1		/3RD WORD EXTENSION OF MULTIPLICAND
	RAR
	DAC	%J1
/
	LAC	%HAC3		/SHIFT TWO WORD MULTIPLIER
	RCL			/ONE BIT LEFT
	DAC	%HAC3		/IF HIGH-ORDER WORD IS ZERO,
	LAC	%HAC2		/THE MULTIPLIER MIGHT BE ZERO
	RAL			/
	DAC	%HAC2		/
	SNA			/IF MULTIPLIER 0?
	JMP	%FMB		/MAYBE
	SMA!CLL			/NO...IS MULTIPLIER BIT 0 SET ?
	JMP	%FMA		/NO...CYCLE AGAIN
/
/ADD THE THREE WORD (INCLUDING EXTENSION) MULTIPLICAND TO THE
/BUILDING PRODUCT IN THE FLOATING ACC.
/
	LAC	%HAC1		/YES...ADD MULTIPLICAND TO PRODUCT
	TAD	%J1		/EXTENSION OF MULTIPLICAND (3RD WORD)
	DAC	%HAC1		/3RD WORD OF BUILDING PRODUCT
	GLK			/ADD OVERFLOW FROM LINK TO 2ND WORD
	TAD	%FAC3		/2ND WORD OF BUILDING PRODUCT
	TAD	%J3
	DAC	%FAC1
	GLK			/ADD OVERFLOW FROM LINK TO 1ST WORD
	TAD	%J2		/OF PRODUCT
	TAD	%FAC2
	DAC	%FAC2
	JMP	%FMA		/CYCLE AGAIN
/
/AT % FMB THE HIGH-ORDER MULTIPLIER WORD IS ZERO.
/TEST LOW-ORDER WORD, IF IT IS ZERO ALSO, EXIT.
/
%FMB	LAC	%HAC3		/IS MULTIPLIER 0 ?
	SZA			/YES
	JMP	%FMA		/NO...CYCLE AGAIN
/
/EXIT ROUTINE.
/
%FMC	JMS	%FNOR.		/NORMALIZE
	JMP*	%FM.		/RETURN
/
/--------------------
/
/GENERAL FLOATING DIVIDE (%FD.) NON-EAE
/CALLING SEQUENCE:
/
/	JMS	%FD.		/CALL
/	-34/-44			/NO OF BITS TO GENERATE
/	400/1			/LEAST SIGNIFICANT 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 FLOATION AC.
/
%FD.	0			/ENTRY-EXIT
	LAC*	%FD.		/GET NO OF BITS (MUST BE NEGATIVE)
	DAC	%J1		/SAVE NO OF BITS AS COUNTER.
	ISZ	%FD.
	JMS	%FS.		/SIGN CONTROL
/
/NEGATE THE DIVISOR IN THE FLOATING ACCUMULATOR.
/
	LAC	%FAC3		/LOW-ORDER DIVISION
	DZM	%FAC3		/CLEAR FOR QUOTIENT
	JMS	%ANEG.		/NEGATE AND
	DAC	%J3		/SAVE LOW-ORDER DIVISION
	LAC	%FAC2		/HIGH-ORDER DIVISION
	CMA!SZL			/SKIP IF LINK ON FROM NEGATING LOW-ORDER
	TAD	(1		/DIVISOR
	DZM	%FAC2		/CLEAR FOR QUOTIENT
	SNA			/IS DIVISOR .EQ.0
	JMP	%FDC
	DAC	%J2
/
/TEST FOR ZERO DIVIDEND
/
	LAC	%HAC2		/HIGH-ORDER DIVIDEND
	SNA			/IS DIVIDEND .EQ.0
	JMP	%FDC
/THE EXPONENT OF THE DIVIDEND MINUS THE EXPONENT OF THE
/DIVISOR EQUALS THE EXPONENT QUOTIENT.
/
	LAC	%FAC1		/DIVISOR EXPONENT
	JMS	%ANEG.
	TAD	%HAC1		/DIVIDEND EXPONENT
	DAC	%FAC1
/
/THE DIVISION IS DONE BY A SERIES OF SUBTRACTIONS. THE DIVISOR WILL BE
/SUBTRACTED FROM THE DIVIDEND, IF THE RESULT IS MINUS THE DIVISOR IS
/LARGER THAN THE DIVIDED AND A BIT IS NOT ADDED TO THE SHIFTED
/EXPONENT.
/
/
%FDA	LAC	%FAC3		/SHIFT BUILDING QUOTIENT 1 BIT LEFT
	RCL
	DAC	%FAC3
	LAC	%FAC2		/IF NEGATIVE, THE LARGEST POSSIBLE		
	RAL			/QUOTIENT HAS BEEN OBTAINED.
	?SPA
	JMP	%FDE
	DAC	%FAC2		/SUBTRACT LOW DIVISOR FROM
	LAC	%J3		/LOW DIVIDEND
	TAD	%HAC3
	DAC	%HAC1		/SAVE TEMPORARILY...MAYBE NEW LOW-ORDER DIVIDEND
	GLK
	TAD	%HAC2		/IF OVERFLOW ADD 1 TO HIGH ORDER DIVIDEND
	TAD	%J2		/SUBJECT HIGH-ORDER DIVISOR
	SMA
	JMP	%FDD		/IF NEGATIVE DO NOT GENERATE A QUOTIENT BIT
	LAC	%HAC3		/CONTINUE WITH OLD DIVIDEND INSTEAD OF REMAINDER
%FDB	RCL			/
	DAC	%HAC3		/
	LAC	%HAC2		/SHIFT DIVIDEND
	RAL			/
	DAC	%HAC2		/
	ISZ	%J1		/HAVE ALL BITS BEEN SHIFTED
	JMP	%FDA		/NO...CYCLE AGAIN
/ALL THE BITS HAVE BEEN SHIFTED
/
%FDC	JMS	%FNOR.		/YES...NORMALIZE
	ISZ	%FD.		/BUMP FOR EXIT
	JMP*	%FD.		/EXIT
/
/AT%FDD THE DIVISOR IS LESS THAN THE DIVIDEND AND A QUOTIENT BIT
/IS GENERATED. THE QUOTIENT BIT IS PICKED UP FROM THE CALLING SEQUENCE;
/IT IS THE LEAST SIGNIFICANT BIT AND IS ORED INTO THE BUILDING QUOTIENT.
/AN ADJUSTMENT IS NECESSARY TO PICK-UP THE NEW DIVIDEND (REMAINDER).
/
%FDD	DAC	%HAC2		/NEW-HIGH-ORDER DIVIDEND
	LAC*	%FD.		/GET LEAST SIGNIFICANT BIT, OR IT
	XOR	%FAC3		/INTP THE LOW-ORDER QUOTIENT WORD
	DAC	%FAC3		/SAVE NEW QUOTIENT 
	LAC	%HAC1		/GET LOW-ORDER REMAINDER
	JMP	%FDB		/GO BACK AND SHIFT QUOTIENT
/
/AT %FDE THE LARGEST POSSIBLE QUOTIENT HAS BEEN OBTAINED. THE
/QUOTIENT WAS SHIFTED LEFT ONE BIT TOO MANY. SHIFT IT BACK 1 BIT
/AND INCREMENT THE EXPONENT OF THE QUOTIENT
/
%FDE	RCR			/HIGH-ORDER QUOTIENT
	LAC	%FAC3		/GET LOW-ORDER QUOTIENT AND
	RAR			/REPLACE BIT TAKEN FROM IT.
	DAC	%FAC3		/MANTISSA	 PORTION COMPLETE.
	ISZ	%FAC1		/INCREMENT EXPONENT
	JMP	%FDC+1		/EXIT ROUTINE WITHOUT NORMALIZING.
	JMP	%FDC+1
/
/
/--------------------
/
/	TEMPORY 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