Пример #1
0
 public SimpleInstrInfo_os_jcc(Code code, int codeSize, string mnemonic, InstrOpInfoFlags flags)
     : base(code)
 {
     this.codeSize = codeSize;
     this.mnemonic = mnemonic;
     this.flags    = flags;
 }
Пример #2
0
 public SimpleInstrInfo_pops(Code code, string mnemonic, string[] pseudo_ops, InstrOpInfoFlags flags)
     : base(code)
 {
     this.mnemonic   = mnemonic;
     this.pseudo_ops = pseudo_ops;
     this.flags      = flags;
 }
Пример #3
0
 public SimpleInstrInfo_reg(Code code, string mnemonic, Register register, InstrOpInfoFlags flags)
     : base(code)
 {
     this.mnemonic = mnemonic;
     this.register = register;
     this.flags    = flags;
 }
Пример #4
0
 public SimpleInstrInfo_ST1(Code code, string mnemonic, InstrOpInfoFlags flags, bool isLoad)
     : base(code)
 {
     this.mnemonic = mnemonic;
     this.flags    = flags;
     op0Access     = isLoad ? OpAccess_Write : OpAccess_ReadWrite;
 }
Пример #5
0
        public override void GetOpInfo(IntelFormatterOptions options, ref Instruction instr, out InstrOpInfo info)
        {
            var flags = this.flags;

            if (instr.HasRepnePrefix)
            {
                flags |= InstrOpInfoFlags.BndPrefix;
            }
            int instrCodeSize = GetCodeSize(instr.CodeSize);

            if (instrCodeSize != 0 && instrCodeSize != codeSize)
            {
                if (codeSize == 16)
                {
                    flags |= InstrOpInfoFlags.OpSize16;
                }
                else if (codeSize == 32)
                {
                    flags |= InstrOpInfoFlags.OpSize32;
                }
                else
                {
                    flags |= InstrOpInfoFlags.OpSize64;
                }
            }
            info = new InstrOpInfo(mnemonic, ref instr, flags);
        }
Пример #6
0
 public SimpleInstrInfo_nop0F1F(Code code, Register reg, string mnemonic, InstrOpInfoFlags flags)
     : base(code)
 {
     this.mnemonic = mnemonic;
     this.flags    = flags;
     this.reg      = reg;
 }
Пример #7
0
 public SimpleInstrInfo_AY(Code code, string mnemonic_args, string mnemonic_no_args, InstrOpInfoFlags flags)
     : base(code)
 {
     this.mnemonic_args    = mnemonic_args;
     this.mnemonic_no_args = mnemonic_no_args;
     this.flags            = flags;
 }
Пример #8
0
        public override void GetOpInfo(IntelFormatterOptions options, ref Instruction instr, out InstrOpInfo info)
        {
            var flags = this.flags;

            if (instr.HasRepnePrefix)
            {
                flags |= InstrOpInfoFlags.BndPrefix;
            }
            info = new InstrOpInfo(mnemonic, ref instr, flags);
        }
Пример #9
0
        public override void GetOpInfo(IntelFormatterOptions options, ref Instruction instr, out InstrOpInfo info)
        {
            const InstrOpInfoFlags flags = InstrOpInfoFlags.None;

            info = new InstrOpInfo(mnemonic, ref instr, flags);
            if (Register.EAX <= (Register)info.Op0Register && (Register)info.Op0Register <= Register.R15D)
            {
                info.Op0Register = (byte)((Register)info.Op0Register - Register.EAX + Register.AX);
            }
            if (Register.EAX <= (Register)info.Op1Register && (Register)info.Op1Register <= Register.R15D)
            {
                info.Op1Register = (byte)((Register)info.Op1Register - Register.EAX + Register.AX);
            }
        }
Пример #10
0
        public override void GetOpInfo(IntelFormatterOptions options, ref Instruction instr, out InstrOpInfo info)
        {
            const InstrOpInfoFlags flags = 0;

            if (options.UsePseudoOps && (instr.Op0Register == Register.ST1 || instr.Op1Register == Register.ST1))
            {
                info          = default;
                info.Mnemonic = mnemonic;
            }
            else
            {
                info = new InstrOpInfo(mnemonic, ref instr, flags);
                Debug.Assert(info.Op1Register == (int)Register.ST0);
                Debug.Assert(InstrOpInfo.TEST_RegisterBits == 8);
                info.Op1Register = (byte)Registers.Register_ST;
            }
        }
