The MASM Forum

General => The Campus => Topic started by: Elegant on July 21, 2015, 04:33:40 AM

Title: Incorrect Mask?
Post by: Elegant on July 21, 2015, 04:33:40 AM
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
Title: Re: Incorrect Mask?
Post by: rrr314159 on July 21, 2015, 09:34:58 AM
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
Title: Re: Incorrect Mask?
Post by: Elegant on July 21, 2015, 10:22:07 AM
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!