fasm 1.69.34 - It's works but need check

git-svn-id: svn://kolibrios.org@2287 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
heavyiron 2011-10-13 19:06:08 +00:00
parent 1d24b843ac
commit 61dfe6eeec
16 changed files with 6984 additions and 3988 deletions

View File

@ -1,14 +1,15 @@
; flat assembler core
; Copyright (c) 1999-2009, Tomasz Grysztar.
; Copyright (c) 1999-2011, Tomasz Grysztar.
; All rights reserved.
assembler:
xor eax,eax
mov [stub_size],eax
mov [number_of_sections],eax
mov [current_pass],ax
mov [resolver_flags],eax
mov [number_of_sections],eax
mov [actual_fixups_size],eax
assembler_loop:
mov eax,[labels_list]
mov [display_buffer],eax
@ -115,6 +116,14 @@ assembler:
or eax,eax
jz assemble_ok
mov [current_line],eax
cmp [error],undefined_symbol
jne error_confirmed
mov eax,[error_info]
or eax,eax
jz error_confirmed
test byte [eax+8],1
jnz next_pass
error_confirmed:
call error_handler
error_handler:
mov eax,[error]
@ -360,10 +369,13 @@ assemble_line:
; mov [operand_size],0
; mov [size_override],0
; mov [operand_prefix],0
; mov [rex_prefix],0
; mov [opcode_prefix],0
mov dword [operand_size],0
mov [opcode_prefix],0
mov [immediate_size],0
; mov [rex_prefix],0
; mov [vex_required],0
; mov [vex_register],0
; mov [immediate_size],0
mov dword [rex_prefix],0
call instruction_handler
instruction_handler:
movzx ebx,word [esi]
@ -384,87 +396,6 @@ assemble_line:
dec esi
stc
ret
skip_line:
call skip_symbol
jnc skip_line
ret
skip_symbol:
lods byte [esi]
or al,al
jz nothing_to_skip
cmp al,0Fh
je nothing_to_skip
cmp al,1
je skip_instruction
cmp al,2
je skip_label
cmp al,3
je skip_label
cmp al,20h
jb skip_assembler_symbol
cmp al,'('
je skip_expression
cmp al,'['
je skip_address
skip_done:
clc
ret
skip_label:
add esi,2
skip_instruction:
add esi,2
skip_assembler_symbol:
inc esi
jmp skip_done
skip_address:
mov al,[esi]
and al,11110000b
cmp al,60h
jb skip_expression
cmp al,70h
ja skip_expression
inc esi
jmp skip_address
skip_expression:
lods byte [esi]
or al,al
jz skip_string
cmp al,'.'
je skip_fp_value
cmp al,')'
je skip_done
cmp al,']'
je skip_done
cmp al,'!'
je skip_expression
cmp al,0Fh
je skip_expression
cmp al,10h
je skip_register
cmp al,11h
je skip_label_value
cmp al,80h
jae skip_expression
movzx eax,al
add esi,eax
jmp skip_expression
skip_label_value:
add esi,3
skip_register:
inc esi
jmp skip_expression
skip_fp_value:
add esi,12
jmp skip_done
skip_string:
lods dword [esi]
add esi,eax
inc esi
jmp skip_done
nothing_to_skip:
dec esi
stc
ret
org_directive:
lods byte [esi]
@ -576,7 +507,6 @@ label_directive:
mov [ebx+4],edx
setne al
or ah,al
jmp finish_label
finish_label:
cmp cl,[ebx+10]
mov [ebx+10],cl
@ -818,15 +748,9 @@ times_directive:
jne invalid_argument
cmp byte [esi],'.'
je invalid_value
call get_dword_value
cmp [next_pass_needed],0
jne times_value_ok
cmp [value_type],0
jne invalid_use_of_symbol
times_value_ok:
call get_count_value
cmp eax,0
je zero_times
jl negative_times
cmp byte [esi],':'
jne times_argument_ok
inc esi
@ -855,14 +779,9 @@ times_directive:
pop [counter_limit]
pop [counter]
jmp instruction_assembled
negative_times:
cmp [error_line],0
jne zero_times
mov eax,[current_line]
mov [error_line],eax
mov [error],invalid_value
zero_times:
call skip_line
call skip_symbol
jnc zero_times
jmp instruction_assembled
virtual_directive:
@ -973,13 +892,15 @@ virtual_directive:
mov edi,[ebx+8]
remove_structure_data:
push esi edi
mov esi,[structures_buffer]
mov ecx,ebx
sub ecx,esi
lea edi,[esi+20h]
mov [structures_buffer],edi
sub ecx,[structures_buffer]
shr ecx,2
lea esi,[ebx-4]
lea edi,[esi+20h]
std
rep movs dword [edi],[esi]
cld
add [structures_buffer],20h
pop edi esi
ret
repeat_directive:
@ -990,15 +911,9 @@ repeat_directive:
jne invalid_argument
cmp byte [esi],'.'
je invalid_value
call get_dword_value
cmp [next_pass_needed],0
jne repeat_value_ok
cmp [value_type],0
jne invalid_use_of_symbol
repeat_value_ok:
call get_count_value
cmp eax,0
je zero_repeat
jl negative_repeat
call allocate_structure_data
mov word [ebx],repeat_directive-instruction_handler
xchg eax,[counter_limit]
@ -1029,12 +944,6 @@ repeat_directive:
continue_repeating:
mov esi,[ebx+8]
jmp instruction_assembled
negative_repeat:
cmp [error_line],0
jne zero_repeat
mov eax,[current_line]
mov [error_line],eax
mov [error],invalid_value
zero_repeat:
mov al,[esi]
or al,al
@ -1187,7 +1096,8 @@ if_directive:
mov eax,[current_line]
mov [error_line],eax
find_end_directive:
call skip_line
call skip_symbol
jnc find_end_directive
lods byte [esi]
cmp al,0Fh
jne no_end_directive
@ -1358,23 +1268,10 @@ data_bytes:
cmp byte [ebx],81h
jne simple_data_value
inc esi
call get_dword_value
cmp [next_pass_needed],0
jne dup_value_ok
cmp [value_type],0
jne invalid_use_of_symbol
dup_value_ok:
call get_count_value
inc esi
cmp eax,0
jg dup_positive
cmp [error_line],0
jne dup_invalid
mov eax,[current_line]
mov [error_line],eax
mov [error],invalid_value
dup_invalid:
mov eax,1
dup_positive:
or eax,eax
jz duplicate_zero_times
cmp byte [esi],'{'
jne duplicate_single_data_value
inc esi
@ -1404,6 +1301,20 @@ data_bytes:
jz data_defined
mov esi,ebx
jmp duplicate_single_data_value
duplicate_zero_times:
cmp byte [esi],'{'
jne skip_single_data_value
inc esi
skip_data_value:
call skip_symbol
jc invalid_argument
cmp byte [esi],'}'
jne skip_data_value
inc esi
jmp data_defined
skip_single_data_value:
call skip_symbol
jmp data_defined
simple_data_value:
cmp edi,[display_buffer]
jae out_of_memory
@ -1691,7 +1602,7 @@ data_file:
cmp byte [esi],'.'
je invalid_value
push ebx
call get_dword_value
call get_count_value
pop ebx
mov edx,eax
sub [esp],edx
@ -1706,7 +1617,7 @@ data_file:
cmp byte [esi],'.'
je invalid_value
push ebx edx
call get_dword_value
call get_count_value
pop edx ebx
cmp eax,[esp]
ja value_out_of_range
@ -1731,8 +1642,13 @@ data_file:
open_binary_file:
push esi
push edi
mov esi,[current_line]
mov esi,[esi]
mov eax,[current_line]
find_current_source_path:
mov esi,[eax]
test byte [eax+7],80h
jz get_current_path
mov eax,[eax+12]
jmp find_current_source_path
get_current_path:
lodsb
stosb
@ -1772,14 +1688,7 @@ reserve_bytes:
jne invalid_argument
cmp byte [esi],'.'
je invalid_value
call get_dword_value
cmp [next_pass_needed],0
jne rb_value_ok
cmp [value_type],0
jne invalid_use_of_symbol
rb_value_ok:
cmp eax,0
jl reserve_negative
call get_count_value
mov ecx,eax
mov edx,ecx
add edx,edi
@ -1806,27 +1715,13 @@ reserve_bytes:
pop eax
call undefined_data
jmp instruction_assembled
reserve_negative:
cmp [error_line],0
jne instruction_assembled
mov eax,[current_line]
mov [error_line],eax
mov [error],invalid_value
jmp instruction_assembled
reserve_words:
lods byte [esi]
cmp al,'('
jne invalid_argument
cmp byte [esi],'.'
je invalid_value
call get_dword_value
cmp [next_pass_needed],0
jne rw_value_ok
cmp [value_type],0
jne invalid_use_of_symbol
rw_value_ok:
cmp eax,0
jl reserve_negative
call get_count_value
mov ecx,eax
mov edx,ecx
shl edx,1
@ -1854,14 +1749,7 @@ reserve_dwords:
jne invalid_argument
cmp byte [esi],'.'
je invalid_value
call get_dword_value
cmp [next_pass_needed],0
jne rd_value_ok
cmp [value_type],0
jne invalid_use_of_symbol
rd_value_ok:
cmp eax,0
jl reserve_negative
call get_count_value
mov ecx,eax
mov edx,ecx
shl edx,1
@ -1887,14 +1775,7 @@ reserve_pwords:
jne invalid_argument
cmp byte [esi],'.'
je invalid_value
call get_dword_value
cmp [next_pass_needed],0
jne rp_value_ok
cmp [value_type],0
jne invalid_use_of_symbol
rp_value_ok:
cmp eax,0
jl reserve_negative
call get_count_value
mov ecx,eax
shl ecx,1
jc out_of_memory
@ -1917,14 +1798,7 @@ reserve_qwords:
jne invalid_argument
cmp byte [esi],'.'
je invalid_value
call get_dword_value
cmp [next_pass_needed],0
jne rq_value_ok
cmp [value_type],0
jne invalid_use_of_symbol
rq_value_ok:
cmp eax,0
jl reserve_negative
call get_count_value
mov ecx,eax
shl ecx,1
jc out_of_memory
@ -1948,14 +1822,7 @@ reserve_twords:
jne invalid_argument
cmp byte [esi],'.'
je invalid_value
call get_dword_value
cmp [next_pass_needed],0
jne rt_value_ok
cmp [value_type],0
jne invalid_use_of_symbol
rt_value_ok:
cmp eax,0
jl reserve_negative
call get_count_value
mov ecx,eax
shl ecx,2
jc out_of_memory
@ -1978,15 +1845,13 @@ align_directive:
jne invalid_argument
cmp byte [esi],'.'
je invalid_value
call get_dword_value
cmp [value_type],0
jne invalid_use_of_symbol
call get_count_value
mov edx,eax
dec edx
test eax,edx
jnz negative_times
jnz invalid_align_value
or eax,eax
jz negative_times
jz invalid_align_value
cmp eax,1
je instruction_assembled
mov ecx,edi
@ -2023,6 +1888,13 @@ align_directive:
je nops
add edi,ecx
jmp reserved_data
invalid_align_value:
cmp [error_line],0
jne instruction_assembled
mov eax,[current_line]
mov [error_line],eax
mov [error],invalid_value
jmp instruction_assembled
nops:
mov eax,90909090h
shr ecx,1

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
; flat assembler core
; Copyright (c) 1999-2009, Tomasz Grysztar.
; Copyright (c) 1999-2011, Tomasz Grysztar.
; All rights reserved.
out_of_memory:
@ -12,95 +12,101 @@ stack_overflow:
main_file_not_found:
push _main_file_not_found
jmp fatal_error
unexpected_end_of_file:
push _unexpected_end_of_file
jmp fatal_error
code_cannot_be_generated:
push _code_cannot_be_generated
jmp fatal_error
format_limitations_exceeded:
push _format_limitations_exceeded
jmp fatal_error
invalid_definition:
push _invalid_definition
jmp fatal_error
write_failed:
push _write_failed
jmp fatal_error
unexpected_end_of_file:
push _unexpected_end_of_file
jmp general_error
code_cannot_be_generated:
push _code_cannot_be_generated
jmp general_error
format_limitations_exceeded:
push _format_limitations_exceeded
general_error:
cmp [symbols_file],0
je fatal_error
call dump_preprocessed_source
jmp fatal_error
file_not_found:
push _file_not_found
jmp assembler_error
jmp error_with_source
error_reading_file:
push _error_reading_file
jmp assembler_error
jmp error_with_source
invalid_file_format:
push _invalid_file_format
jmp assembler_error
jmp error_with_source
invalid_macro_arguments:
push _invalid_macro_arguments
jmp assembler_error
jmp error_with_source
incomplete_macro:
push _incomplete_macro
jmp assembler_error
jmp error_with_source
unexpected_characters:
push _unexpected_characters
jmp assembler_error
jmp error_with_source
invalid_argument:
push _invalid_argument
jmp assembler_error
jmp error_with_source
illegal_instruction:
push _illegal_instruction
jmp assembler_error
jmp error_with_source
invalid_operand:
push _invalid_operand
jmp assembler_error
jmp error_with_source
invalid_operand_size:
push _invalid_operand_size
jmp assembler_error
jmp error_with_source
operand_size_not_specified:
push _operand_size_not_specified
jmp assembler_error
jmp error_with_source
operand_sizes_do_not_match:
push _operand_sizes_do_not_match
jmp assembler_error
jmp error_with_source
invalid_address_size:
push _invalid_address_size
jmp assembler_error
jmp error_with_source
address_sizes_do_not_agree:
push _address_sizes_do_not_agree
jmp assembler_error
jmp error_with_source
prefix_conflict:
push _prefix_conflict
jmp assembler_error
jmp error_with_source
long_immediate_not_encodable:
push _long_immediate_not_encodable
jmp assembler_error
jmp error_with_source
relative_jump_out_of_range:
push _relative_jump_out_of_range
jmp assembler_error
jmp error_with_source
invalid_expression:
push _invalid_expression
jmp assembler_error
jmp error_with_source
invalid_address:
push _invalid_address
jmp assembler_error
jmp error_with_source
invalid_value:
push _invalid_value
jmp assembler_error
jmp error_with_source
value_out_of_range:
push _value_out_of_range
jmp assembler_error
jmp error_with_source
undefined_symbol:
mov edi,message
mov esi,_undefined_symbol
call copy_asciiz
push message
cmp [error_info],0
je assembler_error
je error_with_source
mov esi,[error_info]
mov esi,[esi+24]
or esi,esi
jz error_with_source
mov byte [edi-1],20h
call write_quoted_symbol_name
jmp assembler_error
jmp error_with_source
copy_asciiz:
lods byte [esi]
stos byte [edi]
@ -110,7 +116,6 @@ undefined_symbol:
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
@ -122,6 +127,10 @@ symbol_out_of_scope:
call copy_asciiz
cmp [error_info],0
je finish_symbol_out_of_scope_message
mov esi,[error_info]
mov esi,[esi+24]
or esi,esi
jz finish_symbol_out_of_scope_message
mov byte [edi-1],20h
call write_quoted_symbol_name
finish_symbol_out_of_scope_message:
@ -129,46 +138,51 @@ symbol_out_of_scope:
mov esi,_symbol_out_of_scope_2
call copy_asciiz
push message
jmp assembler_error
jmp error_with_source
invalid_use_of_symbol:
push _invalid_use_of_symbol
jmp assembler_error
jmp error_with_source
name_too_long:
push _name_too_long
jmp assembler_error
jmp error_with_source
invalid_name:
push _invalid_name
jmp assembler_error
jmp error_with_source
reserved_word_used_as_symbol:
push _reserved_word_used_as_symbol
jmp assembler_error
jmp error_with_source
symbol_already_defined:
push _symbol_already_defined
jmp assembler_error
jmp error_with_source
missing_end_quote:
push _missing_end_quote
jmp assembler_error
jmp error_with_source
missing_end_directive:
push _missing_end_directive
jmp assembler_error
jmp error_with_source
unexpected_instruction:
push _unexpected_instruction
jmp assembler_error
jmp error_with_source
extra_characters_on_line:
push _extra_characters_on_line
jmp assembler_error
jmp error_with_source
section_not_aligned_enough:
push _section_not_aligned_enough
jmp assembler_error
jmp error_with_source
setting_already_specified:
push _setting_already_specified
jmp assembler_error
jmp error_with_source
data_already_defined:
push _data_already_defined
jmp assembler_error
jmp error_with_source
too_many_repeats:
push _too_many_repeats
jmp assembler_error
jmp error_with_source
invoked_error:
push _invoked_error
error_with_source:
cmp [symbols_file],0
je assembler_error
call dump_preprocessed_source
call restore_preprocessed_source
jmp assembler_error

