QUADMATH Quadword Math Routines by Rodrick A. Eldridge Iowa State University - 1 - Overview 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. Notice 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. References 1. VAX ARCHITECTURE HANDBOOK; Digital Equipment Corporation. 2. QUADMATH - Quadword Math; HUGHES AIRCRAFT DECUS SIG tape submission. [VAX83C.HUGHES] - 2 - ADDQ add,sum ADDQ3 add1,add2,sum 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. After the addition is performed, r0 will contain one of the following values: -1 sum < 0 0 sum = 0 1 sum > 0 The ADDQ procedure is equivalent to the expression: sum = add + sum and the ADDQ3 procedure is equivalent to the expression: sum = add1 + add2 MLR Example: var add1: .blkq 1 add2: .blkq 1 sum: .blkq 1 external module addq external module addq3 addq add1,sum addq3 add1,add2,sum - 3 - CLRQ dst The CLRQ procedure will zero a quadword. After the quadword is cleared, r0 will contain one of the following value: 0 dst = 0 The CLRQ procedure is equivalent to the expression: dst = 0 MLR Example: var dst: .blkq 1 external module clrq clrq dst - 4 - CMPQ src,dst The CMPQ procedure will compare a quadword with another quadword. After the comparision is performed, r0 will contain one of the following values: -1 src < dst 0 src = dst 1 src > dst MLR Example: var src: .blkq 1 dst: .blkq 1 external module cmpq cmpq src,dst - 5 - DIVQ4 divisor,dividend,quotient,remainder The DIVQ4 procedure will divide one quadword with another quadword and leave the quotient and remainder in two other quadwords. After the division is performed, r0 will contain one of the following values: -1 quotient < 0 0 quotient = 0 1 quotient > 0 The DIVQ4 procedure is equivalent to the expression: (quoitent,remainder) = divisor / dividend MLR Example: var divr: .blkq 1 divd: .blkq 1 quo: .blkq 1 rem: .blkq 1 external module divq4 divq4 divr,divd,quo,rem - 6 - MOVQ src,dst The MOVQ procedure will move one quadword to another quadword. After the quadword is moved, r0 will contain one of the following values: -1 dst < 0 0 dst = 0 1 dst > 0 The MOVQ procedure is equivalent to the expression: dst = src MLR Example: var src: .blkq 1 dst: .blkq 1 external module movq movq src,dst - 7 - MULQ multiplier,product MULQ3 multiplier,multipland,product 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. After the multiplication is performed, r0 will contain one of the following values: -1 product < 0 0 product = 0 1 product > 0 The MULQ macro is equivalent to the expression: product = multiplier * product and the MULQ3 macro is equivalent to the expression: product = multiplier * multipland MLR Example: var mulr: .blkq 1 muld: .blkq 1 prod: .blkq 1 external module mulq external module mulq3 mulq mulr,prod mulq3 mulr,muld,prod - 8 - SUBQ sub,dif SUBQ3 sub,min,dif 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. After the subtraction is performed, r0 will contain one of the following values: -1 dif < 0 0 dif = 0 1 dif > 0 The SUBQ macro is equivalent to the expression: dif = sub - dif and the SUBQ3 macro is equivalent to the expression: dif = sub - min MLR Example: var sub: .blkq 1 min: .blkq 1 dif: .blkq 1 external module subq external module subq3 subq sub,dif subq3 sub,min,dif - 9 - TSTQ dst The TSTQ procedure will test a quadword with zero. After the test is performed, r0 will contain one of the following values: -1 dst < 0 0 dst = 0 1 dst > 0 MLR Example: var src: .blkq 1 external module tstq tstq src - 10 - Index ADDQ, 3 MOVQ, 7 ADDQ3, 3 MULQ, 8 MULQ3, 8 CLRQ, 4 CMPQ, 5 SUBQ, 9 SUBQ3, 9 DIVQ4, 6 TSTQ, 10 - 11 -