mirror of
https://github.com/sampletext32/ParkanPlayground.git
synced 2025-05-19 03:41:18 +03:00
remove duplicate registration
This commit is contained in:
parent
66f9e838ad
commit
84d5652a62
@ -76,12 +76,12 @@ public class InstructionHandlerFactory
|
|||||||
RegisterImulHandlers(); // IMUL instructions
|
RegisterImulHandlers(); // IMUL instructions
|
||||||
RegisterDivHandlers(); // DIV instructions
|
RegisterDivHandlers(); // DIV instructions
|
||||||
RegisterIdivHandlers(); // IDIV instructions
|
RegisterIdivHandlers(); // IDIV instructions
|
||||||
RegisterDataTransferHandlers(); // MOV, MOVZX, MOVSX
|
RegisterXchgHandlers(); // XCHG
|
||||||
RegisterJumpHandlers(); // JMP instructions
|
RegisterJumpHandlers(); // JMP instructions
|
||||||
RegisterCallHandlers(); // CALL instructions
|
RegisterCallHandlers(); // CALL instructions
|
||||||
RegisterReturnHandlers(); // RET instructions
|
RegisterReturnHandlers(); // RET instructions
|
||||||
RegisterDecHandlers(); // DEC instructions
|
RegisterDecHandlers(); // DEC instructions
|
||||||
RegisterIncHandlers(); // INC/DEC handlers after Group 1 handlers
|
RegisterIncHandlers(); // INC/DEC handlers after Group 1 handlers
|
||||||
RegisterPushHandlers(); // PUSH instructions
|
RegisterPushHandlers(); // PUSH instructions
|
||||||
RegisterPopHandlers(); // POP instructions
|
RegisterPopHandlers(); // POP instructions
|
||||||
RegisterLeaHandlers(); // LEA instructions
|
RegisterLeaHandlers(); // LEA instructions
|
||||||
@ -350,20 +350,10 @@ public class InstructionHandlerFactory
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Registers all Data Transfer instruction handlers
|
/// Registers all XCHG instruction handlers
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void RegisterDataTransferHandlers()
|
private void RegisterXchgHandlers()
|
||||||
{
|
{
|
||||||
// Add MOV handlers
|
|
||||||
_handlers.Add(new MovRegMemHandler(_decoder)); // MOV r32, r/m32 (opcode 8B)
|
|
||||||
_handlers.Add(new MovMemRegHandler(_decoder)); // MOV r/m32, r32 (opcode 89)
|
|
||||||
_handlers.Add(new MovRegImm32Handler(_decoder)); // MOV r32, imm32 (opcode B8 + register)
|
|
||||||
_handlers.Add(new MovRegImm8Handler(_decoder)); // MOV r32, imm8 (opcode B0 + register)
|
|
||||||
_handlers.Add(new MovEaxMoffsHandler(_decoder)); // MOV EAX, moffs32 (opcode A1)
|
|
||||||
_handlers.Add(new MovMoffsEaxHandler(_decoder)); // MOV moffs32, EAX (opcode A3)
|
|
||||||
_handlers.Add(new MovRm32Imm32Handler(_decoder)); // MOV r/m32, imm32 (opcode C7 /0)
|
|
||||||
_handlers.Add(new MovRm8Imm8Handler(_decoder)); // MOV r/m8, imm8 (opcode C6 /0)
|
|
||||||
|
|
||||||
// Add XCHG handlers
|
// Add XCHG handlers
|
||||||
_handlers.Add(new XchgEaxRegHandler(_decoder)); // XCHG EAX, r32 (opcode 90 + register)
|
_handlers.Add(new XchgEaxRegHandler(_decoder)); // XCHG EAX, r32 (opcode 90 + register)
|
||||||
}
|
}
|
||||||
@ -404,16 +394,6 @@ public class InstructionHandlerFactory
|
|||||||
_handlers.Add(new FloatingPoint.Arithmetic.FidivInt32Handler(_decoder)); // FIDIV int32 (DA /6)
|
_handlers.Add(new FloatingPoint.Arithmetic.FidivInt32Handler(_decoder)); // FIDIV int32 (DA /6)
|
||||||
_handlers.Add(new FloatingPoint.Arithmetic.FidivrInt32Handler(_decoder)); // FIDIVR int32 (DA /7)
|
_handlers.Add(new FloatingPoint.Arithmetic.FidivrInt32Handler(_decoder)); // FIDIVR int32 (DA /7)
|
||||||
|
|
||||||
// DC opcode handlers (float64 operations)
|
|
||||||
_handlers.Add(new FloatingPoint.Arithmetic.FaddFloat64Handler(_decoder)); // FADD float64 (DC /0)
|
|
||||||
_handlers.Add(new FloatingPoint.Arithmetic.FmulFloat64Handler(_decoder)); // FMUL float64 (DC /1)
|
|
||||||
_handlers.Add(new FloatingPoint.Comparison.FcomFloat64Handler(_decoder)); // FCOM float64 (DC /2)
|
|
||||||
_handlers.Add(new FloatingPoint.Comparison.FcompFloat64Handler(_decoder)); // FCOMP float64 (DC /3)
|
|
||||||
_handlers.Add(new FloatingPoint.Arithmetic.FsubFloat64Handler(_decoder)); // FSUB float64 (DC /4)
|
|
||||||
_handlers.Add(new FloatingPoint.Arithmetic.FsubrFloat64Handler(_decoder)); // FSUBR float64 (DC /5)
|
|
||||||
_handlers.Add(new FloatingPoint.Arithmetic.FdivFloat64Handler(_decoder)); // FDIV float64 (DC /6)
|
|
||||||
_handlers.Add(new FloatingPoint.Arithmetic.FdivrFloat64Handler(_decoder)); // FDIVR float64 (DC /7)
|
|
||||||
|
|
||||||
// DD opcode handlers (load/store float64 operations)
|
// DD opcode handlers (load/store float64 operations)
|
||||||
_handlers.Add(new FloatingPoint.LoadStore.FldFloat64Handler(_decoder)); // FLD float64 (DD /0)
|
_handlers.Add(new FloatingPoint.LoadStore.FldFloat64Handler(_decoder)); // FLD float64 (DD /0)
|
||||||
_handlers.Add(new FloatingPoint.LoadStore.FstFloat64Handler(_decoder)); // FST float64 (DD /2)
|
_handlers.Add(new FloatingPoint.LoadStore.FstFloat64Handler(_decoder)); // FST float64 (DD /2)
|
||||||
@ -457,7 +437,7 @@ public class InstructionHandlerFactory
|
|||||||
// DB opcode handlers (comparison instructions)
|
// DB opcode handlers (comparison instructions)
|
||||||
_handlers.Add(new FloatingPoint.Comparison.FucomiHandler(_decoder)); // FUCOMI (DB E8-EF)
|
_handlers.Add(new FloatingPoint.Comparison.FucomiHandler(_decoder)); // FUCOMI (DB E8-EF)
|
||||||
_handlers.Add(new FloatingPoint.Comparison.FcomiHandler(_decoder)); // FCOMI (DB F0-F7)
|
_handlers.Add(new FloatingPoint.Comparison.FcomiHandler(_decoder)); // FCOMI (DB F0-F7)
|
||||||
|
|
||||||
// D8 opcode handlers (register operations)
|
// D8 opcode handlers (register operations)
|
||||||
_handlers.Add(new FloatingPoint.Arithmetic.FaddRegisterHandler(_decoder)); // FADD ST(0), ST(i) (D8 C0-C7)
|
_handlers.Add(new FloatingPoint.Arithmetic.FaddRegisterHandler(_decoder)); // FADD ST(0), ST(i) (D8 C0-C7)
|
||||||
_handlers.Add(new FloatingPoint.Arithmetic.FmulRegisterHandler(_decoder)); // FMUL ST(0), ST(i) (D8 C8-CF)
|
_handlers.Add(new FloatingPoint.Arithmetic.FmulRegisterHandler(_decoder)); // FMUL ST(0), ST(i) (D8 C8-CF)
|
||||||
@ -467,7 +447,7 @@ public class InstructionHandlerFactory
|
|||||||
_handlers.Add(new FloatingPoint.Arithmetic.FdivRegisterHandler(_decoder)); // FDIV ST(0), ST(i) (D8 F0-F7)
|
_handlers.Add(new FloatingPoint.Arithmetic.FdivRegisterHandler(_decoder)); // FDIV ST(0), ST(i) (D8 F0-F7)
|
||||||
_handlers.Add(new FloatingPoint.Arithmetic.FdivrRegisterHandler(_decoder)); // FDIVR ST(0), ST(i) (D8 F8-FF)
|
_handlers.Add(new FloatingPoint.Arithmetic.FdivrRegisterHandler(_decoder)); // FDIVR ST(0), ST(i) (D8 F8-FF)
|
||||||
|
|
||||||
// DC opcode handlers (register-register operations)
|
// DC opcode handlers (memory operations - float64)
|
||||||
_handlers.Add(new FloatingPoint.Arithmetic.FaddFloat64Handler(_decoder)); // FADD float64 (DC /0)
|
_handlers.Add(new FloatingPoint.Arithmetic.FaddFloat64Handler(_decoder)); // FADD float64 (DC /0)
|
||||||
_handlers.Add(new FloatingPoint.Arithmetic.FmulFloat64Handler(_decoder)); // FMUL float64 (DC /1)
|
_handlers.Add(new FloatingPoint.Arithmetic.FmulFloat64Handler(_decoder)); // FMUL float64 (DC /1)
|
||||||
_handlers.Add(new FloatingPoint.Comparison.FcomFloat64Handler(_decoder)); // FCOM float64 (DC /2)
|
_handlers.Add(new FloatingPoint.Comparison.FcomFloat64Handler(_decoder)); // FCOM float64 (DC /2)
|
||||||
@ -476,6 +456,8 @@ public class InstructionHandlerFactory
|
|||||||
_handlers.Add(new FloatingPoint.Arithmetic.FsubrFloat64Handler(_decoder)); // FSUBR float64 (DC /5)
|
_handlers.Add(new FloatingPoint.Arithmetic.FsubrFloat64Handler(_decoder)); // FSUBR float64 (DC /5)
|
||||||
_handlers.Add(new FloatingPoint.Arithmetic.FdivFloat64Handler(_decoder)); // FDIV float64 (DC /6)
|
_handlers.Add(new FloatingPoint.Arithmetic.FdivFloat64Handler(_decoder)); // FDIV float64 (DC /6)
|
||||||
_handlers.Add(new FloatingPoint.Arithmetic.FdivrFloat64Handler(_decoder)); // FDIVR float64 (DC /7)
|
_handlers.Add(new FloatingPoint.Arithmetic.FdivrFloat64Handler(_decoder)); // FDIVR float64 (DC /7)
|
||||||
|
|
||||||
|
// DC opcode handlers (register operations)
|
||||||
_handlers.Add(new FloatingPoint.Comparison.FcomRegisterHandler(_decoder)); // FCOM ST(i), ST(0) (DC D0-D7)
|
_handlers.Add(new FloatingPoint.Comparison.FcomRegisterHandler(_decoder)); // FCOM ST(i), ST(0) (DC D0-D7)
|
||||||
_handlers.Add(new FloatingPoint.Comparison.FcompRegisterHandler(_decoder)); // FCOMP ST(i), ST(0) (DC D8-DF)
|
_handlers.Add(new FloatingPoint.Comparison.FcompRegisterHandler(_decoder)); // FCOMP ST(i), ST(0) (DC D8-DF)
|
||||||
|
|
||||||
|
@ -40,5 +40,21 @@ public class InstructionHandlerFactoryTests
|
|||||||
{
|
{
|
||||||
Assert.Contains(handlers, x => x.GetType() == handlerType);
|
Assert.Contains(handlers, x => x.GetType() == handlerType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var uniqueRegisteredHandlers = new HashSet<string>();
|
||||||
|
var duplicates = new List<string>();
|
||||||
|
foreach (var handler in handlers)
|
||||||
|
{
|
||||||
|
if (!uniqueRegisteredHandlers.Add(handler.GetType().Name))
|
||||||
|
{
|
||||||
|
duplicates.Add(handler.GetType().Name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (duplicates.Count != 0)
|
||||||
|
{
|
||||||
|
Assert.Fail($"The following handlers are registered more than 1 time:\n" +
|
||||||
|
$"{string.Join("\n", duplicates)}");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user