mirror of
https://github.com/KolibriOS/kolibrios.git
synced 2024-12-22 14:52:39 +03:00
fasm 1.71.13, proc32.inc and struct.inc from fasm 1.71.13
git-svn-id: svn://kolibrios.org@4039 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
b7c730f2b9
commit
53cca077c5
@ -1,6 +1,6 @@
|
||||
|
||||
; flat assembler core
|
||||
; Copyright (c) 1999-2012, Tomasz Grysztar.
|
||||
; Copyright (c) 1999-2013, Tomasz Grysztar.
|
||||
; All rights reserved.
|
||||
|
||||
assembler:
|
||||
@ -12,7 +12,7 @@ assembler:
|
||||
mov [actual_fixups_size],eax
|
||||
assembler_loop:
|
||||
mov eax,[labels_list]
|
||||
mov [display_buffer],eax
|
||||
mov [tagged_blocks],eax
|
||||
mov eax,[additional_memory]
|
||||
mov [free_additional_memory],eax
|
||||
mov eax,[additional_memory_end]
|
||||
@ -22,11 +22,7 @@ assembler:
|
||||
xor eax,eax
|
||||
mov dword [adjustment],eax
|
||||
mov dword [adjustment+4],eax
|
||||
mov dword [org_origin],edi
|
||||
mov dword [org_origin+4],eax
|
||||
mov [org_start],edi
|
||||
mov [org_registers],eax
|
||||
mov [org_symbol],eax
|
||||
mov [addressing_space],eax
|
||||
mov [error_line],eax
|
||||
mov [counter],eax
|
||||
mov [format_flags],eax
|
||||
@ -35,18 +31,16 @@ assembler:
|
||||
mov [file_extension],eax
|
||||
mov [next_pass_needed],al
|
||||
mov [output_format],al
|
||||
mov [org_origin_sign],al
|
||||
mov [adjustment_sign],al
|
||||
mov [labels_type],al
|
||||
mov [virtual_data],al
|
||||
mov [code_type],16
|
||||
call init_addressing_space
|
||||
pass_loop:
|
||||
call assemble_line
|
||||
jnc pass_loop
|
||||
mov eax,[additional_memory_end]
|
||||
cmp eax,[structures_buffer]
|
||||
je pass_done
|
||||
sub eax,20h
|
||||
sub eax,18h
|
||||
mov eax,[eax+4]
|
||||
mov [current_line],eax
|
||||
jmp missing_end_directive
|
||||
@ -141,8 +135,36 @@ assembler:
|
||||
assemble_ok:
|
||||
ret
|
||||
|
||||
create_addressing_space:
|
||||
mov ebx,[addressing_space]
|
||||
test ebx,ebx
|
||||
jz init_addressing_space
|
||||
test byte [ebx+0Ah],1
|
||||
jnz illegal_instruction
|
||||
mov eax,edi
|
||||
sub eax,[ebx+18h]
|
||||
mov [ebx+1Ch],eax
|
||||
init_addressing_space:
|
||||
mov ebx,[tagged_blocks]
|
||||
mov dword [ebx-4],10h
|
||||
mov dword [ebx-8],20h
|
||||
sub ebx,8+20h
|
||||
cmp ebx,edi
|
||||
jbe out_of_memory
|
||||
mov [tagged_blocks],ebx
|
||||
mov [addressing_space],ebx
|
||||
xor eax,eax
|
||||
mov [ebx],edi
|
||||
mov [ebx+4],eax
|
||||
mov [ebx+8],eax
|
||||
mov [ebx+10h],eax
|
||||
mov [ebx+14h],eax
|
||||
mov [ebx+18h],edi
|
||||
mov [ebx+1Ch],eax
|
||||
ret
|
||||
|
||||
assemble_line:
|
||||
mov eax,[display_buffer]
|
||||
mov eax,[tagged_blocks]
|
||||
sub eax,100h
|
||||
cmp edi,eax
|
||||
ja out_of_memory
|
||||
@ -153,6 +175,8 @@ assemble_line:
|
||||
cmp al,3
|
||||
jb define_label
|
||||
je define_constant
|
||||
cmp al,4
|
||||
je label_addressing_space
|
||||
cmp al,0Fh
|
||||
je new_line
|
||||
cmp al,13h
|
||||
@ -164,7 +188,7 @@ assemble_line:
|
||||
code_type_setting:
|
||||
lods byte [esi]
|
||||
mov [code_type],al
|
||||
jmp line_assembled
|
||||
jmp instruction_assembled
|
||||
new_line:
|
||||
lods dword [esi]
|
||||
mov [current_line],eax
|
||||
@ -173,30 +197,19 @@ assemble_line:
|
||||
je continue_line
|
||||
cmp [next_pass_needed],0
|
||||
jne continue_line
|
||||
mov ebx,[display_buffer]
|
||||
mov ebx,[tagged_blocks]
|
||||
mov dword [ebx-4],1
|
||||
mov dword [ebx-8],1Ch
|
||||
sub ebx,8+1Ch
|
||||
mov dword [ebx-8],14h
|
||||
sub ebx,8+14h
|
||||
cmp ebx,edi
|
||||
jbe out_of_memory
|
||||
mov [display_buffer],ebx
|
||||
mov [tagged_blocks],ebx
|
||||
mov [ebx],eax
|
||||
mov [ebx+4],edi
|
||||
mov eax,dword [org_origin]
|
||||
mov edx,dword [org_origin+4]
|
||||
mov ecx,[org_registers]
|
||||
mov eax,[addressing_space]
|
||||
mov [ebx+8],eax
|
||||
mov [ebx+8+4],edx
|
||||
mov [ebx+10h],ecx
|
||||
mov edx,[org_symbol]
|
||||
; mov al,[virtual_data]
|
||||
; mov ah,[org_origin_sign]
|
||||
; shl eax,16
|
||||
; mov al,[labels_type]
|
||||
; mov ah,[code_type]
|
||||
mov eax,dword [labels_type]
|
||||
mov [ebx+14h],edx
|
||||
mov [ebx+18h],eax
|
||||
mov al,[code_type]
|
||||
mov [ebx+10h],al
|
||||
continue_line:
|
||||
cmp byte [esi],0Fh
|
||||
je line_assembled
|
||||
@ -215,15 +228,16 @@ assemble_line:
|
||||
mov eax,edi
|
||||
xor edx,edx
|
||||
xor cl,cl
|
||||
sub eax,dword [org_origin]
|
||||
sbb edx,dword [org_origin+4]
|
||||
sbb cl,[org_origin_sign]
|
||||
mov ebp,[addressing_space]
|
||||
sub eax,[ds:ebp]
|
||||
sbb edx,[ds:ebp+4]
|
||||
sbb cl,[ds:ebp+8]
|
||||
jp label_value_ok
|
||||
call recoverable_overflow
|
||||
label_value_ok:
|
||||
mov [address_sign],cl
|
||||
cmp [virtual_data],0
|
||||
jne make_virtual_label
|
||||
test byte [ds:ebp+0Ah],1
|
||||
jnz make_virtual_label
|
||||
or byte [ebx+9],1
|
||||
xchg eax,[ebx]
|
||||
xchg edx,[ebx+4]
|
||||
@ -251,10 +265,11 @@ assemble_line:
|
||||
setne al
|
||||
or ah,al
|
||||
finish_label:
|
||||
mov ch,[labels_type]
|
||||
mov ebp,[addressing_space]
|
||||
mov ch,[ds:ebp+9]
|
||||
mov cl,[label_size]
|
||||
mov ebp,[org_registers]
|
||||
mov edx,[org_symbol]
|
||||
mov edx,[ds:ebp+14h]
|
||||
mov ebp,[ds:ebp+10h]
|
||||
finish_label_symbol:
|
||||
mov al,[address_sign]
|
||||
xor al,[ebx+9]
|
||||
@ -289,6 +304,8 @@ assemble_line:
|
||||
jz new_label
|
||||
cmp cx,[ebx+16]
|
||||
je symbol_already_defined
|
||||
btr dword [ebx+8],10
|
||||
jc requalified_label
|
||||
inc cx
|
||||
sub cx,[ebx+16]
|
||||
setnz al
|
||||
@ -299,6 +316,7 @@ assemble_line:
|
||||
mov cx,[current_pass]
|
||||
cmp cx,[ebx+18]
|
||||
jne label_made
|
||||
requalified_label:
|
||||
or [next_pass_needed],-1
|
||||
label_made:
|
||||
ret
|
||||
@ -320,7 +338,7 @@ assemble_line:
|
||||
mov cx,[current_pass]
|
||||
cmp cx,[eax+16]
|
||||
je get_constant_value
|
||||
and dl,not 1
|
||||
or dl,4
|
||||
mov [eax+8],dl
|
||||
get_constant_value:
|
||||
push eax
|
||||
@ -331,10 +349,11 @@ assemble_line:
|
||||
pop ebx
|
||||
mov ch,bl
|
||||
pop ebx
|
||||
pop dword [ebx+8]
|
||||
cmp ebx,0Fh
|
||||
jb invalid_use_of_symbol
|
||||
je reserved_word_used_as_symbol
|
||||
pop ecx
|
||||
test cl,4
|
||||
jnz constant_referencing_mode_ok
|
||||
and byte [ebx+8],not 4
|
||||
constant_referencing_mode_ok:
|
||||
xor cl,cl
|
||||
mov ch,[value_type]
|
||||
cmp ch,3
|
||||
@ -385,8 +404,11 @@ assemble_line:
|
||||
test byte [ebx+8],2
|
||||
jz symbol_already_defined
|
||||
or byte [ebx+8],4
|
||||
and byte [ebx+9],not 4
|
||||
jmp instruction_assembled
|
||||
redeclare_constant:
|
||||
btr dword [ebx+8],10
|
||||
jc requalified_constant
|
||||
inc cx
|
||||
sub cx,[ebx+16]
|
||||
setnz al
|
||||
@ -399,11 +421,37 @@ assemble_line:
|
||||
mov cx,[current_pass]
|
||||
cmp cx,[ebx+18]
|
||||
jne instruction_assembled
|
||||
requalified_constant:
|
||||
or [next_pass_needed],-1
|
||||
jmp instruction_assembled
|
||||
new_constant:
|
||||
or byte [ebx+8],1+2
|
||||
jmp instruction_assembled
|
||||
label_addressing_space:
|
||||
lods dword [esi]
|
||||
cmp eax,0Fh
|
||||
jb invalid_use_of_symbol
|
||||
je reserved_word_used_as_symbol
|
||||
mov cx,[current_pass]
|
||||
test byte [eax+8],1
|
||||
jz make_addressing_space_label
|
||||
cmp cx,[eax+16]
|
||||
je symbol_already_defined
|
||||
test byte [eax+9],4
|
||||
jnz make_addressing_space_label
|
||||
or [next_pass_needed],-1
|
||||
make_addressing_space_label:
|
||||
mov dx,[eax+8]
|
||||
and dx,not (2 or 100h)
|
||||
or dx,1 or 4 or 400h
|
||||
mov [eax+8],dx
|
||||
mov [eax+16],cx
|
||||
mov edx,[current_line]
|
||||
mov [eax+28],edx
|
||||
mov ebx,[addressing_space]
|
||||
mov [eax],ebx
|
||||
or byte [ebx+0Ah],2
|
||||
jmp continue_line
|
||||
assemble_instruction:
|
||||
; mov [operand_size],0
|
||||
; mov [size_override],0
|
||||
@ -446,22 +494,31 @@ org_directive:
|
||||
mov cl,[value_type]
|
||||
test cl,1
|
||||
jnz invalid_use_of_symbol
|
||||
mov [labels_type],cl
|
||||
mov dword [org_origin],edi
|
||||
xor ecx,ecx
|
||||
mov dword [org_origin+4],ecx
|
||||
mov [org_origin_sign],cl
|
||||
mov [org_registers],ecx
|
||||
push eax
|
||||
mov ebx,[addressing_space]
|
||||
mov eax,edi
|
||||
sub eax,[ebx+18h]
|
||||
mov [ebx+1Ch],eax
|
||||
test byte [ebx+0Ah],1
|
||||
jnz in_virtual
|
||||
call init_addressing_space
|
||||
jmp org_space_ok
|
||||
in_virtual:
|
||||
call close_virtual_addressing_space
|
||||
call init_addressing_space
|
||||
or byte [ebx+0Ah],1
|
||||
org_space_ok:
|
||||
pop eax
|
||||
mov [ebx+9],cl
|
||||
mov cl,[value_sign]
|
||||
sub dword [org_origin],eax
|
||||
sbb dword [org_origin+4],edx
|
||||
sbb [org_origin_sign],cl
|
||||
sub [ebx],eax
|
||||
sbb [ebx+4],edx
|
||||
sbb byte [ebx+8],cl
|
||||
jp org_value_ok
|
||||
call recoverable_overflow
|
||||
org_value_ok:
|
||||
mov [org_start],edi
|
||||
mov edx,[symbol_identifier]
|
||||
mov [org_symbol],edx
|
||||
mov [ebx+14h],edx
|
||||
cmp [output_format],1
|
||||
ja instruction_assembled
|
||||
cmp edi,[code_start]
|
||||
@ -502,9 +559,8 @@ label_directive:
|
||||
lods byte [esi]
|
||||
cmp al,'('
|
||||
jne invalid_argument
|
||||
push dword [ebx+8]
|
||||
push ebx ecx
|
||||
and byte [ebx+8],not 1
|
||||
or byte [ebx+8],4
|
||||
cmp byte [esi],'.'
|
||||
je invalid_value
|
||||
call get_address_value
|
||||
@ -516,14 +572,10 @@ label_directive:
|
||||
xchg bl,bh
|
||||
mov bp,bx
|
||||
pop ecx ebx
|
||||
pop dword [ebx+8]
|
||||
and byte [ebx+8],not 4
|
||||
mov ch,[value_type]
|
||||
or ch,ch
|
||||
jz make_free_label
|
||||
cmp ch,4
|
||||
je make_free_label
|
||||
cmp ch,2
|
||||
jne invalid_use_of_symbol
|
||||
test ch,1
|
||||
jnz invalid_use_of_symbol
|
||||
make_free_label:
|
||||
and byte [ebx+9],not 1
|
||||
cmp eax,[ebx]
|
||||
@ -558,45 +610,102 @@ load_directive:
|
||||
mov [operand_size],al
|
||||
and dword [value],0
|
||||
and dword [value+4],0
|
||||
lods word [esi]
|
||||
cmp ax,82h+'(' shl 8
|
||||
lods byte [esi]
|
||||
cmp al,82h
|
||||
jne invalid_argument
|
||||
load_from_code:
|
||||
cmp byte [esi],'.'
|
||||
je invalid_value
|
||||
or [size_override],-1
|
||||
call get_address_value
|
||||
call calculate_relative_offset
|
||||
call get_data_point
|
||||
jc value_loaded
|
||||
push esi edi
|
||||
cmp [next_pass_needed],0
|
||||
jne load_address_type_ok
|
||||
cmp [value_type],0
|
||||
jne invalid_use_of_symbol
|
||||
load_address_type_ok:
|
||||
cmp edx,-1
|
||||
jne bad_load_address
|
||||
neg eax
|
||||
mov esi,edi
|
||||
sub esi,eax
|
||||
jc bad_load_address
|
||||
cmp esi,[org_start]
|
||||
jb bad_load_address
|
||||
mov esi,ebx
|
||||
mov edi,value
|
||||
movzx ecx,[operand_size]
|
||||
cmp ecx,eax
|
||||
ja bad_load_address
|
||||
rep movs byte [edi],[esi]
|
||||
jmp value_loaded
|
||||
bad_load_address:
|
||||
call recoverable_overflow
|
||||
value_loaded:
|
||||
pop edi esi
|
||||
value_loaded:
|
||||
mov [value_sign],0
|
||||
mov eax,dword [value]
|
||||
mov edx,dword [value+4]
|
||||
pop ebx
|
||||
xor cx,cx
|
||||
jmp make_constant
|
||||
get_data_point:
|
||||
mov ebx,[addressing_space]
|
||||
mov ecx,edi
|
||||
sub ecx,[ebx+18h]
|
||||
mov [ebx+1Ch],ecx
|
||||
lods byte [esi]
|
||||
cmp al,'('
|
||||
jne invalid_argument
|
||||
cmp byte [esi],11h
|
||||
jne get_data_address
|
||||
cmp word [esi+1+4],'):'
|
||||
jne get_data_address
|
||||
inc esi
|
||||
lods dword [esi]
|
||||
add esi,2
|
||||
cmp byte [esi],'('
|
||||
jne invalid_argument
|
||||
inc esi
|
||||
cmp eax,0Fh
|
||||
jbe reserved_word_used_as_symbol
|
||||
mov edx,undefined_symbol
|
||||
test byte [eax+8],1
|
||||
jz addressing_space_unavailable
|
||||
mov edx,symbol_out_of_scope
|
||||
mov cx,[eax+16]
|
||||
cmp cx,[current_pass]
|
||||
jne addressing_space_unavailable
|
||||
test byte [eax+9],4
|
||||
jz invalid_use_of_symbol
|
||||
mov ebx,eax
|
||||
mov ax,[current_pass]
|
||||
mov [ebx+18],ax
|
||||
or byte [ebx+8],8
|
||||
cmp [symbols_file],0
|
||||
je get_addressing_space
|
||||
cmp [next_pass_needed],0
|
||||
jne get_addressing_space
|
||||
call store_label_reference
|
||||
get_addressing_space:
|
||||
mov ebx,[ebx]
|
||||
get_data_address:
|
||||
push ebx
|
||||
cmp byte [esi],'.'
|
||||
je invalid_value
|
||||
or [size_override],-1
|
||||
call get_address_value
|
||||
pop ebp
|
||||
call calculate_relative_offset
|
||||
cmp [next_pass_needed],0
|
||||
jne data_address_type_ok
|
||||
cmp [value_type],0
|
||||
jne invalid_use_of_symbol
|
||||
data_address_type_ok:
|
||||
mov ebx,edi
|
||||
xor ecx,ecx
|
||||
add ebx,eax
|
||||
adc edx,ecx
|
||||
mov eax,ebx
|
||||
sub eax,[ds:ebp+18h]
|
||||
sbb edx,ecx
|
||||
jnz bad_data_address
|
||||
mov cl,[operand_size]
|
||||
add eax,ecx
|
||||
cmp eax,[ds:ebp+1Ch]
|
||||
ja bad_data_address
|
||||
clc
|
||||
ret
|
||||
addressing_space_unavailable:
|
||||
cmp [error_line],0
|
||||
jne get_data_address
|
||||
push [current_line]
|
||||
pop [error_line]
|
||||
mov [error],edx
|
||||
mov [error_info],eax
|
||||
jmp get_data_address
|
||||
bad_data_address:
|
||||
call recoverable_overflow
|
||||
stc
|
||||
ret
|
||||
store_directive:
|
||||
cmp byte [esi],11h
|
||||
je sized_store
|
||||
@ -616,44 +725,23 @@ store_directive:
|
||||
jne invalid_use_of_symbol
|
||||
mov dword [value],eax
|
||||
mov dword [value+4],edx
|
||||
lods word [esi]
|
||||
cmp ax,80h+'(' shl 8
|
||||
lods byte [esi]
|
||||
cmp al,80h
|
||||
jne invalid_argument
|
||||
cmp byte [esi],'.'
|
||||
je invalid_value
|
||||
or [size_override],-1
|
||||
call get_address_value
|
||||
call calculate_relative_offset
|
||||
call get_data_point
|
||||
jc instruction_assembled
|
||||
push esi edi
|
||||
cmp [next_pass_needed],0
|
||||
jne store_address_type_ok
|
||||
cmp [value_type],0
|
||||
jne invalid_use_of_symbol
|
||||
store_address_type_ok:
|
||||
cmp edx,-1
|
||||
jne bad_store_address
|
||||
neg eax
|
||||
sub edi,eax
|
||||
jc bad_store_address
|
||||
cmp edi,[org_start]
|
||||
jb bad_store_address
|
||||
mov esi,value
|
||||
movzx ecx,[operand_size]
|
||||
cmp ecx,eax
|
||||
ja bad_store_address
|
||||
mov edi,ebx
|
||||
rep movs byte [edi],[esi]
|
||||
mov eax,edi
|
||||
pop edi esi
|
||||
cmp edi,[undefined_data_end]
|
||||
jne instruction_assembled
|
||||
cmp ebx,[undefined_data_end]
|
||||
jae instruction_assembled
|
||||
cmp eax,[undefined_data_start]
|
||||
jbe instruction_assembled
|
||||
mov [undefined_data_start],eax
|
||||
jmp instruction_assembled
|
||||
bad_store_address:
|
||||
pop edi esi
|
||||
call recoverable_overflow
|
||||
jmp instruction_assembled
|
||||
|
||||
display_directive:
|
||||
lods byte [esi]
|
||||
@ -665,12 +753,12 @@ display_directive:
|
||||
lods dword [esi]
|
||||
mov ecx,eax
|
||||
push edi
|
||||
mov edi,[display_buffer]
|
||||
mov edi,[tagged_blocks]
|
||||
sub edi,8
|
||||
sub edi,eax
|
||||
cmp edi,[esp]
|
||||
jbe out_of_memory
|
||||
mov [display_buffer],edi
|
||||
mov [tagged_blocks],edi
|
||||
rep movs byte [edi],[esi]
|
||||
stos dword [edi]
|
||||
xor eax,eax
|
||||
@ -681,9 +769,9 @@ display_directive:
|
||||
display_byte:
|
||||
call get_byte_value
|
||||
push edi
|
||||
mov edi,[display_buffer]
|
||||
mov edi,[tagged_blocks]
|
||||
sub edi,8+1
|
||||
mov [display_buffer],edi
|
||||
mov [tagged_blocks],edi
|
||||
stos byte [edi]
|
||||
mov eax,1
|
||||
stos dword [edi]
|
||||
@ -691,7 +779,7 @@ display_directive:
|
||||
stos dword [edi]
|
||||
pop edi
|
||||
display_next:
|
||||
cmp edi,[display_buffer]
|
||||
cmp edi,[tagged_blocks]
|
||||
ja out_of_memory
|
||||
lods byte [esi]
|
||||
cmp al,','
|
||||
@ -699,7 +787,7 @@ display_directive:
|
||||
dec esi
|
||||
jmp instruction_assembled
|
||||
show_display_buffer:
|
||||
mov eax,[display_buffer]
|
||||
mov eax,[tagged_blocks]
|
||||
or eax,eax
|
||||
jz display_done
|
||||
mov esi,[labels_list]
|
||||
@ -711,12 +799,12 @@ show_display_buffer:
|
||||
mov ecx,[esi]
|
||||
sub esi,ecx
|
||||
test eax,eax
|
||||
jnz skip_internal_message
|
||||
jnz skip_block
|
||||
push esi
|
||||
call display_block
|
||||
pop esi
|
||||
skip_internal_message:
|
||||
cmp esi,[display_buffer]
|
||||
skip_block:
|
||||
cmp esi,[tagged_blocks]
|
||||
jne display_messages
|
||||
display_done:
|
||||
ret
|
||||
@ -779,28 +867,41 @@ virtual_directive:
|
||||
jmp set_virtual
|
||||
virtual_at_current:
|
||||
dec esi
|
||||
mov al,[labels_type]
|
||||
mov ebp,[addressing_space]
|
||||
mov al,[ds:ebp+9]
|
||||
mov [value_type],al
|
||||
mov ebp,[org_symbol]
|
||||
mov eax,edi
|
||||
xor edx,edx
|
||||
xor cl,cl
|
||||
sub eax,dword [org_origin]
|
||||
sbb edx,dword [org_origin+4]
|
||||
sbb cl,[org_origin_sign]
|
||||
sub eax,[ds:ebp]
|
||||
sbb edx,[ds:ebp+4]
|
||||
sbb cl,[ds:ebp+8]
|
||||
mov [address_sign],cl
|
||||
mov bx,word [org_registers]
|
||||
mov cx,word [org_registers+2]
|
||||
mov bx,[ds:ebp+10h]
|
||||
mov cx,[ds:ebp+10h+2]
|
||||
xchg bh,bl
|
||||
xchg ch,cl
|
||||
mov ebp,[ds:ebp+14h]
|
||||
set_virtual:
|
||||
push [org_registers]
|
||||
mov byte [org_registers],bh
|
||||
mov byte [org_registers+1],bl
|
||||
mov byte [org_registers+2],ch
|
||||
mov byte [org_registers+3],cl
|
||||
xchg bl,bh
|
||||
xchg cl,ch
|
||||
shl ecx,16
|
||||
mov cx,bx
|
||||
push ecx eax
|
||||
call allocate_structure_data
|
||||
mov word [ebx],virtual_directive-instruction_handler
|
||||
mov ecx,[addressing_space]
|
||||
mov [ebx+12],ecx
|
||||
mov [ebx+8],edi
|
||||
mov ecx,[current_line]
|
||||
mov [ebx+4],ecx
|
||||
mov ebx,[addressing_space]
|
||||
mov eax,edi
|
||||
sub eax,[ebx+18h]
|
||||
mov [ebx+1Ch],eax
|
||||
call init_addressing_space
|
||||
or byte [ebx+0Ah],1
|
||||
pop eax
|
||||
mov cl,[address_sign]
|
||||
not eax
|
||||
not edx
|
||||
@ -811,37 +912,19 @@ virtual_directive:
|
||||
add eax,edi
|
||||
adc edx,0
|
||||
adc cl,0
|
||||
xchg dword [org_origin],eax
|
||||
xchg dword [org_origin+4],edx
|
||||
xchg [org_origin_sign],cl
|
||||
mov [ebx+10h],eax
|
||||
mov [ebx+14h],edx
|
||||
pop eax
|
||||
mov [ebx+18h],eax
|
||||
mov al,[virtual_data]
|
||||
and al,0Fh
|
||||
shl cl,4
|
||||
or al,cl
|
||||
mov [ebx+2],al
|
||||
mov al,[labels_type]
|
||||
mov [ebx+3],al
|
||||
mov eax,edi
|
||||
xchg eax,[org_start]
|
||||
mov [ebx+0Ch],eax
|
||||
xchg ebp,[org_symbol]
|
||||
mov [ebx+1Ch],ebp
|
||||
mov [ebx+8],edi
|
||||
mov eax,[current_line]
|
||||
mov [ebx+4],eax
|
||||
or [virtual_data],-1
|
||||
mov [ebx],eax
|
||||
mov [ebx+4],edx
|
||||
mov [ebx+8],cl
|
||||
pop dword [ebx+10h]
|
||||
mov [ebx+14h],ebp
|
||||
mov al,[value_type]
|
||||
test al,1
|
||||
jnz invalid_use_of_symbol
|
||||
mov [labels_type],al
|
||||
mov [ebx+9],al
|
||||
jmp instruction_assembled
|
||||
allocate_structure_data:
|
||||
mov ebx,[structures_buffer]
|
||||
sub ebx,20h
|
||||
sub ebx,18h
|
||||
cmp ebx,[free_additional_memory]
|
||||
jb out_of_memory
|
||||
mov [structures_buffer],ebx
|
||||
@ -853,7 +936,7 @@ virtual_directive:
|
||||
je no_such_structure
|
||||
cmp ax,[ebx]
|
||||
je structure_data_found
|
||||
add ebx,20h
|
||||
add ebx,18h
|
||||
jmp scan_structures
|
||||
structure_data_found:
|
||||
ret
|
||||
@ -863,27 +946,11 @@ virtual_directive:
|
||||
end_virtual:
|
||||
call find_structure_data
|
||||
jc unexpected_instruction
|
||||
mov al,[ebx+2]
|
||||
mov ah,al
|
||||
shr ah,4
|
||||
and al,1
|
||||
neg al
|
||||
and ah,1
|
||||
neg ah
|
||||
mov [virtual_data],al
|
||||
mov [org_origin_sign],ah
|
||||
mov al,[ebx+3]
|
||||
mov [labels_type],al
|
||||
mov eax,[ebx+10h]
|
||||
mov dword [org_origin],eax
|
||||
mov eax,[ebx+14h]
|
||||
mov dword [org_origin+4],eax
|
||||
mov eax,[ebx+18h]
|
||||
mov [org_registers],eax
|
||||
mov eax,[ebx+0Ch]
|
||||
mov [org_start],eax
|
||||
mov eax,[ebx+1Ch]
|
||||
mov [org_symbol],eax
|
||||
push ebx
|
||||
call close_virtual_addressing_space
|
||||
pop ebx
|
||||
mov eax,[ebx+12]
|
||||
mov [addressing_space],eax
|
||||
mov edi,[ebx+8]
|
||||
remove_structure_data:
|
||||
push esi edi
|
||||
@ -891,13 +958,55 @@ virtual_directive:
|
||||
sub ecx,[structures_buffer]
|
||||
shr ecx,2
|
||||
lea esi,[ebx-4]
|
||||
lea edi,[esi+20h]
|
||||
lea edi,[esi+18h]
|
||||
std
|
||||
rep movs dword [edi],[esi]
|
||||
cld
|
||||
add [structures_buffer],20h
|
||||
add [structures_buffer],18h
|
||||
pop edi esi
|
||||
ret
|
||||
close_virtual_addressing_space:
|
||||
mov ebx,[addressing_space]
|
||||
mov eax,edi
|
||||
sub eax,[ebx+18h]
|
||||
mov [ebx+1Ch],eax
|
||||
test byte [ebx+0Ah],2
|
||||
jz addressing_space_closed
|
||||
push esi edi ecx edx
|
||||
mov ecx,eax
|
||||
mov eax,[tagged_blocks]
|
||||
mov dword [eax-4],11h
|
||||
mov dword [eax-8],ecx
|
||||
sub eax,8
|
||||
sub eax,ecx
|
||||
mov [tagged_blocks],eax
|
||||
lea edi,[eax+ecx-1]
|
||||
xchg eax,[ebx+18h]
|
||||
lea esi,[eax+ecx-1]
|
||||
mov eax,edi
|
||||
sub eax,esi
|
||||
std
|
||||
shr ecx,1
|
||||
jnc virtual_byte_ok
|
||||
movs byte [edi],[esi]
|
||||
virtual_byte_ok:
|
||||
dec esi
|
||||
dec edi
|
||||
shr ecx,1
|
||||
jnc virtual_word_ok
|
||||
movs word [edi],[esi]
|
||||
virtual_word_ok:
|
||||
sub esi,2
|
||||
sub edi,2
|
||||
rep movs dword [edi],[esi]
|
||||
cld
|
||||
xor edx,edx
|
||||
add [ebx],eax
|
||||
adc dword [ebx+4],edx
|
||||
adc byte [ebx+8],dl
|
||||
pop edx ecx edi esi
|
||||
addressing_space_closed:
|
||||
ret
|
||||
repeat_directive:
|
||||
cmp [prefixed_instruction],0
|
||||
jne unexpected_instruction
|
||||
@ -1193,7 +1302,7 @@ break_directive:
|
||||
je break_while
|
||||
cmp ax,if_directive-instruction_handler
|
||||
je break_if
|
||||
add ebx,20h
|
||||
add ebx,18h
|
||||
jmp find_breakable_structure
|
||||
break_if:
|
||||
push [current_line]
|
||||
@ -1235,14 +1344,15 @@ data_bytes:
|
||||
lods dword [esi]
|
||||
mov ecx,eax
|
||||
lea eax,[edi+ecx]
|
||||
cmp eax,[display_buffer]
|
||||
cmp eax,[tagged_blocks]
|
||||
ja out_of_memory
|
||||
rep movs byte [edi],[esi]
|
||||
inc esi
|
||||
ret
|
||||
undefined_data:
|
||||
cmp [virtual_data],0
|
||||
je mark_undefined_data
|
||||
mov ebp,[addressing_space]
|
||||
test byte [ds:ebp+0Ah],1
|
||||
jz mark_undefined_data
|
||||
ret
|
||||
mark_undefined_data:
|
||||
cmp eax,[undefined_data_end]
|
||||
@ -1252,7 +1362,7 @@ data_bytes:
|
||||
mov [undefined_data_end],edi
|
||||
ret
|
||||
define_data:
|
||||
cmp edi,[display_buffer]
|
||||
cmp edi,[tagged_blocks]
|
||||
jae out_of_memory
|
||||
cmp byte [esi],'('
|
||||
jne simple_data_value
|
||||
@ -1273,7 +1383,7 @@ data_bytes:
|
||||
duplicate_data:
|
||||
push eax esi
|
||||
duplicated_values:
|
||||
cmp edi,[display_buffer]
|
||||
cmp edi,[tagged_blocks]
|
||||
jae out_of_memory
|
||||
call near dword [esp+8]
|
||||
lods byte [esi]
|
||||
@ -1287,7 +1397,7 @@ data_bytes:
|
||||
mov esi,ebx
|
||||
jmp duplicate_data
|
||||
duplicate_single_data_value:
|
||||
cmp edi,[display_buffer]
|
||||
cmp edi,[tagged_blocks]
|
||||
jae out_of_memory
|
||||
push eax esi
|
||||
call near dword [esp+8]
|
||||
@ -1311,7 +1421,7 @@ data_bytes:
|
||||
call skip_symbol
|
||||
jmp data_defined
|
||||
simple_data_value:
|
||||
cmp edi,[display_buffer]
|
||||
cmp edi,[tagged_blocks]
|
||||
jae out_of_memory
|
||||
call near dword [esp]
|
||||
data_defined:
|
||||
@ -1354,7 +1464,7 @@ data_words:
|
||||
mov ecx,eax
|
||||
jecxz word_string_ok
|
||||
lea eax,[edi+ecx*2]
|
||||
cmp eax,[display_buffer]
|
||||
cmp eax,[tagged_blocks]
|
||||
ja out_of_memory
|
||||
xor ah,ah
|
||||
copy_word_string:
|
||||
@ -1624,7 +1734,7 @@ data_file:
|
||||
mov edx,edi
|
||||
add edi,ecx
|
||||
jc out_of_memory
|
||||
cmp edi,[display_buffer]
|
||||
cmp edi,[tagged_blocks]
|
||||
ja out_of_memory
|
||||
call read
|
||||
jc error_reading_file
|
||||
@ -1704,7 +1814,7 @@ reserve_bytes:
|
||||
mov edx,ecx
|
||||
add edx,edi
|
||||
jc out_of_memory
|
||||
cmp edx,[display_buffer]
|
||||
cmp edx,[tagged_blocks]
|
||||
ja out_of_memory
|
||||
push edi
|
||||
cmp [next_pass_needed],0
|
||||
@ -1739,7 +1849,7 @@ reserve_words:
|
||||
jc out_of_memory
|
||||
add edx,edi
|
||||
jc out_of_memory
|
||||
cmp edx,[display_buffer]
|
||||
cmp edx,[tagged_blocks]
|
||||
ja out_of_memory
|
||||
push edi
|
||||
cmp [next_pass_needed],0
|
||||
@ -1769,7 +1879,7 @@ reserve_dwords:
|
||||
jc out_of_memory
|
||||
add edx,edi
|
||||
jc out_of_memory
|
||||
cmp edx,[display_buffer]
|
||||
cmp edx,[tagged_blocks]
|
||||
ja out_of_memory
|
||||
push edi
|
||||
cmp [next_pass_needed],0
|
||||
@ -1796,7 +1906,7 @@ reserve_pwords:
|
||||
jc out_of_memory
|
||||
add edx,edi
|
||||
jc out_of_memory
|
||||
cmp edx,[display_buffer]
|
||||
cmp edx,[tagged_blocks]
|
||||
ja out_of_memory
|
||||
push edi
|
||||
cmp [next_pass_needed],0
|
||||
@ -1820,7 +1930,7 @@ reserve_qwords:
|
||||
jc out_of_memory
|
||||
add edx,edi
|
||||
jc out_of_memory
|
||||
cmp edx,[display_buffer]
|
||||
cmp edx,[tagged_blocks]
|
||||
ja out_of_memory
|
||||
push edi
|
||||
cmp [next_pass_needed],0
|
||||
@ -1843,7 +1953,7 @@ reserve_twords:
|
||||
jc out_of_memory
|
||||
add edx,edi
|
||||
jc out_of_memory
|
||||
cmp edx,[display_buffer]
|
||||
cmp edx,[tagged_blocks]
|
||||
ja out_of_memory
|
||||
push edi
|
||||
cmp [next_pass_needed],0
|
||||
@ -1866,14 +1976,15 @@ align_directive:
|
||||
cmp eax,1
|
||||
je instruction_assembled
|
||||
mov ecx,edi
|
||||
sub ecx,dword [org_origin]
|
||||
cmp [org_registers],0
|
||||
mov ebp,[addressing_space]
|
||||
sub ecx,[ds:ebp]
|
||||
cmp dword [ds:ebp+10h],0
|
||||
jne section_not_aligned_enough
|
||||
cmp [labels_type],0
|
||||
cmp byte [ds:ebp+9],0
|
||||
je make_alignment
|
||||
cmp [output_format],3
|
||||
je pe_alignment
|
||||
mov ebx,[org_symbol]
|
||||
mov ebx,[ds:ebp+14h]
|
||||
cmp byte [ebx],0
|
||||
jne section_not_aligned_enough
|
||||
cmp eax,[ebx+10h]
|
||||
@ -1892,7 +2003,7 @@ align_directive:
|
||||
mov edx,ecx
|
||||
add edx,edi
|
||||
jc out_of_memory
|
||||
cmp edx,[display_buffer]
|
||||
cmp edx,[tagged_blocks]
|
||||
ja out_of_memory
|
||||
push edi
|
||||
cmp [next_pass_needed],0
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,6 @@
|
||||
|
||||
; flat assembler core
|
||||
; Copyright (c) 1999-2012, Tomasz Grysztar.
|
||||
; Copyright (c) 1999-2013, Tomasz Grysztar.
|
||||
; All rights reserved.
|
||||
|
||||
out_of_memory:
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,6 @@
|
||||
|
||||
; flat assembler core
|
||||
; Copyright (c) 1999-2012, Tomasz Grysztar.
|
||||
; Copyright (c) 1999-2013, Tomasz Grysztar.
|
||||
; All rights reserved.
|
||||
|
||||
formatter:
|
||||
@ -129,14 +129,14 @@ formatter:
|
||||
je labels_table_ok
|
||||
mov ecx,[memory_end]
|
||||
sub ecx,[labels_list]
|
||||
mov edi,[display_buffer]
|
||||
mov edi,[tagged_blocks]
|
||||
sub edi,8
|
||||
mov [edi],ecx
|
||||
or dword [edi+4],-1
|
||||
sub edi,ecx
|
||||
cmp edi,[current_offset]
|
||||
jbe out_of_memory
|
||||
mov [display_buffer],edi
|
||||
mov [tagged_blocks],edi
|
||||
mov esi,[memory_end]
|
||||
copy_labels:
|
||||
sub esi,32
|
||||
@ -200,8 +200,9 @@ formatter:
|
||||
format_directive:
|
||||
cmp edi,[code_start]
|
||||
jne unexpected_instruction
|
||||
cmp [virtual_data],0
|
||||
jne unexpected_instruction
|
||||
mov ebp,[addressing_space]
|
||||
test byte [ds:ebp+0Ah],1
|
||||
jnz unexpected_instruction
|
||||
cmp [output_format],0
|
||||
jne unexpected_instruction
|
||||
lods byte [esi]
|
||||
@ -280,8 +281,6 @@ heap_directive:
|
||||
je pe_heap
|
||||
jmp illegal_instruction
|
||||
segment_directive:
|
||||
cmp [virtual_data],0
|
||||
jne illegal_instruction
|
||||
mov al,[output_format]
|
||||
cmp al,2
|
||||
je mz_segment
|
||||
@ -289,8 +288,6 @@ segment_directive:
|
||||
je elf_segment
|
||||
jmp illegal_instruction
|
||||
section_directive:
|
||||
cmp [virtual_data],0
|
||||
jne illegal_instruction
|
||||
mov al,[output_format]
|
||||
cmp al,3
|
||||
je pe_section
|
||||
@ -410,6 +407,7 @@ extrn_directive:
|
||||
xor eax,eax
|
||||
xor edx,edx
|
||||
xor ebp,ebp
|
||||
mov [address_sign],0
|
||||
mov ch,2
|
||||
test [format_flags],8
|
||||
jz make_free_label
|
||||
@ -418,8 +416,9 @@ extrn_directive:
|
||||
mark_relocation:
|
||||
cmp [value_type],0
|
||||
je relocation_ok
|
||||
cmp [virtual_data],0
|
||||
jne relocation_ok
|
||||
mov ebp,[addressing_space]
|
||||
test byte [ds:ebp+0Ah],1
|
||||
jnz relocation_ok
|
||||
cmp [output_format],2
|
||||
je mark_mz_relocation
|
||||
cmp [output_format],3
|
||||
@ -493,13 +492,11 @@ mz_segment:
|
||||
mov edx,edi
|
||||
xor eax,eax
|
||||
rep stos byte [edi]
|
||||
mov dword [org_origin],edi
|
||||
mov dword [org_origin+4],eax
|
||||
mov [org_origin_sign],al
|
||||
mov [org_registers],eax
|
||||
mov [org_start],edi
|
||||
mov eax,edx
|
||||
call undefined_data
|
||||
push ebx
|
||||
call create_addressing_space
|
||||
pop ebx
|
||||
mov eax,edi
|
||||
sub eax,[code_start]
|
||||
shr eax,4
|
||||
@ -515,9 +512,10 @@ mz_segment:
|
||||
mov [code_type],al
|
||||
mov eax,edx
|
||||
mov ch,1
|
||||
mov [label_size],0
|
||||
mov [address_sign],0
|
||||
xor edx,edx
|
||||
xor ebp,ebp
|
||||
mov [label_size],0
|
||||
mov [address_symbol],edx
|
||||
jmp make_free_label
|
||||
mz_entry:
|
||||
@ -724,7 +722,7 @@ make_stub:
|
||||
and ecx,not 11b
|
||||
add ecx,(40h-1Ch) shr 2
|
||||
lea eax,[edi+ecx*4]
|
||||
cmp edi,[display_buffer]
|
||||
cmp edi,[tagged_blocks]
|
||||
jae out_of_memory
|
||||
xor eax,eax
|
||||
rep stos dword [edi]
|
||||
@ -762,7 +760,7 @@ make_stub:
|
||||
inc ecx
|
||||
shl ecx,1
|
||||
lea eax,[edi+ecx*4]
|
||||
cmp eax,[display_buffer]
|
||||
cmp eax,[tagged_blocks]
|
||||
jae out_of_memory
|
||||
xor eax,eax
|
||||
rep stos dword [edi]
|
||||
@ -826,7 +824,7 @@ make_stub:
|
||||
mov [esi+16h],ax
|
||||
mov word [esi+14h],100h
|
||||
mov byte [esi+18h],40h
|
||||
mov eax,[display_buffer]
|
||||
mov eax,[tagged_blocks]
|
||||
sub eax,ecx
|
||||
cmp edi,eax
|
||||
jae out_of_memory
|
||||
@ -1053,7 +1051,7 @@ format_pe:
|
||||
shl ebx,cl
|
||||
sub ebx,ebp
|
||||
mov ecx,ebx
|
||||
mov eax,[display_buffer]
|
||||
mov eax,[tagged_blocks]
|
||||
sub eax,ecx
|
||||
cmp edi,eax
|
||||
jae out_of_memory
|
||||
@ -1117,12 +1115,14 @@ format_pe:
|
||||
jc pe_labels_type_ok
|
||||
xor bh,bh
|
||||
pe_labels_type_ok:
|
||||
mov [labels_type],bh
|
||||
mov dword [org_origin],eax
|
||||
mov dword [org_origin+4],ecx
|
||||
mov [org_origin_sign],bl
|
||||
and [org_registers],0
|
||||
mov [org_start],edi
|
||||
push eax ebx
|
||||
call init_addressing_space
|
||||
mov ebp,ebx
|
||||
pop ebx eax
|
||||
mov [ds:ebp],eax
|
||||
mov [ds:ebp+4],ecx
|
||||
mov [ds:ebp+8],bx
|
||||
mov [ds:ebp+18h],edi
|
||||
bt [format_flags],8
|
||||
jnc dll_flag_ok
|
||||
or byte [edx+16h+1],20h
|
||||
@ -1142,6 +1142,10 @@ format_pe:
|
||||
jmp format_defined
|
||||
pe_section:
|
||||
call close_pe_section
|
||||
push eax ebx
|
||||
call create_addressing_space
|
||||
mov ebp,ebx
|
||||
pop ebx eax
|
||||
bts [format_flags],5
|
||||
lea ecx,[ebx+28h]
|
||||
add edx,[edx+54h]
|
||||
@ -1179,38 +1183,36 @@ pe_section:
|
||||
mov edx,[code_start]
|
||||
mov eax,edi
|
||||
xor ecx,ecx
|
||||
mov [org_origin_sign],0
|
||||
sub eax,[ebx+0Ch]
|
||||
sbb ecx,0
|
||||
sbb [org_origin_sign],0
|
||||
mov [labels_type],2
|
||||
sbb byte [ds:ebp+8],0
|
||||
mov byte [ds:ebp+9],2
|
||||
mov [code_type],32
|
||||
test [format_flags],8
|
||||
jz pe_section_code_type_ok
|
||||
mov [labels_type],4
|
||||
mov byte [ds:ebp+9],4
|
||||
mov [code_type],64
|
||||
pe_section_code_type_ok:
|
||||
test [format_flags],4
|
||||
jnz peplus_section_org
|
||||
sub eax,[edx+34h]
|
||||
sbb ecx,0
|
||||
sbb [org_origin_sign],0
|
||||
sbb byte [ds:ebp+8],0
|
||||
bt [resolver_flags],0
|
||||
jc pe_section_org_ok
|
||||
mov [labels_type],0
|
||||
mov byte [ds:ebp+9],0
|
||||
jmp pe_section_org_ok
|
||||
peplus_section_org:
|
||||
sub eax,[edx+30h]
|
||||
sbb ecx,[edx+34h]
|
||||
sbb [org_origin_sign],0
|
||||
sbb byte [ds:ebp+8],0
|
||||
bt [resolver_flags],0
|
||||
jc pe_section_org_ok
|
||||
mov [labels_type],0
|
||||
mov byte [ds:ebp+9],0
|
||||
pe_section_org_ok:
|
||||
mov dword [org_origin],eax
|
||||
mov dword [org_origin+4],ecx
|
||||
and [org_registers],0
|
||||
mov [org_start],edi
|
||||
mov [ds:ebp],eax
|
||||
mov [ds:ebp+4],ecx
|
||||
mov [ds:ebp+18h],edi
|
||||
get_section_flags:
|
||||
lods byte [esi]
|
||||
cmp al,1Ah
|
||||
@ -1541,7 +1543,7 @@ pe_heap:
|
||||
cmp edx,[ecx+74h]
|
||||
ja value_out_of_range
|
||||
jb instruction_assembled
|
||||
cmp eax,[edx+70h]
|
||||
cmp eax,[ecx+70h]
|
||||
ja value_out_of_range
|
||||
jmp instruction_assembled
|
||||
mark_pe_relocation:
|
||||
@ -1664,7 +1666,7 @@ make_pe_resource:
|
||||
and [resource_size],0
|
||||
reserve_space_for_resource:
|
||||
add edi,[resource_size]
|
||||
cmp edi,[display_buffer]
|
||||
cmp edi,[tagged_blocks]
|
||||
ja out_of_memory
|
||||
jmp resource_done
|
||||
resource_from_file:
|
||||
@ -1750,7 +1752,7 @@ make_pe_resource:
|
||||
mov [esi],eax
|
||||
mov [resource_data],edi
|
||||
lea eax,[edi+16]
|
||||
cmp eax,[display_buffer]
|
||||
cmp eax,[tagged_blocks]
|
||||
jae out_of_memory
|
||||
xor eax,eax
|
||||
stos dword [edi]
|
||||
@ -1812,7 +1814,7 @@ make_pe_resource:
|
||||
mov eax,[resource_data]
|
||||
inc word [eax+12]
|
||||
lea eax,[edi+8]
|
||||
cmp eax,[display_buffer]
|
||||
cmp eax,[tagged_blocks]
|
||||
jae out_of_memory
|
||||
mov eax,ebx
|
||||
stos dword [edi]
|
||||
@ -1849,7 +1851,7 @@ make_pe_resource:
|
||||
mov eax,[resource_data]
|
||||
inc word [eax+14]
|
||||
lea eax,[edi+8]
|
||||
cmp eax,[display_buffer]
|
||||
cmp eax,[tagged_blocks]
|
||||
jae out_of_memory
|
||||
mov eax,ebx
|
||||
stos dword [edi]
|
||||
@ -1870,7 +1872,7 @@ make_pe_resource:
|
||||
bts edx,31
|
||||
mov [esi+4],edx
|
||||
lea eax,[edi+16]
|
||||
cmp eax,[display_buffer]
|
||||
cmp eax,[tagged_blocks]
|
||||
jae out_of_memory
|
||||
xor eax,eax
|
||||
stos dword [edi]
|
||||
@ -1949,7 +1951,7 @@ make_pe_resource:
|
||||
mov eax,[esp]
|
||||
inc word [eax+12]
|
||||
lea eax,[edi+8]
|
||||
cmp eax,[display_buffer]
|
||||
cmp eax,[tagged_blocks]
|
||||
jae out_of_memory
|
||||
mov eax,ebx
|
||||
stos dword [edi]
|
||||
@ -1992,7 +1994,7 @@ make_pe_resource:
|
||||
mov eax,[esp]
|
||||
inc word [eax+14]
|
||||
lea eax,[edi+8]
|
||||
cmp eax,[display_buffer]
|
||||
cmp eax,[tagged_blocks]
|
||||
jae out_of_memory
|
||||
mov eax,ebx
|
||||
stos dword [edi]
|
||||
@ -2031,7 +2033,7 @@ make_pe_resource:
|
||||
bts edx,31
|
||||
mov [esi+4],edx
|
||||
lea eax,[edi+16]
|
||||
cmp eax,[display_buffer]
|
||||
cmp eax,[tagged_blocks]
|
||||
jae out_of_memory
|
||||
xor eax,eax
|
||||
stos dword [edi]
|
||||
@ -2081,7 +2083,7 @@ make_pe_resource:
|
||||
mov eax,[esp]
|
||||
inc word [eax+14]
|
||||
lea eax,[edi+8]
|
||||
cmp eax,[display_buffer]
|
||||
cmp eax,[tagged_blocks]
|
||||
jae out_of_memory
|
||||
mov eax,ebx
|
||||
stos dword [edi]
|
||||
@ -2122,7 +2124,7 @@ make_pe_resource:
|
||||
stos word [edi]
|
||||
copy_string_data:
|
||||
lea eax,[edi+2]
|
||||
cmp eax,[display_buffer]
|
||||
cmp eax,[tagged_blocks]
|
||||
jae out_of_memory
|
||||
mov ax,[edx]
|
||||
or ax,ax
|
||||
@ -2160,7 +2162,7 @@ make_pe_resource:
|
||||
sub esi,[resource_data]
|
||||
xchg esi,[ebx+4]
|
||||
lea eax,[edi+16]
|
||||
cmp eax,[display_buffer]
|
||||
cmp eax,[tagged_blocks]
|
||||
jae out_of_memory
|
||||
mov eax,esi
|
||||
stos dword [edi]
|
||||
@ -2190,7 +2192,7 @@ make_pe_resource:
|
||||
mov edx,edi
|
||||
mov ecx,[esi+4]
|
||||
add edi,ecx
|
||||
cmp edi,[display_buffer]
|
||||
cmp edi,[tagged_blocks]
|
||||
ja out_of_memory
|
||||
call read
|
||||
mov eax,edi
|
||||
@ -2319,28 +2321,16 @@ format_coff:
|
||||
mov [current_section],ebx
|
||||
xor eax,eax
|
||||
mov [number_of_sections],eax
|
||||
call setup_coff_section_org
|
||||
mov edx,ebx
|
||||
call init_addressing_space
|
||||
mov [ebx+14h],edx
|
||||
mov byte [ebx+9],2
|
||||
mov [code_type],32
|
||||
test [format_flags],8
|
||||
jz format_defined
|
||||
mov byte [ebx+9],4
|
||||
mov [code_type],64
|
||||
jmp format_defined
|
||||
setup_coff_section_org:
|
||||
xor eax,eax
|
||||
mov dword [org_origin],edi
|
||||
mov dword [org_origin+4],eax
|
||||
mov [org_origin_sign],al
|
||||
mov [org_registers],eax
|
||||
mov [org_start],edi
|
||||
mov [org_symbol],ebx
|
||||
test [format_flags],8
|
||||
jnz coff_64bit_labels
|
||||
mov [labels_type],2
|
||||
ret
|
||||
coff_64bit_labels:
|
||||
mov [labels_type],4
|
||||
ret
|
||||
|
||||
coff_section:
|
||||
call close_coff_section
|
||||
mov ebx,[free_additional_memory]
|
||||
@ -2355,7 +2345,15 @@ coff_section:
|
||||
mov [ebx+8],edi
|
||||
mov [ebx+10h],eax
|
||||
mov [ebx+14h],eax
|
||||
call setup_coff_section_org
|
||||
mov edx,ebx
|
||||
call create_addressing_space
|
||||
xchg edx,ebx
|
||||
mov [edx+14h],ebx
|
||||
mov byte [edx+9],2
|
||||
test [format_flags],8
|
||||
jz coff_labels_type_ok
|
||||
mov byte [edx+9],4
|
||||
coff_labels_type_ok:
|
||||
lods word [esi]
|
||||
cmp ax,'('
|
||||
jne invalid_argument
|
||||
@ -2442,8 +2440,10 @@ mark_coff_relocation:
|
||||
test [format_flags],8
|
||||
jnz coff_64bit_relocation
|
||||
mov al,6
|
||||
cmp [value_type],2
|
||||
je coff_relocation
|
||||
cmp [value_type],5
|
||||
jne coff_relocation
|
||||
jne invalid_use_of_symbol
|
||||
inc al
|
||||
jmp coff_relocation
|
||||
coff_64bit_relocation:
|
||||
@ -2451,8 +2451,10 @@ mark_coff_relocation:
|
||||
cmp [value_type],4
|
||||
je coff_relocation
|
||||
mov al,2
|
||||
cmp [value_type],2
|
||||
je coff_relocation
|
||||
cmp [value_type],5
|
||||
jne coff_relocation
|
||||
jne invalid_use_of_symbol
|
||||
inc al
|
||||
jmp coff_relocation
|
||||
coff_relocation_relative:
|
||||
@ -2465,16 +2467,17 @@ mark_coff_relocation:
|
||||
sub eax,ebx
|
||||
add eax,4
|
||||
relative_ok:
|
||||
mov ebx,[addressing_space]
|
||||
push eax
|
||||
mov al,20
|
||||
test [format_flags],8
|
||||
jnz relative_coff_64bit_relocation
|
||||
cmp [labels_type],2
|
||||
cmp byte [ebx+9],2
|
||||
jne invalid_use_of_symbol
|
||||
jmp coff_relocation
|
||||
relative_coff_64bit_relocation:
|
||||
mov al,4
|
||||
cmp [labels_type],4
|
||||
cmp byte [ebx+9],4
|
||||
jne invalid_use_of_symbol
|
||||
coff_relocation:
|
||||
mov ebx,[free_additional_memory]
|
||||
@ -2686,7 +2689,7 @@ coff_formatter:
|
||||
jmp find_relocations
|
||||
add_relocation:
|
||||
lea eax,[ebx+0Ah]
|
||||
cmp eax,[display_buffer]
|
||||
cmp eax,[tagged_blocks]
|
||||
ja out_of_memory
|
||||
mov eax,[esi+4]
|
||||
mov [ebx],eax
|
||||
@ -2905,7 +2908,7 @@ format_elf:
|
||||
mov edx,edi
|
||||
mov ecx,34h shr 2
|
||||
lea eax,[edi+ecx*4]
|
||||
cmp eax,[display_buffer]
|
||||
cmp eax,[tagged_blocks]
|
||||
jae out_of_memory
|
||||
xor eax,eax
|
||||
rep stos dword [edi]
|
||||
@ -2940,16 +2943,21 @@ format_elf:
|
||||
mov [ebx+14h],eax
|
||||
mov al,4
|
||||
mov [ebx+10h],eax
|
||||
call setup_coff_section_org
|
||||
mov edx,ebx
|
||||
call init_addressing_space
|
||||
xchg edx,ebx
|
||||
mov [edx+14h],ebx
|
||||
mov byte [edx+9],2
|
||||
test [format_flags],8
|
||||
jz format_defined
|
||||
mov byte [edx+9],4
|
||||
mov byte [ebx+10h],8
|
||||
jmp format_defined
|
||||
format_elf64:
|
||||
mov edx,edi
|
||||
mov ecx,40h shr 2
|
||||
lea eax,[edi+ecx*4]
|
||||
cmp eax,[display_buffer]
|
||||
cmp eax,[tagged_blocks]
|
||||
jae out_of_memory
|
||||
xor eax,eax
|
||||
rep stos dword [edi]
|
||||
@ -2984,7 +2992,15 @@ elf_section:
|
||||
mov [ebx+10h],eax
|
||||
mov al,10b
|
||||
mov [ebx+14h],eax
|
||||
call setup_coff_section_org
|
||||
mov edx,ebx
|
||||
call create_addressing_space
|
||||
xchg edx,ebx
|
||||
mov [edx+14h],ebx
|
||||
mov byte [edx+9],2
|
||||
test [format_flags],8
|
||||
jz elf_labels_type_ok
|
||||
mov byte [edx+9],4
|
||||
elf_labels_type_ok:
|
||||
lods word [esi]
|
||||
cmp ax,'('
|
||||
jne invalid_argument
|
||||
@ -3038,11 +3054,13 @@ elf_section:
|
||||
mov byte [ebx+10h],8
|
||||
jmp instruction_assembled
|
||||
mark_elf_relocation:
|
||||
push ebx
|
||||
mov ebx,[addressing_space]
|
||||
cmp [value_type],3
|
||||
je elf_relocation_relative
|
||||
cmp [value_type],7
|
||||
je elf_relocation_relative
|
||||
push ebx eax
|
||||
push eax
|
||||
cmp [value_type],5
|
||||
je elf_gotoff_relocation
|
||||
ja invalid_use_of_symbol
|
||||
@ -3059,9 +3077,8 @@ mark_elf_relocation:
|
||||
mov al,9 ; R_386_GOTOFF
|
||||
jmp coff_relocation
|
||||
elf_relocation_relative:
|
||||
cmp [labels_type],0
|
||||
cmp byte [ebx+9],0
|
||||
je invalid_use_of_symbol
|
||||
push ebx
|
||||
mov ebx,[current_section]
|
||||
mov ebx,[ebx+8]
|
||||
sub ebx,edi
|
||||
@ -3690,11 +3707,13 @@ format_elf_exe:
|
||||
add eax,edi
|
||||
adc ebp,0
|
||||
adc cl,0
|
||||
mov dword [org_origin],eax
|
||||
mov dword [org_origin+4],edx
|
||||
mov [org_origin_sign],cl
|
||||
and [org_registers],0
|
||||
mov [org_start],edi
|
||||
elf_exe_addressing_setup:
|
||||
push eax
|
||||
call init_addressing_space
|
||||
pop eax
|
||||
mov [ebx],eax
|
||||
mov [ebx+4],edx
|
||||
mov [ebx+8],cl
|
||||
mov [symbols_stream],edi
|
||||
jmp format_defined
|
||||
format_elf64_exe:
|
||||
@ -3768,13 +3787,7 @@ format_elf_exe:
|
||||
add eax,edi
|
||||
adc edx,0
|
||||
adc cl,0
|
||||
mov dword [org_origin],eax
|
||||
mov dword [org_origin+4],edx
|
||||
mov [org_origin_sign],cl
|
||||
and [org_registers],0
|
||||
mov [org_start],edi
|
||||
mov [symbols_stream],edi
|
||||
jmp format_defined
|
||||
jmp elf_exe_addressing_setup
|
||||
elf_entry:
|
||||
lods byte [esi]
|
||||
cmp al,'('
|
||||
@ -3804,6 +3817,8 @@ elf_segment:
|
||||
jnz elf64_segment
|
||||
call close_elf_segment
|
||||
push eax
|
||||
call create_addressing_space
|
||||
mov ebp,ebx
|
||||
mov ebx,[number_of_sections]
|
||||
shl ebx,5
|
||||
add ebx,[code_start]
|
||||
@ -3883,11 +3898,10 @@ elf_segment:
|
||||
add eax,edi
|
||||
adc edx,0
|
||||
adc cl,0
|
||||
mov dword [org_origin],eax
|
||||
mov dword [org_origin+4],edx
|
||||
mov [org_origin_sign],cl
|
||||
and [org_registers],0
|
||||
mov [org_start],edi
|
||||
elf_segment_addressing_setup:
|
||||
mov [ds:ebp],eax
|
||||
mov [ds:ebp+4],edx
|
||||
mov [ds:ebp+8],cl
|
||||
inc [number_of_sections]
|
||||
jmp instruction_assembled
|
||||
close_elf_segment:
|
||||
@ -3935,6 +3949,8 @@ elf_segment:
|
||||
elf64_segment:
|
||||
call close_elf64_segment
|
||||
push eax edx
|
||||
call create_addressing_space
|
||||
mov ebp,ebx
|
||||
mov ebx,[number_of_sections]
|
||||
imul ebx,38h
|
||||
add ebx,[code_start]
|
||||
@ -4015,13 +4031,7 @@ elf_segment:
|
||||
add eax,edi
|
||||
adc edx,0
|
||||
adc cl,0
|
||||
mov dword [org_origin],eax
|
||||
mov dword [org_origin+4],edx
|
||||
mov [org_origin_sign],cl
|
||||
and [org_registers],0
|
||||
mov [org_start],edi
|
||||
inc [number_of_sections]
|
||||
jmp instruction_assembled
|
||||
jmp elf_segment_addressing_setup
|
||||
close_elf64_segment:
|
||||
cmp [number_of_sections],0
|
||||
jne finish_elf64_segment
|
||||
|
@ -1,52 +1,52 @@
|
||||
|
||||
; flat assembler core
|
||||
; Copyright (c) 1999-2012, Tomasz Grysztar.
|
||||
; All rights reserved.
|
||||
|
||||
_out_of_memory db 'out of memory',0
|
||||
_stack_overflow db 'out of stack space',0
|
||||
_main_file_not_found db 'source file not found',0
|
||||
_unexpected_end_of_file db 'unexpected end of file',0
|
||||
_code_cannot_be_generated db 'code cannot be generated',0
|
||||
_format_limitations_exceeded db 'format limitations exceeded',0
|
||||
_invalid_definition db 'invalid definition provided',0
|
||||
_write_failed db 'write failed',0
|
||||
_file_not_found db 'file not found',0
|
||||
_error_reading_file db 'error reading file',0
|
||||
_invalid_file_format db 'invalid file format',0
|
||||
_invalid_macro_arguments db 'invalid macro arguments',0
|
||||
_incomplete_macro db 'incomplete macro',0
|
||||
_unexpected_characters db 'unexpected characters',0
|
||||
_invalid_argument db 'invalid argument',0
|
||||
_illegal_instruction db 'illegal instruction',0
|
||||
_invalid_operand db 'invalid operand',0
|
||||
_invalid_operand_size db 'invalid size of operand',0
|
||||
_operand_size_not_specified db 'operand size not specified',0
|
||||
_operand_sizes_do_not_match db 'operand sizes do not match',0
|
||||
_invalid_address_size db 'invalid size of address value',0
|
||||
_address_sizes_do_not_agree db 'address sizes do not agree',0
|
||||
_disallowed_combination_of_registers db 'disallowed combination of registers',0
|
||||
_long_immediate_not_encodable db 'not encodable with long immediate',0
|
||||
_relative_jump_out_of_range db 'relative jump out of range',0
|
||||
_invalid_expression db 'invalid expression',0
|
||||
_invalid_address db 'invalid address',0
|
||||
_invalid_value db 'invalid value',0
|
||||
_value_out_of_range db 'value out of range',0
|
||||
_undefined_symbol db 'undefined symbol',0
|
||||
_symbol_out_of_scope_1 db 'symbol',0
|
||||
_symbol_out_of_scope_2 db 'out of scope',0
|
||||
_invalid_use_of_symbol db 'invalid use of symbol',0
|
||||
_name_too_long db 'name too long',0
|
||||
_invalid_name db 'invalid name',0
|
||||
_reserved_word_used_as_symbol db 'reserved word used as symbol',0
|
||||
_symbol_already_defined db 'symbol already defined',0
|
||||
_missing_end_quote db 'missing end quote',0
|
||||
_missing_end_directive db 'missing end directive',0
|
||||
_unexpected_instruction db 'unexpected instruction',0
|
||||
_extra_characters_on_line db 'extra characters on line',0
|
||||
_section_not_aligned_enough db 'section is not aligned enough',0
|
||||
_setting_already_specified db 'setting already specified',0
|
||||
_data_already_defined db 'data already defined',0
|
||||
_too_many_repeats db 'too many repeats',0
|
||||
_invoked_error db 'error directive encountered in source file',0
|
||||
_assertion_failed db 'assertion failed',0
|
||||
|
||||
; flat assembler core
|
||||
; Copyright (c) 1999-2013, Tomasz Grysztar.
|
||||
; All rights reserved.
|
||||
|
||||
_out_of_memory db 'out of memory',0
|
||||
_stack_overflow db 'out of stack space',0
|
||||
_main_file_not_found db 'source file not found',0
|
||||
_unexpected_end_of_file db 'unexpected end of file',0
|
||||
_code_cannot_be_generated db 'code cannot be generated',0
|
||||
_format_limitations_exceeded db 'format limitations exceeded',0
|
||||
_invalid_definition db 'invalid definition provided',0
|
||||
_write_failed db 'write failed',0
|
||||
_file_not_found db 'file not found',0
|
||||
_error_reading_file db 'error reading file',0
|
||||
_invalid_file_format db 'invalid file format',0
|
||||
_invalid_macro_arguments db 'invalid macro arguments',0
|
||||
_incomplete_macro db 'incomplete macro',0
|
||||
_unexpected_characters db 'unexpected characters',0
|
||||
_invalid_argument db 'invalid argument',0
|
||||
_illegal_instruction db 'illegal instruction',0
|
||||
_invalid_operand db 'invalid operand',0
|
||||
_invalid_operand_size db 'invalid size of operand',0
|
||||
_operand_size_not_specified db 'operand size not specified',0
|
||||
_operand_sizes_do_not_match db 'operand sizes do not match',0
|
||||
_invalid_address_size db 'invalid size of address value',0
|
||||
_address_sizes_do_not_agree db 'address sizes do not agree',0
|
||||
_disallowed_combination_of_registers db 'disallowed combination of registers',0
|
||||
_long_immediate_not_encodable db 'not encodable with long immediate',0
|
||||
_relative_jump_out_of_range db 'relative jump out of range',0
|
||||
_invalid_expression db 'invalid expression',0
|
||||
_invalid_address db 'invalid address',0
|
||||
_invalid_value db 'invalid value',0
|
||||
_value_out_of_range db 'value out of range',0
|
||||
_undefined_symbol db 'undefined symbol',0
|
||||
_symbol_out_of_scope_1 db 'symbol',0
|
||||
_symbol_out_of_scope_2 db 'out of scope',0
|
||||
_invalid_use_of_symbol db 'invalid use of symbol',0
|
||||
_name_too_long db 'name too long',0
|
||||
_invalid_name db 'invalid name',0
|
||||
_reserved_word_used_as_symbol db 'reserved word used as symbol',0
|
||||
_symbol_already_defined db 'symbol already defined',0
|
||||
_missing_end_quote db 'missing end quote',0
|
||||
_missing_end_directive db 'missing end directive',0
|
||||
_unexpected_instruction db 'unexpected instruction',0
|
||||
_extra_characters_on_line db 'extra characters on line',0
|
||||
_section_not_aligned_enough db 'section is not aligned enough',0
|
||||
_setting_already_specified db 'setting already specified',0
|
||||
_data_already_defined db 'data already defined',0
|
||||
_too_many_repeats db 'too many repeats',0
|
||||
_invoked_error db 'error directive encountered in source file',0
|
||||
_assertion_failed db 'assertion failed',0
|
||||
|
@ -1,6 +1,6 @@
|
||||
|
||||
; flat assembler core
|
||||
; Copyright (c) 1999-2012, Tomasz Grysztar.
|
||||
; Copyright (c) 1999-2013, Tomasz Grysztar.
|
||||
; All rights reserved.
|
||||
|
||||
parser:
|
||||
@ -64,6 +64,8 @@ parser:
|
||||
simple_label:
|
||||
pop edi
|
||||
call identify_label
|
||||
cmp byte [esi+1],':'
|
||||
je block_label
|
||||
mov byte [edi],2
|
||||
inc edi
|
||||
stos dword [edi]
|
||||
@ -71,6 +73,12 @@ parser:
|
||||
xor al,al
|
||||
stos byte [edi]
|
||||
jmp parse_line
|
||||
block_label:
|
||||
mov byte [edi],4
|
||||
inc edi
|
||||
stos dword [edi]
|
||||
add esi,2
|
||||
jmp parse_line
|
||||
constant_label:
|
||||
pop edi
|
||||
call get_label_id
|
||||
@ -127,8 +135,6 @@ parser:
|
||||
cmp al,':'
|
||||
je invalid_name
|
||||
dec esi
|
||||
cmp al,3Bh
|
||||
je skip_rest_of_line
|
||||
mov [parenthesis_stack],0
|
||||
call parse_argument
|
||||
jmp parse_next_line
|
||||
@ -530,6 +536,8 @@ parse_line_contents:
|
||||
je unallowed_character
|
||||
cmp al,'`'
|
||||
je unallowed_character
|
||||
cmp al,3Bh
|
||||
je foreign_argument
|
||||
dec esi
|
||||
cmp al,1Ah
|
||||
jne expression_argument
|
||||
@ -550,6 +558,10 @@ parse_line_contents:
|
||||
pop edi
|
||||
movs byte [edi],[esi]
|
||||
jmp argument_parsed
|
||||
foreign_argument:
|
||||
dec esi
|
||||
call skip_foreign_line
|
||||
jmp contents_parsed
|
||||
symbol_argument:
|
||||
pop edi
|
||||
stos word [edi]
|
||||
@ -560,7 +572,7 @@ parse_line_contents:
|
||||
je ptr_argument
|
||||
stos byte [edi]
|
||||
cmp al,80h
|
||||
je forced_expression
|
||||
je forced_multipart_expression
|
||||
cmp al,8Ch
|
||||
je forced_expression
|
||||
cmp al,81h
|
||||
@ -725,7 +737,7 @@ parse_line_contents:
|
||||
jmp argument_parsed
|
||||
parse_from_operator:
|
||||
cmp byte [esi],22h
|
||||
jne forced_expression
|
||||
jne forced_multipart_expression
|
||||
jmp argument_parsed
|
||||
parse_quoted_extrn:
|
||||
inc esi
|
||||
@ -771,14 +783,10 @@ parse_line_contents:
|
||||
mov eax,[esi+1]
|
||||
lea ebx,[esi+5+eax]
|
||||
push ebx ecx esi edi
|
||||
mov al,'('
|
||||
stos byte [edi]
|
||||
call convert_expression
|
||||
mov al,')'
|
||||
stos byte [edi]
|
||||
call parse_expression
|
||||
pop eax edx ecx ebx
|
||||
cmp esi,ebx
|
||||
jne expression_parsed
|
||||
jne expression_argument_parsed
|
||||
mov edi,eax
|
||||
mov esi,edx
|
||||
string_argument:
|
||||
@ -799,7 +807,14 @@ parse_line_contents:
|
||||
rep movs dword [edi],[esi]
|
||||
xor al,al
|
||||
stos byte [edi]
|
||||
jmp expression_parsed
|
||||
jmp expression_argument_parsed
|
||||
parse_expression:
|
||||
mov al,'('
|
||||
stos byte [edi]
|
||||
call convert_expression
|
||||
mov al,')'
|
||||
stos byte [edi]
|
||||
ret
|
||||
not_string:
|
||||
cmp byte [esi],'('
|
||||
jne expression
|
||||
@ -838,24 +853,27 @@ parse_line_contents:
|
||||
mov al,0F1h
|
||||
jmp expression_comparator
|
||||
expression:
|
||||
mov al,'('
|
||||
stos byte [edi]
|
||||
call convert_expression
|
||||
mov al,')'
|
||||
stos byte [edi]
|
||||
jmp expression_parsed
|
||||
call parse_expression
|
||||
jmp expression_argument_parsed
|
||||
forced_expression:
|
||||
xor al,al
|
||||
xchg al,[formatter_symbols_allowed]
|
||||
push eax
|
||||
mov al,'('
|
||||
stos byte [edi]
|
||||
call convert_expression
|
||||
mov al,')'
|
||||
stos byte [edi]
|
||||
call parse_expression
|
||||
forced_expression_parsed:
|
||||
pop eax
|
||||
mov [formatter_symbols_allowed],al
|
||||
jmp argument_parsed
|
||||
forced_multipart_expression:
|
||||
xor al,al
|
||||
xchg al,[formatter_symbols_allowed]
|
||||
push eax
|
||||
call parse_expression
|
||||
cmp byte [esi],':'
|
||||
jne forced_expression_parsed
|
||||
movs byte [edi],[esi]
|
||||
call parse_expression
|
||||
jmp forced_expression_parsed
|
||||
address_argument:
|
||||
call parse_address
|
||||
lods byte [esi]
|
||||
@ -925,7 +943,7 @@ parse_line_contents:
|
||||
dec [parenthesis_stack]
|
||||
add esp,8
|
||||
jmp argument_parsed
|
||||
expression_parsed:
|
||||
expression_argument_parsed:
|
||||
cmp [parenthesis_stack],0
|
||||
je parse_argument
|
||||
cmp byte [esi],')'
|
||||
|
@ -1,6 +1,6 @@
|
||||
|
||||
; flat assembler core
|
||||
; Copyright (c) 1999-2012, Tomasz Grysztar.
|
||||
; Copyright (c) 1999-2013, Tomasz Grysztar.
|
||||
; All rights reserved.
|
||||
|
||||
preprocessor:
|
||||
@ -38,7 +38,7 @@ preprocessor:
|
||||
mov [labels_list],eax
|
||||
xor eax,eax
|
||||
mov [source_start],eax
|
||||
mov [display_buffer],eax
|
||||
mov [tagged_blocks],eax
|
||||
mov [hash_tree],eax
|
||||
mov [error],eax
|
||||
mov [macro_status],al
|
||||
@ -195,13 +195,13 @@ convert_line:
|
||||
lods byte [esi]
|
||||
stos byte [edi]
|
||||
cmp al,0Ah
|
||||
je missing_end_quote
|
||||
je no_end_quote
|
||||
cmp al,0Dh
|
||||
je missing_end_quote
|
||||
je no_end_quote
|
||||
or al,al
|
||||
jz missing_end_quote
|
||||
jz no_end_quote
|
||||
cmp al,1Ah
|
||||
je missing_end_quote
|
||||
je no_end_quote
|
||||
cmp al,ah
|
||||
jne copy_string
|
||||
lods byte [esi]
|
||||
@ -243,6 +243,9 @@ convert_line:
|
||||
stos byte [edi]
|
||||
inc byte [ecx]
|
||||
jmp group_backslashes
|
||||
no_end_quote:
|
||||
mov byte [ebx-5],0
|
||||
jmp missing_end_quote
|
||||
backslashed_symbol:
|
||||
cmp al,1Ah
|
||||
je unexpected_end_of_file
|
||||
@ -554,6 +557,9 @@ preprocess_line:
|
||||
call get_preprocessor_symbol
|
||||
jnc symbolic_constant_in_label
|
||||
lea esi,[esi+ecx+1]
|
||||
cmp byte [esi],':'
|
||||
jne preprocess_instruction
|
||||
inc esi
|
||||
jmp preprocess_instruction
|
||||
symbolic_constant_in_label:
|
||||
mov ebx,[edx+8]
|
||||
@ -571,6 +577,9 @@ preprocess_line:
|
||||
cmp byte [ebx],':'
|
||||
jne label_broken
|
||||
inc ebx
|
||||
cmp byte [ebx],':'
|
||||
jne check_for_broken_label
|
||||
inc ebx
|
||||
jmp check_for_broken_label
|
||||
label_broken:
|
||||
push line_preprocessed
|
||||
@ -1685,6 +1694,7 @@ do_irp:
|
||||
or [default_argument_value],-1
|
||||
call skip_macro_argument_value
|
||||
inc esi
|
||||
jmp irp_parameters_start
|
||||
irps_name_ok:
|
||||
cmp al,','
|
||||
jne invalid_macro_arguments
|
||||
|
@ -1,435 +1,450 @@
|
||||
|
||||
; flat assembler core
|
||||
; Copyright (c) 1999-2012, Tomasz Grysztar.
|
||||
; All rights reserved.
|
||||
|
||||
dump_symbols:
|
||||
mov edi,[code_start]
|
||||
call setup_dump_header
|
||||
mov esi,[input_file]
|
||||
call copy_asciiz
|
||||
cmp edi,[display_buffer]
|
||||
jae out_of_memory
|
||||
mov eax,edi
|
||||
sub eax,ebx
|
||||
mov [ebx-40h+0Ch],eax
|
||||
mov esi,[output_file]
|
||||
call copy_asciiz
|
||||
cmp edi,[display_buffer]
|
||||
jae out_of_memory
|
||||
mov edx,[symbols_stream]
|
||||
mov ebp,[free_additional_memory]
|
||||
and [number_of_sections],0
|
||||
cmp [output_format],4
|
||||
je prepare_strings_table
|
||||
cmp [output_format],5
|
||||
jne strings_table_ready
|
||||
bt [format_flags],0
|
||||
jc strings_table_ready
|
||||
prepare_strings_table:
|
||||
cmp edx,ebp
|
||||
je strings_table_ready
|
||||
mov al,[edx]
|
||||
test al,al
|
||||
jz prepare_string
|
||||
cmp al,80h
|
||||
je prepare_string
|
||||
add edx,0Ch
|
||||
cmp al,0C0h
|
||||
jb prepare_strings_table
|
||||
add edx,4
|
||||
jmp prepare_strings_table
|
||||
prepare_string:
|
||||
mov esi,edi
|
||||
sub esi,ebx
|
||||
xchg esi,[edx+4]
|
||||
test al,al
|
||||
jz prepare_section_string
|
||||
or dword [edx+4],1 shl 31
|
||||
add edx,0Ch
|
||||
prepare_external_string:
|
||||
mov ecx,[esi]
|
||||
add esi,4
|
||||
rep movs byte [edi],[esi]
|
||||
mov byte [edi],0
|
||||
inc edi
|
||||
cmp edi,[display_buffer]
|
||||
jae out_of_memory
|
||||
jmp prepare_strings_table
|
||||
prepare_section_string:
|
||||
mov ecx,[number_of_sections]
|
||||
mov eax,ecx
|
||||
inc eax
|
||||
mov [number_of_sections],eax
|
||||
xchg eax,[edx+4]
|
||||
shl ecx,2
|
||||
add ecx,[free_additional_memory]
|
||||
mov [ecx],eax
|
||||
add edx,20h
|
||||
test esi,esi
|
||||
jz prepare_default_section_string
|
||||
cmp [output_format],5
|
||||
jne prepare_external_string
|
||||
bt [format_flags],0
|
||||
jc prepare_external_string
|
||||
mov esi,[esi]
|
||||
add esi,[resource_data]
|
||||
copy_elf_section_name:
|
||||
lods byte [esi]
|
||||
cmp edi,[display_buffer]
|
||||
jae out_of_memory
|
||||
stos byte [edi]
|
||||
test al,al
|
||||
jnz copy_elf_section_name
|
||||
jmp prepare_strings_table
|
||||
prepare_default_section_string:
|
||||
mov eax,'.fla'
|
||||
stos dword [edi]
|
||||
mov ax,'t'
|
||||
stos word [edi]
|
||||
cmp edi,[display_buffer]
|
||||
jae out_of_memory
|
||||
jmp prepare_strings_table
|
||||
strings_table_ready:
|
||||
mov edx,[display_buffer]
|
||||
mov ebp,[memory_end]
|
||||
sub ebp,[labels_list]
|
||||
add ebp,edx
|
||||
prepare_labels_dump:
|
||||
cmp edx,ebp
|
||||
je labels_dump_ok
|
||||
mov eax,[edx+24]
|
||||
test eax,eax
|
||||
jz label_dump_name_ok
|
||||
cmp eax,[memory_start]
|
||||
jb label_name_outside_source
|
||||
cmp eax,[source_start]
|
||||
ja label_name_outside_source
|
||||
sub eax,[memory_start]
|
||||
dec eax
|
||||
mov [edx+24],eax
|
||||
jmp label_dump_name_ok
|
||||
label_name_outside_source:
|
||||
mov esi,eax
|
||||
mov eax,edi
|
||||
sub eax,ebx
|
||||
or eax,1 shl 31
|
||||
mov [edx+24],eax
|
||||
movzx ecx,byte [esi-1]
|
||||
lea eax,[edi+ecx+1]
|
||||
cmp edi,[display_buffer]
|
||||
jae out_of_memory
|
||||
rep movsb
|
||||
xor al,al
|
||||
stosb
|
||||
label_dump_name_ok:
|
||||
mov eax,[edx+28]
|
||||
test eax,eax
|
||||
jz label_dump_line_ok
|
||||
sub eax,[memory_start]
|
||||
mov [edx+28],eax
|
||||
label_dump_line_ok:
|
||||
mov eax,[edx+20]
|
||||
test eax,eax
|
||||
jz base_symbol_for_label_ok
|
||||
cmp eax,[symbols_stream]
|
||||
mov eax,[eax+4]
|
||||
jae base_symbol_for_label_ok
|
||||
xor eax,eax
|
||||
base_symbol_for_label_ok:
|
||||
mov [edx+20],eax
|
||||
mov ax,[current_pass]
|
||||
cmp ax,[edx+16]
|
||||
je label_defined_flag_ok
|
||||
and byte [edx+8],not 1
|
||||
label_defined_flag_ok:
|
||||
cmp ax,[edx+18]
|
||||
je label_used_flag_ok
|
||||
and byte [edx+8],not 8
|
||||
label_used_flag_ok:
|
||||
add edx,LABEL_STRUCTURE_SIZE
|
||||
jmp prepare_labels_dump
|
||||
labels_dump_ok:
|
||||
mov eax,edi
|
||||
sub eax,ebx
|
||||
mov [ebx-40h+14h],eax
|
||||
add eax,40h
|
||||
mov [ebx-40h+18h],eax
|
||||
mov ecx,[memory_end]
|
||||
sub ecx,[labels_list]
|
||||
mov [ebx-40h+1Ch],ecx
|
||||
add eax,ecx
|
||||
mov [ebx-40h+20h],eax
|
||||
mov ecx,[source_start]
|
||||
sub ecx,[memory_start]
|
||||
mov [ebx-40h+24h],ecx
|
||||
add eax,ecx
|
||||
mov [ebx-40h+28h],eax
|
||||
mov eax,[number_of_sections]
|
||||
shl eax,2
|
||||
mov [ebx-40h+34h],eax
|
||||
call prepare_preprocessed_source
|
||||
mov esi,[labels_list]
|
||||
mov ebp,edi
|
||||
make_lines_dump:
|
||||
cmp esi,[display_buffer]
|
||||
je lines_dump_ok
|
||||
mov eax,[esi-4]
|
||||
mov ecx,[esi-8]
|
||||
sub esi,8
|
||||
sub esi,ecx
|
||||
cmp eax,1
|
||||
je process_line_dump
|
||||
cmp eax,2
|
||||
jne make_lines_dump
|
||||
add dword [ebx-40h+3Ch],8
|
||||
jmp make_lines_dump
|
||||
process_line_dump:
|
||||
mov eax,[esi+4]
|
||||
sub eax,[code_start]
|
||||
add eax,[headers_size]
|
||||
cmp byte [esi+1Ah],0
|
||||
je store_offset
|
||||
xor eax,eax
|
||||
store_offset:
|
||||
stos dword [edi]
|
||||
mov eax,[esi]
|
||||
sub eax,[memory_start]
|
||||
stos dword [edi]
|
||||
mov eax,[esi+4]
|
||||
xor edx,edx
|
||||
xor cl,cl
|
||||
sub eax,[esi+8]
|
||||
sbb edx,[esi+8+4]
|
||||
sbb cl,[esi+1Bh]
|
||||
stos dword [edi]
|
||||
mov eax,edx
|
||||
stos dword [edi]
|
||||
mov eax,[esi+10h]
|
||||
stos dword [edi]
|
||||
mov eax,[esi+14h]
|
||||
test eax,eax
|
||||
jz base_symbol_for_line_ok
|
||||
cmp eax,[symbols_stream]
|
||||
mov eax,[eax+4]
|
||||
jae base_symbol_for_line_ok
|
||||
xor eax,eax
|
||||
base_symbol_for_line_ok:
|
||||
stos dword [edi]
|
||||
mov eax,[esi+18h]
|
||||
and eax,01FFFFh
|
||||
stos dword [edi]
|
||||
mov [edi-1],cl
|
||||
cmp edi,[display_buffer]
|
||||
jae out_of_memory
|
||||
mov eax,edi
|
||||
sub eax,1Ch
|
||||
sub eax,ebp
|
||||
mov [esi],eax
|
||||
jmp make_lines_dump
|
||||
lines_dump_ok:
|
||||
mov edx,edi
|
||||
mov eax,[current_offset]
|
||||
sub eax,[code_start]
|
||||
add eax,[headers_size]
|
||||
stos dword [edi]
|
||||
mov ecx,edi
|
||||
sub ecx,ebx
|
||||
sub ecx,[ebx-40h+14h]
|
||||
mov [ebx-40h+2Ch],ecx
|
||||
add ecx,[ebx-40h+28h]
|
||||
mov [ebx-40h+30h],ecx
|
||||
add ecx,[ebx-40h+34h]
|
||||
mov [ebx-40h+38h],ecx
|
||||
find_inexisting_offsets:
|
||||
sub edx,1Ch
|
||||
cmp edx,ebp
|
||||
jb write_symbols
|
||||
test byte [edx+1Ah],1
|
||||
jnz find_inexisting_offsets
|
||||
cmp eax,[edx]
|
||||
jb correct_inexisting_offset
|
||||
mov eax,[edx]
|
||||
jmp find_inexisting_offsets
|
||||
correct_inexisting_offset:
|
||||
and dword [edx],0
|
||||
or byte [edx+1Ah],2
|
||||
jmp find_inexisting_offsets
|
||||
write_symbols:
|
||||
mov edx,[symbols_file]
|
||||
call create
|
||||
jc write_failed
|
||||
mov edx,[code_start]
|
||||
mov ecx,[edx+14h]
|
||||
add ecx,40h
|
||||
call write
|
||||
jc write_failed
|
||||
mov edx,[display_buffer]
|
||||
mov ecx,[memory_end]
|
||||
sub ecx,[labels_list]
|
||||
call write
|
||||
jc write_failed
|
||||
mov edx,[memory_start]
|
||||
mov ecx,[source_start]
|
||||
sub ecx,edx
|
||||
call write
|
||||
jc write_failed
|
||||
mov edx,ebp
|
||||
mov ecx,edi
|
||||
sub ecx,edx
|
||||
call write
|
||||
jc write_failed
|
||||
mov edx,[free_additional_memory]
|
||||
mov ecx,[number_of_sections]
|
||||
shl ecx,2
|
||||
call write
|
||||
jc write_failed
|
||||
mov esi,[labels_list]
|
||||
mov edi,[memory_start]
|
||||
make_references_dump:
|
||||
cmp esi,[display_buffer]
|
||||
je references_dump_ok
|
||||
mov eax,[esi-4]
|
||||
mov ecx,[esi-8]
|
||||
sub esi,8
|
||||
sub esi,ecx
|
||||
cmp eax,2
|
||||
je dump_reference
|
||||
cmp eax,1
|
||||
jne make_references_dump
|
||||
mov edx,[esi]
|
||||
jmp make_references_dump
|
||||
dump_reference:
|
||||
mov eax,[memory_end]
|
||||
sub eax,[esi]
|
||||
sub eax,LABEL_STRUCTURE_SIZE
|
||||
stosd
|
||||
mov eax,edx
|
||||
stosd
|
||||
cmp edi,[display_buffer]
|
||||
jb make_references_dump
|
||||
jmp out_of_memory
|
||||
references_dump_ok:
|
||||
mov edx,[memory_start]
|
||||
mov ecx,edi
|
||||
sub ecx,edx
|
||||
call write
|
||||
jc write_failed
|
||||
call close
|
||||
ret
|
||||
setup_dump_header:
|
||||
xor eax,eax
|
||||
mov ecx,40h shr 2
|
||||
rep stos dword [edi]
|
||||
mov ebx,edi
|
||||
mov dword [ebx-40h],'fas'+1Ah shl 24
|
||||
mov dword [ebx-40h+4],VERSION_MAJOR + VERSION_MINOR shl 8 + 40h shl 16
|
||||
mov dword [ebx-40h+10h],40h
|
||||
ret
|
||||
prepare_preprocessed_source:
|
||||
mov esi,[memory_start]
|
||||
mov ebp,[source_start]
|
||||
test ebp,ebp
|
||||
jnz prepare_preprocessed_line
|
||||
mov ebp,[current_line]
|
||||
inc ebp
|
||||
prepare_preprocessed_line:
|
||||
cmp esi,ebp
|
||||
jae preprocessed_source_ok
|
||||
mov eax,[memory_start]
|
||||
mov edx,[input_file]
|
||||
cmp [esi],edx
|
||||
jne line_not_from_main_input
|
||||
mov [esi],eax
|
||||
line_not_from_main_input:
|
||||
sub [esi],eax
|
||||
test byte [esi+7],1 shl 7
|
||||
jz prepare_next_preprocessed_line
|
||||
sub [esi+8],eax
|
||||
sub [esi+12],eax
|
||||
prepare_next_preprocessed_line:
|
||||
call skip_preprocessed_line
|
||||
jmp prepare_preprocessed_line
|
||||
preprocessed_source_ok:
|
||||
ret
|
||||
skip_preprocessed_line:
|
||||
add esi,16
|
||||
skip_preprocessed_line_content:
|
||||
lods byte [esi]
|
||||
cmp al,1Ah
|
||||
je skip_preprocessed_symbol
|
||||
cmp al,3Bh
|
||||
je skip_preprocessed_symbol
|
||||
cmp al,22h
|
||||
je skip_preprocessed_string
|
||||
or al,al
|
||||
jnz skip_preprocessed_line_content
|
||||
ret
|
||||
skip_preprocessed_string:
|
||||
lods dword [esi]
|
||||
add esi,eax
|
||||
jmp skip_preprocessed_line_content
|
||||
skip_preprocessed_symbol:
|
||||
lods byte [esi]
|
||||
movzx eax,al
|
||||
add esi,eax
|
||||
jmp skip_preprocessed_line_content
|
||||
restore_preprocessed_source:
|
||||
mov esi,[memory_start]
|
||||
mov ebp,[source_start]
|
||||
test ebp,ebp
|
||||
jnz restore_preprocessed_line
|
||||
mov ebp,[current_line]
|
||||
inc ebp
|
||||
restore_preprocessed_line:
|
||||
cmp esi,ebp
|
||||
jae preprocessed_source_restored
|
||||
mov eax,[memory_start]
|
||||
add [esi],eax
|
||||
cmp [esi],eax
|
||||
jne preprocessed_line_source_restored
|
||||
mov edx,[input_file]
|
||||
mov [esi],edx
|
||||
preprocessed_line_source_restored:
|
||||
test byte [esi+7],1 shl 7
|
||||
jz restore_next_preprocessed_line
|
||||
add [esi+8],eax
|
||||
add [esi+12],eax
|
||||
restore_next_preprocessed_line:
|
||||
call skip_preprocessed_line
|
||||
jmp restore_preprocessed_line
|
||||
preprocessed_source_restored:
|
||||
ret
|
||||
dump_preprocessed_source:
|
||||
mov edi,[free_additional_memory]
|
||||
call setup_dump_header
|
||||
mov esi,[input_file]
|
||||
call copy_asciiz
|
||||
cmp edi,[additional_memory_end]
|
||||
jae out_of_memory
|
||||
mov eax,edi
|
||||
sub eax,ebx
|
||||
dec eax
|
||||
mov [ebx-40h+0Ch],eax
|
||||
mov eax,edi
|
||||
sub eax,ebx
|
||||
mov [ebx-40h+14h],eax
|
||||
add eax,40h
|
||||
mov [ebx-40h+20h],eax
|
||||
call prepare_preprocessed_source
|
||||
sub esi,[memory_start]
|
||||
mov [ebx-40h+24h],esi
|
||||
mov edx,[symbols_file]
|
||||
call create
|
||||
jc write_failed
|
||||
mov edx,[free_additional_memory]
|
||||
mov ecx,[edx+14h]
|
||||
add ecx,40h
|
||||
call write
|
||||
jc write_failed
|
||||
mov edx,[memory_start]
|
||||
mov ecx,esi
|
||||
call write
|
||||
jc write_failed
|
||||
call close
|
||||
|
||||
; flat assembler core
|
||||
; Copyright (c) 1999-2013, Tomasz Grysztar.
|
||||
; All rights reserved.
|
||||
|
||||
dump_symbols:
|
||||
mov edi,[code_start]
|
||||
call setup_dump_header
|
||||
mov esi,[input_file]
|
||||
call copy_asciiz
|
||||
cmp edi,[tagged_blocks]
|
||||
jae out_of_memory
|
||||
mov eax,edi
|
||||
sub eax,ebx
|
||||
mov [ebx-40h+0Ch],eax
|
||||
mov esi,[output_file]
|
||||
call copy_asciiz
|
||||
cmp edi,[tagged_blocks]
|
||||
jae out_of_memory
|
||||
mov edx,[symbols_stream]
|
||||
mov ebp,[free_additional_memory]
|
||||
and [number_of_sections],0
|
||||
cmp [output_format],4
|
||||
je prepare_strings_table
|
||||
cmp [output_format],5
|
||||
jne strings_table_ready
|
||||
bt [format_flags],0
|
||||
jc strings_table_ready
|
||||
prepare_strings_table:
|
||||
cmp edx,ebp
|
||||
je strings_table_ready
|
||||
mov al,[edx]
|
||||
test al,al
|
||||
jz prepare_string
|
||||
cmp al,80h
|
||||
je prepare_string
|
||||
add edx,0Ch
|
||||
cmp al,0C0h
|
||||
jb prepare_strings_table
|
||||
add edx,4
|
||||
jmp prepare_strings_table
|
||||
prepare_string:
|
||||
mov esi,edi
|
||||
sub esi,ebx
|
||||
xchg esi,[edx+4]
|
||||
test al,al
|
||||
jz prepare_section_string
|
||||
or dword [edx+4],1 shl 31
|
||||
add edx,0Ch
|
||||
prepare_external_string:
|
||||
mov ecx,[esi]
|
||||
add esi,4
|
||||
rep movs byte [edi],[esi]
|
||||
mov byte [edi],0
|
||||
inc edi
|
||||
cmp edi,[tagged_blocks]
|
||||
jae out_of_memory
|
||||
jmp prepare_strings_table
|
||||
prepare_section_string:
|
||||
mov ecx,[number_of_sections]
|
||||
mov eax,ecx
|
||||
inc eax
|
||||
mov [number_of_sections],eax
|
||||
xchg eax,[edx+4]
|
||||
shl ecx,2
|
||||
add ecx,[free_additional_memory]
|
||||
mov [ecx],eax
|
||||
add edx,20h
|
||||
test esi,esi
|
||||
jz prepare_default_section_string
|
||||
cmp [output_format],5
|
||||
jne prepare_external_string
|
||||
bt [format_flags],0
|
||||
jc prepare_external_string
|
||||
mov esi,[esi]
|
||||
add esi,[resource_data]
|
||||
copy_elf_section_name:
|
||||
lods byte [esi]
|
||||
cmp edi,[tagged_blocks]
|
||||
jae out_of_memory
|
||||
stos byte [edi]
|
||||
test al,al
|
||||
jnz copy_elf_section_name
|
||||
jmp prepare_strings_table
|
||||
prepare_default_section_string:
|
||||
mov eax,'.fla'
|
||||
stos dword [edi]
|
||||
mov ax,'t'
|
||||
stos word [edi]
|
||||
cmp edi,[tagged_blocks]
|
||||
jae out_of_memory
|
||||
jmp prepare_strings_table
|
||||
strings_table_ready:
|
||||
mov edx,[tagged_blocks]
|
||||
mov ebp,[memory_end]
|
||||
sub ebp,[labels_list]
|
||||
add ebp,edx
|
||||
prepare_labels_dump:
|
||||
cmp edx,ebp
|
||||
je labels_dump_ok
|
||||
mov eax,[edx+24]
|
||||
test eax,eax
|
||||
jz label_dump_name_ok
|
||||
cmp eax,[memory_start]
|
||||
jb label_name_outside_source
|
||||
cmp eax,[source_start]
|
||||
ja label_name_outside_source
|
||||
sub eax,[memory_start]
|
||||
dec eax
|
||||
mov [edx+24],eax
|
||||
jmp label_dump_name_ok
|
||||
label_name_outside_source:
|
||||
mov esi,eax
|
||||
mov eax,edi
|
||||
sub eax,ebx
|
||||
or eax,1 shl 31
|
||||
mov [edx+24],eax
|
||||
movzx ecx,byte [esi-1]
|
||||
lea eax,[edi+ecx+1]
|
||||
cmp edi,[tagged_blocks]
|
||||
jae out_of_memory
|
||||
rep movsb
|
||||
xor al,al
|
||||
stosb
|
||||
label_dump_name_ok:
|
||||
mov eax,[edx+28]
|
||||
test eax,eax
|
||||
jz label_dump_line_ok
|
||||
sub eax,[memory_start]
|
||||
mov [edx+28],eax
|
||||
label_dump_line_ok:
|
||||
test byte [edx+9],4
|
||||
jz convert_base_symbol_for_label
|
||||
xor eax,eax
|
||||
mov [edx],eax
|
||||
mov [edx+4],eax
|
||||
jmp base_symbol_for_label_ok
|
||||
convert_base_symbol_for_label:
|
||||
mov eax,[edx+20]
|
||||
test eax,eax
|
||||
jz base_symbol_for_label_ok
|
||||
cmp eax,[symbols_stream]
|
||||
mov eax,[eax+4]
|
||||
jae base_symbol_for_label_ok
|
||||
xor eax,eax
|
||||
base_symbol_for_label_ok:
|
||||
mov [edx+20],eax
|
||||
mov ax,[current_pass]
|
||||
cmp ax,[edx+16]
|
||||
je label_defined_flag_ok
|
||||
and byte [edx+8],not 1
|
||||
label_defined_flag_ok:
|
||||
cmp ax,[edx+18]
|
||||
je label_used_flag_ok
|
||||
and byte [edx+8],not 8
|
||||
label_used_flag_ok:
|
||||
add edx,LABEL_STRUCTURE_SIZE
|
||||
jmp prepare_labels_dump
|
||||
labels_dump_ok:
|
||||
mov eax,edi
|
||||
sub eax,ebx
|
||||
mov [ebx-40h+14h],eax
|
||||
add eax,40h
|
||||
mov [ebx-40h+18h],eax
|
||||
mov ecx,[memory_end]
|
||||
sub ecx,[labels_list]
|
||||
mov [ebx-40h+1Ch],ecx
|
||||
add eax,ecx
|
||||
mov [ebx-40h+20h],eax
|
||||
mov ecx,[source_start]
|
||||
sub ecx,[memory_start]
|
||||
mov [ebx-40h+24h],ecx
|
||||
add eax,ecx
|
||||
mov [ebx-40h+28h],eax
|
||||
mov eax,[number_of_sections]
|
||||
shl eax,2
|
||||
mov [ebx-40h+34h],eax
|
||||
call prepare_preprocessed_source
|
||||
mov esi,[labels_list]
|
||||
mov ebp,edi
|
||||
make_lines_dump:
|
||||
cmp esi,[tagged_blocks]
|
||||
je lines_dump_ok
|
||||
mov eax,[esi-4]
|
||||
mov ecx,[esi-8]
|
||||
sub esi,8
|
||||
sub esi,ecx
|
||||
cmp eax,1
|
||||
je process_line_dump
|
||||
cmp eax,2
|
||||
jne make_lines_dump
|
||||
add dword [ebx-40h+3Ch],8
|
||||
jmp make_lines_dump
|
||||
process_line_dump:
|
||||
push ebx
|
||||
mov ebx,[esi+8]
|
||||
mov eax,[esi+4]
|
||||
sub eax,[code_start]
|
||||
add eax,[headers_size]
|
||||
test byte [ebx+0Ah],1
|
||||
jz store_offset
|
||||
xor eax,eax
|
||||
store_offset:
|
||||
stos dword [edi]
|
||||
mov eax,[esi]
|
||||
sub eax,[memory_start]
|
||||
stos dword [edi]
|
||||
mov eax,[esi+4]
|
||||
xor edx,edx
|
||||
xor cl,cl
|
||||
sub eax,[ebx]
|
||||
sbb edx,[ebx+4]
|
||||
sbb cl,[ebx+8]
|
||||
stos dword [edi]
|
||||
mov eax,edx
|
||||
stos dword [edi]
|
||||
mov eax,[ebx+10h]
|
||||
stos dword [edi]
|
||||
mov eax,[ebx+14h]
|
||||
test eax,eax
|
||||
jz base_symbol_for_line_ok
|
||||
cmp eax,[symbols_stream]
|
||||
mov eax,[eax+4]
|
||||
jae base_symbol_for_line_ok
|
||||
xor eax,eax
|
||||
base_symbol_for_line_ok:
|
||||
stos dword [edi]
|
||||
mov al,[ebx+9]
|
||||
stos byte [edi]
|
||||
mov al,[esi+10h]
|
||||
stos byte [edi]
|
||||
mov al,[ebx+0Ah]
|
||||
and al,1
|
||||
stos byte [edi]
|
||||
mov al,cl
|
||||
stos byte [edi]
|
||||
pop ebx
|
||||
cmp edi,[tagged_blocks]
|
||||
jae out_of_memory
|
||||
mov eax,edi
|
||||
sub eax,1Ch
|
||||
sub eax,ebp
|
||||
mov [esi],eax
|
||||
jmp make_lines_dump
|
||||
lines_dump_ok:
|
||||
mov edx,edi
|
||||
mov eax,[current_offset]
|
||||
sub eax,[code_start]
|
||||
add eax,[headers_size]
|
||||
stos dword [edi]
|
||||
mov ecx,edi
|
||||
sub ecx,ebx
|
||||
sub ecx,[ebx-40h+14h]
|
||||
mov [ebx-40h+2Ch],ecx
|
||||
add ecx,[ebx-40h+28h]
|
||||
mov [ebx-40h+30h],ecx
|
||||
add ecx,[ebx-40h+34h]
|
||||
mov [ebx-40h+38h],ecx
|
||||
find_inexisting_offsets:
|
||||
sub edx,1Ch
|
||||
cmp edx,ebp
|
||||
jb write_symbols
|
||||
test byte [edx+1Ah],1
|
||||
jnz find_inexisting_offsets
|
||||
cmp eax,[edx]
|
||||
jb correct_inexisting_offset
|
||||
mov eax,[edx]
|
||||
jmp find_inexisting_offsets
|
||||
correct_inexisting_offset:
|
||||
and dword [edx],0
|
||||
or byte [edx+1Ah],2
|
||||
jmp find_inexisting_offsets
|
||||
write_symbols:
|
||||
mov edx,[symbols_file]
|
||||
call create
|
||||
jc write_failed
|
||||
mov edx,[code_start]
|
||||
mov ecx,[edx+14h]
|
||||
add ecx,40h
|
||||
call write
|
||||
jc write_failed
|
||||
mov edx,[tagged_blocks]
|
||||
mov ecx,[memory_end]
|
||||
sub ecx,[labels_list]
|
||||
call write
|
||||
jc write_failed
|
||||
mov edx,[memory_start]
|
||||
mov ecx,[source_start]
|
||||
sub ecx,edx
|
||||
call write
|
||||
jc write_failed
|
||||
mov edx,ebp
|
||||
mov ecx,edi
|
||||
sub ecx,edx
|
||||
call write
|
||||
jc write_failed
|
||||
mov edx,[free_additional_memory]
|
||||
mov ecx,[number_of_sections]
|
||||
shl ecx,2
|
||||
call write
|
||||
jc write_failed
|
||||
mov esi,[labels_list]
|
||||
mov edi,[memory_start]
|
||||
make_references_dump:
|
||||
cmp esi,[tagged_blocks]
|
||||
je references_dump_ok
|
||||
mov eax,[esi-4]
|
||||
mov ecx,[esi-8]
|
||||
sub esi,8
|
||||
sub esi,ecx
|
||||
cmp eax,2
|
||||
je dump_reference
|
||||
cmp eax,1
|
||||
jne make_references_dump
|
||||
mov edx,[esi]
|
||||
jmp make_references_dump
|
||||
dump_reference:
|
||||
mov eax,[memory_end]
|
||||
sub eax,[esi]
|
||||
sub eax,LABEL_STRUCTURE_SIZE
|
||||
stosd
|
||||
mov eax,edx
|
||||
stosd
|
||||
cmp edi,[tagged_blocks]
|
||||
jb make_references_dump
|
||||
jmp out_of_memory
|
||||
references_dump_ok:
|
||||
mov edx,[memory_start]
|
||||
mov ecx,edi
|
||||
sub ecx,edx
|
||||
call write
|
||||
jc write_failed
|
||||
call close
|
||||
ret
|
||||
setup_dump_header:
|
||||
xor eax,eax
|
||||
mov ecx,40h shr 2
|
||||
rep stos dword [edi]
|
||||
mov ebx,edi
|
||||
mov dword [ebx-40h],'fas'+1Ah shl 24
|
||||
mov dword [ebx-40h+4],VERSION_MAJOR + VERSION_MINOR shl 8 + 40h shl 16
|
||||
mov dword [ebx-40h+10h],40h
|
||||
ret
|
||||
prepare_preprocessed_source:
|
||||
mov esi,[memory_start]
|
||||
mov ebp,[source_start]
|
||||
test ebp,ebp
|
||||
jnz prepare_preprocessed_line
|
||||
mov ebp,[current_line]
|
||||
inc ebp
|
||||
prepare_preprocessed_line:
|
||||
cmp esi,ebp
|
||||
jae preprocessed_source_ok
|
||||
mov eax,[memory_start]
|
||||
mov edx,[input_file]
|
||||
cmp [esi],edx
|
||||
jne line_not_from_main_input
|
||||
mov [esi],eax
|
||||
line_not_from_main_input:
|
||||
sub [esi],eax
|
||||
test byte [esi+7],1 shl 7
|
||||
jz prepare_next_preprocessed_line
|
||||
sub [esi+8],eax
|
||||
sub [esi+12],eax
|
||||
prepare_next_preprocessed_line:
|
||||
call skip_preprocessed_line
|
||||
jmp prepare_preprocessed_line
|
||||
preprocessed_source_ok:
|
||||
ret
|
||||
skip_preprocessed_line:
|
||||
add esi,16
|
||||
skip_preprocessed_line_content:
|
||||
lods byte [esi]
|
||||
cmp al,1Ah
|
||||
je skip_preprocessed_symbol
|
||||
cmp al,3Bh
|
||||
je skip_preprocessed_symbol
|
||||
cmp al,22h
|
||||
je skip_preprocessed_string
|
||||
or al,al
|
||||
jnz skip_preprocessed_line_content
|
||||
ret
|
||||
skip_preprocessed_string:
|
||||
lods dword [esi]
|
||||
add esi,eax
|
||||
jmp skip_preprocessed_line_content
|
||||
skip_preprocessed_symbol:
|
||||
lods byte [esi]
|
||||
movzx eax,al
|
||||
add esi,eax
|
||||
jmp skip_preprocessed_line_content
|
||||
restore_preprocessed_source:
|
||||
mov esi,[memory_start]
|
||||
mov ebp,[source_start]
|
||||
test ebp,ebp
|
||||
jnz restore_preprocessed_line
|
||||
mov ebp,[current_line]
|
||||
inc ebp
|
||||
restore_preprocessed_line:
|
||||
cmp esi,ebp
|
||||
jae preprocessed_source_restored
|
||||
mov eax,[memory_start]
|
||||
add [esi],eax
|
||||
cmp [esi],eax
|
||||
jne preprocessed_line_source_restored
|
||||
mov edx,[input_file]
|
||||
mov [esi],edx
|
||||
preprocessed_line_source_restored:
|
||||
test byte [esi+7],1 shl 7
|
||||
jz restore_next_preprocessed_line
|
||||
add [esi+8],eax
|
||||
add [esi+12],eax
|
||||
restore_next_preprocessed_line:
|
||||
call skip_preprocessed_line
|
||||
jmp restore_preprocessed_line
|
||||
preprocessed_source_restored:
|
||||
ret
|
||||
dump_preprocessed_source:
|
||||
mov edi,[free_additional_memory]
|
||||
call setup_dump_header
|
||||
mov esi,[input_file]
|
||||
call copy_asciiz
|
||||
cmp edi,[additional_memory_end]
|
||||
jae out_of_memory
|
||||
mov eax,edi
|
||||
sub eax,ebx
|
||||
dec eax
|
||||
mov [ebx-40h+0Ch],eax
|
||||
mov eax,edi
|
||||
sub eax,ebx
|
||||
mov [ebx-40h+14h],eax
|
||||
add eax,40h
|
||||
mov [ebx-40h+20h],eax
|
||||
call prepare_preprocessed_source
|
||||
sub esi,[memory_start]
|
||||
mov [ebx-40h+24h],esi
|
||||
mov edx,[symbols_file]
|
||||
call create
|
||||
jc write_failed
|
||||
mov edx,[free_additional_memory]
|
||||
mov ecx,[edx+14h]
|
||||
add ecx,40h
|
||||
call write
|
||||
jc write_failed
|
||||
mov edx,[memory_start]
|
||||
mov ecx,esi
|
||||
call write
|
||||
jc write_failed
|
||||
call close
|
||||
ret
|
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,6 @@
|
||||
|
||||
; flat assembler core variables
|
||||
; Copyright (c) 1999-2012, Tomasz Grysztar.
|
||||
; Copyright (c) 1999-2013, Tomasz Grysztar.
|
||||
; All rights reserved.
|
||||
|
||||
; Variables which have to be set up by interface:
|
||||
@ -50,10 +50,7 @@ labels_list dd ?
|
||||
label_hash dd ?
|
||||
label_leaf dd ?
|
||||
hash_tree dd ?
|
||||
org_origin dq ?
|
||||
org_registers dd ?
|
||||
org_symbol dd ?
|
||||
org_start dd ?
|
||||
addressing_space dd ?
|
||||
undefined_data_start dd ?
|
||||
undefined_data_end dd ?
|
||||
counter dd ?
|
||||
@ -61,7 +58,7 @@ counter_limit dd ?
|
||||
error_info dd ?
|
||||
error_line dd ?
|
||||
error dd ?
|
||||
display_buffer dd ?
|
||||
tagged_blocks dd ?
|
||||
structures_buffer dd ?
|
||||
number_start dd ?
|
||||
current_offset dd ?
|
||||
@ -131,16 +128,15 @@ compare_type db ?
|
||||
logical_value_wrapping db ?
|
||||
next_pass_needed db ?
|
||||
output_format db ?
|
||||
labels_type db ?
|
||||
code_type db ?
|
||||
virtual_data db ?
|
||||
org_origin_sign db ?
|
||||
adjustment_sign db ?
|
||||
|
||||
macro_status db ?
|
||||
default_argument_value db ?
|
||||
prefixed_instruction db ?
|
||||
formatter_symbols_allowed db ?
|
||||
free_address_range db ?
|
||||
|
||||
|
||||
characters rb 100h
|
||||
converted rb 100h
|
||||
|
@ -1,6 +1,6 @@
|
||||
|
||||
; flat assembler version 1.70
|
||||
; Copyright (c) 1999-2012, Tomasz Grysztar.
|
||||
; flat assembler version 1.71
|
||||
; Copyright (c) 1999-2013, 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.70.03"
|
||||
VERSION_STRING equ "1.71.13"
|
||||
|
||||
VERSION_MAJOR = 1
|
||||
VERSION_MINOR = 70
|
||||
VERSION_MINOR = 71
|
||||
|
@ -1,6 +1,6 @@
|
||||
|
||||
; flat assembler core
|
||||
; Copyright (c) 1999-2012, Tomasz Grysztar.
|
||||
; Copyright (c) 1999-2013, Tomasz Grysztar.
|
||||
; All rights reserved.
|
||||
|
||||
simple_instruction_except64:
|
||||
@ -2989,6 +2989,7 @@ jmp_instruction:
|
||||
jmp instruction_assembled
|
||||
calculate_jump_offset:
|
||||
add edi,2
|
||||
mov ebp,[addressing_space]
|
||||
call calculate_relative_offset
|
||||
sub edi,2
|
||||
ret
|
||||
@ -5982,6 +5983,27 @@ movbe_instruction:
|
||||
mov al,[operand_size]
|
||||
call operand_autodetect
|
||||
jmp instruction_ready
|
||||
adx_instruction:
|
||||
mov [base_code],0Fh
|
||||
mov [extended_code],38h
|
||||
mov [supplemental_code],0F6h
|
||||
mov [operand_prefix],al
|
||||
call get_reg_mem
|
||||
jc adx_reg_reg
|
||||
mov al,[operand_size]
|
||||
cmp al,4
|
||||
je instruction_ready
|
||||
cmp al,8
|
||||
jne invalid_operand_size
|
||||
call operand_64bit
|
||||
jmp instruction_ready
|
||||
adx_reg_reg:
|
||||
cmp ah,4
|
||||
je nomem_instruction_ready
|
||||
cmp ah,8
|
||||
jne invalid_operand_size
|
||||
call operand_64bit
|
||||
jmp nomem_instruction_ready
|
||||
|
||||
simple_vmx_instruction:
|
||||
mov ah,al
|
||||
@ -6251,6 +6273,7 @@ xbegin_instruction:
|
||||
xbegin_16bit:
|
||||
call get_address_word_value
|
||||
add edi,4
|
||||
mov ebp,[addressing_space]
|
||||
call calculate_relative_offset
|
||||
sub edi,4
|
||||
shl eax,16
|
||||
@ -6264,6 +6287,7 @@ xbegin_instruction:
|
||||
call get_address_qword_value
|
||||
xbegin_address_ok:
|
||||
add edi,5
|
||||
mov ebp,[addressing_space]
|
||||
call calculate_relative_offset
|
||||
sub edi,5
|
||||
mov edx,eax
|
||||
@ -6383,6 +6407,7 @@ get_jump_operator:
|
||||
get_address:
|
||||
mov [segment_register],0
|
||||
mov [address_size],0
|
||||
mov [free_address_range],0
|
||||
mov al,[code_type]
|
||||
shr al,3
|
||||
mov [value_size],al
|
||||
@ -6422,6 +6447,7 @@ get_address:
|
||||
mov edx,[address_symbol]
|
||||
mov [symbol_identifier],edx
|
||||
mov edx,[address_high]
|
||||
mov ebp,[addressing_space]
|
||||
call calculate_relative_offset
|
||||
mov [address_high],edx
|
||||
cdq
|
||||
|
@ -55,11 +55,15 @@ macro proc [args] ; define procedure
|
||||
prologue@proc equ prologuedef
|
||||
|
||||
macro prologuedef procname,flag,parmbytes,localbytes,reglist
|
||||
{ if parmbytes | localbytes
|
||||
{ local loc
|
||||
loc = (localbytes+3) and (not 3)
|
||||
parmbase@proc equ ebp+8
|
||||
localbase@proc equ ebp-loc
|
||||
if parmbytes | localbytes
|
||||
push ebp
|
||||
mov ebp,esp
|
||||
if localbytes
|
||||
sub esp,localbytes
|
||||
sub esp,loc
|
||||
end if
|
||||
end if
|
||||
irps reg, reglist \{ push reg \} }
|
||||
@ -77,6 +81,8 @@ macro epiloguedef procname,flag,parmbytes,localbytes,reglist
|
||||
retn parmbytes
|
||||
end if }
|
||||
|
||||
close@proc equ
|
||||
|
||||
macro define@proc name,statement
|
||||
{ local params,flag,regs,parmbytes,localbytes,current
|
||||
if used name
|
||||
@ -91,22 +97,22 @@ macro define@proc name,statement
|
||||
flag = 10001b \}
|
||||
match =params, params \{ params equ statement
|
||||
flag = 0 \}
|
||||
virtual at ebp+8
|
||||
match =uses reglist=,args, params \{ regs equ reglist
|
||||
params equ args \}
|
||||
match =regs =uses reglist, regs params \{ regs equ reglist
|
||||
params equ \}
|
||||
match =regs, regs \{ regs equ \}
|
||||
match prologue:reglist, prologue@proc:<regs> \{ prologue name,flag,parmbytes,localbytes,reglist \}
|
||||
virtual at parmbase@proc
|
||||
match =,args, params \{ defargs@proc args \}
|
||||
match =args@proc args, args@proc params \{ defargs@proc args \}
|
||||
parmbytes = $ - (ebp+8)
|
||||
parmbytes = $-(parmbase@proc)
|
||||
end virtual
|
||||
name # % = parmbytes/4
|
||||
all@vars equ
|
||||
current = 0
|
||||
match prologue:reglist, prologue@proc:<regs> \{ prologue name,flag,parmbytes,localbytes,reglist \}
|
||||
macro locals
|
||||
\{ virtual at ebp-localbytes+current
|
||||
\{ virtual at localbase@proc+current
|
||||
macro label def \\{ match . type,def> \\\{ deflocal@proc .,label,<type \\\} \\}
|
||||
struc db [val] \\{ \common deflocal@proc .,db,val \\}
|
||||
struc du [val] \\{ \common deflocal@proc .,du,val \\}
|
||||
@ -125,14 +131,15 @@ macro define@proc name,statement
|
||||
\{ purge label
|
||||
restruc db,du,dw,dp,dd,dt,dq
|
||||
restruc rb,rw,rp,rd,rt,rq
|
||||
current = $-(ebp-localbytes)
|
||||
current = $-(localbase@proc)
|
||||
end virtual \}
|
||||
macro ret operand
|
||||
\{ match any, operand \\{ retn operand \\}
|
||||
match , operand \\{ match epilogue:reglist, epilogue@proc:<regs>
|
||||
\\\{ epilogue name,flag,parmbytes,localbytes,reglist \\\} \\} \}
|
||||
macro finish@proc \{ localbytes = (((current-1) shr 2)+1) shl 2
|
||||
end if \} }
|
||||
match , operand \\{ match epilogue:reglist, epilogue@proc:<regs> \\\{ epilogue name,flag,parmbytes,localbytes,reglist \\\} \\} \}
|
||||
macro finish@proc
|
||||
\{ localbytes = current
|
||||
match close:reglist, close@proc:<regs> \\{ close name,flag,parmbytes,localbytes,reglist \\}
|
||||
end if \} }
|
||||
|
||||
macro defargs@proc [arg]
|
||||
{ common
|
||||
@ -143,7 +150,9 @@ macro defargs@proc [arg]
|
||||
\{ current@arg equ argname
|
||||
label ..arg type
|
||||
argname equ ..arg
|
||||
if dqword eq type
|
||||
if qqword eq type
|
||||
dd ?,?,?,?,?,?,?,?
|
||||
else if dqword eq type
|
||||
dd ?,?,?,?
|
||||
else if tbyte eq type
|
||||
dd ?,?,?
|
||||
@ -163,17 +172,19 @@ macro defargs@proc [arg]
|
||||
common
|
||||
end if }
|
||||
|
||||
macro deflocal@proc name,def,[val] { name def val }
|
||||
|
||||
macro deflocal@proc name,def,[val]
|
||||
{ common
|
||||
match vars, all@vars \{ all@vars equ all@vars, \}
|
||||
all@vars equ all@vars name
|
||||
forward
|
||||
local ..var,..tmp
|
||||
match =label,def \{ ..tmp equ \}
|
||||
match tmp,..tmp \{ ..var def val \}
|
||||
match ,..tmp \{ label ..var val \}
|
||||
..var def val
|
||||
match =?, val \{ ..tmp equ \}
|
||||
match any =dup (=?), val \{ ..tmp equ \}
|
||||
match any =?, val \{ ..tmp equ \}
|
||||
match any (=?), val \{ ..tmp equ \}
|
||||
match =label, def \{ ..tmp equ \}
|
||||
match tmp : value, ..tmp : val
|
||||
\{ tmp: end virtual
|
||||
initlocal@proc ..var,def value
|
||||
@ -181,6 +192,8 @@ macro deflocal@proc name,def,[val]
|
||||
common
|
||||
match first rest, ..var, \{ name equ first \} }
|
||||
|
||||
struc label type { label . type }
|
||||
|
||||
macro initlocal@proc name,def
|
||||
{ virtual at name
|
||||
def
|
||||
@ -238,8 +251,17 @@ macro local [var]
|
||||
match =TBYTE, vartype \\{ varname rt count
|
||||
restore done@local \\}
|
||||
match =DQWORD, vartype \\{ label varname dqword
|
||||
rq count+count
|
||||
rq count*2
|
||||
restore done@local \\}
|
||||
match =QQWORD, vartype \\{ label varname qqword
|
||||
rq count*4
|
||||
restore done@local \\}
|
||||
match =XWORD, vartype \\{ label varname xword
|
||||
rq count*2
|
||||
restore done@local \\}
|
||||
match =YWORD, vartype \\{ label varname yword
|
||||
rq count*4
|
||||
restore done@local \\}
|
||||
match , done@local \\{ virtual
|
||||
varname vartype
|
||||
end virtual
|
||||
@ -261,6 +283,15 @@ macro local [var]
|
||||
match =DQWORD, vartype \\{ label varname dqword
|
||||
dq ?,?
|
||||
restore done@local \\}
|
||||
match =QQWORD, vartype \\{ label varname qqword
|
||||
dq ?,?,?,?
|
||||
restore done@local \\}
|
||||
match =XWORD, vartype \\{ label varname xword
|
||||
dq ?,?
|
||||
restore done@local \\}
|
||||
match =YWORD, vartype \\{ label varname yword
|
||||
dq ?,?,?,?
|
||||
restore done@local \\}
|
||||
match , done@local \\{ varname vartype
|
||||
restore done@local \\} \}
|
||||
match ,done@local
|
||||
|
@ -2,53 +2,79 @@
|
||||
; Macroinstructions for defining data structures
|
||||
|
||||
macro struct name
|
||||
{ fields@struct equ name
|
||||
{ virtual at 0
|
||||
fields@struct equ name
|
||||
match child parent, name \{ fields@struct equ child,fields@\#parent \}
|
||||
sub@struct equ
|
||||
struc db [val] \{ \common fields@struct equ fields@struct,.,db,<val> \}
|
||||
struc dw [val] \{ \common fields@struct equ fields@struct,.,dw,<val> \}
|
||||
struc du [val] \{ \common fields@struct equ fields@struct,.,du,<val> \}
|
||||
struc dd [val] \{ \common fields@struct equ fields@struct,.,dd,<val> \}
|
||||
struc dp [val] \{ \common fields@struct equ fields@struct,.,dp,<val> \}
|
||||
struc dq [val] \{ \common fields@struct equ fields@struct,.,dq,<val> \}
|
||||
struc dt [val] \{ \common fields@struct equ fields@struct,.,dt,<val> \}
|
||||
struc rb count \{ fields@struct equ fields@struct,.,db,count dup (?) \}
|
||||
struc rw count \{ fields@struct equ fields@struct,.,dw,count dup (?) \}
|
||||
struc rd count \{ fields@struct equ fields@struct,.,dd,count dup (?) \}
|
||||
struc rp count \{ fields@struct equ fields@struct,.,dp,count dup (?) \}
|
||||
struc rq count \{ fields@struct equ fields@struct,.,dq,count dup (?) \}
|
||||
struc rt count \{ fields@struct equ fields@struct,.,dt,count dup (?) \}
|
||||
struc db [val] \{ \common define field@struct .,db,<val>
|
||||
fields@struct equ fields@struct,field@struct \}
|
||||
struc dw [val] \{ \common define field@struct .,dw,<val>
|
||||
fields@struct equ fields@struct,field@struct \}
|
||||
struc du [val] \{ \common define field@struct .,du,<val>
|
||||
fields@struct equ fields@struct,field@struct \}
|
||||
struc dd [val] \{ \common define field@struct .,dd,<val>
|
||||
fields@struct equ fields@struct,field@struct \}
|
||||
struc dp [val] \{ \common define field@struct .,dp,<val>
|
||||
fields@struct equ fields@struct,field@struct \}
|
||||
struc dq [val] \{ \common define field@struct .,dq,<val>
|
||||
fields@struct equ fields@struct,field@struct \}
|
||||
struc dt [val] \{ \common define field@struct .,dt,<val>
|
||||
fields@struct equ fields@struct,field@struct \}
|
||||
struc rb count \{ define field@struct .,db,count dup (?)
|
||||
fields@struct equ fields@struct,field@struct \}
|
||||
struc rw count \{ define field@struct .,dw,count dup (?)
|
||||
fields@struct equ fields@struct,field@struct \}
|
||||
struc rd count \{ define field@struct .,dd,count dup (?)
|
||||
fields@struct equ fields@struct,field@struct \}
|
||||
struc rp count \{ define field@struct .,dp,count dup (?)
|
||||
fields@struct equ fields@struct,field@struct \}
|
||||
struc rq count \{ define field@struct .,dq,count dup (?)
|
||||
fields@struct equ fields@struct,field@struct \}
|
||||
struc rt count \{ define field@struct .,dt,count dup (?)
|
||||
fields@struct equ fields@struct,field@struct \}
|
||||
macro db [val] \{ \common \local anonymous
|
||||
fields@struct equ fields@struct,anonymous,db,<val> \}
|
||||
define field@struct anonymous,db,<val>
|
||||
fields@struct equ fields@struct,field@struct \}
|
||||
macro dw [val] \{ \common \local anonymous
|
||||
fields@struct equ fields@struct,anonymous,dw,<val> \}
|
||||
define field@struct anonymous,dw,<val>
|
||||
fields@struct equ fields@struct,field@struct \}
|
||||
macro du [val] \{ \common \local anonymous
|
||||
fields@struct equ fields@struct,anonymous,du,<val> \}
|
||||
define field@struct anonymous,du,<val>
|
||||
fields@struct equ fields@struct,field@struct \}
|
||||
macro dd [val] \{ \common \local anonymous
|
||||
fields@struct equ fields@struct,anonymous,dd,<val> \}
|
||||
define field@struct anonymous,dd,<val>
|
||||
fields@struct equ fields@struct,field@struct \}
|
||||
macro dp [val] \{ \common \local anonymous
|
||||
fields@struct equ fields@struct,anonymous,dp,<val> \}
|
||||
define field@struct anonymous,dp,<val>
|
||||
fields@struct equ fields@struct,field@struct \}
|
||||
macro dq [val] \{ \common \local anonymous
|
||||
fields@struct equ fields@struct,anonymous,dq,<val> \}
|
||||
define field@struct anonymous,dq,<val>
|
||||
fields@struct equ fields@struct,field@struct \}
|
||||
macro dt [val] \{ \common \local anonymous
|
||||
fields@struct equ fields@struct,anonymous,dt,<val> \}
|
||||
define field@struct anonymous,dt,<val>
|
||||
fields@struct equ fields@struct,field@struct \}
|
||||
macro rb count \{ \local anonymous
|
||||
fields@struct equ fields@struct,anonymous,db,count dup (?) \}
|
||||
define field@struct anonymous,db,count dup (?)
|
||||
fields@struct equ fields@struct,field@struct \}
|
||||
macro rw count \{ \local anonymous
|
||||
fields@struct equ fields@struct,anonymous,dw,count dup (?) \}
|
||||
define field@struct anonymous,dw,count dup (?)
|
||||
fields@struct equ fields@struct,field@struct \}
|
||||
macro rd count \{ \local anonymous
|
||||
fields@struct equ fields@struct,anonymous,dd,count dup (?) \}
|
||||
define field@struct anonymous,dd,count dup (?)
|
||||
fields@struct equ fields@struct,field@struct \}
|
||||
macro rp count \{ \local anonymous
|
||||
fields@struct equ fields@struct,anonymous,dp,count dup (?) \}
|
||||
define field@struct anonymous,dp,count dup (?)
|
||||
fields@struct equ fields@struct,field@struct \}
|
||||
macro rq count \{ \local anonymous
|
||||
fields@struct equ fields@struct,anonymous,dq,count dup (?) \}
|
||||
define field@struct anonymous,dq,count dup (?)
|
||||
fields@struct equ fields@struct,field@struct \}
|
||||
macro rt count \{ \local anonymous
|
||||
fields@struct equ fields@struct,anonymous,dt,count dup (?) \}
|
||||
define field@struct anonymous,dt,count dup (?)
|
||||
fields@struct equ fields@struct,field@struct \}
|
||||
macro union \{ fields@struct equ fields@struct,,union,<
|
||||
sub@struct equ union \}
|
||||
macro struct \{ fields@struct equ fields@struct,,substruct,<
|
||||
sub@struct equ substruct \}
|
||||
virtual at 0 }
|
||||
sub@struct equ substruct \} }
|
||||
|
||||
macro ends
|
||||
{ match , sub@struct \{ restruc db,dw,du,dd,dp,dq,dt
|
||||
@ -56,19 +82,19 @@ macro ends
|
||||
purge db,dw,du,dd,dp,dq,dt
|
||||
purge rb,rw,rd,rp,rq,rt
|
||||
purge union,struct
|
||||
match name tail,fields@struct, \\{ if $
|
||||
display 'Error: definition of ',\\`name,' contains illegal instructions.',0Dh,0Ah
|
||||
err
|
||||
end if \\}
|
||||
match name=,fields,fields@struct \\{ fields@struct equ
|
||||
make@struct name,fields
|
||||
fields@\\#name equ fields \\}
|
||||
define fields@\\#name fields \\}
|
||||
end virtual \}
|
||||
match any, sub@struct \{ fields@struct equ fields@struct> \}
|
||||
restore sub@struct }
|
||||
|
||||
macro make@struct name,[field,type,def]
|
||||
{ common
|
||||
if $
|
||||
display 'Error: definition of ',`name,' contains illegal instructions.',0Dh,0Ah
|
||||
err
|
||||
end if
|
||||
local define
|
||||
define equ name
|
||||
forward
|
||||
@ -81,6 +107,14 @@ macro make@struct name,[field,type,def]
|
||||
|
||||
macro define@struct name,[field,type,def]
|
||||
{ common
|
||||
virtual
|
||||
db `name
|
||||
load initial@struct byte from 0
|
||||
if initial@struct = '.'
|
||||
display 'Error: name of structure should not begin with a dot.',0Dh,0Ah
|
||||
err
|
||||
end if
|
||||
end virtual
|
||||
local list
|
||||
list equ
|
||||
forward
|
||||
@ -88,6 +122,7 @@ macro define@struct name,[field,type,def]
|
||||
name#field type def
|
||||
sizeof.#name#field = $ - name#field
|
||||
else
|
||||
label name#.#type
|
||||
rb sizeof.#type
|
||||
end if
|
||||
local value
|
||||
@ -97,14 +132,28 @@ macro define@struct name,[field,type,def]
|
||||
sizeof.#name = $
|
||||
restruc name
|
||||
match values, list \{
|
||||
struc name value \\{
|
||||
struc name value \\{ \\local \\..base
|
||||
match any, fields@struct \\\{ fields@struct equ fields@struct,.,name,<values> \\\}
|
||||
match , fields@struct \\\{ label .
|
||||
match , fields@struct \\\{ label \\..base
|
||||
forward
|
||||
match , value \\\\{ field type def \\\\}
|
||||
match any, value \\\\{ field type value
|
||||
if ~ field eq .
|
||||
rb sizeof.#name#field - ($-field)
|
||||
end if \\\\}
|
||||
common label . at \\..base \\\}
|
||||
\\}
|
||||
macro name value \\{
|
||||
match any, fields@struct \\\{ \\\local anonymous
|
||||
fields@struct equ fields@struct,anonymous,name,<values> \\\}
|
||||
match , fields@struct \\\{
|
||||
forward
|
||||
match , value \\\\{ type def \\\\}
|
||||
match any, value \\\\{ \\\\local ..field
|
||||
..field = $
|
||||
type value
|
||||
if ~ field eq .
|
||||
rb sizeof.#name#field - ($-field)
|
||||
rb sizeof.#name#field - ($-..field)
|
||||
end if \\\\}
|
||||
common \\\} \\} \} }
|
||||
|
||||
@ -116,7 +165,7 @@ macro enable@substruct
|
||||
\forward
|
||||
\local sub
|
||||
match , field \\{ match any, type \\\{ enable@substruct
|
||||
make@substruct type,name,sub def
|
||||
make@substruct type,parent,sub def
|
||||
purge make@substruct
|
||||
define equ define,.,sub, \\\} \\}
|
||||
match any, field \\{ define equ define,.\#field,type,<def> \\}
|
||||
@ -127,21 +176,28 @@ enable@substruct
|
||||
|
||||
macro define@union parent,name,[field,type,def]
|
||||
{ common
|
||||
virtual at 0
|
||||
virtual at parent#.#name
|
||||
forward
|
||||
if ~ field eq .
|
||||
virtual at 0
|
||||
virtual at parent#.#name
|
||||
parent#field type def
|
||||
sizeof.#parent#field = $ - parent#field
|
||||
end virtual
|
||||
if sizeof.#parent#field > $
|
||||
rb sizeof.#parent#field - $
|
||||
if sizeof.#parent#field > $ - parent#.#name
|
||||
rb sizeof.#parent#field - ($ - parent#.#name)
|
||||
end if
|
||||
else
|
||||
virtual at parent#.#name
|
||||
label parent#.#type
|
||||
type def
|
||||
end virtual
|
||||
label name#.#type at parent#.#name
|
||||
if sizeof.#type > $ - parent#.#name
|
||||
rb sizeof.#type - ($ - parent#.#name)
|
||||
end if
|
||||
else if sizeof.#type > $
|
||||
rb sizeof.#type - $
|
||||
end if
|
||||
common
|
||||
sizeof.#name = $
|
||||
sizeof.#name = $ - parent#.#name
|
||||
end virtual
|
||||
struc name [value] \{ \common
|
||||
label .\#name
|
||||
@ -153,21 +209,23 @@ macro define@union parent,name,[field,type,def]
|
||||
match , last@union \\{ match , value \\\{ field type def \\\}
|
||||
match any, value \\\{ field type value \\\} \\}
|
||||
last@union equ field
|
||||
common rb sizeof.#name - ($ - .\#name) \} }
|
||||
common rb sizeof.#name - ($ - .\#name) \}
|
||||
macro name [value] \{ \common \local ..anonymous
|
||||
..anonymous name value \} }
|
||||
|
||||
macro define@substruct parent,name,[field,type,def]
|
||||
{ common
|
||||
virtual at 0
|
||||
virtual at parent#.#name
|
||||
forward
|
||||
if ~ field eq .
|
||||
parent#field type def
|
||||
sizeof.#parent#field = $ - parent#field
|
||||
else
|
||||
label parent#.#type
|
||||
rb sizeof.#type
|
||||
end if
|
||||
local value
|
||||
common
|
||||
sizeof.#name = $
|
||||
sizeof.#name = $ - parent#.#name
|
||||
end virtual
|
||||
struc name value \{
|
||||
label .\#name
|
||||
@ -177,4 +235,6 @@ macro define@substruct parent,name,[field,type,def]
|
||||
if ~ field eq .
|
||||
rb sizeof.#parent#field - ($-field)
|
||||
end if \\}
|
||||
common \} }
|
||||
common \}
|
||||
macro name value \{ \local ..anonymous
|
||||
..anonymous name \} }
|
||||
|
Loading…
Reference in New Issue
Block a user