From f4c8ec9028f19fe334ecd4ae49521011fcdba012 Mon Sep 17 00:00:00 2001 From: Christian Cunningham Date: Sun, 14 Jul 2024 09:54:54 -0700 Subject: Single Linked List Impl --- linked_list.inc | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'linked_list.inc') diff --git a/linked_list.inc b/linked_list.inc index 76a3956..4fbb923 100644 --- a/linked_list.inc +++ b/linked_list.inc @@ -15,20 +15,30 @@ dll_prev: resq 1 dll_value: resq 1 endstruc -%macro alloc_lln 0 +%macro lln_alloc 0 alloc LinkedListNode_size + mov qword [rax + ll_next], 0 %endmacro -%macro alloc_dlln 0 +%macro dlln_alloc 0 alloc DoublyLinkedListNode_size + mov qword [rax + dll_next], 0 %endmacro -%macro free_lln 0-1 rax +%macro lln_free 0-1 rax free %1, LinkedListNode_size %endmacro -%macro free_dlln 0-1 rax +%macro dlln_free 0-1 rax free %1, DoublyLinkedListNode_size %endmacro +%macro ll_push 2 + ;; %1 = Current Linked List Node + ;; %2 = Value to push (Must fit in a register, larger must be pushed as pointer to the underlying structure) + lln_alloc + mov qword [%1 + ll_next], rax + mov qword [rax + ll_value], %2 +%endm + %endif -- cgit v1.2.1