mirror of
https://github.com/sampletext32/ParkanPlayground.git
synced 2025-06-20 08:18:36 +03:00
nice big refactor
This commit is contained in:
@ -56,7 +56,27 @@ public class XorImmWithRm16Handler : InstructionHandler
|
||||
}
|
||||
|
||||
// Read the ModR/M byte
|
||||
var (mod, reg, rm, destOperand) = ModRMDecoder.ReadModRM();
|
||||
var (mod, reg, rm, memOperand) = ModRMDecoder.ReadModRM();
|
||||
|
||||
// For the first operand, handle based on addressing mode
|
||||
string rmOperand;
|
||||
if (mod == 3) // Register addressing mode
|
||||
{
|
||||
// Get 16-bit register name for the operand
|
||||
rmOperand = ModRMDecoder.GetRegisterName(rm, 16);
|
||||
}
|
||||
else // Memory addressing mode
|
||||
{
|
||||
// For memory operands, replace "dword ptr" with "word ptr"
|
||||
if (memOperand.StartsWith("dword ptr "))
|
||||
{
|
||||
rmOperand = memOperand.Replace("dword ptr", "word ptr");
|
||||
}
|
||||
else
|
||||
{
|
||||
rmOperand = memOperand;
|
||||
}
|
||||
}
|
||||
|
||||
// Get the updated position after ModR/M decoding
|
||||
position = Decoder.GetPosition();
|
||||
@ -74,7 +94,7 @@ public class XorImmWithRm16Handler : InstructionHandler
|
||||
string immStr = $"0x{imm16:X4}";
|
||||
|
||||
// Set the operands
|
||||
instruction.Operands = $"{destOperand}, {immStr}";
|
||||
instruction.Operands = $"{rmOperand}, {immStr}";
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -56,7 +56,27 @@ public class XorImmWithRm16SignExtendedHandler : InstructionHandler
|
||||
}
|
||||
|
||||
// Read the ModR/M byte
|
||||
var (mod, reg, rm, destOperand) = ModRMDecoder.ReadModRM();
|
||||
var (mod, reg, rm, memOperand) = ModRMDecoder.ReadModRM();
|
||||
|
||||
// For the first operand, handle based on addressing mode
|
||||
string rmOperand;
|
||||
if (mod == 3) // Register addressing mode
|
||||
{
|
||||
// Get 16-bit register name for the operand
|
||||
rmOperand = ModRMDecoder.GetRegisterName(rm, 16);
|
||||
}
|
||||
else // Memory addressing mode
|
||||
{
|
||||
// For memory operands, replace "dword ptr" with "word ptr"
|
||||
if (memOperand.StartsWith("dword ptr "))
|
||||
{
|
||||
rmOperand = memOperand.Replace("dword ptr", "word ptr");
|
||||
}
|
||||
else
|
||||
{
|
||||
rmOperand = memOperand;
|
||||
}
|
||||
}
|
||||
|
||||
// Get the updated position after ModR/M decoding
|
||||
position = Decoder.GetPosition();
|
||||
@ -85,7 +105,7 @@ public class XorImmWithRm16SignExtendedHandler : InstructionHandler
|
||||
}
|
||||
|
||||
// Set the operands
|
||||
instruction.Operands = $"{destOperand}, {immStr}";
|
||||
instruction.Operands = $"{rmOperand}, {immStr}";
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ public class XorMemRegHandler : InstructionHandler
|
||||
var (mod, reg, rm, destOperand) = ModRMDecoder.ReadModRM();
|
||||
|
||||
// Get the source register
|
||||
string srcReg = GetRegister32(reg);
|
||||
string srcReg = ModRMDecoder.GetRegisterName(reg, 32);
|
||||
|
||||
// Set the operands
|
||||
instruction.Operands = $"{destOperand}, {srcReg}";
|
||||
|
@ -48,11 +48,31 @@ public class XorR16Rm16Handler : InstructionHandler
|
||||
// Read the ModR/M byte
|
||||
var (mod, reg, rm, memOperand) = ModRMDecoder.ReadModRM();
|
||||
|
||||
// Get register name
|
||||
// Get register name for the first operand (16-bit)
|
||||
string regName = ModRMDecoder.GetRegisterName(reg, 16);
|
||||
|
||||
// For the second operand, handle based on addressing mode
|
||||
string rmOperand;
|
||||
if (mod == 3) // Register addressing mode
|
||||
{
|
||||
// Get 16-bit register name for the second operand
|
||||
rmOperand = ModRMDecoder.GetRegisterName(rm, 16);
|
||||
}
|
||||
else // Memory addressing mode
|
||||
{
|
||||
// For memory operands, replace "dword ptr" with "word ptr"
|
||||
if (memOperand.StartsWith("dword ptr "))
|
||||
{
|
||||
rmOperand = memOperand.Replace("dword ptr", "word ptr");
|
||||
}
|
||||
else
|
||||
{
|
||||
rmOperand = memOperand;
|
||||
}
|
||||
}
|
||||
|
||||
// Set the operands
|
||||
instruction.Operands = $"{regName}, {memOperand}";
|
||||
instruction.Operands = $"{regName}, {rmOperand}";
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ public class XorRegMemHandler : InstructionHandler
|
||||
var (mod, reg, rm, srcOperand) = ModRMDecoder.ReadModRM();
|
||||
|
||||
// Get the destination register
|
||||
string destReg = GetRegister32(reg);
|
||||
string destReg = ModRMDecoder.GetRegisterName(reg, 32);
|
||||
|
||||
// Set the operands
|
||||
instruction.Operands = $"{destReg}, {srcOperand}";
|
||||
|
@ -48,11 +48,31 @@ public class XorRm16R16Handler : InstructionHandler
|
||||
// Read the ModR/M byte
|
||||
var (mod, reg, rm, memOperand) = ModRMDecoder.ReadModRM();
|
||||
|
||||
// Get register name
|
||||
// Get register name for the second operand (16-bit)
|
||||
string regName = ModRMDecoder.GetRegisterName(reg, 16);
|
||||
|
||||
// For the first operand, handle based on addressing mode
|
||||
string rmOperand;
|
||||
if (mod == 3) // Register addressing mode
|
||||
{
|
||||
// Get 16-bit register name for the first operand
|
||||
rmOperand = ModRMDecoder.GetRegisterName(rm, 16);
|
||||
}
|
||||
else // Memory addressing mode
|
||||
{
|
||||
// For memory operands, replace "dword ptr" with "word ptr"
|
||||
if (memOperand.StartsWith("dword ptr "))
|
||||
{
|
||||
rmOperand = memOperand.Replace("dword ptr", "word ptr");
|
||||
}
|
||||
else
|
||||
{
|
||||
rmOperand = memOperand;
|
||||
}
|
||||
}
|
||||
|
||||
// Set the operands
|
||||
instruction.Operands = $"{memOperand}, {regName}";
|
||||
instruction.Operands = $"{rmOperand}, {regName}";
|
||||
|
||||
return true;
|
||||
}
|
||||
|
Reference in New Issue
Block a user