def get_instructions(self, cm, size, insn, idx):
self.odex = cm.get_odex_format()<EOL>max_idx = size * calcsize('<STR_LIT>')<EOL>if max_idx > len(insn):<EOL><INDENT>max_idx = len(insn)<EOL><DEDENT>while idx < max_idx:<EOL><INDENT>obj = None<EOL>classic_instruction = True<EOL>op_value = insn[idx]<EOL>if (op_value == <NUM_LIT> or op_value == <NUM_LIT>) and ((idx + <NUM_LIT:2>) < max_idx):<EOL><INDENT>op_value = unpack('<STR_LIT>', insn[idx:idx + <NUM_LIT:2>])[<NUM_LIT:0>]<EOL>if op_value in DALVIK_OPCODES_PAYLOAD:<EOL><INDENT>try:<EOL><INDENT>obj = get_instruction_payload(op_value, insn[idx:])<EOL>classic_instruction = False<EOL><DEDENT>except struct.error:<EOL><INDENT>warning("<STR_LIT>")<EOL><DEDENT><DEDENT>elif op_value in DALVIK_OPCODES_EXTENDED_WIDTH:<EOL><INDENT>try:<EOL><INDENT>obj = get_extented_instruction(cm, op_value, insn[idx:])<EOL>classic_instruction = False<EOL><DEDENT>except struct.error as why:<EOL><INDENT>warning("<STR_LIT>" +<EOL>why.__str__())<EOL><DEDENT><DEDENT>elif self.odex and (op_value in DALVIK_OPCODES_OPTIMIZED):<EOL><INDENT>obj = get_optimized_instruction(cm, op_value, insn[idx:])<EOL>classic_instruction = False<EOL><DEDENT><DEDENT>if classic_instruction:<EOL><INDENT>op_value = insn[idx]<EOL>obj = get_instruction(cm, op_value, insn[idx:], self.odex)<EOL><DEDENT>yield obj<EOL>idx = idx + obj.get_length()<EOL><DEDENT>
:param cm: a ClassManager object
:type cm: :class:`ClassManager` object
:param size: the total size of the buffer
:type size: int
:param insn: a raw buffer where are the instructions
:type insn: string
:param idx: a start address in the buffer
:type idx: int

:rtype: a generator of :class:`Instruction` objects