fasm 1.67.25

git-svn-id: svn://kolibrios.org@692 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
heavyiron 2007-12-30 23:34:37 +00:00
parent b4c6fb8d7b
commit 4dbfb6d6a0
9 changed files with 367 additions and 99 deletions

View File

@ -4,128 +4,168 @@
; All rights reserved. ; All rights reserved.
out_of_memory: out_of_memory:
call fatal_error push _out_of_memory
db 'out of memory',0 jmp fatal_error
stack_overflow: stack_overflow:
call fatal_error push _stack_overflow
db 'out of stack space',0 jmp fatal_error
main_file_not_found: main_file_not_found:
call fatal_error push _main_file_not_found
db 'source file not found',0 jmp fatal_error
unexpected_end_of_file: unexpected_end_of_file:
call fatal_error push _unexpected_end_of_file
db 'unexpected end of file',0 jmp fatal_error
code_cannot_be_generated: code_cannot_be_generated:
call fatal_error push _code_cannot_be_generated
db 'code cannot be generated',0 jmp fatal_error
format_limitations_exceeded: format_limitations_exceeded:
call fatal_error push _format_limitations_exceeded
db 'format limitations exceeded',0 jmp fatal_error
invalid_definition:
push _invalid_definition
jmp fatal_error
write_failed: write_failed:
call fatal_error push _write_failed
db 'write failed',0 jmp fatal_error
file_not_found: file_not_found:
call assembler_error push _file_not_found
db 'file not found',0 jmp assembler_error
error_reading_file: error_reading_file:
call assembler_error push _error_reading_file
db 'error reading file',0 jmp assembler_error
invalid_file_format: invalid_file_format:
call assembler_error push _invalid_file_format
db 'invalid file format',0 jmp assembler_error
invalid_macro_arguments: invalid_macro_arguments:
call assembler_error push _invalid_macro_arguments
db 'invalid macro arguments',0 jmp assembler_error
incomplete_macro: incomplete_macro:
call assembler_error push _incomplete_macro
db 'incomplete macro',0 jmp assembler_error
unexpected_characters: unexpected_characters:
call assembler_error push _unexpected_characters
db 'unexpected characters',0 jmp assembler_error
invalid_argument: invalid_argument:
call assembler_error push _invalid_argument
db 'invalid argument',0 jmp assembler_error
illegal_instruction: illegal_instruction:
call assembler_error push _illegal_instruction
db 'illegal instruction',0 jmp assembler_error
invalid_operand: invalid_operand:
call assembler_error push _invalid_operand
db 'invalid operand',0 jmp assembler_error
invalid_operand_size: invalid_operand_size:
call assembler_error push _invalid_operand_size
db 'invalid size of operand',0 jmp assembler_error
operand_size_not_specified: operand_size_not_specified:
call assembler_error push _operand_size_not_specified
db 'operand size not specified',0 jmp assembler_error
operand_sizes_do_not_match: operand_sizes_do_not_match:
call assembler_error push _operand_sizes_do_not_match
db 'operand sizes do not match',0 jmp assembler_error
invalid_address_size: invalid_address_size:
call assembler_error push _invalid_address_size
db 'invalid size of address value',0 jmp assembler_error
address_sizes_do_not_agree: address_sizes_do_not_agree:
call assembler_error push _address_sizes_do_not_agree
db 'address sizes do not agree',0 jmp assembler_error
prefix_conflict: prefix_conflict:
call assembler_error push _prefix_conflict
db 'disallowed combination of registers',0 jmp assembler_error
long_immediate_not_encodable: long_immediate_not_encodable:
call assembler_error push _long_immediate_not_encodable
db 'not encodable with long immediate',0 jmp assembler_error
relative_jump_out_of_range: relative_jump_out_of_range:
call assembler_error push _relative_jump_out_of_range
db 'relative jump out of range',0 jmp assembler_error
invalid_expression: invalid_expression:
call assembler_error push _invalid_expression
db 'invalid expression',0 jmp assembler_error
invalid_address: invalid_address:
call assembler_error push _invalid_address
db 'invalid address',0 jmp assembler_error
invalid_value: invalid_value:
call assembler_error push _invalid_value
db 'invalid value',0 jmp assembler_error
value_out_of_range: value_out_of_range:
call assembler_error push _value_out_of_range
db 'value out of range',0 jmp assembler_error
undefined_symbol: undefined_symbol:
call assembler_error mov edi,message
db 'undefined symbol',0 mov esi,_undefined_symbol
call copy_asciiz
push message
cmp [error_info],0
je assembler_error
mov byte [edi-1],20h
call write_quoted_symbol_name
jmp assembler_error
copy_asciiz:
lods byte [esi]
stos byte [edi]
test al,al
jnz copy_asciiz
ret
write_quoted_symbol_name:
mov al,27h
stosb
mov esi,[error_info]
movzx ecx,byte [esi-1]
rep movs byte [edi],[esi]
mov ax,27h
stosw
ret
symbol_out_of_scope:
mov edi,message
mov esi,_symbol_out_of_scope_1
call copy_asciiz
cmp [error_info],0
je finish_symbol_out_of_scope_message
mov byte [edi-1],20h
call write_quoted_symbol_name
finish_symbol_out_of_scope_message:
mov byte [edi-1],20h
mov esi,_symbol_out_of_scope_2
call copy_asciiz
push message
jmp assembler_error
invalid_use_of_symbol: invalid_use_of_symbol:
call assembler_error push _invalid_use_of_symbol
db 'invalid use of symbol',0 jmp assembler_error
name_too_long: name_too_long:
call assembler_error push _name_too_long
db 'name too long',0 jmp assembler_error
invalid_name: invalid_name:
call assembler_error push _invalid_name
db 'invalid name',0 jmp assembler_error
reserved_word_used_as_symbol: reserved_word_used_as_symbol:
call assembler_error push _reserved_word_used_as_symbol
db 'reserved word used as symbol',0 jmp assembler_error
symbol_already_defined: symbol_already_defined:
call assembler_error push _symbol_already_defined
db 'symbol already defined',0 jmp assembler_error
missing_end_quote: missing_end_quote:
call assembler_error push _missing_end_quote
db 'missing end quote',0 jmp assembler_error
missing_end_directive: missing_end_directive:
call assembler_error push _missing_end_directive
db 'missing end directive',0 jmp assembler_error
unexpected_instruction: unexpected_instruction:
call assembler_error push _unexpected_instruction
db 'unexpected instruction',0 jmp assembler_error
extra_characters_on_line: extra_characters_on_line:
call assembler_error push _extra_characters_on_line
db 'extra characters on line',0 jmp assembler_error
section_not_aligned_enough: section_not_aligned_enough:
call assembler_error push _section_not_aligned_enough
db 'section is not aligned enough',0 jmp assembler_error
setting_already_specified: setting_already_specified:
call assembler_error push _setting_already_specified
db 'setting already specified',0 jmp assembler_error
data_already_defined: data_already_defined:
call assembler_error push _data_already_defined
db 'data already defined',0 jmp assembler_error
too_many_repeats: too_many_repeats:
call assembler_error push _too_many_repeats
db 'too many repeats',0 jmp assembler_error

