예제 #1
0
        public OpCodeAluImm64(Inst inst, long position, int opCode) : base(inst, position, opCode)
        {
            if (DataOp == DataOp.Arithmetic)
            {
                Imm = (opCode >> 10) & 0xfff;

                int shift = (opCode >> 22) & 3;

                Imm <<= shift * 12;
            }
            else if (DataOp == DataOp.Logical)
            {
                var bm = DecoderHelper.DecodeBitMask(opCode, true);

                if (bm.IsUndefined)
                {
                    Emitter = InstEmit.Und;

                    return;
                }

                Imm = bm.WMask;
            }
            else
            {
                throw new ArgumentException(nameof(opCode));
            }
        }
예제 #2
0
        public OpCodeAdr64(Inst inst, long position, int opCode) : base(inst, position, opCode)
        {
            Rd = opCode & 0x1f;

            Imm  = DecoderHelper.DecodeImmS19_2(opCode);
            Imm |= ((long)opCode >> 29) & 3;
        }
예제 #3
0
        public OpCodeBImmTest64(Inst inst, long position, int opCode) : base(inst, position, opCode)
        {
            Rt = opCode & 0x1f;

            Imm = position + DecoderHelper.DecodeImmS14_2(opCode);

            Pos  = (opCode >> 19) & 0x1f;
            Pos |= (opCode >> 26) & 0x20;
        }
예제 #4
0
        public OpCodeBImmCmp64(Inst inst, long position, int opCode) : base(inst, position, opCode)
        {
            Rt = opCode & 0x1f;

            Imm = position + DecoderHelper.DecodeImmS19_2(opCode);

            RegisterSize = (opCode >> 31) != 0
                ? State.RegisterSize.Int64
                : State.RegisterSize.Int32;
        }
예제 #5
0
        public OpCodeSimdImm64(Inst inst, long position, int opCode) : base(inst, position, opCode)
        {
            Rd = opCode & 0x1f;

            int cMode = (opCode >> 12) & 0xf;
            int op    = (opCode >> 29) & 0x1;

            int modeLow  = cMode & 1;
            int modeHigh = cMode >> 1;

            long imm;

            imm  = ((uint)opCode >> 5) & 0x1f;
            imm |= ((uint)opCode >> 11) & 0xe0;

            if (modeHigh == 0b111)
            {
                Size = modeLow != 0 ? op : 3;

                switch (op | (modeLow << 1))
                {
                case 0:
                    // 64-bits Immediate.
                    // Transform abcd efgh into abcd efgh abcd efgh ...
                    imm = (long)((ulong)imm * 0x0101010101010101);
                    break;

                case 1:
                    // 64-bits Immediate.
                    // Transform abcd efgh into aaaa aaaa bbbb bbbb ...
                    imm = (imm & 0xf0) >> 4 | (imm & 0x0f) << 4;
                    imm = (imm & 0xcc) >> 2 | (imm & 0x33) << 2;
                    imm = (imm & 0xaa) >> 1 | (imm & 0x55) << 1;

                    imm = (long)((ulong)imm * 0x8040201008040201);
                    imm = (long)((ulong)imm & 0x8080808080808080);

                    imm |= imm >> 4;
                    imm |= imm >> 2;
                    imm |= imm >> 1;
                    break;

                case 2:
                case 3:
                    // Floating point Immediate.
                    imm = DecoderHelper.DecodeImm8Float(imm, Size);
                    break;
                }
            }
            else if ((modeHigh & 0b110) == 0b100)
            {
                // 16-bits shifted Immediate.
                Size = 1; imm <<= (modeHigh & 1) << 3;
            }
예제 #6
0
        public OpCodeBImmCond64(Inst inst, long position, int opCode) : base(inst, position, opCode)
        {
            int o0 = (opCode >> 4) & 1;

            if (o0 != 0)
            {
                Emitter = InstEmit.Und;

                return;
            }

            Cond = (Condition)(opCode & 0xf);

            Imm = position + DecoderHelper.DecodeImmS19_2(opCode);
        }
예제 #7
0
        public OpCodeBfm64(Inst inst, long position, int opCode) : base(inst, position, opCode)
        {
            var bm = DecoderHelper.DecodeBitMask(opCode, false);

            if (bm.IsUndefined)
            {
                Emitter = InstEmit.Und;

                return;
            }

            WMask = bm.WMask;
            TMask = bm.TMask;
            Pos   = bm.Pos;
            Shift = bm.Shift;
        }
예제 #8
0
        public OpCodeMemLit64(Inst inst, long position, int opCode) : base(inst, position, opCode)
        {
            Rt = opCode & 0x1f;

            Imm = position + 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;
            }
        }
예제 #9
0
        public OpCodeSimdMemLit64(Inst inst, long position, int opCode) : base(inst, position, opCode)
        {
            int opc = (opCode >> 30) & 3;

            if (opc == 3)
            {
                Emitter = InstEmit.Und;

                return;
            }

            Rt = opCode & 0x1f;

            Imm = position + DecoderHelper.DecodeImmS19_2(opCode);

            Size = opc + 2;
        }
예제 #10
0
        public OpCode32BImm(Inst inst, long position, int opCode) : base(inst, position, opCode)
        {
            uint pc = GetPc();

            // When the condition 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;
            }
        }
예제 #11
0
        public OpCodeSimdFmov64(Inst inst, long position, int opCode) : base(inst, position, opCode)
        {
            int imm5 = (opCode >> 5) & 0x1f;
            int type = (opCode >> 22) & 0x3;

            if (imm5 != 0b00000 || type > 1)
            {
                Emitter = InstEmit.Und;

                return;
            }

            Size = type;

            long imm;

            Rd  = (opCode >> 0) & 0x1f;
            imm = (opCode >> 13) & 0xff;

            Imm = DecoderHelper.DecodeImm8Float(imm, type);
        }
예제 #12
0
 public OpCodeBImmAl64(Inst inst, long position, int opCode) : base(inst, position, opCode)
 {
     Imm = position + DecoderHelper.DecodeImm26_2(opCode);
 }