0
mirror of https://github.com/sampletext32/ParkanPlayground.git synced 2025-05-19 03:41:18 +03:00

Added flag manipulation instruction handlers (STC, CLC, CMC, STD, CLD, STI, CLI, SAHF, LAHF)

This commit is contained in:
bird_egop 2025-04-18 12:30:47 +03:00
parent e967c0e0c0
commit e9c221ac14
14 changed files with 460 additions and 45 deletions

View File

@ -0,0 +1,44 @@
namespace X86Disassembler.X86.Handlers.Flags;
/// <summary>
/// Handler for CLC (Clear Carry Flag) instruction (opcode F8)
/// </summary>
public class ClcHandler : InstructionHandler
{
/// <summary>
/// Initializes a new instance of the ClcHandler class
/// </summary>
/// <param name="decoder">The instruction decoder that owns this handler</param>
public ClcHandler(InstructionDecoder decoder)
: base(decoder)
{
}
/// <summary>
/// Checks if this handler can decode the given opcode
/// </summary>
/// <param name="opcode">The opcode to check</param>
/// <returns>True if this handler can decode the opcode</returns>
public override bool CanHandle(byte opcode)
{
// CLC is F8
return opcode == 0xF8;
}
/// <summary>
/// Decodes a CLC instruction
/// </summary>
/// <param name="opcode">The opcode of the instruction</param>
/// <param name="instruction">The instruction object to populate</param>
/// <returns>True if the instruction was successfully decoded</returns>
public override bool Decode(byte opcode, Instruction instruction)
{
// Set the instruction type
instruction.Type = InstructionType.Clc;
// CLC has no operands
instruction.StructuredOperands = [];
return true;
}
}

View File

@ -0,0 +1,44 @@
namespace X86Disassembler.X86.Handlers.Flags;
/// <summary>
/// Handler for CLD (Clear Direction Flag) instruction (opcode FC)
/// </summary>
public class CldHandler : InstructionHandler
{
/// <summary>
/// Initializes a new instance of the CldHandler class
/// </summary>
/// <param name="decoder">The instruction decoder that owns this handler</param>
public CldHandler(InstructionDecoder decoder)
: base(decoder)
{
}
/// <summary>
/// Checks if this handler can decode the given opcode
/// </summary>
/// <param name="opcode">The opcode to check</param>
/// <returns>True if this handler can decode the opcode</returns>
public override bool CanHandle(byte opcode)
{
// CLD is FC
return opcode == 0xFC;
}
/// <summary>
/// Decodes a CLD instruction
/// </summary>
/// <param name="opcode">The opcode of the instruction</param>
/// <param name="instruction">The instruction object to populate</param>
/// <returns>True if the instruction was successfully decoded</returns>
public override bool Decode(byte opcode, Instruction instruction)
{
// Set the instruction type
instruction.Type = InstructionType.Cld;
// CLD has no operands
instruction.StructuredOperands = [];
return true;
}
}

View File

@ -0,0 +1,44 @@
namespace X86Disassembler.X86.Handlers.Flags;
/// <summary>
/// Handler for CLI (Clear Interrupt Flag) instruction (opcode FA)
/// </summary>
public class CliHandler : InstructionHandler
{
/// <summary>
/// Initializes a new instance of the CliHandler class
/// </summary>
/// <param name="decoder">The instruction decoder that owns this handler</param>
public CliHandler(InstructionDecoder decoder)
: base(decoder)
{
}
/// <summary>
/// Checks if this handler can decode the given opcode
/// </summary>
/// <param name="opcode">The opcode to check</param>
/// <returns>True if this handler can decode the opcode</returns>
public override bool CanHandle(byte opcode)
{
// CLI is FA
return opcode == 0xFA;
}
/// <summary>
/// Decodes a CLI instruction
/// </summary>
/// <param name="opcode">The opcode of the instruction</param>
/// <param name="instruction">The instruction object to populate</param>
/// <returns>True if the instruction was successfully decoded</returns>
public override bool Decode(byte opcode, Instruction instruction)
{
// Set the instruction type
instruction.Type = InstructionType.Cli;
// CLI has no operands
instruction.StructuredOperands = [];
return true;
}
}

View File

