/COPYRIGHT 1970, DIGITAL EQUIPMENT CORP., MAYNARD, MASS.
	/EDIT 06P  10-14-70
	.TITLE INTEGER ARITHMETIC LIBRARY ROUTINES (EAE)
	.GLOBL .AD,.AE,.AF,.AY,.AZ,.CO
	.GLOBL INTEGE,INTEAE
INTEGE=.
INTEAE=.
TCA=CMA!IAC
/DIRECT ASSIGNMENTS FOR EAE INSTRUCTIONS
GSM=664000
IDIVS=657323
LACQ=641002
MULS=657122
	.IFDEF TIME%
	.GLOBL TIMON, TIMOFF
	.ENDC
/
/	CONTENTS
/	.AD	INTEGER MULTIPLICATION
/	.AE	INTEGER DIVISION
/	.AF	REVERSE INTEGER DIVISION
/	.AY	INTEGER SUBTRACTION
/	.AZ	REVERSE INTEGER SUBTRACTION
/	.CO	INTEGER REMAINDER FROM .AE OR .AF (ABOVE)
/	INTEGER MULTIPLICATION (.AD)
/	CALLING SEQUENCE
/	JMS* (.AD)	SUBR. CALL  (-A-REG CONTAINS MULTIPLICAND
/	LAC(*) ADDR	ADDR OF MULTIPLIER (LAC* IF INDIRECT)
/	NEXT INSTRUCTION SUB RETURN (PRODUCT IN -A- REG)
/
.AD	0
	.IFDEF TIME%
	JMS* TIMON
	.DSA 62
	.ENDC
	GSM	/GET SIGN AND MAG OF MULTIPLICAND
	SZL
	IAC		/2'S COMP MAG.
	DAC AD03	/STORE
	XCT* .AD	/GET MULTIPLIER
	ISZ .AD		/BUMP EXIT
	SPA
	ADD INT07	/(-2)
	MULS		/SIGNED MULTIPLY
AD03	0		/MULTIPLICAND
	LACQ		/LOAD PRODUCT FROM MQ
	SPA		/ASSUMED 18 BITS OR LESS
	IAC	/IF NEG TAD (1
	.IFDEF TIME%
	JMS* TIMOFF
	.DSA 62
	.ENDC
	JMP* .AD	/EXIT
	.EJECT
/	INTEGER DIVISION (.AE)
/	CALLING SEQUENCE
/	JMS* (.AE)	SUBR CALL (-A-REG. CONTAINS DIVIDEND)
/	LAC(*) ADDR	ADDR OF DIVISOR (LAC* IF INDIRECT)
/	NEXT INSTRUCTION  SUBR. RETURN (QUOTIENT IN -A- REG.
/                                      (REMAINDER IN GLOBL .CO
/
.AE	0
	.IFDEF TIME%
	JMS* TIMON
	.DSA 63
	.ENDC
	SPA
	TAD INT11	/IF NEG
	DAC INT10	/STORE DIVIDEND
	XCT* .AE	/GET DIVISOR
	ISZ .AE
	GSM		/GET MAG AND SIGN
	SZL
	IAC	/MAKE TWO'S COMPL.
	SNA		/CHK FOR 0 DIV.
	.IFUND TIME%
	JMP* .AE
	.ENDC
	.IFDEF TIME%
	JMP .CO-3
	.ENDC
	DAC AE03	/SETUP DIVISOR
	LAC INT10	/GET DIVIDEND
	IDIVS
AE03	0		/DIVISOR
	SPA
	CMA	/TWO'S COMPL. MAGNITUDE OF REMAINDER
	DAC .CO
	LACQ		/GET QUOTIENT
	SPA
	IAC
	.IFDEF TIME%
	JMS* TIMOFF
	.DSA 63
	.ENDC
	JMP* .AE	/EXIT
.CO	0		/REMAINDER
	.EJECT
/	REVERSE INTEGER DIVISION (.AF)
/	CALLING SEQUENCE
/	JMS* (.AF)	SUBR CALL (A-REG CONTAINS DIVISOR
/	LAC(*) ADDR	ADDR OF DIVIDEND (LAC* IF INDIRECT)
/	NEXT INSTRUCTION SUBR. RETURN (QUOTIENT IN A-REG
/			(REMAINDER IN GLOBL .CO)
/
.AF	0		/ENTRY-EXIT
	.IFDEF TIME%
	JMS* TIMOFF
	.DSA 64
	.ENDC
	GSM
	SZL
	IAC
	SNA
	JMP RDO		/IF 0 DIV
	DAC AF03	/STORE DIVISOR
	XCT* .AF	/GET DIVIDEND
	SPA
	ADD INT07	/-2
	IDIVS
AF03	0		/DIVISOR
	SPA
	CMA	/TWOS COMPL. MAG. OF REMAINDER
	DAC .CO
	LACQ		/GET RESULT
	SPA
	IAC
RDO	ISZ .AF		/BUMP EXIT
	.IFDEF TIME%
	JMS* TIMOFF
	.DSA 64
	.ENDC
	JMP* .AF
	.EJECT
/	INTEGER SUBTRACTION (.AY)
/	CALLING SEQUENCE
/	JMS* (.AY)	SUBR CALL (A-REG CONTAINS THE MINUEND
/	LAC(*) ADDR	ADDR OF SUBTRAHEND (LAC* IF INDIRECT)
/	NEXT INSTRUCTION SUBR RETURN (DIFFERENCE IN A-REG
/
.AY	0		/ENTRY-EXIT
	.IFDEF TIME%
	JMS* TIMON
	.DSA 65
	.ENDC
	DAC INT02	/STORE MINUEND
	XCT* .AY	/GET SUBTRAHEND
	TCA		/NEGATE
	TAD INT02	/MINUEND-SUBTRAHEND
	ISZ .AY		/BUMP EXIT
	.IFDEF TIME%
	JMS* TIMOFF
	.DSA 65
	.ENDC
	JMP* .AY	/EXIT
	.EJECT
/	REVERSE INTEGER SUBTRACTION (.AZ)
/	CALLING SEQUENCE
/	JMS* (.AZ)	SUBR CALL (A-REG CONTAINS SUBTRAHEND)
/	LAC(*) ADDR	ADDR OF MINUEND (LAC* IF INDIRECT)
/	NEXT INSTRUCTION	SUBR RETURN (DIFFERENCE IN A-REG)
/
.AZ	0		/ENTRY-EXIT
	.IFDEF TIME%
	JMS* TIMON
	.DSA 66
	.ENDC
	TCA		/NEGATE SUBTRAHEND
	DAC INT02	/STORE IT
	XCT* .AZ	/GET MINUEND
	ISZ .AZ		/BUMP EXIT
	TAD INT02	/COMBINE (MINUEND-SUBTRAHEND)
	.IFDEF TIME%
	JMS* TIMOFF
	.DSA 66
	.ENDC
	JMP* .AZ
	.EJECT
/STORAGE AND CONSTANTS
INT07	-2		/CONSTANT
INT10	0		/TEMP. STORAGE IN .AE
INT11	-1		/CONSTANT
INT02	0		/STORAGE FOR .AY
	.END
