News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Incorrect Mask?

Started by Elegant, July 21, 2015, 04:33:40 AM

Previous topic - Next topic

Elegant

Hi, I have two masks in the code below that I've seen used in another program. I was wondering if someone could explain how it is the code is creating the mask but yet not having to deal with the same XMM register (in my eyes the code below could should not generate the commented masks they indicate to be making). The code goes on to use xmm11 and xmm 10 and seems to completely disregard xmm13 and xmm14 beyond this snippet. Should the code not use a single XMM register per mask instead of two?


    ; 0x0006
    pcmpeqb xmm11,xmm11
    psrlw xmm14,14
    psllw xmm14,1

    ; 0x0008
    pcmpeqb xmm10,xmm10
    psrlw xmm13,15
    psllw xmm13,3

rrr314159

You're right. To answer such questions for certain, get used to the debugger. Simply stop the code at that point, single step thru the instructions, watch what happens to the registers. In this case (first example) xmm14 will wind up with either 0, 2, 4, or 6 in each word, while xmm11 will have -1 in each byte (or word). OTOH change xmm14 to xmm11 and it will have the correct mask in each word, 6.

I can't guess why the code is written the way it is, some misunderstanding here
I am NaN ;)

Elegant

Just wanted to double check that I wasn't missing some relationship with xmm13 or 14 since they're never ever mentioned again in the entire project except for those parts. Thanks!