Miasm2
 All Classes Namespaces Files Functions Variables Typedefs Properties Macros
jit.py
Go to the documentation of this file.
1 from miasm2.jitter.jitload import jitter
2 from miasm2.core import asmbloc
3 from miasm2.core.utils import *
4 
5 import logging
6 
7 log = logging.getLogger('jit_msp430')
8 hnd = logging.StreamHandler()
9 hnd.setFormatter(logging.Formatter("[%(levelname)s]: %(message)s"))
10 log.addHandler(hnd)
11 log.setLevel(logging.CRITICAL)
12 
14 
15  def __init__(self, *args, **kwargs):
16  from miasm2.arch.msp430.sem import ir_msp430
17  sp = asmbloc.asm_symbol_pool()
18  jitter.__init__(self, ir_msp430(sp), *args, **kwargs)
19  self.vm.set_little_endian()
20  self.ir_arch.jit_pc = self.ir_arch.arch.regs.PC
21 
22  def push_uint16_t(self, v):
23  regs = self.cpu.get_gpreg()
24  regs['SP'] -= 2
25  self.cpu.set_gpreg(regs)
26  self.vm.set_mem(regs['SP'], pck16(v))
27 
28  def pop_uint16_t(self):
29  regs = self.cpu.get_gpreg()
30  x = upck16(self.vm.get_mem(regs['SP'], 2))
31  regs['SP'] += 2
32  self.cpu.set_gpreg(regs)
33  return x
34 
35  def get_stack_arg(self, n):
36  regs = self.cpu.get_gpreg()
37  x = upck16(self.vm.get_mem(regs['SP'] + 2 * n, 2))
38  return x
39 
40  def init_run(self, *args, **kwargs):
41  jitter.init_run(self, *args, **kwargs)
42  self.cpu.PC = self.pc
43 
tuple upck16
Definition: utils.py:7
tuple pck16
Definition: utils.py:11