1 %default {"preinstr":"", "result0":"a0", "result1":"a1", "chkzero":"0", "arg0":"a0", "arg1":"a1", "arg2":"a2", "arg3":"a3"} 2 /* 3 * Generic 64-bit "/2addr" binary operation. Provide an "instr" line 4 * that specifies an instruction that performs "result = a0-a1 op a2-a3". 5 * This could be a MIPS instruction or a function call. (If the result 6 * comes back in a register pair other than a0-a1, you can override "result".) 7 * 8 * If "chkzero" is set to 1, we perform a divide-by-zero check on 9 * vB (a2-a3). Useful for integer division and modulus. 10 * 11 * For: add-long/2addr, sub-long/2addr, div-long/2addr, rem-long/2addr, 12 * and-long/2addr, or-long/2addr, xor-long/2addr 13 */ 14 /* binop/2addr vA, vB */ 15 GET_OPA4(rOBJ) # rOBJ <- A+ 16 GET_OPB(a1) # a1 <- B 17 EAS2(a1, rFP, a1) # a1 <- &fp[B] 18 EAS2(t0, rFP, rOBJ) # t0 <- &fp[A] 19 LOAD64($arg2, $arg3, a1) # a2/a3 <- vB/vB+1 20 LOAD64($arg0, $arg1, t0) # a0/a1 <- vA/vA+1 21 .if $chkzero 22 or t0, $arg2, $arg3 # second arg (a2-a3) is zero? 23 beqz t0, common_errDivideByZero 24 .endif 25 FETCH_ADVANCE_INST(1) # advance rPC, load rINST 26 27 $preinstr # optional op 28 $instr # result <- op, a0-a3 changed 29 GET_INST_OPCODE(t0) # extract opcode from rINST 30 SET_VREG64_GOTO($result0, $result1, rOBJ, t0) # vA/vA+1 <- $result0/$result1 31