mirror of
https://github.com/sampletext32/ParkanPlayground.git
synced 2025-06-20 08:18:36 +03:00
simplify reading logic
This commit is contained in:
@ -50,18 +50,14 @@ public class AddR32Rm32Handler : InstructionHandler
|
||||
// Get the register name
|
||||
string regName = ModRMDecoder.GetRegisterName(reg, 32);
|
||||
|
||||
// For memory operands, set the operand
|
||||
if (mod != 3) // Memory operand
|
||||
if (mod == 3)
|
||||
{
|
||||
string operand = ModRMDecoder.DecodeModRM(mod, rm, false);
|
||||
instruction.Operands = $"{regName}, {operand}";
|
||||
}
|
||||
else // Register operand
|
||||
{
|
||||
string rmName = ModRMDecoder.GetRegisterName(rm, 32);
|
||||
instruction.Operands = $"{regName}, {rmName}";
|
||||
// Register operand
|
||||
destOperand = ModRMDecoder.GetRegisterName(rm, 32);
|
||||
}
|
||||
|
||||
instruction.Operands = $"{regName}, {destOperand}";
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
@ -48,20 +48,16 @@ public class AddRm32R32Handler : InstructionHandler
|
||||
instruction.Mnemonic = "add";
|
||||
|
||||
// Get the register name
|
||||
string regName = ModRMDecoder.GetRegisterName(reg, 32);;
|
||||
string regName = ModRMDecoder.GetRegisterName(reg, 32);
|
||||
|
||||
// For memory operands, set the operand
|
||||
if (mod != 3) // Memory operand
|
||||
if (mod == 3)
|
||||
{
|
||||
string operand = ModRMDecoder.DecodeModRM(mod, rm, false);
|
||||
instruction.Operands = $"{operand}, {regName}";
|
||||
}
|
||||
else // Register operand
|
||||
{
|
||||
string rmName = ModRMDecoder.GetRegisterName(rm, 32);;
|
||||
instruction.Operands = $"{rmName}, {regName}";
|
||||
// Register operand
|
||||
destOperand = ModRMDecoder.GetRegisterName(rm, 32);
|
||||
}
|
||||
|
||||
instruction.Operands = $"{destOperand}, {regName}";
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user