namespace X86Disassembler.X86;
///
/// Represents a decoded x86 instruction
///
public class Instruction
{
///
/// The address of the instruction in memory
///
public ulong Address { get; set; }
///
/// The raw bytes of the instruction
///
public byte[] Bytes { get; set; } = Array.Empty();
///
/// The mnemonic of the instruction (e.g., "mov", "add", "jmp")
///
public string Mnemonic { get; set; } = string.Empty;
///
/// The operands of the instruction as a formatted string
///
public string Operands { get; set; } = string.Empty;
///
/// The length of the instruction in bytes
///
public int Length => Bytes.Length;
///
/// Returns a string representation of the instruction
///
/// A formatted string representing the instruction
public override string ToString()
{
return $"{Address:X8} {BytesToString()} {Mnemonic} {Operands}".Trim();
}
///
/// Converts the instruction bytes to a formatted hex string
///
/// A formatted hex string of the instruction bytes
private string BytesToString()
{
return string.Join(" ", Bytes.Select(b => b.ToString("X2")));
}
}