Commit f0b80877 authored by Tomasz Buchert's avatar Tomasz Buchert

New upstream version 1.71.57

parent be266ee9
No preview for this file type
; flat assembler interface for DOS
; Copyright (c) 1999-2016, Tomasz Grysztar.
; All rights reserved.
init_dpmi_memory:
mov ax,500h ; get free memory information
mov edi,[buffer_address]
int 31h
mov ebx,[edi]
allocate_dpmi_memory:
mov edx,[memory_setting]
shl edx,10
jz dpmi_memory_size_ok
cmp ebx,edx
jbe dpmi_memory_size_ok
mov ebx,edx
dpmi_memory_size_ok:
mov [memory_end],ebx
mov ecx,ebx
shr ebx,16
mov ax,501h
int 31h
jnc dpmi_memory_ok
mov ebx,[memory_end]
shr ebx,1
cmp ebx,4000h
jb out_of_memory
jmp allocate_dpmi_memory
dpmi_memory_ok:
shl ebx,16
mov bx,cx
sub ebx,[program_base]
jc out_of_memory
mov [memory_start],ebx
add [memory_end],ebx
mov ax,100h ; get free conventional memory size
mov bx,-1
int 31h
movzx ecx,bx
shl ecx,4
jecxz no_conventional_memory
mov ax,100h ; allocate all conventional memory
int 31h
movzx edi,ax
shl edi,4
sub edi,[program_base]
jc no_conventional_memory
mov [additional_memory],edi
mov [additional_memory_end],edi
add [additional_memory_end],ecx
mov eax,[memory_end]
sub eax,[memory_start]
shr eax,2
cmp eax,ecx
ja no_conventional_memory
ret
no_conventional_memory:
mov eax,[memory_end]
mov ebx,[memory_start]
sub eax,ebx
shr eax,2
mov [additional_memory],ebx
add ebx,eax
mov [additional_memory_end],ebx
mov [memory_start],ebx
ret
dpmi_dos_int:
mov [real_mode_segment],main
simulate_real_mode:
push 0 ; SS:SP (DPMI will allocate stack)
push 0 ; CS:IP (ignored)
push 0
push [real_mode_segment] ; DS
push [real_mode_segment] ; ES
stc
pushfw
push eax
push ecx
push edx
push ebx
push 0
push ebp
push esi
push edi
mov ax,300h
mov bx,21h
xor cx,cx
mov edi,esp
push es ss
pop es
int 31h
pop es
mov edi,[esp]
mov esi,[esp+4]
mov ebp,[esp+8]
mov ebx,[esp+10h]
mov edx,[esp+14h]
mov ecx,[esp+18h]
mov ah,[esp+20h]
add esp,32h
sahf
mov eax,[esp-32h+1Ch]
ret
dpmi_dos_int_with_buffer:
mov [real_mode_segment],buffer
jmp simulate_real_mode
......@@ -58,7 +58,9 @@ start:
jmp main+(first_segment shr 4):first_gate-first_segment
compile:
and [preprocessing_done],0
call preprocessor
or [preprocessing_done],-1
call parser
call assembler
call formatter
......@@ -355,6 +357,9 @@ error_suffix db '.'
cr_lf db 0Dh,0Ah,0
line_number_start db ' [',0
line_data_start db ':',0Dh,0Ah,0
preprocessed_instruction_prefix db 'processed: ',0
include 'dpmi.inc'
align 16
first_segment:
......@@ -373,7 +378,9 @@ include '..\symbdump.inc'
include 'system.inc'
first_gate:
and [preprocessing_done],0
call preprocessor
or [preprocessing_done],-1
call parser
jmp main+(second_segment shr 4):second_gate-second_segment
first_segment_top = $ - first_segment
......@@ -421,6 +428,7 @@ mode dw ?
real_mode_segment dw ?
displayed_count dd ?
last_displayed rb 2
preprocessing_done db ?
segment buffer
......
......@@ -62,110 +62,6 @@ exit_program:
end if
init_dpmi_memory:
mov ax,500h ; get free memory information
mov edi,[buffer_address]
int 31h
mov ebx,[edi]
allocate_dpmi_memory:
mov edx,[memory_setting]
shl edx,10
jz dpmi_memory_size_ok
cmp ebx,edx
jbe dpmi_memory_size_ok
mov ebx,edx
dpmi_memory_size_ok:
mov [memory_end],ebx
mov ecx,ebx
shr ebx,16
mov ax,501h
int 31h
jnc dpmi_memory_ok
mov ebx,[memory_end]
shr ebx,1
cmp ebx,4000h
jb out_of_memory
jmp allocate_dpmi_memory
dpmi_memory_ok:
shl ebx,16
mov bx,cx
sub ebx,[program_base]
jc out_of_memory
mov [memory_start],ebx
add [memory_end],ebx
mov ax,100h ; get free conventional memory size
mov bx,-1
int 31h
movzx ecx,bx
shl ecx,4
jecxz no_conventional_memory
mov ax,100h ; allocate all conventional memory
int 31h
movzx edi,ax
shl edi,4
sub edi,[program_base]
jc no_conventional_memory
mov [additional_memory],edi
mov [additional_memory_end],edi
add [additional_memory_end],ecx
mov eax,[memory_end]
sub eax,[memory_start]
shr eax,2
cmp eax,ecx
ja no_conventional_memory
ret
no_conventional_memory:
mov eax,[memory_end]
mov ebx,[memory_start]
sub eax,ebx
shr eax,2
mov [additional_memory],ebx
add ebx,eax
mov [additional_memory_end],ebx
mov [memory_start],ebx
ret
dpmi_dos_int:
mov [real_mode_segment],main
simulate_real_mode:
push 0 ; SS:SP (DPMI will allocate stack)
push 0 ; CS:IP (ignored)
push 0
push [real_mode_segment] ; DS
push [real_mode_segment] ; ES
stc
pushfw
push eax
push ecx
push edx
push ebx
push 0
push ebp
push esi
push edi
mov ax,300h
mov bx,21h
xor cx,cx
mov edi,esp
push es ss
pop es
int 31h
pop es
mov edi,[esp]
mov esi,[esp+4]
mov ebp,[esp+8]
mov ebx,[esp+10h]
mov edx,[esp+14h]
mov ecx,[esp+18h]
mov ah,[esp+20h]
add esp,32h
sahf
mov eax,[esp-32h+1Ch]
ret
dpmi_dos_int_with_buffer:
mov [real_mode_segment],buffer
jmp simulate_real_mode
get_environment_variable:
mov ebx,esi
push ds
......@@ -546,6 +442,66 @@ assembler_error:
pop ebx
or ebx,ebx
jnz display_error_line
cmp [preprocessing_done],0
je display_error_message
mov esi,preprocessed_instruction_prefix
call display_string
mov esi,[current_line]
add esi,16
mov edi,[additional_memory]
xor dl,dl
convert_instruction:
lodsb
cmp al,1Ah
je copy_symbol
cmp al,22h
je copy_symbol
cmp al,3Bh
je instruction_converted
stosb
or al,al
jz instruction_converted
xor dl,dl
jmp convert_instruction
copy_symbol:
or dl,dl
jz space_ok
mov byte [edi],20h
inc edi
space_ok:
cmp al,22h
je quoted
lodsb
movzx ecx,al
rep movsb
or dl,-1
jmp convert_instruction
quoted:
mov al,27h
stosb
lodsd
mov ecx,eax
jecxz quoted_copied
copy_quoted:
lodsb
stosb
cmp al,27h
jne quote_ok
stosb
quote_ok:
loop copy_quoted
quoted_copied:
mov al,27h
stosb
or dl,-1
jmp convert_instruction
instruction_converted:
xor al,al
stosb
mov esi,[additional_memory]
call display_string
mov esi,cr_lf
call display_string
display_error_message:
mov esi,error_prefix
call display_string
......
......@@ -47,7 +47,9 @@ start:
add eax,ebx
mov [start_time],eax
and [preprocessing_done],0
call preprocessor
or [preprocessing_done],-1
call parser
call assembler
call formatter
......@@ -284,10 +286,10 @@ _logo db 'flat assembler version ',VERSION_STRING,0
_usage db 0xA
db 'usage: fasm <source> [output]',0xA
db 'optional settings:',0xA
db ' -m <limit> set the limit in kilobytes for the available memory',0Dh,0Ah
db ' -p <limit> set the maximum allowed number of passes',0Dh,0Ah
db ' -d <name>=<value> define symbolic variable',0Dh,0Ah
db ' -s <file> dump symbolic information for debugging',0Dh,0Ah
db ' -m <limit> set the limit in kilobytes for the available memory',0xA
db ' -p <limit> set the maximum allowed number of passes',0xA
db ' -d <name>=<value> define symbolic variable',0xA
db ' -s <file> dump symbolic information for debugging',0xA
db 0
_memory_prefix db ' (',0
_memory_suffix db ' kilobytes memory)',0xA,0
......@@ -325,6 +327,7 @@ con_handle dd ?
displayed_count dd ?
last_displayed db ?
character db ?
preprocessing_done db ?
predefinitions rb 1000h
buffer rb 1000h
......@@ -380,6 +380,66 @@ assembler_error:
pop ebx
or ebx,ebx
jnz display_error_line
cmp [preprocessing_done],0
je display_error_message
mov esi,preprocessed_instruction_prefix
call display_string
mov esi,[current_line]
add esi,16
mov edi,[additional_memory]
xor dl,dl
convert_instruction:
lodsb
cmp al,1Ah
je copy_symbol
cmp al,22h
je copy_symbol
cmp al,3Bh
je instruction_converted
stosb
or al,al
jz instruction_converted
xor dl,dl
jmp convert_instruction
copy_symbol:
or dl,dl
jz space_ok
mov byte [edi],20h
inc edi
space_ok:
cmp al,22h
je quoted
lodsb
movzx ecx,al
rep movsb
or dl,-1
jmp convert_instruction
quoted:
mov al,27h
stosb
lodsd
mov ecx,eax
jecxz quoted_copied
copy_quoted:
lodsb
stosb
cmp al,27h
jne quote_ok
stosb
quote_ok:
loop copy_quoted
quoted_copied:
mov al,27h
stosb
or dl,-1
jmp convert_instruction
instruction_converted:
xor al,al
stosb
mov esi,[additional_memory]
call display_string
mov esi,lf
call display_string
display_error_message:
mov esi,error_prefix
call display_string
......@@ -403,3 +463,4 @@ error_suffix db '.'
lf db 0xA,0
line_number_start db ' [',0
line_data_start db ':',0xA,0
preprocessed_instruction_prefix db 'processed: ',0
......@@ -32,7 +32,9 @@ start:
call [GetTickCount]
mov [start_time],eax
and [preprocessing_done],0
call preprocessor
or [preprocessing_done],-1
call parser
call assembler
call formatter
......@@ -355,6 +357,7 @@ bytes_count dd ?
displayed_count dd ?
character db ?
last_displayed rb 2
preprocessing_done db ?
params rb 1000h
options rb 1000h
......
......@@ -410,6 +410,66 @@ assembler_error:
pop ebx
or ebx,ebx
jnz display_error_line
cmp [preprocessing_done],0
je display_error_message
mov esi,preprocessed_instruction_prefix
call display_string
mov esi,[current_line]
add esi,16
mov edi,[additional_memory]
xor dl,dl
convert_instruction:
lodsb
cmp al,1Ah
je copy_symbol
cmp al,22h
je copy_symbol
cmp al,3Bh
je instruction_converted
stosb
or al,al
jz instruction_converted
xor dl,dl
jmp convert_instruction
copy_symbol:
or dl,dl
jz space_ok
mov byte [edi],20h
inc edi
space_ok:
cmp al,22h
je quoted
lodsb
movzx ecx,al
rep movsb
or dl,-1
jmp convert_instruction
quoted:
mov al,27h
stosb
lodsd
mov ecx,eax
jecxz quoted_copied
copy_quoted:
lodsb
stosb
cmp al,27h
jne quote_ok
stosb
quote_ok:
loop copy_quoted
quoted_copied:
mov al,27h
stosb
or dl,-1
jmp convert_instruction
instruction_converted:
xor al,al
stosb
mov esi,[additional_memory]
call display_string
mov esi,cr_lf
call display_string
display_error_message:
mov esi,error_prefix
call display_string
......@@ -504,3 +564,4 @@ error_suffix db '.'
cr_lf db 0Dh,0Ah,0
line_number_start db ' [',0
line_data_start db ':',0Dh,0Ah,0
preprocessed_instruction_prefix db 'processed: ',0
......@@ -3894,6 +3894,9 @@ elf_segment:
elf_segment_type_ok:
mov [ebx],ah
mov word [ebx+1Ch],1
cmp ah,50h
jb elf_segment_flags
or dword [ebx],6474E500h
jmp elf_segment_flags
elf_segment_flags_ok:
mov eax,edi
......@@ -4027,6 +4030,9 @@ elf_segment:
elf64_segment_type_ok:
mov [ebx],ah
mov word [ebx+30h],1
cmp ah,50h
jb elf64_segment_flags
or dword [ebx],6474E500h
jmp elf64_segment_flags
elf64_segment_flags_ok:
mov ecx,edi
......
......@@ -69,7 +69,9 @@ main:
add eax,ebx
mov [start_time],eax
and [preprocessing_done],0
call preprocessor
or [preprocessing_done],-1
call parser
call assembler
call formatter
......@@ -129,7 +131,6 @@ get_params:
mov [memory_setting],0
mov [passes_limit],100
mov ecx,[argc]
mov ebx,[argv]
add ebx,4
......@@ -307,10 +308,10 @@ _logo db 'flat assembler version ',VERSION_STRING,0
_usage db 0xA
db 'usage: fasm <source> [output]',0xA
db 'optional settings:',0xA
db ' -m <limit> set the limit in kilobytes for the available memory',0Dh,0Ah
db ' -p <limit> set the maximum allowed number of passes',0Dh,0Ah
db ' -d <name>=<value> define symbolic variable',0Dh,0Ah
db ' -s <file> dump symbolic information for debugging',0Dh,0Ah
db ' -m <limit> set the limit in kilobytes for the available memory',0xA
db ' -p <limit> set the maximum allowed number of passes',0xA
db ' -d <name>=<value> define symbolic variable',0xA
db ' -s <file> dump symbolic information for debugging',0xA
db 0
_memory_prefix db ' (',0
_memory_suffix db ' kilobytes memory)',0xA,0
......@@ -347,6 +348,7 @@ con_handle dd ?
displayed_count dd ?
last_displayed db ?
character db ?
preprocessing_done db ?
predefinitions rb 1000h
buffer rb 1000h
......@@ -316,6 +316,66 @@ assembler_error:
pop ebx
or ebx,ebx
jnz display_error_line
cmp [preprocessing_done],0
je display_error_message
mov esi,preprocessed_instruction_prefix
call display_string
mov esi,[current_line]
add esi,16
mov edi,[additional_memory]
xor dl,dl
convert_instruction:
lodsb
cmp al,1Ah
je copy_symbol
cmp al,22h
je copy_symbol
cmp al,3Bh
je instruction_converted
stosb
or al,al
jz instruction_converted
xor dl,dl
jmp convert_instruction
copy_symbol:
or dl,dl
jz space_ok
mov byte [edi],20h
inc edi
space_ok:
cmp al,22h
je quoted
lodsb
movzx ecx,al
rep movsb
or dl,-1
jmp convert_instruction
quoted:
mov al,27h
stosb
lodsd
mov ecx,eax
jecxz quoted_copied
copy_quoted:
lodsb
stosb
cmp al,27h
jne quote_ok
stosb
quote_ok:
loop copy_quoted
quoted_copied:
mov al,27h
stosb
or dl,-1
jmp convert_instruction
instruction_converted:
xor al,al
stosb
mov esi,[additional_memory]
call display_string
mov esi,lf
call display_string
display_error_message:
mov esi,error_prefix
call display_string
......@@ -340,3 +400,4 @@ error_suffix db '.'
lf db 0xA,0
line_number_start db ' [',0
line_data_start db ':',0xA,0
preprocessed_instruction_prefix db 'processed: ',0
......@@ -420,6 +420,7 @@ symbols_7:
db 'dynamic',1Eh,2
db 'efiboot',1Bh,11
symbols_8:
db 'gnustack',1Eh,51h
db 'linkinfo',19h,9
db 'readable',19h,30
db 'resource',1Ah,2
......@@ -430,6 +431,7 @@ symbols_9:
symbols_10:
db 'efiruntime',1Bh,12
db 'executable',19h,29
db 'gnuehframe',1Eh,50h
db 'linkremove',19h,11
symbols_11:
db 'discardable',19h,25
......
......@@ -33,7 +33,7 @@
; cannot simply be copied and put under another distribution licence
; (including the GNU Public Licence).
VERSION_STRING equ "1.71.56"
VERSION_STRING equ "1.71.57"
VERSION_MAJOR = 1
VERSION_MINOR = 71
......@@ -2,6 +2,14 @@
Visit http://flatassembler.net/ for more information.
version 1.71.57 (Sep 26, 2016)
[+] Added "gnustack" and "gnuehframe" segment types to ELF executable formatter.
[+] Console versions now display preprocessed instruction that caused an error
(previously only displayed by Windows GUI interface).
version 1.71.56 (Sep 19, 2016)
[+] Allowed underscore character to be put inside the number value.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment