release 1.51

This commit is contained in:
Tomasz Grysztar 2004-01-31 12:00:00 +00:00
parent 020c1f127f
commit 26b2f09d6e
15 changed files with 1094 additions and 831 deletions

566
FASM.TXT

File diff suppressed because it is too large Load diff

View file

@ -1,6 +1,6 @@
flat assembler version 1.50
Copyright (c) 1999-2003, Tomasz Grysztar.
flat assembler version 1.51
Copyright (c) 1999-2004, Tomasz Grysztar.
All rights reserved.
This program is free for commercial and non-commercial use as long as

View file

@ -129,13 +129,11 @@ assemble_line:
cmp edi,eax
ja out_of_memory
lods byte [esi]
or al,al
jz source_end
cmp al,1
je assemble_instruction
cmp al,2
je define_label
jb source_end
cmp al,3
jb define_label
je define_constant
cmp al,0Fh
je new_line
@ -318,10 +316,10 @@ assemble_line:
assemble_instruction:
mov [operand_size],0
mov [forced_size],0
lods word [esi]
movzx ebx,ax
movzx ebx,word [esi]
mov al,[esi+2]
add ebx,assembler
lods byte [esi]
add esi,3
jmp near ebx
instruction_assembled:
mov al,[esi]
@ -626,16 +624,21 @@ load_directive:
push esi edi
mov esi,edi
sub esi,eax
jc value_out_of_range
jc bad_load_address
cmp esi,[org_start]
jb value_out_of_range
jb bad_load_address
mov edi,value
movzx ecx,[operand_size]
cmp ecx,eax
ja value_out_of_range
ja bad_load_address
rep movs byte [edi],[esi]
pop edi esi
jmp value_loaded
bad_load_address:
cmp [next_pass_needed],0
je value_out_of_range
pop edi esi
jmp value_loaded
display_directive:
push esi edi
prepare_display:

View file

@ -3,9 +3,9 @@
; Copyright (c) 1999-2003, Tomasz Grysztar.
; All rights reserved.
format MZ
heap 0
entry main:start
format MZ
heap 0
entry main:start
include 'modes.inc'
@ -13,120 +13,120 @@ segment main use16
start:
mov ax,ds
mov dx,[2Ch]
push cs cs
pop ds es
mov [psp_segment],ax
mov [environment_segment],dx
mov ax,ds
mov dx,[2Ch]
push cs cs
pop ds es
mov [psp_segment],ax
mov [environment_segment],dx
mov dx,_logo
mov ah,9
int 21h
mov dx,_logo
mov ah,9
int 21h
cld
cld
call go32
use32
call init_memory
call go32
use32
call init_memory
call get_params
cmp [params],0
je information
lea eax,[params+1]
mov [input_file],eax
movzx ecx,byte [eax-1]
add eax,ecx
cmp byte [eax],0
je information
inc eax
mov [output_file],eax
movzx ecx,byte [eax-1]
add eax,ecx
cmp byte [eax],0
jne information
call get_params
cmp [params],0
je information
lea eax,[params+1]
mov [input_file],eax
movzx ecx,byte [eax-1]
add eax,ecx
cmp byte [eax],0
je information
inc eax
mov [output_file],eax
movzx ecx,byte [eax-1]
add eax,ecx
cmp byte [eax],0
jne information
mov edi,characters
mov ecx,100h
xor al,al
mov edi,characters
mov ecx,100h
xor al,al
make_characters_table:
stosb
inc al
loop make_characters_table
mov esi,characters+'a'
mov edi,characters+'A'
mov ecx,26
rep movsb
mov edi,characters
mov esi,symbol_characters+1
movzx ecx,byte [esi-1]
xor ebx,ebx
stosb
inc al
loop make_characters_table
mov esi,characters+'a'
mov edi,characters+'A'
mov ecx,26
rep movsb
mov edi,characters
mov esi,symbol_characters+1
movzx ecx,byte [esi-1]
xor ebx,ebx
convert_table:
lodsb
mov bl,al
mov byte [edi+ebx],0
loop convert_table
mov [display_buffer],0
lodsb
mov bl,al
mov byte [edi+ebx],0
loop convert_table
mov [display_buffer],0
xor ah,ah
int 1Ah
mov ax,cx
shl eax,16
mov ax,dx
mov [start_time],eax
xor ah,ah
int 1Ah
mov ax,cx
shl eax,16
mov ax,dx
mov [start_time],eax
call preprocessor
call parser
call assembler
call formatter
call preprocessor
call parser
call assembler
call formatter
call display_user_messages
movzx eax,[current_pass]
inc eax
call display_number
mov ah,9
mov dx,_passes_suffix
call dos_int
xor ah,ah
int 1Ah
mov ax,cx
shl eax,16
mov ax,dx
sub eax,[start_time]
mov ebx,100
mul ebx
mov ebx,182
div ebx
or eax,eax
jz display_bytes_count
xor edx,edx
mov ebx,10
div ebx
push edx
call display_number
mov ah,2
mov dl,'.'
int 21h
pop eax
call display_number
mov ah,9
mov dx,_seconds_suffix
call dos_int
call display_user_messages
movzx eax,[current_pass]
inc eax
call display_number
mov ah,9
mov dx,_passes_suffix
call dos_int
xor ah,ah
int 1Ah
mov ax,cx
shl eax,16
mov ax,dx
sub eax,[start_time]
mov ebx,100
mul ebx
mov ebx,182
div ebx
or eax,eax
jz display_bytes_count
xor edx,edx
mov ebx,10
div ebx
push edx
call display_number
mov ah,2
mov dl,'.'
int 21h
pop eax
call display_number
mov ah,9
mov dx,_seconds_suffix
call dos_int
display_bytes_count:
mov eax,[written_size]
call display_number
mov ah,9
mov dx,_bytes_suffix
call dos_int
xor al,al
jmp exit_program
mov eax,[written_size]
call display_number
mov ah,9
mov dx,_bytes_suffix
call dos_int
xor al,al
jmp exit_program
information:
mov dx,_usage
mov ah,9
call dos_int
mov al,1
jmp exit_program
mov dx,_usage
mov ah,9
call dos_int
mov al,1
jmp exit_program
include 'system.inc'
@ -184,6 +184,8 @@ anonymous_reverse dd ?
anonymous_forward dd ?
labels_list dd ?
label_hash dd ?
label_leaf dd ?
hash_tree dd ?
org_origin dd ?
org_registers dd ?
org_start dd ?

