diff --git a/X86Disassembler/X86/Handlers/Flags/ClcHandler.cs b/X86Disassembler/X86/Handlers/Flags/ClcHandler.cs new file mode 100644 index 0000000..44a1d2e --- /dev/null +++ b/X86Disassembler/X86/Handlers/Flags/ClcHandler.cs @@ -0,0 +1,44 @@ +namespace X86Disassembler.X86.Handlers.Flags; + +/// +/// Handler for CLC (Clear Carry Flag) instruction (opcode F8) +/// +public class ClcHandler : InstructionHandler +{ + /// + /// Initializes a new instance of the ClcHandler class + /// + /// The instruction decoder that owns this handler + public ClcHandler(InstructionDecoder decoder) + : base(decoder) + { + } + + /// + /// Checks if this handler can decode the given opcode + /// + /// The opcode to check + /// True if this handler can decode the opcode + public override bool CanHandle(byte opcode) + { + // CLC is F8 + return opcode == 0xF8; + } + + /// + /// Decodes a CLC instruction + /// + /// The opcode of the instruction + /// The instruction object to populate + /// True if the instruction was successfully decoded + public override bool Decode(byte opcode, Instruction instruction) + { + // Set the instruction type + instruction.Type = InstructionType.Clc; + + // CLC has no operands + instruction.StructuredOperands = []; + + return true; + } +} diff --git a/X86Disassembler/X86/Handlers/Flags/CldHandler.cs b/X86Disassembler/X86/Handlers/Flags/CldHandler.cs new file mode 100644 index 0000000..9c324fa --- /dev/null +++ b/X86Disassembler/X86/Handlers/Flags/CldHandler.cs @@ -0,0 +1,44 @@ +namespace X86Disassembler.X86.Handlers.Flags; + +/// +/// Handler for CLD (Clear Direction Flag) instruction (opcode FC) +/// +public class CldHandler : InstructionHandler +{ + /// + /// Initializes a new instance of the CldHandler class + /// + /// The instruction decoder that owns this handler + public CldHandler(InstructionDecoder decoder) + : base(decoder) + { + } + + /// + /// Checks if this handler can decode the given opcode + /// + /// The opcode to check + /// True if this handler can decode the opcode + public override bool CanHandle(byte opcode) + { + // CLD is FC + return opcode == 0xFC; + } + + /// + /// Decodes a CLD instruction + /// + /// The opcode of the instruction + /// The instruction object to populate + /// True if the instruction was successfully decoded + public override bool Decode(byte opcode, Instruction instruction) + { + // Set the instruction type + instruction.Type = InstructionType.Cld; + + // CLD has no operands + instruction.StructuredOperands = []; + + return true; + } +} diff --git a/X86Disassembler/X86/Handlers/Flags/CliHandler.cs b/X86Disassembler/X86/Handlers/Flags/CliHandler.cs new file mode 100644 index 0000000..6a66226 --- /dev/null +++ b/X86Disassembler/X86/Handlers/Flags/CliHandler.cs @@ -0,0 +1,44 @@ +namespace X86Disassembler.X86.Handlers.Flags; + +/// +/// Handler for CLI (Clear Interrupt Flag) instruction (opcode FA) +/// +public class CliHandler : InstructionHandler +{ + /// + /// Initializes a new instance of the CliHandler class + /// + /// The instruction decoder that owns this handler + public CliHandler(InstructionDecoder decoder) + : base(decoder) + { + } + + /// + /// Checks if this handler can decode the given opcode + /// + /// The opcode to check + /// True if this handler can decode the opcode + public override bool CanHandle(byte opcode) + { + // CLI is FA + return opcode == 0xFA; + } + + /// + /// Decodes a CLI instruction + /// + /// The opcode of the instruction + /// The instruction object to populate + /// True if the instruction was successfully decoded + public override bool Decode(byte opcode, Instruction instruction) + { + // Set the instruction type + instruction.Type = InstructionType.Cli; + + // CLI has no operands + instruction.StructuredOperands = []; + + return true; + } +} diff --git a/X86Disassembler/X86/Handlers/Flags/CmcHandler.cs b/X86Disassembler/X86/Handlers/Flags/CmcHandler.cs new file mode 100644 index 0000000..5d21bc9 --- /dev/null +++ b/X86Disassembler/X86/Handlers/Flags/CmcHandler.cs @@ -0,0 +1,44 @@ +namespace X86Disassembler.X86.Handlers.Flags; + +/// +/// Handler for CMC (Complement Carry Flag) instruction (opcode F5) +/// +public class CmcHandler : InstructionHandler +{ + /// + /// Initializes a new instance of the CmcHandler class + /// + /// The instruction decoder that owns this handler + public CmcHandler(InstructionDecoder decoder) + : base(decoder) + { + } + + /// + /// Checks if this handler can decode the given opcode + /// + /// The opcode to check + /// True if this handler can decode the opcode + public override bool CanHandle(byte opcode) + { + // CMC is F5 + return opcode == 0xF5; + } + + /// + /// Decodes a CMC instruction + /// + /// The opcode of the instruction + /// The instruction object to populate + /// True if the instruction was successfully decoded + public override bool Decode(byte opcode, Instruction instruction) + { + // Set the instruction type + instruction.Type = InstructionType.Cmc; + + // CMC has no operands + instruction.StructuredOperands = []; + + return true; + } +} diff --git a/X86Disassembler/X86/Handlers/Flags/LahfHandler.cs b/X86Disassembler/X86/Handlers/Flags/LahfHandler.cs new file mode 100644 index 0000000..4ea7d29 --- /dev/null +++ b/X86Disassembler/X86/Handlers/Flags/LahfHandler.cs @@ -0,0 +1,44 @@ +namespace X86Disassembler.X86.Handlers.Flags; + +/// +/// Handler for LAHF (Load Flags into AH) instruction (opcode 9F) +/// +public class LahfHandler : InstructionHandler +{ + /// + /// Initializes a new instance of the LahfHandler class + /// + /// The instruction decoder that owns this handler + public LahfHandler(InstructionDecoder decoder) + : base(decoder) + { + } + + /// + /// Checks if this handler can decode the given opcode + /// + /// The opcode to check + /// True if this handler can decode the opcode + public override bool CanHandle(byte opcode) + { + // LAHF is 9F + return opcode == 0x9F; + } + + /// + /// Decodes a LAHF instruction + /// + /// The opcode of the instruction + /// The instruction object to populate + /// True if the instruction was successfully decoded + public override bool Decode(byte opcode, Instruction instruction) + { + // Set the instruction type + instruction.Type = InstructionType.Lahf; + + // LAHF has no operands + instruction.StructuredOperands = []; + + return true; + } +} diff --git a/X86Disassembler/X86/Handlers/Flags/SahfHandler.cs b/X86Disassembler/X86/Handlers/Flags/SahfHandler.cs new file mode 100644 index 0000000..0c3bd88 --- /dev/null +++ b/X86Disassembler/X86/Handlers/Flags/SahfHandler.cs @@ -0,0 +1,44 @@ +namespace X86Disassembler.X86.Handlers.Flags; + +/// +/// Handler for SAHF (Store AH into Flags) instruction (opcode 9E) +/// +public class SahfHandler : InstructionHandler +{ + /// + /// Initializes a new instance of the SahfHandler class + /// + /// The instruction decoder that owns this handler + public SahfHandler(InstructionDecoder decoder) + : base(decoder) + { + } + + /// + /// Checks if this handler can decode the given opcode + /// + /// The opcode to check + /// True if this handler can decode the opcode + public override bool CanHandle(byte opcode) + { + // SAHF is 9E + return opcode == 0x9E; + } + + /// + /// Decodes a SAHF instruction + /// + /// The opcode of the instruction + /// The instruction object to populate + /// True if the instruction was successfully decoded + public override bool Decode(byte opcode, Instruction instruction) + { + // Set the instruction type + instruction.Type = InstructionType.Sahf; + + // SAHF has no operands + instruction.StructuredOperands = []; + + return true; + } +} diff --git a/X86Disassembler/X86/Handlers/Flags/StcHandler.cs b/X86Disassembler/X86/Handlers/Flags/StcHandler.cs new file mode 100644 index 0000000..d9b0fd3 --- /dev/null +++ b/X86Disassembler/X86/Handlers/Flags/StcHandler.cs @@ -0,0 +1,44 @@ +namespace X86Disassembler.X86.Handlers.Flags; + +/// +/// Handler for STC (Set Carry Flag) instruction (opcode F9) +/// +public class StcHandler : InstructionHandler +{ + /// + /// Initializes a new instance of the StcHandler class + /// + /// The instruction decoder that owns this handler + public StcHandler(InstructionDecoder decoder) + : base(decoder) + { + } + + /// + /// Checks if this handler can decode the given opcode + /// + /// The opcode to check + /// True if this handler can decode the opcode + public override bool CanHandle(byte opcode) + { + // STC is F9 + return opcode == 0xF9; + } + + /// + /// Decodes a STC instruction + /// + /// The opcode of the instruction + /// The instruction object to populate + /// True if the instruction was successfully decoded + public override bool Decode(byte opcode, Instruction instruction) + { + // Set the instruction type + instruction.Type = InstructionType.Stc; + + // STC has no operands + instruction.StructuredOperands = []; + + return true; + } +} diff --git a/X86Disassembler/X86/Handlers/Flags/StdHandler.cs b/X86Disassembler/X86/Handlers/Flags/StdHandler.cs new file mode 100644 index 0000000..d1b8ec8 --- /dev/null +++ b/X86Disassembler/X86/Handlers/Flags/StdHandler.cs @@ -0,0 +1,44 @@ +namespace X86Disassembler.X86.Handlers.Flags; + +/// +/// Handler for STD (Set Direction Flag) instruction (opcode FD) +/// +public class StdHandler : InstructionHandler +{ + /// + /// Initializes a new instance of the StdHandler class + /// + /// The instruction decoder that owns this handler + public StdHandler(InstructionDecoder decoder) + : base(decoder) + { + } + + /// + /// Checks if this handler can decode the given opcode + /// + /// The opcode to check + /// True if this handler can decode the opcode + public override bool CanHandle(byte opcode) + { + // STD is FD + return opcode == 0xFD; + } + + /// + /// Decodes a STD instruction + /// + /// The opcode of the instruction + /// The instruction object to populate + /// True if the instruction was successfully decoded + public override bool Decode(byte opcode, Instruction instruction) + { + // Set the instruction type + instruction.Type = InstructionType.Std; + + // STD has no operands + instruction.StructuredOperands = []; + + return true; + } +} diff --git a/X86Disassembler/X86/Handlers/Flags/StiHandler.cs b/X86Disassembler/X86/Handlers/Flags/StiHandler.cs new file mode 100644 index 0000000..d362ca0 --- /dev/null +++ b/X86Disassembler/X86/Handlers/Flags/StiHandler.cs @@ -0,0 +1,44 @@ +namespace X86Disassembler.X86.Handlers.Flags; + +/// +/// Handler for STI (Set Interrupt Flag) instruction (opcode FB) +/// +public class StiHandler : InstructionHandler +{ + /// + /// Initializes a new instance of the StiHandler class + /// + /// The instruction decoder that owns this handler + public StiHandler(InstructionDecoder decoder) + : base(decoder) + { + } + + /// + /// Checks if this handler can decode the given opcode + /// + /// The opcode to check + /// True if this handler can decode the opcode + public override bool CanHandle(byte opcode) + { + // STI is FB + return opcode == 0xFB; + } + + /// + /// Decodes a STI instruction + /// + /// The opcode of the instruction + /// The instruction object to populate + /// True if the instruction was successfully decoded + public override bool Decode(byte opcode, Instruction instruction) + { + // Set the instruction type + instruction.Type = InstructionType.Sti; + + // STI has no operands + instruction.StructuredOperands = []; + + return true; + } +} diff --git a/X86Disassembler/X86/Handlers/FloatingPoint/Arithmetic/FdivStiStHandler.cs b/X86Disassembler/X86/Handlers/FloatingPoint/Arithmetic/FdivStiStHandler.cs index 6d822a4..65156f5 100644 --- a/X86Disassembler/X86/Handlers/FloatingPoint/Arithmetic/FdivStiStHandler.cs +++ b/X86Disassembler/X86/Handlers/FloatingPoint/Arithmetic/FdivStiStHandler.cs @@ -3,15 +3,15 @@ namespace X86Disassembler.X86.Handlers.FloatingPoint.Arithmetic; using X86Disassembler.X86.Operands; /// -/// Handler for FDIV ST(i), ST instruction (DC F0-F7) +/// Handler for FDIVR ST(i), ST instruction (DC F8-FF) /// -public class FdivStiStHandler : InstructionHandler +public class FdivrStiStHandler_FDIVStiSt : InstructionHandler { /// - /// Initializes a new instance of the FdivStiStHandler class + /// Initializes a new instance of the FdivrStiStHandler class /// /// The instruction decoder that owns this handler - public FdivStiStHandler(InstructionDecoder decoder) + public FdivrStiStHandler_FDIVStiSt(InstructionDecoder decoder) : base(decoder) { } @@ -23,7 +23,7 @@ public class FdivStiStHandler : InstructionHandler /// True if this handler can decode the opcode public override bool CanHandle(byte opcode) { - // FDIV ST(i), ST is DC F0-F7 + // FDIVR ST(i), ST is DC F8-FF if (opcode != 0xDC) return false; if (!Decoder.CanReadByte()) @@ -34,12 +34,12 @@ public class FdivStiStHandler : InstructionHandler // Check second opcode byte byte secondOpcode = Decoder.PeakByte(); - // Only handle F0-F7 - return secondOpcode is >= 0xF0 and <= 0xF7; + // Only handle F8-FF + return secondOpcode is >= 0xF8 and <= 0xFF; } /// - /// Decodes a FDIV ST(i), ST instruction + /// Decodes a FDIVR ST(i), ST instruction /// /// The opcode of the instruction /// The instruction object to populate @@ -52,10 +52,10 @@ public class FdivStiStHandler : InstructionHandler } // Read the ModR/M byte and calculate ST(i) index - var stIndex = (FpuRegisterIndex)(Decoder.ReadByte() - 0xF0); + var stIndex = (FpuRegisterIndex)(Decoder.ReadByte() - 0xF8); // Set the instruction type - instruction.Type = InstructionType.Fdiv; + instruction.Type = InstructionType.Fdivr; // Create the FPU register operands var stiOperand = OperandFactory.CreateFPURegisterOperand(stIndex); diff --git a/X86Disassembler/X86/Handlers/FloatingPoint/Arithmetic/FdivpStiStHandler.cs b/X86Disassembler/X86/Handlers/FloatingPoint/Arithmetic/FdivpStiStHandler.cs index e3e2ce5..5da09df 100644 --- a/X86Disassembler/X86/Handlers/FloatingPoint/Arithmetic/FdivpStiStHandler.cs +++ b/X86Disassembler/X86/Handlers/FloatingPoint/Arithmetic/FdivpStiStHandler.cs @@ -3,15 +3,15 @@ namespace X86Disassembler.X86.Handlers.FloatingPoint.Arithmetic; using X86Disassembler.X86.Operands; /// -/// Handler for FDIVP ST(i), ST instruction (DE F0-F7) +/// Handler for FDIVRP ST(i), ST instruction (DE F8-FF) /// -public class FdivpStiStHandler : InstructionHandler +public class FdivrpStiStHandler_FDIVPStiSt : InstructionHandler { /// - /// Initializes a new instance of the FdivpStiStHandler class + /// Initializes a new instance of the FdivrpStiStHandler class /// /// The instruction decoder that owns this handler - public FdivpStiStHandler(InstructionDecoder decoder) + public FdivrpStiStHandler_FDIVPStiSt(InstructionDecoder decoder) : base(decoder) { } @@ -23,7 +23,7 @@ public class FdivpStiStHandler : InstructionHandler /// True if this handler can decode the opcode public override bool CanHandle(byte opcode) { - // FDIVP ST(i), ST is DE F0-F7 + // FDIVRP ST(i), ST is DE F8-FF if (opcode != 0xDE) return false; if (!Decoder.CanReadByte()) @@ -34,12 +34,12 @@ public class FdivpStiStHandler : InstructionHandler // Check second opcode byte byte secondOpcode = Decoder.PeakByte(); - // Only handle F0-F7 - return secondOpcode is >= 0xF0 and <= 0xF7; + // Only handle F8-FF + return secondOpcode is >= 0xF8 and <= 0xFF; } /// - /// Decodes a FDIVP ST(i), ST instruction + /// Decodes a FDIVRP ST(i), ST instruction /// /// The opcode of the instruction /// The instruction object to populate @@ -52,10 +52,10 @@ public class FdivpStiStHandler : InstructionHandler } // Read the ModR/M byte and calculate ST(i) index - var stIndex = (FpuRegisterIndex)(Decoder.ReadByte() - 0xF0); + var stIndex = (FpuRegisterIndex)(Decoder.ReadByte() - 0xF8); // Set the instruction type - instruction.Type = InstructionType.Fdivp; + instruction.Type = InstructionType.Fdivrp; // Create the FPU register operands var stiOperand = OperandFactory.CreateFPURegisterOperand(stIndex); diff --git a/X86Disassembler/X86/Handlers/FloatingPoint/Arithmetic/FdivrStiStHandler.cs b/X86Disassembler/X86/Handlers/FloatingPoint/Arithmetic/FdivrStiStHandler.cs index 845d1d0..d6207d7 100644 --- a/X86Disassembler/X86/Handlers/FloatingPoint/Arithmetic/FdivrStiStHandler.cs +++ b/X86Disassembler/X86/Handlers/FloatingPoint/Arithmetic/FdivrStiStHandler.cs @@ -3,15 +3,15 @@ namespace X86Disassembler.X86.Handlers.FloatingPoint.Arithmetic; using X86Disassembler.X86.Operands; /// -/// Handler for FDIVR ST(i), ST instruction (DC F8-FF) +/// Handler for FDIV ST(i), ST instruction (DC F0-F7) /// -public class FdivrStiStHandler : InstructionHandler +public class FdivStiStHandler_FDIVRStiSt : InstructionHandler { /// - /// Initializes a new instance of the FdivrStiStHandler class + /// Initializes a new instance of the FdivStiStHandler class /// /// The instruction decoder that owns this handler - public FdivrStiStHandler(InstructionDecoder decoder) + public FdivStiStHandler_FDIVRStiSt(InstructionDecoder decoder) : base(decoder) { } @@ -23,7 +23,7 @@ public class FdivrStiStHandler : InstructionHandler /// True if this handler can decode the opcode public override bool CanHandle(byte opcode) { - // FDIVR ST(i), ST is DC F8-FF + // FDIV ST(i), ST is DC F0-F7 if (opcode != 0xDC) return false; if (!Decoder.CanReadByte()) @@ -34,12 +34,12 @@ public class FdivrStiStHandler : InstructionHandler // Check second opcode byte byte secondOpcode = Decoder.PeakByte(); - // Only handle F8-FF - return secondOpcode is >= 0xF8 and <= 0xFF; + // Only handle F0-F7 + return secondOpcode is >= 0xF0 and <= 0xF7; } /// - /// Decodes a FDIVR ST(i), ST instruction + /// Decodes a FDIV ST(i), ST instruction /// /// The opcode of the instruction /// The instruction object to populate @@ -52,10 +52,10 @@ public class FdivrStiStHandler : InstructionHandler } // Read the ModR/M byte and calculate ST(i) index - var stIndex = (FpuRegisterIndex)(Decoder.ReadByte() - 0xF8); + var stIndex = (FpuRegisterIndex)(Decoder.ReadByte() - 0xF0); // Set the instruction type - instruction.Type = InstructionType.Fdivr; + instruction.Type = InstructionType.Fdiv; // Create the FPU register operands var stiOperand = OperandFactory.CreateFPURegisterOperand(stIndex); diff --git a/X86Disassembler/X86/Handlers/FloatingPoint/Arithmetic/FdivrpStiStHandler.cs b/X86Disassembler/X86/Handlers/FloatingPoint/Arithmetic/FdivrpStiStHandler.cs index a2b3f9d..2b87cc4 100644 --- a/X86Disassembler/X86/Handlers/FloatingPoint/Arithmetic/FdivrpStiStHandler.cs +++ b/X86Disassembler/X86/Handlers/FloatingPoint/Arithmetic/FdivrpStiStHandler.cs @@ -3,15 +3,15 @@ namespace X86Disassembler.X86.Handlers.FloatingPoint.Arithmetic; using X86Disassembler.X86.Operands; /// -/// Handler for FDIVRP ST(i), ST instruction (DE F8-FF) +/// Handler for FDIVP ST(i), ST instruction (DE F0-F7) /// -public class FdivrpStiStHandler : InstructionHandler +public class FdivpStiStHandler_FDIVRPStiSt : InstructionHandler { /// - /// Initializes a new instance of the FdivrpStiStHandler class + /// Initializes a new instance of the FdivpStiStHandler class /// /// The instruction decoder that owns this handler - public FdivrpStiStHandler(InstructionDecoder decoder) + public FdivpStiStHandler_FDIVRPStiSt(InstructionDecoder decoder) : base(decoder) { } @@ -23,7 +23,7 @@ public class FdivrpStiStHandler : InstructionHandler /// True if this handler can decode the opcode public override bool CanHandle(byte opcode) { - // FDIVRP ST(i), ST is DE F8-FF + // FDIVP ST(i), ST is DE F0-F7 if (opcode != 0xDE) return false; if (!Decoder.CanReadByte()) @@ -34,12 +34,12 @@ public class FdivrpStiStHandler : InstructionHandler // Check second opcode byte byte secondOpcode = Decoder.PeakByte(); - // Only handle F8-FF - return secondOpcode is >= 0xF8 and <= 0xFF; + // Only handle F0-F7 + return secondOpcode is >= 0xF0 and <= 0xF7; } /// - /// Decodes a FDIVRP ST(i), ST instruction + /// Decodes a FDIVP ST(i), ST instruction /// /// The opcode of the instruction /// The instruction object to populate @@ -52,10 +52,10 @@ public class FdivrpStiStHandler : InstructionHandler } // Read the ModR/M byte and calculate ST(i) index - var stIndex = (FpuRegisterIndex)(Decoder.ReadByte() - 0xF8); + var stIndex = (FpuRegisterIndex)(Decoder.ReadByte() - 0xF0); // Set the instruction type - instruction.Type = InstructionType.Fdivrp; + instruction.Type = InstructionType.Fdivp; // Create the FPU register operands var stiOperand = OperandFactory.CreateFPURegisterOperand(stIndex); diff --git a/X86Disassembler/X86/Handlers/InstructionHandlerFactory.cs b/X86Disassembler/X86/Handlers/InstructionHandlerFactory.cs index 8a0a3d4..56d160c 100644 --- a/X86Disassembler/X86/Handlers/InstructionHandlerFactory.cs +++ b/X86Disassembler/X86/Handlers/InstructionHandlerFactory.cs @@ -29,6 +29,7 @@ using X86Disassembler.X86.Handlers.Sub; using X86Disassembler.X86.Handlers.Test; using X86Disassembler.X86.Handlers.Xchg; using X86Disassembler.X86.Handlers.Xor; +using X86Disassembler.X86.Handlers.Flags; namespace X86Disassembler.X86.Handlers; @@ -93,6 +94,7 @@ public class InstructionHandlerFactory RegisterBitHandlers(); // Register bit manipulation handlers RegisterMiscHandlers(); // Register miscellaneous instructions RegisterShiftHandlers(); // Register shift and rotate instructions + RegisterFlagHandlers(); // Register flag manipulation instructions } /// @@ -464,8 +466,8 @@ public class InstructionHandlerFactory _handlers.Add(new FloatingPoint.Comparison.FcomRegisterHandler(_decoder)); // FCOM ST(i), ST(0) (DC D0-D7) _handlers.Add(new FloatingPoint.Arithmetic.FsubStiStHandler(_decoder)); // FSUB ST(i), ST (DC E0-E7) _handlers.Add(new FloatingPoint.Arithmetic.FsubrStiStHandler(_decoder)); // FSUBR ST(i), ST (DC E8-EF) - _handlers.Add(new FloatingPoint.Arithmetic.FdivStiStHandler(_decoder)); // FDIV ST(i), ST (DC F0-F7) - _handlers.Add(new FloatingPoint.Arithmetic.FdivrStiStHandler(_decoder)); // FDIVR ST(i), ST (DC F8-FF) + _handlers.Add(new FloatingPoint.Arithmetic.FdivrStiStHandler(_decoder)); // FDIV ST(i), ST (DC F0-F7) + _handlers.Add(new FloatingPoint.Arithmetic.FdivStiStHandler(_decoder)); // FDIVR ST(i), ST (DC F8-FF) _handlers.Add(new FloatingPoint.Comparison.FcompRegisterHandler(_decoder)); // FCOMP ST(i), ST(0) (DC D8-DF) // DD opcode handlers (register operations) @@ -496,8 +498,8 @@ public class InstructionHandlerFactory _handlers.Add(new FloatingPoint.Comparison.FcomppHandler(_decoder)); // FCOMPP (DE D9) _handlers.Add(new FloatingPoint.Arithmetic.FsubpStiStHandler(_decoder)); // FSUBP ST(i), ST (DE E0-E7) _handlers.Add(new FloatingPoint.Arithmetic.FsubrpStiStHandler(_decoder)); // FSUBRP ST(i), ST (DE E8-EF) - _handlers.Add(new FloatingPoint.Arithmetic.FdivpStiStHandler(_decoder)); // FDIVP ST(i), ST (DE F0-F7) - _handlers.Add(new FloatingPoint.Arithmetic.FdivrpStiStHandler(_decoder)); // FDIVRP ST(i), ST (DE F8-FF) + _handlers.Add(new FloatingPoint.Arithmetic.FdivrpStiStHandler(_decoder)); // FDIVP ST(i), ST (DE F0-F7) + _handlers.Add(new FloatingPoint.Arithmetic.FdivpStiStHandler(_decoder)); // FDIVRP ST(i), ST (DE F8-FF) // DF opcode handlers (memory operations) _handlers.Add(new FloatingPoint.LoadStore.FildInt16Handler(_decoder)); // FILD int16 (DF /0) @@ -656,7 +658,7 @@ public class InstructionHandlerFactory } /// - /// Registers all shift and rotate instruction handlers + /// Registers all Shift instruction handlers /// private void RegisterShiftHandlers() { @@ -716,6 +718,23 @@ public class InstructionHandlerFactory _handlers.Add(new RcrRm32ByClHandler(_decoder)); // RCR r/m32, CL (0xD3 /3) _handlers.Add(new RcrRm32ByImmHandler(_decoder)); // RCR r/m32, imm8 (0xC1 /3) } + + /// + /// Registers all Flag manipulation instruction handlers + /// + private void RegisterFlagHandlers() + { + // Register flag manipulation handlers + _handlers.Add(new StcHandler(_decoder)); // STC (Set Carry Flag) - opcode F9 + _handlers.Add(new ClcHandler(_decoder)); // CLC (Clear Carry Flag) - opcode F8 + _handlers.Add(new CmcHandler(_decoder)); // CMC (Complement Carry Flag) - opcode F5 + _handlers.Add(new StdHandler(_decoder)); // STD (Set Direction Flag) - opcode FD + _handlers.Add(new CldHandler(_decoder)); // CLD (Clear Direction Flag) - opcode FC + _handlers.Add(new StiHandler(_decoder)); // STI (Set Interrupt Flag) - opcode FB + _handlers.Add(new CliHandler(_decoder)); // CLI (Clear Interrupt Flag) - opcode FA + _handlers.Add(new SahfHandler(_decoder)); // SAHF (Store AH into Flags) - opcode 9E + _handlers.Add(new LahfHandler(_decoder)); // LAHF (Load Flags into AH) - opcode 9F + } /// /// Registers all bit manipulation instruction handlers