Пример #11
0
 public InstrOpInfo(string mnemonic, ref Instruction instr, InstrOpInfoFlags flags)
 {
     Mnemonic = mnemonic;
     Flags    = flags;
     OpCount  = (byte)instr.OpCount;
     Debug.Assert(instr.OpCount <= 4);
     Op0Kind = (InstrOpKind)instr.Op0Kind;
     Op1Kind = (InstrOpKind)instr.Op1Kind;
     Op2Kind = (InstrOpKind)instr.Op2Kind;
     Op3Kind = (InstrOpKind)instr.Op3Kind;
     Debug.Assert(TEST_RegisterBits == 8);
     Op0Register = (byte)instr.Op0Register;
     Debug.Assert(TEST_RegisterBits == 8);
     Op1Register = (byte)instr.Op1Register;
     Debug.Assert(TEST_RegisterBits == 8);
     Op2Register = (byte)instr.Op2Register;
     Debug.Assert(TEST_RegisterBits == 8);
     Op3Register = (byte)instr.Op3Register;
 }
Пример #12
0
 public InstrOpInfo(string mnemonic, ref Instruction instr, InstrOpInfoFlags flags)
 {
     Debug.Assert(DecoderConstants.MaxOpCount == 5);
     Mnemonic = mnemonic;
     Flags    = flags;
     OpCount  = (byte)instr.OpCount;
     Op0Kind  = (InstrOpKind)instr.Op0Kind;
     Op1Kind  = (InstrOpKind)instr.Op1Kind;
     Op2Kind  = (InstrOpKind)instr.Op2Kind;
     Op3Kind  = (InstrOpKind)instr.Op3Kind;
     Op4Kind  = (InstrOpKind)instr.Op4Kind;
     Debug.Assert(TEST_RegisterBits == 8);
     Op0Register = (byte)instr.Op0Register;
     Debug.Assert(TEST_RegisterBits == 8);
     Op1Register = (byte)instr.Op1Register;
     Debug.Assert(TEST_RegisterBits == 8);
     Op2Register = (byte)instr.Op2Register;
     Debug.Assert(TEST_RegisterBits == 8);
     Op3Register = (byte)instr.Op3Register;
     Debug.Assert(TEST_RegisterBits == 8);
     Op4Register = (byte)instr.Op4Register;
 }
Пример #13
0
        public override void GetOpInfo(IntelFormatterOptions options, ref Instruction instr, out InstrOpInfo info)
        {
            var flags         = this.flags;
            int instrCodeSize = GetCodeSize(instr.CodeSize);

            if (instrCodeSize != 0 && instrCodeSize != codeSize)
            {
                if (codeSize == 16)
                {
                    flags |= InstrOpInfoFlags.OpSize16;
                }
                else if (codeSize == 32)
                {
                    flags |= InstrOpInfoFlags.OpSize32;
                }
                else
                {
                    flags |= InstrOpInfoFlags.OpSize64;
                }
            }
            var prefixSeg = instr.SegmentPrefix;

            if (prefixSeg == Register.CS)
            {
                flags |= InstrOpInfoFlags.IgnoreSegmentPrefix | InstrOpInfoFlags.JccNotTaken;
            }
            else if (prefixSeg == Register.DS)
            {
                flags |= InstrOpInfoFlags.IgnoreSegmentPrefix | InstrOpInfoFlags.JccTaken;
            }
            if (instr.HasRepnePrefix)
            {
                flags |= InstrOpInfoFlags.BndPrefix;
            }
            info = new InstrOpInfo(mnemonic, ref instr, flags);
        }
