Jump to content
  • Advertisement
Sign in to follow this  
squicklid

MMX multiply

This topic is 4803 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I see that there are two mmx instructions to do a multiplication. PMULLW and PMULHW. If my analysis is correct, these will multiply the operands, and return ONLY the high word or low word? What if I want to multiply the whole 64 bits of a register?

Share this post


Link to post
Share on other sites
Advertisement
MMX only provides 16-bit multiplications with 16 or 32 bit results.
A full 64x64 to 128-bit multiplication would have to be emulated by multiplying the parts and adding them togheter. Only having signed multiplications to work with would make it tedious and almost certainly horribly slow too.

Using the basic insturction set would be a lot easier and faster, or you could get the FPU to do it for you (though not even the FPU interacts with 64-bit integers comfortably).

Perhaps there's some SSE2 instruction to load 64-bit integers. You'd loose a bit of precision but it might be enough anyway.

Share this post


Link to post
Share on other sites
either use PMULUDQ and xmm

or you can use
(a*2^n + b)*(c*2^n + d) = a*c*2^2n + (a*d+b*c)*2^n + c*d

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!