@ -0,0 +1,44 @@
namespace X86Disassembler.X86.Handlers.Flags;
/// <summary>
/// Handler for CMC (Complement Carry Flag) instruction (opcode F5)
/// </summary>
public class CmcHandler : InstructionHandler
{
/// <summary>
/// Initializes a new instance of the CmcHandler class
/// </summary>
/// <param name="decoder">The instruction decoder that owns this handler</param>
public CmcHandler(InstructionDecoder decoder)
: base(decoder)
{
}
/// <summary>
/// Checks if this handler can decode the given opcode
/// </summary>
/// <param name="opcode">The opcode to check</param>
/// <returns>True if this handler can decode the opcode</returns>
public override bool CanHandle(byte opcode)
{
// CMC is F5
return opcode == 0xF5;
}
/// <summary>
/// Decodes a CMC instruction
/// </summary>
/// <param name="opcode">The opcode of the instruction</param>
/// <param name="instruction">The instruction object to populate</param>
/// <returns>True if the instruction was successfully decoded</returns>
public override bool Decode(byte opcode, Instruction instruction)
{
// Set the instruction type
instruction.Type = InstructionType.Cmc;
// CMC has no operands
instruction.StructuredOperands = [];
return true;
}
}

View File

@ -0,0 +1,44 @@
namespace X86Disassembler.X86.Handlers.Flags;
/// <summary>
/// Handler for LAHF (Load Flags into AH) instruction (opcode 9F)
/// </summary>
public class LahfHandler : InstructionHandler
{
/// <summary>
/// Initializes a new instance of the LahfHandler class
/// </summary>
/// <param name="decoder">The instruction decoder that owns this handler</param>
public LahfHandler(InstructionDecoder decoder)
: base(decoder)
{
}
/// <summary>
/// Checks if this handler can decode the given opcode
/// </summary>
/// <param name="opcode">The opcode to check</param>
/// <returns>True if this handler can decode the opcode</returns>
public override bool CanHandle(byte opcode)
{
// LAHF is 9F
return opcode == 0x9F;
}
/// <summary>
/// Decodes a LAHF instruction
/// </summary>
/// <param name="opcode">The opcode of the instruction</param>
/// <param name="instruction">The instruction object to populate</param>
/// <returns>True if the instruction was successfully decoded</returns>
public override bool Decode(byte opcode, Instruction instruction)
{
// Set the instruction type
instruction.Type = InstructionType.Lahf;
// LAHF has no operands
instruction.StructuredOperands = [];
return true;
}
}

View File

@ -0,0 +1,44 @@
namespace X86Disassembler.X86.Handlers.Flags;
/// <summary>
/// Handler for SAHF (Store AH into Flags) instruction (opcode 9E)
/// </summary>
public class SahfHandler : InstructionHandler
{
/// <summary>
/// Initializes a new instance of the SahfHandler class
/// </summary>
/// <param name="decoder">The instruction decoder that owns this handler</param>
public SahfHandler(InstructionDecoder decoder)
: base(decoder)
{
}
/// <summary>
/// Checks if this handler can decode the given opcode
/// </summary>
/// <param name="opcode">The opcode to check</param>
/// <returns>True if this handler can decode the opcode</returns>
public override bool CanHandle(byte opcode)
{
// SAHF is 9E
return opcode == 0x9E;
}
/// <summary>
/// Decodes a SAHF instruction
/// </summary>
/// <param name="opcode">The opcode of the instruction</param>
/// <param name="instruction">The instruction object to populate</param>
/// <returns>True if the instruction was successfully decoded</returns>
public override bool Decode(byte opcode, Instruction instruction)
{
// Set the instruction type
instruction.Type = InstructionType.Sahf;
// SAHF has no operands
instruction.StructuredOperands = [];
return true;
}
}

View File