Пример #14
0
        static string ToString(StringBuilder sb, InstrOpInfoFlags flags)
        {
            sb.Clear();

            if ((flags & InstrOpInfoFlags.MnemonicSuffixIfMem) != 0)
            {
                flags &= ~InstrOpInfoFlags.MnemonicSuffixIfMem;
                Append(sb, nameof(InstrOpInfoFlags.MnemonicSuffixIfMem));
            }

            switch (flags & (InstrOpInfoFlags)((int)InstrOpInfoFlags.SizeOverrideMask << (int)InstrOpInfoFlags.OpSizeShift))
            {
            case 0: break;

            case InstrOpInfoFlags.OpSize16: Append(sb, nameof(InstrOpInfoFlags.OpSize16)); break;

            case InstrOpInfoFlags.OpSize32: Append(sb, nameof(InstrOpInfoFlags.OpSize32)); break;

            case InstrOpInfoFlags.OpSize64: Append(sb, nameof(InstrOpInfoFlags.OpSize64)); break;

            default: throw new InvalidOperationException();
            }
            flags &= ~(InstrOpInfoFlags)((int)InstrOpInfoFlags.SizeOverrideMask << (int)InstrOpInfoFlags.OpSizeShift);

            switch (flags & (InstrOpInfoFlags)((int)InstrOpInfoFlags.SizeOverrideMask << (int)InstrOpInfoFlags.AddrSizeShift))
            {
            case 0: break;

            case InstrOpInfoFlags.AddrSize16: Append(sb, nameof(InstrOpInfoFlags.AddrSize16)); break;

            case InstrOpInfoFlags.AddrSize32: Append(sb, nameof(InstrOpInfoFlags.AddrSize32)); break;

            case InstrOpInfoFlags.AddrSize64: Append(sb, nameof(InstrOpInfoFlags.AddrSize64)); break;

            default: throw new InvalidOperationException();
            }
            flags &= ~(InstrOpInfoFlags)((int)InstrOpInfoFlags.SizeOverrideMask << (int)InstrOpInfoFlags.AddrSizeShift);

            if ((flags & InstrOpInfoFlags.IndirectOperand) != 0)
            {
                flags &= ~InstrOpInfoFlags.IndirectOperand;
                Append(sb, nameof(InstrOpInfoFlags.IndirectOperand));
            }

            if ((flags & InstrOpInfoFlags.OpSizeIsByteDirective) != 0)
            {
                flags &= ~InstrOpInfoFlags.OpSizeIsByteDirective;
                Append(sb, nameof(InstrOpInfoFlags.OpSizeIsByteDirective));
            }

            if ((flags & InstrOpInfoFlags.KeepOperandOrder) != 0)
            {
                flags &= ~InstrOpInfoFlags.KeepOperandOrder;
                Append(sb, nameof(InstrOpInfoFlags.KeepOperandOrder));
            }

            if ((flags & InstrOpInfoFlags.JccNotTaken) != 0)
            {
                flags &= ~InstrOpInfoFlags.JccNotTaken;
                Append(sb, nameof(InstrOpInfoFlags.JccNotTaken));
            }

            if ((flags & InstrOpInfoFlags.JccTaken) != 0)
            {
                flags &= ~InstrOpInfoFlags.JccTaken;
                Append(sb, nameof(InstrOpInfoFlags.JccTaken));
            }

            if ((flags & InstrOpInfoFlags.BndPrefix) != 0)
            {
                flags &= ~InstrOpInfoFlags.BndPrefix;
                Append(sb, nameof(InstrOpInfoFlags.BndPrefix));
            }

            if ((flags & InstrOpInfoFlags.IgnoreIndexReg) != 0)
            {
                flags &= ~InstrOpInfoFlags.IgnoreIndexReg;
                Append(sb, nameof(InstrOpInfoFlags.IgnoreIndexReg));
            }

            if ((flags & InstrOpInfoFlags.MnemonicIsDirective) != 0)
            {
                flags &= ~InstrOpInfoFlags.MnemonicIsDirective;
                Append(sb, nameof(InstrOpInfoFlags.MnemonicIsDirective));
            }

            if (flags != 0)
            {
                throw new InvalidOperationException();
            }

            if (sb.Length == 0)
            {
                Append(sb, nameof(InstrOpInfoFlags.None));
            }

            return(sb.ToString());
        }
