aboutsummaryrefslogtreecommitdiff
path: root/ChocolArm64/Decoders/OpCode32BImm.cs
blob: 43f191eb4dca903b490238278c45e569103afd78 (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
using ChocolArm64.Instructions;

namespace ChocolArm64.Decoders
{
    class OpCode32BImm : OpCode32, IOpCode32BImm
    {
        public long Imm { get; private set; }

        public OpCode32BImm(Inst inst, long position, int opCode) : base(inst, position, opCode)
        {
            uint pc = GetPc();

            //When the codition is never, the instruction is BLX to Thumb mode.
            if (Cond != Condition.Nv)
            {
                pc &= ~3u;
            }

            Imm = pc + DecoderHelper.DecodeImm24_2(opCode);

            if (Cond == Condition.Nv)
            {
                long H = (opCode >> 23) & 2;

                Imm |= H;
            }
        }
    }
}