共用方式為


_mm_abs_pi8

Microsoft Specific

Emits the Supplemental Streaming SIMD Extensions 3 (SSSE3) instruction pabsb. This instruction returns the absolute value for each packed 8-bit integer of the 64-bit parameter.

__m64 _mm_abs_pi8( 
   __m64 a
);

Parameters

  • [in] a
    A 64-bit parameter that contains eight 8-bit signed integers for which the absolute values will be returned.

Return value

r0 := (a0 < 0) ? -a0 : a0

r1 := (a1 < 0) ? -a1 : a1

...

r7 := (a7 < 0) ? -a7 : a7

Requirements

Intrinsic

Architecture

_mm_abs_pi8

x86, x64

Header file <tmmintrin.h>

Remarks

The return value r and parameter a each consist of 64 bits. r0-r7, a0-a7 are the sequentially ordered 8-bit components of these parameters, where r0 and a0 indicate the least significant 8 bits.

Before using this intrinsic, software must ensure that the processor supports the instruction.

Example

#include <stdio.h>
#include <tmmintrin.h>

int main ()
{
    __m64 a;

    a.m64_i8[0] = 0;
    a.m64_i8[1] = 0;
    a.m64_i8[2] = 2;
    a.m64_i8[3] = -2;
    a.m64_i8[4] = 15;
    a.m64_i8[5] = -15;
    a.m64_i8[6] = 127;
    a.m64_i8[7] = -127;

    __m64 b = _mm_abs_pi8( a );


    printf_s("Original 8 bit pairs:\n%4d, %4d\n%4d, %4d\n%4d, %4d\n%4d, %4d\n\n",
                a.m64_i8[0], a.m64_i8[1], a.m64_i8[2], a.m64_i8[3],
                a.m64_i8[4], a.m64_i8[5], a.m64_i8[6], a.m64_i8[7]);

    printf_s("New 8 bit pairs:\n%4d, %4d\n%4d, %4d\n%4d, %4d\n%4d, %4d\n",
                b.m64_i8[0], b.m64_i8[1], b.m64_i8[2], b.m64_i8[3],
                b.m64_i8[4], b.m64_i8[5], b.m64_i8[6], b.m64_i8[7]);

    _mm_empty();

    return 0;
}

Original 8 bit pairs:
   0,    0
   2,   -2
  15,  -15
 127, -127

New 8 bit pairs:
   0,    0
   2,    2
  15,   15
 127,  127

See Also

Concepts

Compiler Intrinsics