about summary refs log tree commit diff stats
path: root/miasm2/jitter/codegen.py
diff options
context:
space:
mode:
authorAjax <commial@gmail.com>2018-05-17 10:51:28 +0200
committerAjax <commial@gmail.com>2018-05-17 10:51:28 +0200
commit18ac4b21a484265ff50f400ad400a6f028038455 (patch)
tree0a5f5ae8b99907e8123225193a17614b0066fc96 /miasm2/jitter/codegen.py
parentf01c7ffbc51c2b9a08b0d2a2efce26a23ef3268a (diff)
downloadmiasm-18ac4b21a484265ff50f400ad400a6f028038455.tar.gz
miasm-18ac4b21a484265ff50f400ad400a6f028038455.zip
Add support for 128 bits operations in VmMngr and GCC outputs
Diffstat (limited to 'miasm2/jitter/codegen.py')
-rw-r--r--miasm2/jitter/codegen.py11
1 files changed, 5 insertions, 6 deletions
diff --git a/miasm2/jitter/codegen.py b/miasm2/jitter/codegen.py
index 2c546be8..b10a9257 100644
--- a/miasm2/jitter/codegen.py
+++ b/miasm2/jitter/codegen.py
@@ -10,9 +10,8 @@ from miasm2.core.asmblock import expr_is_label, AsmBlockBad, AsmLabel
 # Miasm to C translator
 TRANSLATOR = Translator.to_language("C")
 
-SIZE_TO_MASK = {x: 2**x - 1 for x in (1, 2, 3, 7, 8, 16, 32, 64)}
-
-MASK_INT = 0xffffffffffffffff
+SIZE_TO_MASK = {size: TRANSLATOR.from_expr(m2_expr.ExprInt(0, size).mask)
+                for size in (1, 2, 3, 7, 8, 16, 32, 64, 128)}
 
 
 class Attributes(object):
@@ -246,9 +245,9 @@ class CGen(object):
                         '%s = (%s);' % (self.id_to_c(new_dst), self.id_to_c(src)))
                 else:
                     c_main.append(
-                        '%s = (%s)&0x%X;' % (self.id_to_c(new_dst),
-                                             self.id_to_c(src),
-                                             SIZE_TO_MASK[src.size]))
+                        '%s = (%s)&%s;' % (self.id_to_c(new_dst),
+                                           self.id_to_c(src),
+                                           SIZE_TO_MASK[src.size]))
             elif isinstance(dst, m2_expr.ExprMem):
                 ptr = dst.arg.replace_expr(prefetchers)
                 new_dst = m2_expr.ExprMem(ptr, dst.size)