@ -0,0 +1,44 @@
namespace X86Disassembler.X86.Handlers.Flags;
/// <summary>
/// Handler for STC (Set Carry Flag) instruction (opcode F9)
/// </summary>
public class StcHandler : InstructionHandler
{
/// <summary>
/// Initializes a new instance of the StcHandler class
/// </summary>
/// <param name="decoder">The instruction decoder that owns this handler</param>
public StcHandler(InstructionDecoder decoder)
: base(decoder)
{
}
/// <summary>
/// Checks if this handler can decode the given opcode
/// </summary>
/// <param name="opcode">The opcode to check</param>
/// <returns>True if this handler can decode the opcode</returns>
public override bool CanHandle(byte opcode)
{
// STC is F9
return opcode == 0xF9;
}
/// <summary>
/// Decodes a STC instruction
/// </summary>
/// <param name="opcode">The opcode of the instruction</param>
/// <param name="instruction">The instruction object to populate</param>
/// <returns>True if the instruction was successfully decoded</returns>
public override bool Decode(byte opcode, Instruction instruction)
{
// Set the instruction type
instruction.Type = InstructionType.Stc;
// STC has no operands
instruction.StructuredOperands = [];
return true;
}
}

View File

@ -0,0 +1,44 @@
namespace X86Disassembler.X86.Handlers.Flags;
/// <summary>
/// Handler for STD (Set Direction Flag) instruction (opcode FD)
/// </summary>
public class StdHandler : InstructionHandler
{
/// <summary>
/// Initializes a new instance of the StdHandler class
/// </summary>
/// <param name="decoder">The instruction decoder that owns this handler</param>
public StdHandler(InstructionDecoder decoder)
: base(decoder)
{
}
/// <summary>
/// Checks if this handler can decode the given opcode
/// </summary>
/// <param name="opcode">The opcode to check</param>
/// <returns>True if this handler can decode the opcode</returns>
public override bool CanHandle(byte opcode)
{
// STD is FD
return opcode == 0xFD;
}
/// <summary>
/// Decodes a STD instruction
/// </summary>
/// <param name="opcode">The opcode of the instruction</param>
/// <param name="instruction">The instruction object to populate</param>
/// <returns>True if the instruction was successfully decoded</returns>
public override bool Decode(byte opcode, Instruction instruction)
{
// Set the instruction type
instruction.Type = InstructionType.Std;
// STD has no operands
instruction.StructuredOperands = [];
return true;
}
}

View File

@ -0,0 +1,44 @@
namespace X86Disassembler.X86.Handlers.Flags;
/// <summary>
/// Handler for STI (Set Interrupt Flag) instruction (opcode FB)
/// </summary>
public class StiHandler : InstructionHandler
{
/// <summary>
/// Initializes a new instance of the StiHandler class
/// </summary>
/// <param name="decoder">The instruction decoder that owns this handler</param>
public StiHandler(InstructionDecoder decoder)
: base(decoder)
{
}
/// <summary>
/// Checks if this handler can decode the given opcode
/// </summary>
/// <param name="opcode">The opcode to check</param>
/// <returns>True if this handler can decode the opcode</returns>
public override bool CanHandle(byte opcode)
{
// STI is FB
return opcode == 0xFB;
}
/// <summary>
/// Decodes a STI instruction
/// </summary>
/// <param name="opcode">The opcode of the instruction</param>
/// <param name="instruction">The instruction object to populate</param>
/// <returns>True if the instruction was successfully decoded</returns>
public override bool Decode(byte opcode, Instruction instruction)
{
// Set the instruction type
instruction.Type = InstructionType.Sti;
// STI has no operands
instruction.StructuredOperands = [];
return true;
}
}

View File