Пример #15
0
        public override void GetOpInfo(IntelFormatterOptions options, ref Instruction instr, out InstrOpInfo info)
        {
            Debug.Assert(instr.OpCount == 3);

            var    opKind = instr.Op0Kind;
            OpKind shortFormOpKind;

            switch (instr.CodeSize)
            {
            case CodeSize.Unknown:
                shortFormOpKind = opKind;
                break;

            case CodeSize.Code16:
                shortFormOpKind = OpKind.MemorySegDI;
                break;

            case CodeSize.Code32:
                shortFormOpKind = OpKind.MemorySegEDI;
                break;

            case CodeSize.Code64:
                shortFormOpKind = OpKind.MemorySegRDI;
                break;

            default:
                throw new InvalidOperationException();
            }

            var flags = this.flags;

            if (opKind != shortFormOpKind)
            {
                if (opKind == OpKind.MemorySegDI)
                {
                    flags |= InstrOpInfoFlags.AddrSize16;
                }
                else if (opKind == OpKind.MemorySegEDI)
                {
                    flags |= InstrOpInfoFlags.AddrSize32;
                }
                else if (opKind == OpKind.MemorySegRDI)
                {
                    flags |= InstrOpInfoFlags.AddrSize64;
                }
            }
            info          = default;
            info.Flags    = flags;
            info.Mnemonic = mnemonic;
            info.OpCount  = 2;
            info.Op0Kind  = (InstrOpKind)instr.Op1Kind;
            info.Op0Index = 1;
            Debug.Assert(InstrOpInfo.TEST_RegisterBits == 8);
            info.Op0Register = (byte)instr.Op1Register;
            info.Op1Kind     = (InstrOpKind)instr.Op2Kind;
            info.Op1Index    = 2;
            Debug.Assert(InstrOpInfo.TEST_RegisterBits == 8);
            info.Op1Register = (byte)instr.Op2Register;
            var segReg = instr.SegmentPrefix;

            if (segReg != Register.None)
            {
                info.OpCount = 3;
                info.Op2Kind = InstrOpKind.Register;
                Debug.Assert(InstrOpInfo.TEST_RegisterBits == 8);
                info.Op2Register = (byte)segReg;
                info.Op2Index    = OpAccess_Read;
            }
        }
Пример #16
0
 public SimpleInstrInfo_maskmovq(Code code, string mnemonic, InstrOpInfoFlags flags)
     : base(code)
 {
     this.mnemonic = mnemonic;
     this.flags    = flags | InstrOpInfoFlags.IgnoreSegmentPrefix;
 }
Пример #17
0
 public SimpleInstrInfo_ST2(Code code, string mnemonic, InstrOpInfoFlags flags)
     : base(code)
 {
     this.mnemonic = mnemonic;
     this.flags    = flags;
 }
