hi!


min<=value<=max

movq mm3,mm2 ; value
pminub mm2,mm1 ; max
pmaxub mm3,mm0 ; min
pcmpeqb mm2,mm3 ; result


These are SSE instructions and only available on the P3 and above, i need to do that with "standard-MMX" instructions.

Cu, Jens
Posted on 2002-03-27 14:46:54 by Jens Duttke
Some comment.
Is as works on anyone Athlon processor.
Posted on 2002-03-28 11:42:14 by Nexo
A liitle bit different way to generate 808080808080808h
It your very code it wouldn't gain anything, cause anyway you need FFFFFFFFFFFFFFFFFFh
but in some code where it cost a special efforts this might be usefull since
doesn't need any manipulation with different values:



pcmpeqd mm6,mm6
psllw mm6,8
packsswb mm6,mm6
Posted on 2002-03-29 04:25:02 by The Svin
I found I byte shorter way to generate 8080808...


pxor mm6,mm6
pcmpeqd mm7,mm7
punpckhbw mm6,mm7
packsswb mm6,mm6

;)
Posted on 2002-03-29 05:11:30 by The Svin
More shorter:
mov eax,80808080h
movd mm6,eax
punpckldq mm6,mm6
Posted on 2002-03-29 11:43:18 by Nexo
Nexo, please, try a little bit better to figure out what were my last two posts about.
your code:
1. Takes 3 clocks
2. Use 11 bytes
3. Use two registers
4. Do one thing - filling MMx with 80808080...h
Now:
a) First of my last two posts:
1.Takes 3 clocks
2.! Use 10 (! not 11) bytes
3.! Use 1(!not 2) register
4. Do the same thing - filling MMx with 80808080...h
So comparing to your code mine is shorter and uses less registers.

b) Second of my last two posts - is idea for replacement Jens start code with
code of the same speed but one 1 byte shorter:
1. Takes 3 clocks
2. Use 12 bytes (instead of Jens 13 bytes for the same part)
3. Do !TWO things Jens's code needs of:
- Fill one register with 8080...
- Fill another register with FFFFF...

This code can not be copmared to yours 'cause your code does just one thing
here is original Jens code I offered replacement for:


pcmpeqd mm7, mm7; mm7 <- FFh -this mm7 used in the end of his code
pxor mm6, mm6 ; mm6 <- 80h
psubb mm6, mm7
psllq mm6, 7
;13 bytes mm6=8080.. mm7=FFF...

My code


pxor mm6,mm6
pcmpeqd mm7,mm7 ;FFFF....
punpckhbw mm6,mm7 ;FF00FF00...
packsswb mm6,mm6 ;808080...
;12 bytes mm7=FFFF.. mm6=808080...

It's OK, just forget it. ;)
Posted on 2002-03-29 12:27:37 by The Svin