Support
 

    MMX Comparison Instructions

    These instructions generate a mask of ones or zeros which can be used by logical operations to select elements within a register: a developer can implement a packed conditional move operation without a set of branch instructions.

     
     

    PCMPEQB mm, mm/m64
    PCMPEQW mm, mm/m64
    PCMPEQD mm, mm/m64

    The PCMPEQ (Packed Compare for Equal) instructions compare the data elements in the destination operand to the corresponding data elements in the source operand. If the data elements are equal, the corresponding data element in the destination register is set to all ones, if they are not, it is set to all zeros. PCMPEQ supports packed byte (PCMPEQB), packed word (PCMPEQW) and packed doubleword (PCMPEQD) data types. 

     

    PCMPEQB instruction with 64-bit operands:
    IF DEST[7..0] = SRC[7..0]
    THEN DEST[7 0) ← FFH;
    ELSE DEST[7..0] ← 0;
    * Continue comparison of 2nd through 7th bytes in DEST and SRC *
    IF DEST[63..56] = SRC[63..56]
    THEN DEST[63..56] ← FFH;
    ELSE DEST[63..56] ← 0;

    PCMPEQW instruction with 64-bit operands:
    IF DEST[15..0] = SRC[15..0]
    THEN DEST[15..0] ← FFFFH;
    ELSE DEST[15..0] ← 0;
    * Continue comparison of 2nd and 3rd words in DEST and SRC *
    IF DEST[63..48] = SRC[63..48]
    THEN DEST[63..48] ← FFFFH;
    ELSE DEST[63..48] ← 0;

    PCMPEQD instruction with 64-bit operands:
    IF DEST[31..0] = SRC[31..0]
    THEN DEST[31..0] ← FFFFFFFFH;
    ELSE DEST[31..0] ← 0;
    IF DEST[63..32] = SRC[63..32]
    THEN DEST[63..32] ← FFFFFFFFH;
    ELSE DEST[63..32] ← 0;

    PCMPEQB __m64 _mm_cmpeq_pi8 (__m64 m1, __m64 m2)

    PCMPEQW __m64 _mm_cmpeq_pi16 (__m64 m1, __m64 m2)

    PCMPEQD __m64 _mm_cmpeq_pi32 (__m64 m1, __m64 m2)


     

    PCMPGTB mm, mm/m64
    PCMPGTW mm, mm/m64
    PCMPGTD mm, mm/m64

    The PCMPGT (Packed Compare for Greater Than) instructions compare the signed data elements in the destination operand to the signed data elements in the source operand. If the signed data elements in the destination register are greater than those in the source operand, the corresponding data element in the destination operand is set to all ones, otherwise it is set to all zeros. PCMPGT supports packed byte (PCMPGTB), packed word (PCMPGTW) and packed doubleword (PCMPGTD) data types. 
    PCMPGTB instruction with 64-bit operands:
    IF DEST[7..0] > SRC[7..0]
    THEN DEST[7 0) ← FFH;
    ELSE DEST[7..0] ← 0;
    * Continue comparison of 2nd through 7th bytes in DEST and SRC *
    IF DEST[63..56] > SRC[63..56]
    THEN DEST[63..56] ← FFH;
    ELSE DEST[63..56] ← 0;

    PCMPGTW instruction with 64-bit operands:
    IF DEST[15..0] > SRC[15..0]
    THEN DEST[15..0] ← FFFFH;
    ELSE DEST[15..0] ← 0;
    * Continue comparison of 2nd and 3rd words in DEST and SRC *
    IF DEST[63..48] > SRC[63..48]
    THEN DEST[63..48] ← FFFFH;
    ELSE DEST[63..48] ← 0;

    PCMPGTD instruction with 64-bit operands:
    IF DEST[31..0] > SRC[31..0]
    THEN DEST[31..0] ← FFFFFFFFH;
    ELSE DEST[31..0] ← 0;
    IF DEST[63..32] > SRC[63..32]
    THEN DEST[63..32] ← FFFFFFFFH;
    ELSE DEST[63..32] ← 0;

    PCMPGTB __m64 _mm_cmpgt_pi8 (__m64 m1, __m64 m2)

    PCMPGTW __m64 _mm_pcmpgt_pi16 (__m64 m1, __m64 m2)

    PCMPGTD __m64 _mm_pcmpgt_pi32 (__m64 m1, __m64 m2)


     
     
    << Back to MMX Primer Home Next: MMX Conversion >>
Copyright Stefano Tommesani 2000/02 - All trademarks belong to their respective holders