add other basic functions and test with them

This commit is contained in:
2025-03-29 19:54:58 +01:00
parent 76cf33dd1c
commit b6ad45ab6d
17 changed files with 311 additions and 6 deletions

View File

@ -0,0 +1,48 @@
section .text
global ft_strcmp
ft_strcmp:
xor rax, rax
test rdi, rdi ; test if args are false
je err
test rsi, rsi
je err
loop_start:
mov al, [rdi]
cmp al, [rsi]
jne compare
test al, al ; test if rdi is \0
je compare
mov al, [rsi] ; test if rsi is \0
test al, al
je 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