namespace X86Disassembler.X86.Handlers.Dec; /// /// Handler for DEC r32 instructions (0x48-0x4F) /// public class DecRegHandler : InstructionHandler { /// /// Initializes a new instance of the DecRegHandler class /// /// The buffer containing the code to decode /// The instruction decoder that owns this handler /// The length of the buffer public DecRegHandler(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) { // 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.) byte reg = (byte)(opcode - 0x48); // Set the mnemonic instruction.Mnemonic = "dec"; // Set the operand (register name) instruction.Operands = GetRegister32(reg); return true; } }