View File

@ -956,7 +956,7 @@ calculate_expression:
cmp ax,[ebx+16] cmp ax,[ebx+16]
je label_defined je label_defined
test byte [ebx+8],4 test byte [ebx+8],4
jnz label_undefined jnz label_out_of_scope
test byte [ebx+9],1 test byte [ebx+9],1
jz label_defined jz label_defined
mov eax,[ebx] mov eax,[ebx]
@ -1053,7 +1053,22 @@ calculate_expression:
je timestamp_label je timestamp_label
cmp eax,3 cmp eax,3
je org_origin_label je org_origin_label
mov edx,invalid_value
jmp error_undefined
label_out_of_scope:
mov edx,symbol_out_of_scope
mov eax,[ebx+24]
cmp [error_line],0
jne error_undefined
mov [error_info],eax
jmp error_undefined
label_undefined: label_undefined:
mov edx,undefined_symbol
cmp [error_line],0
jne error_undefined
mov eax,[ebx+24]
mov [error_info],eax
error_undefined:
cmp [current_pass],1 cmp [current_pass],1
ja undefined_value ja undefined_value
force_next_pass: force_next_pass:
@ -1069,7 +1084,7 @@ calculate_expression:
jne calculation_loop jne calculation_loop
mov eax,[current_line] mov eax,[current_line]
mov [error_line],eax mov [error_line],eax
mov [error],undefined_symbol mov [error],edx
jmp calculation_loop jmp calculation_loop
calculate_add: calculate_add:
mov ecx,[ebx+16] mov ecx,[ebx+16]

