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:
@ -71,7 +71,7 @@ public class XorImmWithRm16SignExtendedHandler : 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 =
|
||||
|
@ -65,7 +65,7 @@ public class XorImmWithRm32SignExtendedHandler : InstructionHandler
|
||||
int imm32 = (sbyte)Decoder.ReadByte();
|
||||
|
||||
// Create the immediate operand with sign extension
|
||||
var immOperand = OperandFactory.CreateImmediateOperand(imm32);
|
||||
var immOperand = OperandFactory.CreateImmediateOperand((uint)imm32);
|
||||
|
||||
// Set the structured operands
|
||||
instruction.StructuredOperands =
|
||||
|
@ -47,18 +47,10 @@ public class XorImmWithRm8Handler : InstructionHandler
|
||||
// Set the instruction type
|
||||
instruction.Type = InstructionType.Xor;
|
||||
|
||||
if (!Decoder.CanReadByte())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
// Read the ModR/M byte, specifying that we're dealing with 8-bit operands
|
||||
var (mod, reg, rm, destinationOperand) = ModRMDecoder.ReadModRM8();
|
||||
|
||||
// Read the ModR/M byte
|
||||
// For XOR r/m8, imm8 (0x80 /6):
|
||||
// - The r/m field with mod specifies the destination operand (register or memory)
|
||||
// - The immediate value is the source operand
|
||||
var (mod, reg, rm, destinationOperand) = ModRMDecoder.ReadModRM();
|
||||
|
||||
// Adjust the operand size to 8-bit
|
||||
// Ensure the destination operand has the correct size (8-bit)
|
||||
destinationOperand.Size = 8;
|
||||
|
||||
// Read the immediate value
|
||||
|
@ -36,19 +36,11 @@ public class XorR8Rm8Handler : InstructionHandler
|
||||
{
|
||||
// Set the instruction type
|
||||
instruction.Type = InstructionType.Xor;
|
||||
|
||||
// Read the ModR/M byte, specifying that we're dealing with 8-bit operands
|
||||
var (mod, reg, rm, sourceOperand) = ModRMDecoder.ReadModRM8();
|
||||
|
||||
if (!Decoder.CanReadByte())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Read the ModR/M byte
|
||||
// For XOR r8, r/m8 (0x32):
|
||||
// - The reg field specifies the destination register
|
||||
// - The r/m field with mod specifies the source operand (register or memory)
|
||||
var (mod, reg, rm, sourceOperand) = ModRMDecoder.ReadModRM();
|
||||
|
||||
// Adjust the operand size to 8-bit
|
||||
// Ensure the source operand has the correct size (8-bit)
|
||||
sourceOperand.Size = 8;
|
||||
|
||||
// Create the destination register operand
|
||||
|
@ -49,12 +49,9 @@ public class XorRm16R16Handler : InstructionHandler
|
||||
// Create the source register operand (16-bit)
|
||||
var sourceOperand = OperandFactory.CreateRegisterOperand(reg, 16);
|
||||
|
||||
// For memory operands, we need to adjust the size to 16-bit
|
||||
if (mod != 3) // Memory addressing mode
|
||||
{
|
||||
// Adjust memory operand size to 16-bit
|
||||
destinationOperand.Size = 16;
|
||||
}
|
||||
// For all operands, we need to adjust the size to 16-bit
|
||||
// This ensures register operands also get the correct size
|
||||
destinationOperand.Size = 16;
|
||||
|
||||
// Set the structured operands
|
||||
instruction.StructuredOperands =
|
||||
|
@ -36,19 +36,11 @@ public class XorRm8R8Handler : InstructionHandler
|
||||
{
|
||||
// Set the instruction type
|
||||
instruction.Type = InstructionType.Xor;
|
||||
|
||||
// Read the ModR/M byte, specifying that we're dealing with 8-bit operands
|
||||
var (mod, reg, rm, destinationOperand) = ModRMDecoder.ReadModRM8();
|
||||
|
||||
if (!Decoder.CanReadByte())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Read the ModR/M byte
|
||||
// For XOR r/m8, r8 (0x30):
|
||||
// - The r/m field with mod specifies the destination operand (register or memory)
|
||||
// - The reg field specifies the source register
|
||||
var (mod, reg, rm, destinationOperand) = ModRMDecoder.ReadModRM();
|
||||
|
||||
// Adjust the operand size to 8-bit
|
||||
// Ensure the destination operand has the correct size (8-bit)
|
||||
destinationOperand.Size = 8;
|
||||
|
||||
// Create the source register operand
|
||||
|
Reference in New Issue
Block a user