SansGrip
26th July 2004, 19:40
I have a sum in mm5 and a counter in mm2. The counter can be either 0, 1 or 2. I want to divide the sum by the counter. Here's the code I have right now:
psrlw mm2, 1 // counter /= 2
psrlw mm5, mm2 // mm5 = average
In theory this should work because:
Two values in sum? Shift right once (divide by two).
One value in sum? Shift right zero times.
Zero in sum? Shift right zero times.
But I get some weird output, and when I run the filter in the debugger I see that following the second line, mm5 is all zeros.
I assume I'm misunderstanding how PSRLW works, but I've not seen this behaviour mentioned in any of the references I've checked.
My processor is an Athlon 2100+ XP.
Any ideas would be greatly appreciated.
psrlw mm2, 1 // counter /= 2
psrlw mm5, mm2 // mm5 = average
In theory this should work because:
Two values in sum? Shift right once (divide by two).
One value in sum? Shift right zero times.
Zero in sum? Shift right zero times.
But I get some weird output, and when I run the filter in the debugger I see that following the second line, mm5 is all zeros.
I assume I'm misunderstanding how PSRLW works, but I've not seen this behaviour mentioned in any of the references I've checked.
My processor is an Athlon 2100+ XP.
Any ideas would be greatly appreciated.