i'm stuck with a NASM code, i'm trying to reproduce the strchr function in NASM and i can't figure out two things : -Why when i try to print the result i got a warning on wrong format with a printf %s even if i'm trying to return a pointer on a string, -And also why i keep getting SIGSEV Signal, but one problem is related to the other i think.
Here is my code, if someone could help, it will be greatly appreciated :
[BITS 64]
global strchr_asm
strchr_asm:
push rbp
mov rbp, rsp
mov r9, -1
mov rax, rsi
mov r8b, BYTE[rdi]
loop:
inc r9
cmp BYTE[rax+r9], 0
je endF
cmp BYTE[rax+r9], r8b
je endV
jmp loop
endF:
add rax, r9
jmp last
endV:
add rax, r9
last:
mov rsp, rbp
pop rbp
ret