diff options
| author | serpilliere <devnull@localhost> | 2012-05-10 13:37:37 +0200 |
|---|---|---|
| committer | serpilliere <devnull@localhost> | 2012-05-10 13:37:37 +0200 |
| commit | 1380aa2b0b8d5376e5825302a851ee40edc8ffed (patch) | |
| tree | 762cfa2b94af7be923a0c07a564ccc08a01e1092 | |
| parent | 95bd3b169b1f9bb44bc0a73c95f5b3a0e720efad (diff) | |
| download | miasm-1380aa2b0b8d5376e5825302a851ee40edc8ffed.tar.gz miasm-1380aa2b0b8d5376e5825302a851ee40edc8ffed.zip | |
replace operator ! by operator ~; fix reload_expr
Diffstat (limited to '')
| -rw-r--r-- | miasm/arch/ia32_sem.py | 8 | ||||
| -rw-r--r-- | miasm/expression/expression.py | 21 | ||||
| -rw-r--r-- | miasm/tools/to_c_helper.py | 1 |
3 files changed, 20 insertions, 10 deletions
diff --git a/miasm/arch/ia32_sem.py b/miasm/arch/ia32_sem.py index 3800ffce..26ea207b 100644 --- a/miasm/arch/ia32_sem.py +++ b/miasm/arch/ia32_sem.py @@ -444,10 +444,10 @@ def arith_flag(a, b, c): #checked: ok for adc add because of b & c before +cf def update_flag_add_cf(cast_int, a, b, c): - return ExprAff(cf, get_op_msb((a ^ b) ^ c) ^ get_op_msb((a ^ c) & ExprOp('!', (a ^ b)))) + return ExprAff(cf, get_op_msb((a ^ b) ^ c) ^ get_op_msb((a ^ c) & (~(a ^ b)))) def update_flag_add_of(cast_int, a, b, c): - return ExprAff(of, get_op_msb(((a ^ c) & ExprOp('!', (a ^ b))))) + return ExprAff(of, get_op_msb(((a ^ c) & (~(a ^ b))))) #checked: ok for sbb add because of b & c before +cf @@ -578,7 +578,7 @@ def neg(info, b): def l_not(info, b): e= [] cast_int = tab_uintsize[b.get_size()] - c = ExprOp('!', b) + c = ~b e.append(ExprAff(b, c)) return e @@ -2068,7 +2068,7 @@ def btr(info, a, b): e= [] c= ExprOp('&', b, ExprInt(cast_int(b.get_size() - 1))) d= ExprOp('>>', a, c) - m= ExprOp('!', ExprOp('<<', ExprInt(cast_int(1)), b)) + m= ~ExprOp('<<', ExprInt(cast_int(1)), b) e.append(ExprAff(cf, ExprOp('&', d, ExprInt(cast_int(1))))) e.append(ExprAff(a, ExprOp('&', a, m))) return e diff --git a/miasm/expression/expression.py b/miasm/expression/expression.py index e538b784..45d1dc66 100644 --- a/miasm/expression/expression.py +++ b/miasm/expression/expression.py @@ -29,6 +29,12 @@ def slice_rest(size, start, stop): return rest +size2type ={8:uint8, + 16:uint16, + 32:uint32, + 64:uint64 + } + tab_int_size = {int8:8, uint8:8, int16:16, @@ -109,6 +115,11 @@ class Expr: return ExprOp('|', self, a) def __and__(self, a): return ExprOp('&', self, a) + def __neg__(self): + fds + def __invert__(self): + s = self.get_size() + return ExprOp('^', self, ExprInt(size2type[s](my_size_mask[s]))) class ExprTop(Expr): def __init__(self, e=None): @@ -318,7 +329,7 @@ class ExprMem(Expr): segm = self.segm if isinstance(segm, Expr): segm = self.segm.reload_expr(g) - return ExprMem(arg, self.size, self.segm) + return ExprMem(arg, self.size, segm) def __contains__(self, e): return self == e or self.arg.__contains__(e) def __eq__(self, a): @@ -575,7 +586,7 @@ class ExprCompose(Expr): return g[self] args = [] for a in self.args: - args.append(a[0].reload_expr(g), a[1], a[2]) + args.append((a[0].reload_expr(g), a[1], a[2])) return ExprCompose(args ) def __contains__(self, e): if self == e: @@ -604,9 +615,9 @@ class ExprCompose(Expr): out = [] # XXX check mask for 64 bit & 32 bit compat for x in self.args: - o.append("((%s & %X) << %d)"%(x[0].toC(), - (1<<(x[2]-x[1]))-1, - x[1])) + out.append("((%s & 0x%X) << %d)"%(x[0].toC(), + (1<<(x[2]-x[1]))-1, + x[1])) out = ' | '.join(out) return '('+out+')' def canonize(self): diff --git a/miasm/tools/to_c_helper.py b/miasm/tools/to_c_helper.py index b7b387df..3fa44b99 100644 --- a/miasm/tools/to_c_helper.py +++ b/miasm/tools/to_c_helper.py @@ -141,7 +141,6 @@ my_C_id = [ float_address , float_ds , #cond, - ds, #vm_exception_flags, #vm_exception_flags_new, #vm_last_write_ad, |