File diff suppressed because it is too large Load Diff

View File

@ -622,14 +622,16 @@ display_bytes_count:
include 'system.inc'
include 'version.inc'
include 'errors.inc'
include 'expressi.inc'
include 'symbdump.inc'
include 'preproce.inc'
include 'parser.inc'
include 'exprpars.inc'
include 'assemble.inc'
include 'exprcalc.inc'
include 'formats.inc'
include 'x86_64.inc'
include 'avx.inc'
include 'tables.inc'
include 'symbdump.inc'
include 'messages.inc'
;---------------------------------------------------------------------
title db appname,VERSION_STRING,0

View File

@ -1,6 +1,6 @@
; flat assembler core
; Copyright (c) 1999-2009, Tomasz Grysztar.
; Copyright (c) 1999-2011, Tomasz Grysztar.
; All rights reserved.
formatter:
@ -204,7 +204,7 @@ format_directive:
cmp [output_format],0
jne unexpected_instruction
lods byte [esi]
cmp al,17h
cmp al,1Ch
je format_prefix
cmp al,18h
jne invalid_argument
@ -834,11 +834,11 @@ format_pe:
mov [subsystem],3
mov [subsystem_version],3 + 10 shl 16
mov [image_base],400000h
mov [image_base_high],0
test [format_flags],8
jz pe_settings
mov [machine],8664h
mov [subsystem_version],5 + 0 shl 16
mov [image_base_high],0
pe_settings:
cmp byte [esi],84h
je get_stub_name
@ -854,6 +854,10 @@ format_pe:
je dll_flag
cmp al,81h
je wdm_flag
cmp al,82h
je large_flag
cmp al,83h
je nx_flag
jmp pe_settings
dll_flag:
bts [format_flags],8
@ -863,6 +867,16 @@ format_pe:
bts [format_flags],9
jc setting_already_specified
jmp pe_settings
large_flag:
bts [format_flags],11
jc setting_already_specified
test [format_flags],8
jnz invalid_argument
jmp pe_settings
nx_flag:
bts [format_flags],12
jc setting_already_specified
jmp pe_settings
subsystem_setting:
bts [format_flags],7
jc setting_already_specified
@ -870,7 +884,7 @@ format_pe:
mov [subsystem],ax
cmp ax,10
jb subsystem_type_ok
or [format_flags],8
or [format_flags],4
subsystem_type_ok:
cmp byte [esi],'('
jne pe_settings
@ -924,7 +938,7 @@ format_pe:
je invalid_value
push edx edi
add edi,[stub_size]
test [format_flags],8
test [format_flags],4
jnz get_peplus_base
call get_dword_value
mov [image_base],eax
@ -966,7 +980,7 @@ format_pe:
pe_stub_ok:
mov edx,edi
mov ecx,18h+0E0h
test [format_flags],8
test [format_flags],4
jz zero_pe_header
add ecx,10h
zero_pe_header:
@ -991,10 +1005,10 @@ format_pe:
mov dword [edx+3Ch],eax
pe_alignment_ok:
mov word [edx+1Ah],VERSION_MAJOR + VERSION_MINOR shl 8
test [format_flags],8
test [format_flags],4
jnz init_peplus_specific
mov byte [edx+14h],0E0h ; size of optional header
mov dword [edx+16h],10B010Eh; flags and magic value
mov dword [edx+16h],10B010Fh; flags and magic value
mov eax,[image_base]
mov [edx+34h],eax
mov byte [edx+60h+1],10h ; stack reserve
@ -1004,7 +1018,7 @@ format_pe:
jmp pe_header_ok
init_peplus_specific:
mov byte [edx+14h],0F0h ; size of optional header
mov dword [edx+16h],20B002Eh; flags and magic value
mov dword [edx+16h],20B002Fh; flags and magic value
mov eax,[image_base]
mov [edx+30h],eax
mov eax,[image_base_high]
@ -1063,19 +1077,24 @@ format_pe:
adc ecx,0
add eax,edi
adc ecx,0
test [format_flags],8
test [format_flags],4
jnz peplus_org
sub eax,[edx+34h]
sbb ecx,0
mov bl,2
mov [code_type],32
jmp pe_org_ok
peplus_org:
sub eax,[edx+30h]
sbb ecx,[edx+34h]
pe_org_ok:
test [format_flags],8
jnz pe64_code
mov bl,2
mov [code_type],32
jmp pe_code_type_ok
pe64_code:
mov bl,4
mov [code_type],64
pe_org_ok:
pe_code_type_ok:
bt [resolver_flags],0
jc pe_labels_type_ok
xor bl,bl
@ -1093,6 +1112,14 @@ format_pe:
jnc wdm_flag_ok
or byte [edx+5Eh+1],20h
wdm_flag_ok:
bt [format_flags],11
jnc large_flag_ok
or byte [edx+16h],20h
large_flag_ok:
bt [format_flags],12
jnc nx_ok
or byte [edx+5Eh+1],1
nx_ok:
jmp format_defined
pe_section:
call close_pe_section
@ -1135,12 +1162,17 @@ pe_section:
xor ecx,ecx
sub eax,[ebx+0Ch]
sbb ecx,0
mov [labels_type],2
mov [code_type],32
test [format_flags],8
jz pe_section_code_type_ok
mov [labels_type],4
mov [code_type],64
pe_section_code_type_ok:
test [format_flags],4
jnz peplus_section_org
sub eax,[edx+34h]
sbb ecx,0
mov [labels_type],2
mov [code_type],32
bt [resolver_flags],0
jc pe_section_org_ok
mov [labels_type],0
@ -1148,8 +1180,6 @@ pe_section:
peplus_section_org:
sub eax,[edx+30h]
sbb ecx,[edx+34h]
mov [labels_type],4
mov [code_type],64
bt [resolver_flags],0
jc pe_section_org_ok
mov [labels_type],0
@ -1170,7 +1200,7 @@ pe_section:
movzx eax,byte [esi]
inc esi
mov ecx,ebx
test [format_flags],8
test [format_flags],4
jnz peplus_directory
xchg ecx,[edx+78h+eax*8]
mov dword [edx+78h+eax*8+4],-1
@ -1244,7 +1274,7 @@ pe_section:
test byte [ebx+24h],40h
jz pe_data_sum_ok
add [edx+20h],ecx
test [format_flags],8
test [format_flags],4
jnz pe_data_sum_ok
cmp dword [edx+30h],0
jne pe_data_sum_ok
@ -1291,7 +1321,7 @@ data_directive:
sub ecx,[ebx+14h]
add ecx,[ebx+0Ch]
mov edx,[code_start]
test [format_flags],8
test [format_flags],4
jnz peplus_data
xchg ecx,[edx+78h+eax*8]
jmp init_pe_data
@ -1318,7 +1348,7 @@ data_directive:
sub ecx,[edx+14h]
add ecx,[edx+0Ch]
mov edx,[code_start]
test [format_flags],8
test [format_flags],4
jnz end_peplus_data
sub ecx,[edx+78h+eax*8]
mov [edx+78h+eax*8+4],ecx
@ -1334,7 +1364,7 @@ pe_entry:
cmp byte [esi],'.'
je invalid_value
test [format_flags],8
jnz peplus_entry
jnz pe64_entry
call get_dword_value
mov bl,2
bt [resolver_flags],0
@ -1349,33 +1379,36 @@ pe_entry:
mov [error_line],edx
mov [error],invalid_address
pe_entry_ok:
cdq
test [format_flags],4
jnz pe64_entry_type_ok
mov edx,[code_start]
sub eax,[edx+34h]
mov [edx+28h],eax
jmp instruction_assembled
peplus_entry:
pe64_entry:
call get_qword_value
mov bl,4
bt [resolver_flags],0
jc check_peplus_entry_label_type
jc check_pe64_entry_label_type
xor bl,bl
check_peplus_entry_label_type:
check_pe64_entry_label_type:
cmp [value_type],bl
je peplus_entry_type_ok
je pe64_entry_type_ok
cmp [error_line],0
jne peplus_entry_type_ok
jne pe64_entry_type_ok
mov edx,[current_line]
mov [error_line],edx
mov [error],invalid_address
peplus_entry_type_ok:
pe64_entry_type_ok:
mov ecx,[code_start]
sub eax,[ecx+30h]
sbb edx,[ecx+34h]
jz peplus_entry_range_ok
jz pe64_entry_range_ok
mov edx,[current_line]
mov [error_line],edx
mov [error],value_out_of_range
peplus_entry_range_ok:
pe64_entry_range_ok:
mov [ecx+28h],eax
jmp instruction_assembled
pe_stack:
@ -1384,11 +1417,9 @@ pe_stack:
jne invalid_argument
cmp byte [esi],'.'
je invalid_value
test [format_flags],8
test [format_flags],4
jnz peplus_stack
call get_dword_value
cmp [value_type],0
jne invalid_use_of_symbol
call get_count_value
mov edx,[code_start]
mov [edx+60h],eax
cmp byte [esi],','
@ -1399,9 +1430,7 @@ pe_stack:
jne invalid_argument
cmp byte [esi],'.'
je invalid_value
call get_dword_value
cmp [value_type],0
jne invalid_use_of_symbol
call get_count_value
mov edx,[code_start]
mov [edx+64h],eax
cmp eax,[edx+60h]
@ -1456,11 +1485,9 @@ pe_heap:
jne invalid_argument
cmp byte [esi],'.'
je invalid_value
test [format_flags],8
test [format_flags],4
jnz peplus_heap
call get_dword_value
cmp [value_type],0
jne invalid_use_of_symbol
call get_count_value
mov edx,[code_start]
mov [edx+68h],eax
cmp byte [esi],','
@ -1471,9 +1498,7 @@ pe_heap:
jne invalid_argument
cmp byte [esi],'.'
je invalid_value
call get_dword_value
cmp [value_type],0
jne invalid_use_of_symbol
call get_count_value
mov edx,[code_start]
mov [edx+6Ch],eax
cmp eax,[edx+68h]
@ -1508,11 +1533,11 @@ pe_heap:
jmp instruction_assembled
mark_pe_relocation:
push eax ebx
test [format_flags],8
jz check_pe32_relocation_type
test [format_flags],4
jz check_standard_pe_relocation_type
cmp [value_type],4
je pe_relocation_type_ok
check_pe32_relocation_type:
check_standard_pe_relocation_type:
cmp [value_type],2
je pe_relocation_type_ok
cmp [error_line],0
@ -1527,7 +1552,6 @@ mark_pe_relocation:
add eax,[ebx+0Ch]
mov ebx,[free_additional_memory]
inc [number_of_relocations]
jz invalid_use_of_symbol
add ebx,5
cmp ebx,[structures_buffer]
jae out_of_memory
@ -1549,20 +1573,36 @@ generate_pe_data:
je make_pe_fixups
ret
make_pe_fixups:
mov edx,[code_start]
and byte [edx+16h],not 1
or byte [edx+5Eh],40h
bts [resolver_flags],0
jc pe_relocatable_ok
jc fixups_ready
or [next_pass_needed],-1
pe_relocatable_ok:
fixups_ready:
mov [last_fixup_base],0
call make_fixups
xchg eax,[actual_fixups_size]
sub eax,[actual_fixups_size]
ja reserve_forward_fixups
xor eax,eax
reserve_forward_fixups:
mov [reserved_fixups],edi
add edi,eax
mov [reserved_fixups_size],eax
ret
make_fixups:
push esi
mov ecx,[number_of_relocations]
xor ecx,ecx
xchg ecx,[number_of_relocations]
mov esi,[free_additional_memory]
lea eax,[ecx*5]
sub esi,eax
mov [free_additional_memory],esi
or [number_of_relocations],-1
xor edx,edx
mov edx,[last_fixup_base]
mov ebp,edi
make_fixups:
jecxz fixups_done
make_fixup:
cmp [esi],edx
jb store_fixup
mov eax,edi
@ -1582,7 +1622,6 @@ make_pe_fixups:
mov eax,8
stos dword [edi]
store_fixup:
jecxz fixups_done
add dword [ebx],2
mov ah,[esi+1]
and ah,0Fh
@ -1592,9 +1631,12 @@ make_pe_fixups:
mov al,[esi]
stos word [edi]
add esi,5
loop make_fixups
loop make_fixup
fixups_done:
mov [last_fixup_base],edx
pop esi
mov eax,edi
sub eax,ebp
ret
make_pe_resource:
cmp byte [esi],82h
@ -2169,15 +2211,6 @@ close_pe:
call make_timestamp
mov edx,[code_start]
mov [edx+8],eax
mov eax,[number_of_relocations]
cmp eax,-1
je pe_relocations_ok
shl eax,2
sub [free_additional_memory],eax
btr [resolver_flags],0
jnc pe_relocations_ok
or [next_pass_needed],-1
pe_relocations_ok:
mov eax,[number_of_sections]
mov [edx+6],ax
imul eax,28h
@ -2195,7 +2228,7 @@ close_pe:
pe_sections_ok:
xor ecx,ecx
add edx,78h
test [format_flags],8
test [format_flags],4
jz process_directories
add edx,10h
process_directories:
@ -2214,6 +2247,25 @@ close_pe:
inc cl
cmp cl,10h
jb process_directories
cmp dword [edx+5*8],0
jne finish_pe_relocations
mov eax,[number_of_relocations]
shl eax,2
sub [free_additional_memory],eax
btr [resolver_flags],0
jnc pe_relocations_ok
or [next_pass_needed],-1
jmp pe_relocations_ok
finish_pe_relocations:
push edi
mov edi,[reserved_fixups]
call make_fixups
pop edi
add [actual_fixups_size],eax
cmp eax,[reserved_fixups_size]
je pe_relocations_ok
or [next_pass_needed],-1
pe_relocations_ok:
mov ebx,[code_start]
sub ebx,[stub_size]
mov ecx,edi
@ -2303,7 +2355,7 @@ coff_section:
cmp ecx,8
ja name_too_long
coff_section_flags:
cmp byte [esi],1Ch
cmp byte [esi],8Ch
je coff_section_alignment
cmp byte [esi],19h
jne coff_section_settings_ok
@ -2326,18 +2378,13 @@ coff_section:
jnc invalid_argument
inc esi
lods byte [esi]
or al,al
jnz invalid_argument
lods byte [esi]
cmp al,'('
jne invalid_argument
cmp byte [esi],'.'
je invalid_value
push ebx
call get_dword_value
call get_count_value
pop ebx
cmp [value_type],0
jne invalid_use_of_symbol
mov edx,eax
dec edx
test eax,edx
@ -2742,7 +2789,6 @@ coff_formatter:
je public_symbol_type_ok
jmp invalid_use_of_symbol
undefined_coff_public:
mov eax,[eax+24]
mov [error_info],eax
jmp undefined_symbol
check_64bit_public_symbol:
@ -2952,7 +2998,7 @@ elf_section:
mov ecx,[esi]
lea esi,[esi+4+ecx+1]
elf_section_flags:
cmp byte [esi],1Ch
cmp byte [esi],8Ch
je elf_section_alignment
cmp byte [esi],19h
jne elf_section_settings_ok
@ -2972,18 +3018,13 @@ elf_section:
elf_section_alignment:
inc esi
lods byte [esi]
or al,al
jnz invalid_argument
lods byte [esi]
cmp al,'('
jne invalid_argument
cmp byte [esi],'.'
je invalid_value
push ebx
call get_dword_value
call get_count_value
pop ebx
cmp [value_type],0
jne invalid_use_of_symbol
mov edx,eax
dec edx
test eax,edx
@ -4007,7 +4048,6 @@ elf_segment:
elf64_segment_position_ok:
and eax,not 0FFFh
ret
close_elf_exe:
test [format_flags],8
jnz close_elf64_exe
@ -4038,299 +4078,3 @@ close_elf_exe:
or [next_pass_needed],-1
elf64_exe_ok:
ret
dump_symbols:
mov ebx,[code_start]
mov dword [ebx],'fas'+1Ah shl 24
mov dword [ebx+4],VERSION_MAJOR + VERSION_MINOR shl 8 + 38h shl 16
add ebx,38h
mov edi,ebx
mov dword [ebx-38h+10h],38h
mov dword [ebx-38h+8],0
mov esi,[input_file]
call copy_asciiz
cmp edi,[display_buffer]
jae out_of_memory
mov eax,edi
sub eax,ebx
mov [ebx-38h+0Ch],eax
mov esi,[output_file]
call copy_asciiz
cmp edi,[display_buffer]
jae out_of_memory
mov edx,[symbols_stream]
mov ebp,[free_additional_memory]
mov [number_of_sections],0
cmp [output_format],4
je prepare_strings_table
cmp [output_format],5
jne strings_table_ready
bt [format_flags],0
jc strings_table_ready
prepare_strings_table:
cmp edx,ebp
je strings_table_ready
mov al,[edx]
test al,al
jz prepare_string
cmp al,80h
je prepare_string
add edx,0Ch
cmp al,0C0h
jb prepare_strings_table
add edx,4
jmp prepare_strings_table
prepare_string:
mov esi,edi
sub esi,ebx
xchg esi,[edx+4]
test al,al
jz prepare_section_string
or dword [edx+4],1 shl 31
add edx,0Ch
prepare_external_string:
mov ecx,[esi]
add esi,4
rep movs byte [edi],[esi]
mov byte [edi],0
inc edi
cmp edi,[display_buffer]
jae out_of_memory
jmp prepare_strings_table
prepare_section_string:
mov ecx,[number_of_sections]
mov eax,ecx
inc eax
mov [number_of_sections],eax
xchg eax,[edx+4]
shl ecx,2
add ecx,[free_additional_memory]
mov [ecx],eax
add edx,20h
test esi,esi
jz prepare_default_section_string
cmp [output_format],5
jne prepare_external_string
bt [format_flags],0
jc prepare_external_string
mov esi,[esi]
add esi,[resource_data]
copy_elf_section_name:
lods byte [esi]
cmp edi,[display_buffer]
jae out_of_memory
stos byte [edi]
test al,al
jnz copy_elf_section_name
jmp prepare_strings_table
prepare_default_section_string:
mov eax,'.fla'
stos dword [edi]
mov ax,'t'
stos word [edi]
cmp edi,[display_buffer]
jae out_of_memory
jmp prepare_strings_table
strings_table_ready:
mov edx,[display_buffer]
mov ebp,[memory_end]
sub ebp,[labels_list]
add ebp,edx
prepare_labels_dump:
cmp edx,ebp
je labels_dump_ok
mov eax,[edx+24]
test eax,eax
jz label_dump_name_ok
cmp eax,[memory_start]
jb label_name_outside_source
cmp eax,[source_start]
ja label_name_outside_source
sub eax,[memory_start]
dec eax
mov [edx+24],eax
jmp label_dump_name_ok
label_name_outside_source:
mov esi,eax
mov eax,edi
sub eax,ebx
or eax,1 shl 31
mov [edx+24],eax
movzx ecx,byte [esi-1]
lea eax,[edi+ecx+1]
cmp edi,[display_buffer]
jae out_of_memory
rep movsb
xor al,al
stosb
label_dump_name_ok:
mov eax,[edx+28]
test eax,eax
jz label_dump_line_ok
sub eax,[memory_start]
mov [edx+28],eax
label_dump_line_ok:
mov eax,[edx+20]
test eax,eax
jz base_symbol_for_label_ok
cmp eax,[symbols_stream]
mov eax,[eax+4]
jae base_symbol_for_label_ok
xor eax,eax
base_symbol_for_label_ok:
mov [edx+20],eax
add edx,LABEL_STRUCTURE_SIZE
jmp prepare_labels_dump
labels_dump_ok:
mov eax,edi
sub eax,ebx
mov [ebx-38h+14h],eax
add eax,38h
mov [ebx-38h+18h],eax
mov ecx,[memory_end]
sub ecx,[labels_list]
mov [ebx-38h+1Ch],ecx
add eax,ecx
mov [ebx-38h+20h],eax
mov ecx,[source_start]
sub ecx,[memory_start]
mov [ebx-38h+24h],ecx
add eax,ecx
mov [ebx-38h+28h],eax
mov eax,[number_of_sections]
shl eax,2
mov [ebx-38h+34h],eax
mov esi,[memory_start]
prepare_preprocessed_source:
cmp esi,[source_start]
jae preprocessed_source_ok
mov eax,[memory_start]
mov edx,[input_file]
cmp [esi],edx
jne line_not_from_main_input
mov [esi],eax
line_not_from_main_input:
sub [esi],eax
test byte [esi+7],1 shl 7
jz prepare_next_preprocessed_line
sub [esi+8],eax
sub [esi+12],eax
prepare_next_preprocessed_line:
add esi,16
skip_preprocessed_line:
lods byte [esi]
cmp al,1Ah
je skip_preprocessed_symbol
cmp al,3Bh
je skip_preprocessed_symbol
cmp al,22h
je skip_preprocessed_string
or al,al
jnz skip_preprocessed_line
jmp prepare_preprocessed_source
skip_preprocessed_string:
lods dword [esi]
add esi,eax
jmp skip_preprocessed_line
skip_preprocessed_symbol:
lods byte [esi]
movzx eax,al
add esi,eax
jmp skip_preprocessed_line
preprocessed_source_ok:
mov esi,[labels_list]
mov ebp,edi
make_lines_dump:
cmp esi,[display_buffer]
je lines_dump_ok
mov eax,[esi-4]
mov ecx,[esi-8]
sub esi,8
sub esi,ecx
cmp eax,1
jne make_lines_dump
mov eax,[esi+4]
sub eax,[code_start]
add eax,[headers_size]
cmp byte [esi+1Ah],0
je store_offset
xor eax,eax
store_offset:
stos dword [edi]
mov eax,[esi]
sub eax,[memory_start]
stos dword [edi]
mov eax,[esi+4]
xor edx,edx
sub eax,[esi+8]
sbb edx,[esi+8+4]
stos dword [edi]
mov eax,edx
stos dword [edi]
mov eax,[esi+10h]
stos dword [edi]
mov eax,[esi+14h]
test eax,eax
jz base_symbol_for_line_ok
cmp eax,[symbols_stream]
mov eax,[eax+4]
jae base_symbol_for_line_ok
xor eax,eax
base_symbol_for_line_ok:
stos dword [edi]
mov eax,[esi+18h]
and eax,001FFFFh
stos dword [edi]
jmp make_lines_dump
lines_dump_ok:
mov edx,edi
mov eax,[current_offset]
sub eax,[code_start]
add eax,[headers_size]
stos dword [edi]
mov ecx,edi
sub ecx,ebx
sub ecx,[ebx-38h+14h]
mov [ebx-38h+2Ch],ecx
add ecx,[ebx-38h+28h]
mov [ebx-38h+30h],ecx
find_inexisting_offsets:
sub edx,1Ch
cmp edx,ebp
jb write_symbols
test byte [edx+1Ah],1
jnz find_inexisting_offsets
cmp eax,[edx]
jb correct_inexisting_offset
mov eax,[edx]
jmp find_inexisting_offsets
correct_inexisting_offset:
mov dword [edx],0
or byte [edx+1Ah],2
jmp find_inexisting_offsets
write_symbols:
mov edx,[symbols_file]
call create
jc write_failed
mov edx,[code_start]
mov ecx,[edx+14h]
add ecx,38h
call write
mov edx,[display_buffer]
mov ecx,[memory_end]
sub ecx,[labels_list]
call write
mov edx,[memory_start]
mov ecx,[source_start]
sub ecx,edx
call write
mov edx,ebp
mov ecx,edi
sub ecx,edx
call write
mov edx,[free_additional_memory]
mov ecx,[number_of_sections]
shl ecx,2
call write
call close
ret

