fasm: update to 1.71.54

git-svn-id: svn://kolibrios.org@6467 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Ivan Baravy 2016-08-01 01:31:26 +00:00
parent 3e57c7257b
commit 25b23034ea
14 changed files with 4741 additions and 2176 deletions

View File

@ -1,6 +1,6 @@
; flat assembler core
; Copyright (c) 1999-2013, Tomasz Grysztar.
; Copyright (c) 1999-2016, Tomasz Grysztar.
; All rights reserved.
assembler:
@ -32,6 +32,7 @@ assembler:
mov [next_pass_needed],al
mov [output_format],al
mov [adjustment_sign],al
mov [evex_mode],al
mov [code_type],16
call init_addressing_space
pass_loop:
@ -192,7 +193,7 @@ assemble_line:
new_line:
lods dword [esi]
mov [current_line],eax
mov [prefixed_instruction],0
and [prefix_flags],0
cmp [symbols_file],0
je continue_line
cmp [next_pass_needed],0
@ -329,31 +330,10 @@ assemble_line:
cmp eax,0Fh
jb invalid_use_of_symbol
je reserved_word_used_as_symbol
mov edx,[eax+8]
push edx
cmp [current_pass],0
je get_constant_value
test dl,4
jnz get_constant_value
mov cx,[current_pass]
cmp cx,[eax+16]
je get_constant_value
or dl,4
mov [eax+8],dl
get_constant_value:
push eax
mov al,byte [esi-1]
push eax
or [size_override],-1
or [operand_flags],1
call get_value
pop ebx
mov ch,bl
pop ebx
pop ecx
test cl,4
jnz constant_referencing_mode_ok
and byte [ebx+8],not 4
constant_referencing_mode_ok:
xor cl,cl
mov ch,[value_type]
cmp ch,3
@ -453,16 +433,16 @@ assemble_line:
or byte [ebx+0Ah],2
jmp continue_line
assemble_instruction:
; mov [operand_size],0
; mov [size_override],0
; mov [operand_prefix],0
; mov [opcode_prefix],0
; mov [operand_size],0
; mov [operand_flags],0
; mov [operand_prefix],0
; mov [rex_prefix],0
and dword [operand_size],0
; mov [rex_prefix],0
; mov [vex_required],0
; mov [vex_register],0
; mov [immediate_size],0
and dword [rex_prefix],0
; mov [opcode_prefix],0
; mov [vex_required],0
; mov [vex_register],0
; mov [immediate_size],0
and dword [opcode_prefix],0
call instruction_handler
instruction_handler:
movzx ebx,word [esi]
@ -471,6 +451,8 @@ assemble_line:
add [esp],ebx
ret
instruction_assembled:
test [prefix_flags],not 1
jnz illegal_instruction
mov al,[esi]
cmp al,0Fh
je line_assembled
@ -671,7 +653,7 @@ load_directive:
push ebx
cmp byte [esi],'.'
je invalid_value
or [size_override],-1
or [operand_flags],1
call get_address_value
pop ebp
call calculate_relative_offset
@ -718,7 +700,7 @@ store_directive:
mov [operand_size],1
jmp store_value_ok
sized_store:
or [size_override],-1
or [operand_flags],1
call get_value
store_value_ok:
cmp [value_type],0
@ -833,7 +815,7 @@ times_directive:
cmp eax,[stack_limit]
jb stack_overflow
push esi
or [prefixed_instruction],-1
or [prefix_flags],1
call continue_line
mov eax,[counter_limit]
cmp [counter],eax
@ -1008,8 +990,8 @@ virtual_directive:
addressing_space_closed:
ret
repeat_directive:
cmp [prefixed_instruction],0
jne unexpected_instruction
test [prefix_flags],1
jnz unexpected_instruction
lods byte [esi]
cmp al,'('
jne invalid_argument
@ -1030,8 +1012,8 @@ repeat_directive:
mov [ebx+4],eax
jmp instruction_assembled
end_repeat:
cmp [prefixed_instruction],0
jne unexpected_instruction
test [prefix_flags],1
jnz unexpected_instruction
call find_structure_data
jc unexpected_instruction
mov eax,[counter_limit]
@ -1062,8 +1044,8 @@ repeat_directive:
jne unexpected_instruction
ret
while_directive:
cmp [prefixed_instruction],0
jne unexpected_instruction
test [prefix_flags],1
jnz unexpected_instruction
call allocate_structure_data
mov word [ebx],while_directive-instruction_handler
mov eax,1
@ -1093,8 +1075,8 @@ while_directive:
pop ebx
jmp instruction_assembled
end_while:
cmp [prefixed_instruction],0
jne unexpected_instruction
test [prefix_flags],1
jnz unexpected_instruction
call find_structure_data
jc unexpected_instruction
mov eax,[ebx+4]
@ -1109,8 +1091,8 @@ while_directive:
jne unexpected_instruction
ret
if_directive:
cmp [prefixed_instruction],0
jne unexpected_instruction
test [prefix_flags],1
jnz unexpected_instruction
call calculate_logical_expression
mov dl,al
mov al,[esi]
@ -1146,8 +1128,8 @@ if_directive:
or al,-1
jmp make_if_structure
else_directive:
cmp [prefixed_instruction],0
jne unexpected_instruction
test [prefix_flags],1
jnz unexpected_instruction
mov ax,if_directive-instruction_handler
call find_structure_data
jc unexpected_instruction
@ -1173,8 +1155,8 @@ if_directive:
call remove_structure_data
jmp instruction_assembled
end_if:
cmp [prefixed_instruction],0
jne unexpected_instruction
test [prefix_flags],1
jnz unexpected_instruction
call find_structure_data
jc unexpected_instruction
call remove_structure_data
@ -1377,7 +1359,7 @@ data_bytes:
inc esi
or eax,eax
jz duplicate_zero_times
cmp byte [esi],'{'
cmp byte [esi],91h
jne duplicate_single_data_value
inc esi
duplicate_data:
@ -1389,7 +1371,7 @@ data_bytes:
lods byte [esi]
cmp al,','
je duplicated_values
cmp al,'}'
cmp al,92h
jne invalid_argument
pop ebx eax
dec eax
@ -1407,13 +1389,13 @@ data_bytes:
mov esi,ebx
jmp duplicate_single_data_value
duplicate_zero_times:
cmp byte [esi],'{'
cmp byte [esi],91h
jne skip_single_data_value
inc esi
skip_data_value:
call skip_symbol
jc invalid_argument
cmp byte [esi],'}'
cmp byte [esi],92h
jne skip_data_value
inc esi
jmp data_defined

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
; flat assembler core
; Copyright (c) 1999-2013, Tomasz Grysztar.
; Copyright (c) 1999-2016, Tomasz Grysztar.
; All rights reserved.
out_of_memory:
@ -24,6 +24,9 @@ code_cannot_be_generated:
jmp general_error
format_limitations_exceeded:
push _format_limitations_exceeded
jmp general_error
invalid_definition:
push _invalid_definition
general_error:
cmp [symbols_file],0
je fatal_error

