about summary refs log tree commit diff stats
path: root/miasm/arch/msp430/lifter_model_call.py
blob: 05f649e559fd193969537039bc86b7c2bedfe82e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#-*- coding:utf-8 -*-

from miasm.ir.analysis import LifterModelCall
from miasm.arch.msp430.sem import Lifter_MSP430
from miasm.ir.ir import AssignBlock
from miasm.expression.expression import *

class LifterModelCallMsp430Base(Lifter_MSP430, LifterModelCall):

    def __init__(self, loc_db):
        Lifter_MSP430.__init__(self, loc_db)
        self.ret_reg = self.arch.regs.R15

    def call_effects(self, addr, instr):
        call_assignblk = AssignBlock(
            [
                ExprAssign(self.ret_reg, ExprOp('call_func_ret', addr, self.sp, self.arch.regs.R15)),
                ExprAssign(self.sp, ExprOp('call_func_stack', addr, self.sp))
            ],
            instr
        )
        return [call_assignblk], []

class LifterModelCallMsp430(LifterModelCallMsp430Base):

    def __init__(self, loc_db):
        LifterModelCallMsp430Base.__init__(self, loc_db)

    def get_out_regs(self, _):
        return set([self.ret_reg, self.sp])