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