namespace X86Disassembler.X86.Handlers.Ret; using Operands; /// /// Handler for RET instruction with immediate operand (0xC2) /// public class RetImmHandler : InstructionHandler { /// /// Initializes a new instance of the RetImmHandler class /// /// The instruction decoder that owns this handler public RetImmHandler(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) { return opcode == 0xC2; } /// /// Decodes a RET instruction with immediate operand /// /// 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) { // Set the instruction type instruction.Type = InstructionType.Ret; if (!Decoder.CanReadUShort()) { return false; } // Read the immediate value ushort imm16 = Decoder.ReadUInt16(); // Create the immediate operand var immOperand = OperandFactory.CreateImmediateOperand(imm16, 16); // Set the structured operands instruction.StructuredOperands = [ immOperand ]; return true; } }