.LAYOUT 3,2
.LEFT MARGIN 0
.RIGHT MARGIN 80
.NO DATE
.NO NUMBER
.NO FLAGS COMMENT
.NO FLAGS ALL
.XLOWER
.FIGURE DEFERRED 15
.C;QUADMATH
.B 5
.C;Quadword Math Routines
.B 10
.C;by
.B
.C;Rodrick A. Eldridge
.C;Iowa State University
.PG
.C;Overview
.B 3
This paper presents a set of routines which implement, in VAX-11 Macro,
quadword math routines to add, clear, compare, divide, move, multiply,
subtract and test quadword values.
.B 5
.C;Notice
.B 3
In order to reassemble these routines, you must have the MLR Macro Language.
The MLR Macro Language is a set of macro that implement structured programming
in VAX-11 Macro.
.B 5
.C;References
.B 3
.LIST
.LE;VAX ARCHITECTURE HANDBOOK;
Digital Equipment Corporation.
.LE;QUADMATH - Quadword Math;
HUGHES AIRCRAFT DECUS SIG tape submission.
[VAX83C.HUGHES]
.END LIST
.PG
.LITERAL
ADDQ  add,sum
ADDQ3 add1,add2,sum
.END LITERAL
.X ADDQ
.X ADDQ3
.B 3
The ADDQ procedure will add one quadword to another and leave the result in
the second quadword.
The ADDQ3 procedure will add one quadword to another and leave the result in
a third quadword.
.B
After the addition is performed, r0 will contain one of the following values:
.B
.LITERAL
	-1	sum < 0
	0	sum = 0
	1	sum > 0
.END LITERAL
.B
The ADDQ procedure is equivalent to the expression:
.B
.LITERAL
	sum = add + sum
.END LITERAL
.B
and the ADDQ3 procedure is equivalent to the expression:
.B
.LITERAL
	sum = add1 + add2
.END LITERAL
.B 2
MLR Example:
.B
.LITERAL
	var
	  add1: 	.blkq 1
	  add2:		.blkq 1
	  sum: 		.blkq 1

	external module addq <add,sum>
	external module addq3 <add1,add2,sum>

	addq	add1,sum
	addq3	add1,add2,sum
.END LITERAL
.PG
CLRQ dst
.X CLRQ
.B 3
The CLRQ procedure will zero a quadword.
.B
After the quadword is cleared, r0 will contain one of the following value:
.B
.LITERAL
	0	dst = 0
.END LITERAL
.B
The CLRQ procedure is equivalent to the expression:
.B
.LITERAL
	dst = 0
.END LITERAL
.B 2
MLR Example:
.B
.LITERAL
	var
	  dst: 		.blkq 1

	external module clrq <dst>

	clrq	dst
.END LITERAL
.PG
CMPQ src,dst
.X CMPQ
.B
The CMPQ procedure will compare a quadword with another quadword.
.B
After the comparision is performed, r0 will contain one of the following values:
.B
.LITERAL
	-1	src < dst
	0	src = dst
	1	src > dst
.END LITERAL
.B 2
MLR Example:
.B
.LITERAL
	var
	  src: 		.blkq 1
	  dst: 		.blkq 1

	external module cmpq <src,dst>

	cmpq	src,dst
.END LITERAL
.PG
DIVQ4 divisor,dividend,quotient,remainder
.X DIVQ4
.B 3
The DIVQ4 procedure will divide one quadword with another quadword and
leave the quotient and remainder in two other quadwords.
.B
After the division is performed, r0 will contain one of the following values:
.B
.LITERAL
	-1	quotient < 0
	0	quotient = 0
	1	quotient > 0
.END LITERAL
.B
The DIVQ4 procedure is equivalent to the expression:
.B
.LITERAL
	(quoitent,remainder) = divisor / dividend
.END LITERAL
.B 2
MLR Example:
.B
.LITERAL
	var
	  divr:		.blkq 1
	  divd: 	.blkq 1
	  quo: 		.blkq 1
	  rem: 		.blkq 1

	external module divq4 <divr,divd,quo,rem>

	divq4	divr,divd,quo,rem
.END LITERAL
.PG
MOVQ src,dst
.X MOVQ
.B 3
The MOVQ procedure will move one quadword to another quadword.
.B
After the quadword is moved, r0 will contain one of the following values:
.B
.LITERAL
	-1	dst < 0
	0	dst = 0
	1	dst > 0
.END LITERAL
.B
The MOVQ procedure is equivalent to the expression:
.B
.LITERAL
	dst = src
.END LITERAL
.B 2
MLR Example:
.B
.LITERAL
	var
	  src: 		.blkq 1
	  dst: 		.blkq 1

	external module movq <src,dst>

	movq	src,dst
.END LITERAL
.PG
.LITERAL
MULQ  multiplier,product
MULQ3 multiplier,multipland,product
.END LITERAL
.X MULQ
.X MULQ3
.B 3
The MULQ procedure will multiply one quadword with another and leave the
result in the second quadword.
The MULQ3 procedure will multiply one quadword with another and leave the
result in a third quadword.
.B
After the multiplication is performed, r0 will contain one of the following values:
.B
.LITERAL
	-1	product < 0
	0	product = 0
	1	product > 0
.END LITERAL
.B
The MULQ macro is equivalent to the expression:
.B
.LITERAL
	product = multiplier * product
.END LITERAL
.B
and the MULQ3 macro is equivalent to the expression:
.B
.LITERAL
	product = multiplier * multipland
.END LITERAL
.B 2
MLR Example:
.B
.LITERAL
	var
	  mulr: 	.blkq 1
	  muld: 	.blkq 1
	  prod: 	.blkq 1

	external module mulq <mulr,prod>
	external module mulq3 <mulr,muld,prod>

	mulq	mulr,prod
	mulq3	mulr,muld,prod
.END LITERAL
.PG
.LITERAL
SUBQ  sub,dif
SUBQ3 sub,min,dif
.END LITERAL
.X SUBQ
.X SUBQ3
.B 3
The SUBQ procedure will subtract one quadword from another and leave the
result in the second quadword.
The SUBQ3 procedure will subtract one quadword from another and leave the
result in a third quadword.
.B
After the subtraction is performed, r0 will contain one of the following values:
.B
.LITERAL
	-1	dif < 0
	0	dif = 0
	1	dif > 0
.END LITERAL
.B
The SUBQ macro is equivalent to the expression:
.B
.LITERAL
	dif = sub - dif
.END LITERAL
.B
and the SUBQ3 macro is equivalent to the expression:
.B
.LITERAL
	dif = sub - min
.END LITERAL
.B 2
MLR Example:
.B
.LITERAL
	var
	  sub: 		.blkq 1
	  min: 		.blkq 1
	  dif: 		.blkq 1

	external module subq <sub,dif>
	external module subq3 <sub,min,dif>

	subq	sub,dif
	subq3	sub,min,dif
.END LITERAL
.PG
TSTQ dst
.X TSTQ
.B 3
The TSTQ procedure will test a quadword with zero.
.B
After the test is performed, r0 will contain one of the following values:
.B
.LITERAL
	-1	dst < 0
	0	dst = 0
	1	dst > 0
.END LITERAL
.B 2
MLR Example:
.B
.LITERAL
	var
	  src: 		.blkq 1

	external module tstq <src>

	tstq	src
.END LITERAL
.IF index
.FLAGS COMMENT
.REQUIRE "quad.rnx"
.ENDIF index
