X86:`movsxd rdx,edx`指令是什么意思? [英] X86: What does `movsxd rdx,edx` instruction mean?

查看:742
本文介绍了X86:`movsxd rdx,edx`指令是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在使用intel mpx,发现它添加了某些我无法理解的说明.例如(以英特尔格式):

I have been playing with intel mpx and found that it adds certain instructions that I could not understand. For e.g. (in intel format):

movsxd rdx,edx

我发现了,其中谈到了类似的指令-.

I found this, which talks about a similar instruction - MOVSX.

从这个问题出发,我对该指令的解释是,它占用了双字节(这就是movsxd中有一个d的原因)并将其复制到rdx寄存器中(两个最低有效字节)并且用该双字节的符号填充其余部分.

From that question, my interpretation of this instruction is that, it takes double byte (that's why there is a d in movsxd) and it copies it into rdx register (in two least significant bytes) and fills the rest with the sign of that double byte.

我的解释正确吗(我认为我错了)?如果不能,请告诉我发生了什么事?

Is my interpretation correct (I think I'm wrong)? If not can you please tell me what is going on?

推荐答案

您的代码是64位.如果您查看 MOVSXD 的指令集体系结构(ISA)手册,那64 -bit变体定义为:

Your code is 64-bit. If you look at the instruction set architecture (ISA) manual for MOVSXD, the 64-bit variant is defined as:

 MOVSXD r64, r/m32       Move doubleword to quadword with sign-extension.

这是64位代码的指令,该指令将32位寄存器或地址转换为32位值,并将其符号扩展为64位寄存器.符号扩展是获取源的最高位(符号位)的值,并使用它来填充目标的所有高位.

This is the instruction in 64-bit code that takes a 32-bit register or an address to a 32-bit value and moves it sign extended into a 64-bit register. Sign extension is taking the value of the top most bit (sign bit) of the source and using it to fill in all the upper bits of the destination.

movsxd rdx,edx查看 EDX 的第31位(最高位),并将目标的高32位设置为该值,并按原样复制低32位.如果在 EDX 中设置了符号位,则64位寄存器的高32位将被设置为1.如果清除了符号位,则 RDX 的高32位将被设置为1.将为0.

movsxd rdx,edx takes a look at bit 31 (top most bit) of EDX and sets the upper 32 bits of the destination to that value and copies the lower 32 bits as is. If the sign bit is set in EDX the upper 32 bits of the 64-bit register will be set to 1. If the sign bit is clear the upper 32 bits of RDX will be 0.

作为示例,假设 EDX 的值为0x80000000.位31为1.作为带符号的数字-2147483648.如果执行movsxd RDX, EDX,则 RDX 中的值将为0xFFFFFFFF80000000.作为仍代表-2147483648的带符号的64位值.

As an example, assume EDX has the value 0x80000000. Bit 31 is 1. As a signed number that is -2147483648. If you do movsxd RDX, EDX the value in RDX will be 0xFFFFFFFF80000000 . As a signed 64-bit value that still represents -2147483648.

如果 EDX 0x7fffffff(有符号值+2147483647)且位31为0,则 RDX 中的值将是0x000000007fffffff,仍然表示签名的数字+2147483647.如您所见,符号扩展会在更宽的寄存器的高位上保留符号位,以便保留目标的签名.

If EDX had been 0x7fffffff (signed value +2147483647) with bit 31 being 0, the value in RDX would have been 0x000000007fffffff which still represents the signed number +2147483647. As you can see sign extension preserves the sign bit across the upper bits of a wider register so that the signedness of the destination is preserved.

这篇关于X86:`movsxd rdx,edx`指令是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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