diff options
| author | serpilliere <devnull@localhost> | 2014-07-11 16:47:55 +0200 |
|---|---|---|
| committer | serpilliere <devnull@localhost> | 2014-07-11 16:47:55 +0200 |
| commit | 2342e243c9a5ef398c0f4faa05da9439e2e4949a (patch) | |
| tree | b20af0fb969cc09a94a88b1221d870445bacd633 | |
| parent | 3062bd79e992c0a31d54988d768ebf7e606e36c3 (diff) | |
| download | miasm-2342e243c9a5ef398c0f4faa05da9439e2e4949a.tar.gz miasm-2342e243c9a5ef398c0f4faa05da9439e2e4949a.zip | |
x86 sem: fix bts cast bug and lookup semantic
| -rw-r--r-- | miasm2/arch/x86/sem.py | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/miasm2/arch/x86/sem.py b/miasm2/arch/x86/sem.py index 8dfd6883..10a5b291 100644 --- a/miasm2/arch/x86/sem.py +++ b/miasm2/arch/x86/sem.py @@ -2405,16 +2405,18 @@ def cpuid(ir, instr): def bittest_get(a, b): b = b.zeroExtend(a.size) if isinstance(a, ExprMem): - off_bit = ExprOp('&', b, ExprInt_from(a, a.size - 1)) - off_byte = (b >> ExprInt_from(a, 3)) & \ - ExprOp('!', ExprInt_from(a, a.size / 8 - 1)) - - d = ExprMem(a.arg + off_byte, a.size) - # d = ExprOp('>>', mem, off_bit) + b_mask = {16:4, 32:5, 64:6} + b_decal = {16:1, 32:3, 64:7} + ptr = a.arg + off_bit = b.zeroExtend(a.size) & ExprInt_fromsize(a.size, + (1<<b_mask[a.size])-1) + off_byte = ((b.zeroExtend(ptr.size) >> ExprInt_from(ptr, 3)) & + ExprInt_from(ptr, ((1<<a.size)-1) ^ b_decal[a.size])) + + d = ExprMem(ptr + off_byte, a.size) else: off_bit = ExprOp('&', b, ExprInt_from(a, a.size - 1)) d = a - # d = ExprOp('>>', a, off_bit) return d, off_bit |