Rafe posed an interesting problem with this style of string comparison so in "brain idling" mode I have put together a procedure that should be able to be tailored to what rafe was after.

It uses a table with XLATB which is a reasonable performer, does the comparison on the 2 retrieved bytes and returns with the 1 based count in EAX of the mismatch if any. A match has the same value as the length returned in EAX.

Depending on what is needed, the calculation at the end can return more or less whatever you need.

Hope its useful.


Posted on 2001-10-11 06:18:58 by hutch--
Why is the bit at the end (sorting out eax) like that?
Can't you just use:

mov eax, esi
sub eax, src

Instead of:

sub esi, ecx
mov eax, esi
neg eax
sub ln, eax
mov eax, ln


And also just a little code shuffle to keep the decoder fed,
mov the inc edi to after the second xlatb. It keeps a nicer 2,1,1 u-op pattern!

Posted on 2001-10-11 07:09:57 by Mirno
Mirno, :tongue:

They tend to come hot of the press in brain idle mode in more or less this form. I was not sure what form rafe wanted the end so I did not do much work on it. When I am a bit less brain dead I will have a play and benchmark it but I doubt there is much speed difference in fiddling it.

Regards & thanks for tidying it up.

Posted on 2001-10-11 07:33:18 by hutch--
Ignore my reply to the other thread... this is good stuff: new instruction (to me) debate about instruction order... This is definitely getting tweeked & plunked into my code. I don't want to work today I want to play with this stuff.... dr-mrs-wifee-poo is about to become a widow again... ahh the little things that make us happy:grin: :grin: :grin:
Posted on 2001-10-11 10:29:57 by rafe