namespace X86Disassembler.X86.Handlers.Inc; /// /// Handler for INC r32 instructions (0x40-0x47) /// public class IncRegHandler : InstructionHandler { /// /// Initializes a new instance of the IncRegHandler class /// /// The buffer containing the code to decode /// The instruction decoder that owns this handler /// The length of the buffer public IncRegHandler(byte[] codeBuffer, InstructionDecoder decoder, int length) : base(codeBuffer, decoder, length) { } /// /// 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 return opcode >= 0x40 && opcode <= 0x47; } /// /// 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 mnemonic instruction.Mnemonic = "inc"; // Set the operand (register name) instruction.Operands = ModRMDecoder.GetRegisterName(reg, 32); return true; } }