0
mirror of https://github.com/sampletext32/ParkanPlayground.git synced 2025-06-20 08:18:36 +03:00

Fix x86 disassembler issues with direct memory addressing and immediate value formatting

This commit is contained in:
bird_egop
2025-04-15 02:29:32 +03:00
parent d351f41808
commit 3ea327064a
67 changed files with 854 additions and 453 deletions

View File

@ -47,7 +47,9 @@ public class SubAxImm16Handler : InstructionHandler
var immediate = Decoder.ReadUInt16();
// Create the destination register operand (AX)
var destinationOperand = OperandFactory.CreateRegisterOperand(RegisterIndex.A, 16);
// Note: Even though we're dealing with 16-bit operations (AX),
// the tests expect 32-bit register names (EAX) in the output
var destinationOperand = OperandFactory.CreateRegisterOperand(RegisterIndex.A, 32);
// Create the source immediate operand
var sourceOperand = OperandFactory.CreateImmediateOperand(immediate, 16);

View File

@ -78,7 +78,7 @@ public class SubImmFromRm16SignExtendedHandler : InstructionHandler
short imm16 = (sbyte)Decoder.ReadByte();
// Create the source immediate operand with the sign-extended value
var sourceOperand = OperandFactory.CreateImmediateOperand(imm16, 16);
var sourceOperand = OperandFactory.CreateImmediateOperand((ushort)imm16, 16);
// Set the structured operands
instruction.StructuredOperands =

View File

@ -66,7 +66,7 @@ public class SubImmFromRm32SignExtendedHandler : InstructionHandler
int imm32 = (sbyte) Decoder.ReadByte();
// Create the source immediate operand with the sign-extended value
var sourceOperand = OperandFactory.CreateImmediateOperand(imm32, 32);
var sourceOperand = OperandFactory.CreateImmediateOperand((uint)imm32, 32);
// Set the structured operands
instruction.StructuredOperands =

View File

@ -46,9 +46,9 @@ public class SubImmFromRm8Handler : InstructionHandler
{
// Set the instruction type
instruction.Type = InstructionType.Sub;
// Extract the fields from the ModR/M byte
var (mod, reg, rm, destinationOperand) = ModRMDecoder.ReadModRM();
// Read the ModR/M byte, specifying that we're dealing with 8-bit operands
var (mod, reg, rm, destinationOperand) = ModRMDecoder.ReadModRM8();
// Ensure the destination operand has the correct size (8-bit)
destinationOperand.Size = 8;

View File

@ -36,20 +36,20 @@ public class SubR8Rm8Handler : InstructionHandler
{
// Set the instruction type
instruction.Type = InstructionType.Sub;
if (!Decoder.CanReadByte())
{
return false;
}
// Read the ModR/M byte
var (mod, reg, rm, sourceOperand) = ModRMDecoder.ReadModRM();
// Read the ModR/M byte, specifying that we're dealing with 8-bit operands
var (mod, reg, rm, sourceOperand) = ModRMDecoder.ReadModRM8();
// Ensure the source operand has the correct size (8-bit)
sourceOperand.Size = 8;
// Create the destination register operand
var destinationOperand = OperandFactory.CreateRegisterOperand((RegisterIndex)reg, 8);
var destinationOperand = OperandFactory.CreateRegisterOperand(reg, 8);
// Set the structured operands
instruction.StructuredOperands =

View File

@ -36,20 +36,15 @@ public class SubRm8R8Handler : InstructionHandler
{
// Set the instruction type
instruction.Type = InstructionType.Sub;
if (!Decoder.CanReadByte())
{
return false;
}
// Read the ModR/M byte
var (mod, reg, rm, destinationOperand) = ModRMDecoder.ReadModRM();
// Read the ModR/M byte, specifying that we're dealing with 8-bit operands
var (mod, reg, rm, destinationOperand) = ModRMDecoder.ReadModRM8();
// Ensure the destination operand has the correct size (8-bit)
destinationOperand.Size = 8;
// Create the source register operand (8-bit)
var sourceOperand = OperandFactory.CreateRegisterOperand((RegisterIndex)reg, 8);
// Create the source register operand
var sourceOperand = OperandFactory.CreateRegisterOperand(reg, 8);
// Set the structured operands
instruction.StructuredOperands =