View File

@ -1,7 +1,6 @@
; flat assembler core
; Copyright (c) 1999-2013, Tomasz Grysztar.
; Copyright (c) 1999-2016, Tomasz Grysztar.
; All rights reserved.
calculate_expression:
@ -12,6 +11,10 @@ calculate_expression:
cmp byte [esi],'.'
je convert_fp
calculation_loop:
mov eax,[tagged_blocks]
sub eax,0Ch
cmp eax,edi
jbe out_of_memory
lods byte [esi]
cmp al,1
je get_byte_number
@ -36,12 +39,16 @@ calculate_expression:
sub edi,14h
mov ebx,edi
sub ebx,14h
cmp al,0E0h
cmp al,0F0h
je calculate_rva
cmp al,0E1h
cmp al,0F1h
je calculate_plt
cmp al,0D0h
je calculate_not
cmp al,0E0h
je calculate_bsf
cmp al,0E1h
je calculate_bsr
cmp al,083h
je calculate_neg
mov dx,[ebx+8]
@ -197,14 +204,8 @@ calculate_expression:
mov al,[ebx+10]
or al,al
jz calculation_loop
cmp [size_override],-1
je calculation_loop
cmp [size_override],0
je check_size
cmp [operand_size],0
jne calculation_loop
mov [operand_size],al
jmp calculation_loop
test [operand_flags],1
jnz calculation_loop
check_size:
xchg [operand_size],al
or al,al
@ -623,76 +624,6 @@ calculate_expression:
xor [ebx],eax
xor [ebx+4],edx
xor [ebx+13],cl
jz calculation_loop
or cl,cl
jz xor_size_check
xor eax,[ebx]
xor edx,[ebx+4]
xor_size_check:
mov cl,[value_size]
cmp cl,1
je xor_byte_result
cmp cl,2
je xor_word_result
cmp cl,4
je xor_dword_result
cmp cl,6
je xor_pword_result
cmp cl,8
jne calculation_loop
xor edx,[ebx+4]
js xor_result_truncated
jmp calculation_loop
xor_pword_result:
test edx,0FFFF0000h
jnz calculation_loop
cmp word [ebx+6],-1
jne calculation_loop
xor dx,[ebx+4]
jns calculation_loop
not word [ebx+6]
jmp xor_result_truncated
xor_dword_result:
test edx,edx
jnz calculation_loop
cmp dword [ebx+4],-1
jne calculation_loop
xor eax,[ebx]
jns calculation_loop
not dword [ebx+4]
jmp xor_result_truncated
xor_word_result:
test edx,edx
jnz calculation_loop
test eax,0FFFF0000h
jnz calculation_loop
cmp dword [ebx+4],-1
jne calculation_loop
cmp word [ebx+2],-1
jne calculation_loop
xor ax,[ebx]
jns calculation_loop
not dword [ebx+4]
not word [ebx+2]
jmp xor_result_truncated
xor_byte_result:
test edx,edx
jnz calculation_loop
test eax,0FFFFFF00h
jnz calculation_loop
cmp dword [ebx+4],-1
jne calculation_loop
cmp word [ebx+2],-1
jne calculation_loop
cmp byte [ebx+1],-1
jne calculation_loop
xor al,[ebx]
jns calculation_loop
not dword [ebx+4]
not word [ebx+2]
not byte [ebx+1]
xor_result_truncated:
mov byte [ebx+13],0
jmp calculation_loop
shr_negative:
mov byte [edi+13],0
@ -761,25 +692,6 @@ calculate_expression:
calculate_shr:
cmp byte [edi+13],0
jne shr_negative
cmp byte [ebx+13],0
je do_shr
mov al,[value_size]
cmp al,1
je shr_negative_byte
cmp al,2
je shr_negative_word
cmp al,4
je shr_negative_dword
cmp al,6
je shr_negative_pword
cmp al,8
jne do_shr
shr_negative_qword:
test byte [ebx+7],80h
jz do_shr
shr_truncated:
mov byte [ebx+13],0
do_shr:
mov edx,[ebx+4]
mov eax,[ebx]
cmp dword [edi+4],0
@ -809,43 +721,6 @@ calculate_expression:
mov dword [ebx],eax
mov dword [ebx+4],eax
jmp calculation_loop
shr_negative_byte:
cmp dword [ebx+4],-1
jne do_shr
cmp word [ebx+2],-1
jne do_shr
cmp byte [ebx+1],-1
jne do_shr
test byte [ebx],80h
jz do_shr
not dword [ebx+4]
not word [ebx+2]
not byte [ebx+1]
jmp shr_truncated
shr_negative_word:
cmp dword [ebx+4],-1
jne do_shr
cmp word [ebx+2],-1
jne do_shr
test byte [ebx+1],80h
jz do_shr
not dword [ebx+4]
not word [ebx+2]
jmp shr_truncated
shr_negative_dword:
cmp dword [ebx+4],-1
jne do_shr
test byte [ebx+3],80h
jz do_shr
not dword [ebx+4]
jmp shr_truncated
shr_negative_pword:
cmp word [ebx+6],-1
jne do_shr
test byte [ebx+5],80h
jz do_shr
not word [ebx+6]
jmp shr_truncated
calculate_not:
cmp word [edi+8],0
jne invalid_expression
@ -853,56 +728,53 @@ calculate_expression:
je not_ok
call recoverable_misuse
not_ok:
mov al,[value_size]
cmp al,1
je not_byte
cmp al,2
je not_word
cmp al,4
je not_dword
cmp al,6
je not_pword
cmp al,8
je not_qword
not dword [edi]
not dword [edi+4]
not byte [edi+13]
add edi,14h
jmp calculation_loop
not_qword:
not dword [edi]
not dword [edi+4]
finish_not:
mov byte [edi+13],0
calculate_bsf:
cmp word [edi+8],0
jne invalid_expression
cmp byte [edi+12],0
je bsf_ok
call recoverable_misuse
bsf_ok:
xor ecx,ecx
bsf eax,[edi]
jnz finish_bs
mov ecx,32
bsf eax,[edi+4]
jnz finish_bs
cmp byte [edi+13],0
jne finish_bs
bs_overflow:
call recoverable_overflow
add edi,14h
jmp calculation_loop
calculate_bsr:
cmp word [edi+8],0
jne invalid_expression
cmp byte [edi+12],0
je bsr_ok
call recoverable_misuse
bsr_ok:
cmp byte [edi+13],0
jne bs_overflow
mov ecx,32
bsr eax,[edi+4]
jnz finish_bs
xor ecx,ecx
bsr eax,[edi]
jz bs_overflow
finish_bs:
add eax,ecx
xor edx,edx
mov [edi],eax
mov [edi+4],edx
mov [edi+13],dl
add edi,14h
jmp calculation_loop
not_byte:
cmp dword [edi+4],0
jne not_qword
cmp word [edi+2],0
jne not_qword
cmp byte [edi+1],0
jne not_qword
not byte [edi]
jmp finish_not
not_word:
cmp dword [edi+4],0
jne not_qword
cmp word [edi+2],0
jne not_qword
not word [edi]
jmp finish_not
not_dword:
cmp dword [edi+4],0
jne not_qword
not dword [edi]
jmp finish_not
not_pword:
cmp word [edi+6],0
jne not_qword
not word [edi+4]
not dword [edi]
jmp finish_not
calculate_neg:
cmp byte [edi+8],0
je neg_first_register_ok
@ -1158,7 +1030,8 @@ calculate_expression:
cmp al,4
je convert_fp_dword
test al,not 8
jnz invalid_value
jz convert_fp_qword
call recoverable_misuse
convert_fp_qword:
xor eax,eax
xor edx,edx
@ -1194,7 +1067,7 @@ calculate_expression:
cmp cx,52
ja value_out_of_range
cmp cx,32
jbe fp_qword_small_shift
jb fp_qword_small_shift
sub cx,32
mov eax,edx
xor edx,edx
@ -1338,7 +1211,7 @@ calculate_expression:
get_byte_value:
mov [value_size],1
mov [size_override],-1
or [operand_flags],1
call calculate_value
or al,al
jz check_byte_value
@ -1350,7 +1223,7 @@ get_byte_value:
je byte_positive
cmp edx,-1
jne range_exceeded
cmp eax,-80h
cmp eax,-100h
jb range_exceeded
ret
byte_positive:
@ -1382,7 +1255,7 @@ get_byte_value:
ret
get_word_value:
mov [value_size],2
mov [size_override],-1
or [operand_flags],1
call calculate_value
cmp al,2
jb check_word_value
@ -1394,7 +1267,7 @@ get_word_value:
je word_positive
cmp edx,-1
jne range_exceeded
cmp eax,-8000h
cmp eax,-10000h
jb range_exceeded
ret
word_positive:
@ -1405,7 +1278,7 @@ get_word_value:
ret
get_dword_value:
mov [value_size],4
mov [size_override],-1
or [operand_flags],1
call calculate_value
cmp al,4
jne check_dword_value
@ -1426,8 +1299,6 @@ get_dword_value:
je dword_positive
cmp edx,-1
jne range_exceeded
bt eax,31
jnc range_exceeded
ret
dword_positive:
test edx,edx
@ -1435,7 +1306,7 @@ get_dword_value:
ret
get_pword_value:
mov [value_size],6
mov [size_override],-1
or [operand_flags],1
call calculate_value
cmp al,4
jne check_pword_value
@ -1445,7 +1316,7 @@ get_pword_value:
mov edx,[edi+4]
cmp byte [edi+13],0
je pword_positive
cmp edx,-8000h
cmp edx,-10000h
jb range_exceeded
ret
pword_positive:
@ -1454,20 +1325,15 @@ get_pword_value:
ret
get_qword_value:
mov [value_size],8
mov [size_override],-1
or [operand_flags],1
call calculate_value
check_qword_value:
mov eax,[edi]
mov edx,[edi+4]
cmp byte [edi+13],0
je qword_positive
cmp edx,-80000000h
jb range_exceeded
qword_positive:
ret
get_count_value:
mov [value_size],8
mov [size_override],-1
or [operand_flags],1
call calculate_expression
cmp word [edi+8],0
jne invalid_value
@ -1636,33 +1502,31 @@ get_address_value:
mov ax,bx
shr ah,4
shr al,4
cmp ah,0Ch
je check_vsib_address
cmp ah,0Dh
je check_vsib_address
cmp al,0Ch
je check_vsib_address
cmp al,0Dh
je check_vsib_address
or bh,bh
jz check_address_registers
or bl,bl
jz check_address_registers
cmp al,ah
jne invalid_address
jne check_vsib
check_address_registers:
or al,ah
cmp al,0Ch
jae check_vsib
cmp al,6
je check_vsib
cmp al,7
je check_vsib
mov ah,[address_size]
and ah,0Fh
jz address_registers_sizes_ok
cmp al,ah
jne address_sizes_do_not_match
jne invalid_address
address_registers_sizes_ok:
cmp al,4
je sib_allowed
cmp al,8
je sib_allowed
cmp al,0Fh
cmp al,9
je check_ip_relative_address
cmp cl,1
ja invalid_address
@ -1679,13 +1543,15 @@ get_address_value:
check_ip_relative_address:
or bl,bl
jnz invalid_address
cmp bh,0F8h
cmp bh,98h
je check_rip_relative_address
cmp bh,0F4h
cmp bh,94h
jne invalid_address
cmp [free_address_range],0
jne check_qword_value
jmp check_dword_value
je check_dword_value
mov eax,[edi]
mov edx,[edi+4]
ret
check_rip_relative_address:
mov eax,[edi]
cdq
@ -1792,35 +1658,41 @@ get_address_value:
and al,cl
jz check_immediate_address
jmp invalid_address
check_vsib_address:
cmp ah,0Ch
je swap_vsib_registers
cmp ah,0Dh
jne check_vsib_base
check_vsib:
xor ah,ah
check_vsib_base:
test bh,bh
jz check_vsib_index
mov al,bh
shr al,4
cmp al,4
je check_vsib_base_size
cmp [code_type],64
jne swap_vsib_registers
cmp al,8
jne swap_vsib_registers
check_vsib_base_size:
mov ah,[address_size]
and ah,0Fh
jz check_vsib_index
cmp al,ah
jne invalid_address
check_vsib_index:
mov al,bl
and al,0E0h
cmp al,0C0h
jae check_index_scale
cmp al,60h
je check_index_scale
jmp invalid_address
swap_vsib_registers:
xor ah,-1
jz invalid_address
cmp cl,1
ja invalid_address
xchg bl,bh
mov cl,1
check_vsib_base:
test bh,bh
jz vsib_base_ok
mov al,bh
shr al,4
cmp al,4
je vsib_base_ok
cmp [code_type],64
jne invalid_address
cmp al,8
jne invalid_address
vsib_base_ok:
mov al,bl
shr al,4
cmp al,0Ch
je check_index_scale
cmp al,0Dh
je check_index_scale
jmp invalid_address
jmp check_vsib_base
calculate_relative_offset:
cmp [value_undefined],0
@ -1912,7 +1784,7 @@ calculate_logical_expression:
jmp logical_loop
get_value_for_comparison:
mov [value_size],8
mov [size_override],-1
or [operand_flags],1
lods byte [esi]
call calculate_expression
cmp byte [edi+8],0
@ -1943,7 +1815,7 @@ calculate_logical_expression:
negation_ok:
push eax
mov al,[esi]
cmp al,'{'
cmp al,91h
je logical_expression
cmp al,0FFh
je invalid_expression
@ -1965,7 +1837,7 @@ calculate_logical_expression:
jz logical_number
cmp al,0Fh
je logical_number
cmp al,'}'
cmp al,92h
je logical_number
cmp al,'&'
je logical_number
@ -2124,7 +1996,7 @@ calculate_logical_expression:
inc esi
jmp check_expression
defined_fp_value:
add esi,12
add esi,12+1
jmp expression_checked
defined_string:
lods dword [esi]
@ -2206,7 +2078,7 @@ calculate_logical_expression:
mov [logical_value_wrapping],dl
push eax
lods byte [esi]
cmp al,'}'
cmp al,92h
jne invalid_expression
pop eax
logical_value_ok:

View File

@ -1,6 +1,6 @@
; flat assembler core
; Copyright (c) 1999-2013, Tomasz Grysztar.
; Copyright (c) 1999-2016, Tomasz Grysztar.
; All rights reserved.
convert_expression:
@ -77,7 +77,7 @@ convert_expression:
ret
convert_number:
lea eax,[edi-10h]
lea eax,[edi+20h]
mov edx,[memory_end]
cmp [source_start],0
je check_memory_for_number
@ -129,7 +129,11 @@ convert_number:
pop [current_offset]
lods byte [esi]
cmp al,')'
jne invalid_expression
je subexpression_closed
dec esi
mov al,'!'
stosb
subexpression_closed:
ret
symbol_value:
cmp [source_start],0
@ -147,16 +151,13 @@ convert_number:
shr ah,4
cmp ah,4
je register_value
and ah,not 1
cmp ah,8
je register_value
cmp ah,0Ch
jae register_value
cmp ah,6
je register_value
cmp ah,0Dh
je register_value
cmp ah,0Fh
je register_value
cmp ah,2
jne no_address_register
cmp al,23h
je register_value
cmp al,25h
@ -912,7 +913,7 @@ preevaluate_logical_expression:
je preevaluate_or
cmp dl,'&'
je preevaluate_and
cmp dl,'}'
cmp dl,92h
je preevaluation_done
or dl,dl
jnz invalid_logical_expression
@ -987,7 +988,7 @@ preevaluate_logical_expression:
jmp skip_logical_value
negation_skipped:
mov al,[esi]
cmp al,'{'
cmp al,91h
jne skip_simple_logical_value
inc esi
xchg al,[logical_value_wrapping]
@ -1003,7 +1004,7 @@ preevaluate_logical_expression:
je skip_logical_expression
cmp al,'&'
je skip_logical_expression
cmp al,'}'
cmp al,92h
jne wrongly_structured_logical_expression
pop eax
mov [logical_value_wrapping],al
@ -1026,13 +1027,13 @@ preevaluate_logical_expression:
je logical_value_skipped
cmp al,'&'
je logical_value_skipped
cmp al,'{'
cmp al,91h
je skip_logical_value_internal_parenthesis
cmp al,'}'
cmp al,92h
jne skip_logical_value_symbol
sub [logical_value_parentheses],1
jnc skip_logical_value_symbol
cmp [logical_value_wrapping],'{'
cmp [logical_value_wrapping],91h
jne skip_logical_value_symbol
jmp logical_value_skipped
skip_logical_value_internal_parenthesis:
@ -1049,7 +1050,7 @@ preevaluate_logical_expression:
jmp preevaluate_negation
preevaluate_negation_ok:
mov ebx,esi
cmp byte [esi],'{'
cmp byte [esi],91h
jne preevaluate_simple_logical_value
lods byte [esi]
stos byte [edi]
@ -1062,7 +1063,7 @@ preevaluate_logical_expression:
pop ebp
cmp al,0FFh
je invalid_logical_value
cmp byte [esi],'}'
cmp byte [esi],92h
jne invalid_logical_value
or al,al
jnz preevaluated_expression_value
@ -1089,9 +1090,9 @@ preevaluate_logical_expression:
mov al,[esi]
or al,al
jz logical_value_boundaries_found
cmp al,'{'
cmp al,91h
je logical_value_internal_parentheses
cmp al,'}'
cmp al,92h
je logical_value_boundaries_parenthesis_close
cmp al,'|'
je logical_value_boundaries_found
@ -1116,7 +1117,7 @@ preevaluate_logical_expression:
logical_value_boundaries_parenthesis_close:
sub [logical_value_parentheses],1
jnc next_symbol_in_logical_value
cmp [logical_value_wrapping],'{'
cmp [logical_value_wrapping],91h
jne next_symbol_in_logical_value
logical_value_boundaries_found:
or edx,edx

