add other basic functions and test with them
This commit is contained in:
@ -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
|
||||
|
Reference in New Issue
Block a user