I didn’t measure it, and I don’t know if you need to keep the upper half of
ebx, but you can try something like this:
mov ebx,ecx
xor ebx,[eax]
and ebx,0ffh
loop1:
shr ecx,8
xor ecx,[esi + ebx*4]
mov ebx,ecx
add eax,1
xor ebx,[eax]
and ebx,0ffh
dec edi
jnz loop1
Some of the ideas are: Avoid byte arithmetic; keep setting of ebx far enough
from using it; take maximum advantage of memory-to-register arithmetic. At
this point, unrolling the loop might even help! Also, maybe aligning loop1
on a cache line boundary might be a good idea. And inserting one NOP at the
right place might make a difference, I don’t know, but you’re going to have
to experiment with it. I suggest you write a little C program with a rdtsc
before the loop and another rdtsc after the loop, and loop a zillion times,
measuring the elapsed time - don’t forget you hike the priorty of the thread
to try to avoid getting preempted while the test is running. The other idea
is, if you can do this four at a time, maybe you could consider using the
Pentium III SIMD instructions. Hope this helps!
Alberto.
-----Original Message-----
From: Paul Bunn [mailto:xxxxx@ultrabac.com]
Sent: Tuesday, June 13, 2000 7:50 PM
To: NT Developers Interest List
Subject: [ntdev] x86 Asm FUN!
Five years ago, I took a small routine in C and converted it to asm. Since
this loop is executed in our app 30 billion times or so, I figured it was
worth the effort, and indeed this was about 10,000% faster than the code
generated by the x86 compiler of the time (interestingly, the best we could
do in Alpha assembler was about a 5-10% speed increase, the GEM back-end
compiler for Alpha is legendary). I was just looking at the code the other
day, and was wondering whether there is any way to improve the speed still
further (using MMX instructions maybe ?). I was wondering whether anyone
would care to share some pearls of wisdom regarding improving performance of
this simple routine…
loop1:
mov bl, byte ptr [eax]
xor bl, cl
mov edx, [esi + ebx*4]
shr ecx, 8
xor ecx, edx
inc eax
dec edi
jnz loop1
Regards,
Paul Bunn, UltraBac.com, 425-644-6000
Microsoft MVP - WindowsNT/2000
http://www.ultrabac.com
You are currently subscribed to ntdev as: xxxxx@numega.com
To unsubscribe send a blank email to $subst(‘Email.Unsub’)