section .text
global my_strlen
my_strlen:
xor rax, rax
.LOOP:
cmp BYTE[rdi+rax], 0
jne .LOOP
inc rax
ret
I execute it with:
#include <stddef.h>
#include <stdio.h>
extern size_t my_strlen(const char *str);
int main(int argc, char *argv[]) {
if(argc!=2) return 1;
printf("%lu\n", (unsigned long)my_strlen(argv[1]));
return 0;
}
But when I execute the program, it does not output anything and it does not close.
Increment
raxin the loop. Otherwise, you always test the same byte.