Пример #18
0
        static string ToString(StringBuilder sb, InstrOpInfoFlags flags)
        {
            sb.Clear();

            if ((flags & InstrOpInfoFlags.MemSize_Nothing) != 0)
            {
                flags &= ~InstrOpInfoFlags.MemSize_Nothing;
                Append(sb, nameof(InstrOpInfoFlags.MemSize_Nothing));
            }

            if ((flags & InstrOpInfoFlags.ShowNoMemSize_ForceSize) != 0)
            {
                flags &= ~InstrOpInfoFlags.ShowNoMemSize_ForceSize;
                Append(sb, nameof(InstrOpInfoFlags.ShowNoMemSize_ForceSize));
            }

            if ((flags & InstrOpInfoFlags.ShowMinMemSize_ForceSize) != 0)
            {
                flags &= ~InstrOpInfoFlags.ShowMinMemSize_ForceSize;
                Append(sb, nameof(InstrOpInfoFlags.ShowMinMemSize_ForceSize));
            }

            switch (flags & (InstrOpInfoFlags)((int)InstrOpInfoFlags.SizeOverrideMask << (int)InstrOpInfoFlags.OpSizeShift))
            {
            case 0: break;

            case InstrOpInfoFlags.OpSize16: Append(sb, nameof(InstrOpInfoFlags.OpSize16)); break;

            case InstrOpInfoFlags.OpSize32: Append(sb, nameof(InstrOpInfoFlags.OpSize32)); break;

            case InstrOpInfoFlags.OpSize64: Append(sb, nameof(InstrOpInfoFlags.OpSize64)); break;

            default: throw new InvalidOperationException();
            }
            flags &= ~(InstrOpInfoFlags)((int)InstrOpInfoFlags.SizeOverrideMask << (int)InstrOpInfoFlags.OpSizeShift);

            switch (flags & (InstrOpInfoFlags)((int)InstrOpInfoFlags.SizeOverrideMask << (int)InstrOpInfoFlags.AddrSizeShift))
            {
            case 0: break;

            case InstrOpInfoFlags.AddrSize16: Append(sb, nameof(InstrOpInfoFlags.AddrSize16)); break;

            case InstrOpInfoFlags.AddrSize32: Append(sb, nameof(InstrOpInfoFlags.AddrSize32)); break;

            case InstrOpInfoFlags.AddrSize64: Append(sb, nameof(InstrOpInfoFlags.AddrSize64)); break;

            default: throw new InvalidOperationException();
            }
            flags &= ~(InstrOpInfoFlags)((int)InstrOpInfoFlags.SizeOverrideMask << (int)InstrOpInfoFlags.AddrSizeShift);

            switch (flags & (InstrOpInfoFlags)((int)InstrOpInfoFlags.BranchSizeInfoMask << (int)InstrOpInfoFlags.BranchSizeInfoShift))
            {
            case 0: break;

            case InstrOpInfoFlags.BranchSizeInfo_Short: Append(sb, nameof(InstrOpInfoFlags.BranchSizeInfo_Short)); break;

            default: throw new InvalidOperationException();
            }
            flags &= ~(InstrOpInfoFlags)((int)InstrOpInfoFlags.BranchSizeInfoMask << (int)InstrOpInfoFlags.BranchSizeInfoShift);

            switch ((SignExtendInfo)(((uint)flags >> (int)InstrOpInfoFlags.SignExtendInfoShift) & (uint)InstrOpInfoFlags.SignExtendInfoMask))
            {
            case SignExtendInfo.None: break;

            case SignExtendInfo.Sex1to2: Append(sb, nameof(SignExtendInfo.Sex1to2)); break;

            case SignExtendInfo.Sex1to4: Append(sb, nameof(SignExtendInfo.Sex1to4)); break;

            case SignExtendInfo.Sex1to8: Append(sb, nameof(SignExtendInfo.Sex1to8)); break;

            case SignExtendInfo.Sex4to8: Append(sb, nameof(SignExtendInfo.Sex4to8)); break;

            case SignExtendInfo.Sex4to8Qword: Append(sb, nameof(SignExtendInfo.Sex4to8Qword)); break;

            case SignExtendInfo.Sex2: Append(sb, nameof(SignExtendInfo.Sex2)); break;

            case SignExtendInfo.Sex4: Append(sb, nameof(SignExtendInfo.Sex4)); break;

            default: throw new InvalidOperationException();
            }
            flags &= ~(InstrOpInfoFlags)((int)InstrOpInfoFlags.SignExtendInfoMask << (int)InstrOpInfoFlags.SignExtendInfoShift);

            switch ((((uint)flags >> (int)InstrOpInfoFlags.MemorySizeInfoShift) & (uint)InstrOpInfoFlags.MemorySizeInfoMask))
            {
            case 0: break;

            default: throw new InvalidOperationException();
            }
            flags &= ~(InstrOpInfoFlags)((int)InstrOpInfoFlags.MemorySizeInfoMask << (int)InstrOpInfoFlags.MemorySizeInfoShift);

            switch ((((uint)flags >> (int)InstrOpInfoFlags.FarMemorySizeInfoShift) & (uint)InstrOpInfoFlags.FarMemorySizeInfoMask))
            {
            case 0: break;

            default: throw new InvalidOperationException();
            }
            flags &= ~(InstrOpInfoFlags)((int)InstrOpInfoFlags.FarMemorySizeInfoMask << (int)InstrOpInfoFlags.FarMemorySizeInfoShift);

            if ((flags & InstrOpInfoFlags.RegisterTo) != 0)
            {
                flags &= ~InstrOpInfoFlags.RegisterTo;
                Append(sb, nameof(InstrOpInfoFlags.RegisterTo));
            }

            if ((flags & InstrOpInfoFlags.BndPrefix) != 0)
            {
                flags &= ~InstrOpInfoFlags.BndPrefix;
                Append(sb, nameof(InstrOpInfoFlags.BndPrefix));
            }

            if ((flags & InstrOpInfoFlags.MnemonicIsDirective) != 0)
            {
                flags &= ~InstrOpInfoFlags.MnemonicIsDirective;
                Append(sb, nameof(InstrOpInfoFlags.MnemonicIsDirective));
            }

            switch ((((uint)flags >> (int)InstrOpInfoFlags.MemorySizeShift) & (uint)InstrOpInfoFlags.MemorySizeMask))
            {
            case 0: break;

            default: throw new InvalidOperationException();
            }
            flags &= ~(InstrOpInfoFlags)((int)InstrOpInfoFlags.MemorySizeMask << (int)InstrOpInfoFlags.MemorySizeShift);

            if (flags != 0)
            {
                throw new InvalidOperationException();
            }

            if (sb.Length == 0)
            {
                Append(sb, nameof(InstrOpInfoFlags.None));
            }

            return(sb.ToString());
        }
