How do you move 128-bit values between XMM registe

2019-04-28 11:00发布

问题:

Seemingly trivial problem in assembly: I want to copy the whole XMM0 register to XMM3. I've tried

movdq xmm3, xmm0

but MOVDQ cannot be used to move values between two XMM registers. What should I do instead?

回答1:

It's movapd, movaps, or movdqa

movaps xmm3, xmm0

They all do the same thing, but there's a catch:

  • movapd and movaps operate in the floating-point domain.
  • movdqa operates in the integer domain

Use the appropriate one according to your datatype to avoid domain-changing stalls.

Also, there's no reason to use movapd. Always use movaps instead because movapd takes an extra byte to encode.