View File

@ -1,6 +1,6 @@
; flat assembler core
; Copyright (c) 1999-2009, Tomasz Grysztar.
; Copyright (c) 1999-2011, 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-2009, Tomasz Grysztar.
; Copyright (c) 1999-2011, Tomasz Grysztar.
; All rights reserved.
parser:
@ -33,6 +33,7 @@ parser:
inc [parsed_lines]
add esi,16
parse_line:
mov [formatter_symbols_allowed],0
cmp byte [esi],1Ah
jne empty_instruction
push edi
@ -461,13 +462,22 @@ parse_line_contents:
cmp bx,label_directive-instruction_handler
je parse_label_directive
cmp bx,segment_directive-instruction_handler
je parse_label_directive
je parse_segment_directive
cmp bx,load_directive-instruction_handler
je parse_load_directive
cmp bx,extrn_directive-instruction_handler
je parse_extrn_directive
cmp bx,public_directive-instruction_handler
je parse_public_directive
cmp bx,section_directive-instruction_handler
je parse_formatter_argument
cmp bx,format_directive-instruction_handler
je parse_formatter_argument
cmp bx,data_directive-instruction_handler
je parse_formatter_argument
jmp parse_argument
parse_formatter_argument:
or [formatter_symbols_allowed],-1
parse_argument:
lea eax,[edi+100h]
cmp eax,[labels_list]
@ -536,6 +546,8 @@ parse_line_contents:
stos byte [edi]
cmp al,80h
je forced_expression
cmp al,8Ch
je forced_expression
cmp al,81h
je forced_parenthesis
cmp al,82h
@ -577,6 +589,8 @@ parse_line_contents:
jne allow_embedded_instruction
movs byte [edi],[esi]
jmp allow_embedded_instruction
parse_segment_directive:
or [formatter_symbols_allowed],-1
parse_label_directive:
cmp byte [esi],1Ah
jne argument_parsed
@ -623,7 +637,9 @@ parse_line_contents:
inc esi
push esi ecx
push edi
or [formatter_symbols_allowed],-1
call get_symbol
mov [formatter_symbols_allowed],0
pop edi
jc parse_public_label
cmp al,1Dh
@ -787,11 +803,16 @@ parse_line_contents:
stos byte [edi]
jmp expression_parsed
forced_expression:
xor al,al
xchg al,[formatter_symbols_allowed]
push eax
mov al,'('
stos byte [edi]
call convert_expression
mov al,')'
stos byte [edi]
pop eax
mov [formatter_symbols_allowed],al
jmp argument_parsed
address_argument:
call parse_address
@ -1009,9 +1030,16 @@ get_symbol:
repe cmps byte [esi],[edi]
ja symbols_up
jb symbols_down
mov ax,[edi]
cmp al,18h
jb symbol_ok
cmp [formatter_symbols_allowed],0
je no_symbol
symbol_ok:
pop esi
add esi,ebp
mov ax,[edi]
clc
ret
no_symbol:
@ -1047,7 +1075,7 @@ get_instruction:
mov ebp,ecx
call lower_case
mov ecx,ebp
cmp cl,11
cmp cl,16
ja no_instruction
sub cl,2
jc no_instruction
@ -1157,9 +1185,13 @@ get_label_id:
ret
anonymous_back:
mov eax,[anonymous_reverse]
or eax,eax
jz new_anonymous
add esi,2
or eax,eax
jz bogus_anonymous
jmp anonymous_ok
bogus_anonymous:
call allocate_label
mov [anonymous_reverse],eax
jmp anonymous_ok
new_anonymous:
add esi,2
@ -1175,7 +1207,15 @@ get_label_id:
cmp byte [esi],'%'
je get_predefined_id
cmp byte [esi],'$'
je current_address_label
cmp byte [esi],'?'
jne find_label
cmp ecx,1
jne find_label
inc esi
mov eax,0Fh
ret
current_address_label:
cmp ecx,2
ja find_label
inc esi

