Condividi tramite


__m64_mux2 

Microsoft Specific

Emits the IPF mux2 instruction, the 2-byte form of the mux instruction, which is used to arrange bytes in a particular pattern specified by the second parameter.

__m64 __m64_mux2( 
   __m64 source, 
   const int permutation 
);

Parameters

  • [in] source
    The source data for the permutation operation.
  • [in] permutation
    Specifies the permutation of the source bytes in the result.

Requirements

Intrinsic Architecture

__m64_mux2

IPF

Header file <intrin.h>

Remarks

The second parameter is 8 bits. The first pair of bits (moving from left to right, or most significant bit to least significant bit) tells which of the four 16-bit sections of the source to choose for the first 16-bit section of the result, and so on for the second, third, and fourth pairs of bits in the permutation parameter. For example, 0x1b (00011011) reverses the bits, and 0xe4 (11100100) puts the bits in the same position as the source. The source bits might be chosen more than once; for example, 0x0 (00000000) broadcasts the first 16-bits into every 16-bit slot of the result and 0xFF (11111111) broadcasts the last 16-bits into every 16-bit slot of the result.

Example

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

#pragma intrinsic(__m64_mux2)

void m64tochararray(__m64 m64, char* c)
{
    for (int j = 0; j < 8; j++)
        c[j] = m64.m64_i8[j];
}

void chararraytom64(const char* c, __m64* pm64)
{
    for (int j = 0; j < 8; j++)
        pm64->m64_i8[j] = c[j];
}

int main()
{
    char s1[9] = "00112233";
    char s2[9];
    __m64 m, result;

    printf_s("Source string:    %s\n", s1);

    memset(s2, 0, 9);
    chararraytom64(s1, &m);  
    result = __m64_mux2(m, 0x1b);  // reverse: 00011011  
    m64tochararray(result, s2);     
    printf_s("mux2 (0x1b) form: %s\n", s2);

    memset(s2, 0, 9);
    chararraytom64(s1, &m);  
    result = __m64_mux2(m, 0xe4); // identity: 11100100
    m64tochararray(result, s2);     
    printf_s("mux2 (0xe4) form: %s\n", s2);

    memset(s2, 0, 9);
    chararraytom64(s1, &m);
    result = __m64_mux2(m, 0);     // broadcast the first 16-bits
    m64tochararray(result, s2);     
    printf_s("mux2 (0x00) form: %s\n", s2);

    memset(s2, 0, 9);
    chararraytom64(s1, &m);      
    result = __m64_mux2(m, 0xff);  // broadcast the last 16-bits
    m64tochararray(result, s2);     
    printf_s("mux2 (0xff) form: %s\n", s2);

    memset(s2, 0, 9);
    chararraytom64(s1, &m);  
    result = __m64_mux2(m, 0x8d);  // shuffle: 10001101 
    m64tochararray(result, s2);     
    printf_s("mux2 (0x8d) form: %s\n", s2);
}

Output

Source string:    00112233
mux2 (0x1b) form: 33221100
mux2 (0xe4) form: 00112233
mux2 (0x00) form: 00000000
mux2 (0xff) form: 33333333
mux2 (0x8d) form: 11330022

END Microsoft Specific

See Also

Reference

__m64
Compiler Intrinsics