@ -3,15 +3,15 @@ namespace X86Disassembler.X86.Handlers.FloatingPoint.Arithmetic;
using X86Disassembler.X86.Operands; using X86Disassembler.X86.Operands;
/// <summary> /// <summary>
/// Handler for FDIV ST(i), ST instruction (DC F0-F7) /// Handler for FDIVR ST(i), ST instruction (DC F8-FF)
/// </summary> /// </summary>
public class FdivStiStHandler : InstructionHandler public class FdivrStiStHandler_FDIVStiSt : InstructionHandler
{ {
/// <summary> /// <summary>
/// Initializes a new instance of the FdivStiStHandler class /// Initializes a new instance of the FdivrStiStHandler class
/// </summary> /// </summary>
/// <param name="decoder">The instruction decoder that owns this handler</param> /// <param name="decoder">The instruction decoder that owns this handler</param>
public FdivStiStHandler(InstructionDecoder decoder) public FdivrStiStHandler_FDIVStiSt(InstructionDecoder decoder)
: base(decoder) : base(decoder)
{ {
} }
@ -23,7 +23,7 @@ public class FdivStiStHandler : InstructionHandler
/// <returns>True if this handler can decode the opcode</returns> /// <returns>True if this handler can decode the opcode</returns>
public override bool CanHandle(byte 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 (opcode != 0xDC) return false;
if (!Decoder.CanReadByte()) if (!Decoder.CanReadByte())
@ -34,12 +34,12 @@ public class FdivStiStHandler : InstructionHandler
// Check second opcode byte // Check second opcode byte
byte secondOpcode = Decoder.PeakByte(); byte secondOpcode = Decoder.PeakByte();
// Only handle F0-F7 // Only handle F8-FF
return secondOpcode is >= 0xF0 and <= 0xF7; return secondOpcode is >= 0xF8 and <= 0xFF;
} }
/// <summary> /// <summary>
/// Decodes a FDIV ST(i), ST instruction /// Decodes a FDIVR ST(i), ST instruction
/// </summary> /// </summary>
/// <param name="opcode">The opcode of the instruction</param> /// <param name="opcode">The opcode of the instruction</param>
/// <param name="instruction">The instruction object to populate</param> /// <param name="instruction">The instruction object to populate</param>
@ -52,10 +52,10 @@ public class FdivStiStHandler : InstructionHandler
} }
// Read the ModR/M byte and calculate ST(i) index // 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 // Set the instruction type
instruction.Type = InstructionType.Fdiv; instruction.Type = InstructionType.Fdivr;
// Create the FPU register operands // Create the FPU register operands
var stiOperand = OperandFactory.CreateFPURegisterOperand(stIndex); var stiOperand = OperandFactory.CreateFPURegisterOperand(stIndex);

View File

@ -3,15 +3,15 @@ namespace X86Disassembler.X86.Handlers.FloatingPoint.Arithmetic;
using X86Disassembler.X86.Operands; using X86Disassembler.X86.Operands;
/// <summary> /// <summary>
/// Handler for FDIVP ST(i), ST instruction (DE F0-F7) /// Handler for FDIVRP ST(i), ST instruction (DE F8-FF)
/// </summary> /// </summary>
public class FdivpStiStHandler : InstructionHandler public class FdivrpStiStHandler_FDIVPStiSt : InstructionHandler
{ {
/// <summary> /// <summary>
/// Initializes a new instance of the FdivpStiStHandler class /// Initializes a new instance of the FdivrpStiStHandler class
/// </summary> /// </summary>
/// <param name="decoder">The instruction decoder that owns this handler</param> /// <param name="decoder">The instruction decoder that owns this handler</param>
public FdivpStiStHandler(InstructionDecoder decoder) public FdivrpStiStHandler_FDIVPStiSt(InstructionDecoder decoder)
: base(decoder) : base(decoder)
{ {
} }
@ -23,7 +23,7 @@ public class FdivpStiStHandler : InstructionHandler
/// <returns>True if this handler can decode the opcode</returns> /// <returns>True if this handler can decode the opcode</returns>
public override bool CanHandle(byte 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 (opcode != 0xDE) return false;
if (!Decoder.CanReadByte()) if (!Decoder.CanReadByte())
@ -34,12 +34,12 @@ public class FdivpStiStHandler : InstructionHandler
// Check second opcode byte // Check second opcode byte
byte secondOpcode = Decoder.PeakByte(); byte secondOpcode = Decoder.PeakByte();
// Only handle F0-F7 // Only handle F8-FF
return secondOpcode is >= 0xF0 and <= 0xF7; return secondOpcode is >= 0xF8 and <= 0xFF;
} }
/// <summary> /// <summary>
/// Decodes a FDIVP ST(i), ST instruction /// Decodes a FDIVRP ST(i), ST instruction
/// </summary> /// </summary>
/// <param name="opcode">The opcode of the instruction</param> /// <param name="opcode">The opcode of the instruction</param>
/// <param name="instruction">The instruction object to populate</param> /// <param name="instruction">The instruction object to populate</param>
@ -52,10 +52,10 @@ public class FdivpStiStHandler : InstructionHandler
} }
// Read the ModR/M byte and calculate ST(i) index // 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 // Set the instruction type
instruction.Type = InstructionType.Fdivp; instruction.Type = InstructionType.Fdivrp;
// Create the FPU register operands // Create the FPU register operands
var stiOperand = OperandFactory.CreateFPURegisterOperand(stIndex); var stiOperand = OperandFactory.CreateFPURegisterOperand(stIndex);

