x86 BSWAP instruction REX doesn't follow Intel specs?

风格不统一 提交于 2021-02-20 06:27:43

问题


I've been assembling (and disassembling) the BSWAP x64 instruction with both NASM and GAS, and both assemble the instruction BSWAP r15 as 490FCF in hex. Disassemblers also disassemble this to the same instruction.

The REX prefix for the instruction (49) thus has the REX.W bit (bit 3) and the REX.B bit (bit 0) set. This is directly in contrast to the Intel documentation, which states:

In 64-bit mode, the instruction’s default operation size is 32 bits. Using a REX prefix in the form of REX.R permits access to additional registers (R8-R15). Using a REX prefix in the form of REX.W promotes operation to 64 bits.

(Emphasis mine)

So according to the documentation, the REX.W bit and the REX.R bit (bit 2) should be set, not REX.B, giving the encoding 4C0FCF.

My question is, who is correct? The assemblers or Intel?


回答1:


The manual is wrong there. See the description of the REX prefix in section 2.2.1.2 More on REX Prefix Fields instead which says:

REX.B either modifies the base in the ModR/M r/m field or SIB base field; or it modifies the opcode reg field used for accessing GPRs.

and Figure 2-7. Register Operand Coded in Opcode Byte; REX.X & REX.R Not Used which looks like:

The BSWAP uses an opcode reg field.



来源:https://stackoverflow.com/questions/53484556/x86-bswap-instruction-rex-doesnt-follow-intel-specs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!