namespace X86Disassembler.X86.Handlers.Dec; using Operands; /// /// Handler for DEC r32 instructions (0x48-0x4F) /// public class DecRegHandler : InstructionHandler { /// /// Initializes a new instance of the DecRegHandler class /// /// The instruction decoder that owns this handler public DecRegHandler(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) { // DEC EAX = 0x48, DEC ECX = 0x49, ..., DEC EDI = 0x4F return opcode >= 0x48 && opcode <= 0x4F; } /// /// Decodes a DEC 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)(opcode - 0x48); // Set the instruction type instruction.Type = InstructionType.Dec; // Create the register operand var regOperand = OperandFactory.CreateRegisterOperand(reg, 32); // Set the structured operands instruction.StructuredOperands = [ regOperand ]; return true; } }