ASM x64 中 40h REX 操作码的目的是什么? [英] What is the purpose of the 40h REX opcode in ASM x64?

查看:28
本文介绍了ASM x64 中 40h REX 操作码的目的是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试了解用于 ASM x64 指令的 0x40 REX 操作码的用途.例如,在 Kernel32.dll 的这个函数序言中:

如你所见,他们使用 push rbx 作为:

40 53 push rbx

但仅使用 53h 操作码(不带前缀)也会产生相同的结果:

根据

所以 40h 操作码似乎没有做任何事情.有人能解释一下它的用途吗?

解决方案

04xh 字节(即 040h, 041h... 04fh) 确实是 REX 字节.正如您在问题中列出的那样,下半字节中的每一位都有一个含义.040h 表示 REX.WREX.RREX.XREX.B 都是0.这意味着添加这个字节不会对这条指令做任何事情,因为你没有覆盖任何默认的 REX 位,而且它不是一个 AH/BH/CH/DH 作为的 8 位指令一个操作数.

此外,XRB位都对应一些操作数.如果您的指令不消耗这些操作数,则相应的 REX 位将被忽略.

I've been trying to understand the purpose of the 0x40 REX opcode for ASM x64 instructions. Like for instance, in this function prologue from Kernel32.dll:

As you see they use push rbx as:

40 53      push        rbx 

But using just the 53h opcode (without the prefix) also produces the same result:

According to this site, the layout for the REX prefix is as follows:

So 40h opcode seems to be not doing anything. Can someone explain its purpose?

解决方案

the 04xh bytes (i.e. 040h, 041h... 04fh) are indeed REX bytes. Each bit in the lower nibble has a meaning, as you listed in your question. The value 040h means that REX.W, REX.R, REX.X and REX.B are all 0. That means that adding this byte doesn't do anything to this instruction, because you're not overriding any default REX bits, and it's not an 8-bit instruction with AH/BH/CH/DH as an operand.

Moreover, the X, R and B bits all correspond to some operands. If your instruction doesn't consume these operands, then the corresponding REX bit is ignored.

这篇关于ASM x64 中 40h REX 操作码的目的是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