Question

I need to calculate the sum of the 4 integers I have inside a MMX register. For example, I have this MMX register: enter image description here And I want to get this result (I don't mind if it's in the same register or if it's in a normal one): enter image description here

I want to know if there is an instruction that performs that operation. I'm using x86 assembly in windows. My first guess is to put 4 1 in another MMX register and call PMADDWD so that I end up with [X1+X2][X3+X4] but I think that's quite dirty.

Thanks in advance.

Was it helpful?

Solution

PMADDWD is actually quite a good way of summing - even though you are "wasting" a multiply operation by using a multiplicand of 1, you get the widening (unpacking) operation for free, so you're getting quite a lot of value out of a single instruction.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top