section .text global ft_strcmp ft_strcmp: xor rax, rax test rdi, rdi ; test if args are false jz .err test rsi, rsi jz .err .loop_start: mov al, [rdi] cmp al, [rsi] jne .compare test al, al ; test if rdi is \0 jz .compare mov al, [rsi] ; test if rsi is \0 test al, al jz .compare lea rsi, [rsi + 1] lea rdi, [rdi + 1] jmp .loop_start .compare: mov al, [rdi] cmp al, [rsi] jl .lower jg .greater mov eax, 0 jmp .end .lower: mov eax, -1 jmp .end .greater: mov eax, 1 jmp .end .err: mov eax, 0 .end: ret