14 return int(
"%x" % val, 10)
16 raise NotImplementedError(
"Not defined behaviour")
20 "Return the hex value of a BCD"
22 return int(
"0x%d" % val, 16)
24 raise NotImplementedError(
"Not defined behaviour")
57 ((((a ^ b) ^ c) ^ ((a ^ c) & (a ^ b))).msb()) ^
ExprInt1(1))]
61 return [
ExprAff(cf, (((a ^ b) ^ c) ^ ((a ^ c) & (~(a ^ b)))).msb())]
65 return [
ExprAff(of, (((a ^ c) & (~(a ^ b)))).msb())]
69 return [
ExprAff(of, (((a ^ c) & (a ^ b))).msb())]
74 if not (isinstance(a, ExprOp)
and a.op ==
"autoinc"):
80 if isinstance(b, ExprMem)
and a_r
in b.arg:
89 if isinstance(b, ExprMem):
93 a = a[:8].zeroExtend(16)
109 e.append(
ExprAff(b, c.zeroExtend(16)))
128 c = (a[:8] ^
ExprInt8(0xff)) & b[:8]
129 c = c.zeroExtend(b.size)
157 def sub_b(ir, instr, a, b):
158 e, a, b = mng_autoinc(a, b, 8)
160 e.append(ExprAff(b, c))
161 e += update_flag_zn_r(c)
162 e += update_flag_sub_cf(b, a, c)
181 if isinstance(b, ExprMem):
207 c =
ExprOp(
"bcdadd", b, a)
229 e.append(
ExprAff(of, b.msb() & a.msb()))
242 n =
ExprId(ir.get_next_label(instr), 16)
252 x, y = a[:8], a[8:16]
276 def jz(ir, instr, a):
277 n =
ExprId(ir.get_next_label(instr), 16)
285 n =
ExprId(ir.get_next_label(instr), 16)
292 def jl(ir, instr, a):
293 n =
ExprId(ir.get_next_label(instr), 16)
300 def jc(ir, instr, a):
301 n =
ExprId(ir.get_next_label(instr), 16)
309 n =
ExprId(ir.get_next_label(instr), 16)
317 n =
ExprId(ir.get_next_label(instr), 16)
368 c = a[:8].signExtend(16)
425 for x, start, stop
in dst.args:
426 e.append(
ExprAff(x, src[start:stop]))
433 ir.__init__(self, mn_msp430,
None, symbol_pool)
438 def mod_pc(self, instr, instr_ir, extra_ir):
444 instr_ir, extra_ir = mnemo_func[instr.name](self, instr, *args)
445 self.mod_sr(instr, instr_ir, extra_ir)
447 return instr_ir, extra_ir
449 def mod_sr(self, instr, instr_ir, extra_ir):
450 for i, x
in enumerate(instr_ir):
451 x =
ExprAff(x.dst, x.src.replace_expr({SR: composed_sr}))
457 for i, x
in enumerate(instr_ir):
458 x =
ExprAff(x.dst, x.src.replace_expr(
463 raise NotImplementedError(
'not fully functional')
def update_flag_cf_inv_zf