Example #1
0
File: sem.py Project: vardyh/miasm
def bc1t(ir, instr, a, b):
    e = []
    n = ExprId(ir.get_next_break_label(instr))
    dst_o = ExprCond(a, b, n)
    e = [ExprAff(PC, dst_o)]
    e.append(ExprAff(ir.IRDst, dst_o))
    return e, []
Example #2
0
File: sem.py Project: vardyh/miasm
def bgtz(ir, instr, a, b):
    e = []
    n = ExprId(ir.get_next_break_label(instr))
    cond = ExprCond(a, ExprInt1(1), ExprInt1(0)) | a.msb()
    dst_o = ExprCond(cond, n, b)
    e = [ExprAff(PC, dst_o), ExprAff(ir.IRDst, dst_o)]
    return e, []
Example #3
0
File: sem.py Project: vardyh/miasm
def jalr(ir, instr, a, b):
    e = []
    n = ExprId(ir.get_next_break_label(instr))
    e.append(ExprAff(PC, a))
    e.append(ExprAff(ir.IRDst, a))
    e.append(ExprAff(b, n))
    return e, []
Example #4
0
def jalr(ir, instr, a, b):
    e = []
    n = ExprId(ir.get_next_break_label(instr))
    e.append(ExprAff(PC, a))
    e.append(ExprAff(ir.IRDst, a))
    e.append(ExprAff(b, n))
    return e, []
Example #5
0
def bc1f(ir, instr, a, b):
    e = []
    n = m2_expr.ExprId(ir.get_next_break_label(instr))
    dst_o = m2_expr.ExprCond(a, n, b)
    e = [m2_expr.ExprAff(PC, dst_o)]
    e.append(m2_expr.ExprAff(ir.IRDst, dst_o))
    return e, []
Example #6
0
def bc1t(ir, instr, a, b):
    e = []
    n = ExprId(ir.get_next_break_label(instr))
    dst_o = ExprCond(a, b, n)
    e = [ExprAff(PC, dst_o)]
    e.append(ExprAff(ir.IRDst, dst_o))
    return e, []
Example #7
0
def bal(ir, instr, a):
    e = []
    n = m2_expr.ExprId(ir.get_next_break_label(instr))
    e.append(m2_expr.ExprAff(PC, a))
    e.append(m2_expr.ExprAff(ir.IRDst, a))
    e.append(m2_expr.ExprAff(RA, n))
    return e, []
Example #8
0
def bgez(ir, instr, a, b):
    e = []
    n = ExprId(ir.get_next_break_label(instr))
    dst_o = ExprCond(a.msb(), n, b)
    e = [ExprAff(PC, dst_o),
         ExprAff(ir.IRDst, dst_o)
     ]
    return e, []
Example #9
0
def bne(ir, instr, a, b, c):
    e = []
    n = ExprId(ir.get_next_break_label(instr))
    dst_o = ExprCond(a-b, c, n)
    e = [ExprAff(PC, dst_o),
         ExprAff(ir.IRDst, dst_o)
    ]
    return e, []
Example #10
0
def jal(ir, instr, a):
    "Jumps to the calculated address @a and stores the return address in $RA"
    e = []
    n = m2_expr.ExprId(ir.get_next_break_label(instr))
    e.append(m2_expr.ExprAff(PC, a))
    e.append(m2_expr.ExprAff(ir.IRDst, a))
    e.append(m2_expr.ExprAff(RA, n))
    return e, []
Example #11
0
def bgtz(ir, instr, a, b):
    e = []
    n = ExprId(ir.get_next_break_label(instr))
    cond = ExprCond(a, ExprInt1(1), ExprInt1(0)) | a.msb()
    dst_o = ExprCond(cond, n, b)
    e = [ExprAff(PC, dst_o),
         ExprAff(ir.IRDst, dst_o)
     ]
    return e, []
Example #12
0
def bltz(ir, instr, a, b):
    """Branches on @b if the register @a is less than zero"""
    e = []
    n = m2_expr.ExprId(ir.get_next_break_label(instr))
    dst_o = m2_expr.ExprCond(a.msb(), b, n)
    e = [m2_expr.ExprAff(PC, dst_o),
         m2_expr.ExprAff(ir.IRDst, dst_o)
    ]
    return e, []
