I am tring to compare a character from a char pointer, i.e. a string, with another specified char, to find the first occurence of that char in the string. However, the char from the char pointer is returning wierd values, I am not sure how to do it.
This is my assembly code:
findChar:
mov $0, %eax
start:
cmp (%rdi), %esi
je done
add $1, %rdi
inc %ebx
jmp start
done:
ret
I am calling the this function from C:
int findChar( char *str, char ch );
I tried returning the value of (%rdi) when it was supposed to match. When printing the return value as a char it is correct, however the integer value is something like 112410010, i.e. alot.
Thanks for any help