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,31 @@
extern malloc
global ft_strdup
extern ft_strcpy
extern ft_strlen
extern __errno_location
section .text
ft_strdup:
test rdi, rdi ; test if arg is NULL
je err
push rdi ;push to use it for the strcpy
call ft_strlen
mov rdi, rax
call malloc wrt ..plt
test rax, rax
je malloc_failed
mov rdi, rax
pop rsi
call ft_strcpy
ret
malloc_failed:
call __errno_location wrt ..plt
mov dword [rax], 12
pop rax
err:
xor rax, rax
ret