Example #1
0
        public static void Lop3(EmitterContext context)
        {
            IOpCodeLop op = (IOpCodeLop)context.CurrOp;

            Operand srcA = GetSrcA(context);
            Operand srcB = GetSrcB(context);
            Operand srcC = GetSrcC(context);

            bool regVariant = op is OpCodeLopReg;

            int truthTable = regVariant
                ? op.RawOpCode.Extract(28, 8)
                : op.RawOpCode.Extract(48, 8);

            Operand res = Lop3Expression.GetFromTruthTable(context, srcA, srcB, srcC, truthTable);

            if (regVariant)
            {
                EmitLopPredWrite(context, op, res, (ConditionalOperation)context.CurrOp.RawOpCode.Extract(36, 2));
            }

            Operand dest = GetDest(context);

            context.Copy(dest, res);

            SetZnFlags(context, dest, op.SetCondCode, op.Extended);
        }
Example #2
0
        private static void EmitLopPredWrite(EmitterContext context, IOpCodeLop op, Operand result, ConditionalOperation condOp)
        {
            if (op is OpCodeLop opLop && !opLop.Predicate48.IsPT)
            {
                Operand pRes;

                if (condOp == ConditionalOperation.False)
                {
                    pRes = Const(IrConsts.False);
                }
                else if (condOp == ConditionalOperation.True)
                {
                    pRes = Const(IrConsts.True);
                }
                else if (condOp == ConditionalOperation.Zero)
                {
                    pRes = context.ICompareEqual(result, Const(0));
                }
                else /* if (opLop.CondOp == ConditionalOperation.NotZero) */
                {
                    pRes = context.ICompareNotEqual(result, Const(0));
                }

                context.Copy(Register(opLop.Predicate48), pRes);
            }
        }
Example #3
0
        public static void Lop(EmitterContext context)
        {
            IOpCodeLop op = (IOpCodeLop)context.CurrOp;

            Operand srcA = context.BitwiseNot(GetSrcA(context), op.InvertA);
            Operand srcB = context.BitwiseNot(GetSrcB(context), op.InvertB);

            Operand res = srcB;

            switch (op.LogicalOp)
            {
            case LogicalOperation.And:         res = context.BitwiseAnd(srcA, srcB); break;

            case LogicalOperation.Or:          res = context.BitwiseOr(srcA, srcB); break;

            case LogicalOperation.ExclusiveOr: res = context.BitwiseExclusiveOr(srcA, srcB); break;
            }

            EmitLopPredWrite(context, op, res, (ConditionalOperation)context.CurrOp.RawOpCode.Extract(44, 2));

            Operand dest = GetDest(context);

            context.Copy(dest, res);

            SetZnFlags(context, dest, op.SetCondCode, op.Extended);
        }