View file

@ -149,14 +149,22 @@ extended_memory_ok:
mov [additional_memory],edi
mov [additional_memory_end],edi
add [additional_memory_end],ecx
cmp [memory_start],0 ; if extended memory available, done
jne memory_ok
cmp [memory_start],0
je only_conventional_memory
mov eax,[memory_end]
sub eax,[memory_start]
shr eax,3
imul eax,3
cmp eax,ecx
ja no_conventional_memory
ret
only_conventional_memory:
shr ecx,3 ; use part of conventional memory
imul ecx,3
add edi,ecx ; as a substitute for extended memory
mov [memory_start],edi
xchg [additional_memory_end],edi
mov [memory_end],edi
memory_ok:
ret
init_dpmi_memory:
@ -188,22 +196,29 @@ init_dpmi_memory:
int 31h
movzx ecx,bx
shl ecx,4
jecxz conventional_memory_unavailable
jecxz no_conventional_memory
mov ax,100h ; allocate all conventional memory
int 31h
movzx edi,ax
shl edi,4
sub edi,[program_base]
jc conventional_memory_unavailable
jc no_conventional_memory
mov [additional_memory],edi
mov [additional_memory_end],edi
add [additional_memory_end],ecx
mov eax,[memory_end]
sub eax,[memory_start]
shr eax,3
imul eax,3
cmp eax,ecx
ja no_conventional_memory
ret
conventional_memory_unavailable:
no_conventional_memory:
mov eax,[memory_end]
mov ebx,[memory_start]
sub eax,ebx
shr eax,3
imul eax,3
mov [additional_memory],ebx
add ebx,eax
mov [additional_memory_end],ebx
@ -412,7 +427,7 @@ open:
jnz next_variable
cmp byte [esi],0
jne compare_variable_names
pop esi
pop esi ds
jmp copy_path
end_of_variable_name:
cmp ah,'%'
@ -787,8 +802,8 @@ make_timestamp:
sub ebp,2
months_correction_ok:
cmp ecx,2
jbe day_correction_ok
pop cx
jbe day_correction_ok
test ecx,11b
jnz day_correction_ok
xor edx,edx

View file

@ -327,11 +327,17 @@ get_number:
cmp bl,64
jae oct_out_of_range
add bl,3
cmp cl,32
jae oct_digit_high
cmp cl,30
je oct_digit_wrap
ja oct_digit_high
shl eax,cl
or dword [edi],eax
jmp get_oct_digit
oct_digit_wrap:
shl eax,cl
adc dword [edi+4],0
or dword [edi],eax
jmp get_oct_digit
oct_digit_high:
sub cl,32
shl eax,cl
@ -455,7 +461,8 @@ get_fp_value:
movzx ecx,al
inc ecx
fp_character_ok:
loop check_fp_value
dec ecx
jnz check_fp_value
or ah,ah
jz not_fp_value
pop esi

View file

