namespace X86Disassembler.X86;
///
/// Represents an x86 instruction
///
public class Instruction
{
///
/// Gets or sets the address of the instruction
///
public uint Address { get; set; }
///
/// Gets or sets the mnemonic of the instruction
///
public string Mnemonic { get; set; } = string.Empty;
///
/// Gets or sets the operands of the instruction
///
public string Operands { get; set; } = string.Empty;
///
/// Gets or sets the raw bytes of the instruction
///
public byte[] RawBytes { get; set; } = [];
///
/// Returns a string representation of the instruction
///
/// A string representation of the instruction
public override string ToString()
{
// Format the address
string addressStr = $"{Address:X8}";
// Format the raw bytes
string bytesStr = string.Empty;
foreach (byte b in RawBytes)
{
bytesStr += $"{b:X2} ";
}
// Pad the bytes string to a fixed width
bytesStr = bytesStr.PadRight(30);
// Format the instruction
string instructionStr = Mnemonic;
if (!string.IsNullOrEmpty(Operands))
{
instructionStr += " " + Operands;
}
return $" {addressStr} {bytesStr}{instructionStr}";
}
}