Пример #19
0
 public SimpleInstrInfo_ST1(Code code, string mnemonic, InstrOpInfoFlags flags) : this(code, mnemonic, flags, false)
 {
 }
Пример #20
0
        public InstrOpInfo(string mnemonic, ref Instruction instr, InstrOpInfoFlags flags)
        {
            Debug.Assert(DecoderConstants.MaxOpCount == 5);
            Mnemonic = mnemonic;
            Flags    = flags;
            Op0Kind  = (InstrOpKind)instr.Op0Kind;
            Op1Kind  = (InstrOpKind)instr.Op1Kind;
            Op2Kind  = (InstrOpKind)instr.Op2Kind;
            Op3Kind  = (InstrOpKind)instr.Op3Kind;
            Op4Kind  = (InstrOpKind)instr.Op4Kind;
            Debug.Assert(TEST_RegisterBits == 8);
            Op0Register = (byte)instr.Op0Register;
            Debug.Assert(TEST_RegisterBits == 8);
            Op1Register = (byte)instr.Op1Register;
            Debug.Assert(TEST_RegisterBits == 8);
            Op2Register = (byte)instr.Op2Register;
            Debug.Assert(TEST_RegisterBits == 8);
            Op3Register = (byte)instr.Op3Register;
            Debug.Assert(TEST_RegisterBits == 8);
            Op4Register = (byte)instr.Op4Register;
            int opCount = instr.OpCount;

            OpCount = (byte)opCount;
            switch (opCount)
            {
            case 0:
                Op0Index = InstrInfo.OpAccess_INVALID;
                Op1Index = InstrInfo.OpAccess_INVALID;
                Op2Index = InstrInfo.OpAccess_INVALID;
                Op3Index = InstrInfo.OpAccess_INVALID;
                Op4Index = InstrInfo.OpAccess_INVALID;
                break;

            case 1:
                Op0Index = 0;
                Op1Index = InstrInfo.OpAccess_INVALID;
                Op2Index = InstrInfo.OpAccess_INVALID;
                Op3Index = InstrInfo.OpAccess_INVALID;
                Op4Index = InstrInfo.OpAccess_INVALID;
                break;

            case 2:
                Op0Index = 0;
                Op1Index = 1;
                Op2Index = InstrInfo.OpAccess_INVALID;
                Op3Index = InstrInfo.OpAccess_INVALID;
                Op4Index = InstrInfo.OpAccess_INVALID;
                break;

            case 3:
                Op0Index = 0;
                Op1Index = 1;
                Op2Index = 2;
                Op3Index = InstrInfo.OpAccess_INVALID;
                Op4Index = InstrInfo.OpAccess_INVALID;
                break;

            case 4:
                Op0Index = 0;
                Op1Index = 1;
                Op2Index = 2;
                Op3Index = 3;
                Op4Index = InstrInfo.OpAccess_INVALID;
                break;

            case 5:
                Op0Index = 0;
                Op1Index = 1;
                Op2Index = 2;
                Op3Index = 3;
                Op4Index = 4;
                break;

            default:
                throw new InvalidOperationException();
            }
        }