@ -3,114 +3,114 @@
; Copyright (c) 1999-2003, Tomasz Grysztar.
; All rights reserved.
format ELF executable
entry start
format ELF executable
entry start
start:
mov esi,_logo
call display_string
mov esi,_logo
call display_string
pop eax
cmp eax,3
jne information
pop eax
pop [input_file]
pop [output_file]
pop eax
pop [environment]
pop eax
cmp eax,3
jne information
pop eax
pop [input_file]
pop [output_file]
pop eax
pop [environment]
call init_memory
call init_memory
mov edi,characters
mov ecx,100h
xor al,al
mov edi,characters
mov ecx,100h
xor al,al
make_characters_table:
stosb
inc al
loop make_characters_table
mov esi,characters+'a'
mov edi,characters+'A'
mov ecx,26
rep movsb
mov edi,characters
mov esi,symbol_characters+1
movzx ecx,byte [esi-1]
xor eax,eax
stosb
inc al
loop make_characters_table
mov esi,characters+'a'
mov edi,characters+'A'
mov ecx,26
rep movsb
mov edi,characters
mov esi,symbol_characters+1
movzx ecx,byte [esi-1]
xor eax,eax
convert_table:
lodsb
mov byte [edi+eax],0
loop convert_table
mov [display_buffer],0
lodsb
mov byte [edi+eax],0
loop convert_table
mov [display_buffer],0
mov eax,78
mov ebx,buffer
xor ecx,ecx
int 0x80
mov eax,dword [buffer]
mov ecx,1000
mul ecx
mov ebx,eax
mov eax,dword [buffer+4]
div ecx
add eax,ebx
mov [start_time],eax
mov eax,78
mov ebx,buffer
xor ecx,ecx
int 0x80
mov eax,dword [buffer]
mov ecx,1000
mul ecx
mov ebx,eax
mov eax,dword [buffer+4]
div ecx
add eax,ebx
mov [start_time],eax
call preprocessor
call parser
call assembler
call formatter
call preprocessor
call parser
call assembler
call formatter
call display_user_messages
movzx eax,[current_pass]
inc eax
call display_number
mov esi,_passes_suffix
call display_string
mov eax,78
mov ebx,buffer
xor ecx,ecx
int 0x80
mov eax,dword [buffer]
mov ecx,1000
mul ecx
mov ebx,eax
mov eax,dword [buffer+4]
div ecx
add eax,ebx
sub eax,[start_time]
jnc time_ok
add eax,3600000
call display_user_messages
movzx eax,[current_pass]
inc eax
call display_number
mov esi,_passes_suffix
call display_string
mov eax,78
mov ebx,buffer
xor ecx,ecx
int 0x80
mov eax,dword [buffer]
mov ecx,1000
mul ecx
mov ebx,eax
mov eax,dword [buffer+4]
div ecx
add eax,ebx
sub eax,[start_time]
jnc time_ok
add eax,3600000
time_ok:
xor edx,edx
mov ebx,100
div ebx
or eax,eax
jz display_bytes_count
xor edx,edx
mov ebx,10
div ebx
push edx
call display_number
mov dl,'.'
call display_character
pop eax
call display_number
mov esi,_seconds_suffix
call display_string
xor edx,edx
mov ebx,100
div ebx
or eax,eax
jz display_bytes_count
xor edx,edx
mov ebx,10
div ebx
push edx
call display_number
mov dl,'.'
call display_character
pop eax
call display_number
mov esi,_seconds_suffix
call display_string
display_bytes_count:
mov eax,[written_size]
call display_number
mov esi,_bytes_suffix
call display_string
xor al,al
jmp exit_program
mov eax,[written_size]
call display_number
mov esi,_bytes_suffix
call display_string
xor al,al
jmp exit_program
information:
mov esi,_usage
call display_string
mov al,1
jmp exit_program
mov esi,_usage
call display_string
mov al,1
jmp exit_program
include 'system.inc'
@ -167,6 +167,8 @@ anonymous_reverse dd ?
anonymous_forward dd ?
labels_list dd ?
label_hash dd ?
label_leaf dd ?
hash_tree dd ?
org_origin dd ?
org_registers dd ?
org_start dd ?

View file

@ -38,12 +38,14 @@ init_memory:
allocate_memory:
mov ebx,[additional_memory]
add ebx,dword [buffer+14h]
add ebx,dword [buffer+24h]
mov eax,45
int 0x80
mov [memory_end],eax
sub eax,[additional_memory]
jz not_enough_memory
shr eax,3
imul eax,3
add eax,[additional_memory]
mov [additional_memory_end],eax
mov [memory_start],eax

View file