View File

@ -1,6 +1,6 @@
; flat assembler core
; Copyright (c) 1999-2009, Tomasz Grysztar.
; Copyright (c) 1999-2011, Tomasz Grysztar.
; All rights reserved.
preprocessor:
@ -96,6 +96,8 @@ preprocess_file:
call preprocess_line
pop edx ebx
next_line:
cmp byte [esi-1],0
je file_end
cmp byte [esi-1],1Ah
jne preprocess_source
file_end:
@ -219,6 +221,8 @@ convert_line:
je concatenate_lines
cmp al,1Ah
je unexpected_end_of_file
or al,al
jz unexpected_end_of_file
cmp al,0Ah
je concatenate_lf
cmp al,0Dh
@ -241,6 +245,8 @@ convert_line:
backslashed_symbol:
cmp al,1Ah
je unexpected_end_of_file
or al,al
jz unexpected_end_of_file
cmp al,0Ah
je extra_characters_on_line
cmp al,0Dh
@ -283,6 +289,8 @@ convert_line:
je concatenate_lines
cmp al,1Ah
je unexpected_end_of_file
or al,al
jz unexpected_end_of_file
cmp al,0Ah
je concatenate_lf
cmp al,0Dh
@ -1594,6 +1602,7 @@ use_instant_macro:
stosb
push esi
mov esi,[esp+4]
mov [value_size],8
call calculate_expression
mov eax,[edi]
mov ecx,[edi+4]
@ -1887,6 +1896,12 @@ process_macro:
je process_macro_line
inc [counter]
process_macro_line:
lods byte [esi]
or al,al
jz process_next_line
cmp al,'}'
je macro_block_processed
dec esi
mov [current_line],edi
lea eax,[edi+10h]
cmp eax,[memory_end]

