示例#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 push_gv(r):
    x86.add_ev_iv(reg(esi), 4)
    x86.mov_ev_gv(at_reg(esi), r)
示例#4
0
def pop_gv(r):
    x86.mov_gv_ev(r, at_reg(esi))
    x86.sub_ev_iv(reg(esi), 4)
示例#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)
示例#6
0
文件: test.py 项目: darius/miasma
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)
示例#7
0
文件: calc.py 项目: darius/miasma
def push_gv(r):
    x86.add_ev_iv(reg(esi), 4);
    x86.mov_ev_gv(at_reg(esi), r);
示例#8
0
文件: calc.py 项目: darius/miasma
def pop_gv(r):
    x86.mov_gv_ev (r, at_reg(esi))
    x86.sub_ev_iv (reg(esi), 4)