diff options
| author | Camille Mougey <commial@gmail.com> | 2017-02-13 16:24:19 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-02-13 16:24:19 +0100 |
| commit | 90e170f45e342d03875e95b86afb038cb25ad2c1 (patch) | |
| tree | f26149c559b32c700a8d7fb7c2a74693229d9f58 /miasm2/arch | |
| parent | 827c6cb8e1cdcc6e501c319353f89615b9cc09c9 (diff) | |
| parent | a7c9a7f769094d0af3b7a98bdb7319bcb3921e11 (diff) | |
| download | miasm-90e170f45e342d03875e95b86afb038cb25ad2c1.tar.gz miasm-90e170f45e342d03875e95b86afb038cb25ad2c1.zip | |
Merge pull request #493 from serpilliere/fix_asm_parsing
Fix asm parsing
Diffstat (limited to '')
| -rw-r--r-- | miasm2/arch/aarch64/arch.py | 31 | ||||
| -rw-r--r-- | miasm2/arch/arm/arch.py | 8 | ||||
| -rw-r--r-- | miasm2/arch/mips32/arch.py | 8 | ||||
| -rw-r--r-- | miasm2/arch/msp430/arch.py | 8 | ||||
| -rw-r--r-- | miasm2/arch/sh4/arch.py | 8 | ||||
| -rw-r--r-- | miasm2/arch/x86/arch.py | 8 |
6 files changed, 23 insertions, 48 deletions
diff --git a/miasm2/arch/aarch64/arch.py b/miasm2/arch/aarch64/arch.py index c875d787..460c134e 100644 --- a/miasm2/arch/aarch64/arch.py +++ b/miasm2/arch/aarch64/arch.py @@ -74,34 +74,29 @@ _, _, base_expr64 = gen_base_expr() def ast_id2expr32(t): - if not t in mn_aarch64.regs.all_regs_ids_byname: - r = m2_expr.ExprId(asm_label(t)) - else: - r = mn_aarch64.regs.all_regs_ids_byname[t] - if not r.size == 32: - raise StopIteration - return r - + if t in mn_aarch64.regs.all_regs_ids_byname: + t = mn_aarch64.regs.all_regs_ids_byname[t] + if not t.size == 32: + raise StopIteration + return t def ast_int2expr32(a): return m2_expr.ExprInt32(a) def ast_id2expr64(t): - if not t in mn_aarch64.regs.all_regs_ids_byname: - r = m2_expr.ExprId(asm_label(t)) - else: - r = mn_aarch64.regs.all_regs_ids_byname[t] - if not r.size == 64: - raise StopIteration - return r + if t in mn_aarch64.regs.all_regs_ids_byname: + t = mn_aarch64.regs.all_regs_ids_byname[t] + if not t.size == 64: + raise StopIteration + return t def ast_int2expr64(a): return m2_expr.ExprInt64(a) -my_var_parser32 = parse_ast(ast_id2expr32, ast_int2expr32) -my_var_parser64 = parse_ast(ast_id2expr64, ast_int2expr64) +my_var_parser32 = ParseAst(ast_id2expr32, ast_int2expr32, default_size=32) +my_var_parser64 = ParseAst(ast_id2expr64, ast_int2expr64, default_size=64) base_expr32.setParseAction(my_var_parser32) base_expr64.setParseAction(my_var_parser64) @@ -234,7 +229,7 @@ simds_info = {8: simd08_info, 128: simd128_info} -my_var_parser = parse_ast(ast_id2expr, ast_int2expr) +my_var_parser = ParseAst(ast_id2expr, ast_int2expr) base_expr.setParseAction(my_var_parser) diff --git a/miasm2/arch/arm/arch.py b/miasm2/arch/arm/arch.py index 0e58008d..d9bf42ba 100644 --- a/miasm2/arch/arm/arch.py +++ b/miasm2/arch/arm/arch.py @@ -181,18 +181,14 @@ int_or_expr = base_expr def ast_id2expr(t): - if not t in mn_arm.regs.all_regs_ids_byname: - r = ExprId(asm_label(t)) - else: - r = mn_arm.regs.all_regs_ids_byname[t] - return r + return mn_arm.regs.all_regs_ids_byname.get(t, t) def ast_int2expr(a): return ExprInt32(a) -my_var_parser = parse_ast(ast_id2expr, ast_int2expr) +my_var_parser = ParseAst(ast_id2expr, ast_int2expr) base_expr.setParseAction(my_var_parser) diff --git a/miasm2/arch/mips32/arch.py b/miasm2/arch/mips32/arch.py index 2ac16770..79176205 100644 --- a/miasm2/arch/mips32/arch.py +++ b/miasm2/arch/mips32/arch.py @@ -53,18 +53,14 @@ int_or_expr = base_expr def ast_id2expr(t): - if not t in mn_mips32.regs.all_regs_ids_byname: - r = ExprId(asm_label(t)) - else: - r = mn_mips32.regs.all_regs_ids_byname[t] - return r + return mn_mips32.regs.all_regs_ids_byname.get(t, t) def ast_int2expr(a): return ExprInt32(a) -my_var_parser = cpu.parse_ast(ast_id2expr, ast_int2expr) +my_var_parser = cpu.ParseAst(ast_id2expr, ast_int2expr) base_expr.setParseAction(my_var_parser) class additional_info: diff --git a/miasm2/arch/msp430/arch.py b/miasm2/arch/msp430/arch.py index a9f695ec..d7463f3d 100644 --- a/miasm2/arch/msp430/arch.py +++ b/miasm2/arch/msp430/arch.py @@ -72,11 +72,7 @@ PINC = Suppress("+") def ast_id2expr(t): - if not t in mn_msp430.regs.all_regs_ids_byname: - r = ExprId(asm_label(t), 16) - else: - r = mn_msp430.regs.all_regs_ids_byname[t] - return r + return mn_msp430.regs.all_regs_ids_byname.get(t, t) def ast_int2expr(a): @@ -85,7 +81,7 @@ def ast_int2expr(a): variable, operand, base_expr = gen_base_expr() -my_var_parser = parse_ast(ast_id2expr, ast_int2expr) +my_var_parser = ParseAst(ast_id2expr, ast_int2expr) base_expr.setParseAction(my_var_parser) diff --git a/miasm2/arch/sh4/arch.py b/miasm2/arch/sh4/arch.py index d72e6945..ae96fef1 100644 --- a/miasm2/arch/sh4/arch.py +++ b/miasm2/arch/sh4/arch.py @@ -36,17 +36,13 @@ def parse_pcandimmimm(t): return (t[0] & t[1]) + t[2] def ast_id2expr(t): - if not t in mn_sh4.regs.all_regs_ids_byname: - r = ExprId(asm_label(t)) - else: - r = mn_sh4.regs.all_regs_ids_byname[t] - return r + return mn_sh4.regs.all_regs_ids_byname.get(t, t) def ast_int2expr(a): return ExprInt32(a) -my_var_parser = parse_ast(ast_id2expr, ast_int2expr) +my_var_parser = ParseAst(ast_id2expr, ast_int2expr) base_expr.setParseAction(my_var_parser) int_or_expr = base_expr diff --git a/miasm2/arch/x86/arch.py b/miasm2/arch/x86/arch.py index 20fdc1cf..8ae6cd31 100644 --- a/miasm2/arch/x86/arch.py +++ b/miasm2/arch/x86/arch.py @@ -223,18 +223,14 @@ variable, operand, base_expr = gen_base_expr() def ast_id2expr(t): - if not t in mn_x86.regs.all_regs_ids_byname: - r = ExprId(asm_label(t)) - else: - r = mn_x86.regs.all_regs_ids_byname[t] - return r + return mn_x86.regs.all_regs_ids_byname.get(t, t) def ast_int2expr(a): return ExprInt64(a) -my_var_parser = parse_ast(ast_id2expr, ast_int2expr) +my_var_parser = ParseAst(ast_id2expr, ast_int2expr) base_expr.setParseAction(my_var_parser) int_or_expr = base_expr |