
/COPYRIGHT 1969, DIGITAL EQUIPMENT CORP., MAYNARD, MASS.
/MULT
/DESCRIPTION:THIS SUBROUTINE FORMS A 36-BIT SIGNED
/	PRODUCT FROM A 18-BIT SIGNED MULTIPLIER
/	AND MULTIPLICAND.  NEGATIVE NUMBERS
/	ARE REPRESENTED IN 2'S COMPLEMENT NOTATION.
/
/CALLING SEQUENCE:LAC MULTIPLIER
/	JMS MULT
/	LAC MULTIPLICAND
/	NEXT INSTR		/RETURN IS MADE HERE
/
/
/RESULTS:C(AC) = LOW-ORDER PROD,C(%MHIGH) = HIGH-ORDER PROD
MULT	0
	DZM	%MHIGH	/CLEAR BUILDER WORD.
	SNA		/TEST FOR ZERO IN MULTIPLIER.
	JMP	%SMPZ	/YES...EXIT.
	DAC	%SMP1
	XCT*	MULT	/FETCH MULTIPLICAND.
	DAC	%SMP2
	XOR	%SMP1	/EXCLUSIVE OR TO GET SIGN
	DAC	%MPSIN	/OF PRODUCT AND SAVE IT.
/
/NOW TEST BOTH MULTIPLIER AND MULTIPLICAND. IF EITHER IS
/NEGATIVE TAKE ITS 2'S COMPLEMENT
/
	LAC	%SMP1	/MULTIPLIER.
	SPA		/IS MULTIPLIER POSITIVE?
	JMS	%SMNEG	/NEGATE ROUTINE.
	DAC	%SMP1
	LAC	%SMP2	/MULTIPLICAND
	SPA		/IS MULTIPLICAND POSITIVE?
	JMS	%SMNEG	/NO...NEGATE.
	DAC	%SMP2
	LAW	-22	/LOOP FOR SERIES OF ADDS
	DAC	%SMP3
	CLL
/PERFORM ADDITION LOOP.
/
%SMP4	LAC	%SMP1	/MULTIPLIER.
	RAR		/SHIFT BIT 17 INTO LINK AND BUILD
	DAC	%SMP1	/THE LOW-ORDER PRODUCT AT THE SAME
	LAC	%MHIGH	/TIME.  IF THE LINK
	SZL!CLL		/IS ON FROM THE MULTIPLIER SHIFT
	TAD	%SMP2	/ADD THE MULTIPLICAND TO ITSELF.
	RAR		/PUT THE RIGHTMOST BIT INTO THE LINK
	DAC	%MHIGH
	ISZ	%SMP3	/IS LOOP FINISHED?
	JMP	%SMP4	/NO...LOOP AGAIN.
	LAC	%SMP1	/PUT LAST BIT INTO LOW PROD.
	RAR
	DAC	%SMP1
/
/NOW THE HIGH ORDER PRODUCT IS IN %SMP5 AND
/THE LOW ORDER PRODUCT IN IN THE (AC) AND %SMP1
/
	LAC	%MPSIN	/GET SIGN
	SMA		/SKIP IF PRODUCT POSITIVE
	JMP	%SMPZ-1
	LAC	%SMP1	/NEGATE PRODUCT
	JMS	%SMNEG
	DAC	%SMP1
	LAC	%MHIGH
	SPL!CLL!CMA
	TAD	(1
	DAC	%MHIGH
	LAC	%SMP1
%SMPZ	ISZ	MULT	/RETURN
	JMP*	MULT
%SMP1	0
%MHIGH	0
%MPSIN	0
%SMP2	0
%SMP3	0
%SMNEG	0
	CMA!CLL
	TAD	(1
	JMP*	%SMNEG
	.EOT
