mirror of
https://github.com/sampletext32/ParkanPlayground.git
synced 2025-06-20 08:18:36 +03:00
more refactoring
This commit is contained in:
@ -34,9 +34,7 @@ public class OrAlImmHandler : InstructionHandler
|
||||
/// <returns>True if the instruction was successfully decoded</returns>
|
||||
public override bool Decode(byte opcode, Instruction instruction)
|
||||
{
|
||||
int position = Decoder.GetPosition();
|
||||
|
||||
if (position >= Length)
|
||||
if (!Decoder.CanReadByte())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -34,9 +34,7 @@ public class OrEaxImmHandler : InstructionHandler
|
||||
/// <returns>True if the instruction was successfully decoded</returns>
|
||||
public override bool Decode(byte opcode, Instruction instruction)
|
||||
{
|
||||
int position = Decoder.GetPosition();
|
||||
|
||||
if (position + 3 >= Length)
|
||||
if (!Decoder.CanReadByte())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -27,11 +27,10 @@ public class OrImmToRm32Handler : InstructionHandler
|
||||
return false;
|
||||
|
||||
// Check if the reg field of the ModR/M byte is 1 (OR)
|
||||
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 == 1; // 1 = OR
|
||||
@ -48,7 +47,7 @@ public class OrImmToRm32Handler : InstructionHandler
|
||||
// Set the mnemonic
|
||||
instruction.Mnemonic = "or";
|
||||
|
||||
if (Decoder.GetPosition() >= Length)
|
||||
if (!Decoder.CanReadByte())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@ -56,10 +55,7 @@ public class OrImmToRm32Handler : InstructionHandler
|
||||
// Read the ModR/M byte
|
||||
var (mod, reg, rm, destOperand) = ModRMDecoder.ReadModRM();
|
||||
|
||||
int position = Decoder.GetPosition();
|
||||
|
||||
// Read the immediate value
|
||||
if (position + 3 >= Length)
|
||||
if (!Decoder.CanReadByte())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -27,11 +27,10 @@ public class OrImmToRm32SignExtendedHandler : InstructionHandler
|
||||
return false;
|
||||
|
||||
// Check if the reg field of the ModR/M byte is 1 (OR)
|
||||
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 == 1; // 1 = OR
|
||||
|
@ -27,11 +27,10 @@ public class OrImmToRm8Handler : InstructionHandler
|
||||
return false;
|
||||
|
||||
// Check if the reg field of the ModR/M byte is 1 (OR)
|
||||
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 == 1; // 1 = OR
|
||||
@ -48,9 +47,7 @@ public class OrImmToRm8Handler : InstructionHandler
|
||||
// Set the mnemonic
|
||||
instruction.Mnemonic = "or";
|
||||
|
||||
int position = Decoder.GetPosition();
|
||||
|
||||
if (position >= Length)
|
||||
if (!Decoder.CanReadByte())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@ -65,9 +62,8 @@ public class OrImmToRm8Handler : InstructionHandler
|
||||
destOperand = ModRMDecoder.GetRegisterName(rm, 8);
|
||||
}
|
||||
|
||||
position = Decoder.GetPosition();
|
||||
|
||||
if (position >= Length)
|
||||
// Read the immediate value
|
||||
if (!Decoder.CanReadByte())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -34,9 +34,7 @@ public class OrR32Rm32Handler : InstructionHandler
|
||||
/// <returns>True if the instruction was successfully decoded</returns>
|
||||
public override bool Decode(byte opcode, Instruction instruction)
|
||||
{
|
||||
int position = Decoder.GetPosition();
|
||||
|
||||
if (position >= Length)
|
||||
if (!Decoder.CanReadByte())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -34,9 +34,7 @@ public class OrR8Rm8Handler : InstructionHandler
|
||||
/// <returns>True if the instruction was successfully decoded</returns>
|
||||
public override bool Decode(byte opcode, Instruction instruction)
|
||||
{
|
||||
int position = Decoder.GetPosition();
|
||||
|
||||
if (position >= Length)
|
||||
if (!Decoder.CanReadByte())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
Reference in New Issue
Block a user