[英]How to move two 32 bit registers in to one 64 bit?
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
. 假设我想将两个32位寄存器EAX
作为低32位字,将EDX
作为高32位字放入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: 只有当我们确定RAX
32到61位为0时,此方法才有效。如果我们不确定,那么我们必须首先清除高32位字,如:
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? 是否有一个asm x86-64指令执行此操作?
Perhaps this is a tad better: 也许这有点好一点:
shl rax,32
shrd rax,rdx,32
Does not assume that high dwords are zero. 不假设高双字为零。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.