|
-
Oct 22nd, 2000, 04:41 PM
#4
Frenzied Member
err, you want pointers to the 2 strings in 2 registers say ebx and ecx then go into a loop, compare the values of the 2 bytes pointed to by ebx and ecx if they are not equal put a value of 0 (false) into eax, if they are equal check if one of them is 0, if it is put -1 (true) into eax and return, if not increment ebx and eax and go back to the start of the loop.
Unfortunatley I'm not quite at the stage where I can code that correctly, so I'll code it incorectly instead
Code:
StringCompare proc
pop ebx ;pops 2 parameters off the stack,
pop ecx ;these should be pointers to char arrays
strt: ;start of loop
cmp [ebx],[ecx] ;compare the bytes pointed to by
;ebx and ecx, this syntax is
;probably vey wrong so change it
;remember you only want to compare
;single bytes, not words or dwords
jne RetFalse ;if they are not the same return false
cmp [ebx], 0 ;compare the byte pointed to by ebx
;to 0 (syntax will be wrong again)
jne strt ;if it's not a termination character
;go back to the start
;end of loop
;both strings terminated so return true
mov eax, -1
ret
RetFalse:
;we've found 2 different characters so return false
mov eax, 0
ret
StringCompare endp
if you code that correctly it should work.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|