59 lines
910 B
ArmAsm
59 lines
910 B
ArmAsm
global ft_list_push_front
|
|
extern malloc
|
|
extern ft_memcpy
|
|
|
|
struc list
|
|
.data resq 1
|
|
.next resq 1
|
|
endstruc
|
|
%define NODE_SIZE 16
|
|
|
|
section .text
|
|
;#include <stdlib.h>
|
|
;#include "ft_list.h"
|
|
;
|
|
;void ft_list_push_front(t_list **begin_list, void *data)
|
|
;{
|
|
; t_list *new_elem;
|
|
;
|
|
; if (!begin_list)
|
|
; return ;
|
|
; new_elem = (t_list *)malloc(sizeof(t_list));
|
|
; if (!new_elem)
|
|
; return ;
|
|
; new_elem->data = data;
|
|
; new_elem->next = *begin_list;
|
|
; *begin_list = new_elem;
|
|
;}
|
|
|
|
; rdi: t_list **begin_list
|
|
; rsi: void *data
|
|
ft_list_push_front:
|
|
; if NULL == begin_list return
|
|
test rdi, rdi
|
|
je .done
|
|
|
|
push rdi
|
|
push rsi
|
|
|
|
; malloc 16
|
|
mov rdi, NODE_SIZE
|
|
call malloc wrt ..plt
|
|
|
|
pop rsi
|
|
pop rdi
|
|
|
|
; if NULL == rax return
|
|
test rax, rax
|
|
je .done
|
|
|
|
; new_elem->data = data;
|
|
; new_elem->next = *begin_list;
|
|
; *begin_list = new_elem;
|
|
mov [rax], rsi
|
|
mov rdx, [rdi]
|
|
mov [rax + list.next], rdx
|
|
mov [rdi], rax
|
|
|
|
.done:
|
|
ret
|