Intel ARCHITECTURE IA-32 User Manual Page 243

  • Download
  • Add to my manuals
  • Print
  • Page
    / 568
  • Table of contents
  • BOOKMARKS
  • Rated. / 5. Based on customer reviews
Page view 242
Optimizing for SIMD Integer Applications 4
4-23
Building Blocks
This section describes instructions and algorithms which implement
common code building blocks efficiently.
Absolute Difference of Unsigned Numbers
Example 4-16 computes the absolute difference of two unsigned
numbers. It assumes an unsigned packed-byte data type. Here, we make
use of the subtract instruction with unsigned saturation. This instruction
receives
UNSIGNED operands and subtracts them with UNSIGNED
saturation. This support exists only for packed bytes and packed words,
not for packed doublewords.
This example will not work if the operands are signed.
Note that the
psadbw instruction may also be used in some situations;
see section “Packed Sum of Absolute Differences” for details.
Example 4-16 Absolute Difference of Two Unsigned Numbers
; Input:
; MM0 source operand
; MM1 source operand
; Output:
; MM0 absolute difference of the unsigned
; operands
movq MM2, MM0 ; make a copy of MM0
psubusb MM0, MM1 ; compute difference one way
psubusb MM1, MM2 ; compute difference the other way
por MM0, MM1 ; OR them together
Page view 242
1 2 ... 238 239 240 241 242 243 244 245 246 247 248 ... 567 568

Comments to this Manuals

No comments