Building Blocks; Absolute Difference Of Unsigned Numbers; Example 4-16 Absolute Difference Of Two Unsigned Numbers - Intel ARCHITECTURE IA-32 Reference Manual

Architecture optimization
Table of Contents

Advertisement

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
saturation. This support exists only for packed bytes and packed words,
not for packed doublewords.

Example 4-16 Absolute Difference of Two Unsigned Numbers

; Input:
;
;
; Output:
;
;
movq
psubusb MM0, MM1
psubusb MM1, MM2
por
This example will not work if the operands are signed.
Note that the
see section "Packed Sum of Absolute Differences" for details.
operands and subtracts them with
UNSIGNED
MM0 source operand
MM1 source operand
MM0 absolute difference of the unsigned
operands
MM2, MM0
; make a copy of MM0
; compute difference one way
; compute difference the other way
MM0, MM1
; OR them together
instruction may also be used in some situations;
psadbw
Optimizing for SIMD Integer Applications
UNSIGNED
4
4-23

Advertisement

Table of Contents
loading

Table of Contents