Example #13
0
def jalr(ir, instr, a, b):
    """Jump to an address stored in a register @a, and store the return address
    in another register @b"""
    e = []
    n = m2_expr.ExprId(ir.get_next_break_label(instr))
    e.append(m2_expr.ExprAff(PC, a))
    e.append(m2_expr.ExprAff(ir.IRDst, a))
    e.append(m2_expr.ExprAff(b, n))
    return e, []
Example #14
0
def beq(ir, instr, a, b, c):
    "Branches on @c if the quantities of two registers @a, @b are equal"
    e = []
    n = m2_expr.ExprId(ir.get_next_break_label(instr))
    dst_o = m2_expr.ExprCond(a-b, n, c)
    e = [m2_expr.ExprAff(PC, dst_o),
         m2_expr.ExprAff(ir.IRDst, dst_o)
     ]
    return e, []
Example #15
0
def bgez(ir, instr, a, b):
    """Branches on @b if the quantities of register @a is greater than or equal
    to zero"""
    e = []
    n = m2_expr.ExprId(ir.get_next_break_label(instr))
    dst_o = m2_expr.ExprCond(a.msb(), n, b)
    e = [m2_expr.ExprAff(PC, dst_o),
         m2_expr.ExprAff(ir.IRDst, dst_o)
     ]
    return e, []
Example #16
0
def bgtz(ir, instr, a, b):
    """Branches on @b if the register @a is greater than zero"""
    e = []
    n = m2_expr.ExprId(ir.get_next_break_label(instr))
    cond = m2_expr.ExprCond(a, m2_expr.ExprInt1(1),
                            m2_expr.ExprInt1(0)) | a.msb()
    dst_o = m2_expr.ExprCond(cond, n, b)
    e = [m2_expr.ExprAff(PC, dst_o),
         m2_expr.ExprAff(ir.IRDst, dst_o)
     ]
    return e, []
Example #17
0
File: sem.py Project: 0xf1sh/miasm
def beq(arg1, arg2, arg3):
    "Branches on @arg3 if the quantities of two registers @arg1, @arg2 are eq"
    dst = ExprId(ir.get_next_break_label(instr)) if arg1 - arg2 else arg3
    PC = dst
    ir.IRDst = dst
Example #18
0
File: sem.py Project: 0xf1sh/miasm
def bgez(arg1, arg2):
    """Branches on @arg2 if the quantities of register @arg1 is greater than or
    equal to zero"""
    dst = ExprId(ir.get_next_break_label(instr)) if arg1.msb() else arg2
    PC = dst
    ir.IRDst = dst
Example #19
0
File: sem.py Project: 0xf1sh/miasm
def bne(arg1, arg2, arg3):
    """Branches on @arg3 if the quantities of two registers @arg1, @arg2 are NOT
    equal"""
    dst = arg3 if arg1 - arg2 else ExprId(ir.get_next_break_label(instr))
    PC = dst
    ir.IRDst = dst
Example #20
0
def bltz(arg1, arg2):
    """Branches on @arg2 if the register @arg1 is less than zero"""
    dst_o = arg2 if arg1.msb() else ExprId(ir.get_next_break_label(instr))
    PC = dst_o
    ir.IRDst = dst_o
Example #21
0
File: sem.py Project: 0xf1sh/miasm
def bgtz(arg1, arg2):
    """Branches on @arg2 if the register @arg1 is greater than zero"""
    cond = (i1(1) if arg1 else i1(0)) | arg1.msb()
    dst_o = ExprId(ir.get_next_break_label(instr)) if cond else arg2
    PC = dst_o
    ir.IRDst = dst_o
Example #22
0
def bc1f(arg1, arg2):
    dst_o = ExprId(ir.get_next_break_label(instr)) if arg1 else arg2
    PC = dst_o
    ir.IRDst = dst_o
Example #23
0
File: sem.py Project: 0xf1sh/miasm
def bc1f(arg1, arg2):
    dst_o = ExprId(ir.get_next_break_label(instr)) if arg1 else arg2
    PC = dst_o
    ir.IRDst = dst_o
Example #24
0
File: sem.py Project: 0xf1sh/miasm
def blez(arg1, arg2):
    """Branches on @arg2 if the register @arg1 is less than or equal to zero"""
    cond = (i1(1) if arg1 else i1(0)) | arg1.msb()
    dst_o = arg2 if cond else ExprId(ir.get_next_break_label(instr))
    PC = dst_o
    ir.IRDst = dst_o
