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

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

问题描述

我一直试图理解 0x40 REX操作码用于ASM x64指令的目的。例如,在此函数的序言中,来自Kernel32.dll:





如您所见,他们将 push rbx 用作:

  40 53 push rbx 

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





根据



所以 40h 操作码似乎什么也没做。有人可以解释其目的吗?

解决方案

04xh 字节(即 040h 041h ... 04fh )确实是REX字节。正如您在问题中列出的那样,下半字节的每一位都有含义。值 040h 表示 REX.W REX.R REX.X REX.B 0 。这意味着添加此字节不会对该指令产生任何作用,因为您不会覆盖任何默认REX位,而且它不是AH / BH / CH / DH为8位指令



此外, X R B 位都对应于某些操作数。如果您的指令不使用这些操作数,则相应的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天全站免登陆