Rev 8089 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 8089 | Rev 8091 | ||
---|---|---|---|
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
2 | ;; ;; |
2 | ;; ;; |
3 | ;; Copyright (C) KolibriOS team 2004-2016. All rights reserved. ;; |
3 | ;; Copyright (C) KolibriOS team 2004-2016. All rights reserved. ;; |
4 | ;; Distributed under terms of the GNU General Public License. ;; |
4 | ;; Distributed under terms of the GNU General Public License. ;; |
5 | ;; ;; |
5 | ;; ;; |
6 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
6 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
7 | 7 | ||
8 | $Revision: 8089 $ |
8 | $Revision: 8091 $ |
9 | 9 | ||
10 | iglobal |
10 | iglobal |
11 | full_file_name_table dd sysdir_name |
11 | full_file_name_table dd sysdir_name |
12 | .size dd 1 |
12 | .size dd 1 |
13 | endg |
13 | endg |
14 | 14 | ||
15 | uglobal |
15 | uglobal |
16 | sysdir_name rb 64 ; 'sys',0 |
16 | sysdir_name rb 64 ; 'sys',0 |
17 | sysdir_path rb 64 |
17 | sysdir_path rb 64 |
18 | sysdir_name1 rb 64 |
18 | sysdir_name1 rb 64 |
19 | sysdir_path1 rb 64 |
19 | sysdir_path1 rb 64 |
20 | endg |
20 | endg |
21 | ; Example: |
21 | ; Example: |
22 | ; align 64 |
22 | ; align 64 |
23 | ; sysdir_name1 db 'KolibriOS',0 |
23 | ; sysdir_name1 db 'KolibriOS',0 |
24 | ; align 64 |
24 | ; align 64 |
25 | ; sysdir_path1 db 'HD0/1',0 |
25 | ; sysdir_path1 db 'HD0/1',0 |
26 | 26 | ||
27 | proc Parser_params |
27 | proc Parser_params |
28 | locals |
28 | locals |
29 | buff rb 4 ; for test cd |
29 | buff rb 4 ; for test cd |
30 | endl |
30 | endl |
- | 31 | if defined extended_primary_loader |
|
- | 32 | mov ecx, sysdir_path |
|
- | 33 | mov [ecx-64], dword 'sys' |
|
- | 34 | mov [ecx-2], byte 3 |
|
- | 35 | mov esi, BOOT.syspath |
|
- | 36 | mov edi, sysdir_path-1 |
|
- | 37 | mov ecx, 20 |
|
- | 38 | rep movsb |
|
- | 39 | ret |
|
- | 40 | else |
|
31 | mov ax, [BOOT.sys_disk] |
41 | mov ax, [BOOT.sys_disk] |
32 | mov ecx, sysdir_path |
42 | mov ecx, sysdir_path |
33 | mov [ecx-64], dword 'sys' |
43 | mov [ecx-64], dword 'sys' |
34 | mov [ecx-2], byte 3 |
44 | mov [ecx-2], byte 3 |
35 | mov [ecx-1], byte '/' |
45 | mov [ecx-1], byte '/' |
36 | cmp al, 'r' ; ram disk |
46 | cmp al, 'r' ; ram disk |
37 | jnz @f |
47 | jnz @f |
38 | mov [ecx], dword 'RD/?' |
48 | mov [ecx], dword 'RD/?' |
39 | mov [ecx+3], byte ah |
49 | mov [ecx+3], byte ah |
40 | mov [ecx+4], byte 0 |
50 | mov [ecx+4], byte 0 |
41 | ret |
51 | ret |
42 | 52 | ||
43 | @@: |
53 | @@: |
44 | cmp al, 'm' |
54 | cmp al, 'm' |
45 | jnz .hard_disk |
55 | jnz .hard_disk |
46 | mov [ecx], dword 'CD?/' |
56 | mov [ecx], dword 'CD?/' |
47 | mov [ecx+4], byte '1' |
57 | mov [ecx+4], byte '1' |
48 | mov [ecx+5], dword '/KOL' |
58 | mov [ecx+5], dword '/KOL' |
49 | mov [ecx+9], dword 'IBRI' |
59 | mov [ecx+9], dword 'IBRI' |
50 | mov [ecx+13], byte 0 |
60 | mov [ecx+13], byte 0 |
51 | .next_cd: |
61 | .next_cd: |
52 | mov [ecx+2], byte ah |
62 | mov [ecx+2], byte ah |
53 | inc ah |
63 | inc ah |
54 | cmp ah, '5' |
64 | cmp ah, '5' |
55 | je @f |
65 | je @f |
56 | lea edx, [buff] |
66 | lea edx, [buff] |
57 | pushad |
67 | pushad |
58 | stdcall read_file, read_firstapp, edx, 0, 4 |
68 | stdcall read_file, read_firstapp, edx, 0, 4 |
59 | popad |
69 | popad |
60 | cmp [edx], dword 'MENU' |
70 | cmp [edx], dword 'MENU' |
61 | jne .next_cd |
71 | jne .next_cd |
62 | @@: |
72 | @@: |
63 | ret |
73 | ret |
- | 74 | end if |
|
64 | 75 | ||
65 | .hard_disk: |
76 | .hard_disk: |
66 | sub al, '1' |
77 | sub al, '1' |
67 | mov [ecx], dword 'HD?/' |
78 | mov [ecx], dword 'HD?/' |
68 | mov [ecx+2], byte al |
79 | mov [ecx+2], byte al |
69 | mov [ecx+4], byte ah |
80 | mov [ecx+4], byte ah |
70 | mov [ecx+5], dword '/KOL' |
81 | mov [ecx+5], dword '/KOL' |
71 | mov [ecx+9], dword 'IBRI' |
82 | mov [ecx+9], dword 'IBRI' |
72 | mov [ecx+13], byte 0 |
83 | mov [ecx+13], byte 0 |
73 | ret |
84 | ret |
74 | endp |
85 | endp |
75 | 86 | ||
76 | cp866toUpper: |
87 | cp866toUpper: |
77 | ; convert cp866 character in al to uppercase |
88 | ; convert cp866 character in al to uppercase |
78 | cmp al, 'a' |
89 | cmp al, 'a' |
79 | jb .ret |
90 | jb .ret |
80 | cmp al, 'z' |
91 | cmp al, 'z' |
81 | jbe @f |
92 | jbe @f |
82 | cmp al, 0xA0 |
93 | cmp al, 0xA0 |
83 | jb .ret |
94 | jb .ret |
84 | cmp al, 0xB0 |
95 | cmp al, 0xB0 |
85 | jb @f |
96 | jb @f |
86 | cmp al, 0xE0 |
97 | cmp al, 0xE0 |
87 | jb .ret |
98 | jb .ret |
88 | cmp al, 0xF0 |
99 | cmp al, 0xF0 |
89 | jb .rus |
100 | jb .rus |
90 | cmp al, 0xF7 |
101 | cmp al, 0xF7 |
91 | ja .ret |
102 | ja .ret |
92 | and eax, -2 |
103 | and eax, -2 |
93 | .ret: |
104 | .ret: |
94 | ret |
105 | ret |
95 | 106 | ||
96 | @@: |
107 | @@: |
97 | sub eax, 32 |
108 | sub eax, 32 |
98 | ret |
109 | ret |
99 | 110 | ||
100 | .rus: |
111 | .rus: |
101 | sub eax, 0xE0-0x90 |
112 | sub eax, 0xE0-0x90 |
102 | ret |
113 | ret |
103 | 114 | ||
104 | utf16toUpper: |
115 | utf16toUpper: |
105 | ; convert UTF-16 character in ax to uppercase |
116 | ; convert UTF-16 character in ax to uppercase |
106 | cmp ax, 'a' |
117 | cmp ax, 'a' |
107 | jb .ret |
118 | jb .ret |
108 | cmp ax, 'z' |
119 | cmp ax, 'z' |
109 | jbe @f |
120 | jbe @f |
110 | cmp ax, 430h |
121 | cmp ax, 430h |
111 | jb .ret |
122 | jb .ret |
112 | cmp ax, 450h |
123 | cmp ax, 450h |
113 | jb @f |
124 | jb @f |
114 | cmp ax, 460h |
125 | cmp ax, 460h |
115 | jnc .ret |
126 | jnc .ret |
116 | sub eax, 80 |
127 | sub eax, 80 |
117 | .ret: |
128 | .ret: |
118 | ret |
129 | ret |
119 | 130 | ||
120 | @@: |
131 | @@: |
121 | sub eax, 32 |
132 | sub eax, 32 |
122 | ret |
133 | ret |
123 | 134 | ||
124 | uni2ansi_char: |
135 | uni2ansi_char: |
125 | ; convert UNICODE character in ax to ANSI character in al using cp866 encoding |
136 | ; convert UNICODE character in ax to ANSI character in al using cp866 encoding |
126 | cmp ax, 0x80 |
137 | cmp ax, 0x80 |
127 | jb .ret |
138 | jb .ret |
128 | cmp ax, 0xB6 |
139 | cmp ax, 0xB6 |
129 | jz .B6 |
140 | jz .B6 |
130 | cmp ax, 0x400 |
141 | cmp ax, 0x400 |
131 | jb .unk |
142 | jb .unk |
132 | cmp ax, 0x410 |
143 | cmp ax, 0x410 |
133 | jb @f |
144 | jb @f |
134 | cmp ax, 0x440 |
145 | cmp ax, 0x440 |
135 | jb .rus1 |
146 | jb .rus1 |
136 | cmp ax, 0x450 |
147 | cmp ax, 0x450 |
137 | jb .rus2 |
148 | jb .rus2 |
138 | cmp ax, 0x460 |
149 | cmp ax, 0x460 |
139 | jb @f |
150 | jb @f |
140 | .unk: |
151 | .unk: |
141 | mov al, '_' |
152 | mov al, '_' |
142 | .ret: |
153 | .ret: |
143 | ret |
154 | ret |
144 | 155 | ||
145 | .B6: |
156 | .B6: |
146 | mov al, 20 |
157 | mov al, 20 |
147 | ret |
158 | ret |
148 | 159 | ||
149 | .rus1: ; 0x410-0x43F -> 0x80-0xAF |
160 | .rus1: ; 0x410-0x43F -> 0x80-0xAF |
150 | add al, 0x70 |
161 | add al, 0x70 |
151 | ret |
162 | ret |
152 | 163 | ||
153 | .rus2: ; 0x440-0x44F -> 0xE0-0xEF |
164 | .rus2: ; 0x440-0x44F -> 0xE0-0xEF |
154 | add al, 0xA0 |
165 | add al, 0xA0 |
155 | ret |
166 | ret |
156 | 167 | ||
157 | @@: |
168 | @@: |
158 | push ecx edi |
169 | push ecx edi |
159 | mov ecx, 8 |
170 | mov ecx, 8 |
160 | mov edi, .table |
171 | mov edi, .table |
161 | repnz scasb |
172 | repnz scasb |
162 | mov ah, cl |
173 | mov ah, cl |
163 | pop edi ecx |
174 | pop edi ecx |
164 | jnz .unk |
175 | jnz .unk |
165 | mov al, 0xF7 |
176 | mov al, 0xF7 |
166 | sub al, ah |
177 | sub al, ah |
167 | ret |
178 | ret |
168 | 179 | ||
169 | .table db 1, 51h, 4, 54h, 7, 57h, 0Eh, 5Eh |
180 | .table db 1, 51h, 4, 54h, 7, 57h, 0Eh, 5Eh |
170 | 181 | ||
171 | ansi2uni_char: |
182 | ansi2uni_char: |
172 | ; convert ANSI character in al to UNICODE character in ax, using cp866 encoding |
183 | ; convert ANSI character in al to UNICODE character in ax, using cp866 encoding |
173 | movzx eax, al |
184 | movzx eax, al |
174 | cmp al, 0x80 |
185 | cmp al, 0x80 |
175 | jb @f ; 0x00-0x7F - trivial map |
186 | jb @f ; 0x00-0x7F - trivial map |
176 | cmp al, 0xB0 |
187 | cmp al, 0xB0 |
177 | jb .rus ; 0x80-0xAF -> 0x410-0x43F |
188 | jb .rus ; 0x80-0xAF -> 0x410-0x43F |
178 | cmp al, 0xE0 |
189 | cmp al, 0xE0 |
179 | jb .unk |
190 | jb .unk |
180 | cmp al, 0xF0 |
191 | cmp al, 0xF0 |
181 | jb .rus2 ; 0xE0-0xEF -> 0x440-0x44F |
192 | jb .rus2 ; 0xE0-0xEF -> 0x440-0x44F |
182 | cmp al, 0xF8 |
193 | cmp al, 0xF8 |
183 | jnc .unk |
194 | jnc .unk |
184 | mov al, [eax+uni2ansi_char.table-0xF0] |
195 | mov al, [eax+uni2ansi_char.table-0xF0] |
185 | add ax, 400h |
196 | add ax, 400h |
186 | ret |
197 | ret |
187 | 198 | ||
188 | @@: |
199 | @@: |
189 | cmp al, 20 |
200 | cmp al, 20 |
190 | jnz .ret |
201 | jnz .ret |
191 | mov al, 0xB6 |
202 | mov al, 0xB6 |
192 | .ret: |
203 | .ret: |
193 | ret |
204 | ret |
194 | 205 | ||
195 | .rus: |
206 | .rus: |
196 | add ax, 0x410-0x80 |
207 | add ax, 0x410-0x80 |
197 | ret |
208 | ret |
198 | 209 | ||
199 | .rus2: |
210 | .rus2: |
200 | add ax, 0x440-0xE0 |
211 | add ax, 0x440-0xE0 |
201 | ret |
212 | ret |
202 | 213 | ||
203 | .unk: |
214 | .unk: |
204 | mov al, '_' |
215 | mov al, '_' |
205 | ret |
216 | ret |
206 | 217 | ||
207 | cp866toUTF8_string: |
218 | cp866toUTF8_string: |
208 | ; in: |
219 | ; in: |
209 | ; esi -> cp866 string (could be zero terminated) |
220 | ; esi -> cp866 string (could be zero terminated) |
210 | ; edi -> buffer for UTF-8 string |
221 | ; edi -> buffer for UTF-8 string |
211 | ; ecx = buffer size (signed) |
222 | ; ecx = buffer size (signed) |
212 | lodsb |
223 | lodsb |
213 | call ansi2uni_char |
224 | call ansi2uni_char |
214 | push eax |
225 | push eax |
215 | call UTF16to8 |
226 | call UTF16to8 |
216 | pop eax |
227 | pop eax |
217 | js @f |
228 | js @f |
218 | test eax, eax |
229 | test eax, eax |
219 | jnz cp866toUTF8_string |
230 | jnz cp866toUTF8_string |
220 | @@: |
231 | @@: |
221 | ret |
232 | ret |
222 | 233 | ||
223 | ; SF=1 -> counter |
234 | ; SF=1 -> counter |
224 | ; ZF=1 -> zero char |
235 | ; ZF=1 -> zero char |
225 | 236 | ||
226 | UTF16to8_string: |
237 | UTF16to8_string: |
227 | ; in: |
238 | ; in: |
228 | ; esi -> UTF-16 string (could be zero terminated) |
239 | ; esi -> UTF-16 string (could be zero terminated) |
229 | ; edi -> buffer for UTF-8 string |
240 | ; edi -> buffer for UTF-8 string |
230 | ; ecx = buffer size (signed) |
241 | ; ecx = buffer size (signed) |
231 | xor eax, eax |
242 | xor eax, eax |
232 | @@: |
243 | @@: |
233 | lodsw |
244 | lodsw |
234 | push eax |
245 | push eax |
235 | call UTF16to8 |
246 | call UTF16to8 |
236 | pop eax |
247 | pop eax |
237 | js @f |
248 | js @f |
238 | test eax, eax |
249 | test eax, eax |
239 | jnz @b |
250 | jnz @b |
240 | @@: |
251 | @@: |
241 | ret |
252 | ret |
242 | 253 | ||
243 | UTF16to8: |
254 | UTF16to8: |
244 | ; in: |
255 | ; in: |
245 | ; eax = UTF-16 char |
256 | ; eax = UTF-16 char |
246 | ; edi -> buffer for UTF-8 char (increasing) |
257 | ; edi -> buffer for UTF-8 char (increasing) |
247 | ; ecx = byte counter (decreasing) |
258 | ; ecx = byte counter (decreasing) |
248 | dec ecx |
259 | dec ecx |
249 | js .ret |
260 | js .ret |
250 | cmp eax, 80h |
261 | cmp eax, 80h |
251 | jnc @f |
262 | jnc @f |
252 | stosb |
263 | stosb |
253 | test eax, eax ; SF=0 |
264 | test eax, eax ; SF=0 |
254 | .ret: |
265 | .ret: |
255 | ret |
266 | ret |
256 | 267 | ||
257 | @@: |
268 | @@: |
258 | dec ecx |
269 | dec ecx |
259 | js .ret |
270 | js .ret |
260 | cmp eax, 800h |
271 | cmp eax, 800h |
261 | jnc @f |
272 | jnc @f |
262 | shl eax, 2 |
273 | shl eax, 2 |
263 | shr al, 2 |
274 | shr al, 2 |
264 | or eax, 1100000010000000b |
275 | or eax, 1100000010000000b |
265 | xchg al, ah |
276 | xchg al, ah |
266 | stosw |
277 | stosw |
267 | ret |
278 | ret |
268 | 279 | ||
269 | @@: |
280 | @@: |
270 | dec ecx |
281 | dec ecx |
271 | js .ret |
282 | js .ret |
272 | shl eax, 4 |
283 | shl eax, 4 |
273 | shr ax, 2 |
284 | shr ax, 2 |
274 | shr al, 2 |
285 | shr al, 2 |
275 | or eax, 111000001000000010000000b |
286 | or eax, 111000001000000010000000b |
276 | bswap eax |
287 | bswap eax |
277 | shr eax, 8 |
288 | shr eax, 8 |
278 | stosb |
289 | stosb |
279 | shr eax, 8 |
290 | shr eax, 8 |
280 | stosw |
291 | stosw |
281 | ret |
292 | ret |
282 | 293 | ||
283 | utf8to16: |
294 | utf8to16: |
284 | ; in: esi -> UTF-8 char (increasing) |
295 | ; in: esi -> UTF-8 char (increasing) |
285 | ; out: ax = UTF-16 char |
296 | ; out: ax = UTF-16 char |
286 | lodsb |
297 | lodsb |
287 | test al, al |
298 | test al, al |
288 | jns .got |
299 | jns .got |
289 | shl al, 2 |
300 | shl al, 2 |
290 | jnc utf8to16 |
301 | jnc utf8to16 |
291 | @@: |
302 | @@: |
292 | shl ax, 8 |
303 | shl ax, 8 |
293 | lodsb |
304 | lodsb |
294 | test al, al |
305 | test al, al |
295 | jns .got |
306 | jns .got |
296 | shl al, 2 |
307 | shl al, 2 |
297 | jc @b |
308 | jc @b |
298 | shr ah, 2 |
309 | shr ah, 2 |
299 | shl ax, 3 |
310 | shl ax, 3 |
300 | jnc @f |
311 | jnc @f |
301 | shl eax, 3 |
312 | shl eax, 3 |
302 | lodsb |
313 | lodsb |
303 | test al, al |
314 | test al, al |
304 | jns .got |
315 | jns .got |
305 | shl al, 2 |
316 | shl al, 2 |
306 | jc @b |
317 | jc @b |
307 | shr eax, 2 |
318 | shr eax, 2 |
308 | ret |
319 | ret |
309 | 320 | ||
310 | @@: |
321 | @@: |
311 | shr ax, 5 |
322 | shr ax, 5 |
312 | ret |
323 | ret |
313 | 324 | ||
314 | .got: |
325 | .got: |
315 | xor ah, ah |
326 | xor ah, ah |
316 | ret |
327 | ret |
317 | 328 | ||
318 | strlen: |
329 | strlen: |
319 | ; in: esi -> source |
330 | ; in: esi -> source |
320 | ; out: ecx = length |
331 | ; out: ecx = length |
321 | push edi eax |
332 | push edi eax |
322 | or ecx, -1 |
333 | or ecx, -1 |
323 | mov edi, esi |
334 | mov edi, esi |
324 | xor eax, eax |
335 | xor eax, eax |
325 | repnz scasb |
336 | repnz scasb |
326 | inc ecx |
337 | inc ecx |
327 | not ecx |
338 | not ecx |
328 | pop eax edi |
339 | pop eax edi |
329 | ret |
340 | ret |