You copied the Doc URL to your clipboard.

__ssat16 intrinsic

This intrinsic inserts an SSAT16 instruction into the instruction stream generated by the compiler. It enables you to saturate two signed 16-bit values to a selected signed range.

The Q bit is set if either operation saturates.

unsigned int __saturate_halfwords(unsigned int val1, unsigned int val2)

Where:

val1

holds the two signed 16-bit values to be saturated

val2

is the bit position for saturation, an integral constant expression in the range 1 to 16.

The __ssat16 intrinsic returns:

  • the signed saturation of the low halfword in val1, saturated to the bit position specified in val2 and returned in the low halfword of the return value

  • the signed saturation of the high halfword in val1, saturated to the bit position specified in val2 and returned in the high halfword of the return value.

Example:

unsigned int saturate_halfwords(unsigned int val1, unsigned int val2)
{
  unsigned int res;

    res = __ssat16(val1,val2); /* Saturate halfwords in val1 to the signed
                                  range specified by the bit position in val2 */
    return res;
}

See also