View File

@ -1,110 +1,390 @@
symbol_dump:
push edi
mov edx,[memory_end]
symb_dump:
cmp edx,[labels_list]
jbe symbols_dumped
sub edx,LABEL_STRUCTURE_SIZE
cmp dword [edx+24],0
je symb_dump ; do not dump anonymous symbols
test byte [edx+8],1
jz symb_dump ; do not dump symbols that didn't get defined
; flat assembler core
; Copyright (c) 1999-2011, Tomasz Grysztar.
; All rights reserved.
dump_symbols:
mov edi,[code_start]
call setup_dump_header
mov esi,[input_file]
call copy_asciiz
cmp edi,[display_buffer]
jae out_of_memory
mov eax,edi
sub eax,ebx
mov [ebx-38h+0Ch],eax
mov esi,[output_file]
call copy_asciiz
cmp edi,[display_buffer]
jae out_of_memory
mov edx,[symbols_stream]
mov ebp,[free_additional_memory]
mov [number_of_sections],0
cmp [output_format],4
je prepare_strings_table
cmp [output_format],5
jne strings_table_ready
bt [format_flags],0
jc strings_table_ready
prepare_strings_table:
cmp edx,ebp
je strings_table_ready
mov al,[edx]
test al,al
jz prepare_string
cmp al,80h
je prepare_string
add edx,0Ch
cmp al,0C0h
jb prepare_strings_table
add edx,4
jmp prepare_strings_table
prepare_string:
mov esi,edi
sub esi,ebx
xchg esi,[edx+4]
test al,al
jz prepare_section_string
or dword [edx+4],1 shl 31
add edx,0Ch
prepare_external_string:
mov ecx,[esi]
add esi,4
rep movs byte [edi],[esi]
mov byte [edi],0
inc edi
cmp edi,[display_buffer]
jae out_of_memory
jmp prepare_strings_table
prepare_section_string:
mov ecx,[number_of_sections]
mov eax,ecx
inc eax
mov [number_of_sections],eax
xchg eax,[edx+4]
shl ecx,2
add ecx,[free_additional_memory]
mov [ecx],eax
add edx,20h
test esi,esi
jz prepare_default_section_string
cmp [output_format],5
jne prepare_external_string
bt [format_flags],0
jc prepare_external_string
mov esi,[esi]
add esi,[resource_data]
copy_elf_section_name:
lods byte [esi]
cmp edi,[display_buffer]
jae out_of_memory
stos byte [edi]
test al,al
jnz copy_elf_section_name
jmp prepare_strings_table
prepare_default_section_string:
mov eax,'.fla'
stos dword [edi]
mov ax,'t'
stos word [edi]
cmp edi,[display_buffer]
jae out_of_memory
jmp prepare_strings_table
strings_table_ready:
mov edx,[display_buffer]
mov ebp,[memory_end]
sub ebp,[labels_list]
add ebp,edx
prepare_labels_dump:
cmp edx,ebp
je labels_dump_ok
mov eax,[edx+24]
test eax,eax
jz label_dump_name_ok
cmp eax,[memory_start]
jb label_name_outside_source
cmp eax,[source_start]
ja label_name_outside_source
sub eax,[memory_start]
dec eax
mov [edx+24],eax
jmp label_dump_name_ok
label_name_outside_source:
mov esi,eax
mov eax,edi
sub eax,ebx
or eax,1 shl 31
mov [edx+24],eax
movzx ecx,byte [esi-1]
lea eax,[edi+ecx+1]
cmp edi,[display_buffer]
jae out_of_memory
rep movsb
xor al,al
stosb
label_dump_name_ok:
mov eax,[edx+28]
test eax,eax
jz label_dump_line_ok
sub eax,[memory_start]
mov [edx+28],eax
label_dump_line_ok:
mov eax,[edx+20]
test eax,eax
jz base_symbol_for_label_ok
cmp eax,[symbols_stream]
mov eax,[eax+4]
jae base_symbol_for_label_ok
xor eax,eax
base_symbol_for_label_ok:
mov [edx+20],eax
mov ax,[current_pass]
cmp ax,[edx+16]
jne symb_dump
test byte [edx+8],4 or 2
jnz symb_dump ; do not dump assembly-time variables
; do not dump variables defined with '='
cmp word [edx+12], 0
jnz symb_dump ; do not dump register-based variables
mov al, '0'
stosb
mov al, 'x'
stosb
mov eax, [edx+4]
mov ecx, 8
@@:
rol eax, 4
test al, 0xF
loopz @b
jz .nohigh
inc ecx
@@:
push eax
and al, 0xF
cmp al, 10
sbb al, 69h
das
stosb
pop eax
rol eax, 4
loop @b
mov eax, [edx]
mov ecx, 8
jmp .low
.nohigh:
mov eax, [edx]
mov ecx, 8
@@:
rol eax, 4
test al, 0xF
loopz @b
inc ecx
.low:
push eax
and al, 0xF
cmp al, 10
sbb al, 69h
das
stosb
pop eax
rol eax, 4
loop .low
mov al, ' '
stosb
mov esi,[edx+24]
movzx ecx,byte [esi-1]
rep movsb
mov ax,0A0Dh
stosw
jmp symb_dump
symbols_dumped:
mov edx,dbgfilename
push esi edi
mov esi, outfile
mov edi, edx
@@:
lodsb
stosb
test al, al
jnz @b
lea ecx, [edi-1]
@@:
dec edi
cmp edi, edx
jb @f
cmp byte [edi], '/'
jz @f
cmp byte [edi], '.'
jnz @b
mov ecx, edi
@@:
mov dword [ecx], '.dbg'
mov byte [ecx+4], 0
pop edi esi
je label_defined_flag_ok
and byte [edx+8],not 1
label_defined_flag_ok:
cmp ax,[edx+18]
je label_used_flag_ok
and byte [edx+8],not 8
label_used_flag_ok:
add edx,LABEL_STRUCTURE_SIZE
jmp prepare_labels_dump
labels_dump_ok:
mov eax,edi
sub eax,ebx
mov [ebx-38h+14h],eax
add eax,38h
mov [ebx-38h+18h],eax
mov ecx,[memory_end]
sub ecx,[labels_list]
mov [ebx-38h+1Ch],ecx
add eax,ecx
mov [ebx-38h+20h],eax
mov ecx,[source_start]
sub ecx,[memory_start]
mov [ebx-38h+24h],ecx
add eax,ecx
mov [ebx-38h+28h],eax
mov eax,[number_of_sections]
shl eax,2
mov [ebx-38h+34h],eax
call prepare_preprocessed_source
mov esi,[labels_list]
mov ebp,edi
make_lines_dump:
cmp esi,[display_buffer]
je lines_dump_ok
mov eax,[esi-4]
mov ecx,[esi-8]
sub esi,8
sub esi,ecx
cmp eax,1
jne make_lines_dump
mov eax,[esi+4]
sub eax,[code_start]
add eax,[headers_size]
cmp byte [esi+1Ah],0
je store_offset
xor eax,eax
store_offset:
stos dword [edi]
mov eax,[esi]
sub eax,[memory_start]
stos dword [edi]
mov eax,[esi+4]
xor edx,edx
sub eax,[esi+8]
sbb edx,[esi+8+4]
stos dword [edi]
mov eax,edx
stos dword [edi]
mov eax,[esi+10h]
stos dword [edi]
mov eax,[esi+14h]
test eax,eax
jz base_symbol_for_line_ok
cmp eax,[symbols_stream]
mov eax,[eax+4]
jae base_symbol_for_line_ok
xor eax,eax
base_symbol_for_line_ok:
stos dword [edi]
mov eax,[esi+18h]
and eax,001FFFFh
stos dword [edi]
cmp edi,[display_buffer]
jae out_of_memory
jmp make_lines_dump
lines_dump_ok:
mov edx,edi
mov eax,[current_offset]
sub eax,[code_start]
add eax,[headers_size]
stos dword [edi]
mov ecx,edi
sub ecx,ebx
sub ecx,[ebx-38h+14h]
mov [ebx-38h+2Ch],ecx
add ecx,[ebx-38h+28h]
mov [ebx-38h+30h],ecx
find_inexisting_offsets:
sub edx,1Ch
cmp edx,ebp
jb write_symbols
test byte [edx+1Ah],1
jnz find_inexisting_offsets
cmp eax,[edx]
jb correct_inexisting_offset
mov eax,[edx]
jmp find_inexisting_offsets
correct_inexisting_offset:
mov dword [edx],0
or byte [edx+1Ah],2
jmp find_inexisting_offsets
write_symbols:
mov edx,[symbols_file]
call create
mov edx,[esp]
jc write_failed
mov edx,[code_start]
mov ecx,[edx+14h]
add ecx,38h
call write
jc write_failed
mov edx,[display_buffer]
mov ecx,[memory_end]
sub ecx,[labels_list]
call write
jc write_failed
mov edx,[memory_start]
mov ecx,[source_start]
sub ecx,edx
call write
jc write_failed
mov edx,ebp
mov ecx,edi
sub ecx,edx
call write
jc write_failed
mov edx,[free_additional_memory]
mov ecx,[number_of_sections]
shl ecx,2
call write
jc write_failed
call close
ret
setup_dump_header:
xor eax,eax
mov ecx,38h shr 2
rep stos dword [edi]
mov ebx,edi
mov dword [ebx-38h],'fas'+1Ah shl 24
mov dword [ebx-38h+4],VERSION_MAJOR + VERSION_MINOR shl 8 + 38h shl 16
mov dword [ebx-38h+10h],38h
ret
prepare_preprocessed_source:
mov esi,[memory_start]
mov ebp,[source_start]
test ebp,ebp
jnz prepare_preprocessed_line
mov ebp,[current_line]
inc ebp
prepare_preprocessed_line:
cmp esi,ebp
jae preprocessed_source_ok
mov eax,[memory_start]
mov edx,[input_file]
cmp [esi],edx
jne line_not_from_main_input
mov [esi],eax
line_not_from_main_input:
sub [esi],eax
test byte [esi+7],1 shl 7
jz prepare_next_preprocessed_line
sub [esi+8],eax
sub [esi+12],eax
prepare_next_preprocessed_line:
call skip_preprocessed_line
jmp prepare_preprocessed_line
preprocessed_source_ok:
ret
skip_preprocessed_line:
add esi,16
skip_preprocessed_line_content:
lods byte [esi]
cmp al,1Ah
je skip_preprocessed_symbol
cmp al,3Bh
je skip_preprocessed_symbol
cmp al,22h
je skip_preprocessed_string
or al,al
jnz skip_preprocessed_line_content
ret
skip_preprocessed_string:
lods dword [esi]
add esi,eax
jmp skip_preprocessed_line_content
skip_preprocessed_symbol:
lods byte [esi]
movzx eax,al
add esi,eax
jmp skip_preprocessed_line_content
restore_preprocessed_source:
mov esi,[memory_start]
mov ebp,[source_start]
test ebp,ebp
jnz restore_preprocessed_line
mov ebp,[current_line]
inc ebp
restore_preprocessed_line:
cmp esi,ebp
jae preprocessed_source_restored
mov eax,[memory_start]
add [esi],eax
cmp [esi],eax
jne preprocessed_line_source_restored
mov edx,[input_file]
mov [esi],edx
preprocessed_line_source_restored:
test byte [esi+7],1 shl 7
jz restore_next_preprocessed_line
add [esi+8],eax
add [esi+12],eax
restore_next_preprocessed_line:
call skip_preprocessed_line
jmp restore_preprocessed_line
preprocessed_source_restored:
ret
dump_preprocessed_source:
mov edi,[free_additional_memory]
call setup_dump_header
mov esi,[input_file]
call copy_asciiz
cmp edi,[additional_memory_end]
jae out_of_memory
mov eax,edi
sub eax,ebx
dec eax
mov [ebx-38h+0Ch],eax
mov eax,edi
sub eax,ebx
mov [ebx-38h+14h],eax
add eax,38h
mov [ebx-38h+20h],eax
call prepare_preprocessed_source
sub esi,[memory_start]
mov [ebx-38h+24h],esi
mov edx,[symbols_file]
call create
jc write_failed
mov edx,[free_additional_memory]
mov ecx,[edx+14h]
add ecx,38h
call write
jc write_failed
mov edx,[memory_start]
mov ecx,esi
call write
jc write_failed
call close
pop edi
ret