Пример #21
0
        static string ToString(StringBuilder sb, InstrOpInfoFlags flags)
        {
            sb.Clear();

            if ((flags & InstrOpInfoFlags.MemSize_Nothing) != 0)
            {
                flags &= ~InstrOpInfoFlags.MemSize_Nothing;
                Append(sb, nameof(InstrOpInfoFlags.MemSize_Nothing));
            }

            if ((flags & InstrOpInfoFlags.ShowNoMemSize_ForceSize) != 0)
            {
                flags &= ~InstrOpInfoFlags.ShowNoMemSize_ForceSize;
                Append(sb, nameof(InstrOpInfoFlags.ShowNoMemSize_ForceSize));
            }

            if ((flags & InstrOpInfoFlags.ShowMinMemSize_ForceSize) != 0)
            {
                flags &= ~InstrOpInfoFlags.ShowMinMemSize_ForceSize;
                Append(sb, nameof(InstrOpInfoFlags.ShowMinMemSize_ForceSize));
            }

            switch (flags & (InstrOpInfoFlags)((int)InstrOpInfoFlags.BranchSizeInfoMask << (int)InstrOpInfoFlags.BranchSizeInfoShift))
            {
            case 0: break;

            case InstrOpInfoFlags.BranchSizeInfo_Short: Append(sb, nameof(InstrOpInfoFlags.BranchSizeInfo_Short)); break;

            default: throw new InvalidOperationException();
            }
            flags &= ~(InstrOpInfoFlags)((int)InstrOpInfoFlags.BranchSizeInfoMask << (int)InstrOpInfoFlags.BranchSizeInfoShift);

            switch (flags & (InstrOpInfoFlags)((int)InstrOpInfoFlags.SizeOverrideMask << (int)InstrOpInfoFlags.OpSizeShift))
            {
            case 0: break;

            case InstrOpInfoFlags.OpSize16: Append(sb, nameof(InstrOpInfoFlags.OpSize16)); break;

            case InstrOpInfoFlags.OpSize32: Append(sb, nameof(InstrOpInfoFlags.OpSize32)); break;

            case InstrOpInfoFlags.OpSize64: Append(sb, nameof(InstrOpInfoFlags.OpSize64)); break;

            default: throw new InvalidOperationException();
            }
            flags &= ~(InstrOpInfoFlags)((int)InstrOpInfoFlags.SizeOverrideMask << (int)InstrOpInfoFlags.OpSizeShift);

            switch (flags & (InstrOpInfoFlags)((int)InstrOpInfoFlags.SizeOverrideMask << (int)InstrOpInfoFlags.AddrSizeShift))
            {
            case 0: break;

            case InstrOpInfoFlags.AddrSize16: Append(sb, nameof(InstrOpInfoFlags.AddrSize16)); break;

            case InstrOpInfoFlags.AddrSize32: Append(sb, nameof(InstrOpInfoFlags.AddrSize32)); break;

            case InstrOpInfoFlags.AddrSize64: Append(sb, nameof(InstrOpInfoFlags.AddrSize64)); break;

            default: throw new InvalidOperationException();
            }
            flags &= ~(InstrOpInfoFlags)((int)InstrOpInfoFlags.SizeOverrideMask << (int)InstrOpInfoFlags.AddrSizeShift);

            if ((flags & InstrOpInfoFlags.IgnoreOpMask) != 0)
            {
                flags &= ~InstrOpInfoFlags.IgnoreOpMask;
                Append(sb, nameof(InstrOpInfoFlags.IgnoreOpMask));
            }

            if ((flags & InstrOpInfoFlags.FarMnemonic) != 0)
            {
                flags &= ~InstrOpInfoFlags.FarMnemonic;
                Append(sb, nameof(InstrOpInfoFlags.FarMnemonic));
            }

            if ((flags & InstrOpInfoFlags.JccNotTaken) != 0)
            {
                flags &= ~InstrOpInfoFlags.JccNotTaken;
                Append(sb, nameof(InstrOpInfoFlags.JccNotTaken));
            }

            if ((flags & InstrOpInfoFlags.JccTaken) != 0)
            {
                flags &= ~InstrOpInfoFlags.JccTaken;
                Append(sb, nameof(InstrOpInfoFlags.JccTaken));
            }

            if ((flags & InstrOpInfoFlags.BndPrefix) != 0)
            {
                flags &= ~InstrOpInfoFlags.BndPrefix;
                Append(sb, nameof(InstrOpInfoFlags.BndPrefix));
            }

            if ((flags & InstrOpInfoFlags.IgnoreIndexReg) != 0)
            {
                flags &= ~InstrOpInfoFlags.IgnoreIndexReg;
                Append(sb, nameof(InstrOpInfoFlags.IgnoreIndexReg));
            }

            if ((flags & InstrOpInfoFlags.IgnoreSegmentPrefix) != 0)
            {
                flags &= ~InstrOpInfoFlags.IgnoreSegmentPrefix;
                Append(sb, nameof(InstrOpInfoFlags.IgnoreSegmentPrefix));
            }

            if ((flags & InstrOpInfoFlags.MnemonicIsDirective) != 0)
            {
                flags &= ~InstrOpInfoFlags.MnemonicIsDirective;
                Append(sb, nameof(InstrOpInfoFlags.MnemonicIsDirective));
            }

            if (flags != 0)
            {
                throw new InvalidOperationException();
            }

            if (sb.Length == 0)
            {
                Append(sb, nameof(InstrOpInfoFlags.None));
            }

            return(sb.ToString());
        }
