Example #1
0
        public static void Ubfm(AILEmitterCtx Context)
        {
            AOpCodeBfm Op = (AOpCodeBfm)Context.CurrOp;

            if (Op.Pos + 1 == Op.GetBitsCount())
            {
                EmitUbfmShift(Context);
            }
            else if (Op.Pos < Op.Shift)
            {
                EmitUbfiz(Context);
            }
            else if (Op.Pos + 1 == Op.Shift)
            {
                EmitBfmLsl(Context);
            }
            else if (Op.Pos == 7 && Op.Shift == 0)
            {
                EmitUbfmCast(Context, OpCodes.Conv_U1);
            }
            else if (Op.Pos == 15 && Op.Shift == 0)
            {
                EmitUbfmCast(Context, OpCodes.Conv_U2);
            }
            else
            {
                EmitBfmLoadRn(Context);

                Context.EmitStintzr(Op.Rd);
            }
        }
Example #2
0
        private static void EmitBfmLsl(AILEmitterCtx Context)
        {
            AOpCodeBfm Op = (AOpCodeBfm)Context.CurrOp;

            Context.EmitLdintzr(Op.Rn);

            Context.EmitLsl(Op.GetBitsCount() - Op.Shift);

            Context.EmitStintzr(Op.Rd);
        }
Example #3
0
        public static void Sbfm(AILEmitterCtx Context)
        {
            AOpCodeBfm Op = (AOpCodeBfm)Context.CurrOp;

            int BitsCount = Op.GetBitsCount();

            if (Op.Pos + 1 == BitsCount)
            {
                EmitSbfmShift(Context);
            }
            else if (Op.Pos < Op.Shift)
            {
                EmitSbfiz(Context);
            }
            else if (Op.Pos == 7 && Op.Shift == 0)
            {
                EmitSbfmCast(Context, OpCodes.Conv_I1);
            }
            else if (Op.Pos == 15 && Op.Shift == 0)
            {
                EmitSbfmCast(Context, OpCodes.Conv_I2);
            }
            else if (Op.Pos == 31 && Op.Shift == 0)
            {
                EmitSbfmCast(Context, OpCodes.Conv_I4);
            }
            else if (Op.Shift == 0)
            {
                Context.EmitLdintzr(Op.Rn);

                Context.EmitLsl(BitsCount - 1 - Op.Pos);
                Context.EmitAsr(BitsCount - 1);

                Context.EmitStintzr(Op.Rd);
            }
            else
            {
                EmitBfmLoadRn(Context);

                Context.EmitLdintzr(Op.Rn);

                Context.EmitLsl(BitsCount - 1 - Op.Pos);
                Context.EmitAsr(BitsCount - 1);

                Context.EmitLdc_I(~Op.TMask);

                Context.Emit(OpCodes.And);
                Context.Emit(OpCodes.Or);

                Context.EmitStintzr(Op.Rd);
            }
        }
Example #4
0
        private static void EmitBfiz(AILEmitterCtx Context, bool Signed)
        {
            AOpCodeBfm Op = (AOpCodeBfm)Context.CurrOp;

            int Width = Op.Pos + 1;

            Context.EmitLdintzr(Op.Rn);

            Context.EmitLsl(Op.GetBitsCount() - Width);

            if (Signed)
            {
                Context.EmitAsr(Op.Shift - Width);
            }
            else
            {
                Context.EmitLsr(Op.Shift - Width);
            }

            Context.EmitStintzr(Op.Rd);
        }