vaddsbs

Vector Add Signed Byte Saturate

vaddsbs vD, vA, vB

Adds 16 signed bytes with saturation (-128..127).

Details

The vaddsbs instruction performs a vectorized addition of signed bytes from two source vectors, saturating the results to fit within an 8-bit signed integer range. If the sum exceeds the maximum value (127), it is clamped to 127; if it goes below the minimum value (-128), it is clamped to -128.

Pseudocode Operation

if MSR.VEC=0 then Vector_Unavailable()
do i = 0 to 15
    src1 ←EXTS(VSR[VRA+32].byte[i])
    src2 ←EXTS(VSR[VRB+32].byte[i])
    VSR[VRT+32].byte[i] ←si8_CLAMP(src1 + src2)
end

Programming Note

The vaddsbs instruction is commonly used for vectorized addition of signed bytes, ensuring that results are clamped to the 8-bit signed integer range. Ensure that the Vector Facility (MSR.VEC) is enabled before using this instruction; otherwise, a Vector_Unavailable exception will be raised. This instruction operates on 16-byte vectors and processes each byte independently.

Example

vaddsbs vd, va, vb

Encoding

Binary Layout
4
0
vD
6
vA
11
vB
16
768
21
 
Format VX-form
Opcode 0x10000300
Extension VMX (AltiVec)
Registers Altered MSR

Operands

  • vD
    Target
  • vA
    Src A
  • vB
    Src B