@ -12,6 +12,8 @@ parser:
mov [current_locals_prefix],eax
mov [anonymous_reverse],eax
mov [anonymous_forward],eax
mov [hash_tree],eax
push [additional_memory_end]
mov esi,[memory_start]
mov edi,[source_start]
parser_loop:
@ -31,6 +33,7 @@ parser:
cmp [anonymous_forward],0
jne unexpected_end_of_file
mov [code_start],edi
pop [additional_memory_end]
ret
parse_line:
@ -39,27 +42,19 @@ parse_line:
cmp byte [esi],1Ah
jne empty_instruction
push edi
inc esi
movzx ecx,byte [esi]
inc esi
add esi,2
movzx ecx,byte [esi-1]
cmp byte [esi+ecx],':'
je simple_label
push esi ecx
add esi,ecx
cmp byte [esi],1Ah
je check_for_data_label
cmp byte [esi],'='
cmp byte [esi+ecx],'='
je constant_label
pop ecx esi
jmp get_main_instruction
check_for_data_label:
inc esi
movzx ecx,byte [esi]
inc esi
push edi
cmp byte [esi+ecx],1Ah
jne get_main_instruction
push esi ecx
lea esi,[esi+ecx+2]
movzx ecx,byte [esi-1]
mov edi,data_directives
call get_symbol
pop edi
jnc data_label
pop ecx esi
get_main_instruction:
@ -82,9 +77,8 @@ parse_line:
sub esi,2
jmp parse_arguments
constant_label:
pop ecx esi
pop edi
call identify_label
call get_label_id
mov byte [edi],3
inc edi
stos dword [edi]
@ -97,6 +91,7 @@ parse_line:
pop edi
push eax esi
mov esi,ebx
movzx ecx,byte [esi-1]
call identify_label
mov byte [edi],2
inc edi
@ -136,6 +131,32 @@ parse_line:
local_label_name:
call get_label_id
ret
parse_label_directive:
cmp byte [esi],1Ah
jne argument_parsed
inc esi
movzx ecx,byte [esi]
lods byte [esi]
mov al,2
stos byte [edi]
call identify_label
stos dword [edi]
xor al,al
stos byte [edi]
jmp argument_parsed
parse_load_directive:
cmp byte [esi],1Ah
jne argument_parsed
inc esi
movzx ecx,byte [esi]
lods byte [esi]
mov al,2
stos byte [edi]
call get_label_id
stos dword [edi]
xor al,al
stos byte [edi]
jmp argument_parsed
parse_prefix_instruction:
cmp byte [esi],1Ah
jne parse_arguments
@ -144,21 +165,6 @@ parse_line:
movzx ecx,byte [esi]
inc esi
jmp get_main_instruction
parse_label_directive:
cmp byte [esi],1Ah
jne argument_parsed
push edi
inc esi
movzx ecx,byte [esi]
lods byte [esi]
pop edi
mov al,2
stos byte [edi]
call identify_label
stos dword [edi]
xor al,al
stos byte [edi]
jmp argument_parsed
parse_instruction:
pop edi
mov dl,al
@ -174,10 +180,10 @@ parse_line:
je parse_prefix_instruction
cmp bx,label_directive-assembler
je parse_label_directive
cmp bx,load_directive-assembler
je parse_label_directive
cmp bx,segment_directive-assembler
je parse_label_directive
cmp bx,load_directive-assembler
je parse_load_directive
cmp bx,extrn_directive-assembler
je parse_extrn_directive
cmp bx,public_directive-assembler
@ -722,26 +728,25 @@ get_label_id:
cmp [current_locals_prefix],0
je standard_label
push edi
mov edi,[additional_memory_end]
sub edi,2
sub edi,ecx
push ecx esi
mov edi,[free_additional_memory]
xor ax,ax
stos word [edi]
mov esi,[current_locals_prefix]
mov ebx,edi
lods byte [esi]
movzx ecx,al
lea ebp,[edi+ecx]
cmp ebp,[additional_memory_end]
jae out_of_memory
sub edi,ecx
cmp edi,[free_additional_memory]
jb out_of_memory
mov [additional_memory_end],edi
mov word [edi],0
add edi,2
mov ebx,edi
rep movs byte [edi],[esi]
pop esi ecx
add al,cl
jc name_too_long
lea ebp,[edi+ecx]
cmp ebp,[additional_memory_end]
jae out_of_memory
rep movs byte [edi],[esi]
mov [free_additional_memory],edi
pop edi
push esi
movzx ecx,al
@ -832,29 +837,82 @@ get_label_id:
sub esi,2
find_label:
xor ebx,ebx
xor ebp,ebp
mov eax,2166136261
mov ebp,16777619
hash_label:
rol ebp,12
mov eax,ebp
shr ebp,8
and eax,1111b
or ebp,eax
movzx eax,byte [esi+ebx]
add ebp,eax
xor al,[esi+ebx]
mul ebp
inc bl
cmp bl,cl
jb hash_label
and ebp,0FFFFFFh
shl ebx,24
mov ebp,eax
shl eax,8
and ebp,0FFh shl 24
xor ebp,eax
or ebp,ebx
mov [label_hash],ebp
push edi
push esi
push edi esi
push ecx
mov ecx,32
mov ebx,hash_tree
follow_tree:
mov edx,[ebx]
or edx,edx
jz extend_tree
xor eax,eax
shl ebp,1
adc eax,0
lea ebx,[edx+eax*4]
dec ecx
jnz follow_tree
mov [label_leaf],ebx
pop edx
mov eax,[ebx]
or eax,eax
jz add_label
mov ebx,esi
mov edx,ecx
mov eax,[labels_list]
mov ebp,[label_hash]
align 16
scan_hashes:
cmp ebp,[eax]
je check_label
next_label:
add eax,8
cmp eax,[memory_end]
jne scan_hashes
jmp add_label
check_label:
mov esi,ebx
mov ecx,edx
mov edi,[eax+4]
repe cmps byte [esi],[edi]
jne next_label
label_found:
add esp,4
pop edi
mov ebx,[eax+4]
make_label_id:
sub eax,[memory_end]
imul eax,3
add eax,[memory_end]
ret
extend_tree:
mov edx,[free_additional_memory]
lea eax,[edx+8]
cmp eax,[additional_memory_end]
ja out_of_memory
mov [free_additional_memory],eax
xor eax,eax
mov [edx],eax
mov [edx+4],eax
shl ebp,1
adc eax,0
mov [ebx],edx
lea ebx,[edx+eax*4]
dec ecx
jnz extend_tree
mov [label_leaf],ebx
pop edx
add_label:
mov ecx,edx
pop esi
@ -910,35 +968,13 @@ get_label_id:
pop edi
cmp eax,edi
jbe out_of_memory
mov edx,[label_leaf]
mov [edx],eax
jmp make_label_id
reserved_word:
mov eax,0Fh
pop edi
ret
align 16
scan_hashes:
cmp ebp,[eax]
je check_label
next_label:
add eax,8
cmp eax,[memory_end]
jne scan_hashes
jmp add_label
check_label:
mov esi,ebx
mov ecx,edx
mov edi,[eax+4]
repe cmps byte [esi],[edi]
jne next_label
label_found:
add esp,4
pop edi
mov ebx,[eax+4]
make_label_id:
sub eax,[memory_end]
imul eax,3
add eax,[memory_end]
ret
operators:
db 1,'+',80h

View file

