如何将两个32位寄存器移至一个64位寄存器?
假设我想将两个 32 位寄存器 EAX
作为低 32 位字,将 EDX
作为高 32 位字放入 RAX
中。 我找到了一种方法:
shl rdx, 32
or rax, rdx
只有当我们确定RAX的32到61位为0时,此方法才有效。如果我们不确定这一点,那么我们必须首先清除高32位字,比如:
mov eax, eax //This instruction should clear the high 32 bit word of RAX
这是最短路线吗?
是否有单个 asm x86-64 指令执行此操作?
Let's say that I want to put two 32 bit registers EAX
as low 32 bit word and EDX
as high 32 bit word into RAX
.
I have found one way:
shl rdx, 32
or rax, rdx
This method works only if we are sure that bits from 32 to 61 of RAX
are 0. If we are not sure about that, then we must first clear the high 32 bit word, like:
mov eax, eax //This instruction should clear the high 32 bit word of RAX
Is this the shortest way?
Is there a single asm x86-64 instruction that does this operation?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
也许这更好一点:
不假设高双字为零。
Perhaps this is a tad better:
Does not assume that high dwords are zero.