Stefano Tommesani

  • Increase font size
  • Default font size
  • Decrease font size
Home Programming MMX Comparison

MMX Comparison

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)

Quote this article on your site

To create link towards this article on your website,
copy and paste the text below in your page.




Preview :

MMX Comparison
Saturday, 24 April 2010

Powered by QuoteThis © 2008
 
View Stefano Tommesani's profile on LinkedIn

Latest Articles

Unit-testing file I/O 26 November 2017, 12.09 Testing
Unit-testing file I/O
Two good news: file I/O is unit-testable, and it is surprisingly easy to do. Let's see how it works! A software no-one asked for First, we need a piece of software that deals with files and that has to be unit-tested. The
Fixing Git pull errors in SourceTree 10 April 2017, 01.44 Software
Fixing Git pull errors in SourceTree
If you encounter the following error when pulling a repository in SourceTree: VirtualAlloc pointer is null, Win32 error 487 it is due to to the Cygwin system failing to allocate a 5 MB large chunk of memory for its heap at
Castle on the hill of crappy audio quality 19 March 2017, 01.53 Audio
Castle on the hill of crappy audio quality
As the yearly dynamic range day is close (March 31st), let's have a look at one of the biggest audio massacres of the year, Ed Sheeran's "Castle on the hill". First time I heard the song, I thought my headphones just got
Necessary evil: testing private methods 29 January 2017, 21.41 Testing
Necessary evil: testing private methods
Some might say that testing private methods should be avoided because it means not testing the contract, that is the interface implemented by the class, but the internal implementation of the class itself. Still, not all
I am right and you are wrong 28 December 2016, 14.23 Web
I am right and you are wrong
Have you ever convinced anyone that disagreed with you about a deeply held belief? Better yet, have you changed your mind lately on an important topic after discussing with someone else that did not share your point of

Translate