From 1d68c64b9831e55bd534b0be7a92940ee3314715 Mon Sep 17 00:00:00 2001 From: Simon Wanner Date: Mon, 23 Oct 2023 18:26:27 +0200 Subject: [PATCH] LibX86: Apply REX.W to B9-BF MOVs All the MOVs in the B8-BF range can use the REX.W prefix, not just B8. Previously instructions like `48 B9... mov rcx, imm64` were interpreted as `mov rcx, imm32` because the REX.W prefix was only applied to `48 B8... mov rax, imm64`. --- Userland/Libraries/LibX86/Instruction.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Userland/Libraries/LibX86/Instruction.cpp b/Userland/Libraries/LibX86/Instruction.cpp index 115bddec88..9daf143080 100644 --- a/Userland/Libraries/LibX86/Instruction.cpp +++ b/Userland/Libraries/LibX86/Instruction.cpp @@ -1236,7 +1236,8 @@ static void build_sse_66_slash(u8 op, u8 slash, char const* mnemonic, Instructio table64[0x9A] = {}; // far CALL table64[0x9C].long_mode_default_64 = true; // PUSHF/D/Q table64[0x9D].long_mode_default_64 = true; // POPF/D/Q - build_in_table(table64, 0xB8, "MOV", OP_regW_immW, &Interpreter::MOV_reg32_imm32, LockPrefixNotAllowed); + for (u8 mov = 0xB8; mov <= 0xBF; ++mov) + build_in_table(table64, mov, "MOV", OP_regW_immW, &Interpreter::MOV_reg32_imm32, LockPrefixNotAllowed); table64[0xC2].long_mode_force_64 = true; // near RET table64[0xC3].long_mode_force_64 = true; // near RET table64[0xC4] = {}; // LES