angr_platforms/msp430/instrs_msp430.py
def fetch_reg(self, reg_num, reg_mode, imm, ty):
        """
        Resolve the operand for register-based modes.
        :param reg_num: The Register Number
        :param reg_mode: The Register Mode
        :param imm: The immediate word, if any
        :param ty: The Type (byte or word)
        :return: The VexValue of the operand, and the writeout function, if any.
        """
        # Boring register mode.  A write is just a Put.
        if reg_mode == ArchMSP430.Mode.REGISTER_MODE:
            # Fetch the register
            reg_vv = self.get(reg_num, ty)
            val = reg_vv
            writeout = lambda v: self.put(v.cast_to(REGISTER_TYPE), reg_num)
        # Indexed mode, add the immediate to the register
        # A write here is a store to reg + imm
        elif reg_mode == ArchMSP430.Mode.INDEXED_MODE:
            # Fetch the register
            reg_vv = self.get(reg_num, REGISTER_TYPE)
            addr_val = reg_vv + imm
            val = self.load(addr_val, ty)
            writeout = lambda v: self.store(v, addr_val)
        # Indirect mode; fetch address in register; store is a write there.
        elif reg_mode == ArchMSP430.Mode.INDIRECT_REGISTER_MODE:
            # Fetch the register
            reg_vv = self.get(reg_num, REGISTER_TYPE)
            val = self.load(reg_vv, ty)
            writeout = lambda v: self.store(v, reg_vv)
        # Indirect Autoincrement mode. Increment the register by the type size, then access it
        elif reg_mode == ArchMSP430.Mode.INDIRECT_AUTOINCREMENT_MODE:
            if ty == Type.int_16:
                incconst = self.constant(2, REGISTER_TYPE)
            else:
                incconst = self.constant(1, REGISTER_TYPE)
            # Fetch the register
            reg_vv = self.get(reg_num, REGISTER_TYPE)
            # Do the increment, now
            self.put(reg_vv + incconst, reg_num)
            # Now load it.
            val = self.load(reg_vv, ty)
            writeout = lambda v: self.store(v, reg_num)
        elif reg_mode == ArchMSP430.Mode.ABSOLUTE_MODE:
            imm_vv = self.constant(imm, REGISTER_TYPE)
            val = self.load(imm_vv, ty)
            writeout = lambda v: self.store(v, imm_vv)
        else:
            raise Exception('Unknown mode found')
        return val, writeout

        Resolve the operand for register-based modes.
        :param reg_num: The Register Number
        :param reg_mode: The Register Mode
        :param imm: The immediate word, if any
        :param ty: The Type (byte or word)
        :return: The VexValue of the operand, and the writeout function, if any.
        
Resolve the operand for register-based modes.
Resolve the operand for register - based modes .
def fetch_reg(self, reg_num, reg_mode, imm, ty):
        if reg_mode == ArchMSP430.Mode.REGISTER_MODE:
            reg_vv = self.get(reg_num, ty)
            val = reg_vv
            writeout = lambda v: self.put(v.cast_to(REGISTER_TYPE), reg_num)
        elif reg_mode == ArchMSP430.Mode.INDEXED_MODE:
            reg_vv = self.get(reg_num, REGISTER_TYPE)
            addr_val = reg_vv + imm
            val = self.load(addr_val, ty)
            writeout = lambda v: self.store(v, addr_val)
        elif reg_mode == ArchMSP430.Mode.INDIRECT_REGISTER_MODE:
            reg_vv = self.get(reg_num, REGISTER_TYPE)
            val = self.load(reg_vv, ty)
            writeout = lambda v: self.store(v, reg_vv)
        elif reg_mode == ArchMSP430.Mode.INDIRECT_AUTOINCREMENT_MODE:
            if ty == Type.int_16:
                incconst = self.constant(2, REGISTER_TYPE)
            else:
                incconst = self.constant(1, REGISTER_TYPE)
            reg_vv = self.get(reg_num, REGISTER_TYPE)
            self.put(reg_vv + incconst, reg_num)
            val = self.load(reg_vv, ty)
            writeout = lambda v: self.store(v, reg_num)
        elif reg_mode == ArchMSP430.Mode.ABSOLUTE_MODE:
            imm_vv = self.constant(imm, REGISTER_TYPE)
            val = self.load(imm_vv, ty)
            writeout = lambda v: self.store(v, imm_vv)
        else:
            raise Exception('Unknown mode found')
        return val, writeout
def fetch_reg ( self , reg_num , reg_mode , imm , ty ) : if reg_mode == ArchMSP430 . Mode . REGISTER_MODE : reg_vv = self . get ( reg_num , ty ) val = reg_vv writeout = lambda v : self . put ( v . cast_to ( REGISTER_TYPE ) , reg_num ) elif reg_mode == ArchMSP430 . Mode . INDEXED_MODE : reg_vv = self . get ( reg_num , REGISTER_TYPE ) addr_val = reg_vv + imm val = self . load ( addr_val , ty ) writeout = lambda v : self . store ( v , addr_val ) elif reg_mode == ArchMSP430 . Mode . INDIRECT_REGISTER_MODE : reg_vv = self . get ( reg_num , REGISTER_TYPE ) val = self . load ( reg_vv , ty ) writeout = lambda v : self . store ( v , reg_vv ) elif reg_mode == ArchMSP430 . Mode . INDIRECT_AUTOINCREMENT_MODE : if ty == Type . int_16 : incconst = self . constant ( 2 , REGISTER_TYPE ) else : incconst = self . constant ( 1 , REGISTER_TYPE ) reg_vv = self . get ( reg_num , REGISTER_TYPE ) self . put ( reg_vv + incconst , reg_num ) val = self . load ( reg_vv , ty ) writeout = lambda v : self . store ( v , reg_num ) elif reg_mode == ArchMSP430 . Mode . ABSOLUTE_MODE : imm_vv = self . constant ( imm , REGISTER_TYPE ) val = self . load ( imm_vv , ty ) writeout = lambda v : self . store ( v , imm_vv ) else : raise Exception ( 'Unknown mode found' ) return val , writeout
Resolve the operand for register-based modes.
Resolve the operand for register - based modes .
"""
        Resolve the operand for register-based modes.
        :param reg_num: The Register Number
        :param reg_mode: The Register Mode
        :param imm: The immediate word, if any
        :param ty: The Type (byte or word)
        :return: The VexValue of the operand, and the writeout function, if any.
        """ # Boring register mode.  A write is just a Put. # Fetch the register # Indexed mode, add the immediate to the register # A write here is a store to reg + imm # Fetch the register # Indirect mode; fetch address in register; store is a write there. # Fetch the register # Indirect Autoincrement mode. Increment the register by the type size, then access it # Fetch the register # Do the increment, now # Now load it.
The VexValue of the operand, and the writeout function, if any.
The VexValue of the operand and the writeout function if any .
self
reg_num
The Register Number
The Register Number
reg_mode
The Register Mode
The Register Mode
imm
The immediate word, if any
The immediate word if any
ty
The Type (byte or word)
The Type ( byte or word )