Exemple #1
0
        public override Constant ApplyConstants(Constant c1, Constant c2)
        {
            uint v1 = (uint)c1.ToUInt32();
            uint v2 = (uint)c2.ToUInt32();

            return(Constant.Bool(v1 >= v2));
        }
Exemple #2
0
        private void RewriteCLRF()
        {
            var(indMode, memPtr) = GetUnaryPtrs(instrCurr.Operands[0], out Expression memExpr);

            switch (indMode)
            {
            case FSRIndexedMode.None:
            case FSRIndexedMode.INDF:
            case FSRIndexedMode.PLUSW:
                m.Assign(memExpr, 0);
                break;

            case FSRIndexedMode.POSTDEC:
                m.Assign(memExpr, 0);
                m.Assign(memPtr, m.ISub(memPtr, 1));
                break;

            case FSRIndexedMode.POSTINC:
                m.Assign(memExpr, 0);
                m.Assign(memPtr, m.IAdd(memPtr, 1));
                break;

            case FSRIndexedMode.PREINC:
                m.Assign(memPtr, m.IAdd(memPtr, 1));
                m.Assign(memExpr, 0);
                break;
            }
            m.Assign(binder.EnsureFlagGroup(PIC18Registers.Z), Constant.Bool(true));
        }
Exemple #3
0
        private void SetFlag(FlagM flag, bool value)
        {
            var reg = FlagGroupStorage(flag);
            var v   = Constant.Bool(value);

            m.Assign(reg, v);
        }
 public override Constant ApplyConstants(Constant c1, Constant c2)
 {
     if (!ValidArgs(c1, c2))
     {
         return(InvalidConstant.Create(PrimitiveType.Bool));
     }
     return(Constant.Bool(c1.ToReal64() <= c2.ToReal64()));
 }
 public override Constant ApplyConstants(Constant c1, Constant c2)
 {
     if (!ValidArgs(c1, c2))
     {
         return(InvalidConstant.Create(c1.DataType));
     }
     return(Constant.Bool(c1.ToReal64() < c2.ToReal64()));
 }
Exemple #6
0
 public override Constant ApplyConstants(Constant c1, Constant c2)
 {
     if (!ValidArgs(c1, c2))
     {
         return(Constant.Invalid);
     }
     return(Constant.Bool(c1.ToReal64() > c2.ToReal64()));
 }
Exemple #7
0
        public override Constant ApplyConstants(Constant c1, Constant c2)
        {
            if (!ValidArgs(c1, c2))
            {
                return(InvalidConstant.Create(c1.DataType));
            }
            ulong v1 = c1.ToUInt64();
            ulong v2 = c2.ToUInt64();

            return(Constant.Bool(v1 <= v2));
        }
Exemple #8
0
        public override Constant ApplyConstants(Constant c1, Constant c2)
        {
            if (!ValidArgs(c1, c2))
            {
                return(Constant.Invalid);
            }
            uint v1 = c1.ToUInt32();
            uint v2 = c2.ToUInt32();

            return(Constant.Bool(v1 <= v2));
        }
Exemple #9
0
        public override Constant ApplyConstants(Constant c1, Constant c2)
        {
            if (!ValidArgs(c1, c2))
            {
                return(Constant.Invalid);
            }
            ulong v1 = c1.ToUInt64();
            ulong v2 = c2.ToUInt64();

            return(Constant.Bool(v1 < v2));
        }
Exemple #10
0
        private void RewriteBit()
        {
            var left  = RewriteOp(instr.Operands[1]);
            var right = RewriteOp(instr.Operands[0]);
            var tmp   = binder.CreateTemporary(instr.Operands[0].Width);
            var grf   = binder.EnsureFlagGroup(arch.GetFlagGroup(Registers.sr, (uint)(FlagM.NF | FlagM.ZF)));
            var c     = binder.EnsureFlagGroup(arch.GetFlagGroup(Registers.sr, (uint)FlagM.CF));
            var v     = binder.EnsureFlagGroup(arch.GetFlagGroup(Registers.sr, (uint)FlagM.VF));

            m.Assign(tmp, m.And(left, right));
            m.Assign(grf, m.Cond(tmp));
            m.Assign(c, m.Test(ConditionCode.NE, tmp));
            m.Assign(v, Constant.Bool(false));
        }
Exemple #11
0
        public Constant GetFlagGroup(uint mask)
        {
            bool sigle = Bits.IsSingleBitSet(mask);

            if ((mask & validFlags) == mask)
            {
                if (sigle)
                {
                    return(Constant.Bool((flags & mask) != 0));
                }
                else
                {
                    return(Constant.Byte((byte)(flags & mask)));
                }
            }
            else
            {
                return(Constant.Invalid);
            }
        }
Exemple #12
0
 private void Rewrite_CLRW()
 {
     m.Assign(Wreg, Constant.Byte(0));
     m.Assign(binder.EnsureFlagGroup(PICRegisters.Z), Constant.Bool(true));
 }
Exemple #13
0
 private void Rewrite_CLRF()
 {
     GetSrc(out var srcMem);
     m.Assign(srcMem, Constant.Byte(0));
     m.Assign(binder.EnsureFlagGroup(PICRegisters.Z), Constant.Bool(true));
 }
Exemple #14
0
 private void RewriteSetBit(FlagM grf, bool value)
 {
     m.Assign(binder.EnsureFlagGroup(arch.GetFlagGroup(arch.sreg, (uint)grf)), Constant.Bool(value));
 }
Exemple #15
0
        private void RewriteSetend()
        {
            var endianness = (EndiannessOperand)instr.Operands[0];
            var intrisic   = host.Intrinsic("__set_bigendian", true, VoidType.Instance, Constant.Bool(endianness.BigEndian));

            m.SideEffect(intrisic);
        }
Exemple #16
0
        private void AssignFlag(FlagM flag, bool value)
        {
            var grf = arch.GetFlagGroup((uint)flag);

            m.Assign(binder.EnsureFlagGroup(grf), Constant.Bool(value));
        }
Exemple #17
0
 public override Constant ApplyConstants(Constant c1, Constant c2)
 {
     return(Constant.Bool(c1.ToInt32() < c2.ToInt32()));
 }
Exemple #18
0
 private void RewriteSetBit(FlagGroupStorage grf, bool value)
 {
     m.Assign(binder.EnsureFlagGroup(grf), Constant.Bool(value));
 }
Exemple #19
0
 private void RewriteSet1()
 {
     RewriteDst(instr.Operands[0], Constant.Bool(true), (a, b) => b);
 }
Exemple #20
0
 private void RewriteClr1()
 {
     RewriteDst(instr.Operands[0], Constant.Bool(false), (a, b) => b);
 }
Exemple #21
0
        private void RewriteSetend()
        {
            var endianness = (EndiannessOperand)instr.ops[0];
            var intrisic   = host.PseudoProcedure("__set_bigendian", VoidType.Instance, Constant.Bool(endianness.BigEndian));

            m.SideEffect(intrisic);
        }