View File

@ -544,6 +544,7 @@ include 'formats.inc'
include 'x86_64.inc' include 'x86_64.inc'
include 'tables.inc' include 'tables.inc'
include 'symbdump.inc' include 'symbdump.inc'
include 'messages.inc'
title db appname,VERSION_STRING,0 title db appname,VERSION_STRING,0
@ -586,6 +587,8 @@ buffer_address dd ?
memory_setting dd ? memory_setting dd ?
start_time dd ? start_time dd ?
predefinitions rb 1000h
dbgfilename rb MAX_PATH+4 dbgfilename rb MAX_PATH+4
sc system_colors sc system_colors

View File

@ -2666,10 +2666,10 @@ coff_formatter:
mov [current_line],eax mov [current_line],eax
mov eax,[esi+8] mov eax,[esi+8]
test byte [eax+8],1 test byte [eax+8],1
jz undefined_symbol jz undefined_coff_public
mov cx,[current_pass] mov cx,[current_pass]
cmp cx,[eax+16] cmp cx,[eax+16]
jne undefined_symbol jne undefined_coff_public
mov cl,[eax+11] mov cl,[eax+11]
or cl,cl or cl,cl
jz public_constant jz public_constant
@ -2678,6 +2678,10 @@ coff_formatter:
cmp cl,2 cmp cl,2
je public_symbol_type_ok je public_symbol_type_ok
jmp invalid_use_of_symbol jmp invalid_use_of_symbol
undefined_coff_public:
mov eax,[eax+24]
mov [error_info],eax
jmp undefined_symbol
check_64bit_public_symbol: check_64bit_public_symbol:
cmp cl,4 cmp cl,4
jne invalid_use_of_symbol jne invalid_use_of_symbol
@ -3092,10 +3096,10 @@ elf_formatter:
jne invalid_argument jne invalid_argument
mov ebx,[esi+8] mov ebx,[esi+8]
test byte [ebx+8],1 test byte [ebx+8],1
jz undefined_symbol jz undefined_public
mov ax,[current_pass] mov ax,[current_pass]
cmp ax,[ebx+16] cmp ax,[ebx+16]
jne undefined_symbol jne undefined_public
mov dl,[ebx+11] mov dl,[ebx+11]
or dl,dl or dl,dl
jz public_absolute jz public_absolute
@ -3109,6 +3113,10 @@ elf_formatter:
jne invalid_use_of_symbol jne invalid_use_of_symbol
mov dx,[eax+0Eh] mov dx,[eax+0Eh]
jmp section_for_public_ok jmp section_for_public_ok
undefined_public:
mov eax,[ebx+24]
mov [error_info],eax
jmp undefined_symbol
elf64_public: elf64_public:
cmp dl,4 cmp dl,4
jne invalid_use_of_symbol jne invalid_use_of_symbol

View File

