diff options
| author | ajax <devnull@localhost> | 2014-09-18 18:55:18 +0200 |
|---|---|---|
| committer | ajax <devnull@localhost> | 2014-09-18 18:55:18 +0200 |
| commit | acea1b8b5bfa8f23ef724f4392520d68c660399e (patch) | |
| tree | 1818db7634c32335a40aeb66905f9ca0ad29a56d | |
| parent | edd933fe4a8e985cb769ec44e8219e95d617590e (diff) | |
| download | miasm-acea1b8b5bfa8f23ef724f4392520d68c660399e.tar.gz miasm-acea1b8b5bfa8f23ef724f4392520d68c660399e.zip | |
x86 SEM: Fix loop off-by-one
| -rw-r--r-- | miasm2/arch/x86/sem.py | 27 |
1 files changed, 7 insertions, 20 deletions
diff --git a/miasm2/arch/x86/sem.py b/miasm2/arch/x86/sem.py index c304def6..46302de3 100644 --- a/miasm2/arch/x86/sem.py +++ b/miasm2/arch/x86/sem.py @@ -1340,10 +1340,10 @@ def loop(ir, instr, dst): n = ExprId(ir.get_next_label(instr), instr.mode) c = myecx - ExprInt_from(myecx, 1) + dst_o = ExprCond(c, dst, n).zeroExtend(instr.mode) e.append(ExprAff(myecx, c)) - e.append(ExprAff(meip, ExprCond(c, dst, n).zeroExtend(instr.mode))) - e.append(ExprAff(ir.IRDst, ExprCond(myecx, dst, n).zeroExtend(instr.mode))) - #dst_o = ExprCond(myecx, dst, n).zeroExtend(instr.mode) + e.append(ExprAff(meip, dst_o)) + e.append(ExprAff(ir.IRDst, dst_o)) return e, [] @@ -1362,15 +1362,9 @@ def loopne(ir, instr, dst): c &= zf ^ ExprInt1(1) e.append(ExprAff(myecx, myecx - ExprInt_from(myecx, 1))) - e.append(ExprAff(meip, ExprCond(c, dst, n).zeroExtend(instr.mode))) - - # for dst, ecx has been modified! - c = ExprCond(mRCX[instr.mode][:s], - ExprInt1(1), - ExprInt1(0)) - c &= zf ^ ExprInt1(1) - #dst_o = ExprCond(c, dst, n).zeroExtend(instr.mode) - e.append(ExprAff(ir.IRDst, ExprCond(c, dst, n).zeroExtend(instr.mode))) + dst_o = ExprCond(c, dst, n).zeroExtend(instr.mode) + e.append(ExprAff(meip, dst_o)) + e.append(ExprAff(ir.IRDst, dst_o)) return e, [] @@ -1389,14 +1383,7 @@ def loope(ir, instr, dst): e.append(ExprAff(myecx, myecx - ExprInt_from(myecx, 1))) dst_o = ExprCond(c, dst, n).zeroExtend(instr.mode) e.append(ExprAff(meip, dst_o)) - - # for dst, ecx has been modified! - c = ExprCond(mRCX[instr.mode][:s], - ExprInt1(1), - ExprInt1(0)) - c &= zf - #dst_o = ExprCond(c, dst, n).zeroExtend(instr.mode) - e.append(ExprAff(ir.IRDst, ExprCond(c, dst, n).zeroExtend(instr.mode))) + e.append(ExprAff(ir.IRDst, dst_o)) return e, [] |