@ -307,11 +307,9 @@ preprocess_line:
mov byte [edx-2],3Bh
movzx ebx,ax
add ebx,preprocessor
xor eax,eax
jmp near ebx
not_preprocessor_directive:
mov al,cl
xor ah,ah
xor ch,ch
call get_macro
jc not_macro
mov byte [edx-2],3Bh
@ -342,7 +340,8 @@ preprocess_line:
je define_equ_constant
mov al,3
not_symbolic_constant:
mov ah,1
mov ch,1
mov cl,al
call get_macro
jc not_preprocessor_symbol
mov al,3Ah
@ -418,30 +417,153 @@ preprocess_line:
pop [struc_name]
ret
get_macro:
mov edx,esi
mov ebp,edi
mov ebx,[free_additional_memory]
check_macro:
mov cl,al
cmp ebx,[macros_list]
je no_macro_found
sub ebx,8
cmp ax,[ebx]
jne check_macro
mov edi,[ebx+4]
repe cmps byte [esi],[edi]
je macro_ok
mov esi,edx
jmp check_macro
no_macro_found:
mov edi,ebp
stc
define_fix_constant:
add esi,3
push ebp esi
call process_fix_constants
mov esi,[esp+4]
movzx ecx,byte [esi-1]
mov [value_type],1
call find_symbolic_constant
jc allocate_new_fix_constant
mov ebx,edx
jmp make_fix_constant
allocate_new_fix_constant:
mov edx,[labels_list]
sub edx,16
cmp edx,[free_additional_memory]
jb out_of_memory
mov [labels_list],edx
make_fix_constant:
pop ebx
mov ecx,edi
dec ecx
sub ecx,ebx
mov [edx+8],ecx
mov [edx+12],ebx
pop ebx
mov byte [ebx-2],3Bh
mov ch,1
mov cl,[ebx-1]
push edx
call hash_constant
pop edx
mov [edx],eax
mov [edx+4],ebx
inc [fix_constants_count]
jmp line_preprocessed
define_equ_constant:
add esi,3
push esi
call process_equ_constants
pop ebx
mov edx,[labels_list]
sub edx,16
cmp edx,[free_additional_memory]
jb out_of_memory
mov [labels_list],edx
mov ecx,edi
dec ecx
sub ecx,ebx
mov [edx+8],ecx
mov [edx+12],ebx
mov ebx,[struc_name]
mov byte [ebx-2],3Bh
xor ch,ch
mov cl,[ebx-1]
push edx
call hash_constant
pop edx
mov [edx],eax
mov [edx+4],ebx
inc [equ_constants_count]
jmp line_preprocessed
hash_constant:
push esi ebp
mov esi,ebx
xor ebx,ebx
mov eax,2166136261
mov ebp,16777619
hash_constant_name:
xor al,[esi+ebx]
mul ebp
inc bl
cmp bl,cl
jb hash_constant_name
mov ebp,eax
and ebp,2FFh shl 22
shl eax,10
xor eax,ebp
or ax,cx
mov ebx,esi
pop ebp esi
ret
macro_ok:
mov edi,ebp
restore_equ_constant:
lods byte [esi]
cmp al,1Ah
jne invalid_name
movzx ecx,byte [esi]
inc esi
mov [value_type],0
call find_symbolic_constant
jc no_symbolic_constant
mov ecx,edx
sub ecx,[labels_list]
add [labels_list],16
shr ecx,2
jz constant_restored
mov ebx,esi
mov esi,edx
xchg edi,edx
add edi,16-4
sub esi,4
std
rep movs dword [edi],[esi]
cld
dec [equ_constants_count]
mov esi,ebx
mov edi,edx
jmp constant_restored
no_symbolic_constant:
add esi,ecx
constant_restored:
lods byte [esi]
cmp al,','
je restore_equ_constant
or al,al
jnz extra_characters_on_line
jmp line_preprocessed
find_symbolic_constant:
push edi
mov ebx,esi
mov ch,[value_type]
call hash_constant
movzx ecx,al
mov edx,[labels_list]
align 16
scan_symbolic_constants:
cmp edx,[additional_memory_end]
je symbolic_constants_ok
cmp eax,[edx]
je check_symbolic_constant
next_symbolic_constant:
add edx,16
jmp scan_symbolic_constants
check_symbolic_constant:
mov edi,[edx+4]
repe cmps byte [esi],[edi]
mov cl,al
je symbolic_constant_found
mov esi,ebx
jmp next_symbolic_constant
symbolic_constant_found:
pop edi
clc
ret
symbolic_constants_ok:
pop edi
stc
ret
process_fix_constants:
cmp [fix_constants_count],0
je no_symbolic_constants
@ -450,7 +572,8 @@ process_fix_constants:
process_equ_constants:
cmp [equ_constants_count],0
je no_symbolic_constants
mov [value_type],2
mov [value_type],0
align 16
process_symbolic_constants:
mov ebp,esi
lods byte [esi]
@ -474,42 +597,13 @@ process_equ_constants:
jnc replace_symbolic_constant
add esi,ecx
jmp process_symbolic_constants
find_symbolic_constant:
push edi
mov ebx,esi
mov eax,ecx
mov edx,[labels_list]
scan_symbolic_constants:
mov esi,ebx
mov ecx,eax
cmp edx,[additional_memory_end]
je symbolic_constants_ok
mov al,[value_type]
cmp al,[edx+1]
mov eax,ecx
jne next_symbolic_constant
cmp cl,[edx]
jne next_symbolic_constant
mov edi,[edx+4]
repe cmps byte [esi],[edi]
je symbolic_constant_found
next_symbolic_constant:
add edx,16
jmp scan_symbolic_constants
symbolic_constants_ok:
pop edi
stc
ret
symbolic_constant_found:
pop edi
clc
ret
replace_symbolic_constant:
mov ecx,[edx+8]
mov edx,[edx+12]
xchg esi,edx
call move_data
mov esi,edx
align 16
process_after_replaced:
lods byte [esi]
cmp al,1Ah
@ -525,22 +619,21 @@ process_equ_constants:
call move_data
ret
move_data:
xor eax,eax
shr ecx,1
rcl al,1
jnc movsb_ok
movs byte [edi],[esi]
movsb_ok:
shr ecx,1
rcl ah,1
jnc movsw_ok
movs word [edi],[esi]
movsw_ok:
rep movs dword [edi],[esi]
mov cl,ah
rep movs word [edi],[esi]
mov cl,al
rep movs byte [edi],[esi]
ret
string_after_replaced:
lods dword [esi]
stos dword [edi]
mov ecx,eax
rep movs byte [edi],[esi]
call move_data
jmp process_after_replaced
symbol_after_replaced:
movzx ecx,byte [esi]
@ -550,7 +643,7 @@ process_equ_constants:
mov al,1Ah
mov ah,cl
stos word [edi]
rep movs byte [edi],[esi]
call move_data
jmp process_after_replaced
process_concatenations:
xor dl,dl
@ -700,117 +793,64 @@ process_concatenations:
mov ecx,eax
rep movs byte [edi],[esi]
jmp after_concatenation
include_file:
lods byte [esi]
cmp al,22h
jne invalid_argument
lods dword [esi]
get_macro:
call hash_macro
mov edx,esi
add esi,eax
cmp byte [esi],0
jne extra_characters_on_line
call preprocess_file
jc file_not_found
jmp line_preprocessed
define_fix_constant:
add esi,3
push ebp esi
call process_fix_constants
mov esi,[esp+4]
movzx ecx,byte [esi-1]
mov [value_type],1
call find_symbolic_constant
jc allocate_new_fix_constant
mov ebx,edx
jmp make_fix_constant
allocate_new_fix_constant:
mov edx,[labels_list]
sub edx,16
cmp edx,[free_additional_memory]
jb out_of_memory
mov [labels_list],edx
make_fix_constant:
pop ebx
mov ecx,edi
dec ecx
sub ecx,ebx
mov [edx+8],ecx
mov [edx+12],ebx
pop ebx
mov byte [ebx-2],3Bh
mov al,[ebx-1]
mov [edx],al
mov [edx+4],ebx
mov byte [edx+1],1
inc [fix_constants_count]
jmp line_preprocessed
define_equ_constant:
add esi,3
push esi
call process_equ_constants
pop ebx
mov edx,[labels_list]
sub edx,16
cmp edx,[free_additional_memory]
jb out_of_memory
mov [labels_list],edx
mov ecx,edi
dec ecx
sub ecx,ebx
mov [edx+8],ecx
mov [edx+12],ebx
mov ebx,[struc_name]
mov byte [ebx-2],3Bh
mov al,[ebx-1]
mov [edx],al
mov [edx+4],ebx
mov byte [edx+1],2
inc [equ_constants_count]
jmp line_preprocessed
restore_equ_constant:
lods byte [esi]
cmp al,1Ah
jne invalid_name
movzx ecx,byte [esi]
inc esi
mov [value_type],2
call find_symbolic_constant
jc no_symbolic_constant
mov ecx,edx
sub ecx,[labels_list]
add [labels_list],16
shr ecx,2
jz constant_restored
mov ebx,esi
mov esi,edx
xchg edi,edx
add edi,16-4
sub esi,4
std
rep movs dword [edi],[esi]
cld
dec [equ_constants_count]
mov esi,ebx
mov edi,edx
jmp constant_restored
no_symbolic_constant:
add esi,ecx
constant_restored:
lods byte [esi]
cmp al,','
je restore_equ_constant
or al,al
jnz extra_characters_on_line
jmp line_preprocessed
define_struc:
or ah,1
define_macro:
lods byte [esi]
cmp al,1Ah
jne invalid_name
lods byte [esi]
mov ebp,edi
mov ebx,[free_additional_memory]
mov [ebx],ax
movzx ecx,cl
align 16
check_macro:
cmp ebx,[macros_list]
je no_macro_found
sub ebx,8
cmp eax,[ebx]
jne check_macro
mov edi,[ebx+4]
repe cmps byte [esi],[edi]
mov cl,al
je macro_ok
mov esi,edx
jmp check_macro
macro_ok:
mov edi,ebp
clc
ret
no_macro_found:
mov edi,ebp
stc
ret
hash_macro:
xor ebx,ebx
mov eax,2166136261
mov ebp,16777619
hash_macro_name:
xor al,[esi+ebx]
mul ebp
inc bl
cmp bl,cl
jb hash_macro_name
mov ebp,eax
and ebp,2FFh shl 22
shl eax,10
xor eax,ebp
or ax,cx
ret
define_struc:
mov ch,1
jmp make_macro
define_macro:
xor ch,ch
make_macro:
lods byte [esi]
cmp al,1Ah
jne invalid_name
lods byte [esi]
mov cl,al
call hash_macro
mov ebx,[free_additional_memory]
mov [ebx],eax
mov [ebx+4],esi
add ebx,8
cmp ebx,[labels_list]
@ -907,10 +947,11 @@ purge_macro:
cmp al,1Ah
jne invalid_name
lods byte [esi]
xor ah,ah
xor ch,ch
mov cl,al
call get_macro
jc macro_purged
or byte [ebx+1],80h
or byte [ebx+1],2
macro_purged:
lods byte [esi]
cmp al,','
@ -923,7 +964,7 @@ use_macro:
push [counter] [counter_limit]
push dword [macro_status]
or [macro_status],10h
or byte [ebx+1],80h
or byte [ebx+1],2
mov edx,esi
mov eax,[ebx+4]
movzx esi,byte [ebx]
@ -1094,6 +1135,7 @@ use_macro:
jz process_macro
mov ax,3Bh
stos word [edi]
align 16
process_macro:
lods byte [esi]
cmp al,'}'
@ -1357,7 +1399,7 @@ use_macro:
macro_block_processed:
call close_macro_block
jc process_macro_line
and byte [ebx+1],not 80h
and byte [ebx+1],not 2
pop [current_line]
mov eax,[macro_constants]
mov [memory_end],eax
@ -1414,6 +1456,19 @@ use_macro:
pop edi
jmp line_preprocessed
include_file:
lods byte [esi]
cmp al,22h
jne invalid_argument
lods dword [esi]
mov edx,esi
add esi,eax
cmp byte [esi],0
jne extra_characters_on_line
call preprocess_file
jc file_not_found
jmp line_preprocessed
increase_counter:
movzx ecx,byte [eax]
counter_loop:

View file

@ -1,6 +1,6 @@
; flat assembler version 1.50
; Copyright (c) 1999-2003, Tomasz Grysztar.
; flat assembler version 1.51
; Copyright (c) 1999-2004, 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.50"
VERSION_STRING equ "1.51"
VERSION_MAJOR = 1
VERSION_MINOR = 50
VERSION_MINOR = 51

View file

@ -3,97 +3,97 @@
; Copyright (c) 1999-2003, Tomasz Grysztar.
; All rights reserved.
format PE console
format PE console
start:
mov esi,_logo
call display_string
mov esi,_logo
call display_string
call get_params
cmp [params],0
je information
lea eax,[params+1]
mov [input_file],eax
movzx ecx,byte [eax-1]
add eax,ecx
cmp byte [eax],0
je information
inc eax
mov [output_file],eax
movzx ecx,byte [eax-1]
add eax,ecx
cmp byte [eax],0
jne information
call get_params
cmp [params],0
je information
lea eax,[params+1]
mov [input_file],eax
movzx ecx,byte [eax-1]
add eax,ecx
cmp byte [eax],0
je information
inc eax
mov [output_file],eax
movzx ecx,byte [eax-1]
add eax,ecx
cmp byte [eax],0
jne information
call init_memory
call init_memory
mov edi,characters
mov ecx,100h
xor al,al
mov edi,characters
mov ecx,100h
xor al,al
make_characters_table:
stosb
inc al
loop make_characters_table
mov esi,characters+'a'
mov edi,characters+'A'
mov ecx,26
rep movsb
mov edi,characters
mov esi,symbol_characters+1
movzx ecx,byte [esi-1]
xor eax,eax
stosb
inc al
loop make_characters_table
mov esi,characters+'a'
mov edi,characters+'A'
mov ecx,26
rep movsb
mov edi,characters
mov esi,symbol_characters+1
movzx ecx,byte [esi-1]
xor eax,eax
convert_table:
lodsb
mov byte [edi+eax],0
loop convert_table
mov [display_buffer],0
lodsb
mov byte [edi+eax],0
loop convert_table
mov [display_buffer],0
call [GetTickCount]
mov [start_time],eax
call [GetTickCount]
mov [start_time],eax
call preprocessor
call parser
call assembler
call formatter
call preprocessor
call parser
call assembler
call formatter
call display_user_messages
movzx eax,[current_pass]
inc eax
call display_number
mov esi,_passes_suffix
call display_string
call [GetTickCount]
sub eax,[start_time]
xor edx,edx
mov ebx,100
div ebx
or eax,eax
jz display_bytes_count
xor edx,edx
mov ebx,10
div ebx
push edx
call display_number
mov dl,'.'
call display_character
pop eax
call display_number
mov esi,_seconds_suffix
call display_string
call display_user_messages
movzx eax,[current_pass]
inc eax
call display_number
mov esi,_passes_suffix
call display_string
call [GetTickCount]
sub eax,[start_time]
xor edx,edx
mov ebx,100
div ebx
or eax,eax
jz display_bytes_count
xor edx,edx
mov ebx,10
div ebx
push edx
call display_number
mov dl,'.'
call display_character
pop eax
call display_number
mov esi,_seconds_suffix
call display_string
display_bytes_count:
mov eax,[written_size]
call display_number
mov esi,_bytes_suffix
call display_string
xor al,al
jmp exit_program
mov eax,[written_size]
call display_number
mov esi,_bytes_suffix
call display_string
xor al,al
jmp exit_program
information:
mov esi,_usage
call display_string
mov al,1
jmp exit_program
mov esi,_usage
call display_string
mov al,1
jmp exit_program
include 'system.inc'
@ -149,6 +149,8 @@ anonymous_forward dd ?
current_locals_prefix dd ?
labels_list dd ?
label_hash dd ?
label_leaf dd ?
hash_tree dd ?
org_origin dd ?
org_registers dd ?
org_start dd ?