@ -0,0 +1,51 @@
; flat assembler core
; Copyright (c) 1999-2007, Tomasz Grysztar.
; All rights reserved.
_out_of_memory db 'out of memory',0
_stack_overflow db 'out of stack space',0
_main_file_not_found db 'source file not found',0
_unexpected_end_of_file db 'unexpected end of file',0
_code_cannot_be_generated db 'code cannot be generated',0
_format_limitations_exceeded db 'format limitations exceeded',0
_invalid_definition db 'invalid definition provided',0
_write_failed db 'write failed',0
_file_not_found db 'file not found',0
_error_reading_file db 'error reading file',0
_invalid_file_format db 'invalid file format',0
_invalid_macro_arguments db 'invalid macro arguments',0
_incomplete_macro db 'incomplete macro',0
_unexpected_characters db 'unexpected characters',0
_invalid_argument db 'invalid argument',0
_illegal_instruction db 'illegal instruction',0
_invalid_operand db 'invalid operand',0
_invalid_operand_size db 'invalid size of operand',0
_operand_size_not_specified db 'operand size not specified',0
_operand_sizes_do_not_match db 'operand sizes do not match',0
_invalid_address_size db 'invalid size of address value',0
_address_sizes_do_not_agree db 'address sizes do not agree',0
_prefix_conflict db 'disallowed combination of registers',0
_long_immediate_not_encodable db 'not encodable with long immediate',0
_relative_jump_out_of_range db 'relative jump out of range',0
_invalid_expression db 'invalid expression',0
_invalid_address db 'invalid address',0
_invalid_value db 'invalid value',0
_value_out_of_range db 'value out of range',0
_undefined_symbol db 'undefined symbol',0
_symbol_out_of_scope_1 db 'symbol',0
_symbol_out_of_scope_2 db 'out of scope',0
_invalid_use_of_symbol db 'invalid use of symbol',0
_name_too_long db 'name too long',0
_invalid_name db 'invalid name',0
_reserved_word_used_as_symbol db 'reserved word used as symbol',0
_symbol_already_defined db 'symbol already defined',0
_missing_end_quote db 'missing end quote',0
_missing_end_directive db 'missing end directive',0
_unexpected_instruction db 'unexpected instruction',0
_extra_characters_on_line db 'extra characters on line',0
_section_not_aligned_enough db 'section is not aligned enough',0
_setting_already_specified db 'setting already specified',0
_data_already_defined db 'data already defined',0
_too_many_repeats db 'too many repeats',0

View File

