namespace X86Disassembler.X86.Handlers.Inc; using Operands; /// /// Handler for INC r32 instructions (0x40-0x47) /// public class IncRegHandler : InstructionHandler { /// /// Initializes a new instance of the IncRegHandler class /// /// The instruction decoder that owns this handler public IncRegHandler(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) { // INC EAX = 0x40, INC ECX = 0x41, ..., INC EDI = 0x47 // Only handle when the operand size prefix is NOT present // This ensures 16-bit handlers get priority when the prefix is present return opcode >= 0x40 && opcode <= 0x47 && !Decoder.HasOperandSizePrefix(); } /// /// Decodes an INC r32 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) { // Calculate the register index (0 for EAX, 1 for ECX, etc.) RegisterIndex reg = (RegisterIndex)(byte)(opcode - 0x40); // Set the instruction type instruction.Type = InstructionType.Inc; // Create the register operand var regOperand = OperandFactory.CreateRegisterOperand(reg, 32); // Set the structured operands instruction.StructuredOperands = [ regOperand ]; return true; } }