blob: 4fbb923fc5c3ff7765ee02f7e59c9a672778c8d1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
%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
|