aboutsummaryrefslogtreecommitdiff
path: root/src/ARMeilleure/Decoders/OpCode32SimdMovGpElem.cs
blob: f6fce7d997a7c30354832447af28a1e53185c069 (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
42
43
44
45
46
47
48
49
50
51
namespace ARMeilleure.Decoders
{
    class OpCode32SimdMovGpElem : OpCode32, IOpCode32Simd
    {
        public int Size { get; }

        public int Vd { get; }
        public int Rt { get; }
        public int Op { get; }
        public bool U { get; }

        public int Index { get; }

        public new static OpCode Create(InstDescriptor inst, ulong address, int opCode) => new OpCode32SimdMovGpElem(inst, address, opCode, false);
        public static OpCode CreateT32(InstDescriptor inst, ulong address, int opCode) => new OpCode32SimdMovGpElem(inst, address, opCode, true);

        public OpCode32SimdMovGpElem(InstDescriptor inst, ulong address, int opCode, bool isThumb) : base(inst, address, opCode)
        {
            IsThumb = isThumb;

            Op = (opCode >> 20) & 0x1;
            U = ((opCode >> 23) & 1) != 0;

            var opc = (((opCode >> 23) & 1) << 4) | (((opCode >> 21) & 0x3) << 2) | ((opCode >> 5) & 0x3);

            if ((opc & 0b01000) == 0b01000)
            {
                Size = 0;
                Index = opc & 0x7;
            }
            else if ((opc & 0b01001) == 0b00001)
            {
                Size = 1;
                Index = (opc >> 1) & 0x3;
            }
            else if ((opc & 0b11011) == 0)
            {
                Size = 2;
                Index = (opc >> 2) & 0x1;
            }
            else
            {
                Instruction = InstDescriptor.Undefined;
                return;
            }

            Vd = ((opCode >> 3) & 0x10) | ((opCode >> 16) & 0xf);
            Rt = (opCode >> 12) & 0xf;
        }
    }
}