namespace X86Disassembler.X86.Handlers.Group3;
///
/// Base class for Group 3 instruction handlers (TEST, NOT, NEG, MUL, IMUL, DIV, IDIV)
///
public abstract class Group3BaseHandler : InstructionHandler
{
// ModR/M decoder
protected readonly ModRMDecoder _modRMDecoder;
///
/// Initializes a new instance of the Group3BaseHandler class
///
/// The buffer containing the code to decode
/// The instruction decoder that owns this handler
/// The length of the buffer
protected Group3BaseHandler(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];
}
}