mirror of
https://github.com/sampletext32/ParkanPlayground.git
synced 2025-06-20 16:18:37 +03:00
more refactoring
This commit is contained in:
@ -11,11 +11,11 @@ public class AndMemRegHandler : InstructionHandler
|
||||
/// <param name="codeBuffer">The buffer containing the code to decode</param>
|
||||
/// <param name="decoder">The instruction decoder that owns this handler</param>
|
||||
/// <param name="length">The length of the buffer</param>
|
||||
public AndMemRegHandler(byte[] codeBuffer, InstructionDecoder decoder, int length)
|
||||
public AndMemRegHandler(byte[] codeBuffer, InstructionDecoder decoder, int length)
|
||||
: base(codeBuffer, decoder, length)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Checks if this handler can decode the given opcode
|
||||
/// </summary>
|
||||
@ -25,7 +25,7 @@ public class AndMemRegHandler : InstructionHandler
|
||||
{
|
||||
return opcode == 0x21;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Decodes an AND r/m32, r32 instruction
|
||||
/// </summary>
|
||||
@ -36,20 +36,18 @@ public class AndMemRegHandler : InstructionHandler
|
||||
{
|
||||
// Set the mnemonic
|
||||
instruction.Mnemonic = "and";
|
||||
|
||||
int position = Decoder.GetPosition();
|
||||
|
||||
if (position >= Length)
|
||||
|
||||
if (!Decoder.CanReadByte())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// Read the ModR/M byte
|
||||
var (mod, reg, rm, memOperand) = ModRMDecoder.ReadModRM();
|
||||
|
||||
|
||||
// Get register name
|
||||
string regName = ModRMDecoder.GetRegisterName(reg, 32);
|
||||
|
||||
|
||||
// For mod == 3, both operands are registers
|
||||
if (mod == 3)
|
||||
{
|
||||
@ -60,4 +58,4 @@ public class AndMemRegHandler : InstructionHandler
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user