	.TITLE	INTEGER ARITHMETIC LIBRARY ROUTINE (EAE)
/ 
/ 
/                   FIRST PRINTING, FEBRUARY 1974
/ 
/ THE INFORMATION IN THIS DOCUMENT IS SUBJECT TO 
/ CHANGE WITHOUT NOTICE AND SHOULD NOT BE CONSTRUED
/ AS A COMMITMENT BY DIGITAL EQUIPMENT CORPORATION.
/ DIGITAL EQUIPMENT CORPORATION ASSUMES NO RESPON-
/ SIBILITY FOR ANY ERRORS THAT MAY APPEAR IN THIS
/ DOCUMENT.
/ 
/ THE SOFTWARE DESCRIBED IN THIS DOCUMENT IS FUR-
/ NISHED TO THE PURCHASER UNDER A LICENSE FOR USE ON
/ A SINGLE COMPUTER SYSTEM AND CAN BE COPIED (WITH
/ INCLUSION OF DIGITAL'S COPYRIGHT NOTICE) ONLY FOR 
/ USE IN SUCH SYSTEM, EXCEPT AS MAY OTHERWISE BE PRO-
/ VIDED IN WRITING BY DIGITAL.
/ 
/ DIGITAL EQUIPMENT CORPORATION ASSUMES NO RESPONSIBILITY
/ FOR THE USE OR RELIABILITY OF ITS SOFTWARE ON EQUIP-
/ MENT THAT IS NOT SUPPLIED BY DIGITAL.
/ 
/ COPYRIGHT (C) 1974, BY DIGITAL EQUIPMENT CORPORATION
/ 
/ 
        .EJECT
/ EDIT 009  17-NOV-75  RKB	NO CHANGES, JUST RENAMED FILE
/
	.GLOBL .AD,.AE,.AF,.AY,.AZ,.CO,.ER
	.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
	DAC AE01	/IN CASE DIVIDE CHECK
	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.
	JMP AE02
	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
AE04=.
	.IFDEF TIME%
	JMS* TIMOFF
	.DSA 63
	.ENDC
	JMP* .AE	/EXIT
.CO	0		/REMAINDER
AE02	JMS* .ER	/DIVIDE CHECK
	400037		/OTS 37
	LAC AE01	/GET DIVIDEND
	DZM .CO		/ZERO REMAINDER
	JMP AE04	/EXIT
	.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 AF02		/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
AF02	JMS* .ER	/DIVIDE CHECK
	400037		/OTS 37
	XCT* .AF	/GET DIVIDEND
	DZM .CO		/ZERO REMAINDER
	JMP RDO	/EXIT
	.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
AE01	0
	.END
