Beispiel #1
0
def call(ir, instr, a):
    e, a, dummy = mng_autoinc(a, None, 16)
    n = ExprId(ir.get_next_label(instr), 16)
    e.append(ExprAff(ExprMem(SP - ExprInt16(2), 16), n))
    e.append(ExprAff(SP, SP - ExprInt16(2)))
    e.append(ExprAff(PC, a))
    e.append(ExprAff(ir.IRDst, a))
    return e, []
Beispiel #2
0
def call(ir, instr, a):
    e, a, dummy = mng_autoinc(a, None, 16)
    n = ExprId(ir.get_next_label(instr), 16)
    e.append(ExprAff(ExprMem(SP - ExprInt16(2), 16), n))
    e.append(ExprAff(SP, SP - ExprInt16(2)))
    e.append(ExprAff(PC, a))
    e.append(ExprAff(ir.IRDst, a))
    return e, []
Beispiel #3
0
def add_condition_expr(ir, instr, cond, instr_ir):
    if cond == COND_AL:
        return instr_ir, []
    if not cond in tab_cond:
        raise ValueError('unknown condition %r' % cond)
    cond = tab_cond[cond]

    lbl_next = ExprId(ir.get_next_label(instr), 32)
    lbl_do = ExprId(ir.gen_label(), 32)

    dst_cond = ExprCond(cond, lbl_do, lbl_next)
    assert(isinstance(instr_ir, list))

    has_irdst = False
    for e in instr_ir:
        if e.dst == ir.IRDst:
            has_irdst = True
            break
    if not has_irdst:
        instr_ir.append(ExprAff(ir.IRDst, lbl_next))
    e_do = irbloc(lbl_do.name, [instr_ir])
    e = [ExprAff(ir.IRDst, dst_cond)]
    return e, [e_do]
Beispiel #4
0
def tbnz(arg1, arg2, arg3):
    bitmask = m2_expr.ExprInt(1, arg1.size) << arg2
    dst = arg3 if arg1 & bitmask else m2_expr.ExprId(
        ir.get_next_label(instr), 64)
    PC = dst
    ir.IRDst = dst
Beispiel #5
0
def b_ne(arg1):
    dst = m2_expr.ExprId(ir.get_next_label(instr), 64) if zf else arg1
    PC = dst
    ir.IRDst = dst
Beispiel #6
0
def cbz(arg1, arg2):
    dst = m2_expr.ExprId(ir.get_next_label(instr), 64) if arg1 else arg2
    PC = dst
    ir.IRDst = dst
Beispiel #7
0
def cbnz(arg1, arg2):
    dst = arg2 if arg1 else m2_expr.ExprId(ir.get_next_label(instr), 64)
    PC = dst
    ir.IRDst = dst
Beispiel #8
0
def tbz(arg1, arg2, arg3):
    bitmask = m2_expr.ExprInt_from(arg1, 1) << arg2
    dst = m2_expr.ExprId(
        ir.get_next_label(instr), 64) if arg1 & bitmask else arg3
    PC = dst
    ir.IRDst = dst
Beispiel #9
0
def jge(ir, instr, a):
    n = ExprId(ir.get_next_label(instr), 16)
    e = []
    e.append(ExprAff(PC, ExprCond(nf ^ of, n, a)))
    e.append(ExprAff(ir.IRDst, ExprCond(nf ^ of, n, a)))
    return e, []
Beispiel #10
0
def b_lt(arg1):
    cond = cond2expr['LT']
    dst = arg1 if cond else m2_expr.ExprId(ir.get_next_label(instr), 64)
    PC = dst
    ir.IRDst = dst
Beispiel #11
0
def cbnz(ir, instr, a, b):
    e = []
    lbl_next = ExprId(ir.get_next_label(instr), 32)
    e.append(ir.IRDst, ExprCond(a, b, lbl_next))
    return e
Beispiel #12
0
def b_ne(arg1):
    dst = m2_expr.ExprId(ir.get_next_label(instr), 64) if zf else arg1
    PC = dst
    ir.IRDst = dst
Beispiel #13
0
def b_eq(arg1):
    dst = arg1 if zf else m2_expr.ExprId(ir.get_next_label(instr), 64)
    PC = dst
    ir.IRDst = dst
Beispiel #14
0
def tbnz(arg1, arg2, arg3):
    bitmask = m2_expr.ExprInt(1, arg1.size) << arg2
    dst = arg3 if arg1 & bitmask else m2_expr.ExprId(ir.get_next_label(instr),
                                                     64)
    PC = dst
    ir.IRDst = dst
Beispiel #15
0
def cbnz(arg1, arg2):
    dst = arg2 if arg1 else m2_expr.ExprId(ir.get_next_label(instr), 64)
    PC = dst
    ir.IRDst = dst
Beispiel #16
0
def cbz(arg1, arg2):
    dst = m2_expr.ExprId(ir.get_next_label(instr), 64) if arg1 else arg2
    PC = dst
    ir.IRDst = dst
Beispiel #17
0
def b_eq(arg1):
    dst = arg1 if zf else m2_expr.ExprId(ir.get_next_label(instr), 64)
    PC = dst
    ir.IRDst = dst
Beispiel #18
0
def jc(ir, instr, a):
    n = ExprId(ir.get_next_label(instr), 16)
    e = []
    e.append(ExprAff(PC, ExprCond(cf, a, n)))
    e.append(ExprAff(ir.IRDst, ExprCond(cf, a, n)))
    return e, []
Beispiel #19
0
def b_lt(arg1):
    cond = cond2expr['LT']
    dst = arg1 if cond else m2_expr.ExprId(ir.get_next_label(instr), 64)
    PC = dst
    ir.IRDst = dst
Beispiel #20
0
def jc(ir, instr, a):
    n = ExprId(ir.get_next_label(instr), 16)
    e = []
    e.append(ExprAff(PC, ExprCond(cf, a, n)))
    e.append(ExprAff(ir.IRDst, ExprCond(cf, a, n)))
    return e, []
Beispiel #21
0
def tbz(arg1, arg2, arg3):
    bitmask = m2_expr.ExprInt_from(arg1, 1) << arg2
    dst = m2_expr.ExprId(ir.get_next_label(instr),
                         64) if arg1 & bitmask else arg3
    PC = dst
    ir.IRDst = dst
Beispiel #22
0
def jge(ir, instr, a):
    n = ExprId(ir.get_next_label(instr), 16)
    e = []
    e.append(ExprAff(PC, ExprCond(nf ^ of, n, a)))
    e.append(ExprAff(ir.IRDst, ExprCond(nf ^ of, n, a)))
    return e, []