Rev 5907 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 5907 | Rev 5913 | ||
---|---|---|---|
1 | proc string.length uses ebx, _str |
1 | proc string.length uses ebx, _str |
2 | mov eax, 0 |
2 | mov eax, 0 |
3 | mov ebx, [_str] |
3 | mov ebx, [_str] |
4 | @@: |
4 | @@: |
5 | cmp [ebx], byte 0 |
5 | cmp [ebx], byte 0 |
6 | je @f |
6 | je @f |
7 | inc eax |
7 | inc eax |
8 | inc ebx |
8 | inc ebx |
9 | jmp @b |
9 | jmp @b |
10 | @@: |
10 | @@: |
11 | ret |
11 | ret |
12 | endp |
12 | endp |
13 | 13 | ||
14 | proc string.copy uses eax ebx ecx, _src, _dst |
14 | proc string.copy uses eax ebx ecx, _src, _dst |
15 | mov eax, [_src] |
15 | mov eax, [_src] |
16 | mov ebx, [_dst] |
16 | mov ebx, [_dst] |
17 | @@: |
17 | @@: |
18 | mov cl, [eax] |
18 | mov cl, [eax] |
19 | mov [ebx], cl |
19 | mov [ebx], cl |
20 | cmp cl, 0 |
20 | cmp cl, 0 |
21 | je @f |
21 | je @f |
22 | inc eax |
22 | inc eax |
23 | inc ebx |
23 | inc ebx |
24 | jmp @b |
24 | jmp @b |
25 | @@: |
25 | @@: |
26 | ret |
26 | ret |
27 | endp |
27 | endp |
28 | 28 | ||
29 | proc string.concatenate uses eax, _src, _dst |
29 | proc string.concatenate uses eax, _src, _dst |
30 | stdcall string.length, [_dst] |
30 | stdcall string.length, [_dst] |
31 | add eax, [_dst] |
31 | add eax, [_dst] |
32 | stdcall string.copy, [_src], eax |
32 | stdcall string.copy, [_src], eax |
33 | ret |
33 | ret |
34 | endp |
34 | endp |
35 | - | ||
36 | proc string.compare uses ebx ecx edx, _str1, _str2 |
- | |
37 | mov eax, 0 |
- | |
38 | mov ebx, [_str1] |
- | |
39 | mov ecx, [_str2] |
- | |
40 | @@: |
- | |
41 | mov dl, [ebx] |
- | |
42 | cmp dl, [ecx] |
- | |
43 | jne .not_eq |
- | |
44 | cmp dl, 0 |
- | |
45 | je @f |
- | |
46 | cmp [ecx], byte 0 |
- | |
47 | je @f |
- | |
48 | inc ebx |
- | |
49 | inc ecx |
- | |
50 | jmp @b |
- | |
51 | .not_eq: |
- | |
52 | mov eax, -1 |
- | |
53 | @@: |
- | |
54 | inc eax |
- | |
55 | ret |
- | |
56 | endp |
- | |
57 | 35 | ||
58 | proc string.cmp uses ecx esi edi, _str1, _str2, _n |
36 | proc string.cmp uses ecx esi edi, _str1, _str2, _n |
59 | mov ecx, [_n] |
37 | mov ecx, [_n] |
60 | test ecx, ecx ; Max length is zero? |
38 | test ecx, ecx ; Max length is zero? |
61 | je .done |
39 | je .done |
62 | 40 | ||
63 | mov esi, [_str1] ; esi = string s1 |
41 | mov esi, [_str1] ; esi = string s1 |
64 | mov edi, [_str2] ; edi = string s2 |
42 | mov edi, [_str2] ; edi = string s2 |
65 | cld |
43 | cld |
66 | .compare: |
44 | .compare: |
67 | cmpsb ; Compare two bytes |
45 | cmpsb ; Compare two bytes |
68 | jne .done |
46 | jne .done |
69 | cmp byte [esi-1], 0 ; End of string? |
47 | cmp byte [esi-1], 0 ; End of string? |
70 | je .done |
48 | je .done |
71 | dec ecx ; Length limit reached? |
49 | dec ecx ; Length limit reached? |
72 | jne .compare |
50 | jne .compare |
73 | .done: |
51 | .done: |
74 | seta al ; al = (s1 > s2) |
52 | seta al ; al = (s1 > s2) |
75 | setb ah ; ah = (s1 < s2) |
53 | setb ah ; ah = (s1 < s2) |
76 | sub al, ah |
54 | sub al, ah |
77 | movsx eax, al ; eax = (s1 > s2) - (s1 < s2), i.e. -1, 0, 1 |
55 | movsx eax, al ; eax = (s1 > s2) - (s1 < s2), i.e. -1, 0, 1 |
78 | ret |
56 | ret |
79 | endp |
57 | endp |
80 | 58 | ||
81 | proc string.to_lower_case uses eax, _str |
59 | proc string.to_lower_case uses eax, _str |
82 | mov eax, [_str] |
60 | mov eax, [_str] |
83 | @@: |
61 | @@: |
84 | cmp [eax], byte 0 |
62 | cmp [eax], byte 0 |
85 | je @f |
63 | je @f |
86 | cmp [eax], byte 65 |
64 | cmp [eax], byte 65 |
87 | jl .next |
65 | jl .next |
88 | cmp [eax], byte 90 |
66 | cmp [eax], byte 90 |
89 | jg .next |
67 | jg .next |
90 | add [eax], byte 97 - 65 |
68 | add [eax], byte 97 - 65 |
91 | .next: |
69 | .next: |
92 | inc eax |
70 | inc eax |
93 | jmp @b |
71 | jmp @b |
94 | @@: |
72 | @@: |
95 | ret |
73 | ret |
96 | endp |
74 | endp |
97 | 75 | ||
98 | proc string.to_upper_case uses eax, _str |
76 | proc string.to_upper_case uses eax, _str |
99 | mov eax, [_str] |
77 | mov eax, [_str] |
100 | @@: |
78 | @@: |
101 | cmp [eax], byte 0 |
79 | cmp [eax], byte 0 |
102 | je @f |
80 | je @f |
103 | cmp [eax], byte 97 |
81 | cmp [eax], byte 97 |
104 | jl .next |
82 | jl .next |
105 | cmp [eax], byte 122 |
83 | cmp [eax], byte 122 |
106 | jg .next |
84 | jg .next |
107 | sub [eax], byte 97 - 65 |
85 | sub [eax], byte 97 - 65 |
108 | .next: |
86 | .next: |
109 | inc eax |
87 | inc eax |
110 | jmp @b |
88 | jmp @b |
111 | @@: |
89 | @@: |
112 | ret |
90 | ret |
113 | endp |
91 | endp |
114 | 92 | ||
115 | proc string.match uses ebx ecx edx, _str1, _str2 |
93 | proc string.match uses ebx ecx edx, _str1, _str2 |
116 | mov ebx, [_str1] |
94 | mov ebx, [_str1] |
117 | mov ecx, [_str2] |
95 | mov ecx, [_str2] |
118 | @@: |
96 | @@: |
119 | cmp [ebx], byte 0 |
97 | cmp [ebx], byte 0 |
120 | je @f |
98 | je @f |
121 | cmp [ecx], byte 0 |
99 | cmp [ecx], byte 0 |
122 | je @f |
100 | je @f |
123 | 101 | ||
124 | mov dl, [ebx] |
102 | mov dl, [ebx] |
125 | cmp [ecx], byte '?' |
103 | cmp [ecx], byte '?' |
126 | je .next |
104 | je .next |
127 | cmp [ecx], byte '*' |
105 | cmp [ecx], byte '*' |
128 | je .next_ebx |
106 | je .next_ebx |
129 | cmp [ecx], dl |
107 | cmp [ecx], dl |
130 | je .next |
108 | je .next |
131 | 109 | ||
132 | cmp [ecx - 1], byte '*' |
110 | cmp [ecx - 1], byte '*' |
133 | je .next_ecx |
111 | je .next_ecx |
134 | 112 | ||
135 | jmp @f |
113 | jmp @f |
136 | 114 | ||
137 | .next_ecx: |
115 | .next_ecx: |
138 | dec ecx |
116 | dec ecx |
139 | jmp .next |
117 | jmp .next |
140 | .next_ebx: |
118 | .next_ebx: |
141 | dec ebx |
119 | dec ebx |
142 | .next: |
120 | .next: |
143 | inc ebx |
121 | inc ebx |
144 | inc ecx |
122 | inc ecx |
145 | jmp @b |
123 | jmp @b |
146 | @@: |
124 | @@: |
147 | 125 | ||
148 | @@: |
126 | @@: |
149 | cmp [ecx], byte 0 |
127 | cmp [ecx], byte 0 |
150 | je @f |
128 | je @f |
151 | cmp [ecx], byte '*' |
129 | cmp [ecx], byte '*' |
152 | jne @f |
130 | jne @f |
153 | inc ecx |
131 | inc ecx |
154 | jmp @b |
132 | jmp @b |
155 | @@: |
133 | @@: |
156 | 134 | ||
157 | cmp [ecx], byte 0 |
135 | cmp [ecx], byte 0 |
158 | je @f |
136 | je @f |
159 | mov eax, 0 |
137 | mov eax, 0 |
160 | ret |
138 | ret |
161 | @@: |
139 | @@: |
162 | mov eax, 1 |
140 | mov eax, 1 |
163 | ret |
141 | ret |
164 | endp |
142 | endp |
165 | 143 | ||
166 | proc string.trim_last uses eax, _str |
144 | proc string.trim_last uses eax, _str |
167 | stdcall string.length, [_str] |
145 | stdcall string.length, [_str] |
168 | add eax, [_str] |
146 | add eax, [_str] |
169 | dec eax |
147 | dec eax |
170 | @@: |
148 | @@: |
171 | cmp [eax], byte ' ' |
149 | cmp [eax], byte ' ' |
172 | jne @f |
150 | jne @f |
173 | mov [eax], byte 0 |
151 | mov [eax], byte 0 |
174 | dec eax |
152 | dec eax |
175 | jmp @b |
153 | jmp @b |
176 | @@: |
154 | @@: |
177 | ret |
155 | ret |
178 | endp |
156 | endp |
179 | 157 | ||
180 | proc string.trim_first, _str |
158 | proc string.trim_first, _str |
181 | mov eax, [_str] |
159 | mov eax, [_str] |
182 | @@: |
160 | @@: |
183 | cmp [eax], byte ' ' |
161 | cmp [eax], byte ' ' |
184 | jne @f |
162 | jne @f |
185 | inc eax |
163 | inc eax |
186 | jmp @b |
164 | jmp @b |
187 | @@: |
165 | @@: |
188 | ret |
166 | ret |
189 | endp |
167 | endp |
190 | 168 | ||
191 | proc string.index_of uses ebx ecx, _str, _char, _num |
169 | proc string.index_of uses ebx ecx, _str, _char, _num |
192 | mov ebx, [_char] |
170 | mov ebx, [_char] |
193 | mov ecx, [_str] |
171 | mov ecx, [_str] |
194 | mov eax, 0 |
172 | mov eax, 0 |
195 | @@: |
173 | @@: |
196 | cmp [ecx], byte 0 |
174 | cmp [ecx], byte 0 |
197 | je @f |
175 | je @f |
198 | cmp [ecx], bl |
176 | cmp [ecx], bl |
199 | jne .after_check |
177 | jne .after_check |
200 | dec [_num] |
178 | dec [_num] |
201 | jz .finded |
179 | jz .finded |
202 | .after_check: |
180 | .after_check: |
203 | inc ecx |
181 | inc ecx |
204 | inc eax |
182 | inc eax |
205 | jmp @b |
183 | jmp @b |
206 | @@: |
184 | @@: |
207 | mov eax, -1 |
185 | mov eax, -1 |
208 | .finded: |
186 | .finded: |
209 | ret |
187 | ret |
210 | endp |
188 | endp |
211 | 189 | ||
212 | proc string.last_index_of uses ebx ecx, _str, _char, _num |
190 | proc string.last_index_of uses ebx ecx, _str, _char, _num |
213 | stdcall string.length, [_str] |
191 | stdcall string.length, [_str] |
214 | mov ecx, [_str] |
192 | mov ecx, [_str] |
215 | add ecx, eax |
193 | add ecx, eax |
216 | mov ebx, [_char] |
194 | mov ebx, [_char] |
217 | @@: |
195 | @@: |
218 | cmp eax, 0 |
196 | cmp eax, 0 |
219 | je @f |
197 | je @f |
220 | cmp [ecx], bl |
198 | cmp [ecx], bl |
221 | jne .after_check |
199 | jne .after_check |
222 | dec [_num] |
200 | dec [_num] |
223 | jz .finded |
201 | jz .finded |
224 | .after_check: |
202 | .after_check: |
225 | dec ecx |
203 | dec ecx |
226 | dec eax |
204 | dec eax |
227 | jmp @b |
205 | jmp @b |
228 | @@: |
206 | @@: |
229 | mov eax, -2 |
207 | mov eax, -2 |
230 | .finded: |
208 | .finded: |
231 | inc eax |
209 | inc eax |
232 | ret |
210 | ret |
233 | endp>> |
211 | endp>> |