2014-06-17 19:43:10 +02:00
|
|
|
head dd 0
|
2014-06-14 23:01:22 +02:00
|
|
|
node equ ftdi_context
|
|
|
|
node.next equ ftdi_context.next_context
|
|
|
|
linkedlist:
|
|
|
|
|
|
|
|
.add:
|
2014-06-17 19:43:10 +02:00
|
|
|
push ebx
|
|
|
|
mov ebx, [head]
|
|
|
|
mov [head], eax
|
|
|
|
mov [eax + node.next], ebx
|
|
|
|
pop ebx
|
|
|
|
ret
|
2014-06-14 23:01:22 +02:00
|
|
|
|
|
|
|
.delete:
|
2014-06-17 19:43:10 +02:00
|
|
|
push ebx ecx
|
|
|
|
mov ebx, eax ; eax - pointer to node for delete
|
|
|
|
cmp eax, [head]
|
|
|
|
jz .unlink_head
|
2014-06-14 23:01:22 +02:00
|
|
|
|
|
|
|
.getnext:
|
2014-06-17 19:43:10 +02:00
|
|
|
cmp [ebx+node.next], eax
|
|
|
|
jz .unlink
|
|
|
|
cmp [ebx+node.next], 0
|
|
|
|
jz .invalid_pointer
|
|
|
|
mov ebx, [ebx+node.next]
|
|
|
|
jmp .getnext
|
2014-06-14 23:01:22 +02:00
|
|
|
|
|
|
|
.unlink:
|
2014-06-17 19:43:10 +02:00
|
|
|
mov ecx, [eax+node.next]
|
|
|
|
mov [ebx+node.next], ecx
|
|
|
|
jmp @f
|
2014-06-14 23:01:22 +02:00
|
|
|
|
|
|
|
|
|
|
|
.unlink_head:
|
2014-06-17 19:43:10 +02:00
|
|
|
mov ebx, [eax+node.next]
|
|
|
|
mov [head], ebx
|
2014-06-14 23:01:22 +02:00
|
|
|
@@:
|
2014-06-17 19:43:10 +02:00
|
|
|
mov ecx, eax
|
|
|
|
call Kfree
|
2014-06-14 23:01:22 +02:00
|
|
|
.invalid_pointer:
|
2014-06-17 19:43:10 +02:00
|
|
|
pop ecx ebx
|
|
|
|
ret
|
2014-06-14 23:01:22 +02:00
|
|
|
|
|
|
|
.gethead:
|
2014-06-17 19:43:10 +02:00
|
|
|
mov eax, [head]
|
|
|
|
ret
|
2014-06-14 23:01:22 +02:00
|
|
|
|
|
|
|
restore node
|
2014-06-17 19:43:10 +02:00
|
|
|
restore node.next
|