EasyManua.ls Logo

Intel ARCHITECTURE IA-32 - Building Blocks; Absolute Difference of Unsigned Numbers

Intel ARCHITECTURE IA-32
568 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
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

Table of Contents

Related product manuals