There was recently a thread asking for a fast way to test several registers.
Well, I've been thinking of it, and this is my idea(using fasm syntax):


numbers:
.first DW ?
.second DW ?
.third DW ?
.fourth DW ?

mask DQ ?

movq mm0, qword [numbers]
pcmpeqw mm0,qword [mask] ;packed compare for equal words

;If any of the numbers was a 0, it'll show now in MM0


This method is good to look for a determinated pattern in , because PCMPEQ returns just on or off bits :)

Using this could compare even 8 bytes at a time, SIMD, pretty quick.
I think using MMX stuff it could be 16 bytes (wow!) in one instruction, but haven't tryed yet.

Now the questions:
in MASM, how would access the STRUCT? Is there something like movq MM0, quad pointer ?
And STRUCTS are globals or locals? (I mean, do they reside in .data or are created in every proc using a base pointer?
Posted on 2002-08-14 11:48:57 by slop
Hey Sloppy

1) MASM defines structures like so:


QWORDTHINGY STRUC
first dw ?
second dw ?
third dw ?
fourth dw?
QWORDTHINGY ENDS

numbers QWORDTHINGY <?> ;uninitialized
numbers1 QWORDTHINGY <1,2,3,4> ;initialized


That is, it first defines a new type with fields, and then you declare a variable of that type (instead of, say, numbers dd ?).

2) Using the example above, you should be able to do movq MM0, QWORD PTR

3) The variables based on STRUCs are global or local depending on how you define them. The STRUCs themselves are just for the programmer, and aren't really part of the code, but act as info for the compiler.



numbers QWORDTHINGY <?> ;global

LOCAL numbers:QWORDTHINGY ;local in a proc


4) you aren't switching back to MASM already are you? ;)

--Chorus
Posted on 2002-08-14 16:01:13 by chorus
No, I'm not switching back, it's just for compatibility issues with my pals ;)

Thank you for being so helpfull, chorus :)
Posted on 2002-08-16 10:57:07 by slop