mirror of
https://github.com/sampletext32/ParkanPlayground.git
synced 2025-06-20 08:18:36 +03:00
Added flag manipulation instruction handlers (STC, CLC, CMC, STD, CLD, STI, CLI, SAHF, LAHF)
This commit is contained in:
44
X86Disassembler/X86/Handlers/Flags/ClcHandler.cs
Normal file
44
X86Disassembler/X86/Handlers/Flags/ClcHandler.cs
Normal 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;
|
||||
}
|
||||
}
|
44
X86Disassembler/X86/Handlers/Flags/CldHandler.cs
Normal file
44
X86Disassembler/X86/Handlers/Flags/CldHandler.cs
Normal 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;
|
||||
}
|
||||
}
|
44
X86Disassembler/X86/Handlers/Flags/CliHandler.cs
Normal file
44
X86Disassembler/X86/Handlers/Flags/CliHandler.cs
Normal 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;
|
||||
}
|
||||
}
|
44
X86Disassembler/X86/Handlers/Flags/CmcHandler.cs
Normal file
44
X86Disassembler/X86/Handlers/Flags/CmcHandler.cs
Normal 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;
|
||||
}
|
||||
}
|
44
X86Disassembler/X86/Handlers/Flags/LahfHandler.cs
Normal file
44
X86Disassembler/X86/Handlers/Flags/LahfHandler.cs
Normal 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;
|
||||
}
|
||||
}
|
44
X86Disassembler/X86/Handlers/Flags/SahfHandler.cs
Normal file
44
X86Disassembler/X86/Handlers/Flags/SahfHandler.cs
Normal 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;
|
||||
}
|
||||
}
|
44
X86Disassembler/X86/Handlers/Flags/StcHandler.cs
Normal file
44
X86Disassembler/X86/Handlers/Flags/StcHandler.cs
Normal 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;
|
||||
}
|
||||
}
|
44
X86Disassembler/X86/Handlers/Flags/StdHandler.cs
Normal file
44
X86Disassembler/X86/Handlers/Flags/StdHandler.cs
Normal 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;
|
||||
}
|
||||
}
|
44
X86Disassembler/X86/Handlers/Flags/StiHandler.cs
Normal file
44
X86Disassembler/X86/Handlers/Flags/StiHandler.cs
Normal 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;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user