angr_platforms/msp430/instrs_msp430.py
def fetch_src(self, src_bits, mode_bits, imm_bits, ty):
        """
        Fetch the ``source'' operand of an instruction.
        Returns the source as a VexValue, and, if it exists, a function for how it can be written
        to if needed (e.g., one-operand instructions)
        :param src_bits: bit-string of the src
        :param mode_bits: bit-string of the mode
        :param imm_bits: bit-string of the immediate
        :param ty: The type to use (the byte type or word type)
        :return: The src as a VexValue, and a lambda describing how to write to it if necessary
        """
        src_num = int(src_bits, 2)
        src_name = ArchMSP430.register_index[src_num]
        src_mode = int(mode_bits, 2)
        writeout = None
        # Load the immediate word
        src_imm = None
        if imm_bits:
            src_imm = bits_to_signed_int(imm_bits)
        # Symbolic and Immediate modes use the PC as the source.
        if src_name == 'pc':
            if src_mode == ArchMSP430.Mode.INDEXED_MODE:
                src_mode = ArchMSP430.Mode.SYMBOLIC_MODE
            elif src_mode == ArchMSP430.Mode.INDIRECT_AUTOINCREMENT_MODE:
                src_mode = ArchMSP430.Mode.IMMEDIATE_MODE
        # Resolve the constant generator stuff.
        elif src_name == 'cg':
            if src_mode == ArchMSP430.Mode.REGISTER_MODE:
                src_mode = ArchMSP430.Mode.CONSTANT_MODE0
            elif src_mode == ArchMSP430.Mode.INDEXED_MODE:
                src_mode = ArchMSP430.Mode.CONSTANT_MODE1
            elif src_mode == ArchMSP430.Mode.INDIRECT_REGISTER_MODE:
                src_mode = ArchMSP430.Mode.CONSTANT_MODE2
            else:
                src_mode = ArchMSP430.Mode.CONSTANT_MODE_NEG1
        # If you use the SR as the source. things get weird.
        elif src_name == 'sr':
            if src_mode == ArchMSP430.Mode.INDEXED_MODE:
                src_mode = ArchMSP430.Mode.ABSOLUTE_MODE
            elif src_mode == ArchMSP430.Mode.INDIRECT_REGISTER_MODE:
                src_mode = ArchMSP430.Mode.CONSTANT_MODE4
            elif src_mode == ArchMSP430.Mode.INDIRECT_AUTOINCREMENT_MODE:
                src_mode = ArchMSP430.Mode.CONSTANT_MODE8
        # Fetch constants
        if src_mode == ArchMSP430.Mode.CONSTANT_MODE0:
            src_vv = self.constant(0, ty)
        elif src_mode == ArchMSP430.Mode.CONSTANT_MODE1:
            src_vv = self.constant(1, ty)
        elif src_mode == ArchMSP430.Mode.CONSTANT_MODE2:
            src_vv = self.constant(2, ty)
        elif src_mode == ArchMSP430.Mode.CONSTANT_MODE4:
            src_vv = self.constant(4, ty)
        elif src_mode == ArchMSP430.Mode.CONSTANT_MODE8:
            src_vv = self.constant(8, ty)
        elif src_mode == ArchMSP430.Mode.CONSTANT_MODE_NEG1:
            src_vv = self.constant(-1, ty)
        # Fetch immediate.
        elif src_mode == ArchMSP430.Mode.IMMEDIATE_MODE:
            src_vv = self.constant(bits_to_signed_int(imm_bits), ty)
        # Symbolic mode: Add the immediate to the PC
        elif src_mode == ArchMSP430.Mode.SYMBOLIC_MODE:
            src_vv = self.get(src_num, Type.int_16) + bits_to_signed_int(imm_bits) + 2
        else:
            # Register mode can write-out to the source for one-operand, so set the writeout
            src_vv, writeout = self.fetch_reg(src_num, src_mode, src_imm, ty)
        return src_vv, writeout

        Fetch the ``source'' operand of an instruction.
        Returns the source as a VexValue, and, if it exists, a function for how it can be written
        to if needed (e.g., one-operand instructions)
        :param src_bits: bit-string of the src
        :param mode_bits: bit-string of the mode
        :param imm_bits: bit-string of the immediate
        :param ty: The type to use (the byte type or word type)
        :return: The src as a VexValue, and a lambda describing how to write to it if necessary
        