View File

@ -1,6 +1,6 @@
; flat assembler core
; Copyright (c) 1999-2013, Tomasz Grysztar.
; Copyright (c) 1999-2016, Tomasz Grysztar.
; All rights reserved.
formatter:
@ -454,7 +454,8 @@ format_mz:
jmp format_defined
mark_mz_relocation:
push eax ebx
inc [number_of_relocations]
inc word [number_of_relocations]
jz format_limitations_exceeded
mov ebx,[free_additional_memory]
mov eax,edi
sub eax,[code_start]
@ -1611,6 +1612,7 @@ make_pe_fixups:
sub esi,eax
mov [free_additional_memory],esi
mov edx,[last_fixup_base]
mov ebx,[last_fixup_header]
mov ebp,edi
jecxz fixups_done
make_fixup:
@ -1645,6 +1647,7 @@ make_pe_fixups:
loop make_fixup
fixups_done:
mov [last_fixup_base],edx
mov [last_fixup_header],ebx
pop esi
mov eax,edi
sub eax,ebp
@ -3491,8 +3494,22 @@ elf_formatter:
shr eax,8
stos dword [edi]
xor eax,eax
push edx
mov edx,[esi+4]
add edx,[image_base]
xchg eax,[edx]
stos dword [edi]
cmp byte [esi],1
je addend_64bit
pop edx
sar eax,31
stos dword [edi]
jmp relocation_entry_ok
addend_64bit:
xor eax,eax
xchg eax,[edx+4]
stos dword [edi]
pop edx
relocation_entry_ok:
add esi,0Ch
jmp convert_relocations

