0

After using the assembly instruction:

pcmpeqd xmm2, xmm7

The result in resgister xmm2 = 00000000 00000000 FFFFFFFF 00000000

The result is correct. Unfortunately the comparison sets no flags that can be tested to break out of the loop. Also any one of the 4 dwords can have all their bits set, not just the example given here. Do I have to load each one of the 4 dwords into a general purpose register to test again? Or is there a quicker way to do it?

Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
John J
  • 31
  • 5
  • Hi, the post maybe your first post which gives to me to review. I'm not familiar with register, but for stackoverflow, question hope a clear error scene. You can attempt your thinking and give a clear question is welcome. – LoranceChen May 20 '20 at 10:04
  • 2
    You can use [`pmovmskb`](https://www.felixcloutier.com/x86/pmovmskb) to extract the upper bits of each byte into a register then use `test` to check if any or all bits are set. With SSE4.1 you can also try [`ptest`](https://www.felixcloutier.com/x86/ptest) – chtz May 20 '20 at 10:24
  • 1
    Note that you need to decide what the break condition is, i.e. "all equal" or "any equal". – Paul R May 20 '20 at 11:13
  • I want to mark the response from chtz as helpful as his suggestion was exactly what I was looking for and it solved my problem! However, there is no green check mark to the left of the response that I can select to show as answered... – John J May 20 '20 at 15:37
  • The above are just comments, not answers. You can write up the solution as a fully fledged answer and accept it, or invite chtz to do the same. – Paul R May 21 '20 at 05:58
  • Yes I am aware of that Paul R. Thanks anyway. I will put up the solution after 48 hours since posting the question as I can only do so once that time has elapsed. :) – John J May 21 '20 at 07:45

0 Answers0