%ifndef LINKED_LIST_INC %define LINKED_LIST_INC %ifndef ALLOC_INC %include "alloc.inc" %endif struc LinkedListNode ll_next: resq 1 ll_value: resq 1 endstruc struc DoublyLinkedListNode dll_next: resq 1 dll_prev: resq 1 dll_value: resq 1 endstruc %macro lln_alloc 0 alloc LinkedListNode_size mov qword [rax + ll_next], 0 %endmacro %macro dlln_alloc 0 alloc DoublyLinkedListNode_size mov qword [rax + dll_next], 0 %endmacro %macro lln_free 0-1 rax free %1, LinkedListNode_size %endmacro %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