• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1%default {"result":"%eax"}
2    /*
3     * Generic 32-bit "lit16" binary operation.  Provide an "instr" line
4     * that specifies an instruction that performs "result = eax op ecx".
5     * This could be an x86 instruction or a function call.  (If the result
6     * comes back in a register other than eax, you can override "result".)
7     *
8     * For: add-int/lit16, rsub-int,
9     *      and-int/lit16, or-int/lit16, xor-int/lit16
10     */
11    /* binop/lit16 vA, vB, #+CCCC */
12    movzbl   rINSTbl,%eax               # eax<- 000000BA
13    sarl     $$4,%eax                   # eax<- B
14    GET_VREG_R %eax %eax                # eax<- vB
15    movswl   2(rPC),%ecx                # ecx<- ssssCCCC
16    andb     $$0xf,rINSTbl              # rINST<- A
17    $instr                              # for example: addl %ecx, %eax
18    SET_VREG $result rINST
19    FETCH_INST_OPCODE 2 %ecx
20    ADVANCE_PC 2
21    GOTO_NEXT_R %ecx
22