Example #25
0
def bc1t(arg1, arg2):
    dst_o = arg2 if arg1 else ExprId(ir.get_next_break_label(instr))
    PC = dst_o
    ir.IRDst = dst_o
Example #26
0
File: sem.py Project: vardyh/miasm
def bgez(ir, instr, a, b):
    e = []
    n = ExprId(ir.get_next_break_label(instr))
    dst_o = ExprCond(a.msb(), n, b)
    e = [ExprAff(PC, dst_o), ExprAff(ir.IRDst, dst_o)]
    return e, []
Example #27
0
def bgtz(arg1, arg2):
    """Branches on @arg2 if the register @arg1 is greater than zero"""
    cond = (i1(1) if arg1 else i1(0)) | arg1.msb()
    dst_o = ExprId(ir.get_next_break_label(instr)) if cond else arg2
    PC = dst_o
    ir.IRDst = dst_o
Example #28
0
def blez(arg1, arg2):
    """Branches on @arg2 if the register @arg1 is less than or equal to zero"""
    cond = (i1(1) if arg1 else i1(0)) | arg1.msb()
    dst_o = arg2 if cond else ExprId(ir.get_next_break_label(instr))
    PC = dst_o
    ir.IRDst = dst_o
Example #29
0
File: sem.py Project: 0xf1sh/miasm
def bal(arg1):
    PC = arg1
    ir.IRDst = arg1
    RA = ExprId(ir.get_next_break_label(instr))
Example #30
0
def bal(arg1):
    PC = arg1
    ir.IRDst = arg1
    RA = ExprId(ir.get_next_break_label(instr))
Example #31
0
File: sem.py Project: 0xf1sh/miasm
def jalr(arg1, arg2):
    """Jump to an address stored in a register @arg1, and store the return
    address in another register @arg2"""
    PC = arg1
    ir.IRDst = arg1
    arg2 = ExprId(ir.get_next_break_label(instr))
Example #32
0
def beq(arg1, arg2, arg3):
    "Branches on @arg3 if the quantities of two registers @arg1, @arg2 are eq"
    dst = ExprId(ir.get_next_break_label(instr)) if arg1 - arg2 else arg3
    PC = dst
    ir.IRDst = dst
Example #33
0
File: sem.py Project: 0xf1sh/miasm
def bc1t(arg1, arg2):
    dst_o = arg2 if arg1 else ExprId(ir.get_next_break_label(instr))
    PC = dst_o
    ir.IRDst = dst_o
Example #34
0
def bgez(arg1, arg2):
    """Branches on @arg2 if the quantities of register @arg1 is greater than or
    equal to zero"""
    dst = ExprId(ir.get_next_break_label(instr)) if arg1.msb() else arg2
    PC = dst
    ir.IRDst = dst
Example #35
0
File: sem.py Project: 0xf1sh/miasm
def jal(arg1):
    "Jumps to the calculated address @arg1 and stores the return address in $RA"
    PC = arg1
    ir.IRDst = arg1
    RA = ExprId(ir.get_next_break_label(instr))
Example #36
0
def bne(arg1, arg2, arg3):
    """Branches on @arg3 if the quantities of two registers @arg1, @arg2 are NOT
    equal"""
    dst = arg3 if arg1 - arg2 else ExprId(ir.get_next_break_label(instr))
    PC = dst
    ir.IRDst = dst
Example #37
0
def jal(arg1):
    "Jumps to the calculated address @arg1 and stores the return address in $RA"
    PC = arg1
    ir.IRDst = arg1
    RA = ExprId(ir.get_next_break_label(instr))
Example #38
0
File: sem.py Project: vardyh/miasm
def bne(ir, instr, a, b, c):
    e = []
    n = ExprId(ir.get_next_break_label(instr))
    dst_o = ExprCond(a - b, c, n)
    e = [ExprAff(PC, dst_o), ExprAff(ir.IRDst, dst_o)]
    return e, []
Example #39
0
def jalr(arg1, arg2):
    """Jump to an address stored in a register @arg1, and store the return
    address in another register @arg2"""
    PC = arg1
    ir.IRDst = arg1
    arg2 = ExprId(ir.get_next_break_label(instr))
Example #40
0
File: sem.py Project: 0xf1sh/miasm
def bltz(arg1, arg2):
    """Branches on @arg2 if the register @arg1 is less than zero"""
    dst_o = arg2 if arg1.msb() else ExprId(ir.get_next_break_label(instr))
    PC = dst_o
    ir.IRDst = dst_o