# arm o_reglist = ida_ua.o_idpspec1 # Register list (for LDM/STM) o_creglist = ida_ua.o_idpspec2 # Coprocessor register list (for CDP) o_creg = ida_ua.o_idpspec3 # Coprocessor register (for LDC/STC) o_fpreglist = ida_ua.o_idpspec4 # Floating point register list o_text = ida_ua.o_idpspec5 # Arbitrary text stored in the operand o_cond = (ida_ua.o_idpspec5+1) # ARM condition as an operand
# ppc o_spr = ida_ua.o_idpspec0 # Special purpose register o_twofpr = ida_ua.o_idpspec1 # Two FPRs o_shmbme = ida_ua.o_idpspec2 # SH & MB & ME o_crf = ida_ua.o_idpspec3 # crfield x.reg o_crb = ida_ua.o_idpspec4 # crbit x.reg o_dcr = ida_ua.o_idpspec5 # Device control register
defget_operand_value(ea, n): """ Get number used in the operand This function returns an immediate number used in the operand @param ea: linear address of instruction @param n: the operand number @return: value operand is an immediate value => immediate value operand has a displacement => displacement operand is a direct memory ref => memory address operand is a register => register number operand is a register phrase => phrase number otherwise => -1 """ insn = ida_ua.insn_t() inslen = ida_ua.decode_insn(insn, ea) if inslen == 0: return -1 op = insn.ops[n] ifnot op: return -1
if op.typein [ ida_ua.o_mem, ida_ua.o_far, ida_ua.o_near, ida_ua.o_displ ]: value = op.addr elif op.type == ida_ua.o_reg: value = op.reg elif op.type == ida_ua.o_imm: value = op.value elif op.type == ida_ua.o_phrase: value = op.phrase else: value = -1 return value