View file

@ -49,6 +49,7 @@ init_memory:
allocate_memory:
mov edx,eax
shr edx,3
imul edx,3
mov ecx,eax
sub ecx,edx
mov [memory_end],ecx

View file

@ -4436,8 +4436,9 @@ fild_instruction:
jmp instruction_assembled
fild_mem_64bit:
mov al,[postbyte_register]
cmp al,0
je fild_mem_64bit_store
cmp al,1
je fisttp_64bit_store
jb fild_mem_64bit_store
dec [postbyte_register]
cmp al,3
je fild_mem_64bit_store
@ -4447,6 +4448,11 @@ fild_instruction:
mov [base_code],0DFh
call store_instruction
jmp instruction_assembled
fisttp_64bit_store:
mov [base_code],0DDh
call store_instruction
jmp instruction_assembled
fbld_instruction:
mov [postbyte_register],al
lods byte [esi]
@ -4902,6 +4908,31 @@ movdq_instruction:
mov al,bl
stos byte [edi]
jmp instruction_assembled
lddqu_instruction:
lods byte [esi]
call get_size_operator
cmp al,10h
jne invalid_operand
lods byte [esi]
call convert_mmx_register
cmp ah,16
jne invalid_operand_size
push eax
lods byte [esi]
cmp al,','
jne invalid_operand
lods byte [esi]
call get_size_operator
cmp al,'['
jne invalid_operand
call get_address
pop eax
mov [postbyte_register],al
mov [mmx_prefix],0F2h
mov [base_code],0Fh
mov [extended_code],0F0h
call store_mmx_instruction
jmp instruction_assembled
movq2dq_instruction:
lods byte [esi]
call get_size_operator
@ -5886,6 +5917,46 @@ movnti_instruction:
mov [postbyte_register],al
call store_instruction
jmp instruction_assembled
monitor_instruction:
mov [postbyte_register],al
lods byte [esi]
call get_size_operator
cmp al,10h
jne invalid_operand
lods byte [esi]
call convert_register
cmp ax,0400h
jne invalid_operand
lods byte [esi]
cmp al,','
jne invalid_operand
lods byte [esi]
call get_size_operator
cmp al,10h
jne invalid_operand
lods byte [esi]
call convert_register
cmp ax,0401h
jne invalid_operand
cmp [postbyte_register],0C8h
jne monitor_instruction_store
lods byte [esi]
cmp al,','
jne invalid_operand
lods byte [esi]
call get_size_operator
cmp al,10h
jne invalid_operand
lods byte [esi]
call convert_register
cmp ax,0402h
jne invalid_operand
monitor_instruction_store:
mov ax,010Fh
stos word [edi]
mov al,[postbyte_register]
stos byte [edi]
jmp instruction_assembled
convert_register:
mov ah,al
@ -7030,6 +7101,8 @@ instructions_5:
dw loop_instruction_32bit-assembler
db 'label',0
dw label_directive-assembler
db 'lddqu',0
dw lddqu_instruction-assembler
db 'leave',0C9h
dw simple_instruction-assembler
db 'lodsb',0ACh
@ -7082,6 +7155,8 @@ instructions_5:
dw sse_sd_instruction-assembler
db 'mulss',59h
dw sse_ss_instruction-assembler
db 'mwait',0C9h
dw monitor_instruction-assembler
db 'outsb',6Eh
dw simple_instruction-assembler
db 'outsd',6Fh
@ -7312,6 +7387,8 @@ instructions_6:
dw fi_instruction-assembler
db 'fidivr',7
dw fi_instruction-assembler
db 'fisttp',1
dw fild_instruction-assembler
db 'fisubr',5
dw fi_instruction-assembler
db 'fldenv',4
@ -7360,6 +7437,14 @@ instructions_6:
dw ffree_instruction-assembler
db 'fxsave',0
dw fxsave_instruction-assembler
db 'haddpd',07Ch
dw sse_pd_instruction-assembler
db 'haddps',07Ch
dw cvtpd2dq_instruction-assembler
db 'hsubpd',07Dh
dw sse_pd_instruction-assembler
db 'hsubps',07Dh
dw cvtpd2dq_instruction-assembler
db 'invlpg',0
dw invlpg_instruction-assembler
db 'lfence',0E8h
@ -7558,6 +7643,10 @@ instructions_7:
dw loop_instruction_32bit-assembler
db 'loopnzw',0E0h
dw loop_instruction_16bit-assembler
db 'monitor',0C8h
dw monitor_instruction-assembler
db 'movddup',12h
dw sse_sd_instruction-assembler
db 'movdq2q',0
dw movdq2q_instruction-assembler
db 'movhlps',12h
@ -7636,6 +7725,10 @@ instructions_7:
dw virtual_directive-assembler
db 0
instructions_8:
db 'addsubpd',0D0h
dw sse_pd_instruction-assembler
db 'addsubps',0D0h
dw cvtpd2dq_instruction-assembler
db 'cmpneqpd',4
dw cmp_pd_instruction-assembler
db 'cmpneqps',4
@ -7708,6 +7801,10 @@ instructions_8:
dw movmskpd_instruction-assembler
db 'movmskps',0
dw movmskps_instruction-assembler
db 'movshdup',16h
dw cvtdq2pd_instruction-assembler
db 'movsldup',12h
dw cvtdq2pd_instruction-assembler
db 'packssdw',6Bh
dw mmx_instruction-assembler
db 'packsswb',63h

View file

@ -1,6 +1,13 @@
Visit http://flatassembler.net/ for more information
version 1.51
[31-01-2004]
------------
[+] added SSE3 instructions
[-] speed improvements
[-] few more bugs fixed
version 1.50
[08-12-2003]
------------