Example #1
0
def emit(op):
    global depth
    # print depth, op
    if op == "+":
        x86.add_gv_ev(eax, reg(ebx))
        pop_gv(ebx)
    elif op == "-":
        x86.sub_gv_ev(eax, reg(ebx))
        pop_gv(eax)
        x86.mov_gv_ev(ebx, reg(eax))
    elif op == "*":
        x86.imul_ev(reg(ebx))
        pop_gv(ebx)
    elif op == "/":
        x86.idiv_ev(reg(ebx))
        x86.mov_gv_iv(edx, 0)
        pop_gv(eax)
        x86.mov_gv_ev(ebx, reg(eax))
    elif op == "%":
        x86.mov_gv_ev(eax, reg(edx))
        x86.idiv_ev(reg(ebx))
        x86.mov_gv_iv(edx, 0)
        pop_gv(eax)
        x86.mov_gv_ev(ebx, reg(eax))
    else:
        gen_push(op)
Example #2
0
def emit(op):
    global depth
    # print depth, op
    if op == "+":
        x86.add_gv_ev(eax, reg(ebx))
        pop_gv(ebx)
    elif op == "-":
        x86.sub_gv_ev(eax, reg(ebx))
        pop_gv(eax)
        x86.mov_gv_ev(ebx, reg(eax))
    elif op == "*":
        x86.imul_ev(reg(ebx))
        pop_gv(ebx)
    elif op == "/":
        x86.idiv_ev(reg(ebx))
        x86.mov_gv_iv(edx, 0)
        pop_gv(eax)
        x86.mov_gv_ev(ebx, reg(eax))
    elif op == "%":
        x86.mov_gv_ev(eax, reg(edx))
        x86.idiv_ev(reg(ebx))
        x86.mov_gv_iv(edx, 0)
        pop_gv(eax)
        x86.mov_gv_ev(ebx, reg(eax))
    else:
        gen_push(op)
Example #3
0
def pop_gv(r):
    x86.mov_gv_ev(r, at_reg(esi))
    x86.sub_ev_iv(reg(esi), 4)
Example #4
0
def prolog():
    x86.push_gv(edi)
    x86.push_gv(esi)
    x86.push_gv(ebx)
    x86.mov_gv_ev(ebp, reg(esp))
    x86.push_gv(ebp)
Example #5
0
def prolog():
    x86.push_gv(edi)
    x86.push_gv(esi)
    x86.push_gv(ebx)
    x86.mov_gv_ev(ebp, reg(esp))
    x86.push_gv(ebp)
Example #6
0
def pop_gv(r):
    x86.mov_gv_ev (r, at_reg(esi))
    x86.sub_ev_iv (reg(esi), 4)