/// <summary> /// Initializes a new <see cref="CodeOperand"/> struct. /// </summary> /// <param name="value">Value of the operand as a register.</param> public CodeOperand(CodeRegister value) { this.type = CodeOperandType.Register; this.register = value; if (value == CodeRegister.AL || value == CodeRegister.AH || value == CodeRegister.BL || value == CodeRegister.BH || value == CodeRegister.CL || value == CodeRegister.CH || value == CodeRegister.DL || value == CodeRegister.DH) { this.operandSize = CodeOperandSize.Byte; } else if (value == CodeRegister.EAX || value == CodeRegister.EBX || value == CodeRegister.ECX || value == CodeRegister.EDX || value == CodeRegister.EBP || value == CodeRegister.ESI || value == CodeRegister.EDI || value == CodeRegister.ESP) { this.operandSize = CodeOperandSize.DoubleWord; } else { this.operandSize = CodeOperandSize.Word; } this.memoryBase = 0; this.value = 0; this.sibScale = 0; this.sibIndex = 0; this.sibBase = 0; this.farSegment = 0; }
/// <summary> /// Initializes a new <see cref="CodeOperand"/> struct. /// </summary> /// <param name="type">Type of the operand.</param> /// <param name="value">Value of the operand.</param> public CodeOperand(CodeOperandType type, uint value, CodeOperandSize size) { this.type = type; this.value = value; this.operandSize = size; this.memoryBase = 0; this.register = 0; this.sibScale = 0; this.sibIndex = 0; this.sibBase = 0; this.farSegment = 0; }
/// <summary> /// Initializes a new <see cref="CodeOperand"/> struct. /// </summary> /// <param name="effectiveAddress">Addressing mode for the operand.</param> /// <param name="value">Displacement value for the operand.</param> public CodeOperand(CodeMemoryBase effectiveAddress, uint value, CodeOperandSize size) { this.type = CodeOperandType.MemoryAddress; this.value = value; this.memoryBase = effectiveAddress; this.operandSize = size; this.register = 0; this.sibScale = 0; this.sibIndex = 0; this.sibBase = 0; this.farSegment = 0; }
private static string GetSizePrefix(CodeOperandSize size) { switch (size) { case CodeOperandSize.Byte: return("byte ptr"); case CodeOperandSize.Word: return("word ptr"); case CodeOperandSize.DoubleWord: return("dword ptr"); default: return(string.Empty); } }