usad8
Unsigned Sum of Absolute Differences
USAD8<c> <Rd>, <Rn>, <Rm>
Computes sum of absolute differences of bytes (Video Codec).
Pseudocode Operation
diff0 ← |Rn[7:0] - Rm[7:0]|
diff1 ← |Rn[15:8] - Rm[15:8]|
diff2 ← |Rn[23:16] - Rm[23:16]|
diff3 ← |Rn[31:24] - Rm[31:24]|
Rd ← diff0 + diff1 + diff2 + diff3
Example
USAD8 r0, r1, r2
Encoding
Binary Layout
cond
31:28
01111000
27:20
Rd
19:16
1111
15:12
Rm
11:8
0001
7:4
Rn
3:0
Operands
-
Rd
Destination general-purpose register -
Rn
First source / base general-purpose register -
Rm
Second source / offset general-purpose register
Related
More in A32 (DSP)
Reference
View in Arm A64 ISA Reference ↗
Arm AArch32 ISA
Instruction Forms
| Encoding | Instruction | ISA | Bit pattern | ||
|---|---|---|---|---|---|
| 0x0780F010 | USAD8{<c>}{<q>} {<Rd>,} <Rn>, <Rm> | A32 | cond | 01111000 | Rd | 1111 | Rm | 0001 | Rn | ||
| 0xFB70F000 | USAD8{<c>}{<q>} {<Rd>,} <Rn>, <Rm> | T32 | 111110110 | 111 | Rn | 1111 | Rd | 00 | 00 | Rm |
Description
Unsigned Sum of Absolute Differences performs four unsigned 8-bit subtractions, and adds the absolute values of the differences together.
Operation
if ConditionPassed() then
EncodingSpecificOperations();
absdiff1 = Abs(UInt(R[n]<7:0>) - UInt(R[m]<7:0>));
absdiff2 = Abs(UInt(R[n]<15:8>) - UInt(R[m]<15:8>));
absdiff3 = Abs(UInt(R[n]<23:16>) - UInt(R[m]<23:16>));
absdiff4 = Abs(UInt(R[n]<31:24>) - UInt(R[m]<31:24>));
result = absdiff1 + absdiff2 + absdiff3 + absdiff4;
R[d] = result<31:0>;