如何强制 GNU 汇编器发出 `rex.W` 前缀?

问题描述 投票:0回答:1

编写内联汇编时,有没有办法强制使用 rex.W 前缀?

所以而不是

"psllq $12, %%xmm1\n"

生成

66 0f 73 f1 0c
,我想要
66 48 0f 73 f1 0c
,带有额外的 0x48 rex.W 前缀。

assembly x86-64
1个回答
0
投票

您只需添加

rex.W
前缀即可:

rex.W psllq $12, %xmm1

这正是 GNU binutils 反汇编您给出的操作码字节的方式。 来自包含内容的文件 psllq.s

.byte 0x66, 0x48, 0x0f, 0x73, 0xf1, 0x0c

我们可以运行

as psllq.s -o psllq.o && objdump -d psllq.o
来获得:


psllq.o:     file format elf64-x86-64


Disassembly of section .text:

0000000000000000 <.text>:
   0:   66 48 0f 73 f1 0c       rex.W psllq $0xc,%xmm1
© www.soinside.com 2019 - 2024. All rights reserved.