I wrote my own implementation of strlen and strcmp from C in x86 FASM and I would like to know is there anything that should be changed/removed/added. strlen needs string in eax and its returning length of that string into ebx
strlen: mov ebx,0 strlen_loop: cmp byte [eax+ebx],0 je strlen_end inc ebx jmp strlen_loop strlen_end: inc ebx ret
strcmp needs two strings (one in eax, second in ebx) and its returning 0 if strings are equal or 1/-1 if they are not into ecx.
strcmp: mov ecx,0 strcmp_loop: mov byte dl,[eax+ecx] mov byte dh,[ebx+ecx] inc ecx cmp dl,0 je strcmp_end_0 cmp byte dl,dh je strcmp_loop jl strcmp_end_1 jg strcmp_end_2 strcmp_end_0: cmp dh,0 jne strcmp_end_1 ret strcmp_end_1: mov ecx,1 ret strcmp_end_2: mov ecx,-1 ret