Google
 

Trailing-Edge - PDP-10 Archives - BB-H506E-SM - cobol/source/dpmul.mac
There are 7 other files named dpmul.mac in the archive. Click here to see a list.
TITLE	DPMUL FOR LIBOL V12C
SUBTTL	DOUBLE-PRECISION INTEGER MULTIPLICATION		AL BLACKINGTON/CAM



	SEARCH	COPYRT
	SALL

;COPYRIGHT (C) DIGITAL EQUIPMENT CORPORATION 1974, 1985
;ALL RIGHTS RESERVED.
;
;THIS SOFTWARE IS FURNISHED UNDER A LICENSE AND MAY BE USED AND COPIED
;ONLY  IN  ACCORDANCE  WITH  THE  TERMS  OF  SUCH LICENSE.

;V10******
;	5/10/75		/DBT	ADD BIS
;**********

	SEARCH	LBLPRM
	%%LBLP==:%%LBLP
	BIS==:BIS

	HISEG

	.COPYRIGHT		;Put COPYRIGHT statement in .REL file.

;ENTER WITH FIRST OPERAND (OPERAND A) IN AC SPECIFIED BY AC-FIELD OF
;	ACCUMULATOR 16 (TWO CONSECUTIVE AC'S IF DOUBLE PRECISION).

;SECOND OPERAND (OPERAND B) IS ACCESSED VIA ADDRESS-FIELD OF
;		 AC 16 (WHERE THE UUO IS).
; IF OPERAND B IS DOUBLE-PRECISION:
;	0(16) GETS HIGH-ORDER WORD, 1(16) REFERENCES LOW HALF.
; IF OPERAND B IS SINGLE-PRECISION:
;	0(16) REFERENCES THE SINGLE WORD.
;EXIT WITH DOUBLE-PRECISION (LOW-ORDER TWO WORDS) IN AC'S SPECIFIED BY
;	AC-FIELD OF AC16.

	ENTRY	MUL.12		;MULTIPLY 1 WORD IN AC BY 2 WORDS IN MEMORY.
	ENTRY	MUL.21		;MULTIPLY 2 WORDS IN AC'S BY 1 WORD IN MEMORY.
	ENTRY	MUL.22		;MULTIPLY 2 WORDS IN AC'S BY 2 WORDS IN MEMORY.
IFN BIS,<
;STORE 4 WORD RESULT IN AC'S SPECIFIED
	ENTRY	MUL.41		;MULTIPLY 2 WORDS IN AC'S BY 1 WORD IN MEMORY.
	ENTRY	MUL.42		;MULTIPLY 2 WORDS IN AC'S BY 2 WORDS IN MEMORY.
>
SIGN=5			;BIT 0 = 1 IF SIGNS OF A AND B DIFFER, 0 OTHERWISE.
T=6			;INTERMEDIATE PRODUCT (2 AC'S)
TA=10			;TEMPORARY
TB=11			;TEMPORARY
TC=13			;HIGH-ORDER AND
TD=14			;  LOW-ORDER PARTS OF OPERAND B
AC=15			;ADDRESS OF INPUT AND RESULT AC'S
PA=16			;POINTER TO OPERAND B.
PP=17			;PUSH-DOWN POINTER.
IFE	BIS,<

MUL.21:	SKIPL	TD,0(PA)	;MULTIPLY DOUBLE BY SINGLE, SET UP
	TDZA	TC,TC		;  SIGN OF HIGH-ORDER OPERAND B.
	SETO	TC,		;  ..
	JRST	DPM22A		;THEN ENTER MAIN LINE.

MUL.12:	LDB	AC,[POINT 4,PA,12]	;GET AC-NUMBER
	MOVE	TB,0(AC)	;GET OPERAND A
	CAIL	TB,0		;MULTIPLY SINGLE BY DOUBLE, SET UP
	TDZA	TA,TA		;  SIGN OF HIGH-ORDER OPERAND A.
	SETO	TA,		;  ..
	MOVE	TC,0(PA)	;GET OPERAND B
	MOVE	TD,1(PA)
	JRST	DPM22B

MUL.22:	MOVE	TC,0(PA)	;PICK UP HIGH AND
	MOVE	TD,1(PA)	;  LOW PARTS OF B OPERAND.
DPM22A:	LDB	AC,[POINT 4,PA,12]	;GET
	MOVE	TA,0(AC)	;  OPERAND
	MOVE	TB,1(AC)	;    A
DPM22B:	MOVE	SIGN,TB		;GET SIGNS OF
	XOR	SIGN,TC		;  BOTH OPERANDS.

	JUMPGE	TA,DPM22C
	SETCA	TA,
	MOVMS	TB
	TLZ	TB,1B18
	SKIPN	TB
	ADDI	TA,1
DPM22C:	JUMPGE	TC,MUL1
	SETCA	TC,
	MOVMS	TD
	TLZ	TD,1B18
	SKIPN	TD
	ADDI	TC,1
;MULTIPLY HIGH-B BY LOW-A, LEAVING  A 1-WORD PRODUCT IN AC 13.
MUL1:	IMUL	TC,TB

;THEN MULTIPLY LOW-A BY LOW-B, LEAVING A 2-WORD PRODUCT IN AC'S T & T+1
MUL2:	MOVE	T,TB
	MUL	T,TD

;AND MULTIPLY HIGH-A BY LOW-B, LEAVING A 1-WORD PRODUCT IN TA.
	IMUL	TA,TD

;THE LOW-ORDER WORD OF THE FINAL PRODUCT NOW APPEARS IN AC 2. FIX UP
;HIGH-ORDER HALF (IN AC 0) .
	ADD	TA,T		;ADD HIGH HALF OF RESULT OF MUL2
	ADD	TA,TC	;  AND RESULT OF MUL1 TO GIVE FINAL HIGH HALF.
	TLZ	TA,1B18	;IGNORE OVERFLOW
	JUMPGE	SIGN,MUL4
	SETCA	TA,
	MOVNS	T+1
	TLZ	T+1,1B18
	SKIPN	T+1
	ADDI	TA,1
	TLO	T+1,1B18

MUL4:	MOVEM	TA,0(AC)	;STASH RESULT
	MOVEM	T+1,1(AC)
	POPJ	PP,

>	;END OF NON-BIS
IFN	BIS,<

MUL.12:	LDB	AC,PACFL.##		;GET AC
	MOVE	T,(AC)			; AND CONTENTS
	ASHC	T,-^D35			;EXTEND SIGN
	DMUL	T,(PA)			;MULTIPLY
	DMOVEM	T+2,(AC)		;STORE RESULT
	POPJ	PP,

MUL.21:	LDB	AC,PACFL.##		;GET AC
	DMOVE	T,(AC)			;AND CONTENTS
	MOVE	T+2,(PA)		;OP
	ASHC	T+2,-^D35		;EXTEND SIGN
	DMUL	T,T+2
	DMOVEM	T+2,(AC)		;RESULT
	POPJ	PP,

MUL.22:	LDB	AC,PACFL.##		;GET AC
	DMOVE	T,(AC)			;GET OP 1
	DMUL	T,(PA)			;MULTIPLY
	DMOVEM	T+2,(AC)
	POPJ	PP,

MUL.41:	LDB	AC,PACFL.##		;GET AC
	DMOVE	T,(AC)			;AND CONTENTS
	MOVE	T+2,(PA)		;OP
	ASHC	T+2,-^D35		;EXTEND SIGN
	DMUL	T,T+2
	DMOVEM	T,(AC)			;RESULT
	DMOVEM	T+2,2(AC)
	POPJ	PP,

MUL.42:	LDB	AC,PACFL.##		;GET AC
	DMOVE	T,(AC)			;GET OP 1
	DMUL	T,(PA)			;MULTIPLY
	DMOVEM	T,(AC)			;RESULT
	DMOVEM	T+2,2(AC)
	POPJ	PP,

>	;END OF BIS
	END