From:	CSBVAX::MRGATE!@KL.SRI.Com,@cis.upenn.edu:CLAYTON@xrt.upenn.edu@SMTP 10-SEP-1987 00:47
To:	EVERHART
Subj:	Quadword Math Routines -- Corrected Version...

Received: from linc.cis.upenn.edu by KL.SRI.Com with TCP; Wed 9 Sep 87 20:34:28-PDT
Received: by linc.cis.upenn.edu
	id AA22775; Wed, 9 Sep 87 23:33:41 EDT
Posted-Date: Wed, 9 Sep 87 23:10 EDT
Message-Id: <8709100333.AA22775@linc.cis.upenn.edu>
Received: from xrt.upenn.edu by cis.upenn.edu; Wed, 9 Sep 87 23:38 EDT
Date: Wed, 9 Sep 87 23:10 EDT
From: "Clayton, Paul D." <@cis.upenn.edu:CLAYTON@xrt.upenn.edu>
Subject: Quadword Math Routines -- Corrected Version...
To: INFO-VAX@kl.sri.com
X-Vms-To: @INFOVAX,CLAYTON


Information From TSO Financial - The Saga Continues...
Chapter 20B - Sept. 9, 1987

It has been pointed out to me that an error in the transmission of the Quad
math routines occured making the 'Comp Quad' function useless. For this
reason, I am enclosing the entire sequence again for everyone, and between the
two copies hopefully, one good one can get pieced together.

	.TITLE	QUAD_MATH
;
;	CALL SUBQUAD(A,B,C)
;
;	RETURNS: A - B -> C
;
	.PSECT	SUBQUAD	NOWRT,EXE
	.ENTRY	SUBQUAD	^M<R2>
;
;
A=4
B=8
C=12
	MOVQ	@A(AP),R0
	MOVAQ	@B(AP),R2
	SUBL	(R2)+,R0
	SBWC	(R2),R1
	MOVQ	R0,@C(AP)
	RET
;
	.PSECT	COMPQUAD	NOWRT,EXE
	.ENTRY	COMPQUAD	^M<R2>
;
	MOVQ	@A(AP),R0
	MOVAQ	@B(AP),R2
	SUBL	(R2)+,R0
	SBWC	(R2),R1
	MOVQ	R0,R0			;"TEST" QUADWORD
	BEQL	10$
	BGTR	20$
	MOVL	#-1,R0
	BRB	30$
10$:
	CLRL	R0
	BRB	30$
20$:
	MOVL	#1,R0
30$:
	RET
;
	.PSECT	EDIV	NOWRT,EXE
	.ENTRY	EDIV	^M<R2>
;
;	CALL EDIV (A,B,C)
;	RETURNS A/B->C
;
	MOVQ	@A(AP),R0
	MOVAL	@B(AP),R2
	EDIV	(R2),R0,R0,R1
	MOVL	R0,@C(AP)
	RET
;
	.PSECT	EMUL	NOWRT,EXE
	.ENTRY	EMUL	^M<R2>
;
;	CALL EMUL (A,B,C)
;	RETURNS A*B->C
;
	MOVAL	@A(AP),R1
	MOVAL	@B(AP),R2
	EMUL	(R1),(R2),#0,R0
	MOVQ	R0,@C(AP)
	RET
;
;	CALL ADDQUAD(A,B,C)
;
;	RETURNS: A + B -> C
;
	.PSECT	ADDQUAD	NOWRT,EXE
	.ENTRY	ADDQUAD	^M<R2>
;
A=4
B=8
C=12
	MOVQ	@A(AP),R0
	MOVAQ	@B(AP),R2
	ADDL	(R2)+,R0
	ADWC	(R2),R1
	MOVQ	R0,@C(AP)
	RET
;
;	RESULT = QUAD_TO_D,F(A)
;
;	RETURNS: A -> CONVERT TO DOUBLE,FLOATING -> RESULT
;
	.PSECT	QUAD_TO_DF	NOWRT,EXE
QUAD_TO_F::
	.ENTRY	QUAD_TO_D ^M<R2,R3>
;
A=4
	MOVQ	@A(AP),R0
	CVTLD	R1,R2
	TSTL	R2
	BEQL	5$
	EXTV	#7,#8,R2,R1
	ADDL	#32,R1
	INSV	R1,#7,#8,R2
5$:
	BBCC	#31,R0,10$
	ADDD	#^F2147483648,R2
10$:
	CVTLD	R0,R0
	ADDD	R2,R0
	RET
	.END

Cheers :-)

Paul D. Clayton - Manager Of Systems
TSO Financial - Horsham, Pa. USA
Address - CLAYTON%XRT@CIS.UPENN.EDU
