aboutsummaryrefslogtreecommitdiff
path: root/ft_list_push_front.s
diff options
context:
space:
mode:
Diffstat (limited to 'ft_list_push_front.s')
-rw-r--r--ft_list_push_front.s27
1 files changed, 21 insertions, 6 deletions
diff --git a/ft_list_push_front.s b/ft_list_push_front.s
index 686ee10..320c49c 100644
--- a/ft_list_push_front.s
+++ b/ft_list_push_front.s
@@ -10,13 +10,28 @@
; ;
; **************************************************************************** ;
-global _ft_list_push_front
+extern _malloc
+
+global ft_list_push_front
; void ft_list_push_front(t_list **begin_list, void *data);
-_ft_list_push_front:
- cmp rdi, 0
- je FT_LIST_PUSH_FRONT_END
- mov [rsi + 8], [rdi]
- mov [rdi], rsi
+ft_list_push_front:
+ cmp rdi, 0
+ je FT_LIST_PUSH_FRONT_END
+
+ push rdi
+ push rsi
+ xor rdi, rdi
+ mov edi, 16
+ call _malloc
+ pop rsi
+ pop rdi
+ cmp rax, 0
+ je FT_LIST_PUSH_FRONT_END
+
+ mov qword [rax + 0], rsi
+ mov r10, [rdi]
+ mov [rax + 8], r10
+ mov [rdi], rax
FT_LIST_PUSH_FRONT_END:
ret