namespace X86Disassembler.X86.Operands;
///
/// Represents an immediate value operand in an x86 instruction
///
public class ImmediateOperand : Operand
{
///
/// Gets or sets the immediate value
///
public long Value { get; set; }
///
/// Initializes a new instance of the ImmediateOperand class
///
/// The immediate value
/// The size of the value in bits
public ImmediateOperand(long value, int size = 32)
{
Type = OperandType.ImmediateValue;
Value = value;
Size = size;
}
///
/// Returns a string representation of this operand
///
public override string ToString()
{
// For negative values, ensure we show the full 32-bit representation
if (Value < 0 && Size == 32)
{
return $"0x{Value & 0xFFFFFFFF:X8}";
}
// For positive values or other sizes, show the regular representation
return $"0x{Value:X}";
}
}