vabsduh

Vector Absolute Difference Unsigned Halfword

vabsduh vD, vA, vB

Computes |A - B| for halfwords.

Details

The vabsduh instruction computes the absolute difference between corresponding unsigned halfword elements of two vector registers and stores the results in a third vector register. It processes each pair of halfwords from the input vectors, calculates the absolute difference, and places the result into the corresponding position in the output vector.

Pseudocode Operation

if MSR.VEC=0 then Vector_Unavailable()
do i = 0 to 7
   src1 ←EXTZ(VSR[VRA+32].hword[i])
   src2 ←EXTZ(VSR[VRB+32].hword[i])

   if src1 > src2 then
      VSR[VRT+32].hword[i] ←CHOP16(src1 + ¬src2 + 1)
   else
      VSR[VRT+32].hword[i] ←CHOP16(src2 + ¬src1 + 1)
end

Programming Note

The vabsduh instruction is commonly used for vectorized image processing tasks where pixel intensity differences need to be calculated. Ensure that the input vectors are properly aligned to halfword boundaries to avoid misaligned access exceptions. This instruction operates at user privilege level and does not generate any exceptions under normal operation, but it will raise a Vector_Unavailable exception if the VEC bit in the MSR is not set.

Example

vabsduh vd, va, vb

Encoding

Binary Layout
4
0
vD
6
vA
11
vB
16
1091
21
 
Format VA-form
Opcode 0x10000443
Extension VMX (AltiVec)
Registers Altered MSR

Operands

  • vD
    Target
  • vA
    Src A
  • vB
    Src B