Partager via


__m64_pavgsub1 

Microsoft Specific

Emits the 1-byte form of the Parallel Average Subtract (pavgsub1) instruction.

__m64 __m64_pavgsub1( 
   __m64 a, 
   __m64 b 
);

Parameters

  • [in] a
    An array of 8 bytes interpreted as unsigned 1-byte integers to be subtracted from.
  • [in] b
    An array of 8 bytes interpreted as unsigned 1-byte integers to subtract.

Return Value

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

Requirements

Intrinsic Architecture

__m64_pavgsub1

IPF

Header file <intrin.h>

Remarks

The instruction computes (a[i]-b[i])/2 for each byte i of a and b. Each byte in the array is treated as an 8-bit unsigned integer. If fractional, the result in each byte is rounded to the nearest odd integer.

Example

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

#pragma intrinsic(__m64_pavgsub1)

void print8(__int8* ia)
{
    printf_s("{ %4d, %4d, %4d, %4d, %4d, %4d, %4d, %4d}\n",
             ia[0], ia[1], ia[2], ia[3], ia[4], ia[5], ia[6], ia[7] );
}

void print8u(unsigned __int8* ia)
{
    printf_s("{ %4u, %4u, %4u, %4u, %4u, %4u, %4u, %4u }\n",
             ia[0], ia[1], ia[2], ia[3], ia[4], ia[5], ia[6], ia[7] );
}


int main()
{
    __m64 m, n, result;
    __int8 ra[8], i;
    unsigned __int8 ma[8] = { 1, 5, 255, 255, 8, 8, 8, 8 };
    unsigned __int8 na[8] = { 5, 1, 1,   0,   2, 1, 0, 8 }; 

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

    result = __m64_pavgsub1(m, n);    
   
    printf_s("Parallel Average Subtract (a[]-b[])/2 : \n");
    print8(result.m64_i8);
    printf_s("\n");
       
    result = __m64_pavgsub1(n, m);
   
    printf_s("Parallel Average Subtract (b[]-a[])/2 : \n");
    print8(result.m64_i8);
    printf_s("\n");

}

Output

a: 
{    1,    5,  255,  255,    8,    8,    8,    8 }
b: 
{    5,    1,    1,    0,    2,    1,    0,    8 }

Parallel Average Subtract (a[]-b[])/2 : 
{   -2,    2,  127,  127,    3,    3,    4,    0}

Parallel Average Subtract (b[]-a[])/2 : 
{    2,   -2, -127, -127,   -3,   -3,   -4,    0}

END Microsoft Specific

See Also

Reference

__m64
Compiler Intrinsics