aboutsummaryrefslogtreecommitdiff
path: root/ARMeilleure/Decoders/OpCode32SimdImm44.cs
blob: a2be6e6486770eeccbd469b7e87fdb575ec7dda2 (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
namespace ARMeilleure.Decoders
{
    class OpCode32SimdImm44 : OpCode32, IOpCode32SimdImm
    {
        public int Vd { get; }
        public long Immediate { get; }
        public int Size { get; }
        public int Elems { get; }

        public new static OpCode Create(InstDescriptor inst, ulong address, int opCode) => new OpCode32SimdImm44(inst, address, opCode);

        public OpCode32SimdImm44(InstDescriptor inst, ulong address, int opCode) : base(inst, address, opCode)
        {
            Size = (opCode >> 8) & 0x3;

            bool single = Size != 3;

            if (single)
            {
                Vd = ((opCode >> 22) & 0x1) | ((opCode >> 11) & 0x1e);
            }
            else
            {
                Vd = ((opCode >> 18) & 0x10) | ((opCode >> 12) & 0xf);
            }

            long imm;

            imm = ((uint)opCode >> 0) & 0xf;
            imm |= ((uint)opCode >> 12) & 0xf0;

            Immediate = (Size == 3) ? (long)DecoderHelper.Imm8ToFP64Table[(int)imm] : DecoderHelper.Imm8ToFP32Table[(int)imm];

            RegisterSize = (!single) ? RegisterSize.Int64 : RegisterSize.Int32;
            Elems = 1;
        }
    }
}