Rev 7836 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 7836 | Rev 9459 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | ; flat assembler core |
1 | ; flat assembler core |
2 | ; Copyright (c) 1999-2020, Tomasz Grysztar. |
2 | ; Copyright (c) 1999-2021, Tomasz Grysztar. |
3 | ; All rights reserved. |
3 | ; All rights reserved. |
Line 4... | Line 4... | ||
4 | 4 | ||
5 | preprocessor: |
5 | preprocessor: |
6 | mov edi,characters |
6 | mov edi,characters |
Line 684... | Line 684... | ||
684 | mov cl,[esi-1] |
684 | mov cl,[esi-1] |
685 | mov ch,10b |
685 | mov ch,10b |
686 | call get_preprocessor_symbol |
686 | call get_preprocessor_symbol |
687 | jc struc_name_ok |
687 | jc struc_name_ok |
688 | mov ecx,[edx+12] |
688 | test edx,edx |
- | 689 | jz reserved_word_used_as_symbol |
|
- | 690 | mov ecx,[edx+12] |
|
689 | add ecx,3 |
691 | add ecx,3 |
690 | lea ebx,[edi+ecx] |
692 | lea ebx,[edi+ecx] |
691 | mov ecx,edi |
693 | mov ecx,edi |
692 | sub ecx,[struc_label] |
694 | sub ecx,[struc_label] |
693 | lea esi,[edi-1] |
695 | lea esi,[edi-1] |
Line 743... | Line 745... | ||
743 | jne preprocess_instruction |
745 | jne preprocess_instruction |
744 | inc esi |
746 | inc esi |
745 | jmp preprocess_instruction |
747 | jmp preprocess_instruction |
746 | symbolic_constant_in_label: |
748 | symbolic_constant_in_label: |
747 | mov ebx,[edx+8] |
749 | test edx,edx |
- | 750 | jz reserved_word_used_as_symbol |
|
- | 751 | mov ebx,[edx+8] |
|
748 | mov ecx,[edx+12] |
752 | mov ecx,[edx+12] |
749 | add ecx,ebx |
753 | add ecx,ebx |
750 | check_for_broken_label: |
754 | check_for_broken_label: |
751 | cmp ebx,ecx |
755 | cmp ebx,ecx |
752 | je label_broken |
756 | je label_broken |
Line 804... | Line 808... | ||
804 | get_preprocessor_symbol: |
808 | get_preprocessor_symbol: |
805 | push ebp edi esi |
809 | push ebp edi esi |
806 | mov ebp,ecx |
810 | mov ebp,ecx |
807 | shl ebp,22 |
811 | shl ebp,22 |
- | 812 | mov al,ch |
|
- | 813 | and al,11b |
|
808 | movzx ecx,cl |
814 | movzx ecx,cl |
- | 815 | cmp al,10b |
|
- | 816 | jne no_preprocessor_special_symbol |
|
- | 817 | cmp cl,4 |
|
- | 818 | jbe no_preprocessor_special_symbol |
|
- | 819 | mov ax,'__' |
|
- | 820 | cmp ax,[esi] |
|
- | 821 | jne no_preprocessor_special_symbol |
|
- | 822 | cmp ax,[esi+ecx-2] |
|
- | 823 | jne no_preprocessor_special_symbol |
|
- | 824 | add esi,2 |
|
- | 825 | sub ecx,4 |
|
- | 826 | push ebp |
|
- | 827 | mov edi,preprocessor_special_symbols |
|
- | 828 | call get_directive |
|
- | 829 | pop ebp |
|
- | 830 | jc preprocessor_special_symbol_not_recognized |
|
- | 831 | add esi,2 |
|
- | 832 | xor edx,edx |
|
- | 833 | jmp preprocessor_symbol_found |
|
- | 834 | preprocessor_special_symbol_not_recognized: |
|
- | 835 | add ecx,4 |
|
- | 836 | sub esi,2 |
|
- | 837 | no_preprocessor_special_symbol: |
|
809 | mov ebx,hash_tree |
838 | mov ebx,hash_tree |
810 | mov edi,10 |
839 | mov edi,10 |
811 | follow_hashes_roots: |
840 | follow_hashes_roots: |
812 | mov edx,[ebx] |
841 | mov edx,[ebx] |
813 | or edx,edx |
842 | or edx,edx |
Line 1331... | Line 1360... | ||
1331 | lods byte [esi] |
1360 | lods byte [esi] |
1332 | mov cl,al |
1361 | mov cl,al |
1333 | call get_preprocessor_symbol |
1362 | call get_preprocessor_symbol |
1334 | jc no_symbol_to_restore |
1363 | jc no_symbol_to_restore |
1335 | mov dword [edx+4],0 |
1364 | test edx,edx |
- | 1365 | jz symbol_restored |
|
- | 1366 | mov dword [edx+4],0 |
|
1336 | jmp symbol_restored |
1367 | jmp symbol_restored |
1337 | no_symbol_to_restore: |
1368 | no_symbol_to_restore: |
1338 | add esi,ecx |
1369 | add esi,ecx |
1339 | symbol_restored: |
1370 | symbol_restored: |
1340 | pop ecx |
1371 | pop ecx |
Line 1381... | Line 1412... | ||
1381 | call get_preprocessor_symbol |
1412 | call get_preprocessor_symbol |
1382 | jc no_replacing |
1413 | jc no_replacing |
1383 | mov [current_section],edi |
1414 | mov [current_section],edi |
1384 | replace_symbolic_constant: |
1415 | replace_symbolic_constant: |
1385 | mov ecx,[edx+12] |
1416 | test edx,edx |
- | 1417 | jz replace_special_symbolic_constant |
|
- | 1418 | mov ecx,[edx+12] |
|
1386 | mov edx,[edx+8] |
1419 | mov edx,[edx+8] |
1387 | xchg esi,edx |
1420 | xchg esi,edx |
1388 | call move_data |
1421 | call move_data |
1389 | mov esi,edx |
1422 | mov esi,edx |
1390 | process_after_replaced: |
1423 | process_after_replaced: |
Line 1449... | Line 1482... | ||
1449 | mov ah,cl |
1482 | mov ah,cl |
1450 | stos word [edi] |
1483 | stos word [edi] |
1451 | call move_data |
1484 | call move_data |
1452 | jmp process_after_replaced |
1485 | jmp process_after_replaced |
1453 | process_macro_operators: |
1486 | replace_special_symbolic_constant: |
- | 1487 | jmp near eax |
|
- | 1488 | preprocessed_file_value: |
|
- | 1489 | call get_current_line_from_file |
|
- | 1490 | test ebx,ebx |
|
- | 1491 | jz process_after_replaced |
|
- | 1492 | push esi edi |
|
- | 1493 | mov esi,[ebx] |
|
- | 1494 | mov edi,esi |
|
- | 1495 | xor al,al |
|
- | 1496 | or ecx,-1 |
|
- | 1497 | repne scas byte [edi] |
|
- | 1498 | add ecx,2 |
|
- | 1499 | neg ecx |
|
- | 1500 | pop edi |
|
- | 1501 | lea eax,[edi+1+4+ecx] |
|
- | 1502 | cmp eax,[memory_end] |
|
- | 1503 | ja out_of_memory |
|
- | 1504 | mov al,22h |
|
- | 1505 | stos byte [edi] |
|
- | 1506 | mov eax,ecx |
|
- | 1507 | stos dword [edi] |
|
- | 1508 | rep movs byte [edi],[esi] |
|
- | 1509 | pop esi |
|
- | 1510 | jmp process_after_replaced |
|
- | 1511 | preprocessed_line_value: |
|
- | 1512 | call get_current_line_from_file |
|
- | 1513 | test ebx,ebx |
|
- | 1514 | jz process_after_replaced |
|
- | 1515 | lea eax,[edi+1+4+20] |
|
- | 1516 | cmp eax,[memory_end] |
|
- | 1517 | ja out_of_memory |
|
- | 1518 | mov ecx,[ebx+4] |
|
- | 1519 | call store_number_symbol |
|
- | 1520 | jmp process_after_replaced |
|
- | 1521 | get_current_line_from_file: |
|
- | 1522 | mov ebx,[current_line] |
|
- | 1523 | find_line_from_file: |
|
- | 1524 | test ebx,ebx |
|
- | 1525 | jz line_from_file_found |
|
- | 1526 | test byte [ebx+7],80h |
|
- | 1527 | jz line_from_file_found |
|
- | 1528 | mov ebx,[ebx+8] |
|
- | 1529 | jmp find_line_from_file |
|
- | 1530 | line_from_file_found: |
|
- | 1531 | ret |
|
- | 1532 | ||
- | 1533 | process_macro_operators: |
|
1454 | xor dl,dl |
1534 | xor dl,dl |
1455 | mov ebp,edi |
1535 | mov ebp,edi |
1456 | before_macro_operators: |
1536 | before_macro_operators: |
1457 | mov edi,esi |
1537 | mov edi,esi |
1458 | lods byte [esi] |
1538 | lods byte [esi] |
Line 1807... | Line 1887... | ||
1807 | pop [macro_symbols] |
1887 | pop [macro_symbols] |
1808 | pop [free_additional_memory] |
1888 | pop [free_additional_memory] |
1809 | jmp line_preprocessed |
1889 | jmp line_preprocessed |
1810 | use_instant_macro: |
1890 | use_instant_macro: |
1811 | push edi [current_line] esi |
1891 | push edi |
- | 1892 | push [current_line] |
|
1812 | mov eax,[error_line] |
1893 | push esi |
- | 1894 | mov eax,[error_line] |
|
1813 | mov [current_line],eax |
1895 | mov [current_line],eax |
1814 | mov [macro_line],eax |
1896 | mov [macro_line],eax |
1815 | mov esi,[instant_macro_start] |
1897 | mov esi,[instant_macro_start] |
1816 | cmp [base_code],10h |
1898 | cmp [base_code],10h |
1817 | jae do_match |
1899 | jae do_match |
Line 2021... | Line 2103... | ||
2021 | mov cl,al |
2103 | mov cl,al |
2022 | mov ch,10b |
2104 | mov ch,10b |
2023 | call get_preprocessor_symbol |
2105 | call get_preprocessor_symbol |
2024 | jc instant_macro_finish |
2106 | jc instant_macro_finish |
2025 | push edx |
2107 | test edx,edx |
- | 2108 | jz invalid_use_of_symbol |
|
- | 2109 | push edx |
|
2026 | mark_variable_value: |
2110 | mark_variable_value: |
2027 | inc [counter_limit] |
2111 | inc [counter_limit] |
2028 | mov [edx+4],ebp |
2112 | mov [edx+4],ebp |
2029 | next_variable_value: |
2113 | next_variable_value: |
2030 | mov edx,[edx] |
2114 | mov edx,[edx] |