aboutsummaryrefslogtreecommitdiff
path: root/src/ARMeilleure/Decoders/OpCodeMemLit.cs
blob: 8712a78e32f9afce64165367326250d0a694dbf6 (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
namespace ARMeilleure.Decoders
{
    class OpCodeMemLit : OpCode, IOpCodeLit
    {
        public int Rt { get; }
        public long Immediate { get; }
        public int Size { get; }
        public bool Signed { get; }
        public bool Prefetch { get; }

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

        public OpCodeMemLit(InstDescriptor inst, ulong address, int opCode) : base(inst, address, opCode)
        {
            Rt = opCode & 0x1f;

            Immediate = (long)address + DecoderHelper.DecodeImmS19_2(opCode);

            switch ((opCode >> 30) & 3)
            {
                case 0:
                    Size = 2;
                    Signed = false;
                    Prefetch = false;
                    break;
                case 1:
                    Size = 3;
                    Signed = false;
                    Prefetch = false;
                    break;
                case 2:
                    Size = 2;
                    Signed = true;
                    Prefetch = false;
                    break;
                case 3:
                    Size = 0;
                    Signed = false;
                    Prefetch = true;
                    break;
            }
        }
    }
}