aboutsummaryrefslogtreecommitdiff
path: root/ARMeilleure/Instructions/InstEmitMove.cs
blob: d551bf2da6982b572a176aaf29c1fd8d4ac60e62 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
using ARMeilleure.Decoders;
using ARMeilleure.IntermediateRepresentation;
using ARMeilleure.Translation;

using static ARMeilleure.Instructions.InstEmitHelper;
using static ARMeilleure.IntermediateRepresentation.Operand.Factory;

namespace ARMeilleure.Instructions
{
    static partial class InstEmit
    {
        public static void Movk(ArmEmitterContext context)
        {
            OpCodeMov op = (OpCodeMov)context.CurrOp;

            OperandType type = op.GetOperandType();

            Operand res = GetIntOrZR(context, op.Rd);

            res = context.BitwiseAnd(res, Const(type, ~(0xffffL << op.Bit)));

            res = context.BitwiseOr(res, Const(type, op.Immediate));

            SetIntOrZR(context, op.Rd, res);
        }

        public static void Movn(ArmEmitterContext context)
        {
            OpCodeMov op = (OpCodeMov)context.CurrOp;

            SetIntOrZR(context, op.Rd, Const(op.GetOperandType(), ~op.Immediate));
        }

        public static void Movz(ArmEmitterContext context)
        {
            OpCodeMov op = (OpCodeMov)context.CurrOp;

            SetIntOrZR(context, op.Rd, Const(op.GetOperandType(), op.Immediate));
        }
    }
}