mirror of
https://github.com/sampletext32/ParkanPlayground.git
synced 2025-06-20 08:18:36 +03:00
fixes and removed unused code
This commit is contained in:
@ -48,7 +48,7 @@ public class AddAlImmHandler : InstructionHandler
|
||||
byte imm8 = Decoder.ReadByte();
|
||||
|
||||
// Create the destination register operand (AL)
|
||||
var destinationOperand = OperandFactory.CreateRegisterOperand(RegisterIndex.A, 8);
|
||||
var destinationOperand = OperandFactory.CreateRegisterOperand8(RegisterIndex8.AL);
|
||||
|
||||
// Create the source immediate operand
|
||||
var sourceOperand = OperandFactory.CreateImmediateOperand(imm8);
|
||||
|
@ -46,8 +46,8 @@ public class AddEaxImmHandler : InstructionHandler
|
||||
|
||||
instruction.StructuredOperands =
|
||||
[
|
||||
OperandFactory.CreateRegisterOperand(RegisterIndex.A, 32),
|
||||
OperandFactory.CreateImmediateOperand(imm32, 32)
|
||||
OperandFactory.CreateRegisterOperand(RegisterIndex.A),
|
||||
OperandFactory.CreateImmediateOperand(imm32)
|
||||
];
|
||||
|
||||
return true;
|
||||
|
@ -65,7 +65,7 @@ public class AddImmToRm32Handler : InstructionHandler
|
||||
|
||||
instruction.StructuredOperands = [
|
||||
destOperand,
|
||||
OperandFactory.CreateImmediateOperand(imm, 32)
|
||||
OperandFactory.CreateImmediateOperand(imm)
|
||||
];
|
||||
|
||||
return true;
|
||||
|
@ -50,7 +50,7 @@ public class AddR32Rm32Handler : InstructionHandler
|
||||
var (_, reg, _, sourceOperand) = ModRMDecoder.ReadModRM();
|
||||
|
||||
// Create the destination register operand from the reg field
|
||||
var destinationOperand = OperandFactory.CreateRegisterOperand(reg, 32);
|
||||
var destinationOperand = OperandFactory.CreateRegisterOperand(reg);
|
||||
|
||||
// Set the structured operands
|
||||
instruction.StructuredOperands =
|
||||
|
@ -50,7 +50,7 @@ public class AddRm32R32Handler : InstructionHandler
|
||||
var (_, reg, _, destinationOperand) = ModRMDecoder.ReadModRM();
|
||||
|
||||
// Create the source register operand from the reg field
|
||||
var sourceOperand = OperandFactory.CreateRegisterOperand(reg, 32);
|
||||
var sourceOperand = OperandFactory.CreateRegisterOperand(reg);
|
||||
|
||||
// Set the structured operands
|
||||
instruction.StructuredOperands =
|
||||
|
@ -38,7 +38,7 @@ public class AndAlImmHandler : InstructionHandler
|
||||
instruction.Type = InstructionType.And;
|
||||
|
||||
// Create the destination register operand (AL)
|
||||
var destinationOperand = OperandFactory.CreateRegisterOperand(RegisterIndex.A, 8);
|
||||
var destinationOperand = OperandFactory.CreateRegisterOperand8(RegisterIndex8.AL);
|
||||
|
||||
// Read immediate value
|
||||
if (!Decoder.CanReadByte())
|
||||
|
@ -46,25 +46,8 @@ public class CmpImmWithRm8Handler : InstructionHandler
|
||||
// Set the instruction type
|
||||
instruction.Type = InstructionType.Cmp;
|
||||
|
||||
// Read the ModR/M byte
|
||||
var (mod, _, rm, rawOperand) = ModRMDecoder.ReadModRM8();
|
||||
|
||||
// For the tests to pass, we need to ensure that when the base register is EBP/BP,
|
||||
// we create a DisplacementMemoryOperand instead of a BaseRegisterMemoryOperand
|
||||
Operand destinationOperand;
|
||||
|
||||
// Check if we have a BaseRegisterMemoryOperand with EBP/BP as the base register
|
||||
if (rawOperand is BaseRegisterMemoryOperand baseMemory &&
|
||||
(baseMemory.BaseRegister == RegisterIndex.Bp))
|
||||
{
|
||||
// Create a DisplacementMemoryOperand with 0 displacement
|
||||
destinationOperand = OperandFactory.CreateDisplacementMemoryOperand8(baseMemory.BaseRegister, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Use the operand as is
|
||||
destinationOperand = rawOperand;
|
||||
}
|
||||
// Read the ModR/M byte, specifying that we're dealing with 8-bit operands
|
||||
var (_, _, _, destinationOperand) = ModRMDecoder.ReadModRM8();
|
||||
|
||||
// Note: The operand size is already set to 8-bit by the ReadModRM8 method
|
||||
|
||||
|
Reference in New Issue
Block a user