View File

@ -3,15 +3,15 @@ namespace X86Disassembler.X86.Handlers.FloatingPoint.Arithmetic;
using X86Disassembler.X86.Operands; using X86Disassembler.X86.Operands;
/// <summary> /// <summary>
/// Handler for FDIVR ST(i), ST instruction (DC F8-FF) /// Handler for FDIV ST(i), ST instruction (DC F0-F7)
/// </summary> /// </summary>
public class FdivrStiStHandler : InstructionHandler public class FdivStiStHandler_FDIVRStiSt : InstructionHandler
{ {
/// <summary> /// <summary>
/// Initializes a new instance of the FdivrStiStHandler class /// Initializes a new instance of the FdivStiStHandler class
/// </summary> /// </summary>
/// <param name="decoder">The instruction decoder that owns this handler</param> /// <param name="decoder">The instruction decoder that owns this handler</param>
public FdivrStiStHandler(InstructionDecoder decoder) public FdivStiStHandler_FDIVRStiSt(InstructionDecoder decoder)
: base(decoder) : base(decoder)
{ {
} }
@ -23,7 +23,7 @@ public class FdivrStiStHandler : InstructionHandler
/// <returns>True if this handler can decode the opcode</returns> /// <returns>True if this handler can decode the opcode</returns>
public override bool CanHandle(byte 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 (opcode != 0xDC) return false;
if (!Decoder.CanReadByte()) if (!Decoder.CanReadByte())
@ -34,12 +34,12 @@ public class FdivrStiStHandler : InstructionHandler
// Check second opcode byte // Check second opcode byte
byte secondOpcode = Decoder.PeakByte(); byte secondOpcode = Decoder.PeakByte();
// Only handle F8-FF // Only handle F0-F7
return secondOpcode is >= 0xF8 and <= 0xFF; return secondOpcode is >= 0xF0 and <= 0xF7;
} }
/// <summary> /// <summary>
/// Decodes a FDIVR ST(i), ST instruction /// Decodes a FDIV ST(i), ST instruction
/// </summary> /// </summary>
/// <param name="opcode">The opcode of the instruction</param> /// <param name="opcode">The opcode of the instruction</param>
/// <param name="instruction">The instruction object to populate</param> /// <param name="instruction">The instruction object to populate</param>
@ -52,10 +52,10 @@ public class FdivrStiStHandler : InstructionHandler
} }
// Read the ModR/M byte and calculate ST(i) index // 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 // Set the instruction type
instruction.Type = InstructionType.Fdivr; instruction.Type = InstructionType.Fdiv;
// Create the FPU register operands // Create the FPU register operands
var stiOperand = OperandFactory.CreateFPURegisterOperand(stIndex); var stiOperand = OperandFactory.CreateFPURegisterOperand(stIndex);

View File

@ -3,15 +3,15 @@ namespace X86Disassembler.X86.Handlers.FloatingPoint.Arithmetic;
using X86Disassembler.X86.Operands; using X86Disassembler.X86.Operands;
/// <summary> /// <summary>
/// Handler for FDIVRP ST(i), ST instruction (DE F8-FF) /// Handler for FDIVP ST(i), ST instruction (DE F0-F7)
/// </summary> /// </summary>
public class FdivrpStiStHandler : InstructionHandler public class FdivpStiStHandler_FDIVRPStiSt : InstructionHandler
{ {
/// <summary> /// <summary>
/// Initializes a new instance of the FdivrpStiStHandler class /// Initializes a new instance of the FdivpStiStHandler class
/// </summary> /// </summary>
/// <param name="decoder">The instruction decoder that owns this handler</param> /// <param name="decoder">The instruction decoder that owns this handler</param>
public FdivrpStiStHandler(InstructionDecoder decoder) public FdivpStiStHandler_FDIVRPStiSt(InstructionDecoder decoder)
: base(decoder) : base(decoder)
{ {
} }
@ -23,7 +23,7 @@ public class FdivrpStiStHandler : InstructionHandler
/// <returns>True if this handler can decode the opcode</returns> /// <returns>True if this handler can decode the opcode</returns>
public override bool CanHandle(byte 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 (opcode != 0xDE) return false;
if (!Decoder.CanReadByte()) if (!Decoder.CanReadByte())
@ -34,12 +34,12 @@ public class FdivrpStiStHandler : InstructionHandler
// Check second opcode byte // Check second opcode byte
byte secondOpcode = Decoder.PeakByte(); byte secondOpcode = Decoder.PeakByte();
// Only handle F8-FF // Only handle F0-F7
return secondOpcode is >= 0xF8 and <= 0xFF; return secondOpcode is >= 0xF0 and <= 0xF7;
} }
/// <summary> /// <summary>
/// Decodes a FDIVRP ST(i), ST instruction /// Decodes a FDIVP ST(i), ST instruction
/// </summary> /// </summary>
/// <param name="opcode">The opcode of the instruction</param> /// <param name="opcode">The opcode of the instruction</param>
/// <param name="instruction">The instruction object to populate</param> /// <param name="instruction">The instruction object to populate</param>
@ -52,10 +52,10 @@ public class FdivrpStiStHandler : InstructionHandler
} }
// Read the ModR/M byte and calculate ST(i) index // 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 // Set the instruction type
instruction.Type = InstructionType.Fdivrp; instruction.Type = InstructionType.Fdivp;
// Create the FPU register operands // Create the FPU register operands
var stiOperand = OperandFactory.CreateFPURegisterOperand(stIndex); var stiOperand = OperandFactory.CreateFPURegisterOperand(stIndex);