View File

@ -98,6 +98,117 @@ make_timestamp:
pop ebx
ret
symbol_dump:
push edi
mov edx,[memory_end]
symb_dump:
cmp edx,[labels_list]
jbe symbols_dumped
sub edx,LABEL_STRUCTURE_SIZE
cmp dword [edx+24],0
je symb_dump ; do not dump anonymous symbols
test byte [edx+8],1
jz symb_dump ; do not dump symbols that didn't get defined
mov ax,[current_pass]
cmp ax,[edx+16]
jne symb_dump
test byte [edx+8],4 or 2
jnz symb_dump ; do not dump assembly-time variables
; do not dump variables defined with '='
cmp word [edx+12], 0
jnz symb_dump ; do not dump register-based variables
mov al, '0'
stosb
mov al, 'x'
stosb
mov eax, [edx+4]
mov ecx, 8
@@:
rol eax, 4
test al, 0xF
loopz @b
jz .nohigh
inc ecx
@@:
push eax
and al, 0xF
cmp al, 10
sbb al, 69h
das
stosb
pop eax
rol eax, 4
loop @b
mov eax, [edx]
mov ecx, 8
jmp .low
.nohigh:
mov eax, [edx]
mov ecx, 8
@@:
rol eax, 4
test al, 0xF
loopz @b
inc ecx
.low:
push eax
and al, 0xF
cmp al, 10
sbb al, 69h
das
stosb
pop eax
rol eax, 4
loop .low
mov al, ' '
stosb
mov esi,[edx+24]
movzx ecx,byte [esi-1]
rep movsb
mov ax,0A0Dh
stosw
jmp symb_dump
symbols_dumped:
mov edx,dbgfilename
push esi edi
mov esi, outfile
mov edi, edx
@@:
lodsb
stosb
test al, al
jnz @b
lea ecx, [edi-1]
@@:
dec edi
cmp edi, edx
jb @f
cmp byte [edi], '/'
jz @f
cmp byte [edi], '.'
jnz @b
mov ecx, edi
@@:
mov dword [ecx], '.dbg'
mov byte [ecx+4], 0
pop edi esi
call create
mov edx,[esp]
mov ecx,edi
sub ecx,edx
call write
call close
pop edi
ret
get_environment_variable:
mov ecx,[memory_end]
sub ecx,edi

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
; flat assembler core variables
; Copyright (c) 1999-2009, Tomasz Grysztar.
; Copyright (c) 1999-2011, Tomasz Grysztar.
; All rights reserved.
; Variables which have to be set up by interface:
@ -86,44 +86,54 @@ image_base dd ?
image_base_high dd ?
resource_data dd ?
resource_size dd ?
actual_fixups_size dd ?
reserved_fixups dd ?
reserved_fixups_size dd ?
last_fixup_base dd ?
parenthesis_stack dd ?
blocks_stack dd ?
parsed_lines dd ?
logical_value_parentheses dd ?
file_extension dd ?
labels_type db ?
code_type db ?
virtual_data db ?
operand_size db ?
size_override db ?
operand_prefix db ?
rex_prefix db ?
opcode_prefix db ?
rex_prefix db ?
vex_required db ?
vex_register db ?
immediate_size db ?
base_code db ?
extended_code db ?
supplemental_code db ?
postbyte_register db ?
segment_register db ?
xop_opcode_map db ?
immediate_size db ?
mmx_size db ?
jump_type db ?
push_size db ?
value_size db ?
address_size db ?
size_declared db ?
value_undefined db ?
value_type db ?
fp_sign db ?
fp_format db ?
compare_type db ?
logical_value_wrapping db ?
next_pass_needed db ?
macro_status db ?
segment_register db ?
prefixed_instruction db ?
fp_sign db ?
fp_format db ?
output_format db ?
labels_type db ?
code_type db ?
virtual_data db ?
macro_status db ?
prefixed_instruction db ?
formatter_symbols_allowed db ?
characters rb 100h
converted rb 100h

View File

@ -1,6 +1,6 @@
; flat assembler version 1.68
; Copyright (c) 1999-2009, Tomasz Grysztar.
; flat assembler version 1.69
; Copyright (c) 1999-2011, 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.69.11"
VERSION_STRING equ "1.69.34"
VERSION_MAJOR = 1
VERSION_MINOR = 69

File diff suppressed because it is too large Load Diff