Rev 2287 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
2287 | heavyiron | 1 | |
2 | ; Copyright (c) 1999-2012, Tomasz Grysztar. |
||
2664 | dunkaist | 3 | ; All rights reserved. |
2287 | heavyiron | 4 | |
5 | |||
6 | mov [current_offset],edi |
||
7 | mov [value_undefined],0 |
||
8 | cmp byte [esi],0 |
||
9 | je get_string_value |
||
10 | cmp byte [esi],'.' |
||
11 | je convert_fp |
||
12 | calculation_loop: |
||
13 | lods byte [esi] |
||
14 | cmp al,1 |
||
15 | je get_byte_number |
||
16 | cmp al,2 |
||
17 | je get_word_number |
||
18 | cmp al,4 |
||
19 | je get_dword_number |
||
20 | cmp al,8 |
||
21 | je get_qword_number |
||
22 | cmp al,0Fh |
||
23 | je value_out_of_range |
||
24 | cmp al,10h |
||
25 | je get_register |
||
26 | cmp al,11h |
||
27 | je get_label |
||
28 | cmp al,')' |
||
29 | je expression_calculated |
||
30 | cmp al,']' |
||
31 | je expression_calculated |
||
32 | cmp al,'!' |
||
33 | je invalid_expression |
||
34 | sub edi,14h |
||
35 | mov ebx,edi |
||
36 | sub ebx,14h |
||
37 | cmp al,0E0h |
||
38 | je calculate_rva |
||
39 | cmp al,0E1h |
||
40 | je calculate_plt |
||
41 | cmp al,0D0h |
||
42 | je calculate_not |
||
43 | cmp al,083h |
||
44 | je calculate_neg |
||
45 | mov dx,[ebx+8] |
||
46 | or dx,[edi+8] |
||
47 | cmp al,80h |
||
48 | je calculate_add |
||
49 | cmp al,81h |
||
50 | je calculate_sub |
||
51 | mov ah,[ebx+12] |
||
52 | or ah,[edi+12] |
||
53 | jz absolute_values_calculation |
||
54 | cmp [error_line],0 |
||
55 | jne absolute_values_calculation |
||
56 | mov eax,[current_line] |
||
57 | mov [error_line],eax |
||
58 | mov [error],invalid_use_of_symbol |
||
59 | absolute_values_calculation: |
||
60 | cmp al,90h |
||
61 | je calculate_mul |
||
62 | cmp al,91h |
||
63 | je calculate_div |
||
64 | or dx,dx |
||
65 | jnz invalid_expression |
||
66 | cmp al,0A0h |
||
67 | je calculate_mod |
||
68 | cmp al,0B0h |
||
69 | je calculate_and |
||
70 | cmp al,0B1h |
||
71 | je calculate_or |
||
72 | cmp al,0B2h |
||
73 | je calculate_xor |
||
74 | cmp al,0C0h |
||
75 | je calculate_shl |
||
76 | cmp al,0C1h |
||
77 | je calculate_shr |
||
78 | jmp invalid_expression |
||
79 | expression_calculated: |
||
80 | sub edi,14h |
||
81 | cmp [value_undefined],0 |
||
82 | je expression_value_ok |
||
83 | xor eax,eax |
||
84 | mov [edi],eax |
||
85 | mov [edi+4],eax |
||
86 | mov [edi+12],al |
||
87 | expression_value_ok: |
||
88 | ret |
||
89 | get_byte_number: |
||
90 | xor eax,eax |
||
91 | lods byte [esi] |
||
92 | stos dword [edi] |
||
93 | xor al,al |
||
94 | stos dword [edi] |
||
95 | got_number: |
||
96 | mov word [edi-8+8],0 |
||
97 | mov byte [edi-8+12],0 |
||
98 | mov dword [edi-8+16],0 |
||
99 | add edi,0Ch |
||
100 | jmp calculation_loop |
||
101 | get_word_number: |
||
102 | xor eax,eax |
||
103 | lods word [esi] |
||
104 | stos dword [edi] |
||
105 | xor ax,ax |
||
106 | stos dword [edi] |
||
107 | jmp got_number |
||
108 | get_dword_number: |
||
109 | movs dword [edi],[esi] |
||
110 | xor eax,eax |
||
111 | stos dword [edi] |
||
112 | jmp got_number |
||
113 | get_qword_number: |
||
114 | movs dword [edi],[esi] |
||
115 | movs dword [edi],[esi] |
||
116 | jmp got_number |
||
117 | get_register: |
||
118 | mov byte [edi+9],0 |
||
119 | mov byte [edi+12],0 |
||
120 | lods byte [esi] |
||
121 | mov [edi+8],al |
||
122 | mov byte [edi+10],1 |
||
123 | xor eax,eax |
||
124 | mov [edi+16],eax |
||
125 | stos dword [edi] |
||
126 | stos dword [edi] |
||
127 | add edi,0Ch |
||
128 | jmp calculation_loop |
||
129 | get_label: |
||
130 | xor eax,eax |
||
131 | mov [edi+8],eax |
||
132 | mov [edi+12],al |
||
133 | mov [edi+20],eax |
||
134 | lods dword [esi] |
||
135 | cmp eax,0Fh |
||
136 | jb predefined_label |
||
137 | je reserved_word_used_as_symbol |
||
138 | mov ebx,eax |
||
139 | mov ax,[current_pass] |
||
140 | mov [ebx+18],ax |
||
141 | or byte [ebx+8],8 |
||
142 | test byte [ebx+8],1 |
||
143 | jz label_undefined |
||
144 | cmp ax,[ebx+16] |
||
145 | je label_defined |
||
146 | test byte [ebx+8],4 |
||
147 | jnz label_out_of_scope |
||
148 | test byte [ebx+9],1 |
||
149 | jz label_defined |
||
150 | mov eax,[ebx] |
||
151 | sub eax,dword [adjustment] |
||
152 | stos dword [edi] |
||
153 | mov eax,[ebx+4] |
||
154 | sbb eax,dword [adjustment+4] |
||
155 | stos dword [edi] |
||
156 | mov eax,dword [adjustment] |
||
157 | or eax,dword [adjustment+4] |
||
158 | jz got_label |
||
159 | or [next_pass_needed],-1 |
||
160 | jmp got_label |
||
161 | label_defined: |
||
162 | mov eax,[ebx] |
||
163 | stos dword [edi] |
||
164 | mov eax,[ebx+4] |
||
165 | stos dword [edi] |
||
166 | got_label: |
||
167 | mov al,[ebx+11] |
||
168 | mov [edi-8+12],al |
||
169 | mov eax,[ebx+12] |
||
170 | mov [edi-8+8],eax |
||
171 | mov eax,[ebx+20] |
||
172 | mov [edi-8+16],eax |
||
173 | add edi,0Ch |
||
174 | mov al,[ebx+10] |
||
175 | or al,al |
||
176 | jz calculation_loop |
||
177 | cmp [size_override],-1 |
||
178 | je calculation_loop |
||
179 | cmp [size_override],0 |
||
180 | je check_size |
||
181 | cmp [operand_size],0 |
||
182 | jne calculation_loop |
||
183 | mov [operand_size],al |
||
184 | jmp calculation_loop |
||
185 | check_size: |
||
186 | xchg [operand_size],al |
||
187 | or al,al |
||
188 | jz calculation_loop |
||
189 | cmp al,[operand_size] |
||
190 | jne operand_sizes_do_not_match |
||
191 | jmp calculation_loop |
||
192 | current_offset_label: |
||
193 | mov eax,[current_offset] |
||
194 | make_current_offset_label: |
||
195 | xor edx,edx |
||
196 | sub eax,dword [org_origin] |
||
197 | sbb edx,dword [org_origin+4] |
||
198 | stos dword [edi] |
||
199 | mov eax,edx |
||
200 | stos dword [edi] |
||
201 | mov eax,[org_registers] |
||
202 | stos dword [edi] |
||
203 | mov al,[labels_type] |
||
204 | mov [edi-12+12],al |
||
205 | mov eax,[org_symbol] |
||
206 | mov [edi-12+16],eax |
||
207 | add edi,8 |
||
208 | jmp calculation_loop |
||
209 | org_origin_label: |
||
210 | mov eax,[org_start] |
||
211 | jmp make_current_offset_label |
||
212 | counter_label: |
||
213 | mov eax,[counter] |
||
214 | make_dword_label_value: |
||
215 | stos dword [edi] |
||
216 | xor eax,eax |
||
217 | stos dword [edi] |
||
218 | add edi,0Ch |
||
219 | jmp calculation_loop |
||
220 | timestamp_label: |
||
221 | call make_timestamp |
||
222 | make_qword_label_value: |
||
223 | stos dword [edi] |
||
224 | mov eax,edx |
||
225 | stos dword [edi] |
||
226 | add edi,0Ch |
||
227 | jmp calculation_loop |
||
228 | predefined_label: |
||
229 | or eax,eax |
||
230 | jz current_offset_label |
||
231 | cmp eax,1 |
||
232 | je counter_label |
||
233 | cmp eax,2 |
||
234 | je timestamp_label |
||
235 | cmp eax,3 |
||
236 | je org_origin_label |
||
237 | mov edx,invalid_value |
||
238 | jmp error_undefined |
||
239 | label_out_of_scope: |
||
240 | mov edx,symbol_out_of_scope |
||
241 | cmp [error_line],0 |
||
242 | jne error_undefined |
||
243 | mov [error_info],ebx |
||
244 | jmp error_undefined |
||
245 | label_undefined: |
||
246 | mov edx,undefined_symbol |
||
247 | cmp [error_line],0 |
||
248 | jne error_undefined |
||
249 | mov [error_info],ebx |
||
250 | error_undefined: |
||
251 | cmp [current_pass],1 |
||
252 | ja undefined_value |
||
253 | force_next_pass: |
||
254 | or [next_pass_needed],-1 |
||
255 | undefined_value: |
||
256 | mov byte [edi+12],0 |
||
257 | or [value_undefined],-1 |
||
258 | xor eax,eax |
||
259 | stos dword [edi] |
||
260 | stos dword [edi] |
||
261 | add edi,0Ch |
||
262 | cmp [error_line],0 |
||
263 | jne calculation_loop |
||
264 | mov eax,[current_line] |
||
265 | mov [error_line],eax |
||
266 | mov [error],edx |
||
267 | jmp calculation_loop |
||
268 | calculate_add: |
||
269 | mov ecx,[ebx+16] |
||
270 | cmp byte [edi+12],0 |
||
271 | je add_values |
||
272 | mov ecx,[edi+16] |
||
273 | cmp byte [ebx+12],0 |
||
274 | je add_values |
||
275 | cmp [error_line],0 |
||
276 | jne add_values |
||
277 | mov eax,[current_line] |
||
278 | mov [error_line],eax |
||
279 | mov [error],invalid_use_of_symbol |
||
280 | add_values: |
||
281 | mov al,[edi+12] |
||
282 | or [ebx+12],al |
||
283 | mov [ebx+16],ecx |
||
284 | mov eax,[edi] |
||
285 | add [ebx],eax |
||
286 | mov eax,[edi+4] |
||
287 | adc [ebx+4],eax |
||
288 | or dx,dx |
||
289 | jz calculation_loop |
||
290 | push esi |
||
291 | mov esi,ebx |
||
292 | lea ebx,[edi+10] |
||
293 | mov cl,[edi+8] |
||
294 | call add_register |
||
295 | lea ebx,[edi+11] |
||
296 | mov cl,[edi+9] |
||
297 | call add_register |
||
298 | pop esi |
||
299 | jmp calculation_loop |
||
300 | add_register: |
||
301 | or cl,cl |
||
302 | jz add_register_done |
||
303 | add_register_start: |
||
304 | cmp [esi+8],cl |
||
305 | jne add_in_second_slot |
||
306 | mov al,[ebx] |
||
307 | add [esi+10],al |
||
308 | jnz add_register_done |
||
309 | mov byte [esi+8],0 |
||
310 | ret |
||
311 | add_in_second_slot: |
||
312 | cmp [esi+9],cl |
||
313 | jne create_in_first_slot |
||
314 | mov al,[ebx] |
||
315 | add [esi+11],al |
||
316 | jnz add_register_done |
||
317 | mov byte [esi+9],0 |
||
318 | ret |
||
319 | create_in_first_slot: |
||
320 | cmp byte [esi+8],0 |
||
321 | jne create_in_second_slot |
||
322 | mov [esi+8],cl |
||
323 | mov al,[ebx] |
||
324 | mov [esi+10],al |
||
325 | ret |
||
326 | create_in_second_slot: |
||
327 | cmp byte [esi+9],0 |
||
328 | jne invalid_expression |
||
329 | mov [esi+9],cl |
||
330 | mov al,[ebx] |
||
331 | mov [esi+11],al |
||
332 | add_register_done: |
||
333 | ret |
||
334 | calculate_sub: |
||
335 | xor ah,ah |
||
336 | mov ah,[ebx+12] |
||
337 | mov al,[edi+12] |
||
338 | or al,al |
||
339 | jz sub_values |
||
340 | cmp al,ah |
||
341 | jne invalid_sub |
||
342 | xor ah,ah |
||
343 | mov ecx,[edi+16] |
||
344 | cmp ecx,[ebx+16] |
||
345 | jne invalid_sub |
||
346 | sub_values: |
||
347 | mov [ebx+12],ah |
||
348 | mov eax,[edi] |
||
349 | sub [ebx],eax |
||
350 | mov eax,[edi+4] |
||
351 | sbb [ebx+4],eax |
||
352 | or dx,dx |
||
353 | jz calculation_loop |
||
354 | push esi |
||
355 | mov esi,ebx |
||
356 | lea ebx,[edi+10] |
||
357 | mov cl,[edi+8] |
||
358 | call sub_register |
||
359 | lea ebx,[edi+11] |
||
360 | mov cl,[edi+9] |
||
361 | call sub_register |
||
362 | pop esi |
||
363 | jmp calculation_loop |
||
364 | invalid_sub: |
||
365 | cmp [error_line],0 |
||
366 | jne sub_values |
||
367 | mov eax,[current_line] |
||
368 | mov [error_line],eax |
||
369 | mov [error],invalid_use_of_symbol |
||
370 | jmp sub_values |
||
371 | sub_register: |
||
372 | or cl,cl |
||
373 | jz add_register_done |
||
374 | neg byte [ebx] |
||
375 | jmp add_register_start |
||
376 | calculate_mul: |
||
377 | or dx,dx |
||
378 | jz mul_start |
||
379 | cmp word [ebx+8],0 |
||
380 | jne mul_start |
||
381 | mov eax,[ebx] |
||
382 | xchg eax,[edi] |
||
383 | mov [ebx],eax |
||
384 | mov eax,[ebx+4] |
||
385 | xchg eax,[edi+4] |
||
386 | mov [ebx+4],eax |
||
387 | mov eax,[ebx+8] |
||
388 | xchg eax,[edi+8] |
||
389 | mov [ebx+8],eax |
||
390 | mov eax,[ebx+12] |
||
391 | xchg eax,[edi+12] |
||
392 | mov [ebx+12],eax |
||
393 | mul_start: |
||
394 | push esi edx |
||
395 | mov esi,ebx |
||
396 | xor bl,bl |
||
397 | bt dword [esi+4],31 |
||
398 | jnc mul_first_sign_ok |
||
399 | not dword [esi] |
||
400 | not dword [esi+4] |
||
401 | add dword [esi],1 |
||
402 | adc dword [esi+4],0 |
||
403 | not bl |
||
404 | mul_first_sign_ok: |
||
405 | bt dword [edi+4],31 |
||
406 | jnc mul_second_sign_ok |
||
407 | not dword [edi] |
||
408 | not dword [edi+4] |
||
409 | add dword [edi],1 |
||
410 | adc dword [edi+4],0 |
||
411 | not bl |
||
412 | mul_second_sign_ok: |
||
413 | cmp dword [esi+4],0 |
||
414 | jz mul_numbers |
||
415 | cmp dword [edi+4],0 |
||
416 | jnz value_out_of_range |
||
417 | mul_numbers: |
||
418 | mov eax,[esi+4] |
||
419 | mul dword [edi] |
||
420 | or edx,edx |
||
421 | jnz value_out_of_range |
||
422 | mov ecx,eax |
||
423 | mov eax,[esi] |
||
424 | mul dword [edi+4] |
||
425 | or edx,edx |
||
426 | jnz value_out_of_range |
||
427 | add ecx,eax |
||
428 | jc value_out_of_range |
||
429 | mov eax,[esi] |
||
430 | mul dword [edi] |
||
431 | add edx,ecx |
||
432 | jc value_out_of_range |
||
433 | test edx,1 shl 31 |
||
434 | jnz value_out_of_range |
||
435 | mov [esi],eax |
||
436 | mov [esi+4],edx |
||
437 | or bl,bl |
||
438 | jz mul_ok |
||
439 | not dword [esi] |
||
440 | not dword [esi+4] |
||
441 | add dword [esi],1 |
||
442 | adc dword [esi+4],0 |
||
443 | mul_ok: |
||
444 | pop edx |
||
445 | or dx,dx |
||
446 | jz mul_calculated |
||
447 | cmp word [edi+8],0 |
||
448 | jne invalid_value |
||
449 | cmp byte [esi+8],0 |
||
450 | je mul_first_register_ok |
||
451 | mov al,[edi] |
||
452 | cbw |
||
453 | cwde |
||
454 | cdq |
||
455 | cmp edx,[edi+4] |
||
456 | jne value_out_of_range |
||
457 | cmp eax,[edi] |
||
458 | jne value_out_of_range |
||
459 | imul byte [esi+10] |
||
460 | mov dl,ah |
||
461 | cbw |
||
462 | cmp ah,dl |
||
463 | jne value_out_of_range |
||
464 | mov [esi+10],al |
||
465 | or al,al |
||
466 | jnz mul_first_register_ok |
||
467 | mov [esi+8],al |
||
468 | mul_first_register_ok: |
||
469 | cmp byte [esi+9],0 |
||
470 | je mul_calculated |
||
471 | mov al,[edi] |
||
472 | cbw |
||
473 | cwde |
||
474 | cdq |
||
475 | cmp edx,[edi+4] |
||
476 | jne value_out_of_range |
||
477 | cmp eax,[edi] |
||
478 | jne value_out_of_range |
||
479 | imul byte [esi+11] |
||
480 | mov dl,ah |
||
481 | cbw |
||
482 | cmp ah,dl |
||
483 | jne value_out_of_range |
||
484 | mov [esi+11],al |
||
485 | or al,al |
||
486 | jnz mul_calculated |
||
487 | mov [esi+9],al |
||
488 | mul_calculated: |
||
489 | pop esi |
||
490 | jmp calculation_loop |
||
491 | calculate_div: |
||
492 | push esi edx |
||
493 | mov esi,ebx |
||
494 | call div_64 |
||
495 | pop edx |
||
496 | or dx,dx |
||
497 | jz div_calculated |
||
498 | cmp byte [esi+8],0 |
||
499 | je div_first_register_ok |
||
500 | mov al,[edi] |
||
501 | cbw |
||
502 | cwde |
||
503 | cdq |
||
504 | cmp edx,[edi+4] |
||
505 | jne value_out_of_range |
||
506 | cmp eax,[edi] |
||
507 | jne value_out_of_range |
||
508 | or al,al |
||
509 | jz value_out_of_range |
||
510 | mov al,[esi+10] |
||
511 | cbw |
||
512 | idiv byte [edi] |
||
513 | or ah,ah |
||
514 | jnz invalid_use_of_symbol |
||
515 | mov [esi+10],al |
||
516 | div_first_register_ok: |
||
517 | cmp byte [esi+9],0 |
||
518 | je div_calculated |
||
519 | mov al,[edi] |
||
520 | cbw |
||
521 | cwde |
||
522 | cdq |
||
523 | cmp edx,[edi+4] |
||
524 | jne value_out_of_range |
||
525 | cmp eax,[edi] |
||
526 | jne value_out_of_range |
||
527 | or al,al |
||
528 | jz value_out_of_range |
||
529 | mov al,[esi+11] |
||
530 | cbw |
||
531 | idiv byte [edi] |
||
532 | or ah,ah |
||
533 | jnz invalid_use_of_symbol |
||
534 | mov [esi+11],al |
||
535 | div_calculated: |
||
536 | pop esi |
||
537 | jmp calculation_loop |
||
538 | calculate_mod: |
||
539 | push esi |
||
540 | mov esi,ebx |
||
541 | call div_64 |
||
542 | mov [esi],eax |
||
543 | mov [esi+4],edx |
||
544 | pop esi |
||
545 | jmp calculation_loop |
||
546 | calculate_and: |
||
547 | mov eax,[edi] |
||
548 | and [ebx],eax |
||
549 | mov eax,[edi+4] |
||
550 | and [ebx+4],eax |
||
551 | jmp calculation_loop |
||
552 | calculate_or: |
||
553 | mov eax,[edi] |
||
554 | or [ebx],eax |
||
555 | mov eax,[edi+4] |
||
556 | or [ebx+4],eax |
||
557 | jmp calculation_loop |
||
558 | calculate_xor: |
||
559 | mov eax,[edi] |
||
560 | xor [ebx],eax |
||
561 | mov edx,[edi+4] |
||
562 | xor [ebx+4],edx |
||
563 | cmp [value_size],1 |
||
564 | je xor_byte |
||
565 | cmp [value_size],2 |
||
566 | je xor_word |
||
567 | cmp [value_size],4 |
||
568 | je xor_dword |
||
569 | cmp [value_size],6 |
||
570 | je xor_pword |
||
571 | xor_calculated: |
||
572 | jmp calculation_loop |
||
573 | prepare_xor_check: |
||
574 | cmp edx,-1 |
||
575 | je xor_check_ready |
||
576 | xor edx,[ebx+4] |
||
577 | xor eax,[ebx] |
||
578 | cmp edx,-1 |
||
579 | xor_check_ready: |
||
580 | ret |
||
581 | xor_byte: |
||
582 | call prepare_xor_check |
||
583 | jne xor_calculated |
||
584 | xor edx,[ebx+4] |
||
585 | jnz xor_calculated |
||
586 | cmp eax,0FFFFFF80h |
||
587 | jb xor_calculated |
||
588 | xor eax,[ebx] |
||
589 | cmp eax,0FFh |
||
590 | ja xor_calculated |
||
591 | mov [ebx+4],edx |
||
592 | and dword [ebx],0FFh |
||
593 | jmp xor_calculated |
||
594 | xor_word: |
||
595 | call prepare_xor_check |
||
596 | jne xor_calculated |
||
597 | xor edx,[ebx+4] |
||
598 | jnz xor_calculated |
||
599 | cmp eax,0FFFF8000h |
||
600 | jb xor_calculated |
||
601 | xor eax,[ebx] |
||
602 | cmp eax,0FFFFh |
||
603 | ja xor_calculated |
||
604 | mov [ebx+4],edx |
||
605 | and dword [ebx],0FFFFh |
||
606 | jmp xor_calculated |
||
607 | xor_dword: |
||
608 | call prepare_xor_check |
||
609 | jne xor_calculated |
||
610 | xor edx,[ebx+4] |
||
611 | jnz xor_calculated |
||
612 | cmp eax,80000000h |
||
613 | jb xor_calculated |
||
614 | mov [ebx+4],edx |
||
615 | jmp xor_calculated |
||
616 | xor_pword: |
||
617 | cmp edx,0FFFF8000h |
||
618 | jae xor_pword_check |
||
619 | xor edx,[ebx+4] |
||
620 | xor eax,[ebx] |
||
621 | cmp edx,0FFFF8000h |
||
622 | jb xor_calculated |
||
623 | xor_pword_check: |
||
624 | xor edx,[ebx+4] |
||
625 | cmp edx,0FFFFh |
||
626 | ja xor_calculated |
||
627 | and dword [ebx+4],0FFFFh |
||
628 | jmp xor_calculated |
||
629 | shr_negative: |
||
630 | not dword [edi] |
||
631 | not dword [edi+4] |
||
632 | add dword [edi],1 |
||
633 | adc dword [edi+4],0 |
||
634 | calculate_shl: |
||
635 | mov eax,dword [edi+4] |
||
636 | bt eax,31 |
||
637 | jc shl_negative |
||
638 | or eax,eax |
||
639 | jnz zero_value |
||
640 | mov ecx,[edi] |
||
641 | cmp ecx,64 |
||
642 | jae zero_value |
||
643 | mov edx,[ebx+4] |
||
644 | mov eax,[ebx] |
||
645 | cmp ecx,32 |
||
646 | jae shl_high |
||
647 | shld edx,eax,cl |
||
648 | shl eax,cl |
||
649 | mov [ebx],eax |
||
650 | mov [ebx+4],edx |
||
651 | jmp calculation_loop |
||
652 | shl_high: |
||
653 | sub cl,32 |
||
654 | shl eax,cl |
||
655 | mov [ebx+4],eax |
||
656 | mov dword [ebx],0 |
||
657 | jmp calculation_loop |
||
658 | shl_negative: |
||
659 | not dword [edi] |
||
660 | not dword [edi+4] |
||
661 | add dword [edi],1 |
||
662 | adc dword [edi+4],0 |
||
663 | calculate_shr: |
||
664 | mov eax,dword [edi+4] |
||
665 | bt eax,31 |
||
666 | jc shr_negative |
||
667 | or eax,eax |
||
668 | jnz zero_value |
||
669 | mov ecx,[edi] |
||
670 | cmp ecx,64 |
||
671 | jae zero_value |
||
672 | mov edx,[ebx+4] |
||
673 | mov eax,[ebx] |
||
674 | cmp ecx,32 |
||
675 | jae shr_high |
||
676 | cmp [value_size],1 |
||
677 | je shr_byte |
||
678 | cmp [value_size],2 |
||
679 | je shr_word |
||
680 | cmp [value_size],4 |
||
681 | je shr_dword |
||
682 | cmp [value_size],6 |
||
683 | je shr_pword |
||
684 | shr_regular: |
||
685 | shrd eax,edx,cl |
||
686 | shr edx,cl |
||
687 | mov [ebx],eax |
||
688 | mov [ebx+4],edx |
||
689 | jmp calculation_loop |
||
690 | shr_byte: |
||
691 | cmp edx,-1 |
||
692 | jne shr_regular |
||
693 | cmp eax,0FFFFFF80h |
||
694 | jb shr_regular |
||
695 | and eax,0FFh |
||
696 | xor edx,edx |
||
697 | jmp shr_regular |
||
698 | shr_word: |
||
699 | cmp edx,-1 |
||
700 | jne shr_regular |
||
701 | cmp eax,0FFFF8000h |
||
702 | jb shr_regular |
||
703 | and eax,0FFFFh |
||
704 | xor edx,edx |
||
705 | jmp shr_regular |
||
706 | shr_dword: |
||
707 | cmp edx,-1 |
||
708 | jne shr_regular |
||
709 | cmp eax,80000000h |
||
710 | jb shr_regular |
||
711 | xor edx,edx |
||
712 | jmp shr_regular |
||
713 | shr_pword: |
||
714 | cmp edx,0FFFF8000h |
||
715 | jb shr_regular |
||
716 | and edx,0FFFFh |
||
717 | jmp shr_regular |
||
718 | shr_high: |
||
719 | sub cl,32 |
||
720 | cmp [value_size],1 |
||
721 | je shr_byte_32plus |
||
722 | cmp [value_size],2 |
||
723 | je shr_word_32plus |
||
724 | cmp [value_size],4 |
||
725 | je shr_dword_32plus |
||
726 | cmp [value_size],6 |
||
727 | je shr_pword_32plus |
||
728 | shr_32plus: |
||
729 | shr edx,cl |
||
730 | mov [ebx],edx |
||
731 | mov dword [ebx+4],0 |
||
732 | jmp calculation_loop |
||
733 | shr_byte_32plus: |
||
734 | cmp edx,-1 |
||
735 | jne shr_32plus |
||
736 | cmp eax,-80h |
||
737 | jb shr_32plus |
||
738 | jmp zero_value |
||
739 | shr_word_32plus: |
||
740 | cmp edx,-1 |
||
741 | jne shr_32plus |
||
742 | cmp eax,-8000h |
||
743 | jb shr_32plus |
||
744 | jmp zero_value |
||
745 | shr_dword_32plus: |
||
746 | cmp edx,-1 |
||
747 | jne shr_32plus |
||
748 | cmp eax,-80000000h |
||
749 | jb shr_32plus |
||
750 | jmp zero_value |
||
751 | shr_pword_32plus: |
||
752 | cmp edx,-8000h |
||
753 | jb shr_32plus |
||
754 | and edx,0FFFFh |
||
755 | jmp shr_32plus |
||
756 | zero_value: |
||
757 | mov dword [ebx],0 |
||
758 | mov dword [ebx+4],0 |
||
759 | jmp calculation_loop |
||
760 | calculate_not: |
||
761 | cmp word [edi+8],0 |
||
762 | jne invalid_expression |
||
763 | cmp byte [edi+12],0 |
||
764 | je not_ok |
||
765 | cmp [error_line],0 |
||
766 | jne not_ok |
||
767 | mov eax,[current_line] |
||
768 | mov [error_line],eax |
||
769 | mov [error],invalid_use_of_symbol |
||
770 | not_ok: |
||
771 | cmp [value_size],1 |
||
772 | je not_byte |
||
773 | cmp [value_size],2 |
||
774 | je not_word |
||
775 | cmp [value_size],4 |
||
776 | je not_dword |
||
777 | cmp [value_size],6 |
||
778 | je not_pword |
||
779 | not_qword: |
||
780 | not dword [edi] |
||
781 | not dword [edi+4] |
||
782 | add edi,14h |
||
783 | jmp calculation_loop |
||
784 | not_byte: |
||
785 | cmp dword [edi+4],0 |
||
786 | jne not_qword |
||
787 | cmp word [edi+2],0 |
||
788 | jne not_qword |
||
789 | cmp byte [edi+1],0 |
||
790 | jne not_qword |
||
791 | not byte [edi] |
||
792 | add edi,14h |
||
793 | jmp calculation_loop |
||
794 | not_word: |
||
795 | cmp dword [edi+4],0 |
||
796 | jne not_qword |
||
797 | cmp word [edi+2],0 |
||
798 | jne not_qword |
||
799 | not word [edi] |
||
800 | add edi,14h |
||
801 | jmp calculation_loop |
||
802 | not_dword: |
||
803 | cmp dword [edi+4],0 |
||
804 | jne not_qword |
||
805 | not dword [edi] |
||
806 | add edi,14h |
||
807 | jmp calculation_loop |
||
808 | not_pword: |
||
809 | cmp word [edi+6],0 |
||
810 | jne not_qword |
||
811 | not dword [edi] |
||
812 | not word [edi+4] |
||
813 | add edi,14h |
||
814 | jmp calculation_loop |
||
815 | calculate_neg: |
||
816 | cmp word [edi+8],0 |
||
817 | jne invalid_expression |
||
818 | cmp byte [edi+12],0 |
||
819 | je neg_ok |
||
820 | cmp [error_line],0 |
||
821 | jne neg_ok |
||
822 | mov eax,[current_line] |
||
823 | mov [error_line],eax |
||
824 | mov [error],invalid_use_of_symbol |
||
825 | neg_ok: |
||
826 | mov eax,[edi] |
||
827 | mov edx,[edi+4] |
||
828 | mov dword [edi],0 |
||
829 | mov dword [edi+4],0 |
||
830 | sub [edi],eax |
||
831 | sbb [edi+4],edx |
||
832 | add edi,14h |
||
833 | jmp calculation_loop |
||
834 | calculate_rva: |
||
835 | cmp word [edi+8],0 |
||
836 | jne invalid_expression |
||
837 | cmp [output_format],5 |
||
838 | je calculate_gotoff |
||
839 | cmp [output_format],4 |
||
840 | je calculate_coff_rva |
||
841 | cmp [output_format],3 |
||
842 | jne invalid_expression |
||
843 | test [format_flags],8 |
||
844 | jnz pe64_rva |
||
845 | mov al,2 |
||
846 | bt [resolver_flags],0 |
||
847 | jc rva_type_ok |
||
848 | xor al,al |
||
849 | rva_type_ok: |
||
850 | cmp byte [edi+12],al |
||
851 | je rva_ok |
||
852 | cmp [error_line],0 |
||
853 | jne rva_ok |
||
854 | mov eax,[current_line] |
||
855 | mov [error_line],eax |
||
856 | mov [error],invalid_use_of_symbol |
||
857 | rva_ok: |
||
858 | mov byte [edi+12],0 |
||
859 | mov eax,[code_start] |
||
860 | mov eax,[eax+34h] |
||
861 | cdq |
||
862 | sub [edi],eax |
||
863 | sbb [edi+4],edx |
||
864 | add edi,14h |
||
865 | jmp calculation_loop |
||
866 | pe64_rva: |
||
867 | mov al,4 |
||
868 | bt [resolver_flags],0 |
||
869 | jc pe64_rva_type_ok |
||
870 | xor al,al |
||
871 | pe64_rva_type_ok: |
||
872 | cmp byte [edi+12],al |
||
873 | je pe64_rva_ok |
||
874 | cmp [error_line],0 |
||
875 | jne pe64_rva_ok |
||
876 | mov eax,[current_line] |
||
877 | mov [error_line],eax |
||
878 | mov [error],invalid_use_of_symbol |
||
879 | pe64_rva_ok: |
||
880 | mov byte [edi+12],0 |
||
881 | mov eax,[code_start] |
||
882 | mov edx,[eax+34h] |
||
883 | mov eax,[eax+30h] |
||
884 | sub [edi],eax |
||
885 | sbb [edi+4],edx |
||
886 | add edi,14h |
||
887 | jmp calculation_loop |
||
888 | calculate_gotoff: |
||
889 | test [format_flags],8+1 |
||
890 | jnz invalid_expression |
||
891 | calculate_coff_rva: |
||
892 | mov dl,5 |
||
893 | cmp byte [edi+12],2 |
||
894 | je change_value_type |
||
895 | incorrect_change_of_value_type: |
||
896 | cmp [error_line],0 |
||
897 | jne change_value_type |
||
898 | mov eax,[current_line] |
||
899 | mov [error_line],eax |
||
900 | mov [error],invalid_use_of_symbol |
||
901 | change_value_type: |
||
902 | mov byte [edi+12],dl |
||
903 | add edi,14h |
||
904 | jmp calculation_loop |
||
905 | calculate_plt: |
||
906 | cmp word [edi+8],0 |
||
907 | jne invalid_expression |
||
908 | cmp [output_format],5 |
||
909 | jne invalid_expression |
||
910 | test [format_flags],1 |
||
911 | jnz invalid_expression |
||
912 | mov dl,6 |
||
913 | mov dh,2 |
||
914 | test [format_flags],8 |
||
915 | jz check_value_for_plt |
||
916 | mov dh,4 |
||
917 | check_value_for_plt: |
||
918 | mov eax,[edi] |
||
919 | or eax,[edi+4] |
||
920 | jnz incorrect_change_of_value_type |
||
921 | cmp byte [edi+12],dh |
||
922 | jne incorrect_change_of_value_type |
||
923 | mov eax,[edi+16] |
||
924 | cmp byte [eax],80h |
||
925 | jne incorrect_change_of_value_type |
||
926 | jmp change_value_type |
||
927 | div_64: |
||
928 | xor ebx,ebx |
||
929 | cmp dword [edi],0 |
||
930 | jne divider_ok |
||
931 | cmp dword [edi+4],0 |
||
932 | jne divider_ok |
||
933 | cmp [next_pass_needed],0 |
||
934 | je value_out_of_range |
||
935 | jmp div_done |
||
936 | divider_ok: |
||
937 | bt dword [esi+4],31 |
||
938 | jnc div_first_sign_ok |
||
939 | not dword [esi] |
||
940 | not dword [esi+4] |
||
941 | add dword [esi],1 |
||
942 | adc dword [esi+4],0 |
||
943 | not bx |
||
944 | div_first_sign_ok: |
||
945 | bt dword [edi+4],31 |
||
946 | jnc div_second_sign_ok |
||
947 | not dword [edi] |
||
948 | not dword [edi+4] |
||
949 | add dword [edi],1 |
||
950 | adc dword [edi+4],0 |
||
951 | not bl |
||
952 | div_second_sign_ok: |
||
953 | cmp dword [edi+4],0 |
||
954 | jne div_high |
||
955 | mov ecx,[edi] |
||
956 | mov eax,[esi+4] |
||
957 | xor edx,edx |
||
958 | div ecx |
||
959 | mov [esi+4],eax |
||
960 | mov eax,[esi] |
||
961 | div ecx |
||
962 | mov [esi],eax |
||
963 | mov eax,edx |
||
964 | xor edx,edx |
||
965 | jmp div_done |
||
966 | div_high: |
||
967 | mov eax,[esi+4] |
||
968 | xor edx,edx |
||
969 | div dword [edi+4] |
||
970 | mov ebx,[esi] |
||
971 | mov [esi],eax |
||
972 | mov dword [esi+4],0 |
||
973 | mov ecx,edx |
||
974 | mul dword [edi] |
||
975 | div_high_loop: |
||
976 | cmp ecx,edx |
||
977 | ja div_high_done |
||
978 | jb div_high_large_correction |
||
979 | cmp ebx,eax |
||
980 | jae div_high_done |
||
981 | div_high_correction: |
||
982 | dec dword [esi] |
||
983 | sub eax,[edi] |
||
984 | sbb edx,[edi+4] |
||
985 | jnc div_high_loop |
||
986 | div_high_done: |
||
987 | sub ebx,eax |
||
988 | sbb ecx,edx |
||
989 | mov edx,ecx |
||
990 | mov eax,ebx |
||
991 | ret |
||
992 | div_high_large_correction: |
||
993 | push eax edx |
||
994 | mov eax,edx |
||
995 | sub eax,ecx |
||
996 | xor edx,edx |
||
997 | div dword [edi+4] |
||
998 | shr eax,1 |
||
999 | jz div_high_small_correction |
||
1000 | sub [esi],eax |
||
1001 | push eax |
||
1002 | mul dword [edi+4] |
||
1003 | sub dword [esp+4],eax |
||
1004 | pop eax |
||
1005 | mul dword [edi] |
||
1006 | sub dword [esp+4],eax |
||
1007 | sbb dword [esp],edx |
||
1008 | pop edx eax |
||
1009 | jmp div_high_loop |
||
1010 | div_high_small_correction: |
||
1011 | pop edx eax |
||
1012 | jmp div_high_correction |
||
1013 | div_done: |
||
1014 | or bh,bh |
||
1015 | jz remainder_ok |
||
1016 | not eax |
||
1017 | not edx |
||
1018 | add eax,1 |
||
1019 | adc edx,0 |
||
1020 | remainder_ok: |
||
1021 | or bl,bl |
||
1022 | jz div_ok |
||
1023 | not dword [esi] |
||
1024 | not dword [esi+4] |
||
1025 | add dword [esi],1 |
||
1026 | adc dword [esi+4],0 |
||
1027 | div_ok: |
||
1028 | ret |
||
1029 | convert_fp: |
||
1030 | inc esi |
||
1031 | mov word [edi+8],0 |
||
1032 | mov byte [edi+12],0 |
||
1033 | mov al,[value_size] |
||
1034 | cmp al,2 |
||
1035 | je convert_fp_word |
||
1036 | cmp al,4 |
||
1037 | je convert_fp_dword |
||
1038 | cmp al,8 |
||
1039 | je convert_fp_qword |
||
1040 | jmp invalid_value |
||
1041 | convert_fp_word: |
||
1042 | xor eax,eax |
||
1043 | cmp word [esi+8],8000h |
||
1044 | je fp_word_store |
||
1045 | mov bx,[esi+8] |
||
1046 | mov ax,[esi+6] |
||
1047 | shl ax,1 |
||
1048 | shr ax,6 |
||
1049 | jnc fp_word_ok |
||
1050 | inc ax |
||
1051 | bt ax,10 |
||
1052 | jnc fp_word_ok |
||
1053 | and ax,1 shl 10 - 1 |
||
1054 | inc bx |
||
1055 | shr ax,1 |
||
1056 | fp_word_ok: |
||
1057 | add bx,0Fh |
||
1058 | cmp bx,01Fh |
||
1059 | jge value_out_of_range |
||
1060 | cmp bx,0 |
||
1061 | jg fp_word_exp_ok |
||
1062 | or ax,1 shl 10 |
||
1063 | mov cx,bx |
||
1064 | neg cx |
||
1065 | inc cx |
||
1066 | cmp cx,10 |
||
1067 | ja value_out_of_range |
||
1068 | xor bx,bx |
||
1069 | shr ax,cl |
||
1070 | jnc fp_word_exp_ok |
||
1071 | inc ax |
||
1072 | test ax,1 shl 10 |
||
1073 | jz fp_word_exp_ok |
||
1074 | and ax,1 shl 10 - 1 |
||
1075 | inc bx |
||
1076 | fp_word_exp_ok: |
||
1077 | shl bx,10 |
||
1078 | or ax,bx |
||
1079 | fp_word_store: |
||
1080 | mov bl,[esi+11] |
||
1081 | shl bx,15 |
||
1082 | or ax,bx |
||
1083 | mov [edi],eax |
||
1084 | xor eax,eax |
||
1085 | mov [edi+4],eax |
||
1086 | add esi,13 |
||
1087 | ret |
||
1088 | convert_fp_dword: |
||
1089 | xor eax,eax |
||
1090 | cmp word [esi+8],8000h |
||
1091 | je fp_dword_store |
||
1092 | mov bx,[esi+8] |
||
1093 | mov eax,[esi+4] |
||
1094 | shl eax,1 |
||
1095 | shr eax,9 |
||
1096 | jnc fp_dword_ok |
||
1097 | inc eax |
||
1098 | bt eax,23 |
||
1099 | jnc fp_dword_ok |
||
1100 | and eax,1 shl 23 - 1 |
||
1101 | inc bx |
||
1102 | shr eax,1 |
||
1103 | fp_dword_ok: |
||
1104 | add bx,7Fh |
||
1105 | cmp bx,0FFh |
||
1106 | jge value_out_of_range |
||
1107 | cmp bx,0 |
||
1108 | jg fp_dword_exp_ok |
||
1109 | or eax,1 shl 23 |
||
1110 | mov cx,bx |
||
1111 | neg cx |
||
1112 | inc cx |
||
1113 | cmp cx,23 |
||
1114 | ja value_out_of_range |
||
1115 | xor bx,bx |
||
1116 | shr eax,cl |
||
1117 | jnc fp_dword_exp_ok |
||
1118 | inc eax |
||
1119 | test eax,1 shl 23 |
||
1120 | jz fp_dword_exp_ok |
||
1121 | and eax,1 shl 23 - 1 |
||
1122 | inc bx |
||
1123 | fp_dword_exp_ok: |
||
1124 | shl ebx,23 |
||
1125 | or eax,ebx |
||
1126 | fp_dword_store: |
||
1127 | mov bl,[esi+11] |
||
1128 | shl ebx,31 |
||
1129 | or eax,ebx |
||
1130 | mov [edi],eax |
||
1131 | xor eax,eax |
||
1132 | mov [edi+4],eax |
||
1133 | add esi,13 |
||
1134 | ret |
||
1135 | convert_fp_qword: |
||
1136 | xor eax,eax |
||
1137 | xor edx,edx |
||
1138 | cmp word [esi+8],8000h |
||
1139 | je fp_qword_store |
||
1140 | mov bx,[esi+8] |
||
1141 | mov eax,[esi] |
||
1142 | mov edx,[esi+4] |
||
1143 | add eax,eax |
||
1144 | adc edx,edx |
||
1145 | mov ecx,edx |
||
1146 | shr edx,12 |
||
1147 | shrd eax,ecx,12 |
||
1148 | jnc fp_qword_ok |
||
1149 | add eax,1 |
||
1150 | adc edx,0 |
||
1151 | bt edx,20 |
||
1152 | jnc fp_qword_ok |
||
1153 | and edx,1 shl 20 - 1 |
||
1154 | inc bx |
||
1155 | shr edx,1 |
||
1156 | rcr eax,1 |
||
1157 | fp_qword_ok: |
||
1158 | add bx,3FFh |
||
1159 | cmp bx,7FFh |
||
1160 | jge value_out_of_range |
||
1161 | cmp bx,0 |
||
1162 | jg fp_qword_exp_ok |
||
1163 | or edx,1 shl 20 |
||
1164 | mov cx,bx |
||
1165 | neg cx |
||
1166 | inc cx |
||
1167 | cmp cx,52 |
||
1168 | ja value_out_of_range |
||
1169 | cmp cx,32 |
||
1170 | jbe fp_qword_small_shift |
||
1171 | sub cx,32 |
||
1172 | mov eax,edx |
||
1173 | xor edx,edx |
||
1174 | shr eax,cl |
||
1175 | jmp fp_qword_shift_done |
||
1176 | fp_qword_small_shift: |
||
1177 | mov ebx,edx |
||
1178 | shr edx,cl |
||
1179 | shrd eax,ebx,cl |
||
1180 | fp_qword_shift_done: |
||
1181 | mov bx,0 |
||
1182 | jnc fp_qword_exp_ok |
||
1183 | add eax,1 |
||
1184 | adc edx,0 |
||
1185 | test edx,1 shl 20 |
||
1186 | jz fp_qword_exp_ok |
||
1187 | and edx,1 shl 20 - 1 |
||
1188 | inc bx |
||
1189 | fp_qword_exp_ok: |
||
1190 | shl ebx,20 |
||
1191 | or edx,ebx |
||
1192 | fp_qword_store: |
||
1193 | mov bl,[esi+11] |
||
1194 | shl ebx,31 |
||
1195 | or edx,ebx |
||
1196 | mov [edi],eax |
||
1197 | mov [edi+4],edx |
||
1198 | add esi,13 |
||
1199 | ret |
||
1200 | get_string_value: |
||
1201 | inc esi |
||
1202 | lods dword [esi] |
||
1203 | mov ecx,eax |
||
1204 | cmp ecx,8 |
||
1205 | ja value_out_of_range |
||
1206 | mov edx,edi |
||
1207 | xor eax,eax |
||
1208 | stos dword [edi] |
||
1209 | stos dword [edi] |
||
1210 | mov edi,edx |
||
1211 | rep movs byte [edi],[esi] |
||
1212 | mov edi,edx |
||
1213 | inc esi |
||
1214 | mov word [edi+8],0 |
||
1215 | mov byte [edi+12],0 |
||
1216 | ret |
||
1217 | |||
1218 | |||
1219 | mov [value_size],1 |
||
1220 | mov [size_override],-1 |
||
1221 | call calculate_expression |
||
1222 | mov eax,[edi+16] |
||
1223 | mov [symbol_identifier],eax |
||
1224 | mov [value_type],0 |
||
1225 | cmp word [edi+8],0 |
||
1226 | jne invalid_value |
||
1227 | cmp byte [edi+12],0 |
||
1228 | je check_byte_value |
||
1229 | cmp [error_line],0 |
||
1230 | jne check_byte_value |
||
1231 | mov eax,[current_line] |
||
1232 | mov [error_line],eax |
||
1233 | mov [error],invalid_use_of_symbol |
||
1234 | check_byte_value: |
||
1235 | mov eax,[edi] |
||
1236 | mov edx,[edi+4] |
||
1237 | or edx,edx |
||
1238 | jz byte_positive |
||
1239 | cmp edx,-1 |
||
1240 | jne range_exceeded |
||
1241 | cmp eax,-80h |
||
1242 | jb range_exceeded |
||
1243 | ret |
||
1244 | byte_positive: |
||
1245 | cmp eax,100h |
||
1246 | jae range_exceeded |
||
1247 | return_byte_value: |
||
1248 | ret |
||
1249 | range_exceeded: |
||
1250 | xor eax,eax |
||
1251 | xor edx,edx |
||
1252 | cmp [error_line],0 |
||
1253 | jne return_byte_value |
||
1254 | mov ecx,[current_line] |
||
1255 | mov [error_line],ecx |
||
1256 | mov [error],value_out_of_range |
||
1257 | ret |
||
1258 | get_word_value: |
||
1259 | mov [value_size],2 |
||
1260 | mov [size_override],-1 |
||
1261 | call calculate_expression |
||
1262 | cmp word [edi+8],0 |
||
1263 | jne invalid_value |
||
1264 | mov eax,[edi+16] |
||
1265 | mov [symbol_identifier],eax |
||
1266 | mov al,[edi+12] |
||
1267 | mov [value_type],al |
||
1268 | cmp al,2 |
||
1269 | jb check_word_value |
||
1270 | cmp [error_line],0 |
||
1271 | jne check_word_value |
||
1272 | mov eax,[current_line] |
||
1273 | mov [error_line],eax |
||
1274 | mov [error],invalid_use_of_symbol |
||
1275 | check_word_value: |
||
1276 | mov eax,[edi] |
||
1277 | mov edx,[edi+4] |
||
1278 | or edx,edx |
||
1279 | jz word_positive |
||
1280 | cmp edx,-1 |
||
1281 | jne range_exceeded |
||
1282 | cmp eax,-8000h |
||
1283 | jb range_exceeded |
||
1284 | ret |
||
1285 | word_positive: |
||
1286 | cmp eax,10000h |
||
1287 | jae range_exceeded |
||
1288 | ret |
||
1289 | get_dword_value: |
||
1290 | mov [value_size],4 |
||
1291 | mov [size_override],-1 |
||
1292 | call calculate_expression |
||
1293 | cmp word [edi+8],0 |
||
1294 | jne invalid_value |
||
1295 | mov eax,[edi+16] |
||
1296 | mov [symbol_identifier],eax |
||
1297 | mov al,[edi+12] |
||
1298 | mov [value_type],al |
||
1299 | cmp al,4 |
||
1300 | jne check_dword_value |
||
1301 | mov [value_type],2 |
||
1302 | mov eax,[edi] |
||
1303 | cdq |
||
1304 | cmp edx,[edi+4] |
||
1305 | jne range_exceeded |
||
1306 | ret |
||
1307 | check_dword_value: |
||
1308 | mov eax,[edi] |
||
1309 | mov edx,[edi+4] |
||
1310 | or edx,edx |
||
1311 | jz dword_positive |
||
1312 | cmp edx,-1 |
||
1313 | jne range_exceeded |
||
1314 | bt eax,31 |
||
1315 | jnc range_exceeded |
||
1316 | dword_positive: |
||
1317 | ret |
||
1318 | get_pword_value: |
||
1319 | mov [value_size],6 |
||
1320 | mov [size_override],-1 |
||
1321 | call calculate_expression |
||
1322 | mov eax,[edi+16] |
||
1323 | mov [symbol_identifier],eax |
||
1324 | cmp word [edi+8],0 |
||
1325 | jne invalid_value |
||
1326 | mov al,[edi+12] |
||
1327 | mov [value_type],al |
||
1328 | cmp al,4 |
||
1329 | jne check_pword_value |
||
1330 | cmp [error_line],0 |
||
1331 | jne check_pword_value |
||
1332 | mov eax,[current_line] |
||
1333 | mov [error_line],eax |
||
1334 | mov [error],invalid_use_of_symbol |
||
1335 | check_pword_value: |
||
1336 | mov eax,[edi] |
||
1337 | mov edx,[edi+4] |
||
1338 | cmp edx,10000h |
||
1339 | jge range_exceeded |
||
1340 | cmp edx,-8000h |
||
1341 | jl range_exceeded |
||
1342 | ret |
||
1343 | get_qword_value: |
||
1344 | mov [value_size],8 |
||
1345 | mov [size_override],-1 |
||
1346 | call calculate_expression |
||
1347 | cmp word [edi+8],0 |
||
1348 | jne invalid_value |
||
1349 | mov eax,[edi+16] |
||
1350 | mov [symbol_identifier],eax |
||
1351 | mov al,[edi+12] |
||
1352 | mov [value_type],al |
||
1353 | check_qword_value: |
||
1354 | mov eax,[edi] |
||
1355 | mov edx,[edi+4] |
||
1356 | ret |
||
1357 | get_count_value: |
||
1358 | mov [value_size],8 |
||
1359 | mov [size_override],-1 |
||
1360 | call calculate_expression |
||
1361 | cmp word [edi+8],0 |
||
1362 | jne invalid_value |
||
1363 | mov al,[edi+12] |
||
1364 | or al,al |
||
1365 | jz check_count_value |
||
1366 | cmp [error_line],0 |
||
1367 | jne check_count_value |
||
1368 | mov eax,[current_line] |
||
1369 | mov [error_line],eax |
||
1370 | mov [error],invalid_use_of_symbol |
||
1371 | check_count_value: |
||
1372 | mov eax,[edi] |
||
1373 | mov edx,[edi+4] |
||
1374 | or edx,edx |
||
1375 | jnz invalid_count_value |
||
1376 | ret |
||
1377 | invalid_count_value: |
||
1378 | cmp [error_line],0 |
||
1379 | jne zero_count |
||
1380 | mov eax,[current_line] |
||
1381 | mov [error_line],eax |
||
1382 | mov [error],invalid_value |
||
1383 | zero_count: |
||
1384 | xor eax,eax |
||
1385 | ret |
||
1386 | get_value: |
||
1387 | mov [operand_size],0 |
||
1388 | lods byte [esi] |
||
1389 | call get_size_operator |
||
1390 | cmp al,'(' |
||
1391 | jne invalid_value |
||
1392 | mov al,[operand_size] |
||
1393 | cmp al,1 |
||
1394 | je value_byte |
||
1395 | cmp al,2 |
||
1396 | je value_word |
||
1397 | cmp al,4 |
||
1398 | je value_dword |
||
1399 | cmp al,6 |
||
1400 | je value_pword |
||
1401 | cmp al,8 |
||
1402 | je value_qword |
||
1403 | or al,al |
||
1404 | jnz invalid_value |
||
1405 | value_qword: |
||
1406 | call get_qword_value |
||
1407 | ret |
||
1408 | value_pword: |
||
1409 | call get_pword_value |
||
1410 | movzx edx,dx |
||
1411 | ret |
||
1412 | value_dword: |
||
1413 | call get_dword_value |
||
1414 | xor edx,edx |
||
1415 | ret |
||
1416 | value_word: |
||
1417 | call get_word_value |
||
1418 | xor edx,edx |
||
1419 | movzx eax,ax |
||
1420 | ret |
||
1421 | value_byte: |
||
1422 | call get_byte_value |
||
1423 | xor edx,edx |
||
1424 | movzx eax,al |
||
1425 | ret |
||
1426 | get_address_word_value: |
||
1427 | mov [address_size],2 |
||
1428 | mov [value_size],2 |
||
1429 | jmp calculate_address |
||
1430 | get_address_dword_value: |
||
1431 | mov [address_size],4 |
||
1432 | mov [value_size],4 |
||
1433 | jmp calculate_address |
||
1434 | get_address_qword_value: |
||
1435 | mov [address_size],8 |
||
1436 | mov [value_size],8 |
||
1437 | jmp calculate_address |
||
1438 | get_address_value: |
||
1439 | mov [address_size],0 |
||
1440 | mov [value_size],8 |
||
1441 | calculate_address: |
||
1442 | cmp byte [esi],'.' |
||
1443 | je invalid_address |
||
1444 | call calculate_expression |
||
1445 | mov eax,[edi+16] |
||
1446 | mov [address_symbol],eax |
||
1447 | mov al,[edi+12] |
||
1448 | mov [value_type],al |
||
1449 | cmp al,6 |
||
1450 | je special_address_type_32bit |
||
1451 | cmp al,5 |
||
1452 | je special_address_type_32bit |
||
1453 | ja invalid_use_of_symbol |
||
1454 | test al,1 |
||
1455 | jnz invalid_use_of_symbol |
||
1456 | or al,al |
||
1457 | jz address_size_ok |
||
1458 | shl al,5 |
||
1459 | jmp address_symbol_ok |
||
1460 | special_address_type_32bit: |
||
1461 | mov al,40h |
||
1462 | address_symbol_ok: |
||
1463 | mov ah,[address_size] |
||
1464 | or [address_size],al |
||
1465 | shr al,4 |
||
1466 | or ah,ah |
||
1467 | jz address_size_ok |
||
1468 | cmp al,ah |
||
1469 | je address_size_ok |
||
1470 | cmp ax,0804h |
||
1471 | jne address_sizes_do_not_agree |
||
1472 | cmp [value_type],2 |
||
1473 | ja value_type_correction_ok |
||
1474 | mov [value_type],2 |
||
1475 | value_type_correction_ok: |
||
1476 | mov eax,[edi] |
||
1477 | cdq |
||
1478 | cmp edx,[edi+4] |
||
1479 | je address_size_ok |
||
1480 | cmp [error_line],0 |
||
1481 | jne address_size_ok |
||
1482 | mov ecx,[current_line] |
||
1483 | mov [error_line],ecx |
||
1484 | mov [error],value_out_of_range |
||
1485 | address_size_ok: |
||
1486 | xor ebx,ebx |
||
1487 | xor ecx,ecx |
||
1488 | mov cl,[value_type] |
||
1489 | shl ecx,16 |
||
1490 | mov ch,[address_size] |
||
1491 | cmp word [edi+8],0 |
||
1492 | je check_immediate_address |
||
1493 | mov al,[edi+8] |
||
1494 | mov dl,[edi+10] |
||
1495 | call get_address_register |
||
1496 | mov al,[edi+9] |
||
1497 | mov dl,[edi+11] |
||
1498 | call get_address_register |
||
1499 | mov ax,bx |
||
1500 | shr ah,4 |
||
1501 | shr al,4 |
||
1502 | or bh,bh |
||
1503 | jz check_address_registers |
||
1504 | or bl,bl |
||
1505 | jz check_address_registers |
||
1506 | cmp al,ah |
||
1507 | jne invalid_address |
||
1508 | check_address_registers: |
||
1509 | or al,ah |
||
1510 | mov ah,[address_size] |
||
1511 | and ah,0Fh |
||
1512 | jz address_registers_sizes_ok |
||
1513 | cmp al,ah |
||
1514 | jne address_sizes_do_not_match |
||
1515 | address_registers_sizes_ok: |
||
1516 | cmp al,4 |
||
1517 | je sib_allowed |
||
1518 | cmp al,8 |
||
1519 | je sib_allowed |
||
1520 | cmp al,0Fh |
||
1521 | je check_ip_relative_address |
||
1522 | or cl,cl |
||
1523 | jz check_word_value |
||
1524 | cmp cl,1 |
||
1525 | je check_word_value |
||
1526 | jmp invalid_address |
||
1527 | address_sizes_do_not_match: |
||
1528 | cmp al,0Fh |
||
1529 | jne invalid_address |
||
1530 | mov al,bh |
||
1531 | and al,0Fh |
||
1532 | cmp al,ah |
||
1533 | jne invalid_address |
||
1534 | check_ip_relative_address: |
||
1535 | cmp bh,0F4h |
||
1536 | je check_dword_value |
||
1537 | cmp bh,0F8h |
||
1538 | jne invalid_address |
||
1539 | mov eax,[edi] |
||
1540 | cdq |
||
1541 | cmp edx,[edi+4] |
||
1542 | jne range_exceeded |
||
1543 | ret |
||
1544 | get_address_register: |
||
1545 | or al,al |
||
1546 | jz address_register_ok |
||
1547 | cmp dl,1 |
||
1548 | jne scaled_register |
||
1549 | or bh,bh |
||
1550 | jnz scaled_register |
||
1551 | mov bh,al |
||
1552 | address_register_ok: |
||
1553 | ret |
||
1554 | scaled_register: |
||
1555 | or bl,bl |
||
1556 | jnz invalid_address |
||
1557 | mov bl,al |
||
1558 | mov cl,dl |
||
1559 | jmp address_register_ok |
||
1560 | sib_allowed: |
||
1561 | or bh,bh |
||
1562 | jnz check_index_with_base |
||
1563 | cmp cl,3 |
||
1564 | je special_index_scale |
||
1565 | cmp cl,5 |
||
1566 | je special_index_scale |
||
1567 | cmp cl,9 |
||
1568 | je special_index_scale |
||
1569 | cmp cl,2 |
||
1570 | jne check_index_scale |
||
1571 | cmp bl,45h |
||
1572 | jne special_index_scale |
||
1573 | cmp [code_type],64 |
||
1574 | je special_index_scale |
||
1575 | cmp [segment_register],4 |
||
1576 | jne special_index_scale |
||
1577 | cmp [value_type],0 |
||
1578 | jne check_index_scale |
||
1579 | mov al,[edi] |
||
1580 | cbw |
||
1581 | cwde |
||
1582 | cmp eax,[edi] |
||
1583 | jne check_index_scale |
||
1584 | cdq |
||
1585 | cmp edx,[edi+4] |
||
1586 | jne check_immediate_address |
||
1587 | special_index_scale: |
||
1588 | mov bh,bl |
||
1589 | dec cl |
||
1590 | check_immediate_address: |
||
1591 | mov al,[address_size] |
||
1592 | and al,0Fh |
||
1593 | cmp al,2 |
||
1594 | je check_word_value |
||
1595 | cmp al,4 |
||
1596 | je check_dword_value |
||
1597 | cmp al,8 |
||
1598 | je check_qword_value |
||
1599 | or al,al |
||
1600 | jnz invalid_value |
||
1601 | cmp [code_type],64 |
||
1602 | jne check_dword_value |
||
1603 | jmp check_qword_value |
||
1604 | check_index_with_base: |
||
1605 | cmp cl,1 |
||
1606 | jne check_index_scale |
||
1607 | cmp bl,44h |
||
1608 | je swap_base_with_index |
||
1609 | cmp bl,84h |
||
1610 | je swap_base_with_index |
||
1611 | cmp [code_type],64 |
||
1612 | je check_for_rbp_base |
||
1613 | cmp bl,45h |
||
1614 | jne check_for_ebp_base |
||
1615 | cmp [segment_register],3 |
||
1616 | je swap_base_with_index |
||
1617 | jmp check_immediate_address |
||
1618 | check_for_ebp_base: |
||
1619 | cmp bh,45h |
||
1620 | jne check_immediate_address |
||
1621 | cmp [segment_register],4 |
||
1622 | jne check_immediate_address |
||
1623 | swap_base_with_index: |
||
1624 | xchg bl,bh |
||
1625 | jmp check_immediate_address |
||
1626 | check_for_rbp_base: |
||
1627 | cmp bh,45h |
||
1628 | je swap_base_with_index |
||
1629 | cmp bh,85h |
||
1630 | je swap_base_with_index |
||
1631 | jmp check_immediate_address |
||
1632 | check_index_scale: |
||
1633 | test cl,not 1111b |
||
1634 | jnz invalid_address |
||
1635 | mov al,cl |
||
1636 | dec al |
||
1637 | and al,cl |
||
1638 | jz check_immediate_address |
||
1639 | jmp invalid_address |
||
1640 | calculate_relative_offset: |
||
1641 | cmp [value_undefined],0 |
||
1642 | jne relative_offset_ok |
||
1643 | test bh,bh |
||
1644 | setne ch |
||
1645 | cmp bx,word [org_registers] |
||
1646 | je origin_registers_ok |
||
1647 | xchg bh,bl |
||
1648 | xchg ch,cl |
||
1649 | cmp bx,word [org_registers] |
||
1650 | jne invalid_value |
||
1651 | origin_registers_ok: |
||
1652 | cmp cx,word [org_registers+2] |
||
1653 | jne invalid_value |
||
1654 | add eax,dword [org_origin] |
||
1655 | adc edx,dword [org_origin+4] |
||
1656 | sub eax,edi |
||
1657 | sbb edx,0 |
||
1658 | mov bl,[value_type] |
||
1659 | or bl,bl |
||
1660 | je relative_offset_ok |
||
1661 | test bl,1 |
||
1662 | jnz invalid_use_of_symbol |
||
1663 | mov ecx,[address_symbol] |
||
1664 | mov [symbol_identifier],ecx |
||
1665 | cmp bl,6 |
||
1666 | je plt_relative_offset |
||
1667 | cmp bl,[labels_type] |
||
1668 | jne invalid_use_of_symbol |
||
1669 | mov [value_type],0 |
||
1670 | cmp ecx,[org_symbol] |
||
1671 | je relative_offset_ok |
||
1672 | mov [value_type],3 |
||
1673 | relative_offset_ok: |
||
1674 | ret |
||
1675 | plt_relative_offset: |
||
1676 | mov [value_type],7 |
||
1677 | ret |
||
1678 | |||
1679 | |||
1680 | xor al,al |
||
1681 | calculate_embedded_logical_expression: |
||
1682 | mov [logical_value_wrapping],al |
||
1683 | call get_logical_value |
||
1684 | logical_loop: |
||
1685 | cmp byte [esi],'|' |
||
1686 | je logical_or |
||
1687 | cmp byte [esi],'&' |
||
1688 | je logical_and |
||
1689 | ret |
||
1690 | logical_or: |
||
1691 | inc esi |
||
1692 | or al,al |
||
1693 | jnz logical_value_already_determined |
||
1694 | push eax |
||
1695 | call get_logical_value |
||
1696 | pop ebx |
||
1697 | or al,bl |
||
1698 | jmp logical_loop |
||
1699 | logical_and: |
||
1700 | inc esi |
||
1701 | or al,al |
||
1702 | jz logical_value_already_determined |
||
1703 | push eax |
||
1704 | call get_logical_value |
||
1705 | pop ebx |
||
1706 | and al,bl |
||
1707 | jmp logical_loop |
||
1708 | logical_value_already_determined: |
||
1709 | push eax |
||
1710 | call skip_logical_value |
||
1711 | jc invalid_expression |
||
1712 | pop eax |
||
1713 | jmp logical_loop |
||
1714 | get_logical_value: |
||
1715 | xor al,al |
||
1716 | check_for_negation: |
||
1717 | cmp byte [esi],'~' |
||
1718 | jne negation_ok |
||
1719 | inc esi |
||
1720 | xor al,-1 |
||
1721 | jmp check_for_negation |
||
1722 | negation_ok: |
||
1723 | push eax |
||
1724 | mov al,[esi] |
||
1725 | cmp al,'{' |
||
1726 | je logical_expression |
||
1727 | cmp al,0FFh |
||
1728 | je invalid_expression |
||
1729 | cmp al,88h |
||
1730 | je check_for_defined |
||
1731 | cmp al,89h |
||
1732 | je check_for_used |
||
1733 | cmp al,'0' |
||
1734 | je given_false |
||
1735 | cmp al,'1' |
||
1736 | je given_true |
||
1737 | call get_value |
||
1738 | mov bl,[value_type] |
||
1739 | push eax edx ebx |
||
1740 | mov al,[esi] |
||
1741 | or al,al |
||
1742 | jz logical_number |
||
1743 | cmp al,0Fh |
||
1744 | je logical_number |
||
1745 | cmp al,'}' |
||
1746 | je logical_number |
||
1747 | cmp al,'&' |
||
1748 | je logical_number |
||
1749 | cmp al,'|' |
||
1750 | je logical_number |
||
1751 | inc esi |
||
1752 | mov [compare_type],al |
||
1753 | call get_value |
||
1754 | pop ebx |
||
1755 | cmp [next_pass_needed],0 |
||
1756 | jne values_ok |
||
1757 | cmp bl,[value_type] |
||
1758 | jne invalid_use_of_symbol |
||
1759 | values_ok: |
||
1760 | pop ecx ebx |
||
1761 | cmp [compare_type],'=' |
||
1762 | je check_equal |
||
1763 | cmp [compare_type],'>' |
||
1764 | je check_greater |
||
1765 | cmp [compare_type],'<' |
||
1766 | je check_less |
||
1767 | cmp [compare_type],0F1h |
||
1768 | je check_not_equal |
||
1769 | cmp [compare_type],0F2h |
||
1770 | je check_not_less |
||
1771 | cmp [compare_type],0F3h |
||
1772 | je check_not_greater |
||
1773 | jmp invalid_expression |
||
1774 | check_equal: |
||
1775 | cmp eax,ebx |
||
1776 | jne return_false |
||
1777 | cmp edx,ecx |
||
1778 | jne return_false |
||
1779 | jmp return_true |
||
1780 | check_greater: |
||
1781 | cmp edx,ecx |
||
1782 | jl return_true |
||
1783 | jg return_false |
||
1784 | cmp eax,ebx |
||
1785 | jb return_true |
||
1786 | jae return_false |
||
1787 | check_less: |
||
1788 | cmp edx,ecx |
||
1789 | jl return_false |
||
1790 | jg return_true |
||
1791 | cmp eax,ebx |
||
1792 | jbe return_false |
||
1793 | ja return_true |
||
1794 | check_not_less: |
||
1795 | cmp edx,ecx |
||
1796 | jl return_true |
||
1797 | jg return_false |
||
1798 | cmp eax,ebx |
||
1799 | jbe return_true |
||
1800 | ja return_false |
||
1801 | check_not_greater: |
||
1802 | cmp edx,ecx |
||
1803 | jl return_false |
||
1804 | jg return_true |
||
1805 | cmp eax,ebx |
||
1806 | jb return_false |
||
1807 | jae return_true |
||
1808 | check_not_equal: |
||
1809 | cmp eax,ebx |
||
1810 | jne return_true |
||
1811 | cmp edx,ecx |
||
1812 | jne return_true |
||
1813 | jmp return_false |
||
1814 | logical_number: |
||
1815 | pop ebx edx eax |
||
1816 | or bl,bl |
||
1817 | jnz invalid_expression |
||
1818 | or eax,edx |
||
1819 | jnz return_true |
||
1820 | jmp return_false |
||
1821 | check_for_defined: |
||
1822 | or bl,-1 |
||
1823 | lods word [esi] |
||
1824 | cmp ah,'(' |
||
1825 | jne invalid_expression |
||
1826 | check_expression: |
||
1827 | lods byte [esi] |
||
1828 | or al,al |
||
1829 | jz defined_string |
||
1830 | cmp al,'.' |
||
1831 | je defined_fp_value |
||
1832 | cmp al,')' |
||
1833 | je expression_checked |
||
1834 | cmp al,'!' |
||
1835 | je invalid_expression |
||
1836 | cmp al,0Fh |
||
1837 | je check_expression |
||
1838 | cmp al,10h |
||
1839 | je defined_register |
||
1840 | cmp al,11h |
||
1841 | je check_if_symbol_defined |
||
1842 | cmp al,80h |
||
1843 | jae check_expression |
||
1844 | movzx eax,al |
||
1845 | add esi,eax |
||
1846 | jmp check_expression |
||
1847 | defined_register: |
||
1848 | inc esi |
||
1849 | jmp check_expression |
||
1850 | defined_fp_value: |
||
1851 | add esi,12 |
||
1852 | jmp expression_checked |
||
1853 | defined_string: |
||
1854 | lods dword [esi] |
||
1855 | add esi,eax |
||
1856 | inc esi |
||
1857 | jmp expression_checked |
||
1858 | check_if_symbol_defined: |
||
1859 | lods dword [esi] |
||
1860 | cmp eax,-1 |
||
1861 | je invalid_expression |
||
1862 | cmp eax,0Fh |
||
1863 | jb check_expression |
||
1864 | je reserved_word_used_as_symbol |
||
1865 | test byte [eax+8],4 |
||
1866 | jnz no_prediction |
||
1867 | test byte [eax+8],1 |
||
1868 | jz symbol_predicted_undefined |
||
1869 | mov cx,[current_pass] |
||
1870 | sub cx,[eax+16] |
||
1871 | jz check_expression |
||
1872 | cmp cx,1 |
||
1873 | ja symbol_predicted_undefined |
||
1874 | or byte [eax+8],40h+80h |
||
1875 | jmp check_expression |
||
1876 | no_prediction: |
||
1877 | test byte [eax+8],1 |
||
1878 | jz symbol_undefined |
||
1879 | mov cx,[current_pass] |
||
1880 | sub cx,[eax+16] |
||
1881 | jz check_expression |
||
1882 | jmp symbol_undefined |
||
1883 | symbol_predicted_undefined: |
||
1884 | or byte [eax+8],40h |
||
1885 | and byte [eax+8],not 80h |
||
1886 | symbol_undefined: |
||
1887 | xor bl,bl |
||
1888 | jmp check_expression |
||
1889 | expression_checked: |
||
1890 | mov al,bl |
||
1891 | jmp logical_value_ok |
||
1892 | check_for_used: |
||
1893 | lods word [esi] |
||
1894 | cmp ah,2 |
||
1895 | jne invalid_expression |
||
1896 | lods dword [esi] |
||
1897 | cmp eax,0Fh |
||
1898 | jb invalid_use_of_symbol |
||
1899 | je reserved_word_used_as_symbol |
||
1900 | inc esi |
||
1901 | test byte [eax+8],8 |
||
1902 | jz not_used |
||
1903 | mov cx,[current_pass] |
||
1904 | sub cx,[eax+18] |
||
1905 | jz return_true |
||
1906 | cmp cx,1 |
||
1907 | ja not_used |
||
1908 | or byte [eax+8],10h+20h |
||
1909 | jmp return_true |
||
1910 | not_used: |
||
1911 | or byte [eax+8],10h |
||
1912 | and byte [eax+8],not 20h |
||
1913 | jmp return_false |
||
1914 | given_false: |
||
1915 | inc esi |
||
1916 | return_false: |
||
1917 | xor al,al |
||
1918 | jmp logical_value_ok |
||
1919 | given_true: |
||
1920 | inc esi |
||
1921 | return_true: |
||
1922 | or al,-1 |
||
1923 | jmp logical_value_ok |
||
1924 | logical_expression: |
||
1925 | lods byte [esi] |
||
1926 | mov dl,[logical_value_wrapping] |
||
1927 | push edx |
||
1928 | call calculate_embedded_logical_expression |
||
1929 | pop edx |
||
1930 | mov [logical_value_wrapping],dl |
||
1931 | push eax |
||
1932 | lods byte [esi] |
||
1933 | cmp al,'}' |
||
1934 | jne invalid_expression |
||
1935 | pop eax |
||
1936 | logical_value_ok: |
||
1937 | pop ebx |
||
1938 | xor al,bl |
||
1939 | ret |
||
1940 | |||
1941 | |||
1942 | lods byte [esi] |
||
1943 | or al,al |
||
1944 | jz nothing_to_skip |
||
1945 | cmp al,0Fh |
||
1946 | je nothing_to_skip |
||
1947 | cmp al,1 |
||
1948 | je skip_instruction |
||
1949 | cmp al,2 |
||
1950 | je skip_label |
||
1951 | cmp al,3 |
||
1952 | je skip_label |
||
1953 | cmp al,20h |
||
1954 | jb skip_assembler_symbol |
||
1955 | cmp al,'(' |
||
1956 | je skip_expression |
||
1957 | cmp al,'[' |
||
1958 | je skip_address |
||
1959 | skip_done: |
||
1960 | clc |
||
1961 | ret |
||
1962 | skip_label: |
||
1963 | add esi,2 |
||
1964 | skip_instruction: |
||
1965 | add esi,2 |
||
1966 | skip_assembler_symbol: |
||
1967 | inc esi |
||
1968 | jmp skip_done |
||
1969 | skip_address: |
||
1970 | mov al,[esi] |
||
1971 | and al,11110000b |
||
1972 | cmp al,60h |
||
1973 | jb skip_expression |
||
1974 | cmp al,70h |
||
1975 | ja skip_expression |
||
1976 | inc esi |
||
1977 | jmp skip_address |
||
1978 | skip_expression: |
||
1979 | lods byte [esi] |
||
1980 | or al,al |
||
1981 | jz skip_string |
||
1982 | cmp al,'.' |
||
1983 | je skip_fp_value |
||
1984 | cmp al,')' |
||
1985 | je skip_done |
||
1986 | cmp al,']' |
||
1987 | je skip_done |
||
1988 | cmp al,'!' |
||
1989 | je skip_expression |
||
1990 | cmp al,0Fh |
||
1991 | je skip_expression |
||
1992 | cmp al,10h |
||
1993 | je skip_register |
||
1994 | cmp al,11h |
||
1995 | je skip_label_value |
||
1996 | cmp al,80h |
||
1997 | jae skip_expression |
||
1998 | movzx eax,al |
||
1999 | add esi,eax |
||
2000 | jmp skip_expression |
||
2001 | skip_label_value: |
||
2002 | add esi,3 |
||
2003 | skip_register: |
||
2004 | inc esi |
||
2005 | jmp skip_expression |
||
2006 | skip_fp_value: |
||
2007 | add esi,12 |
||
2008 | jmp skip_done |
||
2009 | skip_string: |
||
2010 | lods dword [esi] |
||
2011 | add esi,eax |
||
2012 | inc esi |
||
2013 | jmp skip_done |
||
2014 | nothing_to_skip: |
||
2015 | dec esi |
||
2016 | stc |
||
2017 | ret' |
||
2018 | > |