Rev 4979 | Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
4975 | gtament | 1 | head dd 1 |
2 | node equ ftdi_context |
||
3 | node.next equ ftdi_context.next_context |
||
4 | linkedlist: |
||
5 | .init: |
||
6 | push eax |
||
7 | xor eax, eax |
||
8 | mov [head], eax |
||
9 | pop eax |
||
10 | ret |
||
11 | |||
12 | .add: |
||
13 | push ebx |
||
14 | mov ebx, [head] |
||
15 | mov [head], eax |
||
16 | mov [eax + node.next], ebx |
||
17 | pop ebx |
||
18 | ret |
||
19 | |||
20 | .delete: |
||
21 | push ebx ecx |
||
22 | mov ebx, eax ; eax - pointer to node for delete |
||
23 | cmp eax, [head] |
||
24 | jz .unlink_head |
||
25 | |||
26 | .getnext: |
||
27 | cmp [ebx+node.next], eax |
||
28 | jz .unlink |
||
29 | cmp [ebx+node.next], 0 |
||
30 | jz .invalid_pointer |
||
31 | mov ebx, [ebx+node.next] |
||
32 | jmp .getnext |
||
33 | |||
34 | .unlink: |
||
35 | mov ecx, [eax+node.next] |
||
36 | mov [ebx+node.next], ecx |
||
37 | jmp @f |
||
38 | |||
39 | |||
40 | .unlink_head: |
||
41 | mov ebx, [eax+node.next] |
||
42 | mov [head], ebx |
||
43 | @@: |
||
44 | mov ecx, eax |
||
45 | call Kfree |
||
46 | .invalid_pointer: |
||
47 | pop ecx ebx |
||
48 | ret |
||
49 | |||
50 | .gethead: |
||
51 | mov eax, [head] |
||
52 | ret |
||
53 | |||
54 | restore node |
||
55 | restore next |