예제 #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)
예제 #2
0
파일: calc.py 프로젝트: darius/miasma
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)
예제 #3
0
def emit_add42():
    x86.ret()
    epilog()
    x86.add_gv_ev(eax, atv(ebp, 8))
    x86.mov_gv_iv(eax, 42)
    prolog()