namespace X86Disassembler.X86.Handlers.Group1;
///
/// Base class for Group 1 instruction handlers (ADD, OR, ADC, SBB, AND, SUB, XOR, CMP)
///
public abstract class Group1BaseHandler : InstructionHandler
{
// ModR/M decoder
protected readonly ModRMDecoder _modRMDecoder;
///
/// Initializes a new instance of the Group1BaseHandler class
///
/// The buffer containing the code to decode
/// The instruction decoder that owns this handler
/// The length of the buffer
protected Group1BaseHandler(byte[] codeBuffer, InstructionDecoder decoder, int length)
: base(codeBuffer, decoder, length)
{
_modRMDecoder = new ModRMDecoder(codeBuffer, decoder, length);
}
///
/// Gets the 32-bit register name for the given register index
///
/// The register index
/// The register name
protected static string GetRegister32(byte reg)
{
string[] registerNames = { "eax", "ecx", "edx", "ebx", "esp", "ebp", "esi", "edi" };
return registerNames[reg & 0x07];
}
///
/// Gets the 8-bit register name for the given register index
///
/// The register index
/// The register name
protected static string GetRegister8(byte reg)
{
string[] registerNames = { "al", "cl", "dl", "bl", "ah", "ch", "dh", "bh" };
return registerNames[reg & 0x07];
}
}