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