View File

@ -1,6 +1,6 @@
; flat assembler core
; Copyright (c) 1999-2013, Tomasz Grysztar.
; Copyright (c) 1999-2016, Tomasz Grysztar.
; All rights reserved.
_out_of_memory db 'out of memory',0

View File

@ -1,6 +1,6 @@
; flat assembler core
; Copyright (c) 1999-2013, Tomasz Grysztar.
; Copyright (c) 1999-2016, Tomasz Grysztar.
; All rights reserved.
parser:
@ -34,6 +34,7 @@ parser:
add esi,16
parse_line:
mov [formatter_symbols_allowed],0
mov [decorator_symbols_allowed],0
cmp byte [esi],1Ah
jne empty_instruction
push edi
@ -529,15 +530,20 @@ parse_line_contents:
cmp al,']'
je separator
cmp al,'{'
je unallowed_character
je open_decorator
cmp al,'}'
je unallowed_character
je close_decorator
cmp al,'#'
je unallowed_character
cmp al,'`'
je unallowed_character
cmp al,3Bh
je foreign_argument
cmp [decorator_symbols_allowed],0
je not_a_separator
cmp al,'-'
je separator
not_a_separator:
dec esi
cmp al,1Ah
jne expression_argument
@ -825,7 +831,7 @@ parse_line_contents:
jb stack_overflow
push esi edi
inc esi
mov al,'{'
mov al,91h
stos byte [edi]
inc [parenthesis_stack]
jmp parse_argument
@ -879,10 +885,16 @@ parse_line_contents:
lods byte [esi]
cmp al,']'
je address_parsed
cmp al,','
je divided_address
dec esi
mov al,')'
stos byte [edi]
jmp argument_parsed
divided_address:
mov ax,'),'
stos word [edi]
jmp expression
address_parsed:
mov al,']'
stos byte [edi]
@ -908,8 +920,9 @@ parse_line_contents:
jne unknown_segment_prefix
mov al,ah
and ah,11110000b
cmp ah,60h
cmp ah,30h
jne unknown_segment_prefix
add al,30h
stos byte [edi]
jmp convert_address
unknown_segment_prefix:
@ -928,13 +941,19 @@ parse_line_contents:
cmp byte [esi],'('
jne argument_parsed
inc esi
mov al,'{'
mov al,91h
jmp separator
unallowed_character:
mov al,0FFh
jmp separator
open_decorator:
inc [decorator_symbols_allowed]
jmp separator
close_decorator:
dec [decorator_symbols_allowed]
jmp separator
close_parenthesis:
mov al,'}'
mov al,92h
separator:
stos byte [edi]
argument_parsed:
@ -1049,7 +1068,7 @@ get_symbol:
mov ecx,ebp
cmp cl,11
ja no_symbol
sub cl,2
sub cl,1
jc no_symbol
movzx ebx,word [symbols+ecx*4]
add ebx,symbols
@ -1070,6 +1089,8 @@ get_symbol:
mov ax,[edi]
cmp al,18h
jb symbol_ok
cmp al,1Fh
je decorator_symbol
cmp [formatter_symbols_allowed],0
je no_symbol
symbol_ok:
@ -1077,6 +1098,9 @@ get_symbol:
add esi,ebp
clc
ret
decorator_symbol:
cmp [decorator_symbols_allowed],0
jne symbol_ok
no_symbol:
pop esi
mov ecx,ebp
@ -1258,7 +1282,7 @@ get_label_id:
inc esi
cmp byte [esi-1],'$'
je get_org_origin_id
sub esi,ecx
sub esi,2
jmp find_label
get_current_offset_id:
xor eax,eax
@ -1363,12 +1387,12 @@ get_label_id:
cmp al,30h
jb name_first_char_ok
cmp al,39h
jbe invalid_name
jbe numeric_name
name_first_char_ok:
cmp al,'$'
jne check_for_reserved_word
cmp ecx,1
jne invalid_name
numeric_name:
add esi,ecx
reserved_word:
mov eax,0Fh
pop edi

