mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-25 17:10:23 +00:00
LibX86: Simplify "register index to string" functions a bit
This commit is contained in:
parent
57b2b96a67
commit
a75af443d4
Notes:
sideshowbarker
2024-07-19 06:59:44 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/a75af443d4a
1 changed files with 10 additions and 101 deletions
|
@ -1770,123 +1770,32 @@ String Instruction::mnemonic() const
|
||||||
|
|
||||||
const char* register_name(SegmentRegister index)
|
const char* register_name(SegmentRegister index)
|
||||||
{
|
{
|
||||||
switch (index) {
|
static constexpr const char* names[] = { "es", "cs", "ss", "ds", "fs", "gs", "segr6", "segr7" };
|
||||||
case SegmentRegister::CS:
|
return names[(int)index & 7];
|
||||||
return "cs";
|
|
||||||
case SegmentRegister::DS:
|
|
||||||
return "ds";
|
|
||||||
case SegmentRegister::ES:
|
|
||||||
return "es";
|
|
||||||
case SegmentRegister::SS:
|
|
||||||
return "ss";
|
|
||||||
case SegmentRegister::FS:
|
|
||||||
return "fs";
|
|
||||||
case SegmentRegister::GS:
|
|
||||||
return "gs";
|
|
||||||
case SegmentRegister::SegR6:
|
|
||||||
return "segr6";
|
|
||||||
case SegmentRegister::SegR7:
|
|
||||||
return "segr7";
|
|
||||||
default:
|
|
||||||
ASSERT_NOT_REACHED();
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* register_name(RegisterIndex8 register_index)
|
const char* register_name(RegisterIndex8 register_index)
|
||||||
{
|
{
|
||||||
switch (register_index) {
|
static constexpr const char* names[] = { "al", "cl", "dl", "bl", "ah", "ch", "dh", "bh" };
|
||||||
case RegisterAL:
|
return names[register_index & 7];
|
||||||
return "al";
|
|
||||||
case RegisterBL:
|
|
||||||
return "bl";
|
|
||||||
case RegisterCL:
|
|
||||||
return "cl";
|
|
||||||
case RegisterDL:
|
|
||||||
return "dl";
|
|
||||||
case RegisterAH:
|
|
||||||
return "ah";
|
|
||||||
case RegisterBH:
|
|
||||||
return "bh";
|
|
||||||
case RegisterCH:
|
|
||||||
return "ch";
|
|
||||||
case RegisterDH:
|
|
||||||
return "dh";
|
|
||||||
}
|
|
||||||
ASSERT_NOT_REACHED();
|
|
||||||
return nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* register_name(RegisterIndex16 register_index)
|
const char* register_name(RegisterIndex16 register_index)
|
||||||
{
|
{
|
||||||
switch (register_index) {
|
static constexpr const char* names[] = { "ax", "cx", "dx", "bx", "sp", "bp", "si", "di" };
|
||||||
case RegisterAX:
|
return names[register_index & 7];
|
||||||
return "ax";
|
|
||||||
case RegisterBX:
|
|
||||||
return "bx";
|
|
||||||
case RegisterCX:
|
|
||||||
return "cx";
|
|
||||||
case RegisterDX:
|
|
||||||
return "dx";
|
|
||||||
case RegisterBP:
|
|
||||||
return "bp";
|
|
||||||
case RegisterSP:
|
|
||||||
return "sp";
|
|
||||||
case RegisterSI:
|
|
||||||
return "si";
|
|
||||||
case RegisterDI:
|
|
||||||
return "di";
|
|
||||||
}
|
|
||||||
ASSERT_NOT_REACHED();
|
|
||||||
return nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* register_name(RegisterIndex32 register_index)
|
const char* register_name(RegisterIndex32 register_index)
|
||||||
{
|
{
|
||||||
switch (register_index) {
|
static constexpr const char* names[] = { "eax", "ecx", "edx", "ebx", "esp", "ebp", "esi", "edi" };
|
||||||
case RegisterEAX:
|
return names[register_index & 7];
|
||||||
return "eax";
|
|
||||||
case RegisterEBX:
|
|
||||||
return "ebx";
|
|
||||||
case RegisterECX:
|
|
||||||
return "ecx";
|
|
||||||
case RegisterEDX:
|
|
||||||
return "edx";
|
|
||||||
case RegisterEBP:
|
|
||||||
return "ebp";
|
|
||||||
case RegisterESP:
|
|
||||||
return "esp";
|
|
||||||
case RegisterESI:
|
|
||||||
return "esi";
|
|
||||||
case RegisterEDI:
|
|
||||||
return "edi";
|
|
||||||
}
|
|
||||||
ASSERT_NOT_REACHED();
|
|
||||||
return nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* register_name(MMXRegisterIndex register_index)
|
const char* register_name(MMXRegisterIndex register_index)
|
||||||
{
|
{
|
||||||
switch (register_index) {
|
static constexpr const char* names[] = { "mm0", "mm1", "mm2", "mm3", "mm4", "mm5", "mm6", "mm7" };
|
||||||
case RegisterMM0:
|
return names[register_index & 7];
|
||||||
return "mm0";
|
|
||||||
case RegisterMM1:
|
|
||||||
return "mm1";
|
|
||||||
case RegisterMM2:
|
|
||||||
return "mm2";
|
|
||||||
case RegisterMM3:
|
|
||||||
return "mm3";
|
|
||||||
case RegisterMM4:
|
|
||||||
return "mm4";
|
|
||||||
case RegisterMM5:
|
|
||||||
return "mm5";
|
|
||||||
case RegisterMM6:
|
|
||||||
return "mm6";
|
|
||||||
case RegisterMM7:
|
|
||||||
return "mm7";
|
|
||||||
}
|
|
||||||
ASSERT_NOT_REACHED();
|
|
||||||
return nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MemoryOrRegisterReference::decode(InstructionStream& stream, bool a32)
|
void MemoryOrRegisterReference::decode(InstructionStream& stream, bool a32)
|
||||||
|
|
Loading…
Reference in a new issue