Hey, Could someone please tell me how to compare strings..cuz i have two edit boxes (password ones) and i want to make sure that they are both the same (one of them is a confirm box). I have got the text box data stored from the first one in esi and the second in edi and i have tried doing cmp esi,edi and then je but this doesnt seem to be working? so i tried .IF esi==edi .endif and this doesnt work.. could someone please help thanx
Comparing strings is not the same way as comparing numbers. First, you have NOT stored the data of the text box in ESI and EDI. What you've done is that you have stored the memory location of the data. ESI is actually *pointing* to the data. -Accessing ESI you get the memory location of the data. -Accessing you get the first character of the data. To get the second character, increase ESI and then access the character trough again until you get a NULL (end of string).
This little code above gets one character after the other until it reaches the end of the string, storing each character in AL. I hope my lazy explanation helped a little. :)
Again: mov al, ;get a character inc esi ;point to next character cmp al, 0 ;check if "End Of String" jne Again ;jump if not "End Of String"
Use WinAPI function lstrcmp or lstrcmpi.
.......vkim pointed out that there are lstrcmp and lstrcmpi which are good, but you might also wanna check out CompareString. *unknown*
.data segment String1 db "This one is not equal..",0 String2 db "To this one...",0 LenStr1 equ $-LenStr1 .code mov ecx,LenStr1 lea esi,String2 lea edi,String2 cld REPE cmpsb je strings_are_equal strings_are_equal: I think this code should work for comparision too =) //Phrekie