forked from KolibriOS/kolibrios
fasm:
change to common line endings (unix) to make and apply patches in more convenient way add license.txt remove local copy of struct.inc which wasn't used git-svn-id: svn://kolibrios.org@3011 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
+1112
-1112
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
+1194
-1194
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,37 @@
|
||||
|
||||
flat assembler version 1.70
|
||||
Copyright (c) 1999-2012, Tomasz Grysztar.
|
||||
All rights reserved.
|
||||
|
||||
This program is free for commercial and non-commercial use as long as
|
||||
the following conditions are adhered to.
|
||||
|
||||
Copyright remains Tomasz Grysztar, and as such any Copyright notices
|
||||
in the code are not to be removed.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
The licence and distribution terms for any publically available
|
||||
version or derivative of this code cannot be changed. i.e. this code
|
||||
cannot simply be copied and put under another distribution licence
|
||||
(including the GNU Public Licence).
|
||||
@@ -4,24 +4,24 @@
|
||||
; 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
|
||||
_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
|
||||
@@ -29,24 +29,24 @@ _disallowed_combination_of_registers 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
|
||||
_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
|
||||
_invoked_error db 'error directive invoked in source file',0
|
||||
_invoked_error db 'error directive encountered in source file',0
|
||||
_assertion_failed db 'assertion failed',0
|
||||
@@ -1,180 +0,0 @@
|
||||
|
||||
; Macroinstructions for defining data structures
|
||||
|
||||
macro struct name
|
||||
{ fields@struct equ name
|
||||
match child parent, name \{ fields@struct equ child,fields@\#parent \}
|
||||
sub@struct equ
|
||||
struc db [val] \{ \common fields@struct equ fields@struct,.,db,<val> \}
|
||||
struc dw [val] \{ \common fields@struct equ fields@struct,.,dw,<val> \}
|
||||
struc du [val] \{ \common fields@struct equ fields@struct,.,du,<val> \}
|
||||
struc dd [val] \{ \common fields@struct equ fields@struct,.,dd,<val> \}
|
||||
struc dp [val] \{ \common fields@struct equ fields@struct,.,dp,<val> \}
|
||||
struc dq [val] \{ \common fields@struct equ fields@struct,.,dq,<val> \}
|
||||
struc dt [val] \{ \common fields@struct equ fields@struct,.,dt,<val> \}
|
||||
struc rb count \{ fields@struct equ fields@struct,.,db,count dup (?) \}
|
||||
struc rw count \{ fields@struct equ fields@struct,.,dw,count dup (?) \}
|
||||
struc rd count \{ fields@struct equ fields@struct,.,dd,count dup (?) \}
|
||||
struc rp count \{ fields@struct equ fields@struct,.,dp,count dup (?) \}
|
||||
struc rq count \{ fields@struct equ fields@struct,.,dq,count dup (?) \}
|
||||
struc rt count \{ fields@struct equ fields@struct,.,dt,count dup (?) \}
|
||||
macro db [val] \{ \common \local anonymous
|
||||
fields@struct equ fields@struct,anonymous,db,<val> \}
|
||||
macro dw [val] \{ \common \local anonymous
|
||||
fields@struct equ fields@struct,anonymous,dw,<val> \}
|
||||
macro du [val] \{ \common \local anonymous
|
||||
fields@struct equ fields@struct,anonymous,du,<val> \}
|
||||
macro dd [val] \{ \common \local anonymous
|
||||
fields@struct equ fields@struct,anonymous,dd,<val> \}
|
||||
macro dp [val] \{ \common \local anonymous
|
||||
fields@struct equ fields@struct,anonymous,dp,<val> \}
|
||||
macro dq [val] \{ \common \local anonymous
|
||||
fields@struct equ fields@struct,anonymous,dq,<val> \}
|
||||
macro dt [val] \{ \common \local anonymous
|
||||
fields@struct equ fields@struct,anonymous,dt,<val> \}
|
||||
macro rb count \{ \local anonymous
|
||||
fields@struct equ fields@struct,anonymous,db,count dup (?) \}
|
||||
macro rw count \{ \local anonymous
|
||||
fields@struct equ fields@struct,anonymous,dw,count dup (?) \}
|
||||
macro rd count \{ \local anonymous
|
||||
fields@struct equ fields@struct,anonymous,dd,count dup (?) \}
|
||||
macro rp count \{ \local anonymous
|
||||
fields@struct equ fields@struct,anonymous,dp,count dup (?) \}
|
||||
macro rq count \{ \local anonymous
|
||||
fields@struct equ fields@struct,anonymous,dq,count dup (?) \}
|
||||
macro rt count \{ \local anonymous
|
||||
fields@struct equ fields@struct,anonymous,dt,count dup (?) \}
|
||||
macro union \{ fields@struct equ fields@struct,,union,<
|
||||
sub@struct equ union \}
|
||||
macro struct \{ fields@struct equ fields@struct,,substruct,<
|
||||
sub@struct equ substruct \}
|
||||
virtual at 0 }
|
||||
|
||||
macro ends
|
||||
{ match , sub@struct \{ restruc db,dw,du,dd,dp,dq,dt
|
||||
restruc rb,rw,rd,rp,rq,rt
|
||||
purge db,dw,du,dd,dp,dq,dt
|
||||
purge rb,rw,rd,rp,rq,rt
|
||||
purge union,struct
|
||||
match name=,fields,fields@struct \\{ fields@struct equ
|
||||
make@struct name,fields
|
||||
fields@\\#name equ fields \\}
|
||||
end virtual \}
|
||||
match any, sub@struct \{ fields@struct equ fields@struct> \}
|
||||
restore sub@struct }
|
||||
|
||||
macro make@struct name,[field,type,def]
|
||||
{ common
|
||||
if $
|
||||
display 'Error: definition of ',`name,' contains illegal instructions.',0Dh,0Ah
|
||||
err
|
||||
end if
|
||||
local define
|
||||
define equ name
|
||||
forward
|
||||
local sub
|
||||
match , field \{ make@substruct type,name,sub def
|
||||
define equ define,.,sub, \}
|
||||
match any, field \{ define equ define,.#field,type,<def> \}
|
||||
common
|
||||
match fields, define \{ define@struct fields \} }
|
||||
|
||||
macro define@struct name,[field,type,def]
|
||||
{ common
|
||||
local list
|
||||
list equ
|
||||
forward
|
||||
if ~ field eq .
|
||||
name#field type def
|
||||
sizeof.#name#field = $ - name#field
|
||||
else
|
||||
rb sizeof.#type
|
||||
end if
|
||||
local value
|
||||
match any, list \{ list equ list, \}
|
||||
list equ list <value>
|
||||
common
|
||||
sizeof.#name = $
|
||||
restruc name
|
||||
match values, list \{
|
||||
struc name value \\{
|
||||
match any, fields@struct \\\{ fields@struct equ fields@struct,.,name,<values> \\\}
|
||||
match , fields@struct \\\{ label .
|
||||
forward
|
||||
match , value \\\\{ field type def \\\\}
|
||||
match any, value \\\\{ field type value
|
||||
if ~ field eq .
|
||||
rb sizeof.#name#field - ($-field)
|
||||
end if \\\\}
|
||||
common \\\} \\} \} }
|
||||
|
||||
macro enable@substruct
|
||||
{ macro make@substruct substruct,parent,name,[field,type,def]
|
||||
\{ \common
|
||||
\local define
|
||||
define equ parent,name
|
||||
\forward
|
||||
\local sub
|
||||
match , field \\{ match any, type \\\{ enable@substruct
|
||||
make@substruct type,name,sub def
|
||||
purge make@substruct
|
||||
define equ define,.,sub, \\\} \\}
|
||||
match any, field \\{ define equ define,.\#field,type,<def> \\}
|
||||
\common
|
||||
match fields, define \\{ define@\#substruct fields \\} \} }
|
||||
|
||||
enable@substruct
|
||||
|
||||
macro define@union parent,name,[field,type,def]
|
||||
{ common
|
||||
virtual at 0
|
||||
forward
|
||||
if ~ field eq .
|
||||
virtual at 0
|
||||
parent#field type def
|
||||
sizeof.#parent#field = $ - parent#field
|
||||
end virtual
|
||||
if sizeof.#parent#field > $
|
||||
rb sizeof.#parent#field - $
|
||||
end if
|
||||
else if sizeof.#type > $
|
||||
rb sizeof.#type - $
|
||||
end if
|
||||
common
|
||||
sizeof.#name = $
|
||||
end virtual
|
||||
struc name [value] \{ \common
|
||||
label .\#name
|
||||
last@union equ
|
||||
forward
|
||||
match any, last@union \\{ virtual at .\#name
|
||||
field type def
|
||||
end virtual \\}
|
||||
match , last@union \\{ match , value \\\{ field type def \\\}
|
||||
match any, value \\\{ field type value \\\} \\}
|
||||
last@union equ field
|
||||
common rb sizeof.#name - ($ - .\#name) \} }
|
||||
|
||||
macro define@substruct parent,name,[field,type,def]
|
||||
{ common
|
||||
virtual at 0
|
||||
forward
|
||||
if ~ field eq .
|
||||
parent#field type def
|
||||
sizeof.#parent#field = $ - parent#field
|
||||
else
|
||||
rb sizeof.#type
|
||||
end if
|
||||
local value
|
||||
common
|
||||
sizeof.#name = $
|
||||
end virtual
|
||||
struc name value \{
|
||||
label .\#name
|
||||
forward
|
||||
match , value \\{ field type def \\}
|
||||
match any, value \\{ field type value
|
||||
if ~ field eq .
|
||||
rb sizeof.#parent#field - ($-field)
|
||||
end if \\}
|
||||
common \} }
|
||||
@@ -4,11 +4,11 @@
|
||||
; All rights reserved.
|
||||
|
||||
dump_symbols:
|
||||
mov edi,[code_start]
|
||||
call setup_dump_header
|
||||
mov esi,[input_file]
|
||||
call copy_asciiz
|
||||
cmp edi,[display_buffer]
|
||||
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
|
||||
@@ -23,132 +23,132 @@ dump_symbols:
|
||||
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]
|
||||
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
|
||||
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]
|
||||
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
|
||||
@@ -171,11 +171,11 @@ dump_symbols:
|
||||
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]
|
||||
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
|
||||
@@ -188,13 +188,13 @@ dump_symbols:
|
||||
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]
|
||||
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
|
||||
@@ -205,15 +205,15 @@ dump_symbols:
|
||||
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
|
||||
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]
|
||||
@@ -229,9 +229,9 @@ dump_symbols:
|
||||
jmp make_lines_dump
|
||||
lines_dump_ok:
|
||||
mov edx,edi
|
||||
mov eax,[current_offset]
|
||||
sub eax,[code_start]
|
||||
add eax,[headers_size]
|
||||
mov eax,[current_offset]
|
||||
sub eax,[code_start]
|
||||
add eax,[headers_size]
|
||||
stos dword [edi]
|
||||
mov ecx,edi
|
||||
sub ecx,ebx
|
||||
@@ -244,11 +244,11 @@ dump_symbols:
|
||||
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
|
||||
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:
|
||||
@@ -256,8 +256,8 @@ dump_symbols:
|
||||
or byte [edx+1Ah],2
|
||||
jmp find_inexisting_offsets
|
||||
write_symbols:
|
||||
mov edx,[symbols_file]
|
||||
call create
|
||||
mov edx,[symbols_file]
|
||||
call create
|
||||
jc write_failed
|
||||
mov edx,[code_start]
|
||||
mov ecx,[edx+14h]
|
||||
@@ -265,22 +265,22 @@ dump_symbols:
|
||||
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]
|
||||
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
|
||||
@@ -328,85 +328,85 @@ dump_symbols:
|
||||
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 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
|
||||
@@ -428,8 +428,8 @@ dump_preprocessed_source:
|
||||
call write
|
||||
jc write_failed
|
||||
mov edx,[memory_start]
|
||||
mov ecx,esi
|
||||
call write
|
||||
jc write_failed
|
||||
call close
|
||||
mov ecx,esi
|
||||
call write
|
||||
jc write_failed
|
||||
call close
|
||||
ret
|
||||
+2701
-2701
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user