Does anyone have a string compare procedure in asm?
Printable View
Does anyone have a string compare procedure in asm?
All you need to do is go through each byte of the arrays and compare them with each other. If they are not equal, go to a different label. If you have reached the end of the arrays and all of them were equal then go to another label. I don't have a procedure, but I can write one if you want.
Ya that would be cool. I tried to write one, but i just have trouble working with two strings.
_strcmp proc STDCALL wrd1:dword, wrd2:dword
mov ecx, wrd1
mov edx, wrd2
xor eax, eax
@@lop:
mov bl, byte ptr [ecx]
mov bh, byte ptr [edx]
cmp bl, bh
jne @@err
cmp bl, 0
je @@done
cmp bh, 0
je @@done
inc ecx
inc edx
jmp @@lop
@@err:
ret
@@done:
mov eax, 1
ret
_strcmp endp
A few months late but never mind!! LOL :)
A little late, but thanks for the reply. If you look into the newest APJ, the strmp routine i eventualy got to work is in there.
This is for using GCC... I hope this map come in useful...
Code:inline char * strcpy(char * dest,const char *src)
{
__asm__("cld\n"
"1:\tlodsb\n\t"
"stosb\n\t"
"testb %%al,%%al\n\t"
"jne 1b"
: /* no output */
:"S" (src),"D" (dest):"si","di","ax","memory");
return dest;
}