diff options
| author | Camille Mougey <commial@gmail.com> | 2017-05-10 15:06:05 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-05-10 15:06:05 +0200 |
| commit | 3260f7867827195ea7c6ec37bc3a8687ce998f6d (patch) | |
| tree | eaba06d1e886a78c51cb342d635bfd083d252e3c /miasm2/ir/translators/python.py | |
| parent | 0904a50a1d6735ad7ae6720b9b09c9feddfcd92f (diff) | |
| parent | 32508138302e608bed354f6c6bf5e105877b4dac (diff) | |
| download | miasm-3260f7867827195ea7c6ec37bc3a8687ce998f6d.tar.gz miasm-3260f7867827195ea7c6ec37bc3a8687ce998f6d.zip | |
Merge pull request #550 from serpilliere/add_rot_pytrans
Add rot pytrans
Diffstat (limited to '')
| -rw-r--r-- | miasm2/ir/translators/python.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/miasm2/ir/translators/python.py b/miasm2/ir/translators/python.py index c06d865c..d7369e9e 100644 --- a/miasm2/ir/translators/python.py +++ b/miasm2/ir/translators/python.py @@ -1,3 +1,4 @@ +from miasm2.expression.expression import ExprInt from miasm2.ir.translators.translator import Translator @@ -55,6 +56,19 @@ class TranslatorPython(Translator): elif expr.op == "parity": return "(%s & 0x1)" % self.from_expr(expr.args[0]) + elif expr.op in ["<<<", ">>>"]: + amount_raw = expr.args[1] + amount = expr.args[1] % ExprInt(amount_raw.size, expr.size) + amount_inv = ExprInt(expr.size, expr.size) - amount + if expr.op == "<<<": + amount, amount_inv = amount_inv, amount + part1 = "(%s >> %s)"% (self.from_expr(expr.args[0]), + self.from_expr(amount)) + part2 = "(%s << %s)"% (self.from_expr(expr.args[0]), + self.from_expr(amount_inv)) + + return "((%s | %s) &0x%x)" % (part1, part2, int(expr.mask)) + raise NotImplementedError("Unknown operator: %s" % expr.op) def from_ExprAff(self, expr): |