def __cs_translate_operand(self, cs_op, cs_insn):
        if cs_op.type == ARM_OP_REG:
            reg = self.__cs_reg_idx_to_arm_op_reg(cs_op.value.reg, cs_insn)

            if 0 > cs_op.shift.type:
                oprnd = self.__cs_shift_to_arm_op(cs_op, cs_insn, reg)
            else:
                oprnd = reg
        elif cs_op.type == ARM_OP_IMM:
            oprnd = ArmImmediateOperand(cs_op.value.imm, self._arch_info.operand_size)
        elif cs_op.type == ARM_OP_MEM:
            reg_base = self.__cs_reg_idx_to_arm_op_reg(cs_op.mem.base, cs_insn)

            # TODO: memory index type
            index_type = ARM_MEMORY_INDEX_OFFSET

            if cs_op.mem.index > 0:
                if cs_op.mem.disp > 0:
                    raise Exception("ARM_OP_MEM: Both index and disp > 0, only one can be.")

                displacement = self.__cs_reg_idx_to_arm_op_reg(cs_op.mem.index, cs_insn)

                # NOTE: In the case of a memory operand, in the second
                # position (slot [1]), the information regarding whether
                # or not the displacement of the operand has a shifted
                # register is encoded in the first operand (slot [0]),
                # that doesn't have a direct relation with the other.

                # TODO: Check if this has to be reported to CS.
                if cs_insn.operands[0].shift.type > 0:
                    # There's a shift operation, the displacement extracted
                    # earlier was just the base register of the shifted
                    # register that is generating the disaplacement.
                    displacement = self.__cs_shift_to_arm_op(cs_insn.operands[0], cs_insn, displacement)
            else:
                displacement = ArmImmediateOperand(cs_op.mem.disp, self._arch_info.operand_size)

            disp_minus = True if cs_op.mem.index == -1 else False

            oprnd = ArmMemoryOperand(reg_base, index_type, displacement, disp_minus, self._arch_info.operand_size)
        else:
            oprnd = None

            error_msg = "Instruction: " + cs_insn.mnemonic  + " " + cs_insn.op_str + ". Unkown operand type: " + str(cs_op.type)

            logger.error(error_msg)

            raise CapstoneOperandNotSupported(error_msg)

        return oprnd
dataset/ETHPy150Open programa-stic/barf-project/barf/barf/arch/arm/armdisassembler.py/ArmDisassembler.__cs_translate_operand/swapped operands of `>`