Ejemplo n.º 1
0
 public static bool InstructionHasImmediate(this OperandEncoding encoding)
 {
     return(encoding == OperandEncoding.I ||
            encoding == OperandEncoding.MI ||
            encoding == OperandEncoding.OI ||
            encoding == OperandEncoding.RMI ||
            encoding == OperandEncoding.D);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="OperandDescriptor"/> structure.
 /// </summary>
 /// <param name="operandType">The type of operand.</param>
 /// <param name="registerType">A bitwise combination of valid types of the register.</param>
 /// <param name="size">The size of the operand.</param>
 /// <param name="encoding">Specifies how the operand is encoded.</param>
 OperandDescriptor(OperandType operandType, RegisterType registerType, DataSize size, OperandEncoding encoding)
 {
     OperandType     = operandType;
     RegisterType    = registerType;
     Size            = (size != DataSize.None ? size : registerType.GetSize());
     FixedRegister   = Register.None;
     OperandEncoding = encoding;
 }
Ejemplo n.º 3
0
 public OpCodeOperandKindDef(EnumValue enumValue, OpCodeOperandKindDefFlags flags, OperandEncoding encoding, int arg1, int arg2, Register register)
 {
     EnumValue = enumValue;
     Flags = flags;
     OperandEncoding = encoding;
     this.arg1 = arg1;
     this.arg2 = arg2;
     this.register = register;
 }
Ejemplo n.º 4
0
 public static bool RequiresModRM(this OperandEncoding encoding)
 {
     return(encoding == OperandEncoding.M ||
            encoding == OperandEncoding.MI ||
            encoding == OperandEncoding.MR ||
            encoding == OperandEncoding.RM ||
            encoding == OperandEncoding.RMI ||
            encoding == OperandEncoding.M1 ||
            encoding == OperandEncoding.MC);
 }
Ejemplo n.º 5
0
 protected OpCode(byte[] code, string name, OperandEncoding opEn, string description, int operandSize, int extension = -1, bool signExtended = false, int signExtensionSize = 64)
 {
     this.Code                  = code;
     this.Name                  = name;
     this.OpEn                  = opEn;
     this.Description           = description;
     this.OperandSize           = operandSize;
     this.Extension             = extension;
     this.SignExtendedImmediate = signExtended;
     this.SignExtensionSize     = signExtensionSize;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="OperandDescriptor"/> structure.
 /// </summary>
 /// <param name="operandType">The type of operand.</param>
 /// <param name="size">The size of the operand.</param>
 /// <param name="encoding">How the operand is encoded.</param>
 public OperandDescriptor(OperandType operandType, DataSize size, OperandEncoding encoding)
     : this(operandType, RegisterType.None, size, encoding)
 {
     #region Contract
     Contract.Requires <InvalidEnumArgumentException>(Enum.IsDefined(typeof(OperandType), operandType));
     Contract.Requires <ArgumentException>(operandType != OperandType.FixedRegister,
                                           "To specify a fixed register, use the appropriate constructor.");
     Contract.Requires <InvalidEnumArgumentException>(Enum.IsDefined(typeof(DataSize), size));
     Contract.Requires <InvalidEnumArgumentException>(Enum.IsDefined(typeof(OperandEncoding), encoding));
     Contract.Requires <ArgumentException>(
         operandType != OperandType.RegisterOperand && operandType != OperandType.RegisterOrMemoryOperand,
         "A register type must be specified when the type of operand may take a register." +
         "Use the appropriate constructor.");
     #endregion
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Adjusts this <see cref="Operand"/> based on the specified
 /// <see cref="X86Instruction.OperandDescriptor"/>.
 /// </summary>
 /// <param name="descriptor">The <see cref="X86Instruction.OperandDescriptor"/> used to
 /// adjust.</param>
 /// <remarks>
 /// Only <see cref="X86Instruction.OperandDescriptor"/> instances for which <see cref="IsMatch"/>
 /// returns <see langword="true"/> may be used as a parameter to this method.
 /// </remarks>
 internal override void Adjust(X86Instruction.OperandDescriptor descriptor)
 {
     // When the operand needs to be added to the opcode, set it as such.
     if (descriptor.OperandEncoding == X86Instruction.OperandEncoding.OpcodeAdd)
     {
         this.Encoding = OperandEncoding.AddToOpcode;
     }
     else if (descriptor.OperandType == X86Instruction.OperandType.FixedRegister)
     {
         this.Encoding = OperandEncoding.Ignore;
     }
     else
     {
         this.Encoding = OperandEncoding.Default;
     }
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Adjusts this <see cref="Operand"/> based on the specified
 /// <see cref="OperandDescriptor"/>.
 /// </summary>
 /// <param name="descriptor">The <see cref="OperandDescriptor"/> used to
 /// adjust.</param>
 /// <remarks>
 /// Only <see cref="OperandDescriptor"/> instances for which <see cref="IsMatch"/>
 /// returns <see langword="true"/> may be used as a parameter to this method.
 /// </remarks>
 public override void Adjust(OperandDescriptor descriptor)
 {
     // When the operand needs to be added to the opcode, set it as such.
     if (descriptor.OperandEncoding == X86.OperandEncoding.OpcodeAdd)
     {
         Encoding = OperandEncoding.AddToOpcode;
     }
     else if (descriptor.OperandType == OperandType.RegisterOrMemoryOperand)
     {
         Encoding = OperandEncoding.ModRm;
     }
     else if (descriptor.OperandType == OperandType.FixedRegister)
     {
         Encoding = OperandEncoding.Ignore;
     }
     else
     {
         Encoding = OperandEncoding.Default;
     }
 }
Ejemplo n.º 9
0
		public OperandDefinition(OperandField field, OperandEncoding encoding, AccessType accessType)
		{
			this.Field = field;
			this.Encoding = encoding;
			this.AccessType = accessType;
		}
Ejemplo n.º 10
0
 /// <summary>
 /// Adjusts this <see cref="Operand"/> based on the specified
 /// <see cref="OperandDescriptor"/>.
 /// </summary>
 /// <param name="descriptor">The <see cref="OperandDescriptor"/> used to
 /// adjust.</param>
 /// <remarks>
 /// Only <see cref="OperandDescriptor"/> instances for which <see cref="IsMatch"/>
 /// returns <see langword="true"/> may be used as a parameter to this method.
 /// </remarks>
 public override void Adjust(OperandDescriptor descriptor)
 {
     // When the operand needs to be added to the opcode, set it as such.
     if (descriptor.OperandEncoding == X86.OperandEncoding.OpcodeAdd)
         Encoding = OperandEncoding.AddToOpcode;
     else if (descriptor.OperandType == OperandType.RegisterOrMemoryOperand)
         Encoding = OperandEncoding.ModRm;
     else if (descriptor.OperandType == OperandType.FixedRegister)
         Encoding = OperandEncoding.Ignore;
     else
         Encoding = OperandEncoding.Default;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="OperandDescriptor"/> structure.
 /// </summary>
 /// <param name="operandType">The type of operand.</param>
 /// <param name="registerType">The type of register.</param>
 /// <param name="encoding">How the operand is encoded.</param>
 public OperandDescriptor(OperandType operandType, RegisterType registerType, OperandEncoding encoding)
     : this(operandType, registerType, DataSize.None, encoding)
 {
 }
Ejemplo n.º 12
0
 internal Bit64SignExtendedOpCode(byte[] code, string name, OperandEncoding opEn, string description, int operandSize, int extension = -1) : base(code, name, opEn, description, operandSize, extension, true, 64)
 {
 }
Ejemplo n.º 13
0
 public static bool UsesRegisterValueWithOpCode(this OperandEncoding encoding)
 {
     return(encoding == OperandEncoding.O ||
            encoding == OperandEncoding.OI);
 }
            /// <summary>
            /// Initializes a new instance of the <see cref="OperandDescriptor"/> structure.
            /// </summary>
            /// <param name="operandType">The type of operand.</param>
            /// <param name="registerType">A bitwise combination of valid types of the register.</param>
            /// <param name="size">The size of the operand.</param>
            /// <param name="encoding">Specifies how the operand is encoded.</param>
            private OperandDescriptor(OperandType operandType, RegisterType registerType, DataSize size, OperandEncoding encoding)
            {
                #region Contract
                Contract.Requires <InvalidEnumArgumentException>(Enum.IsDefined(typeof(OperandType), operandType));
                Contract.Requires <ArgumentException>(operandType != OperandType.FixedRegister,
                                                      "To specify a fixed register, use the appropriate constructor.");
                Contract.Requires <InvalidEnumArgumentException>(Enum.IsDefined(typeof(DataSize), size));
                Contract.Requires <InvalidEnumArgumentException>(Enum.IsDefined(typeof(OperandEncoding), encoding));
                Contract.Requires <ArgumentException>(
                    (operandType != OperandType.RegisterOperand && operandType != OperandType.RegisterOrMemoryOperand) ||
                    registerType != RegisterType.None,
                    "A register type must be specified when the type of operand may take a register.");
                #endregion

                this.operandType     = operandType;
                this.registerType    = registerType;
                this.size            = (size != DataSize.None ? size : registerType.GetSize());
                this.fixedRegister   = Register.None;
                this.operandEncoding = encoding;
            }
Ejemplo n.º 15
0
 /// <summary>
 /// Adjusts this <see cref="Operand"/> based on the specified
 /// <see cref="X86Instruction.OperandDescriptor"/>.
 /// </summary>
 /// <param name="descriptor">The <see cref="X86Instruction.OperandDescriptor"/> used to
 /// adjust.</param>
 /// <remarks>
 /// Only <see cref="X86Instruction.OperandDescriptor"/> instances for which <see cref="IsMatch"/>
 /// returns <see langword="true"/> may be used as a parameter to this method.
 /// </remarks>
 internal override void Adjust(X86Instruction.OperandDescriptor descriptor)
 {
     // When the operand needs to be added to the opcode, set it as such.
     if (descriptor.OperandEncoding == X86Instruction.OperandEncoding.OpcodeAdd)
         this.Encoding = OperandEncoding.AddToOpcode;
     else if (descriptor.OperandType == X86Instruction.OperandType.FixedRegister)
         this.Encoding = OperandEncoding.Ignore;
     else
         this.Encoding = OperandEncoding.Default;
 }