Fetch the ``source'' operand of an instruction.
Returns the source as a VexValue, and, if it exists, a function for how it can be written
to if needed
Fetch the ` ` source ' ' operand of an instruction . Returns the source as a VexValue and if it exists a function for how it can be written to if needed
def fetch_src(self, src_bits, mode_bits, imm_bits, ty):
        src_num = int(src_bits, 2)
        src_name = ArchMSP430.register_index[src_num]
        src_mode = int(mode_bits, 2)
        writeout = None
        src_imm = None
        if imm_bits:
            src_imm = bits_to_signed_int(imm_bits)
        if src_name == 'pc':
            if src_mode == ArchMSP430.Mode.INDEXED_MODE:
                src_mode = ArchMSP430.Mode.SYMBOLIC_MODE
            elif src_mode == ArchMSP430.Mode.INDIRECT_AUTOINCREMENT_MODE:
                src_mode = ArchMSP430.Mode.IMMEDIATE_MODE
        elif src_name == 'cg':
            if src_mode == ArchMSP430.Mode.REGISTER_MODE:
                src_mode = ArchMSP430.Mode.CONSTANT_MODE0
            elif src_mode == ArchMSP430.Mode.INDEXED_MODE:
                src_mode = ArchMSP430.Mode.CONSTANT_MODE1
            elif src_mode == ArchMSP430.Mode.INDIRECT_REGISTER_MODE:
                src_mode = ArchMSP430.Mode.CONSTANT_MODE2
            else:
                src_mode = ArchMSP430.Mode.CONSTANT_MODE_NEG1
        elif src_name == 'sr':
            if src_mode == ArchMSP430.Mode.INDEXED_MODE:
                src_mode = ArchMSP430.Mode.ABSOLUTE_MODE
            elif src_mode == ArchMSP430.Mode.INDIRECT_REGISTER_MODE:
                src_mode = ArchMSP430.Mode.CONSTANT_MODE4
            elif src_mode == ArchMSP430.Mode.INDIRECT_AUTOINCREMENT_MODE:
                src_mode = ArchMSP430.Mode.CONSTANT_MODE8
        if src_mode == ArchMSP430.Mode.CONSTANT_MODE0:
            src_vv = self.constant(0, ty)
        elif src_mode == ArchMSP430.Mode.CONSTANT_MODE1:
            src_vv = self.constant(1, ty)
        elif src_mode == ArchMSP430.Mode.CONSTANT_MODE2:
            src_vv = self.constant(2, ty)
        elif src_mode == ArchMSP430.Mode.CONSTANT_MODE4:
            src_vv = self.constant(4, ty)
        elif src_mode == ArchMSP430.Mode.CONSTANT_MODE8:
            src_vv = self.constant(8, ty)
        elif src_mode == ArchMSP430.Mode.CONSTANT_MODE_NEG1:
            src_vv = self.constant(-1, ty)
        elif src_mode == ArchMSP430.Mode.IMMEDIATE_MODE:
            src_vv = self.constant(bits_to_signed_int(imm_bits), ty)
        elif src_mode == ArchMSP430.Mode.SYMBOLIC_MODE:
            src_vv = self.get(src_num, Type.int_16) + bits_to_signed_int(imm_bits) + 2
        else:
            src_vv, writeout = self.fetch_reg(src_num, src_mode, src_imm, ty)
        return src_vv, writeout
