mirror of
https://github.com/sampletext32/ParkanPlayground.git
synced 2025-06-20 16:18:37 +03:00
Updated instruction handlers to use Type and StructuredOperands instead of Mnemonic and Operands
This commit is contained in:
@ -1,3 +1,5 @@
|
||||
using X86Disassembler.X86.Operands;
|
||||
|
||||
namespace X86Disassembler.X86.Handlers.Sub;
|
||||
|
||||
/// <summary>
|
||||
@ -8,11 +10,9 @@ public class SubRm32R32Handler : InstructionHandler
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the SubRm32R32Handler class
|
||||
/// </summary>
|
||||
/// <param name="codeBuffer">The buffer containing the code to decode</param>
|
||||
/// <param name="decoder">The instruction decoder that owns this handler</param>
|
||||
/// <param name="length">The length of the buffer</param>
|
||||
public SubRm32R32Handler(byte[] codeBuffer, InstructionDecoder decoder, int length)
|
||||
: base(codeBuffer, decoder, length)
|
||||
public SubRm32R32Handler(InstructionDecoder decoder)
|
||||
: base(decoder)
|
||||
{
|
||||
}
|
||||
|
||||
@ -39,27 +39,21 @@ public class SubRm32R32Handler : InstructionHandler
|
||||
return false;
|
||||
}
|
||||
|
||||
// Set the instruction type
|
||||
instruction.Type = InstructionType.Sub;
|
||||
|
||||
// Read the ModR/M byte
|
||||
|
||||
// Extract the fields from the ModR/M byte
|
||||
var (mod, reg, rm, operand) = ModRMDecoder.ReadModRM();
|
||||
|
||||
// Set the mnemonic
|
||||
instruction.Mnemonic = "sub";
|
||||
|
||||
// Get the register name
|
||||
string regName = ModRMDecoder.GetRegisterName(reg, 32);
|
||||
|
||||
// For memory operands, set the operand
|
||||
if (mod != 3) // Memory operand
|
||||
{
|
||||
instruction.Operands = $"{operand}, {regName}";
|
||||
}
|
||||
else // Register operand
|
||||
{
|
||||
string rmName = ModRMDecoder.GetRegisterName(rm, 32);
|
||||
instruction.Operands = $"{rmName}, {regName}";
|
||||
}
|
||||
var (mod, reg, rm, destinationOperand) = ModRMDecoder.ReadModRM();
|
||||
|
||||
// Create the source register operand (32-bit)
|
||||
var sourceOperand = OperandFactory.CreateRegisterOperand((RegisterIndex)reg, 32);
|
||||
|
||||
// Set the structured operands
|
||||
instruction.StructuredOperands =
|
||||
[
|
||||
destinationOperand,
|
||||
sourceOperand
|
||||
];
|
||||
|
||||
return true;
|
||||
}
|
||||
|
Reference in New Issue
Block a user