using X86Disassembler.X86.Operands; namespace X86Disassembler.X86.Handlers.Sub; /// /// Handler for SUB AL, imm8 instruction (0x2C) /// public class SubAlImm8Handler : InstructionHandler { /// /// Initializes a new instance of the SubAlImm8Handler class /// /// The instruction decoder that owns this handler public SubAlImm8Handler(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 == 0x2C; } /// /// Decodes a SUB AL, imm8 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) { if (!Decoder.CanReadByte()) { return false; } // Read the immediate byte byte imm8 = Decoder.ReadByte(); // Set the instruction type instruction.Type = InstructionType.Sub; // Create the destination register operand (AL) var destinationOperand = OperandFactory.CreateRegisterOperand8(RegisterIndex8.AL); // Create the source immediate operand var sourceOperand = OperandFactory.CreateImmediateOperand(imm8, 8); // Set the structured operands instruction.StructuredOperands = [ destinationOperand, sourceOperand ]; return true; } }