def fetch_src ( self , src_bits , mode_bits , imm_bits , ty ) : src_num = int ( src_bits , 2 ) src_name = ArchMSP430 . register_index [ src_num ] src_mode = int ( mode_bits , 2 ) writeout = None src_imm = None if imm_bits : src_imm = bits_to_signed_int ( imm_bits ) if src_name == 'pc' : if src_mode == ArchMSP430 . Mode . INDEXED_MODE : src_mode = ArchMSP430 . Mode . SYMBOLIC_MODE elif src_mode == ArchMSP430 . Mode . INDIRECT_AUTOINCREMENT_MODE : src_mode = ArchMSP430 . Mode . IMMEDIATE_MODE elif src_name == 'cg' : if src_mode == ArchMSP430 . Mode . REGISTER_MODE : src_mode = ArchMSP430 . Mode . CONSTANT_MODE0 elif src_mode == ArchMSP430 . Mode . INDEXED_MODE : src_mode = ArchMSP430 . Mode . CONSTANT_MODE1 elif src_mode == ArchMSP430 . Mode . INDIRECT_REGISTER_MODE : src_mode = ArchMSP430 . Mode . CONSTANT_MODE2 else : src_mode = ArchMSP430 . Mode . CONSTANT_MODE_NEG1 elif src_name == 'sr' : if src_mode == ArchMSP430 . Mode . INDEXED_MODE : src_mode = ArchMSP430 . Mode . ABSOLUTE_MODE elif src_mode == ArchMSP430 . Mode . INDIRECT_REGISTER_MODE : src_mode = ArchMSP430 . Mode . CONSTANT_MODE4 elif src_mode == ArchMSP430 . Mode . INDIRECT_AUTOINCREMENT_MODE : src_mode = ArchMSP430 . Mode . CONSTANT_MODE8 if src_mode == ArchMSP430 . Mode . CONSTANT_MODE0 : src_vv = self . constant ( 0 , ty ) elif src_mode == ArchMSP430 . Mode . CONSTANT_MODE1 : src_vv = self . constant ( 1 , ty ) elif src_mode == ArchMSP430 . Mode . CONSTANT_MODE2 : src_vv = self . constant ( 2 , ty ) elif src_mode == ArchMSP430 . Mode . CONSTANT_MODE4 : src_vv = self . constant ( 4 , ty ) elif src_mode == ArchMSP430 . Mode . CONSTANT_MODE8 : src_vv = self . constant ( 8 , ty ) elif src_mode == ArchMSP430 . Mode . CONSTANT_MODE_NEG1 : src_vv = self . constant ( - 1 , ty ) elif src_mode == ArchMSP430 . Mode . IMMEDIATE_MODE : src_vv = self . constant ( bits_to_signed_int ( imm_bits ) , ty ) elif src_mode == ArchMSP430 . Mode . SYMBOLIC_MODE : src_vv = self . get ( src_num , Type . int_16 ) + bits_to_signed_int ( imm_bits ) + 2 else : src_vv , writeout = self . fetch_reg ( src_num , src_mode , src_imm , ty ) return src_vv , writeout
Fetch the ``source'' operand of an instruction.
Fetch the ` ` source ' ' operand of an instruction .
"""
        Fetch the ``source'' operand of an instruction.
        Returns the source as a VexValue, and, if it exists, a function for how it can be written
        to if needed (e.g., one-operand instructions)
        :param src_bits: bit-string of the src
        :param mode_bits: bit-string of the mode
        :param imm_bits: bit-string of the immediate
        :param ty: The type to use (the byte type or word type)
        :return: The src as a VexValue, and a lambda describing how to write to it if necessary
        """ # Load the immediate word # Symbolic and Immediate modes use the PC as the source. # Resolve the constant generator stuff. # If you use the SR as the source. things get weird. # Fetch constants # Fetch immediate. # Symbolic mode: Add the immediate to the PC # Register mode can write-out to the source for one-operand, so set the writeout
The src as a VexValue, and a lambda describing how to write to it if necessary
The src as a VexValue and a lambda describing how to write to it if necessary
self
src_bits
bit-string of the src
bit - string of the src
mode_bits
bit-string of the mode
bit - string of the mode
imm_bits
bit-string of the immediate
bit - string of the immediate
ty
The type to use (the byte type or word type)
The type to use ( the byte type or word type )