summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibX86
diff options
context:
space:
mode:
authorSimon Wanner <skyrising@pvpctutorials.de>2022-03-27 19:40:52 +0200
committerAndreas Kling <kling@serenityos.org>2022-11-26 12:50:38 +0100
commit4041ea835ce67c81c5eca15d2d0a2878b179ed59 (patch)
tree29afec0e9a92b852bdd0f68c1eafd303d71b3ec2 /Userland/Libraries/LibX86
parentbf768ed215101579a1f8fd311e8210cd9a18c76d (diff)
downloadserenity-4041ea835ce67c81c5eca15d2d0a2878b179ed59.zip
LibX86: Add OP_regW_immW
This is a variation of OP_reg32_imm32 that turns into "OP_reg64_imm64" with a REX.W prefix.
Diffstat (limited to 'Userland/Libraries/LibX86')
-rw-r--r--Userland/Libraries/LibX86/Instruction.cpp30
-rw-r--r--Userland/Libraries/LibX86/Instruction.h2
2 files changed, 25 insertions, 7 deletions
diff --git a/Userland/Libraries/LibX86/Instruction.cpp b/Userland/Libraries/LibX86/Instruction.cpp
index e6d777446d..f0a5e4bd16 100644
--- a/Userland/Libraries/LibX86/Instruction.cpp
+++ b/Userland/Libraries/LibX86/Instruction.cpp
@@ -90,6 +90,9 @@ static void build(InstructionDescriptor* table, u8 op, char const* mnemonic, Ins
case OP_relimm32:
d.imm1_bytes = 4;
break;
+ case OP_regW_immW:
+ d.imm1_bytes = CurrentOperandSize;
+ break;
case OP_imm16_imm8:
d.imm1_bytes = 2;
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_rm64 = [&] { builder.append(m_modrm.to_string_fpu64(*this)); };
auto append_fpu_rm80 = [&] { builder.append(m_modrm.to_string_fpu80(*this)); };
- auto append_imm8 = [&] { builder.appendff("{:#x}", imm8()); };
- auto append_imm8_2 = [&] { builder.appendff("{:#x}", imm8_2()); };
- auto append_imm16 = [&] { builder.appendff("{:#x}", imm16()); };
- auto append_imm16_1 = [&] { builder.appendff("{:#x}", imm16_1()); };
- auto append_imm16_2 = [&] { builder.appendff("{:#x}", imm16_2()); };
- auto append_imm32 = [&] { builder.appendff("{:#x}", imm32()); };
- auto append_imm32_2 = [&] { builder.appendff("{:#x}", imm32_2()); };
+ auto append_imm8 = [&] { builder.appendff("{:#02x}", imm8()); };
+ auto append_imm8_2 = [&] { builder.appendff("{:#02x}", imm8_2()); };
+ auto append_imm16 = [&] { builder.appendff("{:#04x}", imm16()); };
+ auto append_imm16_1 = [&] { builder.appendff("{:#04x}", imm16_1()); };
+ auto append_imm16_2 = [&] { builder.appendff("{:#04x}", imm16_2()); };
+ auto append_imm32 = [&] { builder.appendff("{:#08x}", imm32()); };
+ 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_reg16 = [&] { builder.append(reg16_name()); };
auto append_reg32 = [&] { builder.append(reg32_name()); };
@@ -1929,6 +1939,12 @@ void Instruction::to_string_internal(StringBuilder& builder, u32 origin, SymbolP
append(',');
append_imm32();
break;
+ case OP_regW_immW:
+ append_mnemonic_space();
+ append_reg32();
+ append(", "sv);
+ append_immW();
+ break;
case OP_RM8_1:
append_mnemonic_space();
append_rm8();
diff --git a/Userland/Libraries/LibX86/Instruction.h b/Userland/Libraries/LibX86/Instruction.h
index c8f65cf97e..547a2e6c48 100644
--- a/Userland/Libraries/LibX86/Instruction.h
+++ b/Userland/Libraries/LibX86/Instruction.h
@@ -160,6 +160,7 @@ enum InstructionFormat {
__EndFormatsWithRMByte,
OP_reg32_imm32,
+ OP_regW_immW,
OP_AL_imm8,
OP_AX_imm16,
OP_EAX_imm32,
@@ -210,6 +211,7 @@ enum InstructionFormat {
};
static constexpr unsigned CurrentAddressSize = 0xB33FBABE;
+static constexpr unsigned CurrentOperandSize = 0xB33FB00F;
struct InstructionDescriptor {
InstructionHandler handler { nullptr };