mirror of
https://github.com/sampletext32/ParkanPlayground.git
synced 2025-06-18 23:59:46 +03:00
Simplified TestRegMem8Handler by removing unused variables and improving code structure
This commit is contained in:
@ -37,9 +37,8 @@ public class TestRegMem8Handler : InstructionHandler
|
|||||||
// Set the mnemonic
|
// Set the mnemonic
|
||||||
instruction.Mnemonic = "test";
|
instruction.Mnemonic = "test";
|
||||||
|
|
||||||
int position = Decoder.GetPosition();
|
// Check if we have enough bytes for the ModR/M byte
|
||||||
|
if (!Decoder.CanReadByte())
|
||||||
if (position >= Length)
|
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -47,26 +46,19 @@ public class TestRegMem8Handler : InstructionHandler
|
|||||||
// Read the ModR/M byte
|
// Read the ModR/M byte
|
||||||
var (mod, reg, rm, destOperand) = ModRMDecoder.ReadModRM();
|
var (mod, reg, rm, destOperand) = ModRMDecoder.ReadModRM();
|
||||||
|
|
||||||
// For direct register addressing (mod == 3), the r/m field specifies a register
|
// Get the register name for the reg field
|
||||||
|
string regOperand = ModRMDecoder.GetRegisterName(reg, 8);
|
||||||
|
|
||||||
|
// For direct register addressing (mod == 3), get the r/m register name
|
||||||
if (mod == 3)
|
if (mod == 3)
|
||||||
{
|
{
|
||||||
// Get the register names
|
string rmOperand = ModRMDecoder.GetRegisterName(rm, 8);
|
||||||
string rmReg = ModRMDecoder.GetRegisterName(rm, 8);
|
instruction.Operands = $"{rmOperand}, {regOperand}";
|
||||||
string regReg = ModRMDecoder.GetRegisterName(reg, 8);
|
|
||||||
|
|
||||||
// Set the operands (TEST r/m8, r8)
|
|
||||||
// In x86 assembly, the TEST instruction has the operand order r/m8, r8
|
|
||||||
// According to Ghidra and standard x86 assembly convention, it should be TEST CL,AL
|
|
||||||
// where CL is the r/m operand and AL is the reg operand
|
|
||||||
instruction.Operands = $"{rmReg}, {regReg}";
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Get the register name
|
// For memory operands, use the decoded operand string
|
||||||
string regReg = ModRMDecoder.GetRegisterName(reg, 8);
|
instruction.Operands = $"{destOperand}, {regOperand}";
|
||||||
|
|
||||||
// Set the operands (TEST r/m8, r8)
|
|
||||||
instruction.Operands = $"{destOperand}, {regReg}";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
Reference in New Issue
Block a user