
/COPYRIGHT 1969, DIGITAL EQUIPMENT CORP., MAYNARD, MASS.
/LDIV	/LOGICAL DIVIDE ROUTINE
/THE DIVIDEND IS A 36-BIT MAGNITUDE
/THE DIVISOR IS AN 18-BIT MAGNITUDE
/
/CALLING SEQUENCE:
/	LAC HIGH-ORDER DIVIDEND
/	JMS LDIV
/	LAC LOW-ORDER DIVIDEND
/	LAC DIVISOR
/	NEXT INSTR	/RETURN IS MADE HERE
/
/RESULTS:C(AC) = QUOTIENT, C(%LREM) = REMAINDER, LINK = 0
/
/RESTRICTIONS:IF THE HIGH ORDER DIVIDEND IS GREATER THAN OR EQUAL
/	THE LINK IS SET ON; OTHERWISE THE LINK = 0.
/
LDIV	0		/ENTER RETURN.
	DAC	%LREM	/HIGH-ORDER DIVIDEND
	XCT*	LDIV	/FETCH LOW-ORDER DIVIDEND
	DAC	%LQUO	/SAVE IT
	ISZ	LDIV	/POINTER TO NEXT INSTRUCTION
	XCT*	LDIV	/FETCH DIVISOR
	SNA!STL
	JMP	%LDV0	/ZERO DIVISOR
	CMA!CLL		/ NEGATE DIVISOR
	TAD	(1
	DAC	%LDVS
/
/BEFORE GOING INTO DIVIDE LOOP TEST TO SEE IF  HO DIVIDEND IS
/GREATER THAN OR EQUAL TO DIVISOR.  IF SO SET LINK = 1 AND EXIT
/
	TAD	%LREM
	ISZ	LDIV	/POINT TO RETURN ADDRESS
	SPL!CLA		/SKIP IF H0 DIVIDEND IS LESS
	JMP	%LDV0	/RETURN
	LAW	-23	/SET LOOP COUNT
	DAC	%LDV1	/SAVE COUNTER
	JMP	%LDV2	/START DIVISION
%LDV3	LAC	%LREM	/ROTATE ANOTHER
	RAL		/BIT FROM LO DIVIDEND
	DAC	%LREM	/INTO HIGH DIVIDEND
	TAD	%LDVS	/ADD DIVISOR
	SPL		/HAS DIVISON TAKEN PLACE?
	DAC	%LREM	/NEW DIVIDEND, DIVISON TOOK PLACE
/
/USING THE CONTENTS OF THE LINK OBTAINED FROM THE ABOVE
/SUBTRACTION, BUILD THE QUOTIENT BY SHIFTING
 /THE LINK INTO THE RIGHT SIDE OF %LQUO.
/
%LDV2	LAC	%LQUO
	RAL
	DAC	%LQUO
	ISZ	%LDV1	/FINISHED?
	JMP	%LDV3	/NO...LOOP AGAIN
	SKP!CLL
%LDV0	DZM	%LREM
	JMP*	LDIV
%LDV1	0
%LREM	0
%LQUO	0
%LDVS	0
	.EOT
*U*$