Subversion Repositories Kolibri OS

Rev

Rev 7134 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 7134 Rev 7649
1
;------------------------------------------------------------------------------
1
;------------------------------------------------------------------------------
2
;///// SORTING ////////////////////////////////////////////////////////////////
2
;///// SORTING ////////////////////////////////////////////////////////////////
3
;------------------------------------------------------------------------------
3
;------------------------------------------------------------------------------
4
 
4
 
5
r_sort db 1
5
r_sort db 1
6
l_sort db 1
6
l_sort db 1
7
 
7
 
8
align 4
8
align 4
9
 compare_table:
9
 compare_table:
10
  dd compare_by_name
10
  dd compare_by_name
11
  dd compare_by_extension
11
  dd compare_by_extension
12
 
12
 
13
; AL = panel
13
; AL = panel
14
__func mfar_sort
14
func mfar_sort
15
        pusha
15
        pusha
16
        cmp     al,0
16
        cmp     al,0
17
        jne    ._00
17
        jne    ._00
18
        mov     eax,[d_lcnt]
18
        mov     eax,[d_lcnt]
19
        mov     edi,lstart
19
        mov     edi,lstart
20
        movzx   edx,[l_sort]
20
        movzx   edx,[l_sort]
21
        jmp     @f
21
        jmp     @f
22
   ._00:
22
   ._00:
23
        mov     eax,[d_rcnt]
23
        mov     eax,[d_rcnt]
24
        mov     edi,rstart
24
        mov     edi,rstart
25
        movzx   edx,[r_sort]
25
        movzx   edx,[r_sort]
26
    @@:
26
    @@:
27
        mov     edx,[edx*4+compare_table]
27
        mov     edx,[edx*4+compare_table]
28
        cmp     eax,2
28
        cmp     eax,2
29
        jbe    .exit
29
        jbe    .exit
30
        dec     eax
30
        dec     eax
31
        shl     eax,4
31
        shl     eax,4
32
        add     eax,edi
32
        add     eax,edi
33
        cmp     word[edi],'..'
33
        cmp     word[edi],'..'
34
        jne     @f
34
        jne     @f
35
        add     edi,16
35
        add     edi,16
36
    @@:
36
    @@:
37
        push    edi
37
        push    edi
38
        mov     esi,edi
38
        mov     esi,edi
39
        add     edi,16
39
        add     edi,16
40
   .next_file:
40
   .next_file:
41
        call    edx
41
        call    edx
42
        add     edi,16
42
        add     edi,16
43
        cmp     edi,eax
43
        cmp     edi,eax
44
        jbe    .next_file
44
        jbe    .next_file
45
 
45
 
46
        mov     ebx,12
46
        mov     ebx,12
47
    @@:
47
    @@:
48
        mov     ecx,[ebx+eax]
48
        mov     ecx,[ebx+eax]
49
        xchg    [ebx+esi],ecx
49
        xchg    [ebx+esi],ecx
50
        mov     [ebx+eax],ecx
50
        mov     [ebx+eax],ecx
51
        sub     ebx,4
51
        sub     ebx,4
52
        jge     @b
52
        jge     @b
53
 
53
 
54
        mov     esi,[esp]
54
        mov     esi,[esp]
55
        mov     edi,esi
55
        mov     edi,esi
56
        add     edi,16
56
        add     edi,16
57
 
57
 
58
        sub     eax,16
58
        sub     eax,16
59
        cmp     eax,edi
59
        cmp     eax,edi
60
        jge    .next_file
60
        jge    .next_file
61
        pop     edi
61
        pop     edi
62
 
62
 
63
 .exit:
63
 .exit:
64
        popad
64
        popad
65
        ret
65
        ret
66
endf
66
endf
67
 
67
 
68
;------------------------------------------------------------------------------
68
;------------------------------------------------------------------------------
69
 
69
 
70
; ESI = pointer to 1st file info
70
; ESI = pointer to 1st file info
71
; EDI = pointer to 2nd file info
71
; EDI = pointer to 2nd file info
72
__func compare_by_name
72
func compare_by_name
73
        mov     ecx,11
73
        mov     ecx,11
74
        push    edi esi
74
        push    edi esi
75
        repe    cmpsb
75
        repe    cmpsb
76
        pop     esi edi
76
        pop     esi edi
77
        pushfd
77
        pushfd
78
        test    byte[esi+11],FA_FOLDER
78
        test    byte[esi+11],FA_FOLDER
79
        jnz    ._00
79
        jnz    ._00
80
        test    byte[edi+11],FA_FOLDER
80
        test    byte[edi+11],FA_FOLDER
81
        jz     ._01
81
        jz     ._01
82
        jmp    ._03
82
        jmp    ._03
83
   ._00:
83
   ._00:
84
        test    byte[edi+11],FA_FOLDER
84
        test    byte[edi+11],FA_FOLDER
85
        jz     ._02
85
        jz     ._02
86
   ._01:
86
   ._01:
87
        popfd
87
        popfd
88
        jg     ._04
88
        jg     ._04
89
        mov     esi,edi
89
        mov     esi,edi
90
        ret
90
        ret
91
   ._02:
91
   ._02:
92
        popfd
92
        popfd
93
        mov     esi,edi
93
        mov     esi,edi
94
        ret
94
        ret
95
   ._03:
95
   ._03:
96
        popfd
96
        popfd
97
   ._04:
97
   ._04:
98
        ret
98
        ret
99
endf
99
endf
100
 
100
 
101
;------------------------------------------------------------------------------
101
;------------------------------------------------------------------------------
102
 
102
 
103
; ESI = pointer to 1st file info
103
; ESI = pointer to 1st file info
104
; EDI = pointer to 2nd file info
104
; EDI = pointer to 2nd file info
105
__func compare_by_extension
105
func compare_by_extension
106
        push    edi esi
106
        push    edi esi
107
        mov     ecx,3
107
        mov     ecx,3
108
        add     esi,8
108
        add     esi,8
109
        add     edi,8
109
        add     edi,8
110
        repe    cmpsb
110
        repe    cmpsb
111
        jne    ._00
111
        jne    ._00
112
        mov     esi,[esp]
112
        mov     esi,[esp]
113
        mov     edi,[esp+4]
113
        mov     edi,[esp+4]
114
        mov     ecx,8
114
        mov     ecx,8
115
        repe    cmpsb
115
        repe    cmpsb
116
   ._00:
116
   ._00:
117
        pop     esi edi
117
        pop     esi edi
118
        pushfd
118
        pushfd
119
        test    byte[esi+11],FA_FOLDER
119
        test    byte[esi+11],FA_FOLDER
120
        jnz    ._01
120
        jnz    ._01
121
        test    byte[edi+11],FA_FOLDER
121
        test    byte[edi+11],FA_FOLDER
122
        jz     ._02
122
        jz     ._02
123
        jmp    ._04
123
        jmp    ._04
124
   ._01:
124
   ._01:
125
        test    byte[edi+11],FA_FOLDER
125
        test    byte[edi+11],FA_FOLDER
126
        jz     ._03
126
        jz     ._03
127
   ._02:
127
   ._02:
128
        popfd
128
        popfd
129
        jg     ._05
129
        jg     ._05
130
        mov     esi,edi
130
        mov     esi,edi
131
        ret
131
        ret
132
   ._03:
132
   ._03:
133
        popfd
133
        popfd
134
        mov     esi,edi
134
        mov     esi,edi
135
        ret
135
        ret
136
   ._04:
136
   ._04:
137
        popfd
137
        popfd
138
   ._05:
138
   ._05:
139
        ret
139
        ret
140
endf
140
endf