@ -23,11 +23,8 @@ preprocessor:
mov byte [edi+eax],0 mov byte [edi+eax],0
loop mark_symbol_characters loop mark_symbol_characters
mov edi,locals_counter mov edi,locals_counter
mov al,7 mov ax,1 + '0' shl 8
stos byte [edi] stos word [edi]
movzx ecx,al
mov al,'0'
rep stos byte [edi]
mov edi,[memory_start] mov edi,[memory_start]
mov [include_paths],edi mov [include_paths],edi
mov esi,include_variable mov esi,include_variable
@ -43,6 +40,149 @@ preprocessor:
mov [display_buffer],eax mov [display_buffer],eax
mov [hash_tree],eax mov [hash_tree],eax
mov [macro_status],al mov [macro_status],al
mov esi,predefinitions
process_predefinitions:
movzx ecx,byte [esi]
test ecx,ecx
jz predefinitions_ok
inc esi
lea eax,[esi+ecx]
push eax
mov ch,10b
call add_preprocessor_symbol
pop esi
mov edi,[memory_start]
mov [edx+8],edi
convert_predefinition:
cmp edi,[memory_end]
jae out_of_memory
lods byte [esi]
or al,al
jz predefinition_converted
cmp al,20h
je convert_predefinition
mov ah,al
mov ebx,characters
xlat byte [ebx]
or al,al
jz predefinition_separator
cmp ah,27h
je predefinition_string
cmp ah,22h
je predefinition_string
mov byte [edi],1Ah
scas word [edi]
xchg al,ah
stos byte [edi]
mov ebx,characters
xor ecx,ecx
predefinition_symbol:
lods byte [esi]
stos byte [edi]
xlat byte [ebx]
or al,al
loopnzd predefinition_symbol
neg ecx
cmp ecx,255
ja invalid_definition
mov ebx,edi
sub ebx,ecx
mov byte [ebx-2],cl
found_predefinition_separator:
dec edi
mov ah,[esi-1]
predefinition_separator:
xchg al,ah
or al,al
jz predefinition_converted
cmp al,20h
je convert_line_data
cmp al,3Bh
je invalid_definition
cmp al,5Ch
je predefinition_backslash
stos byte [edi]
jmp convert_predefinition
predefinition_string:
mov al,22h
stos byte [edi]
scas dword [edi]
mov ebx,edi
copy_predefinition_string:
lods byte [esi]
stos byte [edi]
or al,al
jz invalid_definition
cmp al,ah
jne copy_predefinition_string
lods byte [esi]
cmp al,ah
je copy_predefinition_string
dec esi
dec edi
mov eax,edi
sub eax,ebx
mov [ebx-4],eax
jmp convert_predefinition
predefinition_backslash:
mov byte [edi],0
lods byte [esi]
or al,al
jz invalid_definition
cmp al,20h
je invalid_definition
cmp al,3Bh
je invalid_definition
mov al,1Ah
stos byte [edi]
mov ecx,edi
mov ax,5C01h
stos word [edi]
dec esi
group_predefinition_backslashes:
lods byte [esi]
cmp al,5Ch
jne predefinition_backslashed_symbol
stos byte [edi]
inc byte [ecx]
jmp group_predefinition_backslashes
predefinition_backslashed_symbol:
cmp al,20h
je invalid_definition
cmp al,22h
je invalid_definition
cmp al,27h
je invalid_definition
cmp al,3Bh
je invalid_definition
mov ah,al
mov ebx,characters
xlat byte [ebx]
or al,al
jz predefinition_backslashed_symbol_character
mov al,ah
convert_predefinition_backslashed_symbol:
stos byte [edi]
xlat byte [ebx]
or al,al
jz found_predefinition_separator
inc byte [ecx]
jz invalid_definition
lods byte [esi]
jmp convert_predefinition_backslashed_symbol
predefinition_backslashed_symbol_character:
mov al,ah
stos byte [edi]
inc byte [ecx]
jmp convert_predefinition
predefinition_converted:
mov [memory_start],edi
sub edi,[edx+8]
mov [edx+12],edi
jmp process_predefinitions
predefinitions_ok:
mov esi,[input_file] mov esi,[input_file]
mov edx,esi mov edx,esi
call open call open
@ -2220,16 +2360,25 @@ local_symbols:
movzx ecx,byte [eax] movzx ecx,byte [eax]
counter_loop: counter_loop:
inc byte [eax+ecx] inc byte [eax+ecx]
cmp byte [eax+ecx],':' cmp byte [eax+ecx],'9'+1
jb counter_ok jb counter_ok
jne letter_digit jne letter_digit
mov byte [eax+ecx],'A' mov byte [eax+ecx],'A'
jmp counter_ok jmp counter_ok
letter_digit: letter_digit:
cmp byte [eax+ecx],'F' cmp byte [eax+ecx],'Z'+1
jbe counter_ok jb counter_ok
jne small_letter_digit
mov byte [eax+ecx],'a'
jmp counter_ok
small_letter_digit:
cmp byte [eax+ecx],'z'+1
jb counter_ok
mov byte [eax+ecx],'0' mov byte [eax+ecx],'0'
loop counter_loop loop counter_loop
inc byte [eax]
movzx ecx,byte [eax]
mov byte [eax+ecx],'0'
counter_ok: counter_ok:
pop ecx pop ecx
lods byte [esi] lods byte [esi]

View File

@ -57,6 +57,7 @@ undefined_data_start dd ?
undefined_data_end dd ? undefined_data_end dd ?
counter dd ? counter dd ?
counter_limit dd ? counter_limit dd ?
error_info dd ?
error_line dd ? error_line dd ?
error dd ? error dd ?
display_buffer dd ? display_buffer dd ?
@ -122,3 +123,4 @@ logical_value_wrapping db ?
characters rb 100h characters rb 100h
converted rb 100h converted rb 100h
message rb 200h

View File

@ -33,7 +33,7 @@
; cannot simply be copied and put under another distribution licence ; cannot simply be copied and put under another distribution licence
; (including the GNU Public Licence). ; (including the GNU Public Licence).
VERSION_STRING equ "1.67.23" VERSION_STRING equ "1.67.25"
VERSION_MAJOR = 1 VERSION_MAJOR = 1
VERSION_MINOR = 67 VERSION_MINOR = 67