Si usas la lib de masm y llamas a
szCmp, te genera el siguiente codigo:
MOV ECX,DWORD PTR SS:[ESP+4]
MOV EDX,DWORD PTR SS:[ESP+8]
PUSH EBX
PUSH ESI
MOV EAX,-1
MOV ESI,1
Bucle:
ADD EAX,ESI
MOVZX EBX,BYTE PTR DS:[EAX+ECX]
CMP BL,BYTE PTR DS:[EAX+EDX]
JNZ NoIgual
TEST EBX,EBX
JE Iguales
ADD EAX,ESI
MOVZX EBX,BYTE PTR DS:[EAX+ECX]
CMP BL,BYTE PTR DS:[EAX+EDX]
JNZ NoIgual
TEST EBX,EBX
JE Iguales
ADD EAX,ESI
MOVZX EBX,BYTE PTR DS:[EAX+ECX]
CMP BL,BYTE PTR DS:[EAX+EDX]
JNZ NoIgual
TEST EBX,EBX
JE Iguales
ADD EAX,ESI
MOVZX EBX,BYTE PTR DS:[EAX+ECX]
CMP BL,BYTE PTR DS:[EAX+EDX]
JNZ NoIgual
TEST EBX,EBX
JNZ Bucle
Iguales:
POP ESI
POP EBX
RETN 8
NoIgual:
XOR EAX,EAX
POP ESI
POP EBX
RETN 8
El largo, pero efectivo (la comparación es Case-Sentive).
La ayuda dice:
szCmp
szCmp proc str1:DWORD,str2:DWORD
Description
szCmp compares two zero terminated strings for difference.
Parameters
1. str1 The first string to compare
2. str2 The second string to compare
Return Value
If the two strings match, the return value is the length of the string. If there is no match, the return value is zero.
Comments
The procedure can be used on strings that may be of uneven length as the terminator will produce the mismatch even if the rest of the charactes match.