mirror of
https://github.com/sampletext32/ParkanPlayground.git
synced 2025-06-20 08:18:36 +03:00
more refactoring
This commit is contained in:
@ -27,11 +27,10 @@ public class SbbImmFromRm32Handler : InstructionHandler
|
||||
return false;
|
||||
|
||||
// Check if the reg field of the ModR/M byte is 3 (SBB)
|
||||
int position = Decoder.GetPosition();
|
||||
if (position >= Length)
|
||||
if (!Decoder.CanReadByte())
|
||||
return false;
|
||||
|
||||
byte modRM = CodeBuffer[position];
|
||||
byte modRM = CodeBuffer[Decoder.GetPosition()];
|
||||
byte reg = (byte) ((modRM & 0x38) >> 3);
|
||||
|
||||
return reg == 3; // 3 = SBB
|
||||
@ -48,9 +47,7 @@ public class SbbImmFromRm32Handler : InstructionHandler
|
||||
// Set the mnemonic
|
||||
instruction.Mnemonic = "sbb";
|
||||
|
||||
int position = Decoder.GetPosition();
|
||||
|
||||
if (position >= Length)
|
||||
if (!Decoder.CanReadByte())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@ -59,7 +56,7 @@ public class SbbImmFromRm32Handler : InstructionHandler
|
||||
var (mod, reg, rm, destOperand) = ModRMDecoder.ReadModRM();
|
||||
|
||||
// Read the immediate value
|
||||
if (position + 3 >= Length)
|
||||
if (!Decoder.CanReadUInt())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -27,11 +27,10 @@ public class SbbImmFromRm32SignExtendedHandler : InstructionHandler
|
||||
return false;
|
||||
|
||||
// Check if the reg field of the ModR/M byte is 3 (SBB)
|
||||
int position = Decoder.GetPosition();
|
||||
if (position >= Length)
|
||||
if (!Decoder.CanReadByte())
|
||||
return false;
|
||||
|
||||
byte modRM = CodeBuffer[position];
|
||||
byte modRM = CodeBuffer[Decoder.GetPosition()];
|
||||
byte reg = (byte) ((modRM & 0x38) >> 3);
|
||||
|
||||
return reg == 3; // 3 = SBB
|
||||
@ -48,9 +47,7 @@ public class SbbImmFromRm32SignExtendedHandler : InstructionHandler
|
||||
// Set the mnemonic
|
||||
instruction.Mnemonic = "sbb";
|
||||
|
||||
int position = Decoder.GetPosition();
|
||||
|
||||
if (position >= Length)
|
||||
if (!Decoder.CanReadByte())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@ -59,7 +56,7 @@ public class SbbImmFromRm32SignExtendedHandler : InstructionHandler
|
||||
var (mod, reg, rm, destOperand) = ModRMDecoder.ReadModRM();
|
||||
|
||||
// Read the immediate value (sign-extended from 8 to 32 bits)
|
||||
if (position >= Length)
|
||||
if (!Decoder.CanReadByte())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
Reference in New Issue
Block a user