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

Fixed instruction boundary detection and added JGE instruction handler

This commit is contained in:
bird_egop
2025-04-13 03:19:42 +03:00
parent e12f5b5bdf
commit 17ef78a7a7
3 changed files with 126 additions and 63 deletions

View File

@ -104,9 +104,6 @@ public class InstructionHandlerFactory
/// </summary>
private void RegisterArithmeticImmediateHandlers()
{
// Add the Group1SignExtendedHandler first to ensure it has priority for 0x83 opcode
_handlers.Add(new Group1SignExtendedHandler(_codeBuffer, _decoder, _length));
// ADC handlers
_handlers.Add(new AdcImmToRm32Handler(_codeBuffer, _decoder, _length));
_handlers.Add(new AdcImmToRm32SignExtendedHandler(_codeBuffer, _decoder, _length));
@ -152,6 +149,7 @@ public class InstructionHandlerFactory
// JMP handlers
_handlers.Add(new JmpRel32Handler(_codeBuffer, _decoder, _length));
_handlers.Add(new JmpRel8Handler(_codeBuffer, _decoder, _length));
_handlers.Add(new JgeRel8Handler(_codeBuffer, _decoder, _length));
_handlers.Add(new ConditionalJumpHandler(_codeBuffer, _decoder, _length));
_handlers.Add(new TwoByteConditionalJumpHandler(_codeBuffer, _decoder, _length));
}
@ -358,13 +356,6 @@ public class InstructionHandlerFactory
/// <returns>The handler that can decode the opcode, or null if no handler can decode it</returns>
public IInstructionHandler? GetHandler(byte opcode)
{
// Special case for 0x83 opcode (Group 1 instructions with sign-extended immediate)
if (opcode == 0x83)
{
// Return the Group1SignExtendedHandler directly for 0x83 opcode
return new ArithmeticImmediate.Group1SignExtendedHandler(_codeBuffer, _decoder, _length);
}
// For all other opcodes, use the normal handler selection logic
return _handlers.FirstOrDefault(h => h.CanHandle(opcode));
}