mirror of
https://github.com/sampletext32/ParkanPlayground.git
synced 2025-06-20 08:18:36 +03:00
Updated instruction handlers to use Type and StructuredOperands instead of Mnemonic and Operands
This commit is contained in:
42
X86Disassembler/X86/Operands/DisplacementMemoryOperand.cs
Normal file
42
X86Disassembler/X86/Operands/DisplacementMemoryOperand.cs
Normal file
@ -0,0 +1,42 @@
|
||||
namespace X86Disassembler.X86.Operands;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a memory operand with a base register and displacement in an x86 instruction (e.g., [eax+0x4])
|
||||
/// </summary>
|
||||
public class DisplacementMemoryOperand : MemoryOperand
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the base register
|
||||
/// </summary>
|
||||
public RegisterIndex BaseRegister { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the displacement value
|
||||
/// </summary>
|
||||
public long Displacement { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the DisplacementMemoryOperand class
|
||||
/// </summary>
|
||||
/// <param name="baseRegister">The base register</param>
|
||||
/// <param name="displacement">The displacement value</param>
|
||||
/// <param name="size">The size of the memory access in bits</param>
|
||||
/// <param name="segmentOverride">Optional segment override</param>
|
||||
public DisplacementMemoryOperand(RegisterIndex baseRegister, long displacement, int size = 32, string? segmentOverride = null)
|
||||
: base(size, segmentOverride)
|
||||
{
|
||||
Type = OperandType.MemoryBaseRegPlusOffset;
|
||||
BaseRegister = baseRegister;
|
||||
Displacement = displacement;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a string representation of this operand
|
||||
/// </summary>
|
||||
public override string ToString()
|
||||
{
|
||||
string sign = Displacement >= 0 ? "+" : "";
|
||||
var registerName = ModRMDecoder.GetRegisterName(BaseRegister, 32);
|
||||
return $"{GetSegmentPrefix()}[{registerName}{sign}0x{Math.Abs(Displacement):X}]";
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user