summaryrefslogtreecommitdiff
path: root/vm/mterp/x86/bindiv2addr.S
blob: cc415beff9281333377ec86fce771650fb51ecd5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
%default {"result":"","special":""}
    /*
     * 32-bit binary div/rem operation.  Handles special case of op0=minint and
     * op1=-1.
     */
    /* div/rem/2addr vA, vB */
    movzx    rINSTbl,%ecx          # eax<- BA
    SPILL(rIBASE)
    sarl     $$4,%ecx              # ecx<- B
    GET_VREG_R %ecx %ecx           # eax<- vBB
    andb     $$0xf,rINSTbl         # rINST<- A
    GET_VREG_R %eax rINST          # eax<- vBB
    cmpl     $$0,%ecx
    je       common_errDivideByZero
    cmpl     $$-1,%ecx
    jne      .L${opcode}_continue_div2addr
    cmpl     $$0x80000000,%eax
    jne      .L${opcode}_continue_div2addr
    movl     $special,$result
    SET_VREG $result rINST
    UNSPILL(rIBASE)
    FETCH_INST_OPCODE 1 %ecx
    ADVANCE_PC 1
    GOTO_NEXT_R %ecx

.L${opcode}_continue_div2addr:
    cltd
    idivl   %ecx
    SET_VREG $result rINST
    UNSPILL(rIBASE)
    FETCH_INST_OPCODE 1 %ecx
    ADVANCE_PC 1
    GOTO_NEXT_R %ecx