Document the new Copy Profile button.
[obnox/wireshark/wip.git] / epan / asm_utils_win32_x86.asm
1 ; asm_utils_win32_x86.asm
2 ; Functions optionally implemented in assembler
3 ;
4 ; $Id$
5 ;
6 ; Wireshark - Network traffic analyzer
7 ; By Gerald Combs <gerald@wireshark.org>
8 ; Copyright 1998 Gerald Combs
9 ;
10 ; This program is free software; you can redistribute it and/or
11 ; modify it under the terms of the GNU General Public License
12 ; as published by the Free Software Foundation; either version 2
13 ; of the License, or (at your option) any later version.
14 ;
15 ; This program is distributed in the hope that it will be useful,
16 ; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 ; GNU General Public License for more details.
19 ;
20 ; You should have received a copy of the GNU General Public License
21 ; along with this program; if not, write to the Free Software
22 ; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
23 ;
24
25 SECTION .text
26
27 GLOBAL _wrs_strcmp
28 GLOBAL _wrs_strcmp_with_data
29 GLOBAL _wrs_str_equal
30 GLOBAL _wrs_check_charset
31 GLOBAL _wrs_str_hash
32
33     align 16
34 _wrs_strcmp:
35 _wrs_strcmp_with_data:
36     mov ecx, dword [esp + 4]  ; a
37     mov edx, dword [esp + 8]  ; b
38     push ebx
39 CMP_LOOP:
40     mov eax, dword [ecx]
41     mov ebx, dword [edx]
42     cmp al, bl
43     jne CMP_NEQ_END
44     or al, al
45     jz CMP_EQ_END
46     cmp ah, bh
47     jne CMP_NEQ_END
48     or ah, ah
49     jz CMP_EQ_END
50     shr eax, 16
51     shr ebx, 16
52     add ecx, byte 4
53     add edx, byte 4
54     cmp al, bl
55     jne CMP_NEQ_END
56     or al, al
57     jz CMP_EQ_END
58     cmp ah, bh
59     jne CMP_NEQ_END
60     or ah, ah
61     jnz CMP_LOOP
62 CMP_EQ_END:
63     pop ebx
64     xor eax, eax
65     retn
66 CMP_NEQ_END:  
67     ; returns 1 or -1 based on CF flag from the last comparision
68     sbb eax, eax
69     pop ebx
70     shl eax, 1
71     inc eax
72     retn
73
74     align 16
75 _wrs_str_equal:
76     mov ecx, dword [esp + 4]  ; a
77     mov edx, dword [esp + 8]  ; b
78     push ebx
79 EQL_LOOP:
80     mov eax, dword [ecx]
81     mov ebx, dword [edx]
82     cmp al, bl
83     jne EQL_NEQ_END
84     or al, al
85     jz EQL_EQ_END
86     cmp ah, bh
87     jne EQL_NEQ_END
88     or ah, ah
89     jz EQL_EQ_END
90     shr eax, 16
91     shr ebx, 16
92     add ecx, byte 4
93     add edx, byte 4
94     cmp al, bl
95     jne EQL_NEQ_END
96     or al, al
97     jz EQL_EQ_END
98     cmp ah, bh
99     jne EQL_NEQ_END
100     or ah, ah
101     jnz EQL_LOOP
102 EQL_EQ_END:
103     xor eax, eax
104     pop ebx
105     not eax
106     retn
107 EQL_NEQ_END:  
108     pop ebx
109     xor eax, eax
110     retn
111
112     align 16
113 _wrs_check_charset:
114     mov edx, dword [esp + 4]  ; table
115     mov ecx, dword [esp + 8]  ; str
116     push edi
117     push ebx
118     mov edi, edx
119     mov bl, byte 0xFF
120 CHK_LOOP:
121     mov eax, dword [ecx]
122     movzx edx, al
123     test bl, byte [edi+edx]
124     jz CHK_AL_END
125     movzx edx, ah
126     test bl, byte [edi+edx]
127     jz CHK_AH_END
128     shr eax, 16
129     add ecx, byte 4
130     movzx edx, al
131     test bl, byte [edi+edx]
132     jz CHK_AL_END
133     movzx edx, ah
134     test bl, byte [edi+edx]
135     jnz CHK_LOOP
136 CHK_AH_END:
137     movzx eax, ah
138     pop ebx
139     pop edi
140     retn
141 CHK_AL_END:
142     movzx eax, al
143     pop ebx
144     pop edi
145     retn
146
147     align 16
148 _wrs_str_hash:
149     mov edx, dword [esp + 4]  ; v
150     push ebx
151     xor eax, eax
152     mov ecx, dword [edx]
153     or cl, cl
154     movzx ebx, cl
155     jz HASH_END
156 HASH_LOOP:
157     sub ebx, eax
158     shl eax, 5
159     add eax, ebx
160     or ch, ch
161     movzx ebx, ch
162     jz HASH_END
163     sub ebx, eax
164     shl eax, 5
165     add eax, ebx
166     shr ecx, 16
167     add edx, byte 4
168     or cl, cl
169     movzx ebx, cl
170     jz HASH_END
171     sub ebx, eax
172     shl eax, 5
173     add eax, ebx
174     or ch, ch
175     movzx ebx, ch
176     jz HASH_END
177     sub ebx, eax
178     shl eax, 5
179     add eax, ebx
180     mov ecx, dword [edx]
181     or cl, cl
182     movzx ebx, cl
183     jnz HASH_LOOP
184 HASH_END:
185     pop ebx
186     retn