I made my own strlen implementation in the assembly but did not return the correct value. It returns the length of the string + 4. Therefore. I donβt understand why .. And I hope one of you ...
Build Source:
section .text [GLOBAL stringlen:] ; C function stringlen: push ebp mov ebp, esp ; setup the stack frame mov ecx, [ebp+8] xor eax, eax ; loop counter startLoop: xor edx, edx mov edx, [ecx+eax] inc eax cmp edx, 0x0 ; null byte jne startLoop end: pop ebp ret
And the main procedure:
#include <stdio.h> extern int stringlen(char *); int main(void) { printf("%d", stringlen("h")); return 0; }
thanks
source share