[文档]defdecode_instruction(arch,instr):# this is clearly architecture specificarch_name=arch.nameifarch_name=="MIPS32"andonce("mips-instruction-groups"):l.warning("Your version of capstone does not support MIPS instruction groups.")insn_info=Noneinfo=INS_GROUP_INFO.get(arch_name)ifinfoisnotNone:forgroupininstr.insn.insn.groups:insn_info=info.get(group,None)ifinsn_infoisnotNone:breakifinsn_infoisNone:info=INS_INFO.get(arch_name)ifinfoisnotNone:insn_info=info.get(instr.insn.insn.id,None)ifinsn_infoisNone:returninstr.type=insn_infoifinstr.typein("call","branch"):# determine if this is a direct or indirect call/branchifarch_namein("X86","AMD64"):last_operand=instr.insn.operands[-1]iflast_operand.type==cs.x86.X86_OP_IMM:instr.branch_type="direct"else:instr.branch_type="indirect"instr.branch_target_operand=len(instr.insn.operands)-1elifis_arm_arch(arch):last_operand=instr.insn.operands[-1]iflast_operand.type==cs.arm.ARM_OP_IMM:instr.branch_type="direct"else:instr.branch_type="indirect"instr.branch_target_operand=len(instr.insn.operands)-1elifarch_name=="MIPS32":# check the last operandlast_operand=instr.insn.operands[-1]iflast_operand.type==cs.mips.MIPS_OP_REG:instr.branch_type="indirect"else:instr.branch_type="direct"instr.branch_target_operand=len(instr.insn.operands)-1