Ejemplo n.º 1
0
    def _translate_bsh(self, oprnd1, oprnd2, oprnd3):
        """Return a formula representation of a BSH instruction.
        """
        assert oprnd1.size and oprnd2.size and oprnd3.size
        assert oprnd1.size == oprnd2.size

        op1_var = self._translate_src_oprnd(oprnd1)
        op2_var = self._translate_src_oprnd(oprnd2)
        op3_var, _ = self._translate_dst_oprnd(oprnd3)

        if oprnd3.size > oprnd1.size:
            op1_var_zx = smtlibv2.ZEXTEND(op1_var, oprnd3.size)
            op2_var_zx = smtlibv2.ZEXTEND(op2_var, oprnd3.size)

            op2_var_neg = (-op2_var)
            op2_var_neg_sx = smtlibv2.SEXTEND(op2_var_neg, oprnd2.size,
                                              oprnd3.size)

            shl = smtlibv2.EXTRACT(op1_var_zx >> op2_var_neg_sx, 0,
                                   op3_var.size)
            shr = smtlibv2.EXTRACT(op1_var_zx << op2_var_zx, 0, op3_var.size)
        elif oprnd3.size < oprnd1.size:
            shl = smtlibv2.EXTRACT(op1_var >> (-op2_var), 0, op3_var.size)
            shr = smtlibv2.EXTRACT(op1_var << op2_var, 0, op3_var.size)
        else:
            shl = op1_var >> (-op2_var)
            shr = op1_var << op2_var

        return [(op3_var == smtlibv2.ITEBV(oprnd3.size, op2_var >= 0, shr,
                                           shl))]
Ejemplo n.º 2
0
    def _translate_bisz(self, oprnd1, oprnd2, oprnd3):
        """Return a formula representation of a BISZ instruction.
        """
        assert oprnd1.size and oprnd3.size

        op1_var = self._translate_src_oprnd(oprnd1)
        op3_var, _ = self._translate_dst_oprnd(oprnd3)

        ite = smtlibv2.ITEBV(oprnd3.size, op1_var == 0x0, 0x1, 0x0)

        return [(op3_var == ite)]
Ejemplo n.º 3
0
    def _translate_bsh(self, oprnd1, oprnd2, oprnd3):
        """Return a formula representation of a BSH instruction.
        """
        assert oprnd1.size and oprnd2.size and oprnd3.size
        assert oprnd1.size == oprnd2.size

        op1_var = self._translate_src_oprnd(oprnd1)
        op2_var = self._translate_src_oprnd(oprnd2)
        op3_var, _ = self._translate_dst_oprnd(oprnd3)

        shl = smtlibv2.EXTRACT(op1_var >> (-op2_var), 0, op3_var.size)
        shr = smtlibv2.EXTRACT(op1_var << op2_var, 0, op3_var.size)

        return [(op3_var == smtlibv2.ITEBV(oprnd3.size, op2_var >= 0, shr,
                                           shl))]