2014-07-16 19:40:12 +02:00
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
;; ;;
|
2015-01-08 21:10:22 +01:00
|
|
|
;; Copyright (C) KolibriOS team 2004-2015. All rights reserved. ;;
|
2014-07-16 19:40:12 +02:00
|
|
|
;; Distributed under terms of the GNU General Public License ;;
|
|
|
|
;; ;;
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
2014-08-17 20:45:31 +02:00
|
|
|
head dd 0
|
2014-06-14 23:01:22 +02:00
|
|
|
|
2014-07-16 19:40:12 +02:00
|
|
|
linkedlist_add:
|
2014-08-17 20:45:31 +02:00
|
|
|
push ebx
|
2014-09-02 22:15:13 +02:00
|
|
|
mov ebx, [head]
|
|
|
|
mov [head], eax
|
|
|
|
mov [eax + node.next], ebx
|
2014-08-17 20:45:31 +02:00
|
|
|
pop ebx
|
2014-09-02 22:15:13 +02:00
|
|
|
ret
|
2014-06-14 23:01:22 +02:00
|
|
|
|
2014-09-02 22:15:13 +02:00
|
|
|
linkedlist_unlink:
|
2014-08-17 20:45:31 +02:00
|
|
|
push ebx ecx
|
2014-09-02 22:15:13 +02:00
|
|
|
test eax, eax
|
|
|
|
jz .invalid_pointer
|
|
|
|
mov ebx, eax ; eax - pointer to node for unlink
|
|
|
|
cmp eax, [head]
|
|
|
|
jz .unlink_head
|
2014-06-14 23:01:22 +02:00
|
|
|
.getnext:
|
2014-09-02 22:15:13 +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-09-02 22:15:13 +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-09-02 22:15:13 +02:00
|
|
|
mov ebx, [eax+node.next]
|
|
|
|
mov [head], ebx
|
2014-06-14 23:01:22 +02:00
|
|
|
@@:
|
|
|
|
.invalid_pointer:
|
2014-08-17 20:45:31 +02:00
|
|
|
pop ecx ebx
|
2014-09-02 22:15:13 +02:00
|
|
|
ret
|
2014-07-16 19:40:12 +02:00
|
|
|
|
2014-08-08 20:00:40 +02:00
|
|
|
linkedlist_isvalid: ;eax - pointer to check; returns zero if valid
|
2014-08-17 20:45:31 +02:00
|
|
|
push ebx ecx
|
|
|
|
xor ecx, ecx
|
|
|
|
test eax, eax
|
|
|
|
jz .invalid_pointer
|
|
|
|
mov ebx, [head]
|
2014-07-16 19:40:12 +02:00
|
|
|
.next_check:
|
2014-08-17 20:45:31 +02:00
|
|
|
cmp eax, ebx
|
|
|
|
jz .valid_pointer
|
|
|
|
mov ebx, [ebx + node.next]
|
|
|
|
test ebx, ebx
|
|
|
|
jz .invalid_pointer
|
|
|
|
jmp .next_check
|
2014-07-16 19:40:12 +02:00
|
|
|
.invalid_pointer:
|
2014-08-17 20:45:31 +02:00
|
|
|
inc ecx
|
2014-07-16 19:40:12 +02:00
|
|
|
.valid_pointer:
|
2014-08-17 20:45:31 +02:00
|
|
|
mov eax, ecx
|
|
|
|
pop ecx ebx
|
2014-07-16 19:40:12 +02:00
|
|
|
ret
|
2014-06-14 23:01:22 +02:00
|
|
|
|
2014-07-16 19:40:12 +02:00
|
|
|
linkedlist_gethead:
|
2014-09-02 22:15:13 +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
|