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:
@ -1,5 +1,7 @@
|
||||
namespace X86Disassembler.X86;
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
||||
/// <summary>
|
||||
/// Represents an x86 instruction
|
||||
/// </summary>
|
||||
@ -11,19 +13,14 @@ public class Instruction
|
||||
public ulong Address { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the mnemonic of the instruction
|
||||
/// Gets or sets the type of the instruction
|
||||
/// </summary>
|
||||
public string Mnemonic { get; set; } = string.Empty;
|
||||
|
||||
public InstructionType Type { get; set; } = InstructionType.Unknown;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the operands of the instruction
|
||||
/// Gets or sets the structured operands of the instruction
|
||||
/// </summary>
|
||||
public string Operands { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the raw bytes of the instruction
|
||||
/// </summary>
|
||||
public byte[] RawBytes { get; set; } = [];
|
||||
public List<Operand> StructuredOperands { get; set; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// Returns a string representation of the instruction
|
||||
@ -31,26 +28,6 @@ public class Instruction
|
||||
/// <returns>A string representation of the instruction</returns>
|
||||
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}";
|
||||
return $"{Address:X8} {Type:G} {string.Join(",", StructuredOperands)}";
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user