forked from KolibriOS/kolibrios
fasm: update to 1.71.54
git-svn-id: svn://kolibrios.org@6467 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
3e57c7257b
commit
25b23034ea
@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
; flat assembler core
|
; flat assembler core
|
||||||
; Copyright (c) 1999-2013, Tomasz Grysztar.
|
; Copyright (c) 1999-2016, Tomasz Grysztar.
|
||||||
; All rights reserved.
|
; All rights reserved.
|
||||||
|
|
||||||
assembler:
|
assembler:
|
||||||
@ -32,6 +32,7 @@ assembler:
|
|||||||
mov [next_pass_needed],al
|
mov [next_pass_needed],al
|
||||||
mov [output_format],al
|
mov [output_format],al
|
||||||
mov [adjustment_sign],al
|
mov [adjustment_sign],al
|
||||||
|
mov [evex_mode],al
|
||||||
mov [code_type],16
|
mov [code_type],16
|
||||||
call init_addressing_space
|
call init_addressing_space
|
||||||
pass_loop:
|
pass_loop:
|
||||||
@ -192,7 +193,7 @@ assemble_line:
|
|||||||
new_line:
|
new_line:
|
||||||
lods dword [esi]
|
lods dword [esi]
|
||||||
mov [current_line],eax
|
mov [current_line],eax
|
||||||
mov [prefixed_instruction],0
|
and [prefix_flags],0
|
||||||
cmp [symbols_file],0
|
cmp [symbols_file],0
|
||||||
je continue_line
|
je continue_line
|
||||||
cmp [next_pass_needed],0
|
cmp [next_pass_needed],0
|
||||||
@ -329,31 +330,10 @@ assemble_line:
|
|||||||
cmp eax,0Fh
|
cmp eax,0Fh
|
||||||
jb invalid_use_of_symbol
|
jb invalid_use_of_symbol
|
||||||
je reserved_word_used_as_symbol
|
je reserved_word_used_as_symbol
|
||||||
mov edx,[eax+8]
|
|
||||||
push edx
|
|
||||||
cmp [current_pass],0
|
|
||||||
je get_constant_value
|
|
||||||
test dl,4
|
|
||||||
jnz get_constant_value
|
|
||||||
mov cx,[current_pass]
|
|
||||||
cmp cx,[eax+16]
|
|
||||||
je get_constant_value
|
|
||||||
or dl,4
|
|
||||||
mov [eax+8],dl
|
|
||||||
get_constant_value:
|
|
||||||
push eax
|
push eax
|
||||||
mov al,byte [esi-1]
|
or [operand_flags],1
|
||||||
push eax
|
|
||||||
or [size_override],-1
|
|
||||||
call get_value
|
call get_value
|
||||||
pop ebx
|
pop ebx
|
||||||
mov ch,bl
|
|
||||||
pop ebx
|
|
||||||
pop ecx
|
|
||||||
test cl,4
|
|
||||||
jnz constant_referencing_mode_ok
|
|
||||||
and byte [ebx+8],not 4
|
|
||||||
constant_referencing_mode_ok:
|
|
||||||
xor cl,cl
|
xor cl,cl
|
||||||
mov ch,[value_type]
|
mov ch,[value_type]
|
||||||
cmp ch,3
|
cmp ch,3
|
||||||
@ -453,16 +433,16 @@ assemble_line:
|
|||||||
or byte [ebx+0Ah],2
|
or byte [ebx+0Ah],2
|
||||||
jmp continue_line
|
jmp continue_line
|
||||||
assemble_instruction:
|
assemble_instruction:
|
||||||
; mov [operand_size],0
|
; mov [operand_size],0
|
||||||
; mov [size_override],0
|
; mov [operand_flags],0
|
||||||
; mov [operand_prefix],0
|
; mov [operand_prefix],0
|
||||||
; mov [opcode_prefix],0
|
; mov [rex_prefix],0
|
||||||
and dword [operand_size],0
|
and dword [operand_size],0
|
||||||
; mov [rex_prefix],0
|
; mov [opcode_prefix],0
|
||||||
; mov [vex_required],0
|
; mov [vex_required],0
|
||||||
; mov [vex_register],0
|
; mov [vex_register],0
|
||||||
; mov [immediate_size],0
|
; mov [immediate_size],0
|
||||||
and dword [rex_prefix],0
|
and dword [opcode_prefix],0
|
||||||
call instruction_handler
|
call instruction_handler
|
||||||
instruction_handler:
|
instruction_handler:
|
||||||
movzx ebx,word [esi]
|
movzx ebx,word [esi]
|
||||||
@ -471,6 +451,8 @@ assemble_line:
|
|||||||
add [esp],ebx
|
add [esp],ebx
|
||||||
ret
|
ret
|
||||||
instruction_assembled:
|
instruction_assembled:
|
||||||
|
test [prefix_flags],not 1
|
||||||
|
jnz illegal_instruction
|
||||||
mov al,[esi]
|
mov al,[esi]
|
||||||
cmp al,0Fh
|
cmp al,0Fh
|
||||||
je line_assembled
|
je line_assembled
|
||||||
@ -671,7 +653,7 @@ load_directive:
|
|||||||
push ebx
|
push ebx
|
||||||
cmp byte [esi],'.'
|
cmp byte [esi],'.'
|
||||||
je invalid_value
|
je invalid_value
|
||||||
or [size_override],-1
|
or [operand_flags],1
|
||||||
call get_address_value
|
call get_address_value
|
||||||
pop ebp
|
pop ebp
|
||||||
call calculate_relative_offset
|
call calculate_relative_offset
|
||||||
@ -718,7 +700,7 @@ store_directive:
|
|||||||
mov [operand_size],1
|
mov [operand_size],1
|
||||||
jmp store_value_ok
|
jmp store_value_ok
|
||||||
sized_store:
|
sized_store:
|
||||||
or [size_override],-1
|
or [operand_flags],1
|
||||||
call get_value
|
call get_value
|
||||||
store_value_ok:
|
store_value_ok:
|
||||||
cmp [value_type],0
|
cmp [value_type],0
|
||||||
@ -833,7 +815,7 @@ times_directive:
|
|||||||
cmp eax,[stack_limit]
|
cmp eax,[stack_limit]
|
||||||
jb stack_overflow
|
jb stack_overflow
|
||||||
push esi
|
push esi
|
||||||
or [prefixed_instruction],-1
|
or [prefix_flags],1
|
||||||
call continue_line
|
call continue_line
|
||||||
mov eax,[counter_limit]
|
mov eax,[counter_limit]
|
||||||
cmp [counter],eax
|
cmp [counter],eax
|
||||||
@ -1008,8 +990,8 @@ virtual_directive:
|
|||||||
addressing_space_closed:
|
addressing_space_closed:
|
||||||
ret
|
ret
|
||||||
repeat_directive:
|
repeat_directive:
|
||||||
cmp [prefixed_instruction],0
|
test [prefix_flags],1
|
||||||
jne unexpected_instruction
|
jnz unexpected_instruction
|
||||||
lods byte [esi]
|
lods byte [esi]
|
||||||
cmp al,'('
|
cmp al,'('
|
||||||
jne invalid_argument
|
jne invalid_argument
|
||||||
@ -1030,8 +1012,8 @@ repeat_directive:
|
|||||||
mov [ebx+4],eax
|
mov [ebx+4],eax
|
||||||
jmp instruction_assembled
|
jmp instruction_assembled
|
||||||
end_repeat:
|
end_repeat:
|
||||||
cmp [prefixed_instruction],0
|
test [prefix_flags],1
|
||||||
jne unexpected_instruction
|
jnz unexpected_instruction
|
||||||
call find_structure_data
|
call find_structure_data
|
||||||
jc unexpected_instruction
|
jc unexpected_instruction
|
||||||
mov eax,[counter_limit]
|
mov eax,[counter_limit]
|
||||||
@ -1062,8 +1044,8 @@ repeat_directive:
|
|||||||
jne unexpected_instruction
|
jne unexpected_instruction
|
||||||
ret
|
ret
|
||||||
while_directive:
|
while_directive:
|
||||||
cmp [prefixed_instruction],0
|
test [prefix_flags],1
|
||||||
jne unexpected_instruction
|
jnz unexpected_instruction
|
||||||
call allocate_structure_data
|
call allocate_structure_data
|
||||||
mov word [ebx],while_directive-instruction_handler
|
mov word [ebx],while_directive-instruction_handler
|
||||||
mov eax,1
|
mov eax,1
|
||||||
@ -1093,8 +1075,8 @@ while_directive:
|
|||||||
pop ebx
|
pop ebx
|
||||||
jmp instruction_assembled
|
jmp instruction_assembled
|
||||||
end_while:
|
end_while:
|
||||||
cmp [prefixed_instruction],0
|
test [prefix_flags],1
|
||||||
jne unexpected_instruction
|
jnz unexpected_instruction
|
||||||
call find_structure_data
|
call find_structure_data
|
||||||
jc unexpected_instruction
|
jc unexpected_instruction
|
||||||
mov eax,[ebx+4]
|
mov eax,[ebx+4]
|
||||||
@ -1109,8 +1091,8 @@ while_directive:
|
|||||||
jne unexpected_instruction
|
jne unexpected_instruction
|
||||||
ret
|
ret
|
||||||
if_directive:
|
if_directive:
|
||||||
cmp [prefixed_instruction],0
|
test [prefix_flags],1
|
||||||
jne unexpected_instruction
|
jnz unexpected_instruction
|
||||||
call calculate_logical_expression
|
call calculate_logical_expression
|
||||||
mov dl,al
|
mov dl,al
|
||||||
mov al,[esi]
|
mov al,[esi]
|
||||||
@ -1146,8 +1128,8 @@ if_directive:
|
|||||||
or al,-1
|
or al,-1
|
||||||
jmp make_if_structure
|
jmp make_if_structure
|
||||||
else_directive:
|
else_directive:
|
||||||
cmp [prefixed_instruction],0
|
test [prefix_flags],1
|
||||||
jne unexpected_instruction
|
jnz unexpected_instruction
|
||||||
mov ax,if_directive-instruction_handler
|
mov ax,if_directive-instruction_handler
|
||||||
call find_structure_data
|
call find_structure_data
|
||||||
jc unexpected_instruction
|
jc unexpected_instruction
|
||||||
@ -1173,8 +1155,8 @@ if_directive:
|
|||||||
call remove_structure_data
|
call remove_structure_data
|
||||||
jmp instruction_assembled
|
jmp instruction_assembled
|
||||||
end_if:
|
end_if:
|
||||||
cmp [prefixed_instruction],0
|
test [prefix_flags],1
|
||||||
jne unexpected_instruction
|
jnz unexpected_instruction
|
||||||
call find_structure_data
|
call find_structure_data
|
||||||
jc unexpected_instruction
|
jc unexpected_instruction
|
||||||
call remove_structure_data
|
call remove_structure_data
|
||||||
@ -1377,7 +1359,7 @@ data_bytes:
|
|||||||
inc esi
|
inc esi
|
||||||
or eax,eax
|
or eax,eax
|
||||||
jz duplicate_zero_times
|
jz duplicate_zero_times
|
||||||
cmp byte [esi],'{'
|
cmp byte [esi],91h
|
||||||
jne duplicate_single_data_value
|
jne duplicate_single_data_value
|
||||||
inc esi
|
inc esi
|
||||||
duplicate_data:
|
duplicate_data:
|
||||||
@ -1389,7 +1371,7 @@ data_bytes:
|
|||||||
lods byte [esi]
|
lods byte [esi]
|
||||||
cmp al,','
|
cmp al,','
|
||||||
je duplicated_values
|
je duplicated_values
|
||||||
cmp al,'}'
|
cmp al,92h
|
||||||
jne invalid_argument
|
jne invalid_argument
|
||||||
pop ebx eax
|
pop ebx eax
|
||||||
dec eax
|
dec eax
|
||||||
@ -1407,13 +1389,13 @@ data_bytes:
|
|||||||
mov esi,ebx
|
mov esi,ebx
|
||||||
jmp duplicate_single_data_value
|
jmp duplicate_single_data_value
|
||||||
duplicate_zero_times:
|
duplicate_zero_times:
|
||||||
cmp byte [esi],'{'
|
cmp byte [esi],91h
|
||||||
jne skip_single_data_value
|
jne skip_single_data_value
|
||||||
inc esi
|
inc esi
|
||||||
skip_data_value:
|
skip_data_value:
|
||||||
call skip_symbol
|
call skip_symbol
|
||||||
jc invalid_argument
|
jc invalid_argument
|
||||||
cmp byte [esi],'}'
|
cmp byte [esi],92h
|
||||||
jne skip_data_value
|
jne skip_data_value
|
||||||
inc esi
|
inc esi
|
||||||
jmp data_defined
|
jmp data_defined
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
; flat assembler core
|
; flat assembler core
|
||||||
; Copyright (c) 1999-2013, Tomasz Grysztar.
|
; Copyright (c) 1999-2016, Tomasz Grysztar.
|
||||||
; All rights reserved.
|
; All rights reserved.
|
||||||
|
|
||||||
out_of_memory:
|
out_of_memory:
|
||||||
@ -24,6 +24,9 @@ code_cannot_be_generated:
|
|||||||
jmp general_error
|
jmp general_error
|
||||||
format_limitations_exceeded:
|
format_limitations_exceeded:
|
||||||
push _format_limitations_exceeded
|
push _format_limitations_exceeded
|
||||||
|
jmp general_error
|
||||||
|
invalid_definition:
|
||||||
|
push _invalid_definition
|
||||||
general_error:
|
general_error:
|
||||||
cmp [symbols_file],0
|
cmp [symbols_file],0
|
||||||
je fatal_error
|
je fatal_error
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
|
|
||||||
|
|
||||||
; flat assembler core
|
; flat assembler core
|
||||||
; Copyright (c) 1999-2013, Tomasz Grysztar.
|
; Copyright (c) 1999-2016, Tomasz Grysztar.
|
||||||
; All rights reserved.
|
; All rights reserved.
|
||||||
|
|
||||||
calculate_expression:
|
calculate_expression:
|
||||||
@ -12,6 +11,10 @@ calculate_expression:
|
|||||||
cmp byte [esi],'.'
|
cmp byte [esi],'.'
|
||||||
je convert_fp
|
je convert_fp
|
||||||
calculation_loop:
|
calculation_loop:
|
||||||
|
mov eax,[tagged_blocks]
|
||||||
|
sub eax,0Ch
|
||||||
|
cmp eax,edi
|
||||||
|
jbe out_of_memory
|
||||||
lods byte [esi]
|
lods byte [esi]
|
||||||
cmp al,1
|
cmp al,1
|
||||||
je get_byte_number
|
je get_byte_number
|
||||||
@ -36,12 +39,16 @@ calculate_expression:
|
|||||||
sub edi,14h
|
sub edi,14h
|
||||||
mov ebx,edi
|
mov ebx,edi
|
||||||
sub ebx,14h
|
sub ebx,14h
|
||||||
cmp al,0E0h
|
cmp al,0F0h
|
||||||
je calculate_rva
|
je calculate_rva
|
||||||
cmp al,0E1h
|
cmp al,0F1h
|
||||||
je calculate_plt
|
je calculate_plt
|
||||||
cmp al,0D0h
|
cmp al,0D0h
|
||||||
je calculate_not
|
je calculate_not
|
||||||
|
cmp al,0E0h
|
||||||
|
je calculate_bsf
|
||||||
|
cmp al,0E1h
|
||||||
|
je calculate_bsr
|
||||||
cmp al,083h
|
cmp al,083h
|
||||||
je calculate_neg
|
je calculate_neg
|
||||||
mov dx,[ebx+8]
|
mov dx,[ebx+8]
|
||||||
@ -197,14 +204,8 @@ calculate_expression:
|
|||||||
mov al,[ebx+10]
|
mov al,[ebx+10]
|
||||||
or al,al
|
or al,al
|
||||||
jz calculation_loop
|
jz calculation_loop
|
||||||
cmp [size_override],-1
|
test [operand_flags],1
|
||||||
je calculation_loop
|
jnz calculation_loop
|
||||||
cmp [size_override],0
|
|
||||||
je check_size
|
|
||||||
cmp [operand_size],0
|
|
||||||
jne calculation_loop
|
|
||||||
mov [operand_size],al
|
|
||||||
jmp calculation_loop
|
|
||||||
check_size:
|
check_size:
|
||||||
xchg [operand_size],al
|
xchg [operand_size],al
|
||||||
or al,al
|
or al,al
|
||||||
@ -623,76 +624,6 @@ calculate_expression:
|
|||||||
xor [ebx],eax
|
xor [ebx],eax
|
||||||
xor [ebx+4],edx
|
xor [ebx+4],edx
|
||||||
xor [ebx+13],cl
|
xor [ebx+13],cl
|
||||||
jz calculation_loop
|
|
||||||
or cl,cl
|
|
||||||
jz xor_size_check
|
|
||||||
xor eax,[ebx]
|
|
||||||
xor edx,[ebx+4]
|
|
||||||
xor_size_check:
|
|
||||||
mov cl,[value_size]
|
|
||||||
cmp cl,1
|
|
||||||
je xor_byte_result
|
|
||||||
cmp cl,2
|
|
||||||
je xor_word_result
|
|
||||||
cmp cl,4
|
|
||||||
je xor_dword_result
|
|
||||||
cmp cl,6
|
|
||||||
je xor_pword_result
|
|
||||||
cmp cl,8
|
|
||||||
jne calculation_loop
|
|
||||||
xor edx,[ebx+4]
|
|
||||||
js xor_result_truncated
|
|
||||||
jmp calculation_loop
|
|
||||||
xor_pword_result:
|
|
||||||
test edx,0FFFF0000h
|
|
||||||
jnz calculation_loop
|
|
||||||
cmp word [ebx+6],-1
|
|
||||||
jne calculation_loop
|
|
||||||
xor dx,[ebx+4]
|
|
||||||
jns calculation_loop
|
|
||||||
not word [ebx+6]
|
|
||||||
jmp xor_result_truncated
|
|
||||||
xor_dword_result:
|
|
||||||
test edx,edx
|
|
||||||
jnz calculation_loop
|
|
||||||
cmp dword [ebx+4],-1
|
|
||||||
jne calculation_loop
|
|
||||||
xor eax,[ebx]
|
|
||||||
jns calculation_loop
|
|
||||||
not dword [ebx+4]
|
|
||||||
jmp xor_result_truncated
|
|
||||||
xor_word_result:
|
|
||||||
test edx,edx
|
|
||||||
jnz calculation_loop
|
|
||||||
test eax,0FFFF0000h
|
|
||||||
jnz calculation_loop
|
|
||||||
cmp dword [ebx+4],-1
|
|
||||||
jne calculation_loop
|
|
||||||
cmp word [ebx+2],-1
|
|
||||||
jne calculation_loop
|
|
||||||
xor ax,[ebx]
|
|
||||||
jns calculation_loop
|
|
||||||
not dword [ebx+4]
|
|
||||||
not word [ebx+2]
|
|
||||||
jmp xor_result_truncated
|
|
||||||
xor_byte_result:
|
|
||||||
test edx,edx
|
|
||||||
jnz calculation_loop
|
|
||||||
test eax,0FFFFFF00h
|
|
||||||
jnz calculation_loop
|
|
||||||
cmp dword [ebx+4],-1
|
|
||||||
jne calculation_loop
|
|
||||||
cmp word [ebx+2],-1
|
|
||||||
jne calculation_loop
|
|
||||||
cmp byte [ebx+1],-1
|
|
||||||
jne calculation_loop
|
|
||||||
xor al,[ebx]
|
|
||||||
jns calculation_loop
|
|
||||||
not dword [ebx+4]
|
|
||||||
not word [ebx+2]
|
|
||||||
not byte [ebx+1]
|
|
||||||
xor_result_truncated:
|
|
||||||
mov byte [ebx+13],0
|
|
||||||
jmp calculation_loop
|
jmp calculation_loop
|
||||||
shr_negative:
|
shr_negative:
|
||||||
mov byte [edi+13],0
|
mov byte [edi+13],0
|
||||||
@ -761,25 +692,6 @@ calculate_expression:
|
|||||||
calculate_shr:
|
calculate_shr:
|
||||||
cmp byte [edi+13],0
|
cmp byte [edi+13],0
|
||||||
jne shr_negative
|
jne shr_negative
|
||||||
cmp byte [ebx+13],0
|
|
||||||
je do_shr
|
|
||||||
mov al,[value_size]
|
|
||||||
cmp al,1
|
|
||||||
je shr_negative_byte
|
|
||||||
cmp al,2
|
|
||||||
je shr_negative_word
|
|
||||||
cmp al,4
|
|
||||||
je shr_negative_dword
|
|
||||||
cmp al,6
|
|
||||||
je shr_negative_pword
|
|
||||||
cmp al,8
|
|
||||||
jne do_shr
|
|
||||||
shr_negative_qword:
|
|
||||||
test byte [ebx+7],80h
|
|
||||||
jz do_shr
|
|
||||||
shr_truncated:
|
|
||||||
mov byte [ebx+13],0
|
|
||||||
do_shr:
|
|
||||||
mov edx,[ebx+4]
|
mov edx,[ebx+4]
|
||||||
mov eax,[ebx]
|
mov eax,[ebx]
|
||||||
cmp dword [edi+4],0
|
cmp dword [edi+4],0
|
||||||
@ -809,43 +721,6 @@ calculate_expression:
|
|||||||
mov dword [ebx],eax
|
mov dword [ebx],eax
|
||||||
mov dword [ebx+4],eax
|
mov dword [ebx+4],eax
|
||||||
jmp calculation_loop
|
jmp calculation_loop
|
||||||
shr_negative_byte:
|
|
||||||
cmp dword [ebx+4],-1
|
|
||||||
jne do_shr
|
|
||||||
cmp word [ebx+2],-1
|
|
||||||
jne do_shr
|
|
||||||
cmp byte [ebx+1],-1
|
|
||||||
jne do_shr
|
|
||||||
test byte [ebx],80h
|
|
||||||
jz do_shr
|
|
||||||
not dword [ebx+4]
|
|
||||||
not word [ebx+2]
|
|
||||||
not byte [ebx+1]
|
|
||||||
jmp shr_truncated
|
|
||||||
shr_negative_word:
|
|
||||||
cmp dword [ebx+4],-1
|
|
||||||
jne do_shr
|
|
||||||
cmp word [ebx+2],-1
|
|
||||||
jne do_shr
|
|
||||||
test byte [ebx+1],80h
|
|
||||||
jz do_shr
|
|
||||||
not dword [ebx+4]
|
|
||||||
not word [ebx+2]
|
|
||||||
jmp shr_truncated
|
|
||||||
shr_negative_dword:
|
|
||||||
cmp dword [ebx+4],-1
|
|
||||||
jne do_shr
|
|
||||||
test byte [ebx+3],80h
|
|
||||||
jz do_shr
|
|
||||||
not dword [ebx+4]
|
|
||||||
jmp shr_truncated
|
|
||||||
shr_negative_pword:
|
|
||||||
cmp word [ebx+6],-1
|
|
||||||
jne do_shr
|
|
||||||
test byte [ebx+5],80h
|
|
||||||
jz do_shr
|
|
||||||
not word [ebx+6]
|
|
||||||
jmp shr_truncated
|
|
||||||
calculate_not:
|
calculate_not:
|
||||||
cmp word [edi+8],0
|
cmp word [edi+8],0
|
||||||
jne invalid_expression
|
jne invalid_expression
|
||||||
@ -853,56 +728,53 @@ calculate_expression:
|
|||||||
je not_ok
|
je not_ok
|
||||||
call recoverable_misuse
|
call recoverable_misuse
|
||||||
not_ok:
|
not_ok:
|
||||||
mov al,[value_size]
|
|
||||||
cmp al,1
|
|
||||||
je not_byte
|
|
||||||
cmp al,2
|
|
||||||
je not_word
|
|
||||||
cmp al,4
|
|
||||||
je not_dword
|
|
||||||
cmp al,6
|
|
||||||
je not_pword
|
|
||||||
cmp al,8
|
|
||||||
je not_qword
|
|
||||||
not dword [edi]
|
not dword [edi]
|
||||||
not dword [edi+4]
|
not dword [edi+4]
|
||||||
not byte [edi+13]
|
not byte [edi+13]
|
||||||
add edi,14h
|
add edi,14h
|
||||||
jmp calculation_loop
|
jmp calculation_loop
|
||||||
not_qword:
|
calculate_bsf:
|
||||||
not dword [edi]
|
cmp word [edi+8],0
|
||||||
not dword [edi+4]
|
jne invalid_expression
|
||||||
finish_not:
|
cmp byte [edi+12],0
|
||||||
mov byte [edi+13],0
|
je bsf_ok
|
||||||
|
call recoverable_misuse
|
||||||
|
bsf_ok:
|
||||||
|
xor ecx,ecx
|
||||||
|
bsf eax,[edi]
|
||||||
|
jnz finish_bs
|
||||||
|
mov ecx,32
|
||||||
|
bsf eax,[edi+4]
|
||||||
|
jnz finish_bs
|
||||||
|
cmp byte [edi+13],0
|
||||||
|
jne finish_bs
|
||||||
|
bs_overflow:
|
||||||
|
call recoverable_overflow
|
||||||
|
add edi,14h
|
||||||
|
jmp calculation_loop
|
||||||
|
calculate_bsr:
|
||||||
|
cmp word [edi+8],0
|
||||||
|
jne invalid_expression
|
||||||
|
cmp byte [edi+12],0
|
||||||
|
je bsr_ok
|
||||||
|
call recoverable_misuse
|
||||||
|
bsr_ok:
|
||||||
|
cmp byte [edi+13],0
|
||||||
|
jne bs_overflow
|
||||||
|
mov ecx,32
|
||||||
|
bsr eax,[edi+4]
|
||||||
|
jnz finish_bs
|
||||||
|
xor ecx,ecx
|
||||||
|
bsr eax,[edi]
|
||||||
|
jz bs_overflow
|
||||||
|
finish_bs:
|
||||||
|
add eax,ecx
|
||||||
|
xor edx,edx
|
||||||
|
mov [edi],eax
|
||||||
|
mov [edi+4],edx
|
||||||
|
mov [edi+13],dl
|
||||||
add edi,14h
|
add edi,14h
|
||||||
jmp calculation_loop
|
jmp calculation_loop
|
||||||
not_byte:
|
|
||||||
cmp dword [edi+4],0
|
|
||||||
jne not_qword
|
|
||||||
cmp word [edi+2],0
|
|
||||||
jne not_qword
|
|
||||||
cmp byte [edi+1],0
|
|
||||||
jne not_qword
|
|
||||||
not byte [edi]
|
|
||||||
jmp finish_not
|
|
||||||
not_word:
|
|
||||||
cmp dword [edi+4],0
|
|
||||||
jne not_qword
|
|
||||||
cmp word [edi+2],0
|
|
||||||
jne not_qword
|
|
||||||
not word [edi]
|
|
||||||
jmp finish_not
|
|
||||||
not_dword:
|
|
||||||
cmp dword [edi+4],0
|
|
||||||
jne not_qword
|
|
||||||
not dword [edi]
|
|
||||||
jmp finish_not
|
|
||||||
not_pword:
|
|
||||||
cmp word [edi+6],0
|
|
||||||
jne not_qword
|
|
||||||
not word [edi+4]
|
|
||||||
not dword [edi]
|
|
||||||
jmp finish_not
|
|
||||||
calculate_neg:
|
calculate_neg:
|
||||||
cmp byte [edi+8],0
|
cmp byte [edi+8],0
|
||||||
je neg_first_register_ok
|
je neg_first_register_ok
|
||||||
@ -1158,7 +1030,8 @@ calculate_expression:
|
|||||||
cmp al,4
|
cmp al,4
|
||||||
je convert_fp_dword
|
je convert_fp_dword
|
||||||
test al,not 8
|
test al,not 8
|
||||||
jnz invalid_value
|
jz convert_fp_qword
|
||||||
|
call recoverable_misuse
|
||||||
convert_fp_qword:
|
convert_fp_qword:
|
||||||
xor eax,eax
|
xor eax,eax
|
||||||
xor edx,edx
|
xor edx,edx
|
||||||
@ -1194,7 +1067,7 @@ calculate_expression:
|
|||||||
cmp cx,52
|
cmp cx,52
|
||||||
ja value_out_of_range
|
ja value_out_of_range
|
||||||
cmp cx,32
|
cmp cx,32
|
||||||
jbe fp_qword_small_shift
|
jb fp_qword_small_shift
|
||||||
sub cx,32
|
sub cx,32
|
||||||
mov eax,edx
|
mov eax,edx
|
||||||
xor edx,edx
|
xor edx,edx
|
||||||
@ -1338,7 +1211,7 @@ calculate_expression:
|
|||||||
|
|
||||||
get_byte_value:
|
get_byte_value:
|
||||||
mov [value_size],1
|
mov [value_size],1
|
||||||
mov [size_override],-1
|
or [operand_flags],1
|
||||||
call calculate_value
|
call calculate_value
|
||||||
or al,al
|
or al,al
|
||||||
jz check_byte_value
|
jz check_byte_value
|
||||||
@ -1350,7 +1223,7 @@ get_byte_value:
|
|||||||
je byte_positive
|
je byte_positive
|
||||||
cmp edx,-1
|
cmp edx,-1
|
||||||
jne range_exceeded
|
jne range_exceeded
|
||||||
cmp eax,-80h
|
cmp eax,-100h
|
||||||
jb range_exceeded
|
jb range_exceeded
|
||||||
ret
|
ret
|
||||||
byte_positive:
|
byte_positive:
|
||||||
@ -1382,7 +1255,7 @@ get_byte_value:
|
|||||||
ret
|
ret
|
||||||
get_word_value:
|
get_word_value:
|
||||||
mov [value_size],2
|
mov [value_size],2
|
||||||
mov [size_override],-1
|
or [operand_flags],1
|
||||||
call calculate_value
|
call calculate_value
|
||||||
cmp al,2
|
cmp al,2
|
||||||
jb check_word_value
|
jb check_word_value
|
||||||
@ -1394,7 +1267,7 @@ get_word_value:
|
|||||||
je word_positive
|
je word_positive
|
||||||
cmp edx,-1
|
cmp edx,-1
|
||||||
jne range_exceeded
|
jne range_exceeded
|
||||||
cmp eax,-8000h
|
cmp eax,-10000h
|
||||||
jb range_exceeded
|
jb range_exceeded
|
||||||
ret
|
ret
|
||||||
word_positive:
|
word_positive:
|
||||||
@ -1405,7 +1278,7 @@ get_word_value:
|
|||||||
ret
|
ret
|
||||||
get_dword_value:
|
get_dword_value:
|
||||||
mov [value_size],4
|
mov [value_size],4
|
||||||
mov [size_override],-1
|
or [operand_flags],1
|
||||||
call calculate_value
|
call calculate_value
|
||||||
cmp al,4
|
cmp al,4
|
||||||
jne check_dword_value
|
jne check_dword_value
|
||||||
@ -1426,8 +1299,6 @@ get_dword_value:
|
|||||||
je dword_positive
|
je dword_positive
|
||||||
cmp edx,-1
|
cmp edx,-1
|
||||||
jne range_exceeded
|
jne range_exceeded
|
||||||
bt eax,31
|
|
||||||
jnc range_exceeded
|
|
||||||
ret
|
ret
|
||||||
dword_positive:
|
dword_positive:
|
||||||
test edx,edx
|
test edx,edx
|
||||||
@ -1435,7 +1306,7 @@ get_dword_value:
|
|||||||
ret
|
ret
|
||||||
get_pword_value:
|
get_pword_value:
|
||||||
mov [value_size],6
|
mov [value_size],6
|
||||||
mov [size_override],-1
|
or [operand_flags],1
|
||||||
call calculate_value
|
call calculate_value
|
||||||
cmp al,4
|
cmp al,4
|
||||||
jne check_pword_value
|
jne check_pword_value
|
||||||
@ -1445,7 +1316,7 @@ get_pword_value:
|
|||||||
mov edx,[edi+4]
|
mov edx,[edi+4]
|
||||||
cmp byte [edi+13],0
|
cmp byte [edi+13],0
|
||||||
je pword_positive
|
je pword_positive
|
||||||
cmp edx,-8000h
|
cmp edx,-10000h
|
||||||
jb range_exceeded
|
jb range_exceeded
|
||||||
ret
|
ret
|
||||||
pword_positive:
|
pword_positive:
|
||||||
@ -1454,20 +1325,15 @@ get_pword_value:
|
|||||||
ret
|
ret
|
||||||
get_qword_value:
|
get_qword_value:
|
||||||
mov [value_size],8
|
mov [value_size],8
|
||||||
mov [size_override],-1
|
or [operand_flags],1
|
||||||
call calculate_value
|
call calculate_value
|
||||||
check_qword_value:
|
check_qword_value:
|
||||||
mov eax,[edi]
|
mov eax,[edi]
|
||||||
mov edx,[edi+4]
|
mov edx,[edi+4]
|
||||||
cmp byte [edi+13],0
|
|
||||||
je qword_positive
|
|
||||||
cmp edx,-80000000h
|
|
||||||
jb range_exceeded
|
|
||||||
qword_positive:
|
|
||||||
ret
|
ret
|
||||||
get_count_value:
|
get_count_value:
|
||||||
mov [value_size],8
|
mov [value_size],8
|
||||||
mov [size_override],-1
|
or [operand_flags],1
|
||||||
call calculate_expression
|
call calculate_expression
|
||||||
cmp word [edi+8],0
|
cmp word [edi+8],0
|
||||||
jne invalid_value
|
jne invalid_value
|
||||||
@ -1636,33 +1502,31 @@ get_address_value:
|
|||||||
mov ax,bx
|
mov ax,bx
|
||||||
shr ah,4
|
shr ah,4
|
||||||
shr al,4
|
shr al,4
|
||||||
cmp ah,0Ch
|
|
||||||
je check_vsib_address
|
|
||||||
cmp ah,0Dh
|
|
||||||
je check_vsib_address
|
|
||||||
cmp al,0Ch
|
|
||||||
je check_vsib_address
|
|
||||||
cmp al,0Dh
|
|
||||||
je check_vsib_address
|
|
||||||
or bh,bh
|
or bh,bh
|
||||||
jz check_address_registers
|
jz check_address_registers
|
||||||
or bl,bl
|
or bl,bl
|
||||||
jz check_address_registers
|
jz check_address_registers
|
||||||
cmp al,ah
|
cmp al,ah
|
||||||
jne invalid_address
|
jne check_vsib
|
||||||
check_address_registers:
|
check_address_registers:
|
||||||
or al,ah
|
or al,ah
|
||||||
|
cmp al,0Ch
|
||||||
|
jae check_vsib
|
||||||
|
cmp al,6
|
||||||
|
je check_vsib
|
||||||
|
cmp al,7
|
||||||
|
je check_vsib
|
||||||
mov ah,[address_size]
|
mov ah,[address_size]
|
||||||
and ah,0Fh
|
and ah,0Fh
|
||||||
jz address_registers_sizes_ok
|
jz address_registers_sizes_ok
|
||||||
cmp al,ah
|
cmp al,ah
|
||||||
jne address_sizes_do_not_match
|
jne invalid_address
|
||||||
address_registers_sizes_ok:
|
address_registers_sizes_ok:
|
||||||
cmp al,4
|
cmp al,4
|
||||||
je sib_allowed
|
je sib_allowed
|
||||||
cmp al,8
|
cmp al,8
|
||||||
je sib_allowed
|
je sib_allowed
|
||||||
cmp al,0Fh
|
cmp al,9
|
||||||
je check_ip_relative_address
|
je check_ip_relative_address
|
||||||
cmp cl,1
|
cmp cl,1
|
||||||
ja invalid_address
|
ja invalid_address
|
||||||
@ -1679,13 +1543,15 @@ get_address_value:
|
|||||||
check_ip_relative_address:
|
check_ip_relative_address:
|
||||||
or bl,bl
|
or bl,bl
|
||||||
jnz invalid_address
|
jnz invalid_address
|
||||||
cmp bh,0F8h
|
cmp bh,98h
|
||||||
je check_rip_relative_address
|
je check_rip_relative_address
|
||||||
cmp bh,0F4h
|
cmp bh,94h
|
||||||
jne invalid_address
|
jne invalid_address
|
||||||
cmp [free_address_range],0
|
cmp [free_address_range],0
|
||||||
jne check_qword_value
|
je check_dword_value
|
||||||
jmp check_dword_value
|
mov eax,[edi]
|
||||||
|
mov edx,[edi+4]
|
||||||
|
ret
|
||||||
check_rip_relative_address:
|
check_rip_relative_address:
|
||||||
mov eax,[edi]
|
mov eax,[edi]
|
||||||
cdq
|
cdq
|
||||||
@ -1792,35 +1658,41 @@ get_address_value:
|
|||||||
and al,cl
|
and al,cl
|
||||||
jz check_immediate_address
|
jz check_immediate_address
|
||||||
jmp invalid_address
|
jmp invalid_address
|
||||||
check_vsib_address:
|
check_vsib:
|
||||||
cmp ah,0Ch
|
xor ah,ah
|
||||||
je swap_vsib_registers
|
check_vsib_base:
|
||||||
cmp ah,0Dh
|
test bh,bh
|
||||||
jne check_vsib_base
|
jz check_vsib_index
|
||||||
|
mov al,bh
|
||||||
|
shr al,4
|
||||||
|
cmp al,4
|
||||||
|
je check_vsib_base_size
|
||||||
|
cmp [code_type],64
|
||||||
|
jne swap_vsib_registers
|
||||||
|
cmp al,8
|
||||||
|
jne swap_vsib_registers
|
||||||
|
check_vsib_base_size:
|
||||||
|
mov ah,[address_size]
|
||||||
|
and ah,0Fh
|
||||||
|
jz check_vsib_index
|
||||||
|
cmp al,ah
|
||||||
|
jne invalid_address
|
||||||
|
check_vsib_index:
|
||||||
|
mov al,bl
|
||||||
|
and al,0E0h
|
||||||
|
cmp al,0C0h
|
||||||
|
jae check_index_scale
|
||||||
|
cmp al,60h
|
||||||
|
je check_index_scale
|
||||||
|
jmp invalid_address
|
||||||
swap_vsib_registers:
|
swap_vsib_registers:
|
||||||
|
xor ah,-1
|
||||||
|
jz invalid_address
|
||||||
cmp cl,1
|
cmp cl,1
|
||||||
ja invalid_address
|
ja invalid_address
|
||||||
xchg bl,bh
|
xchg bl,bh
|
||||||
mov cl,1
|
mov cl,1
|
||||||
check_vsib_base:
|
jmp check_vsib_base
|
||||||
test bh,bh
|
|
||||||
jz vsib_base_ok
|
|
||||||
mov al,bh
|
|
||||||
shr al,4
|
|
||||||
cmp al,4
|
|
||||||
je vsib_base_ok
|
|
||||||
cmp [code_type],64
|
|
||||||
jne invalid_address
|
|
||||||
cmp al,8
|
|
||||||
jne invalid_address
|
|
||||||
vsib_base_ok:
|
|
||||||
mov al,bl
|
|
||||||
shr al,4
|
|
||||||
cmp al,0Ch
|
|
||||||
je check_index_scale
|
|
||||||
cmp al,0Dh
|
|
||||||
je check_index_scale
|
|
||||||
jmp invalid_address
|
|
||||||
|
|
||||||
calculate_relative_offset:
|
calculate_relative_offset:
|
||||||
cmp [value_undefined],0
|
cmp [value_undefined],0
|
||||||
@ -1912,7 +1784,7 @@ calculate_logical_expression:
|
|||||||
jmp logical_loop
|
jmp logical_loop
|
||||||
get_value_for_comparison:
|
get_value_for_comparison:
|
||||||
mov [value_size],8
|
mov [value_size],8
|
||||||
mov [size_override],-1
|
or [operand_flags],1
|
||||||
lods byte [esi]
|
lods byte [esi]
|
||||||
call calculate_expression
|
call calculate_expression
|
||||||
cmp byte [edi+8],0
|
cmp byte [edi+8],0
|
||||||
@ -1943,7 +1815,7 @@ calculate_logical_expression:
|
|||||||
negation_ok:
|
negation_ok:
|
||||||
push eax
|
push eax
|
||||||
mov al,[esi]
|
mov al,[esi]
|
||||||
cmp al,'{'
|
cmp al,91h
|
||||||
je logical_expression
|
je logical_expression
|
||||||
cmp al,0FFh
|
cmp al,0FFh
|
||||||
je invalid_expression
|
je invalid_expression
|
||||||
@ -1965,7 +1837,7 @@ calculate_logical_expression:
|
|||||||
jz logical_number
|
jz logical_number
|
||||||
cmp al,0Fh
|
cmp al,0Fh
|
||||||
je logical_number
|
je logical_number
|
||||||
cmp al,'}'
|
cmp al,92h
|
||||||
je logical_number
|
je logical_number
|
||||||
cmp al,'&'
|
cmp al,'&'
|
||||||
je logical_number
|
je logical_number
|
||||||
@ -2124,7 +1996,7 @@ calculate_logical_expression:
|
|||||||
inc esi
|
inc esi
|
||||||
jmp check_expression
|
jmp check_expression
|
||||||
defined_fp_value:
|
defined_fp_value:
|
||||||
add esi,12
|
add esi,12+1
|
||||||
jmp expression_checked
|
jmp expression_checked
|
||||||
defined_string:
|
defined_string:
|
||||||
lods dword [esi]
|
lods dword [esi]
|
||||||
@ -2206,7 +2078,7 @@ calculate_logical_expression:
|
|||||||
mov [logical_value_wrapping],dl
|
mov [logical_value_wrapping],dl
|
||||||
push eax
|
push eax
|
||||||
lods byte [esi]
|
lods byte [esi]
|
||||||
cmp al,'}'
|
cmp al,92h
|
||||||
jne invalid_expression
|
jne invalid_expression
|
||||||
pop eax
|
pop eax
|
||||||
logical_value_ok:
|
logical_value_ok:
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
; flat assembler core
|
; flat assembler core
|
||||||
; Copyright (c) 1999-2013, Tomasz Grysztar.
|
; Copyright (c) 1999-2016, Tomasz Grysztar.
|
||||||
; All rights reserved.
|
; All rights reserved.
|
||||||
|
|
||||||
convert_expression:
|
convert_expression:
|
||||||
@ -77,7 +77,7 @@ convert_expression:
|
|||||||
ret
|
ret
|
||||||
|
|
||||||
convert_number:
|
convert_number:
|
||||||
lea eax,[edi-10h]
|
lea eax,[edi+20h]
|
||||||
mov edx,[memory_end]
|
mov edx,[memory_end]
|
||||||
cmp [source_start],0
|
cmp [source_start],0
|
||||||
je check_memory_for_number
|
je check_memory_for_number
|
||||||
@ -129,7 +129,11 @@ convert_number:
|
|||||||
pop [current_offset]
|
pop [current_offset]
|
||||||
lods byte [esi]
|
lods byte [esi]
|
||||||
cmp al,')'
|
cmp al,')'
|
||||||
jne invalid_expression
|
je subexpression_closed
|
||||||
|
dec esi
|
||||||
|
mov al,'!'
|
||||||
|
stosb
|
||||||
|
subexpression_closed:
|
||||||
ret
|
ret
|
||||||
symbol_value:
|
symbol_value:
|
||||||
cmp [source_start],0
|
cmp [source_start],0
|
||||||
@ -147,16 +151,13 @@ convert_number:
|
|||||||
shr ah,4
|
shr ah,4
|
||||||
cmp ah,4
|
cmp ah,4
|
||||||
je register_value
|
je register_value
|
||||||
|
and ah,not 1
|
||||||
cmp ah,8
|
cmp ah,8
|
||||||
je register_value
|
je register_value
|
||||||
cmp ah,0Ch
|
cmp ah,0Ch
|
||||||
|
jae register_value
|
||||||
|
cmp ah,6
|
||||||
je register_value
|
je register_value
|
||||||
cmp ah,0Dh
|
|
||||||
je register_value
|
|
||||||
cmp ah,0Fh
|
|
||||||
je register_value
|
|
||||||
cmp ah,2
|
|
||||||
jne no_address_register
|
|
||||||
cmp al,23h
|
cmp al,23h
|
||||||
je register_value
|
je register_value
|
||||||
cmp al,25h
|
cmp al,25h
|
||||||
@ -912,7 +913,7 @@ preevaluate_logical_expression:
|
|||||||
je preevaluate_or
|
je preevaluate_or
|
||||||
cmp dl,'&'
|
cmp dl,'&'
|
||||||
je preevaluate_and
|
je preevaluate_and
|
||||||
cmp dl,'}'
|
cmp dl,92h
|
||||||
je preevaluation_done
|
je preevaluation_done
|
||||||
or dl,dl
|
or dl,dl
|
||||||
jnz invalid_logical_expression
|
jnz invalid_logical_expression
|
||||||
@ -987,7 +988,7 @@ preevaluate_logical_expression:
|
|||||||
jmp skip_logical_value
|
jmp skip_logical_value
|
||||||
negation_skipped:
|
negation_skipped:
|
||||||
mov al,[esi]
|
mov al,[esi]
|
||||||
cmp al,'{'
|
cmp al,91h
|
||||||
jne skip_simple_logical_value
|
jne skip_simple_logical_value
|
||||||
inc esi
|
inc esi
|
||||||
xchg al,[logical_value_wrapping]
|
xchg al,[logical_value_wrapping]
|
||||||
@ -1003,7 +1004,7 @@ preevaluate_logical_expression:
|
|||||||
je skip_logical_expression
|
je skip_logical_expression
|
||||||
cmp al,'&'
|
cmp al,'&'
|
||||||
je skip_logical_expression
|
je skip_logical_expression
|
||||||
cmp al,'}'
|
cmp al,92h
|
||||||
jne wrongly_structured_logical_expression
|
jne wrongly_structured_logical_expression
|
||||||
pop eax
|
pop eax
|
||||||
mov [logical_value_wrapping],al
|
mov [logical_value_wrapping],al
|
||||||
@ -1026,13 +1027,13 @@ preevaluate_logical_expression:
|
|||||||
je logical_value_skipped
|
je logical_value_skipped
|
||||||
cmp al,'&'
|
cmp al,'&'
|
||||||
je logical_value_skipped
|
je logical_value_skipped
|
||||||
cmp al,'{'
|
cmp al,91h
|
||||||
je skip_logical_value_internal_parenthesis
|
je skip_logical_value_internal_parenthesis
|
||||||
cmp al,'}'
|
cmp al,92h
|
||||||
jne skip_logical_value_symbol
|
jne skip_logical_value_symbol
|
||||||
sub [logical_value_parentheses],1
|
sub [logical_value_parentheses],1
|
||||||
jnc skip_logical_value_symbol
|
jnc skip_logical_value_symbol
|
||||||
cmp [logical_value_wrapping],'{'
|
cmp [logical_value_wrapping],91h
|
||||||
jne skip_logical_value_symbol
|
jne skip_logical_value_symbol
|
||||||
jmp logical_value_skipped
|
jmp logical_value_skipped
|
||||||
skip_logical_value_internal_parenthesis:
|
skip_logical_value_internal_parenthesis:
|
||||||
@ -1049,7 +1050,7 @@ preevaluate_logical_expression:
|
|||||||
jmp preevaluate_negation
|
jmp preevaluate_negation
|
||||||
preevaluate_negation_ok:
|
preevaluate_negation_ok:
|
||||||
mov ebx,esi
|
mov ebx,esi
|
||||||
cmp byte [esi],'{'
|
cmp byte [esi],91h
|
||||||
jne preevaluate_simple_logical_value
|
jne preevaluate_simple_logical_value
|
||||||
lods byte [esi]
|
lods byte [esi]
|
||||||
stos byte [edi]
|
stos byte [edi]
|
||||||
@ -1062,7 +1063,7 @@ preevaluate_logical_expression:
|
|||||||
pop ebp
|
pop ebp
|
||||||
cmp al,0FFh
|
cmp al,0FFh
|
||||||
je invalid_logical_value
|
je invalid_logical_value
|
||||||
cmp byte [esi],'}'
|
cmp byte [esi],92h
|
||||||
jne invalid_logical_value
|
jne invalid_logical_value
|
||||||
or al,al
|
or al,al
|
||||||
jnz preevaluated_expression_value
|
jnz preevaluated_expression_value
|
||||||
@ -1089,9 +1090,9 @@ preevaluate_logical_expression:
|
|||||||
mov al,[esi]
|
mov al,[esi]
|
||||||
or al,al
|
or al,al
|
||||||
jz logical_value_boundaries_found
|
jz logical_value_boundaries_found
|
||||||
cmp al,'{'
|
cmp al,91h
|
||||||
je logical_value_internal_parentheses
|
je logical_value_internal_parentheses
|
||||||
cmp al,'}'
|
cmp al,92h
|
||||||
je logical_value_boundaries_parenthesis_close
|
je logical_value_boundaries_parenthesis_close
|
||||||
cmp al,'|'
|
cmp al,'|'
|
||||||
je logical_value_boundaries_found
|
je logical_value_boundaries_found
|
||||||
@ -1116,7 +1117,7 @@ preevaluate_logical_expression:
|
|||||||
logical_value_boundaries_parenthesis_close:
|
logical_value_boundaries_parenthesis_close:
|
||||||
sub [logical_value_parentheses],1
|
sub [logical_value_parentheses],1
|
||||||
jnc next_symbol_in_logical_value
|
jnc next_symbol_in_logical_value
|
||||||
cmp [logical_value_wrapping],'{'
|
cmp [logical_value_wrapping],91h
|
||||||
jne next_symbol_in_logical_value
|
jne next_symbol_in_logical_value
|
||||||
logical_value_boundaries_found:
|
logical_value_boundaries_found:
|
||||||
or edx,edx
|
or edx,edx
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
; flat assembler core
|
; flat assembler core
|
||||||
; Copyright (c) 1999-2013, Tomasz Grysztar.
|
; Copyright (c) 1999-2016, Tomasz Grysztar.
|
||||||
; All rights reserved.
|
; All rights reserved.
|
||||||
|
|
||||||
formatter:
|
formatter:
|
||||||
@ -454,7 +454,8 @@ format_mz:
|
|||||||
jmp format_defined
|
jmp format_defined
|
||||||
mark_mz_relocation:
|
mark_mz_relocation:
|
||||||
push eax ebx
|
push eax ebx
|
||||||
inc [number_of_relocations]
|
inc word [number_of_relocations]
|
||||||
|
jz format_limitations_exceeded
|
||||||
mov ebx,[free_additional_memory]
|
mov ebx,[free_additional_memory]
|
||||||
mov eax,edi
|
mov eax,edi
|
||||||
sub eax,[code_start]
|
sub eax,[code_start]
|
||||||
@ -1611,6 +1612,7 @@ make_pe_fixups:
|
|||||||
sub esi,eax
|
sub esi,eax
|
||||||
mov [free_additional_memory],esi
|
mov [free_additional_memory],esi
|
||||||
mov edx,[last_fixup_base]
|
mov edx,[last_fixup_base]
|
||||||
|
mov ebx,[last_fixup_header]
|
||||||
mov ebp,edi
|
mov ebp,edi
|
||||||
jecxz fixups_done
|
jecxz fixups_done
|
||||||
make_fixup:
|
make_fixup:
|
||||||
@ -1645,6 +1647,7 @@ make_pe_fixups:
|
|||||||
loop make_fixup
|
loop make_fixup
|
||||||
fixups_done:
|
fixups_done:
|
||||||
mov [last_fixup_base],edx
|
mov [last_fixup_base],edx
|
||||||
|
mov [last_fixup_header],ebx
|
||||||
pop esi
|
pop esi
|
||||||
mov eax,edi
|
mov eax,edi
|
||||||
sub eax,ebp
|
sub eax,ebp
|
||||||
@ -3491,8 +3494,22 @@ elf_formatter:
|
|||||||
shr eax,8
|
shr eax,8
|
||||||
stos dword [edi]
|
stos dword [edi]
|
||||||
xor eax,eax
|
xor eax,eax
|
||||||
|
push edx
|
||||||
|
mov edx,[esi+4]
|
||||||
|
add edx,[image_base]
|
||||||
|
xchg eax,[edx]
|
||||||
stos dword [edi]
|
stos dword [edi]
|
||||||
|
cmp byte [esi],1
|
||||||
|
je addend_64bit
|
||||||
|
pop edx
|
||||||
|
sar eax,31
|
||||||
stos dword [edi]
|
stos dword [edi]
|
||||||
|
jmp relocation_entry_ok
|
||||||
|
addend_64bit:
|
||||||
|
xor eax,eax
|
||||||
|
xchg eax,[edx+4]
|
||||||
|
stos dword [edi]
|
||||||
|
pop edx
|
||||||
relocation_entry_ok:
|
relocation_entry_ok:
|
||||||
add esi,0Ch
|
add esi,0Ch
|
||||||
jmp convert_relocations
|
jmp convert_relocations
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
; flat assembler core
|
; flat assembler core
|
||||||
; Copyright (c) 1999-2013, Tomasz Grysztar.
|
; Copyright (c) 1999-2016, Tomasz Grysztar.
|
||||||
; All rights reserved.
|
; All rights reserved.
|
||||||
|
|
||||||
_out_of_memory db 'out of memory',0
|
_out_of_memory db 'out of memory',0
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
; flat assembler core
|
; flat assembler core
|
||||||
; Copyright (c) 1999-2013, Tomasz Grysztar.
|
; Copyright (c) 1999-2016, Tomasz Grysztar.
|
||||||
; All rights reserved.
|
; All rights reserved.
|
||||||
|
|
||||||
parser:
|
parser:
|
||||||
@ -34,6 +34,7 @@ parser:
|
|||||||
add esi,16
|
add esi,16
|
||||||
parse_line:
|
parse_line:
|
||||||
mov [formatter_symbols_allowed],0
|
mov [formatter_symbols_allowed],0
|
||||||
|
mov [decorator_symbols_allowed],0
|
||||||
cmp byte [esi],1Ah
|
cmp byte [esi],1Ah
|
||||||
jne empty_instruction
|
jne empty_instruction
|
||||||
push edi
|
push edi
|
||||||
@ -529,15 +530,20 @@ parse_line_contents:
|
|||||||
cmp al,']'
|
cmp al,']'
|
||||||
je separator
|
je separator
|
||||||
cmp al,'{'
|
cmp al,'{'
|
||||||
je unallowed_character
|
je open_decorator
|
||||||
cmp al,'}'
|
cmp al,'}'
|
||||||
je unallowed_character
|
je close_decorator
|
||||||
cmp al,'#'
|
cmp al,'#'
|
||||||
je unallowed_character
|
je unallowed_character
|
||||||
cmp al,'`'
|
cmp al,'`'
|
||||||
je unallowed_character
|
je unallowed_character
|
||||||
cmp al,3Bh
|
cmp al,3Bh
|
||||||
je foreign_argument
|
je foreign_argument
|
||||||
|
cmp [decorator_symbols_allowed],0
|
||||||
|
je not_a_separator
|
||||||
|
cmp al,'-'
|
||||||
|
je separator
|
||||||
|
not_a_separator:
|
||||||
dec esi
|
dec esi
|
||||||
cmp al,1Ah
|
cmp al,1Ah
|
||||||
jne expression_argument
|
jne expression_argument
|
||||||
@ -825,7 +831,7 @@ parse_line_contents:
|
|||||||
jb stack_overflow
|
jb stack_overflow
|
||||||
push esi edi
|
push esi edi
|
||||||
inc esi
|
inc esi
|
||||||
mov al,'{'
|
mov al,91h
|
||||||
stos byte [edi]
|
stos byte [edi]
|
||||||
inc [parenthesis_stack]
|
inc [parenthesis_stack]
|
||||||
jmp parse_argument
|
jmp parse_argument
|
||||||
@ -879,10 +885,16 @@ parse_line_contents:
|
|||||||
lods byte [esi]
|
lods byte [esi]
|
||||||
cmp al,']'
|
cmp al,']'
|
||||||
je address_parsed
|
je address_parsed
|
||||||
|
cmp al,','
|
||||||
|
je divided_address
|
||||||
dec esi
|
dec esi
|
||||||
mov al,')'
|
mov al,')'
|
||||||
stos byte [edi]
|
stos byte [edi]
|
||||||
jmp argument_parsed
|
jmp argument_parsed
|
||||||
|
divided_address:
|
||||||
|
mov ax,'),'
|
||||||
|
stos word [edi]
|
||||||
|
jmp expression
|
||||||
address_parsed:
|
address_parsed:
|
||||||
mov al,']'
|
mov al,']'
|
||||||
stos byte [edi]
|
stos byte [edi]
|
||||||
@ -908,8 +920,9 @@ parse_line_contents:
|
|||||||
jne unknown_segment_prefix
|
jne unknown_segment_prefix
|
||||||
mov al,ah
|
mov al,ah
|
||||||
and ah,11110000b
|
and ah,11110000b
|
||||||
cmp ah,60h
|
cmp ah,30h
|
||||||
jne unknown_segment_prefix
|
jne unknown_segment_prefix
|
||||||
|
add al,30h
|
||||||
stos byte [edi]
|
stos byte [edi]
|
||||||
jmp convert_address
|
jmp convert_address
|
||||||
unknown_segment_prefix:
|
unknown_segment_prefix:
|
||||||
@ -928,13 +941,19 @@ parse_line_contents:
|
|||||||
cmp byte [esi],'('
|
cmp byte [esi],'('
|
||||||
jne argument_parsed
|
jne argument_parsed
|
||||||
inc esi
|
inc esi
|
||||||
mov al,'{'
|
mov al,91h
|
||||||
jmp separator
|
jmp separator
|
||||||
unallowed_character:
|
unallowed_character:
|
||||||
mov al,0FFh
|
mov al,0FFh
|
||||||
jmp separator
|
jmp separator
|
||||||
|
open_decorator:
|
||||||
|
inc [decorator_symbols_allowed]
|
||||||
|
jmp separator
|
||||||
|
close_decorator:
|
||||||
|
dec [decorator_symbols_allowed]
|
||||||
|
jmp separator
|
||||||
close_parenthesis:
|
close_parenthesis:
|
||||||
mov al,'}'
|
mov al,92h
|
||||||
separator:
|
separator:
|
||||||
stos byte [edi]
|
stos byte [edi]
|
||||||
argument_parsed:
|
argument_parsed:
|
||||||
@ -1049,7 +1068,7 @@ get_symbol:
|
|||||||
mov ecx,ebp
|
mov ecx,ebp
|
||||||
cmp cl,11
|
cmp cl,11
|
||||||
ja no_symbol
|
ja no_symbol
|
||||||
sub cl,2
|
sub cl,1
|
||||||
jc no_symbol
|
jc no_symbol
|
||||||
movzx ebx,word [symbols+ecx*4]
|
movzx ebx,word [symbols+ecx*4]
|
||||||
add ebx,symbols
|
add ebx,symbols
|
||||||
@ -1070,6 +1089,8 @@ get_symbol:
|
|||||||
mov ax,[edi]
|
mov ax,[edi]
|
||||||
cmp al,18h
|
cmp al,18h
|
||||||
jb symbol_ok
|
jb symbol_ok
|
||||||
|
cmp al,1Fh
|
||||||
|
je decorator_symbol
|
||||||
cmp [formatter_symbols_allowed],0
|
cmp [formatter_symbols_allowed],0
|
||||||
je no_symbol
|
je no_symbol
|
||||||
symbol_ok:
|
symbol_ok:
|
||||||
@ -1077,6 +1098,9 @@ get_symbol:
|
|||||||
add esi,ebp
|
add esi,ebp
|
||||||
clc
|
clc
|
||||||
ret
|
ret
|
||||||
|
decorator_symbol:
|
||||||
|
cmp [decorator_symbols_allowed],0
|
||||||
|
jne symbol_ok
|
||||||
no_symbol:
|
no_symbol:
|
||||||
pop esi
|
pop esi
|
||||||
mov ecx,ebp
|
mov ecx,ebp
|
||||||
@ -1258,7 +1282,7 @@ get_label_id:
|
|||||||
inc esi
|
inc esi
|
||||||
cmp byte [esi-1],'$'
|
cmp byte [esi-1],'$'
|
||||||
je get_org_origin_id
|
je get_org_origin_id
|
||||||
sub esi,ecx
|
sub esi,2
|
||||||
jmp find_label
|
jmp find_label
|
||||||
get_current_offset_id:
|
get_current_offset_id:
|
||||||
xor eax,eax
|
xor eax,eax
|
||||||
@ -1363,12 +1387,12 @@ get_label_id:
|
|||||||
cmp al,30h
|
cmp al,30h
|
||||||
jb name_first_char_ok
|
jb name_first_char_ok
|
||||||
cmp al,39h
|
cmp al,39h
|
||||||
jbe invalid_name
|
jbe numeric_name
|
||||||
name_first_char_ok:
|
name_first_char_ok:
|
||||||
cmp al,'$'
|
cmp al,'$'
|
||||||
jne check_for_reserved_word
|
jne check_for_reserved_word
|
||||||
cmp ecx,1
|
numeric_name:
|
||||||
jne invalid_name
|
add esi,ecx
|
||||||
reserved_word:
|
reserved_word:
|
||||||
mov eax,0Fh
|
mov eax,0Fh
|
||||||
pop edi
|
pop edi
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
; flat assembler core
|
; flat assembler core
|
||||||
; Copyright (c) 1999-2013, Tomasz Grysztar.
|
; Copyright (c) 1999-2016, Tomasz Grysztar.
|
||||||
; All rights reserved.
|
; All rights reserved.
|
||||||
|
|
||||||
preprocessor:
|
preprocessor:
|
||||||
@ -42,6 +42,150 @@ preprocessor:
|
|||||||
mov [hash_tree],eax
|
mov [hash_tree],eax
|
||||||
mov [error],eax
|
mov [error],eax
|
||||||
mov [macro_status],al
|
mov [macro_status],al
|
||||||
|
mov [current_line],eax
|
||||||
|
mov esi,[initial_definitions]
|
||||||
|
test esi,esi
|
||||||
|
jz predefinitions_ok
|
||||||
|
process_predefinitions:
|
||||||
|
movzx ecx,byte [esi]
|
||||||
|
test ecx,ecx
|
||||||
|
jz predefinitions_ok
|
||||||
|
inc esi
|
||||||
|
lea eax,[esi+ecx]
|
||||||
|
push eax
|
||||||
|
mov ch,10b
|
||||||
|
call add_preprocessor_symbol
|
||||||
|
pop esi
|
||||||
|
mov edi,[memory_start]
|
||||||
|
mov [edx+8],edi
|
||||||
|
convert_predefinition:
|
||||||
|
cmp edi,[memory_end]
|
||||||
|
jae out_of_memory
|
||||||
|
lods byte [esi]
|
||||||
|
or al,al
|
||||||
|
jz predefinition_converted
|
||||||
|
cmp al,20h
|
||||||
|
je convert_predefinition
|
||||||
|
mov ah,al
|
||||||
|
mov ebx,characters
|
||||||
|
xlat byte [ebx]
|
||||||
|
or al,al
|
||||||
|
jz predefinition_separator
|
||||||
|
cmp ah,27h
|
||||||
|
je predefinition_string
|
||||||
|
cmp ah,22h
|
||||||
|
je predefinition_string
|
||||||
|
mov byte [edi],1Ah
|
||||||
|
scas word [edi]
|
||||||
|
xchg al,ah
|
||||||
|
stos byte [edi]
|
||||||
|
mov ebx,characters
|
||||||
|
xor ecx,ecx
|
||||||
|
predefinition_symbol:
|
||||||
|
lods byte [esi]
|
||||||
|
stos byte [edi]
|
||||||
|
xlat byte [ebx]
|
||||||
|
or al,al
|
||||||
|
loopnzd predefinition_symbol
|
||||||
|
neg ecx
|
||||||
|
cmp ecx,255
|
||||||
|
ja invalid_definition
|
||||||
|
mov ebx,edi
|
||||||
|
sub ebx,ecx
|
||||||
|
mov byte [ebx-2],cl
|
||||||
|
found_predefinition_separator:
|
||||||
|
dec edi
|
||||||
|
mov ah,[esi-1]
|
||||||
|
predefinition_separator:
|
||||||
|
xchg al,ah
|
||||||
|
or al,al
|
||||||
|
jz predefinition_converted
|
||||||
|
cmp al,20h
|
||||||
|
je convert_predefinition
|
||||||
|
cmp al,3Bh
|
||||||
|
je invalid_definition
|
||||||
|
cmp al,5Ch
|
||||||
|
je predefinition_backslash
|
||||||
|
stos byte [edi]
|
||||||
|
jmp convert_predefinition
|
||||||
|
predefinition_string:
|
||||||
|
mov al,22h
|
||||||
|
stos byte [edi]
|
||||||
|
scas dword [edi]
|
||||||
|
mov ebx,edi
|
||||||
|
copy_predefinition_string:
|
||||||
|
lods byte [esi]
|
||||||
|
stos byte [edi]
|
||||||
|
or al,al
|
||||||
|
jz invalid_definition
|
||||||
|
cmp al,ah
|
||||||
|
jne copy_predefinition_string
|
||||||
|
lods byte [esi]
|
||||||
|
cmp al,ah
|
||||||
|
je copy_predefinition_string
|
||||||
|
dec esi
|
||||||
|
dec edi
|
||||||
|
mov eax,edi
|
||||||
|
sub eax,ebx
|
||||||
|
mov [ebx-4],eax
|
||||||
|
jmp convert_predefinition
|
||||||
|
predefinition_backslash:
|
||||||
|
mov byte [edi],0
|
||||||
|
lods byte [esi]
|
||||||
|
or al,al
|
||||||
|
jz invalid_definition
|
||||||
|
cmp al,20h
|
||||||
|
je invalid_definition
|
||||||
|
cmp al,3Bh
|
||||||
|
je invalid_definition
|
||||||
|
mov al,1Ah
|
||||||
|
stos byte [edi]
|
||||||
|
mov ecx,edi
|
||||||
|
mov ax,5C01h
|
||||||
|
stos word [edi]
|
||||||
|
dec esi
|
||||||
|
group_predefinition_backslashes:
|
||||||
|
lods byte [esi]
|
||||||
|
cmp al,5Ch
|
||||||
|
jne predefinition_backslashed_symbol
|
||||||
|
stos byte [edi]
|
||||||
|
inc byte [ecx]
|
||||||
|
jmp group_predefinition_backslashes
|
||||||
|
predefinition_backslashed_symbol:
|
||||||
|
cmp al,20h
|
||||||
|
je invalid_definition
|
||||||
|
cmp al,22h
|
||||||
|
je invalid_definition
|
||||||
|
cmp al,27h
|
||||||
|
je invalid_definition
|
||||||
|
cmp al,3Bh
|
||||||
|
je invalid_definition
|
||||||
|
mov ah,al
|
||||||
|
mov ebx,characters
|
||||||
|
xlat byte [ebx]
|
||||||
|
or al,al
|
||||||
|
jz predefinition_backslashed_symbol_character
|
||||||
|
mov al,ah
|
||||||
|
convert_predefinition_backslashed_symbol:
|
||||||
|
stos byte [edi]
|
||||||
|
xlat byte [ebx]
|
||||||
|
or al,al
|
||||||
|
jz found_predefinition_separator
|
||||||
|
inc byte [ecx]
|
||||||
|
jz invalid_definition
|
||||||
|
lods byte [esi]
|
||||||
|
jmp convert_predefinition_backslashed_symbol
|
||||||
|
predefinition_backslashed_symbol_character:
|
||||||
|
mov al,ah
|
||||||
|
stos byte [edi]
|
||||||
|
inc byte [ecx]
|
||||||
|
jmp convert_predefinition
|
||||||
|
predefinition_converted:
|
||||||
|
mov [memory_start],edi
|
||||||
|
sub edi,[edx+8]
|
||||||
|
mov [edx+12],edi
|
||||||
|
jmp process_predefinitions
|
||||||
|
predefinitions_ok:
|
||||||
mov esi,[input_file]
|
mov esi,[input_file]
|
||||||
mov edx,esi
|
mov edx,esi
|
||||||
call open
|
call open
|
||||||
@ -78,7 +222,11 @@ preprocessor:
|
|||||||
mov [ebx],eax
|
mov [ebx],eax
|
||||||
call use_postponed_macro
|
call use_postponed_macro
|
||||||
pop edx
|
pop edx
|
||||||
jmp process_postponed_list
|
cmp [macro_status],0
|
||||||
|
je process_postponed_list
|
||||||
|
mov eax,[error_line]
|
||||||
|
mov [current_line],eax
|
||||||
|
jmp incomplete_macro
|
||||||
preprocessing_finished:
|
preprocessing_finished:
|
||||||
mov [source_start],edi
|
mov [source_start],edi
|
||||||
ret
|
ret
|
||||||
@ -275,6 +423,7 @@ convert_line:
|
|||||||
jne backslashed_symbol
|
jne backslashed_symbol
|
||||||
stos byte [edi]
|
stos byte [edi]
|
||||||
inc byte [ecx]
|
inc byte [ecx]
|
||||||
|
jz name_too_long
|
||||||
jmp group_backslashes
|
jmp group_backslashes
|
||||||
no_end_quote:
|
no_end_quote:
|
||||||
mov byte [ebx-5],0
|
mov byte [ebx-5],0
|
||||||
@ -896,6 +1045,8 @@ define_macro:
|
|||||||
inc esi
|
inc esi
|
||||||
add esi,eax
|
add esi,eax
|
||||||
lods byte [esi]
|
lods byte [esi]
|
||||||
|
cmp al,':'
|
||||||
|
je macro_argument_with_default_value
|
||||||
cmp al,'='
|
cmp al,'='
|
||||||
je macro_argument_with_default_value
|
je macro_argument_with_default_value
|
||||||
cmp al,'*'
|
cmp al,'*'
|
||||||
@ -904,10 +1055,13 @@ define_macro:
|
|||||||
macro_argument_end:
|
macro_argument_end:
|
||||||
cmp al,','
|
cmp al,','
|
||||||
je skip_macro_arguments
|
je skip_macro_arguments
|
||||||
|
cmp al,'&'
|
||||||
|
je macro_arguments_finisher
|
||||||
cmp al,']'
|
cmp al,']'
|
||||||
jne end_macro_arguments
|
jne end_macro_arguments
|
||||||
lods byte [esi]
|
|
||||||
not ebp
|
not ebp
|
||||||
|
macro_arguments_finisher:
|
||||||
|
lods byte [esi]
|
||||||
end_macro_arguments:
|
end_macro_arguments:
|
||||||
or ebp,ebp
|
or ebp,ebp
|
||||||
jnz invalid_macro_arguments
|
jnz invalid_macro_arguments
|
||||||
@ -917,7 +1071,7 @@ define_macro:
|
|||||||
je found_macro_block
|
je found_macro_block
|
||||||
jmp invalid_macro_arguments
|
jmp invalid_macro_arguments
|
||||||
macro_argument_with_default_value:
|
macro_argument_with_default_value:
|
||||||
or [default_argument_value],-1
|
or [skip_default_argument_value],-1
|
||||||
call skip_macro_argument_value
|
call skip_macro_argument_value
|
||||||
inc esi
|
inc esi
|
||||||
jmp macro_argument_end
|
jmp macro_argument_end
|
||||||
@ -956,10 +1110,12 @@ define_macro:
|
|||||||
jz argument_value_end
|
jz argument_value_end
|
||||||
cmp al,','
|
cmp al,','
|
||||||
je argument_value_end
|
je argument_value_end
|
||||||
cmp [default_argument_value],0
|
cmp [skip_default_argument_value],0
|
||||||
je invalid_macro_arguments
|
je invalid_macro_arguments
|
||||||
cmp al,'{'
|
cmp al,'{'
|
||||||
je argument_value_end
|
je argument_value_end
|
||||||
|
cmp al,'&'
|
||||||
|
je argument_value_end
|
||||||
or ebp,ebp
|
or ebp,ebp
|
||||||
jz invalid_macro_arguments
|
jz invalid_macro_arguments
|
||||||
cmp al,']'
|
cmp al,']'
|
||||||
@ -975,10 +1131,12 @@ define_macro:
|
|||||||
je argument_string
|
je argument_string
|
||||||
cmp al,1Ah
|
cmp al,1Ah
|
||||||
je argument_symbol
|
je argument_symbol
|
||||||
cmp [default_argument_value],0
|
cmp [skip_default_argument_value],0
|
||||||
je simple_argument
|
je simple_argument
|
||||||
cmp al,'{'
|
cmp al,'{'
|
||||||
je argument_value_end
|
je argument_value_end
|
||||||
|
cmp al,'&'
|
||||||
|
je argument_value_end
|
||||||
or ebp,ebp
|
or ebp,ebp
|
||||||
jz simple_argument
|
jz simple_argument
|
||||||
cmp al,']'
|
cmp al,']'
|
||||||
@ -1056,6 +1214,7 @@ postpone_directive:
|
|||||||
xor ecx,ecx
|
xor ecx,ecx
|
||||||
call add_preprocessor_symbol
|
call add_preprocessor_symbol
|
||||||
mov eax,[current_line]
|
mov eax,[current_line]
|
||||||
|
mov [error_line],eax
|
||||||
mov [edx+12],eax
|
mov [edx+12],eax
|
||||||
pop esi
|
pop esi
|
||||||
mov [edx+8],esi
|
mov [edx+8],esi
|
||||||
@ -1063,8 +1222,6 @@ postpone_directive:
|
|||||||
and al,0F0h
|
and al,0F0h
|
||||||
or al,1
|
or al,1
|
||||||
mov [macro_status],al
|
mov [macro_status],al
|
||||||
mov eax,[current_line]
|
|
||||||
mov [error_line],eax
|
|
||||||
lods byte [esi]
|
lods byte [esi]
|
||||||
or al,al
|
or al,al
|
||||||
jz line_preprocessed
|
jz line_preprocessed
|
||||||
@ -1080,6 +1237,9 @@ irp_directive:
|
|||||||
irps_directive:
|
irps_directive:
|
||||||
mov [base_code],2
|
mov [base_code],2
|
||||||
jmp define_instant_macro
|
jmp define_instant_macro
|
||||||
|
irpv_directive:
|
||||||
|
mov [base_code],3
|
||||||
|
jmp define_instant_macro
|
||||||
match_directive:
|
match_directive:
|
||||||
mov [base_code],10h
|
mov [base_code],10h
|
||||||
define_instant_macro:
|
define_instant_macro:
|
||||||
@ -1555,6 +1715,8 @@ use_macro:
|
|||||||
je next_argument
|
je next_argument
|
||||||
cmp al,']'
|
cmp al,']'
|
||||||
je next_arguments_group
|
je next_arguments_group
|
||||||
|
cmp al,'&'
|
||||||
|
je arguments_end
|
||||||
dec esi
|
dec esi
|
||||||
jmp arguments_end
|
jmp arguments_end
|
||||||
next_argument:
|
next_argument:
|
||||||
@ -1575,19 +1737,50 @@ use_macro:
|
|||||||
mov eax,[counter_limit]
|
mov eax,[counter_limit]
|
||||||
call add_macro_symbol
|
call add_macro_symbol
|
||||||
add esi,ecx
|
add esi,ecx
|
||||||
|
xor eax,eax
|
||||||
|
mov [default_argument_value],eax
|
||||||
|
cmp byte [esi],'*'
|
||||||
|
je required_value
|
||||||
|
cmp byte [esi],':'
|
||||||
|
je get_default_value
|
||||||
|
cmp byte [esi],'='
|
||||||
|
jne default_value_ok
|
||||||
|
get_default_value:
|
||||||
|
inc esi
|
||||||
|
mov [default_argument_value],esi
|
||||||
|
or [skip_default_argument_value],-1
|
||||||
|
call skip_macro_argument_value
|
||||||
|
jmp default_value_ok
|
||||||
|
required_value:
|
||||||
|
inc esi
|
||||||
|
or [default_argument_value],-1
|
||||||
|
default_value_ok:
|
||||||
xchg esi,ebx
|
xchg esi,ebx
|
||||||
mov [edx+12],esi
|
mov [edx+12],esi
|
||||||
mov [default_argument_value],0
|
mov [skip_default_argument_value],0
|
||||||
|
cmp byte [ebx],'&'
|
||||||
|
je greedy_macro_argument
|
||||||
call skip_macro_argument_value
|
call skip_macro_argument_value
|
||||||
call finish_macro_argument
|
call finish_macro_argument
|
||||||
|
jmp got_macro_argument
|
||||||
|
greedy_macro_argument:
|
||||||
|
call skip_foreign_line
|
||||||
|
dec esi
|
||||||
|
mov eax,[edx+12]
|
||||||
|
mov ecx,esi
|
||||||
|
sub ecx,eax
|
||||||
|
mov [edx+8],ecx
|
||||||
|
got_macro_argument:
|
||||||
xchg esi,ebx
|
xchg esi,ebx
|
||||||
cmp byte [esi],'='
|
|
||||||
je argument_with_default_value
|
|
||||||
cmp byte [esi],'*'
|
|
||||||
jne macro_argument_ok
|
|
||||||
cmp dword [edx+8],0
|
cmp dword [edx+8],0
|
||||||
|
jne macro_argument_ok
|
||||||
|
mov eax,[default_argument_value]
|
||||||
|
or eax,eax
|
||||||
|
jz macro_argument_ok
|
||||||
|
cmp eax,-1
|
||||||
je invalid_macro_arguments
|
je invalid_macro_arguments
|
||||||
inc esi
|
mov [edx+12],eax
|
||||||
|
call finish_macro_argument
|
||||||
macro_argument_ok:
|
macro_argument_ok:
|
||||||
ret
|
ret
|
||||||
finish_macro_argument:
|
finish_macro_argument:
|
||||||
@ -1602,17 +1795,6 @@ use_macro:
|
|||||||
argument_value_length_ok:
|
argument_value_length_ok:
|
||||||
mov [edx+8],ecx
|
mov [edx+8],ecx
|
||||||
ret
|
ret
|
||||||
argument_with_default_value:
|
|
||||||
inc esi
|
|
||||||
push esi
|
|
||||||
or [default_argument_value],-1
|
|
||||||
call skip_macro_argument_value
|
|
||||||
pop eax
|
|
||||||
cmp dword [edx+8],0
|
|
||||||
jne macro_argument_ok
|
|
||||||
mov [edx+12],eax
|
|
||||||
call finish_macro_argument
|
|
||||||
jmp macro_argument_ok
|
|
||||||
arguments_end:
|
arguments_end:
|
||||||
cmp byte [ebx],0
|
cmp byte [ebx],0
|
||||||
jne invalid_macro_arguments
|
jne invalid_macro_arguments
|
||||||
@ -1738,6 +1920,8 @@ do_irp:
|
|||||||
lods byte [esi]
|
lods byte [esi]
|
||||||
cmp [base_code],1
|
cmp [base_code],1
|
||||||
ja irps_name_ok
|
ja irps_name_ok
|
||||||
|
cmp al,':'
|
||||||
|
je irp_with_default_value
|
||||||
cmp al,'='
|
cmp al,'='
|
||||||
je irp_with_default_value
|
je irp_with_default_value
|
||||||
cmp al,'*'
|
cmp al,'*'
|
||||||
@ -1749,13 +1933,17 @@ do_irp:
|
|||||||
jmp irp_parameters_start
|
jmp irp_parameters_start
|
||||||
irp_with_default_value:
|
irp_with_default_value:
|
||||||
xor ebp,ebp
|
xor ebp,ebp
|
||||||
or [default_argument_value],-1
|
or [skip_default_argument_value],-1
|
||||||
call skip_macro_argument_value
|
call skip_macro_argument_value
|
||||||
|
cmp byte [esi],','
|
||||||
|
jne invalid_macro_arguments
|
||||||
inc esi
|
inc esi
|
||||||
jmp irp_parameters_start
|
jmp irp_parameters_start
|
||||||
irps_name_ok:
|
irps_name_ok:
|
||||||
cmp al,','
|
cmp al,','
|
||||||
jne invalid_macro_arguments
|
jne invalid_macro_arguments
|
||||||
|
cmp [base_code],3
|
||||||
|
je irp_parameters_start
|
||||||
mov al,[esi]
|
mov al,[esi]
|
||||||
or al,al
|
or al,al
|
||||||
jz instant_macro_done
|
jz instant_macro_done
|
||||||
@ -1769,9 +1957,11 @@ do_irp:
|
|||||||
push [counter_limit]
|
push [counter_limit]
|
||||||
mov [counter_limit],eax
|
mov [counter_limit],eax
|
||||||
mov [struc_name],eax
|
mov [struc_name],eax
|
||||||
|
cmp [base_code],3
|
||||||
|
je get_irpv_parameter
|
||||||
mov ebx,esi
|
mov ebx,esi
|
||||||
cmp [base_code],1
|
cmp [base_code],2
|
||||||
ja get_irps_parameter
|
je get_irps_parameter
|
||||||
mov edx,[parameters_end]
|
mov edx,[parameters_end]
|
||||||
mov al,[edx]
|
mov al,[edx]
|
||||||
push eax
|
push eax
|
||||||
@ -1822,6 +2012,70 @@ do_irp:
|
|||||||
irps_parameters_end:
|
irps_parameters_end:
|
||||||
mov esi,ebx
|
mov esi,ebx
|
||||||
jmp instant_macro_parameters_ok
|
jmp instant_macro_parameters_ok
|
||||||
|
get_irpv_parameter:
|
||||||
|
lods byte [esi]
|
||||||
|
cmp al,1Ah
|
||||||
|
jne invalid_macro_arguments
|
||||||
|
lods byte [esi]
|
||||||
|
mov ebp,esi
|
||||||
|
mov cl,al
|
||||||
|
mov ch,10b
|
||||||
|
call get_preprocessor_symbol
|
||||||
|
jc instant_macro_finish
|
||||||
|
push edx
|
||||||
|
mark_variable_value:
|
||||||
|
inc [counter_limit]
|
||||||
|
mov [edx+4],ebp
|
||||||
|
next_variable_value:
|
||||||
|
mov edx,[edx]
|
||||||
|
or edx,edx
|
||||||
|
jz variable_values_marked
|
||||||
|
mov eax,[edx+4]
|
||||||
|
cmp eax,1
|
||||||
|
jbe next_variable_value
|
||||||
|
mov esi,ebp
|
||||||
|
movzx ecx,byte [esi-1]
|
||||||
|
xchg edi,eax
|
||||||
|
repe cmps byte [esi],[edi]
|
||||||
|
xchg edi,eax
|
||||||
|
je mark_variable_value
|
||||||
|
jmp next_variable_value
|
||||||
|
variable_values_marked:
|
||||||
|
pop edx
|
||||||
|
push [counter_limit]
|
||||||
|
add_irpv_value:
|
||||||
|
push edx
|
||||||
|
mov esi,[instant_macro_start]
|
||||||
|
inc esi
|
||||||
|
lods byte [esi]
|
||||||
|
movzx ecx,al
|
||||||
|
mov eax,[esp+4]
|
||||||
|
call add_macro_symbol
|
||||||
|
mov ebx,edx
|
||||||
|
pop edx
|
||||||
|
mov ecx,[edx+12]
|
||||||
|
mov eax,[edx+8]
|
||||||
|
mov [ebx+12],eax
|
||||||
|
mov [ebx+8],ecx
|
||||||
|
collect_next_variable_value:
|
||||||
|
mov edx,[edx]
|
||||||
|
or edx,edx
|
||||||
|
jz variable_values_collected
|
||||||
|
cmp ebp,[edx+4]
|
||||||
|
jne collect_next_variable_value
|
||||||
|
dec dword [esp]
|
||||||
|
jnz add_irpv_value
|
||||||
|
variable_values_collected:
|
||||||
|
pop eax
|
||||||
|
mov esi,ebp
|
||||||
|
movzx ecx,byte [esi-1]
|
||||||
|
add esi,ecx
|
||||||
|
cmp byte [esi],0
|
||||||
|
je instant_macro_parameters_ok
|
||||||
|
cmp byte [esi],'{'
|
||||||
|
jne invalid_macro_arguments
|
||||||
|
jmp instant_macro_parameters_ok
|
||||||
|
|
||||||
do_match:
|
do_match:
|
||||||
mov ebx,esi
|
mov ebx,esi
|
||||||
call skip_pattern
|
call skip_pattern
|
||||||
@ -2451,6 +2705,8 @@ reverse_block:
|
|||||||
mov [macro_block_line_number],ecx
|
mov [macro_block_line_number],ecx
|
||||||
jmp process_macro_line
|
jmp process_macro_line
|
||||||
close_macro_block:
|
close_macro_block:
|
||||||
|
cmp esi,[macro_block]
|
||||||
|
je block_closed
|
||||||
cmp [counter],0
|
cmp [counter],0
|
||||||
je block_closed
|
je block_closed
|
||||||
jl reverse_counter
|
jl reverse_counter
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
; flat assembler core
|
; flat assembler core
|
||||||
; Copyright (c) 1999-2013, Tomasz Grysztar.
|
; Copyright (c) 1999-2016, Tomasz Grysztar.
|
||||||
; All rights reserved.
|
; All rights reserved.
|
||||||
|
|
||||||
dump_symbols:
|
dump_symbols:
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
; flat assembler core variables
|
; flat assembler core variables
|
||||||
; Copyright (c) 1999-2013, Tomasz Grysztar.
|
; Copyright (c) 1999-2016, Tomasz Grysztar.
|
||||||
; All rights reserved.
|
; All rights reserved.
|
||||||
|
|
||||||
; Variables which have to be set up by interface:
|
; Variables which have to be set up by interface:
|
||||||
@ -13,6 +13,7 @@ additional_memory_end dd ?
|
|||||||
|
|
||||||
stack_limit dd ?
|
stack_limit dd ?
|
||||||
|
|
||||||
|
initial_definitions dd ?
|
||||||
input_file dd ?
|
input_file dd ?
|
||||||
output_file dd ?
|
output_file dd ?
|
||||||
symbols_file dd ?
|
symbols_file dd ?
|
||||||
@ -42,6 +43,7 @@ struc_name dd ?
|
|||||||
struc_label dd ?
|
struc_label dd ?
|
||||||
instant_macro_start dd ?
|
instant_macro_start dd ?
|
||||||
parameters_end dd ?
|
parameters_end dd ?
|
||||||
|
default_argument_value dd ?
|
||||||
locals_counter rb 8
|
locals_counter rb 8
|
||||||
current_locals_prefix dd ?
|
current_locals_prefix dd ?
|
||||||
anonymous_reverse dd ?
|
anonymous_reverse dd ?
|
||||||
@ -68,6 +70,7 @@ adjustment dq ?
|
|||||||
symbol_identifier dd ?
|
symbol_identifier dd ?
|
||||||
address_symbol dd ?
|
address_symbol dd ?
|
||||||
address_high dd ?
|
address_high dd ?
|
||||||
|
uncompressed_displacement dd ?
|
||||||
format_flags dd ?
|
format_flags dd ?
|
||||||
resolver_flags dd ?
|
resolver_flags dd ?
|
||||||
symbols_stream dd ?
|
symbols_stream dd ?
|
||||||
@ -87,6 +90,7 @@ actual_fixups_size dd ?
|
|||||||
reserved_fixups dd ?
|
reserved_fixups dd ?
|
||||||
reserved_fixups_size dd ?
|
reserved_fixups_size dd ?
|
||||||
last_fixup_base dd ?
|
last_fixup_base dd ?
|
||||||
|
last_fixup_header dd ?
|
||||||
parenthesis_stack dd ?
|
parenthesis_stack dd ?
|
||||||
blocks_stack dd ?
|
blocks_stack dd ?
|
||||||
parsed_lines dd ?
|
parsed_lines dd ?
|
||||||
@ -94,13 +98,16 @@ logical_value_parentheses dd ?
|
|||||||
file_extension dd ?
|
file_extension dd ?
|
||||||
|
|
||||||
operand_size db ?
|
operand_size db ?
|
||||||
size_override db ?
|
operand_flags db ?
|
||||||
operand_prefix db ?
|
operand_prefix db ?
|
||||||
opcode_prefix db ?
|
|
||||||
rex_prefix db ?
|
rex_prefix db ?
|
||||||
|
opcode_prefix db ?
|
||||||
vex_required db ?
|
vex_required db ?
|
||||||
vex_register db ?
|
vex_register db ?
|
||||||
immediate_size db ?
|
immediate_size db ?
|
||||||
|
mask_register db ?
|
||||||
|
broadcast_size db ?
|
||||||
|
rounding_mode db ?
|
||||||
|
|
||||||
base_code db ?
|
base_code db ?
|
||||||
extended_code db ?
|
extended_code db ?
|
||||||
@ -116,6 +123,8 @@ value_size db ?
|
|||||||
address_size db ?
|
address_size db ?
|
||||||
label_size db ?
|
label_size db ?
|
||||||
size_declared db ?
|
size_declared db ?
|
||||||
|
address_size_declared db ?
|
||||||
|
displacement_compression db ?
|
||||||
|
|
||||||
value_undefined db ?
|
value_undefined db ?
|
||||||
value_constant db ?
|
value_constant db ?
|
||||||
@ -124,17 +133,20 @@ value_sign db ?
|
|||||||
fp_sign db ?
|
fp_sign db ?
|
||||||
fp_format db ?
|
fp_format db ?
|
||||||
address_sign db ?
|
address_sign db ?
|
||||||
|
address_register db ?
|
||||||
compare_type db ?
|
compare_type db ?
|
||||||
logical_value_wrapping db ?
|
logical_value_wrapping db ?
|
||||||
next_pass_needed db ?
|
next_pass_needed db ?
|
||||||
output_format db ?
|
output_format db ?
|
||||||
code_type db ?
|
code_type db ?
|
||||||
adjustment_sign db ?
|
adjustment_sign db ?
|
||||||
|
evex_mode db ?
|
||||||
|
|
||||||
macro_status db ?
|
macro_status db ?
|
||||||
default_argument_value db ?
|
skip_default_argument_value db ?
|
||||||
prefixed_instruction db ?
|
prefix_flags db ?
|
||||||
formatter_symbols_allowed db ?
|
formatter_symbols_allowed db ?
|
||||||
|
decorator_symbols_allowed db ?
|
||||||
free_address_range db ?
|
free_address_range db ?
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
; flat assembler version 1.71
|
; flat assembler version 1.71
|
||||||
; Copyright (c) 1999-2013, Tomasz Grysztar.
|
; Copyright (c) 1999-2016, Tomasz Grysztar.
|
||||||
; All rights reserved.
|
; All rights reserved.
|
||||||
;
|
;
|
||||||
; This programs is free for commercial and non-commercial use as long as
|
; 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
|
; cannot simply be copied and put under another distribution licence
|
||||||
; (including the GNU Public Licence).
|
; (including the GNU Public Licence).
|
||||||
|
|
||||||
VERSION_STRING equ "1.71.16"
|
VERSION_STRING equ "1.71.54"
|
||||||
|
|
||||||
VERSION_MAJOR = 1
|
VERSION_MAJOR = 1
|
||||||
VERSION_MINOR = 71
|
VERSION_MINOR = 71
|
||||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user