mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 08:27:45 +00:00
LibX86: Add OP_regW_immW
This is a variation of OP_reg32_imm32 that turns into "OP_reg64_imm64" with a REX.W prefix.
This commit is contained in:
parent
bf768ed215
commit
4041ea835c
2 changed files with 25 additions and 7 deletions
|
@ -90,6 +90,9 @@ static void build(InstructionDescriptor* table, u8 op, char const* mnemonic, Ins
|
||||||
case OP_relimm32:
|
case OP_relimm32:
|
||||||
d.imm1_bytes = 4;
|
d.imm1_bytes = 4;
|
||||||
break;
|
break;
|
||||||
|
case OP_regW_immW:
|
||||||
|
d.imm1_bytes = CurrentOperandSize;
|
||||||
|
break;
|
||||||
case OP_imm16_imm8:
|
case OP_imm16_imm8:
|
||||||
d.imm1_bytes = 2;
|
d.imm1_bytes = 2;
|
||||||
d.imm2_bytes = 1;
|
d.imm2_bytes = 1;
|
||||||
|
@ -1666,13 +1669,20 @@ void Instruction::to_string_internal(StringBuilder& builder, u32 origin, SymbolP
|
||||||
auto append_fpu_rm32 = [&] { builder.append(m_modrm.to_string_fpu32(*this)); };
|
auto append_fpu_rm32 = [&] { builder.append(m_modrm.to_string_fpu32(*this)); };
|
||||||
auto append_fpu_rm64 = [&] { builder.append(m_modrm.to_string_fpu64(*this)); };
|
auto append_fpu_rm64 = [&] { builder.append(m_modrm.to_string_fpu64(*this)); };
|
||||||
auto append_fpu_rm80 = [&] { builder.append(m_modrm.to_string_fpu80(*this)); };
|
auto append_fpu_rm80 = [&] { builder.append(m_modrm.to_string_fpu80(*this)); };
|
||||||
auto append_imm8 = [&] { builder.appendff("{:#x}", imm8()); };
|
auto append_imm8 = [&] { builder.appendff("{:#02x}", imm8()); };
|
||||||
auto append_imm8_2 = [&] { builder.appendff("{:#x}", imm8_2()); };
|
auto append_imm8_2 = [&] { builder.appendff("{:#02x}", imm8_2()); };
|
||||||
auto append_imm16 = [&] { builder.appendff("{:#x}", imm16()); };
|
auto append_imm16 = [&] { builder.appendff("{:#04x}", imm16()); };
|
||||||
auto append_imm16_1 = [&] { builder.appendff("{:#x}", imm16_1()); };
|
auto append_imm16_1 = [&] { builder.appendff("{:#04x}", imm16_1()); };
|
||||||
auto append_imm16_2 = [&] { builder.appendff("{:#x}", imm16_2()); };
|
auto append_imm16_2 = [&] { builder.appendff("{:#04x}", imm16_2()); };
|
||||||
auto append_imm32 = [&] { builder.appendff("{:#x}", imm32()); };
|
auto append_imm32 = [&] { builder.appendff("{:#08x}", imm32()); };
|
||||||
auto append_imm32_2 = [&] { builder.appendff("{:#x}", imm32_2()); };
|
auto append_imm32_2 = [&] { builder.appendff("{:#08x}", imm32_2()); };
|
||||||
|
auto append_imm64 = [&] { builder.appendff("{:#016x}", imm64()); };
|
||||||
|
auto append_immW = [&] {
|
||||||
|
if (m_operand_size == OperandSize::Size64)
|
||||||
|
append_imm64();
|
||||||
|
else
|
||||||
|
append_imm32();
|
||||||
|
};
|
||||||
auto append_reg8 = [&] { builder.append(reg8_name()); };
|
auto append_reg8 = [&] { builder.append(reg8_name()); };
|
||||||
auto append_reg16 = [&] { builder.append(reg16_name()); };
|
auto append_reg16 = [&] { builder.append(reg16_name()); };
|
||||||
auto append_reg32 = [&] { builder.append(reg32_name()); };
|
auto append_reg32 = [&] { builder.append(reg32_name()); };
|
||||||
|
@ -1929,6 +1939,12 @@ void Instruction::to_string_internal(StringBuilder& builder, u32 origin, SymbolP
|
||||||
append(',');
|
append(',');
|
||||||
append_imm32();
|
append_imm32();
|
||||||
break;
|
break;
|
||||||
|
case OP_regW_immW:
|
||||||
|
append_mnemonic_space();
|
||||||
|
append_reg32();
|
||||||
|
append(", "sv);
|
||||||
|
append_immW();
|
||||||
|
break;
|
||||||
case OP_RM8_1:
|
case OP_RM8_1:
|
||||||
append_mnemonic_space();
|
append_mnemonic_space();
|
||||||
append_rm8();
|
append_rm8();
|
||||||
|
|
|
@ -160,6 +160,7 @@ enum InstructionFormat {
|
||||||
__EndFormatsWithRMByte,
|
__EndFormatsWithRMByte,
|
||||||
|
|
||||||
OP_reg32_imm32,
|
OP_reg32_imm32,
|
||||||
|
OP_regW_immW,
|
||||||
OP_AL_imm8,
|
OP_AL_imm8,
|
||||||
OP_AX_imm16,
|
OP_AX_imm16,
|
||||||
OP_EAX_imm32,
|
OP_EAX_imm32,
|
||||||
|
@ -210,6 +211,7 @@ enum InstructionFormat {
|
||||||
};
|
};
|
||||||
|
|
||||||
static constexpr unsigned CurrentAddressSize = 0xB33FBABE;
|
static constexpr unsigned CurrentAddressSize = 0xB33FBABE;
|
||||||
|
static constexpr unsigned CurrentOperandSize = 0xB33FB00F;
|
||||||
|
|
||||||
struct InstructionDescriptor {
|
struct InstructionDescriptor {
|
||||||
InstructionHandler handler { nullptr };
|
InstructionHandler handler { nullptr };
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue