separate declarations in libasm.h file and add list_push_front and list_size
This commit is contained in:
29
srcs/bonus/ft_list_push_front.s
Normal file
29
srcs/bonus/ft_list_push_front.s
Normal file
@ -0,0 +1,29 @@
|
||||
global ft_list_push_front
|
||||
extern malloc
|
||||
|
||||
section .text
|
||||
|
||||
ft_list_push_front:
|
||||
test rdi, rdi
|
||||
je err
|
||||
|
||||
push rdi
|
||||
push rsi
|
||||
mov rdi, 10
|
||||
call malloc wrt ..plt
|
||||
pop rsi
|
||||
pop rdi
|
||||
|
||||
test rax, rax ; did malloc return 0
|
||||
je err
|
||||
|
||||
push rdi
|
||||
mov rdi, [rdi]
|
||||
mov [rax + 8], rdi ;set both settings
|
||||
mov [rax], rsi
|
||||
pop rdi
|
||||
|
||||
mov [rdi], rax
|
||||
|
||||
err:
|
||||
ret
|
19
srcs/bonus/ft_list_size.s
Normal file
19
srcs/bonus/ft_list_size.s
Normal file
@ -0,0 +1,19 @@
|
||||
global ft_list_size
|
||||
|
||||
section .text
|
||||
|
||||
ft_list_size:
|
||||
xor rax, rax
|
||||
|
||||
count_start:
|
||||
test rdi, rdi
|
||||
je end
|
||||
|
||||
mov rdi, [rdi + 8]
|
||||
|
||||
lea rax, [rax + 1]
|
||||
|
||||
jmp count_start
|
||||
|
||||
end:
|
||||
ret
|
Reference in New Issue
Block a user