	.TITLE	DIVD
/
/  8 MAR 72 - MOD BY P. HENDERSON
/
/NORMALIZED INTEGER DIVIDE SUBROUTINE
/EXECUTION TIME:  92 TO 96 MICROSECONDS
/CALLING SEQUENCE:
/   CALL DIVD(DIVDND,DIVSOR,QUOT,ERROR)
/   DIVDND:  NORMALIZED INTEGER DIVIDEND
/   DIVSOR:  NORMALIZED INTEGER DIVISOR
/   QUOT:    NORMALIZED INTEGER QUOTIENT
/   ERROR=0:  NO ERROR
/        =1:  DIVSOR NOT GREATER THAN DIVDND
/             (IN ABSOLUTE VALUE)
/
	.GLOBL DIVD
/
DIVD	XX
	.ARG	DIVD
	DAC DIVDND	/DIVIDEND LOCATION
	.ARG
	DAC DIVSOR	/DIVISOR LOCATION
	.ARG
	DAC QUOT	/QUOTIENT LOCATION
	.ARG
	DAC ERROR	/ERROR LOCATION
	DZM* ERROR	/ERROR=0
	LAC* DIVDND
	SMA!CLL	/CLEAR LINK
	JMP .+3
	CMA!CML	/COMPLEMENT DIVIDEND; SET LINK
	TAD (1
	DAC DIVDND	/STORE DIVIDEND
	LAC* DIVSOR
	SMA
	JMP .+3
	CMA!CML	/COMPLEMENT DIVISOR; COMPLEMENT LINK
	TAD (1
	DAC DIVSOR	/STORE DIVISOR
	CLA!RAR
	DAC SIGN	/STORE SIGN
	CLQ	/SET LEAST SIGNIFICANT DIVIDEND=0
	LAC DIVDND	/LOAD MOST SIGNIFICANT DIVIDEND
	DIV	/UNSIGNED DIVIDE
DIVSOR	XX
	SZL
	JMP ERROR1	/DIVIDE ERROR
	LAC SIGN
	RAL	/LINK=SIGN
	LACQ	/LOAD QUOTIENT
	SNL
	JMP .+3
	CMA	/COMPLEMENT QUOTIENT
	TAD (1
	RAR	/DIVIDE BY TWO TO MAKE IT RIGHT
	DAC* QUOT	/DEPOSIT QUOTIENT
	JMP* DIVD
ERROR1	ISZ* ERROR	/DIVISOR NOT GREATER THAN DIVIDEND
	JMP* DIVD
DIVDND
ERROR
QUOT
SIGN
	.END
