In the previous chapter, we used floating-point values and instructions. SSE also provides a long list of instructions for manipulating integers, and just as in the previous chapter, we are going to show a couple of instructions to get you going.
Here again we have two vectors, this time with integer values. We use the instruction movdqa to copy values into an xmm register. This instruction is for use with aligned data. Then paddd adds the values in the registers together and puts the result in xmm0. To use printf, we need to extract the integer values from the xmm registers and put them in the “regular” registers. Remember from the calling conventions that printf considers an xmm register to be a floating register. If we do not extract the integer values, printf will consider the values in an xmm register to be floating-point values and print the wrong values. For extracting and inserting packed integers, we use pinsrd and pextrd. We also reverse a vector to show how to insert values into a vector in an xmm register.
There are versions of movd, padd, pinsr, and pextr for bytes, words, double words, and quadwords, respectively.