View File

@ -1,6 +1,6 @@
; flat assembler core
; Copyright (c) 1999-2013, Tomasz Grysztar.
; Copyright (c) 1999-2016, Tomasz Grysztar.
; All rights reserved.
preprocessor:
@ -42,6 +42,150 @@ preprocessor:
mov [hash_tree],eax
mov [error],eax
mov [macro_status],al
mov [current_line],eax
mov esi,[initial_definitions]
test esi,esi
jz predefinitions_ok
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_predefinition
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 edx,esi
call open
@ -78,7 +222,11 @@ preprocessor:
mov [ebx],eax
call use_postponed_macro
pop edx
jmp process_postponed_list
cmp [macro_status],0
je process_postponed_list
mov eax,[error_line]
mov [current_line],eax
jmp incomplete_macro
preprocessing_finished:
mov [source_start],edi
ret
@ -275,6 +423,7 @@ convert_line:
jne backslashed_symbol
stos byte [edi]
inc byte [ecx]
jz name_too_long
jmp group_backslashes
no_end_quote:
mov byte [ebx-5],0
@ -896,6 +1045,8 @@ define_macro:
inc esi
add esi,eax
lods byte [esi]
cmp al,':'
je macro_argument_with_default_value
cmp al,'='
je macro_argument_with_default_value
cmp al,'*'
@ -904,10 +1055,13 @@ define_macro:
macro_argument_end:
cmp al,','
je skip_macro_arguments
cmp al,'&'
je macro_arguments_finisher
cmp al,']'
jne end_macro_arguments
lods byte [esi]
not ebp
macro_arguments_finisher:
lods byte [esi]
end_macro_arguments:
or ebp,ebp
jnz invalid_macro_arguments
@ -917,7 +1071,7 @@ define_macro:
je found_macro_block
jmp invalid_macro_arguments
macro_argument_with_default_value:
or [default_argument_value],-1
or [skip_default_argument_value],-1
call skip_macro_argument_value
inc esi
jmp macro_argument_end
@ -956,10 +1110,12 @@ define_macro:
jz argument_value_end
cmp al,','
je argument_value_end
cmp [default_argument_value],0
cmp [skip_default_argument_value],0
je invalid_macro_arguments
cmp al,'{'
je argument_value_end
cmp al,'&'
je argument_value_end
or ebp,ebp
jz invalid_macro_arguments
cmp al,']'
@ -975,10 +1131,12 @@ define_macro:
je argument_string
cmp al,1Ah
je argument_symbol
cmp [default_argument_value],0
cmp [skip_default_argument_value],0
je simple_argument
cmp al,'{'
je argument_value_end
cmp al,'&'
je argument_value_end
or ebp,ebp
jz simple_argument
cmp al,']'
@ -1056,6 +1214,7 @@ postpone_directive:
xor ecx,ecx
call add_preprocessor_symbol
mov eax,[current_line]
mov [error_line],eax
mov [edx+12],eax
pop esi
mov [edx+8],esi
@ -1063,8 +1222,6 @@ postpone_directive:
and al,0F0h
or al,1
mov [macro_status],al
mov eax,[current_line]
mov [error_line],eax
lods byte [esi]
or al,al
jz line_preprocessed
@ -1080,6 +1237,9 @@ irp_directive:
irps_directive:
mov [base_code],2
jmp define_instant_macro
irpv_directive:
mov [base_code],3
jmp define_instant_macro
match_directive:
mov [base_code],10h
define_instant_macro:
@ -1555,6 +1715,8 @@ use_macro:
je next_argument
cmp al,']'
je next_arguments_group
cmp al,'&'
je arguments_end
dec esi
jmp arguments_end
next_argument:
@ -1575,19 +1737,50 @@ use_macro:
mov eax,[counter_limit]
call add_macro_symbol
add esi,ecx
xor eax,eax
mov [default_argument_value],eax
cmp byte [esi],'*'
je required_value
cmp byte [esi],':'
je get_default_value
cmp byte [esi],'='
jne default_value_ok
get_default_value:
inc esi
mov [default_argument_value],esi
or [skip_default_argument_value],-1
call skip_macro_argument_value
jmp default_value_ok
required_value:
inc esi
or [default_argument_value],-1
default_value_ok:
xchg esi,ebx
mov [edx+12],esi
mov [default_argument_value],0
mov [skip_default_argument_value],0
cmp byte [ebx],'&'
je greedy_macro_argument
call skip_macro_argument_value
call finish_macro_argument
jmp got_macro_argument
greedy_macro_argument:
call skip_foreign_line
dec esi
mov eax,[edx+12]
mov ecx,esi
sub ecx,eax
mov [edx+8],ecx
got_macro_argument:
xchg esi,ebx
cmp byte [esi],'='
je argument_with_default_value
cmp byte [esi],'*'
jne macro_argument_ok
cmp dword [edx+8],0
jne macro_argument_ok
mov eax,[default_argument_value]
or eax,eax
jz macro_argument_ok
cmp eax,-1
je invalid_macro_arguments
inc esi
mov [edx+12],eax
call finish_macro_argument
macro_argument_ok:
ret
finish_macro_argument:
@ -1602,17 +1795,6 @@ use_macro:
argument_value_length_ok:
mov [edx+8],ecx
ret
argument_with_default_value:
inc esi
push esi
or [default_argument_value],-1
call skip_macro_argument_value
pop eax
cmp dword [edx+8],0
jne macro_argument_ok
mov [edx+12],eax
call finish_macro_argument
jmp macro_argument_ok
arguments_end:
cmp byte [ebx],0
jne invalid_macro_arguments
@ -1738,6 +1920,8 @@ do_irp:
lods byte [esi]
cmp [base_code],1
ja irps_name_ok
cmp al,':'
je irp_with_default_value
cmp al,'='
je irp_with_default_value
cmp al,'*'
@ -1749,13 +1933,17 @@ do_irp:
jmp irp_parameters_start
irp_with_default_value:
xor ebp,ebp
or [default_argument_value],-1
or [skip_default_argument_value],-1
call skip_macro_argument_value
cmp byte [esi],','
jne invalid_macro_arguments
inc esi
jmp irp_parameters_start
irps_name_ok:
cmp al,','
jne invalid_macro_arguments
cmp [base_code],3
je irp_parameters_start
mov al,[esi]
or al,al
jz instant_macro_done
@ -1769,9 +1957,11 @@ do_irp:
push [counter_limit]
mov [counter_limit],eax
mov [struc_name],eax
cmp [base_code],3
je get_irpv_parameter
mov ebx,esi
cmp [base_code],1
ja get_irps_parameter
cmp [base_code],2
je get_irps_parameter
mov edx,[parameters_end]
mov al,[edx]
push eax
@ -1822,6 +2012,70 @@ do_irp:
irps_parameters_end:
mov esi,ebx
jmp instant_macro_parameters_ok
get_irpv_parameter:
lods byte [esi]
cmp al,1Ah
jne invalid_macro_arguments
lods byte [esi]
mov ebp,esi
mov cl,al
mov ch,10b
call get_preprocessor_symbol
jc instant_macro_finish
push edx
mark_variable_value:
inc [counter_limit]
mov [edx+4],ebp
next_variable_value:
mov edx,[edx]
or edx,edx
jz variable_values_marked
mov eax,[edx+4]
cmp eax,1
jbe next_variable_value
mov esi,ebp
movzx ecx,byte [esi-1]
xchg edi,eax
repe cmps byte [esi],[edi]
xchg edi,eax
je mark_variable_value
jmp next_variable_value
variable_values_marked:
pop edx
push [counter_limit]
add_irpv_value:
push edx
mov esi,[instant_macro_start]
inc esi
lods byte [esi]
movzx ecx,al
mov eax,[esp+4]
call add_macro_symbol
mov ebx,edx
pop edx
mov ecx,[edx+12]
mov eax,[edx+8]
mov [ebx+12],eax
mov [ebx+8],ecx
collect_next_variable_value:
mov edx,[edx]
or edx,edx
jz variable_values_collected
cmp ebp,[edx+4]
jne collect_next_variable_value
dec dword [esp]
jnz add_irpv_value
variable_values_collected:
pop eax
mov esi,ebp
movzx ecx,byte [esi-1]
add esi,ecx
cmp byte [esi],0
je instant_macro_parameters_ok
cmp byte [esi],'{'
jne invalid_macro_arguments
jmp instant_macro_parameters_ok
do_match:
mov ebx,esi
call skip_pattern
@ -2451,6 +2705,8 @@ reverse_block:
mov [macro_block_line_number],ecx
jmp process_macro_line
close_macro_block:
cmp esi,[macro_block]
je block_closed
cmp [counter],0
je block_closed
jl reverse_counter

