diff options
Diffstat (limited to 'miasm/arch/msp430/arch.py')
| -rw-r--r-- | miasm/arch/msp430/arch.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/miasm/arch/msp430/arch.py b/miasm/arch/msp430/arch.py index 8d208d26..dbe93fd2 100644 --- a/miasm/arch/msp430/arch.py +++ b/miasm/arch/msp430/arch.py @@ -11,6 +11,7 @@ from miasm.core.bin_stream import bin_stream import miasm.arch.msp430.regs as regs_module from miasm.arch.msp430.regs import * from miasm.core.asm_ast import AstInt, AstId, AstMem, AstOp +from miasm.ir.ir import color_expr_html log = logging.getLogger("msp430dis") console_handler = logging.StreamHandler() @@ -130,6 +131,29 @@ class instruction_msp430(instruction): raise NotImplementedError('unknown instance expr = %s' % type(expr)) return o + @staticmethod + def arg2html(expr, index=None, loc_db=None): + if isinstance(expr, ExprId) or isinstance(expr, ExprInt) or expr.is_loc(): + return color_expr_html(expr, loc_db) + elif isinstance(expr, ExprOp) and expr.op == "autoinc": + o = "@%s+" % color_expr_html(expr.args[0], loc_db) + elif isinstance(expr, ExprMem): + if isinstance(expr.ptr, ExprId): + if index == 0: + o = "@%s" % color_expr_html(expr.ptr, loc_db) + else: + o = "0x0(%s)" % color_expr_html(expr.ptr, loc_db) + elif isinstance(expr.ptr, ExprInt): + o = "@%s" % color_expr_html(expr.ptr, loc_db) + elif isinstance(expr.ptr, ExprOp): + o = "%s(%s)" % ( + color_expr_html(expr.ptr.args[1], loc_db), + color_expr_html(expr.ptr.args[0], loc_db) + ) + else: + raise NotImplementedError('unknown instance expr = %s' % type(expr)) + return o + def dstflow2label(self, loc_db): expr = self.args[0] |