0
mirror of https://github.com/sampletext32/ParkanPlayground.git synced 2025-06-20 00:18:02 +03:00

more cleanup

This commit is contained in:
bird_egop
2025-04-15 02:42:47 +03:00
parent 49f1d7d221
commit abe4d38d4b
97 changed files with 160 additions and 219 deletions

View File

@ -1,6 +1,6 @@
namespace X86Disassembler.X86.Handlers.And;
using X86Disassembler.X86.Operands;
using Operands;
/// <summary>
/// Handler for AND r/m32, imm32 instruction (0x81 /4)
@ -30,8 +30,7 @@ public class AndImmToRm32Handler : InstructionHandler
if (!Decoder.CanReadByte())
return false;
byte modRM = Decoder.PeakByte();
byte reg = (byte) ((modRM & 0x38) >> 3);
var reg = ModRMDecoder.PeakModRMReg();
return reg == 4; // 4 = AND
}
@ -53,7 +52,7 @@ public class AndImmToRm32Handler : InstructionHandler
}
// Read the ModR/M byte
var (mod, reg, rm, destOperand) = ModRMDecoder.ReadModRM();
var (_, _, _, destOperand) = ModRMDecoder.ReadModRM();
// Read the immediate value
if (!Decoder.CanReadUInt())

View File

@ -35,8 +35,7 @@ public class AndImmToRm32SignExtendedHandler : InstructionHandler
}
// Read the ModR/M byte to check the reg field (bits 5-3)
byte modRM = Decoder.PeakByte();
int reg = (modRM >> 3) & 0x7;
var reg = ModRMDecoder.PeakModRMReg();
// reg = 4 means AND operation
return reg == 4;
@ -57,7 +56,7 @@ public class AndImmToRm32SignExtendedHandler : InstructionHandler
// For AND r/m32, imm8 (sign-extended) (0x83 /4):
// - The r/m field with mod specifies the destination operand (register or memory)
// - The immediate value is the source operand (sign-extended from 8 to 32 bits)
var (mod, reg, rm, destinationOperand) = ModRMDecoder.ReadModRM();
var (_, _, _, destinationOperand) = ModRMDecoder.ReadModRM();
if (!Decoder.CanReadByte())
{

View File

@ -35,8 +35,7 @@ public class AndImmToRm8Handler : InstructionHandler
}
// Read the ModR/M byte to check the reg field (bits 5-3)
byte modRM = Decoder.PeakByte();
int reg = (modRM >> 3) & 0x7;
var reg = ModRMDecoder.PeakModRMReg();
// reg = 4 means AND operation
return reg == 4;
@ -57,7 +56,7 @@ public class AndImmToRm8Handler : InstructionHandler
// For AND r/m8, imm8 (0x80 /4):
// - The r/m field with mod specifies the destination operand (register or memory)
// - The immediate value is the source operand
var (mod, reg, rm, destinationOperand) = ModRMDecoder.ReadModRM();
var (_, _, _, destinationOperand) = ModRMDecoder.ReadModRM();
// Adjust the operand size to 8-bit
destinationOperand.Size = 8;

View File

@ -30,8 +30,7 @@ public class AndImmWithRm32Handler : InstructionHandler
if (!Decoder.CanReadByte())
return false;
byte modRM = Decoder.PeakByte();
byte reg = (byte) ((modRM & 0x38) >> 3);
var reg = ModRMDecoder.PeakModRMReg();
return reg == 4; // 4 = AND
}
@ -51,7 +50,7 @@ public class AndImmWithRm32Handler : InstructionHandler
// For AND r/m32, imm32 (0x81 /4):
// - The r/m field with mod specifies the destination operand (register or memory)
// - The immediate value is the source operand
var (mod, reg, rm, destinationOperand) = ModRMDecoder.ReadModRM();
var (_, _, _, destinationOperand) = ModRMDecoder.ReadModRM();
// Check if we have enough bytes for the immediate value
if (!Decoder.CanReadUInt())

View File

@ -46,7 +46,7 @@ public class AndMemRegHandler : InstructionHandler
// For AND r/m32, r32 (0x21):
// - The r/m field with mod specifies the destination operand (register or memory)
// - The reg field specifies the source register
var (mod, reg, rm, destinationOperand) = ModRMDecoder.ReadModRM();
var (_, reg, _, destinationOperand) = ModRMDecoder.ReadModRM();
// Create the source register operand
var sourceOperand = OperandFactory.CreateRegisterOperand(reg, 32);

View File

@ -46,7 +46,7 @@ public class AndR32Rm32Handler : InstructionHandler
// For AND r32, r/m32 (0x23):
// - The reg field specifies the destination register
// - The r/m field with mod specifies the source operand (register or memory)
var (mod, reg, rm, sourceOperand) = ModRMDecoder.ReadModRM();
var (_, reg, _, sourceOperand) = ModRMDecoder.ReadModRM();
// Create the destination register operand
var destinationOperand = OperandFactory.CreateRegisterOperand(reg, 32);

View File

@ -1,6 +1,6 @@
namespace X86Disassembler.X86.Handlers.And;
using X86Disassembler.X86.Operands;
using Operands;
/// <summary>
/// Handler for AND r8, r/m8 instruction (0x22)

View File

@ -1,6 +1,6 @@
namespace X86Disassembler.X86.Handlers.And;
using X86Disassembler.X86.Operands;
using Operands;
/// <summary>
/// Handler for AND r/m8, r8 instruction (0x20)