View File

@ -1,6 +1,6 @@
; flat assembler core
; Copyright (c) 1999-2013, Tomasz Grysztar.
; Copyright (c) 1999-2016, Tomasz Grysztar.
; All rights reserved.
dump_symbols:

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
; flat assembler core variables
; Copyright (c) 1999-2013, Tomasz Grysztar.
; Copyright (c) 1999-2016, Tomasz Grysztar.
; All rights reserved.
; Variables which have to be set up by interface:
@ -13,6 +13,7 @@ additional_memory_end dd ?
stack_limit dd ?
initial_definitions dd ?
input_file dd ?
output_file dd ?
symbols_file dd ?
@ -42,6 +43,7 @@ struc_name dd ?
struc_label dd ?
instant_macro_start dd ?
parameters_end dd ?
default_argument_value dd ?
locals_counter rb 8
current_locals_prefix dd ?
anonymous_reverse dd ?
@ -68,6 +70,7 @@ adjustment dq ?
symbol_identifier dd ?
address_symbol dd ?
address_high dd ?
uncompressed_displacement dd ?
format_flags dd ?
resolver_flags dd ?
symbols_stream dd ?
@ -87,6 +90,7 @@ actual_fixups_size dd ?
reserved_fixups dd ?
reserved_fixups_size dd ?
last_fixup_base dd ?
last_fixup_header dd ?
parenthesis_stack dd ?
blocks_stack dd ?
parsed_lines dd ?
@ -94,13 +98,16 @@ logical_value_parentheses dd ?
file_extension dd ?
operand_size db ?
size_override db ?
operand_flags db ?
operand_prefix db ?
opcode_prefix db ?
rex_prefix db ?
opcode_prefix db ?
vex_required db ?
vex_register db ?
immediate_size db ?
mask_register db ?
broadcast_size db ?
rounding_mode db ?
base_code db ?
extended_code db ?
@ -116,6 +123,8 @@ value_size db ?
address_size db ?
label_size db ?
size_declared db ?
address_size_declared db ?
displacement_compression db ?
value_undefined db ?
value_constant db ?
@ -124,17 +133,20 @@ value_sign db ?
fp_sign db ?
fp_format db ?
address_sign db ?
address_register db ?
compare_type db ?
logical_value_wrapping db ?
next_pass_needed db ?
output_format db ?
code_type db ?
adjustment_sign db ?
evex_mode db ?
macro_status db ?
default_argument_value db ?
prefixed_instruction db ?
skip_default_argument_value db ?
prefix_flags db ?
formatter_symbols_allowed db ?
decorator_symbols_allowed db ?
free_address_range db ?

View File

@ -1,6 +1,6 @@
; flat assembler version 1.71
; Copyright (c) 1999-2013, Tomasz Grysztar.
; Copyright (c) 1999-2016, Tomasz Grysztar.
; All rights reserved.
;
; This programs is free for commercial and non-commercial use as long as
@ -33,7 +33,7 @@
; cannot simply be copied and put under another distribution licence
; (including the GNU Public Licence).
VERSION_STRING equ "1.71.16"
VERSION_STRING equ "1.71.54"
VERSION_MAJOR = 1
VERSION_MINOR = 71

File diff suppressed because it is too large Load Diff