diff --git a/SOURCE/EXPRPARS.INC b/SOURCE/EXPRPARS.INC index 3aadbad..1aa69f7 100644 --- a/SOURCE/EXPRPARS.INC +++ b/SOURCE/EXPRPARS.INC @@ -192,8 +192,6 @@ convert_number: ret preprocessor_value: dec edi - cmp [hash_tree],0 - je invalid_value lods byte [esi] cmp al,1Ah jne invalid_value @@ -202,6 +200,8 @@ convert_number: mov ch,10b call get_preprocessor_symbol jc invalid_value + test edx,edx + jz special_preprocessor_value push esi mov esi,[edx+8] push [current_offset] @@ -209,6 +209,15 @@ convert_number: pop [current_offset] pop esi ret + special_preprocessor_value: + cmp eax,preprocessed_line_value + jne invalid_value + call get_current_line_from_file + mov al,4 + stos byte [edi] + mov eax,[ebx+4] + stos dword [edi] + ret get_number: xor ebp,ebp diff --git a/SOURCE/PREPROCE.INC b/SOURCE/PREPROCE.INC index b9b6776..b676e2d 100644 --- a/SOURCE/PREPROCE.INC +++ b/SOURCE/PREPROCE.INC @@ -686,6 +686,8 @@ preprocess_line: mov ch,10b call get_preprocessor_symbol jc struc_name_ok + test edx,edx + jz reserved_word_used_as_symbol mov ecx,[edx+12] add ecx,3 lea ebx,[edi+ecx] @@ -745,6 +747,8 @@ preprocess_line: inc esi jmp preprocess_instruction symbolic_constant_in_label: + test edx,edx + jz reserved_word_used_as_symbol mov ebx,[edx+8] mov ecx,[edx+12] add ecx,ebx @@ -806,7 +810,32 @@ get_preprocessor_symbol: push ebp edi esi mov ebp,ecx shl ebp,22 + mov al,ch + and al,11b movzx ecx,cl + cmp al,10b + jne no_preprocessor_special_symbol + cmp cl,4 + jbe no_preprocessor_special_symbol + mov ax,'__' + cmp ax,[esi] + jne no_preprocessor_special_symbol + cmp ax,[esi+ecx-2] + jne no_preprocessor_special_symbol + add esi,2 + sub ecx,4 + push ebp + mov edi,preprocessor_special_symbols + call get_directive + pop ebp + jc preprocessor_special_symbol_not_recognized + add esi,2 + xor edx,edx + jmp preprocessor_symbol_found + preprocessor_special_symbol_not_recognized: + add ecx,4 + sub esi,2 + no_preprocessor_special_symbol: mov ebx,hash_tree mov edi,10 follow_hashes_roots: @@ -1333,6 +1362,8 @@ restore_equ_constant: mov cl,al call get_preprocessor_symbol jc no_symbol_to_restore + test edx,edx + jz symbol_restored mov dword [edx+4],0 jmp symbol_restored no_symbol_to_restore: @@ -1383,6 +1414,8 @@ process_equ_constants: jc no_replacing mov [current_section],edi replace_symbolic_constant: + test edx,edx + jz replace_special_symbolic_constant mov ecx,[edx+12] mov edx,[edx+8] xchg esi,edx @@ -1451,6 +1484,53 @@ process_equ_constants: stos word [edi] call move_data jmp process_after_replaced + replace_special_symbolic_constant: + jmp near eax + preprocessed_file_value: + call get_current_line_from_file + test ebx,ebx + jz process_after_replaced + push esi edi + mov esi,[ebx] + mov edi,esi + xor al,al + or ecx,-1 + repne scas byte [edi] + add ecx,2 + neg ecx + pop edi + lea eax,[edi+1+4+ecx] + cmp eax,[memory_end] + ja out_of_memory + mov al,22h + stos byte [edi] + mov eax,ecx + stos dword [edi] + rep movs byte [edi],[esi] + pop esi + jmp process_after_replaced + preprocessed_line_value: + call get_current_line_from_file + test ebx,ebx + jz process_after_replaced + lea eax,[edi+1+4+20] + cmp eax,[memory_end] + ja out_of_memory + mov ecx,[ebx+4] + call store_number_symbol + jmp process_after_replaced + get_current_line_from_file: + mov ebx,[current_line] + find_line_from_file: + test ebx,ebx + jz line_from_file_found + test byte [ebx+7],80h + jz line_from_file_found + mov ebx,[ebx+8] + jmp find_line_from_file + line_from_file_found: + ret + process_macro_operators: xor dl,dl mov ebp,edi @@ -2025,6 +2105,8 @@ do_irp: mov ch,10b call get_preprocessor_symbol jc instant_macro_finish + test edx,edx + jz invalid_use_of_symbol push edx mark_variable_value: inc [counter_limit] diff --git a/SOURCE/SYMBDUMP.INC b/SOURCE/SYMBDUMP.INC index f93a6cf..b557cd8 100644 --- a/SOURCE/SYMBDUMP.INC +++ b/SOURCE/SYMBDUMP.INC @@ -447,4 +447,4 @@ dump_preprocessed_source: call write jc write_failed call close - ret \ No newline at end of file + ret diff --git a/SOURCE/TABLES.INC b/SOURCE/TABLES.INC index c80cb68..125648c 100644 --- a/SOURCE/TABLES.INC +++ b/SOURCE/TABLES.INC @@ -48,6 +48,13 @@ macro_directives: dw reverse_block-directive_handler db 0 +preprocessor_special_symbols: + db 4,'file' + dw preprocessed_file_value-directive_handler + db 4,'line' + dw preprocessed_line_value-directive_handler + db 0 + operators: db 1,'+',80h db 1,'-',81h @@ -457,7 +464,7 @@ instructions: dw instructions_14-instructions,(instructions_15-instructions_14)/(14+3) dw instructions_15-instructions,(instructions_16-instructions_15)/(15+3) dw instructions_16-instructions,(instructions_17-instructions_16)/(16+3) - dw instructions_17-instructions,(instructions_end-instructions_17)/(16+3) + dw instructions_17-instructions,(instructions_end-instructions_17)/(17+3) instructions_2: db 'bt',4 diff --git a/SOURCE/VERSION.INC b/SOURCE/VERSION.INC index 4443991..7cea885 100644 --- a/SOURCE/VERSION.INC +++ b/SOURCE/VERSION.INC @@ -33,7 +33,7 @@ ; cannot simply be copied and put under another distribution licence ; (including the GNU Public Licence). -VERSION_STRING equ "1.73.27" +VERSION_STRING equ "1.73.28" VERSION_MAJOR = 1 VERSION_MINOR = 73 diff --git a/WHATSNEW.TXT b/WHATSNEW.TXT index da7ee53..44f10a4 100644 --- a/WHATSNEW.TXT +++ b/WHATSNEW.TXT @@ -2,6 +2,12 @@ Visit http://flatassembler.net/ for more information. +version 1.73.28 (Sep 16, 2021) + +[+] Added special preprocessing of symbols "__file__" and "__line__" + (backported from flat assembler g). + + version 1.73.27 (Jan 27, 2021) [-] The assembler should no longer prematurely abort when sign-extended 32-bit