diff options
| author | serpilliere <devnull@localhost> | 2014-06-12 22:14:26 +0200 |
|---|---|---|
| committer | serpilliere <devnull@localhost> | 2014-06-12 22:14:26 +0200 |
| commit | 24b677448d875d408c1fff038bed27d2b223a3da (patch) | |
| tree | 06e95a70a7ae014fde33364ae67c3f785d3c48a3 /miasm2/arch/x86/sem.py | |
| parent | 1b69d0f86c340febf781d9284a87e447b40ee3ba (diff) | |
| parent | a635b0185b9fe26453ceedb5d56aa9d59503b695 (diff) | |
| download | miasm-24b677448d875d408c1fff038bed27d2b223a3da.tar.gz miasm-24b677448d875d408c1fff038bed27d2b223a3da.zip | |
merge; fix x86 ror/rol
rol ror mask shifter in semantic instead of in expr_simpl
Diffstat (limited to 'miasm2/arch/x86/sem.py')
| -rw-r--r-- | miasm2/arch/x86/sem.py | 43 |
1 files changed, 22 insertions, 21 deletions
diff --git a/miasm2/arch/x86/sem.py b/miasm2/arch/x86/sem.py index 4b8a357b..f85a6bcf 100644 --- a/miasm2/arch/x86/sem.py +++ b/miasm2/arch/x86/sem.py @@ -314,10 +314,22 @@ def l_test(ir, instr, a, b): return None, e, [] + +def get_shift(a, b): + # b.size must match a + b = b.zeroExtend(a.size) + if a.size == 64: + shift = b & ExprInt_from(b, 0x3f) + else: + shift = b & ExprInt_from(b, 0x1f) + shift = expr_simp(shift) + return shift + + def l_rol(ir, instr, a, b): e = [] - b = b.zeroExtend(a.size) - c = ExprOp('<<<', a, b) + shifter = get_shift(a, b) + c = ExprOp('<<<', a, shifter) new_cf = c[:1] e.append(ExprAff(cf, new_cf)) @@ -329,8 +341,8 @@ def l_rol(ir, instr, a, b): def l_ror(ir, instr, a, b): e = [] - b = b.zeroExtend(a.size) - c = ExprOp('>>>', a, b) + shifter = get_shift(a, b) + c = ExprOp('>>>', a, shifter) e.append(ExprAff(cf, c.msb())) # hack (only valid if b=1): when count == 1: a = msb-1(dest) @@ -341,9 +353,9 @@ def l_ror(ir, instr, a, b): def rcl(ir, instr, a, b): e = [] - b = b.zeroExtend(a.size) - c = ExprOp('<<<c_rez', a, b, cf.zeroExtend(a.size)) - new_cf = ExprOp('<<<c_cf', a, b, cf.zeroExtend(a.size))[:1] + shifter = get_shift(a, b) + c = ExprOp('<<<c_rez', a, shifter, cf.zeroExtend(a.size)) + new_cf = ExprOp('<<<c_cf', a, shifter, cf.zeroExtend(a.size))[:1] e.append(ExprAff(cf, new_cf)) # hack (only valid if b=1) @@ -354,9 +366,9 @@ def rcl(ir, instr, a, b): def rcr(ir, instr, a, b): e = [] - b = b.zeroExtend(a.size) - c = ExprOp('>>>c_rez', a, b, cf.zeroExtend(a.size)) - new_cf = ExprOp('>>>c_cf', a, b, cf.zeroExtend(a.size))[:1] + shifter = get_shift(a, b) + c = ExprOp('>>>c_rez', a, shifter, cf.zeroExtend(a.size)) + new_cf = ExprOp('>>>c_cf', a, shifter, cf.zeroExtend(a.size))[:1] e.append(ExprAff(cf, new_cf)) # hack (only valid if b=1) @@ -366,17 +378,6 @@ def rcr(ir, instr, a, b): return None, e, [] -def get_shift(a, b): - # b.size must match a - b = b.zeroExtend(a.size) - if a.size == 64: - shift = b & ExprInt_from(b, 0x3f) - else: - shift = b & ExprInt_from(b, 0x1f) - shift = expr_simp(shift) - return shift - - def sar(ir, instr, a, b): shifter = get_shift(a, b) |