1%default {"preinstr":"", "result":"a0", "chkzero":"0"} 2 /* 3 * Generic 32-bit "/2addr" binary operation. Provide an "instr" line 4 * that specifies an instruction that performs "result = a0 op a1". 5 * This could be an MIPS instruction or a function call. 6 * 7 * If "chkzero" is set to 1, we perform a divide-by-zero check on 8 * vCC (a1). Useful for integer division and modulus. 9 * 10 * For: add-int/2addr, sub-int/2addr, mul-int/2addr, div-int/2addr, 11 * rem-int/2addr, and-int/2addr, or-int/2addr, xor-int/2addr, 12 * shl-int/2addr, shr-int/2addr, ushr-int/2addr 13 */ 14 /* binop/2addr vA, vB */ 15 GET_OPA4(rOBJ) # rOBJ <- A+ 16 GET_OPB(a3) # a3 <- B 17 GET_VREG(a0, rOBJ) # a0 <- vA 18 GET_VREG(a1, a3) # a1 <- vB 19 .if $chkzero 20 # is second operand zero? 21 beqz a1, common_errDivideByZero 22 .endif 23 FETCH_ADVANCE_INST(1) # advance rPC, load rINST 24 25 $preinstr # optional op 26 $instr # $result <- op, a0-a3 changed 27 GET_INST_OPCODE(t0) # extract opcode from rINST 28 SET_VREG_GOTO($result, rOBJ, t0) # vAA <- $result 29 /* 10-13 instructions */ 30