View File

@ -29,6 +29,7 @@ using X86Disassembler.X86.Handlers.Sub;
using X86Disassembler.X86.Handlers.Test; using X86Disassembler.X86.Handlers.Test;
using X86Disassembler.X86.Handlers.Xchg; using X86Disassembler.X86.Handlers.Xchg;
using X86Disassembler.X86.Handlers.Xor; using X86Disassembler.X86.Handlers.Xor;
using X86Disassembler.X86.Handlers.Flags;
namespace X86Disassembler.X86.Handlers; namespace X86Disassembler.X86.Handlers;
@ -93,6 +94,7 @@ public class InstructionHandlerFactory
RegisterBitHandlers(); // Register bit manipulation handlers RegisterBitHandlers(); // Register bit manipulation handlers
RegisterMiscHandlers(); // Register miscellaneous instructions RegisterMiscHandlers(); // Register miscellaneous instructions
RegisterShiftHandlers(); // Register shift and rotate instructions RegisterShiftHandlers(); // Register shift and rotate instructions
RegisterFlagHandlers(); // Register flag manipulation instructions
} }
/// <summary> /// <summary>
@ -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.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.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.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)); // 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.FdivStiStHandler(_decoder)); // FDIVR ST(i), ST (DC F8-FF)
_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)
// DD opcode handlers (register operations) // 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.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.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.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)); // 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.FdivpStiStHandler(_decoder)); // FDIVRP ST(i), ST (DE F8-FF)
// DF opcode handlers (memory operations) // DF opcode handlers (memory operations)
_handlers.Add(new FloatingPoint.LoadStore.FildInt16Handler(_decoder)); // FILD int16 (DF /0) _handlers.Add(new FloatingPoint.LoadStore.FildInt16Handler(_decoder)); // FILD int16 (DF /0)
@ -656,7 +658,7 @@ public class InstructionHandlerFactory
} }
/// <summary> /// <summary>
/// Registers all shift and rotate instruction handlers /// Registers all Shift instruction handlers
/// </summary> /// </summary>
private void RegisterShiftHandlers() private void RegisterShiftHandlers()
{ {
@ -716,6 +718,23 @@ public class InstructionHandlerFactory
_handlers.Add(new RcrRm32ByClHandler(_decoder)); // RCR r/m32, CL (0xD3 /3) _handlers.Add(new RcrRm32ByClHandler(_decoder)); // RCR r/m32, CL (0xD3 /3)
_handlers.Add(new RcrRm32ByImmHandler(_decoder)); // RCR r/m32, imm8 (0xC1 /3) _handlers.Add(new RcrRm32ByImmHandler(_decoder)); // RCR r/m32, imm8 (0xC1 /3)
} }
/// <summary>
/// Registers all Flag manipulation instruction handlers
/// </summary>
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
}
/// <summary> /// <summary>
/// Registers all bit manipulation instruction handlers /// Registers all bit manipulation instruction handlers