Partager via


__m64_pavgsub2

Microsoft Specific

Emits the 2-byte form of the Parallel Average Subtract (pavgsub2) instruction.

__m64 __m64_pavgsub2( 
   __m64 a,
   __m64 b
);

Parameters

  • [in] a
    An __m64 union containing an array of four unsigned short integers, which are subtracted from.

  • [in] b
    An __m64 union containing an array of four unsigned short integers, which are subtracted.

Return Value

An __m64 union containing the array of results of (a[i]-b[i])/2 interpreted as 16-bit signed integers.

Requirements

Intrinsic

Architecture

__m64_pavgsub2

IPF

Header file <intrin.h>

Remarks

The numbers in the input array b are subtracted from the numbers in the input array a. The result is an __m64 union containing an array of unsigned short integers with the result of (a[i] – b[i])/2, where i numbers the four unsigned integers in the source arrays. If fractional, the result of each average is rounded to the nearest odd integer.

Example

// pavgsub2.cpp
// processor: IPF
#include <stdio.h>
#include <intrin.h>

#pragma intrinsic(__m64_pavgsub2)

void print4u(unsigned __int16* ia)
{
    printf_s("{ %8u, %8u, %8u, %8u }\n", ia[0], ia[1], ia[2], ia[3] );
}

void print4(__int16* ia)
{
    printf_s("{ %8d, %8d, %8d, %8d }\n", ia[0], ia[1], ia[2], ia[3] );
}


int main()
{
    __m64 m, n, result;
    unsigned __int16 ra[4], i;
    unsigned __int16 ma[4] = { 10, 100, 70, 10000 };
    unsigned __int16 na[4] = { 1, 95, 50,   5000 }; 

    for (i = 0; i < 4; i++)
    {
       m.m64_u16[i] = ma[i];
       n.m64_u16[i] = na[i];
    }
    
    printf_s("a: \n");
    print4u(ma);
    printf_s("b: \n");
    print4u(na);
    printf_s("\n");

    result = __m64_pavgsub2(m, n);    
    
    printf_s("Parallel Average Subtract (a[]-b[])/2 : \n");
    print4(result.m64_i16);
    printf_s("\n");
       
    result = __m64_pavgsub2(n, m);
    
    printf_s("Parallel Average Subtract (b[]-a[])/2 : \n");
    print4(result.m64_i16);
    printf_s("\n");

}

a: 
{       10,      100,       70,    10000 }
b: 
{        1,       95,       50,     5000 }

Parallel Average Subtract (a[]-b[])/2 : 
{        5,        3,       10,     2500 }

Parallel Average Subtract (b[]-a[])/2 : 
{       -5,       -3,      -10,    -2500 }

See Also

Concepts

__m64

Compiler Intrinsics