diff options
| author | Camille Mougey <commial@gmail.com> | 2019-03-07 14:37:07 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-03-07 14:37:07 +0100 |
| commit | 4c2320b46250a8d6f8774e1218544b72a154cd8e (patch) | |
| tree | b67e7b072439f84109bd39dad8ed7f3f135224f8 /test/arch/x86/sem.py | |
| parent | eab809932871f91d6f4aa770fc321af9e156e0f5 (diff) | |
| parent | 26c1075723a02984da6d3bc7423c5c0c43082dc3 (diff) | |
| download | miasm-4c2320b46250a8d6f8774e1218544b72a154cd8e.tar.gz miasm-4c2320b46250a8d6f8774e1218544b72a154cd8e.zip | |
Merge pull request #990 from serpilliere/support_python2_python3
Support python2 python3
Diffstat (limited to 'test/arch/x86/sem.py')
| -rwxr-xr-x | test/arch/x86/sem.py | 37 |
1 files changed, 22 insertions, 15 deletions
diff --git a/test/arch/x86/sem.py b/test/arch/x86/sem.py index 0783089d..5109d2b4 100755 --- a/test/arch/x86/sem.py +++ b/test/arch/x86/sem.py @@ -3,18 +3,23 @@ # Loosely based on ARM's sem.py +from __future__ import print_function +from builtins import range + +from future.utils import viewitems + import unittest import logging import copy -from miasm2.ir.symbexec import SymbolicExecutionEngine -from miasm2.arch.x86.arch import mn_x86 as mn -from miasm2.arch.x86.sem import ir_x86_32 as ir_32, ir_x86_64 as ir_64 -from miasm2.arch.x86.regs import * -from miasm2.expression.expression import * -from miasm2.expression.simplifications import expr_simp -from miasm2.core import parse_asm, asmblock -from miasm2.core.locationdb import LocationDB +from miasm.ir.symbexec import SymbolicExecutionEngine +from miasm.arch.x86.arch import mn_x86 as mn +from miasm.arch.x86.sem import ir_x86_32 as ir_32, ir_x86_64 as ir_64 +from miasm.arch.x86.regs import * +from miasm.expression.expression import * +from miasm.expression.simplifications import expr_simp +from miasm.core import parse_asm, asmblock +from miasm.core.locationdb import LocationDB logging.getLogger('cpuhelper').setLevel(logging.ERROR) @@ -30,11 +35,13 @@ def symb_exec(lbl, ir_arch, ircfg, inputstate, debug): symexec = SymbolicExecutionEngine(ir_arch, sympool) symexec.run_at(ircfg, lbl) if debug: - for k, v in symexec.symbols.items(): + for k, v in viewitems(symexec.symbols): if regs_init.get(k, None) != v: - print k, v - return {k: v for k, v in symexec.symbols.items() - if k not in EXCLUDE_REGS and regs_init.get(k, None) != v} + print(k, v) + return { + k: v for k, v in viewitems(symexec.symbols) + if k not in EXCLUDE_REGS and regs_init.get(k, None) != v + } def compute(ir, mode, asm, inputstate={}, debug=False): loc_db = LocationDB() @@ -60,7 +67,7 @@ def compute_txt(ir, mode, txt, inputstate={}, debug=False): op_add = lambda a, b: a+b op_sub = lambda a, b: a-b op_mul = lambda a, b: a*b -op_div = lambda a, b: a/b +op_div = lambda a, b: a //b op_and = lambda a, b: a&b op_or = lambda a, b: a|b @@ -72,8 +79,8 @@ def int_vec_op(op, elt_size, reg_size, arg1, arg2): assert(reg_size % elt_size == 0) ret = 0 mask = (1<<elt_size)-1 - nelts = reg_size/elt_size - for i in xrange(0, nelts): + nelts = reg_size // elt_size + for i in range(0, nelts): ret |= (op(arg1 & mask, arg2 & mask) & mask) << (i*elt_size) arg1 >>= elt_size arg2 >>= elt_size |