将两个x86 32位寄存器存储到128位xmm寄存器中 [英] Storing two x86 32 bit registers into 128 bit xmm register

查看:110
本文介绍了将两个x86 32位寄存器存储到128位xmm寄存器中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有更快的方法将两个x86 32位寄存器存储在一个128位xmm寄存器中?

Is there any faster method to store two x86 32 bit registers in one 128 bit xmm register?

  movd  xmm0, edx
  movd  xmm1, eax
  pshufd xmm0, xmm0, $1
  por   xmm0, xmm1 

因此,如果EAX为0x12345678,而EDX为0x87654321,则xmm0中的结果必须为0x8765432112345678.

So if EAX is 0x12345678 and EDX is 0x87654321 the result in xmm0 must be 0x8765432112345678.

谢谢

推荐答案

使用SSE 4.1,您可以使用movd xmm0, eax/pinsrd xmm0, edx, 1并按照2条说明进行操作.

With SSE 4.1 you can use movd xmm0, eax / pinsrd xmm0, edx, 1 and do it in 2 instructions.

对于较旧的CPU,您可以使用2 x movd,然后使用punpckldq总共3条指令:

For older CPUs you can use 2 x movd and then punpckldq for a total of 3 instructions:

movd xmm0, edx
movd xmm1, eax
punpckldq xmm0, xmm1

这篇关于将两个x86 32位寄存器存储到128位xmm寄存器中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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