• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1%default {"preinstr":"", "result0":"a0", "result1":"a1", "chkzero":"0", "arg0":"a0", "arg1":"a1", "arg2":"a2", "arg3":"a3"}
2    /*
3     * Generic 64-bit binary operation.  Provide an "instr" line that
4     * 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 other than a0, you can override "result".)
7     *
8     * If "chkzero" is set to 1, we perform a divide-by-zero check on
9     * vCC (a1).  Useful for integer division and modulus.
10     *
11     * for: add-long, sub-long, div-long, rem-long, and-long, or-long,
12     *      xor-long
13     *
14     * IMPORTANT: you may specify "chkzero" or "preinstr" but not both.
15     */
16    /* binop vAA, vBB, vCC */
17    FETCH(a0, 1)                           #  a0 <- CCBB
18    GET_OPA(rOBJ)                          #  rOBJ <- AA
19    and       a2, a0, 255                  #  a2 <- BB
20    srl       a3, a0, 8                    #  a3 <- CC
21    EAS2(rOBJ, rFP, rOBJ)                  #  rOBJ <- &fp[AA]
22    EAS2(a2, rFP, a2)                      #  a2 <- &fp[BB]
23    EAS2(t1, rFP, a3)                      #  a3 <- &fp[CC]
24    LOAD64($arg0, $arg1, a2)               #  a0/a1 <- vBB/vBB+1
25    LOAD64($arg2, $arg3, t1)               #  a2/a3 <- vCC/vCC+1
26    .if $chkzero
27    or        t0, $arg2, $arg3             #  second arg (a2-a3) is zero?
28    beqz      t0, common_errDivideByZero
29    .endif
30    FETCH_ADVANCE_INST(2)                  #  advance rPC, load rINST
31
32    $preinstr                              #  optional op
33    $instr                                 #  result <- op, a0-a3 changed
34    GET_INST_OPCODE(t0)                    #  extract opcode from rINST
35    STORE64($result0, $result1, rOBJ)      #  vAA/vAA+1 <- $result0/$result1
36    GOTO_OPCODE(t0)                        #  jump to next instruction
37    /* 14-17 instructions */
38
39