diff options
| author | Ajax <commial@gmail.com> | 2015-11-12 19:04:23 +0100 |
|---|---|---|
| committer | Ajax <commial@gmail.com> | 2015-11-12 19:04:23 +0100 |
| commit | f62aba88c71fc3c62ac4890e0237553c30a208e7 (patch) | |
| tree | b7da8a5194a23d21b9073e2cba4dab28c0d43070 | |
| parent | ab17bd233f0000e8e95295742db7d1e8cf8a722c (diff) | |
| download | miasm-f62aba88c71fc3c62ac4890e0237553c30a208e7.tar.gz miasm-f62aba88c71fc3c62ac4890e0237553c30a208e7.zip | |
x86/sem: use shift_tpl for shld
A refactor is needed, some comments are missing
Diffstat (limited to '')
| -rw-r--r-- | miasm2/arch/x86/sem.py | 25 |
1 files changed, 4 insertions, 21 deletions
diff --git a/miasm2/arch/x86/sem.py b/miasm2/arch/x86/sem.py index 9763b07c..aeb62531 100644 --- a/miasm2/arch/x86/sem.py +++ b/miasm2/arch/x86/sem.py @@ -468,7 +468,7 @@ def rcr(ir, instr, a, b): return e, [] -def _shift_tpl(op, ir, instr, a, b, c=None, op_inv=None): +def _shift_tpl(op, ir, instr, a, b, c=None, op_inv=None, left=False): """Template for generate shifter with operation @op A temporary basic block is generated to handle 0-shift @op: operation to execute @@ -493,6 +493,8 @@ def _shift_tpl(op, ir, instr, a, b, c=None, op_inv=None): # Overflow behavior if (shift / size % 2) cond_overflow = ((c - m2_expr.ExprInt(1, size=c.size)) & m2_expr.ExprInt(a.size, c.size)) + if left: + mask = ~mask mask = m2_expr.ExprCond(cond_overflow, ~mask, mask) # Build res with dst and src @@ -602,26 +604,7 @@ def shld_cl(ir, instr, a, b): def shld(ir, instr, a, b, c): - e = [] - shifter = c.zeroExtend(a.size) & m2_expr.ExprInt_from(a, 0x1f) - c = m2_expr.ExprOp('|', - a << shifter, - b >> (m2_expr.ExprInt_from(a, a.size) - shifter) - ) - - new_cf = (a >> (m2_expr.ExprInt_from(a, a.size) - shifter))[:1] - e.append(m2_expr.ExprAff(cf, m2_expr.ExprCond(shifter, - new_cf, - cf) - ) - ) - # XXX todo: don't update flag if shifter is 0 - e += update_flag_znp(c) - e.append(m2_expr.ExprAff(of, c.msb() ^ new_cf)) - e.append(m2_expr.ExprAff(a, m2_expr.ExprCond(shifter, - c, - a))) - return e, [] + return _shift_tpl("<<<", ir, instr, a, b, c, ">>>", left=True) # XXX todo ### |