Пример #22
0
        static string ToString(StringBuilder sb, InstrOpInfoFlags flags)
        {
            sb.Clear();

            switch (flags & (InstrOpInfoFlags)((int)InstrOpInfoFlags.MemSize_Mask << 0))
            {
            case 0: break;

            case InstrOpInfoFlags.MemSize_Mmx: Append(sb, nameof(InstrOpInfoFlags.MemSize_Mmx)); break;

            case InstrOpInfoFlags.MemSize_Normal: Append(sb, nameof(InstrOpInfoFlags.MemSize_Normal)); break;

            case InstrOpInfoFlags.MemSize_Nothing: Append(sb, nameof(InstrOpInfoFlags.MemSize_Nothing)); break;

            case InstrOpInfoFlags.MemSize_XmmwordPtr: Append(sb, nameof(InstrOpInfoFlags.MemSize_XmmwordPtr)); break;

            case InstrOpInfoFlags.MemSize_DwordOrQword: Append(sb, nameof(InstrOpInfoFlags.MemSize_DwordOrQword)); break;

            default: throw new InvalidOperationException();
            }
            flags &= ~(InstrOpInfoFlags)((int)InstrOpInfoFlags.MemSize_Mask << 0);

            if ((flags & InstrOpInfoFlags.ShowNoMemSize_ForceSize) != 0)
            {
                flags &= ~InstrOpInfoFlags.ShowNoMemSize_ForceSize;
                Append(sb, nameof(InstrOpInfoFlags.ShowNoMemSize_ForceSize));
            }

            if ((flags & InstrOpInfoFlags.ShowMinMemSize_ForceSize) != 0)
            {
                flags &= ~InstrOpInfoFlags.ShowMinMemSize_ForceSize;
                Append(sb, nameof(InstrOpInfoFlags.ShowMinMemSize_ForceSize));
            }

            if ((flags & InstrOpInfoFlags.JccNotTaken) != 0)
            {
                flags &= ~InstrOpInfoFlags.JccNotTaken;
                Append(sb, nameof(InstrOpInfoFlags.JccNotTaken));
            }

            if ((flags & InstrOpInfoFlags.JccTaken) != 0)
            {
                flags &= ~InstrOpInfoFlags.JccTaken;
                Append(sb, nameof(InstrOpInfoFlags.JccTaken));
            }

            if ((flags & InstrOpInfoFlags.BndPrefix) != 0)
            {
                flags &= ~InstrOpInfoFlags.BndPrefix;
                Append(sb, nameof(InstrOpInfoFlags.BndPrefix));
            }

            if ((flags & InstrOpInfoFlags.IgnoreIndexReg) != 0)
            {
                flags &= ~InstrOpInfoFlags.IgnoreIndexReg;
                Append(sb, nameof(InstrOpInfoFlags.IgnoreIndexReg));
            }

            if ((flags & InstrOpInfoFlags.MnemonicIsDirective) != 0)
            {
                flags &= ~InstrOpInfoFlags.MnemonicIsDirective;
                Append(sb, nameof(InstrOpInfoFlags.MnemonicIsDirective));
            }

            if (flags != 0)
            {
                throw new InvalidOperationException();
            }

            if (sb.Length == 0)
            {
                Append(sb, nameof(InstrOpInfoFlags.None));
            }

            return(sb.ToString());
        }
Пример #23
0
 public SimpleInstrInfo_mmxmem(Code code, string mnemonic, InstrOpInfoFlags flags)
     : base(code)
 {
     this.mnemonic = mnemonic;
     this.flags    = flags | InstrOpInfoFlags.MemSize_Mmx;
 }