FASM 1.73.23 by Prohor Nikiforov

git-svn-id: svn://kolibrios.org@7836 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Kirill Lipatov (Leency) 2020-04-28 23:24:56 +00:00
parent f7731a6366
commit 0e67df68e0
38 changed files with 33534 additions and 0 deletions

View File

@ -0,0 +1,3 @@
if tup.getconfig("NO_FASM") ~= "" then return end
tup.rule("echo lang fix " .. ((tup.getconfig("LANG") == "") and "en" or tup.getconfig("LANG")) .. " > lang.inc", {"lang.inc"})
tup.rule({"fasm.asm", extra_inputs = {"lang.inc"}}, "fasm %f %o " .. tup.getconfig("KPACK_CMD"), "fasm")

View File

@ -0,0 +1,5 @@
@erase lang.inc
@echo lang fix en >lang.inc
@fasm -m 16384 fasm.asm fasm
@erase lang.inc
@pause

View File

@ -0,0 +1,5 @@
@erase lang.inc
@echo lang fix ru >lang.inc
@fasm -m 16384 fasm.asm fasm
@erase lang.inc
@pause

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,194 @@
; flat assembler core
; Copyright (c) 1999-2020, Tomasz Grysztar.
; All rights reserved.
out_of_memory:
push _out_of_memory
jmp fatal_error
stack_overflow:
push _stack_overflow
jmp fatal_error
main_file_not_found:
push _main_file_not_found
jmp fatal_error
write_failed:
push _write_failed
jmp fatal_error
unexpected_end_of_file:
push _unexpected_end_of_file
jmp general_error
code_cannot_be_generated:
push _code_cannot_be_generated
jmp general_error
format_limitations_exceeded:
push _format_limitations_exceeded
jmp general_error
invalid_definition:
push _invalid_definition
general_error:
cmp [symbols_file],0
je fatal_error
call dump_preprocessed_source
jmp fatal_error
file_not_found:
push _file_not_found
jmp error_with_source
error_reading_file:
push _error_reading_file
jmp error_with_source
invalid_file_format:
push _invalid_file_format
jmp error_with_source
invalid_macro_arguments:
push _invalid_macro_arguments
jmp error_with_source
incomplete_macro:
push _incomplete_macro
jmp error_with_source
unexpected_characters:
push _unexpected_characters
jmp error_with_source
invalid_argument:
push _invalid_argument
jmp error_with_source
illegal_instruction:
push _illegal_instruction
jmp error_with_source
invalid_operand:
push _invalid_operand
jmp error_with_source
invalid_operand_size:
push _invalid_operand_size
jmp error_with_source
operand_size_not_specified:
push _operand_size_not_specified
jmp error_with_source
operand_sizes_do_not_match:
push _operand_sizes_do_not_match
jmp error_with_source
invalid_address_size:
push _invalid_address_size
jmp error_with_source
address_sizes_do_not_agree:
push _address_sizes_do_not_agree
jmp error_with_source
disallowed_combination_of_registers:
push _disallowed_combination_of_registers
jmp error_with_source
long_immediate_not_encodable:
push _long_immediate_not_encodable
jmp error_with_source
relative_jump_out_of_range:
push _relative_jump_out_of_range
jmp error_with_source
invalid_expression:
push _invalid_expression
jmp error_with_source
invalid_address:
push _invalid_address
jmp error_with_source
invalid_value:
push _invalid_value
jmp error_with_source
value_out_of_range:
push _value_out_of_range
jmp error_with_source
undefined_symbol:
mov edi,message
mov esi,_undefined_symbol
call copy_asciiz
push message
cmp [error_info],0
je error_with_source
mov esi,[error_info]
mov esi,[esi+24]
or esi,esi
jz error_with_source
mov byte [edi-1],20h
call write_quoted_symbol_name
jmp error_with_source
copy_asciiz:
lods byte [esi]
stos byte [edi]
test al,al
jnz copy_asciiz
ret
write_quoted_symbol_name:
mov al,27h
stosb
movzx ecx,byte [esi-1]
rep movs byte [edi],[esi]
mov ax,27h
stosw
ret
symbol_out_of_scope:
mov edi,message
mov esi,_symbol_out_of_scope_1
call copy_asciiz
cmp [error_info],0
je finish_symbol_out_of_scope_message
mov esi,[error_info]
mov esi,[esi+24]
or esi,esi
jz finish_symbol_out_of_scope_message
mov byte [edi-1],20h
call write_quoted_symbol_name
finish_symbol_out_of_scope_message:
mov byte [edi-1],20h
mov esi,_symbol_out_of_scope_2
call copy_asciiz
push message
jmp error_with_source
invalid_use_of_symbol:
push _invalid_use_of_symbol
jmp error_with_source
name_too_long:
push _name_too_long
jmp error_with_source
invalid_name:
push _invalid_name
jmp error_with_source
reserved_word_used_as_symbol:
push _reserved_word_used_as_symbol
jmp error_with_source
symbol_already_defined:
push _symbol_already_defined
jmp error_with_source
missing_end_quote:
push _missing_end_quote
jmp error_with_source
missing_end_directive:
push _missing_end_directive
jmp error_with_source
unexpected_instruction:
push _unexpected_instruction
jmp error_with_source
extra_characters_on_line:
push _extra_characters_on_line
jmp error_with_source
section_not_aligned_enough:
push _section_not_aligned_enough
jmp error_with_source
setting_already_specified:
push _setting_already_specified
jmp error_with_source
data_already_defined:
push _data_already_defined
jmp error_with_source
too_many_repeats:
push _too_many_repeats
jmp error_with_source
assertion_failed:
push _assertion_failed
jmp error_with_source
invoked_error:
push _invoked_error
error_with_source:
cmp [symbols_file],0
je assembler_error
call dump_preprocessed_source
call restore_preprocessed_source
jmp assembler_error

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,52 @@
; flat assembler core
; Copyright (c) 1999-2020, 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

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,450 @@
; flat assembler core
; Copyright (c) 1999-2020, 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

View File

@ -0,0 +1,155 @@
; flat assembler core variables
; Copyright (c) 1999-2020, Tomasz Grysztar.
; All rights reserved.
; Variables which have to be set up by interface:
memory_start dd ?
memory_end dd ?
additional_memory dd ?
additional_memory_end dd ?
stack_limit dd ?
initial_definitions dd ?
input_file dd ?
output_file dd ?
symbols_file dd ?
passes_limit dw ?
; Internal core variables:
current_pass dw ?
include_paths dd ?
free_additional_memory dd ?
source_start dd ?
code_start dd ?
code_size dd ?
real_code_size dd ?
written_size dd ?
headers_size dd ?
current_line dd ?
macro_line dd ?
macro_block dd ?
macro_block_line dd ?
macro_block_line_number dd ?
macro_symbols dd ?
struc_name dd ?
struc_label dd ?
instant_macro_start dd ?
parameters_end dd ?
default_argument_value dd ?
locals_counter rb 8
current_locals_prefix dd ?
anonymous_reverse dd ?
anonymous_forward dd ?
labels_list dd ?
label_hash dd ?
label_leaf dd ?
hash_tree dd ?
addressing_space dd ?
undefined_data_start dd ?
undefined_data_end dd ?
counter dd ?
counter_limit dd ?
error_info dd ?
error_line dd ?
error dd ?
tagged_blocks dd ?
structures_buffer dd ?
number_start dd ?
current_offset dd ?
value dq ?
fp_value rd 8
adjustment dq ?
symbol_identifier dd ?
address_symbol dd ?
address_high dd ?
uncompressed_displacement dd ?
format_flags dd ?
resolver_flags dd ?
symbols_stream dd ?
number_of_relocations dd ?
number_of_sections dd ?
stub_size dd ?
stub_file dd ?
current_section dd ?
machine dw ?
subsystem dw ?
subsystem_version dd ?
image_base dd ?
image_base_high dd ?
merge_segment dd ?
resource_data dd ?
resource_size dd ?
actual_fixups_size dd ?
reserved_fixups dd ?
reserved_fixups_size dd ?
last_fixup_base dd ?
last_fixup_header dd ?
parenthesis_stack dd ?
blocks_stack dd ?
parsed_lines dd ?
logical_value_parentheses dd ?
file_extension dd ?
operand_size db ?
operand_flags db ?
operand_prefix db ?
rex_prefix db ?
opcode_prefix db ?
vex_required db ?
vex_register db ?
immediate_size db ?
mask_register db ?
broadcast_size db ?
rounding_mode db ?
base_code db ?
extended_code db ?
supplemental_code db ?
postbyte_register db ?
segment_register db ?
xop_opcode_map db ?
mmx_size db ?
jump_type db ?
push_size db ?
value_size db ?
address_size db ?
label_size db ?
size_declared db ?
address_size_declared db ?
displacement_compression db ?
value_undefined db ?
value_constant db ?
value_type db ?
value_sign db ?
fp_sign db ?
fp_format db ?
address_sign db ?
address_register db ?
compare_type db ?
logical_value_wrapping db ?
next_pass_needed db ?
output_format db ?
code_type db ?
adjustment_sign db ?
evex_mode db ?
macro_status db ?
skip_default_argument_value db ?
prefix_flags db ?
formatter_symbols_allowed db ?
decorator_symbols_allowed db ?
free_address_range db ?
characters rb 100h
converted rb 100h
message rb 180h

View File

@ -0,0 +1,39 @@
; flat assembler version 1.73
; Copyright (c) 1999-2020, Tomasz Grysztar.
; All rights reserved.
;
; This programs is free for commercial and non-commercial use as long as
; the following conditions are adhered to.
;
; Redistribution and use in source and binary forms, with or without
; modification, are permitted provided that the following conditions are
; met:
;
; 1. Redistributions of source code must retain the above copyright notice,
; this list of conditions and the following disclaimer.
; 2. Redistributions in binary form must reproduce the above copyright
; notice, this list of conditions and the following disclaimer in the
; documentation and/or other materials provided with the distribution.
;
; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
; "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
; TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
; PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
; CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
; EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
; PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
; LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
; NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
;
; The licence and distribution terms for any publically available
; version or derivative of this code cannot be changed. i.e. this code
; cannot simply be copied and put under another distribution licence
; (including the GNU Public Licence).
VERSION_STRING equ "1.73.23"
VERSION_MAJOR = 1
VERSION_MINOR = 73

File diff suppressed because it is too large Load Diff

Binary file not shown.

View File

@ -0,0 +1,690 @@
; flat assembler source
; Copyright (c) 1999-2020, Tomasz Grysztar.
; All rights reserved.
; KolibriOS port by KolibriOS Team
format binary as ''
appname equ 'flat assembler '
;-------------------------------------------------
; HEADER
;-------------------------------------------------
db 'MENUET01' ; 8 byte id
dd 0x01 ; header version
dd START ; program start
dd program_end ; program image size
dd stacktop ; required amount of memory
dd stacktop ; stack
dd params ; parameters
dd cur_dir_path ; icon
if defined import.data
dd import.data
else
dd 0
end if
;-------------------------------------------------
; INCLUDES
;-------------------------------------------------
lang equ ru
include 'kolibria.inc'
include 'fasm.inc'
MAX_PATH = 100
struc path name:?& {
.:
db name
rb MAX_PATH-$+. }
;-------------------------------------------------
; CODE
;-------------------------------------------------
use32
include 'kolibri/osloader/osloader.inc'
;-------------------------------------------------
parse_params:
cmp [params],'/'
jnz @f
ret
@@:
cmp [params],0
jnz .chunk.console
ret
.chunk.console:
mov [_mode],CONSOLE_MODE
mov dword [esp], CUI_START ; force retaddr to CUI_START
mov eax, ' '
mov esi, 10
cld
mov ecx, esi
mov edi, infile
rep stosd
mov ecx, esi
mov edi, outfile
rep stosd
mov ecx, esi
mov edi, path
rep stosd
or ecx, -1
mov edi, params
mov al, ' '
repe scasb
mov esi, edi
dec esi
mov edi, dbgWord
@@: lodsb
scasb
jne .NoOutDebugInfo
cmp byte[edi], 0
jnz @b
cmp byte[esi],' '
jne .NoOutDebugInfo
mov edi,esi
mov al,' '
repe scasb
mov esi,edi
dec esi
mov edi,params
@@: lodsb
stosb
test al,al
jnz @b
or dword[ch1_dbg.flags],CB_FLAG_EN
.NoOutDebugInfo:
mov [_mode],CONSOLE_MODE
regcall mov_param_str,,,,,params,infile
regcall mov_param_str,,,,,esi,outfile
regcall mov_param_str,,,,,esi,path
mov eax, [esi-1]
cmp al,','
jne .locret
cmp eax, ',run'
jne .check_again
mov [_run_outfile],1
jmp .locret
.check_again:
cmp eax, ',dbg'
jne .locret
mov [_run_outfile],2
.locret:
ret
;-------------------------------------------------
START: ; Start of execution
mov edi, fileinfos
mov ecx, (fileinfos_end-fileinfos)/4
or eax, -1
rep stosd
mcall SF_SYS_MISC,SSF_HEAP_INIT
call parse_params
mcall SF_SYS_MISC,SSF_MEM_ALLOC,$1000
mov [file_io_notify.flags],eax
call LoadLibraries
mcall SF_SET_EVENTS_MASK,EVM_MOUSE_FILTER or EVM_MOUSE or EVM_BUTTON or EVM_KEY or EVM_REDRAW;0x80000027 ; filter events: 80000000h - don`t receive mouse events if wnd nonactive , 7 - allowed events: redraw,keypresses, button presses
invoke init_checkbox,ch1_dbg
invoke OpenDialog_Init,OpenDialog_data
call prepare_esp_and_redraw
still:
sub esp,4
mcall SF_WAIT_EVENT ; Wait here for event
movzx ecx,al
jmp [event_handlers+4*ecx]
event_handlers dd 0,do_redraw,key,button,0,0,mouse
;-------------------------------------------------
key: ; Key
mcall SF_GET_KEY ; Read it and ignore
invoke edit_box_key, edit1
invoke edit_box_key, edit2
invoke edit_box_key, edit3
ret
;-------------------------------------------------
button: ; Button in Window
mcall SF_GET_BUTTON
movzx ecx,ah
jmp [button_handlers+4*ecx]
button_handlers dd 0,btn_close,CUI_START,btn_runout,btn_rundbg,fun_opn_dlg
;-------------------------------------------------
btn_close:
mcall SF_TERMINATE_PROCESS
;-------------------------------------------------
btn_runout:
mov edx,outfile
call make_fullpaths
mcall SF_FILE,file_io_start
ret
;-------------------------------------------------
btn_rundbg:
mov edx,outfile
call make_fullpaths
mcall SF_FILE,file_io_debug
ret
;-------------------------------------------------
mouse:
invoke edit_box_mouse, edit1
invoke edit_box_mouse, edit2
invoke edit_box_mouse, edit3
invoke check_box_mouse,ch1_dbg
ret
;-------------------------------------------------
Edit_Update_Colors:
mov [edi+EDIT_BOX.focus_border_color], ebx
mov [edi+EDIT_BOX.blur_border_color], eax
ret
;-------------------------------------------------
CheckBox_Update_Colors:
or eax, 0x10000000
mov [edi+CHECK_BOX2.text_color], eax
mov [edi+CHECK_BOX2.border_color], ebx
ret
;-------------------------------------------------
accept_systemcolors:
mcall SF_STYLE_SETTINGS,SSF_GET_COLORS,sc,sizeof.system_colors
or [sc.work], $3000000
mov esi, sc
mov edi, sc_prev
mov ecx, sizeof.system_colors/4
repe cmpsd
jne .chunk.update_colors
ret
.chunk.update_colors:
inc ecx ; move back
sub edi, 4 ; on first element
sub esi, 4 ; that not match
rep movsd ; copy only difference part
mov eax, [sc.work]
mov ebx, [sc.work_graph]
shr eax, 1
shr ebx, 1
and eax, $7F7F7F
and ebx, $7F7F7F
add eax, ebx
regcall Edit_Update_Colors,eax, ebx,,,,edit1
regcall Edit_Update_Colors,eax, ebx,,,,edit2
regcall Edit_Update_Colors,eax, ebx,,,,edit3
mov eax, [sc.work_text]
or eax, $80000000
mov ebx, [sc.work_graph]
regcall CheckBox_Update_Colors,eax, ebx,,,,ch1_dbg
ret
;-------------------------------------------------
draw_window:
cmp dword[PROCESS_INFO.client_box.width],WIN_MIN_W
jge @f
mcall 67,-1,-1,WIN_MIN_W+20,-1
ret
@@:
cmp dword[PROCESS_INFO.client_box.height],WIN_MIN_H
jge @f
mcall 67,-1,-1,-1,WIN_MIN_H+50
ret
@@:
mpack ebx,[PROCESS_INFO.client_box.width],RIGHT_BTN_W
msub ebx,RIGHT_BTN_W+1,0
mcall SF_DEFINE_BUTTON,ebx,<LINE_H*0+3,LINE_H-4>,ID_COMPILE_BTN,[sc.work_button]
mcallb SF_DEFINE_BUTTON,ebx,<LINE_H*1+3,LINE_H-4>,ID_EXECUTE_BTN
mcallb SF_DEFINE_BUTTON,ebx,<LINE_H*2+3,LINE_H-4>,ID_EXECDBG_BTN
mcallb SF_DEFINE_BUTTON,<5,62>,<LINE_H*2+3,LINE_H-5>,ID_OPENDLG_BTN ;button for OpenDialog [..]
mov ecx, [sc.work_text]
or ecx, $10000000
mcall SF_DRAW_TEXT,<6,LINE_H*0+6>,,text+text.line_size*0,text.line_size ;InFile
mcallb SF_DRAW_TEXT,<6,LINE_H*1+6>,,text+text.line_size*1,esi ;OutFile
mov ecx, [sc.work_button_text]
or ecx, $10000000
mcallb SF_DRAW_TEXT,<0,LINE_H*2+6>,,text+text.line_size*2,esi ;Path
mov ebx,[PROCESS_INFO.client_box.width]
sub ebx,RIGHT_BTN_W-11
shl ebx,16
add ebx,LINE_H/2-6
mov ecx, [sc.work_button_text]
or ecx, $10000000
mcallb SF_DRAW_TEXT,ebx,ecx,s_compile,7
add ebx,LINE_H
mcallb SF_DRAW_TEXT,ebx,ecx,s_run
add ebx,LINE_H
mcallb SF_DRAW_TEXT,ebx,ecx,s_debug
;MAGIC1 = 6*(text.line_size-1)+14 ;MAGIC???? MAGIC??????????? GO FYSLF.
;mpack ebx,MAGIC1+6,1+ 14/2-3+ 14*0
;mov esi,[PROCESS_INFO.client_box.width]
;sub esi,MAGIC1*2+6+3
;mov eax,esi
;mov cl,6
;div cl
;cmp al,MAX_PATH
;jbe @f
;mov al,MAX_PATH
;@@:
movzx esi,al
call draw_messages
mov eax,dword [PROCESS_INFO.client_box.width]
sub eax,[edit1.left]
sub eax,RIGHT_BTN_W+6
mov dword[edit1.width],eax
mov dword[edit2.width],eax
mov dword[edit3.width],eax
invoke edit_box_draw, edit1
invoke edit_box_draw, edit2
invoke edit_box_draw, edit3
invoke check_box_draw, ch1_dbg
ret
;-------------------------------------------------
prepare_esp_and_redraw:
mov [processing_esp],esp
do_redraw:
pusha
mcall SF_REDRAW,SSF_BEGIN_DRAW ; Start of draw
call accept_systemcolors
mov edx,[sc.work]
or edx,CW_CAPTION or CW_CLIENTRECTCOORDS or CW_SKINED;0x33000000
mcall SF_CREATE_WINDOW,<150,DEFAULT_WIN_W>,<150,DEFAULT_WIN_H>,edx,,title
mcall SF_THREAD_INFO,PROCESS_INFO,-1
mov eax,dword[PROCESS_INFO.wnd_state] ;status of window
test eax,100b
jnz .skip_draw_window
call draw_window
.skip_draw_window:
mcall SF_REDRAW,SSF_END_DRAW ; End of Draw
popa
ret
;---------------------------------------------------------------------
bottom_right dd ?
align 4
fun_opn_dlg:
pushad
mov edx, open_dialog_name
mov edi, communication_area_default_path
mov esi, library_path
call @copy_path_wo_pdname
mov [OpenDialog_data.type], 0
xor al, al
mov edi, dword [edit3.text]
mov ecx, dword [edit3.max]
cld
repne scasb
cmp byte[edi-2], '/'
jne @f
mov byte[edi-2], 0 ;if last symbol is slash cut it off
@@:
invoke OpenDialog_Start, OpenDialog_data
cmp [OpenDialog_data.status], 2
je @f
xor al, al
mov edi, dword [edit3.text]
mov ebx, edi ;copy text pointer
mov ecx, dword [edit3.max]
cld
repne scasb
cmp byte[edi-2], '/'
jne .no_slash
dec edi ;if last symbol is slash cut it off
.no_slash:
mov byte[edi-1], '/' ;add slash as last symbol
mov byte[edi], 0 ;cut off file name
sub edi, ebx ;edi = strlen(edit3.text)
mov [edit3.size], edi
mov [edit3.pos], edi
invoke edit_box_set_text, edit1, [OpenDialog_data.filename_area]
invoke edit_box_set_text, edit2, [OpenDialog_data.filename_area]
mov esi, [edit2.text]
xor eax, eax
cld
.cycle:
lodsb
test eax, eax
jnz .cycle
sub esi, 5
cmp esi, [edit2.text]
jle .short_fn
mov byte[esi], 0
sub dword [edit2.size], 4
sub dword [edit2.pos], 4
.short_fn:
invoke edit_box_draw, edit1
invoke edit_box_draw, edit2
invoke edit_box_draw, edit3
@@:
popad
ret
;---------------------------------------------------------------------
draw_messages:
mpack ebx, 5,[PROCESS_INFO.client_box.width]
sub ebx, 9
mpack ecx, 0,[PROCESS_INFO.client_box.height]
madd ecx, LINE_H*4,-( LINE_H*4+5)
mov word[bottom_right+2], bx
mov word[bottom_right], cx
msub [bottom_right], 7,11
add [bottom_right], 7 shl 16 + 53
mcall SF_DRAW_RECT,,,0xFeFefe ; clear work area
; draw top shadow
push ecx
mov cx,1
mov edx,0xDADEDA
mcall
; draw left shadow
pop ecx
push ebx
mov bx,1
mcall
pop ebx
_cy = 0
_sy = 2
_cx = 4
_sx = 6
push ebx ecx
mpack ebx, 4,5
add bx, [esp+_cx]
mov ecx, [esp+_sy-2]
mov cx, [esp+_sy]
msub ecx, 1,1
mcall SF_DRAW_LINE,,,[sc.work_graph]
mov si, [esp+_cy]
add cx, si
shl esi, 16
add ecx, esi
madd ecx, 1,1
mcallb SF_DRAW_LINE
mpack ebx, 4,4
mov esi, [esp+_sy-2]
mov si, cx
mov ecx, esi
mcallb SF_DRAW_LINE
mov si,[esp+_cx]
add bx,si
shl esi,16
add ebx,esi
madd ebx,1,1
mcallb SF_DRAW_LINE
pop ecx ebx
ret
;---------------------------------------------------------------------
mov_param_str:
cld
@@:
lodsb
cmp al,','
je @f
stosb
test al,al
jnz @b
@@:
xor al,al
stosb
ret
;---------------------------------------------------------------------
CUI_START:
cmp [_mode],NORMAL_MODE
jne @f
call draw_messages
mov [textxy],8 shl 16 + LINE_H*4+4
@@:
mov esi,_logo
call display_string
;---------------------------------------------------------------------
; Fasm native code
;---------------------------------------------------------------------
mov [input_file],infile
mov [output_file],outfile
call init_memory
call make_timestamp
mov [start_time],eax
call preprocessor
call parser
call assembler
bt dword[ch1_dbg.flags],1 ;cmp [bGenerateDebugInfo], 0
jae @f ;jz @f
call symbol_dump
@@:
call formatter
call display_user_messages
movzx eax,[current_pass]
inc eax
call display_number
mov esi,_passes_suffix
call display_string
call make_timestamp
sub eax,[start_time]
xor edx,edx
mov ebx,100
div ebx
or eax,eax
jz display_bytes_count
xor edx,edx
mov ebx,10
div ebx
push edx
call display_number
mov dl,'.'
call display_character
pop eax
call display_number
mov esi,_seconds_suffix
call display_string
display_bytes_count:
mov eax,[written_size]
call display_number
mov esi,_bytes_suffix
call display_string
xor al,al
cmp [_run_outfile],0
je @f
mov edx,outfile
call make_fullpaths
xor ecx,ecx
cmp [_run_outfile],2 ; param is ',dbg'
jne run
mcall SF_FILE,file_io_debug
jmp @f
run:
mcall SF_FILE,file_io_start
@@:
jmp exit_program
;---------------------------------------------------------------------
include 'system.inc'
include 'core/version.inc'
include 'core/errors.inc'
include 'core/symbdump.inc'
include 'core/preproce.inc'
include 'core/parser.inc'
include 'core/exprpars.inc'
include 'core/assemble.inc'
include 'core/exprcalc.inc'
include 'core/formats.inc'
include 'core/x86_64.inc'
include 'core/avx.inc'
include 'core/tables.inc'
include 'core/messages.inc'
;---------------------------------------------------------------------
; IMPORT
;---------------------------------------------------------------------
library box_lib,'box_lib.obj',\
proc_lib,'proc_lib.obj'
import box_lib,edit_box_draw,'edit_box',\
edit_box_key,'edit_box_key',\
edit_box_mouse,'edit_box_mouse',\
edit_box_set_text,'edit_box_set_text',\
version_ed,'version_ed',\
init_checkbox,'init_checkbox2',\
check_box_draw,'check_box_draw2',\
check_box_mouse,'check_box_mouse2',\
version_ch,'version_ch'
import proc_lib,OpenDialog_Init,'OpenDialog_init',\
OpenDialog_Start,'OpenDialog_start'
;---------------------------------------------------------------------
; INITIALIZED DATA
;---------------------------------------------------------------------
;match =en,lang {include 'lang/en.inc'}
;match =ru,lang {include 'lang/ru.inc'}
include 'traslations.inc'
edit1 EDIT_BOX 153, 72, 3, 0xffffff, 0xA4C4E4, 0x80ff, 0, 0x10000000,(outfile-infile-1), infile, mouse_dd, 0, 11,11
edit2 EDIT_BOX 153, 72, LINE_H+3, 0xffffff, 0xA4C4E4, 0x80ff, 0, 0x10000000,(path-outfile-1), outfile, mouse_dd, 0, 7,7
edit3 EDIT_BOX 153, 72, LINE_H*2+3, 0xffffff, 0xA4C4E4, 0x80ff, 0, 0x10000000,(path_end-path-1), path, mouse_dd, 0, 6,6
editboxes_end:
ch1_dbg CHECK_BOX2 (5 shl 16)+15, ((LINE_H*3+3) shl 16)+15, 6, 0xffffff, 0x80ff, 0x10000000, s_dbgdescr,CB_FLAG_TOP
;---------------------------------------------------------------------
align 4
OpenDialog_data OPEN_DLG 0,PROCESS_INFO,communication_area_name,0,path,default_dir,library_path,do_redraw,0,path,filename_area,Filter,420,10,320,10
default_dir db '/rd/1',0
communication_area_name db 'FFFFFFFF_open_dialog',0
open_dialog_name db 'opendial',0
communication_area_default_path db '/rd/1/File managers/',0
Filter:
dd Filter.end - Filter
.1:
db 'ASM',0
.end:
db 0
;---------------------------------------------------------------------
mouse_dd dd 0 ;needed for Shift in editbox
;---------------------------------------------------------------------
infile path 'example.asm',0
outfile path 'example',0
path path '/rd/1//',0
path_end:
crlf db $D,$A,0
title db appname,VERSION_STRING,0
_logo db 'flat assembler version ',VERSION_STRING,$D,$A,0
_passes_suffix db ' passes, ',0
_seconds_suffix db ' seconds, ',0
_bytes_suffix db ' bytes.',$D,$A,0
_include db 'INCLUDE',0
_counter db 4,'0000'
_mode dd NORMAL_MODE
_run_outfile dd 0
dbgWord db '-d',0
character db ?,0
textxy dd 5:$A0
dc db 0
filesize dd 0
error_prefix db 'error: ',0
error_suffix db '.',0
line_data_start db ':'
line_number_start db ' [',0
import_loader.state dd 0
file_io_notify FILEIO SSF_START_APP
file_io_notify.path db 0
file_io_notify.lppath dd notify_path
notify_path db '/rd/1/@notify',0
file_io_start FILEIO SSF_START_APP
file_io_start.path path
file_io_debug FILEIO SSF_START_APP,0,file_io_start.path
file_io_debug.path db '/SYS/DEVELOP/MTDBG',0
_ramdisk db '/rd/1/'
filepos dd 0
sub_table:
times $41 db $00
times $1A db $20
times $25 db $00
times $10 db $20
times $30 db $00
times $10 db $50
times $04 db $00,$01
times $08 db $00
program_end:
;---------------------------------------------------------------------
; UNINITIALIZED DATA
;---------------------------------------------------------------------
params rb $1000
cur_dir_path rb $1000
library_path rb $1000
filename_area rb $100
align 4
include 'core/variable.inc'
align 4
program_base dd ?
buffer_address dd ?
memory_setting dd ?
start_time dd ?
memblock dd ?
fileinfo FILEINFO
predefinitions rb $1000
fullpath_open path
fullpath_write path
dbgfilename rb MAX_PATH+4
sc system_colors
sc_prev system_colors
max_handles = 8
fileinfos rb (4+20+MAX_PATH)*max_handles
fileinfos_end:
PROCESS_INFO process_information
bytes_count dd ?
displayed_count dd ?
last_displayed rb 2
processing_esp dd ?
align 1000h
;---------------------------------------------------------------------
; STACK
;---------------------------------------------------------------------
rb $1000
stacktop:

View File

@ -0,0 +1,33 @@
ID_CLOSE_BTN = 1
ID_COMPILE_BTN = 2
ID_EXECUTE_BTN = 3
ID_EXECDBG_BTN = 4
ID_OPENDLG_BTN = 5
NORMAL_MODE = 8
CONSOLE_MODE = 32
DEFAULT_WIN_W = 450
DEFAULT_WIN_H = 350
WIN_MIN_W = 350
WIN_MIN_H = 300
LINE_H = 25
RIGHT_BTN_W = 80
APP_MEMORY = 0x00800000
macro mmov reg,a1,a2 {
mov reg,(a1) shl 16 + (a2)
}
macro madd reg,a1,a2 {
add reg,(a1) shl 16 + (a2)
}
macro msub reg,a1,a2 {
sub reg,(a1) shl 16 + (a2)
}

View File

@ -0,0 +1,55 @@
;equates for EDIT_BOX
ED_PASS = 0001h
ED_FOCUS = 0002h
ED_SHIFT = 0004h
ED_SHIFT_ON = 0008h
ED_SHIFT_BAC = 0010h
ED_LEFT_FL = 0020h
ED_OFFSET_FL = 0040h
ED_INSERT = 0080h
ED_MOUSE_ON = 0100h
ED_CTRL_ON = 0200h
ED_ALT_ON = 0400h
ED_DISABLED = 0800h
ED_ALWAYS_FOCUS = 4000h
ED_FIGURE_ONLY = 8000h
ED_MOUS_ADN_B = ED_MOUSE_ON or ED_SHIFT_ON or ED_SHIFT_BAC
ED_SHIFT_OFF = not ED_SHIFT
ED_SHIFT_MCL = not ED_SHIFT
ED_SHIFT_ON_OFF = not ED_SHIFT_ON
ED_SHIFT_BAC_CL = not ED_SHIFT_BAC
ED_SHIFT_CL = not (ED_SHIFT or ED_SHIFT_ON or ED_SHIFT_BAC)
ED_RIGHT_FL = not ED_LEFT_FL
ED_OFFSET_CL = not ED_OFFSET_FL
ED_INSERT_CL = not ED_INSERT
ED_MOUSE_ON_OFF = not ED_MOUSE_ON
ED_CTRL_OFF = not ED_CTRL_ON
ED_ALT_OFF = not ED_ALT_ON
;equates for CHECK_BOX2
CB_FLAG_TOP = 0
CB_FLAG_EN = 2
CB_FLAG_MIDDLE = 4
CB_FLAG_BOTTOM = 8
; equates for TREE_LIST
TL_KEY_NO_EDIT = 0001h
TL_DRAW_PAR_LINE = 0002h
TL_LIST_BOX_MODE = 0004h
TL_ERR_LOAD_CAPTION = 0001h
TL_ERR_SAVE_MEMORY_SIZE = 0002h
TL_ERR_LOAD_INFO_SIZE= 0004h
TL_LOAD_MODE_ADD =20000h
TL_SAVE_LOAD_HEDER_SIZE = 26
TL_OFFS_BOX = 0
; equates for TEXT_EDITOR
TED_OPT_ED_MOVE_CURSOR = 0001h
TED_OPT_ED_CHANGE_TIME = 0002h

View File

@ -0,0 +1,39 @@
; events
EV_IDLE = 0
EV_TIMER = 0
EV_REDRAW = 1
EV_KEY = 2
EV_BUTTON = 3
EV_EXIT = 4
EV_BACKGROUND = 5
EV_MOUSE = 6
EV_IPC = 7
EV_STACK = 8
; event mask bits for function 40
EVM_REDRAW = 1b
EVM_KEY = 10b
EVM_BUTTON = 100b
EVM_EXIT = 1000b
EVM_BACKGROUND = 10000b
EVM_MOUSE = 100000b
EVM_IPC = 1000000b
EVM_STACK = 10000000b
EVM_DEBUG = 100000000b
EVM_STACK2 = 1000000000b
EVM_MOUSE_FILTER = 0x80000000
EVM_CURSOR_FILTER = 0x40000000
; create window constants
CW_CAPTION = $10000000
CW_CLIENTRECTCOORDS = $20000000
CW_TRANSPARENT = $40000000
CW_GRADIENTFILL = $80000000
CW_DONTDRAW = $01000000
CW_SKINED = $03000000
CW_SKINEDFIXED = $04000000
CW_UNMOVABLE = $01000000
; colors
CLR_BLACK = $00000000

View File

@ -0,0 +1,12 @@
; equates for OpenDialog
; OpenDialog type
ODT_OPEN = 0
ODT_SAVE = 1
ODT_DIR = 2
; OpenDialog status
ODS_CANCEL = 0
ODS_OK = 1
ODS_ALTER = 2

View File

@ -0,0 +1,292 @@
; KolibriOS system functions:
SF_TERMINATE_PROCESS=-1
SF_CREATE_WINDOW=0 ; define and draw the window
SF_PUT_PIXEL=1 ; draw pixel to the window
SF_GET_KEY=2 ; get code of the pressed key
SF_GET_SYS_TIME=3
SF_DRAW_TEXT=4
SF_SLEEP=5 ; pause process
SF_PUT_IMAGE=7 ; draw image to the window
SF_DEFINE_BUTTON=8 ; define/delete the button
SF_THREAD_INFO=9 ; information on execution thread
SF_WAIT_EVENT=10 ; wait for event
SF_CHECK_EVENT=11 ; check for event and return
SF_REDRAW=12
SSF_BEGIN_DRAW=1
SSF_END_DRAW=2
SF_DRAW_RECT=13 ; draw rectangle to the window
SF_GET_SCREEN_SIZE=14 ; get screen resolution
SF_BACKGROUND_SET=15 ; work with desktop background graphics
SSF_SIZE_BG=1 ; set a size of the background image
SSF_PIXEL_BG=2 ; put pixel on the background image
SSF_REDRAW_BG=3 ; redraw background
SSF_MODE_BG=4 ; set drawing mode for the background
SSF_IMAGE_BG=5 ; put block of pixels on the background image
SSF_MAP_BG=6 ; map background image to the address space of the process
SSF_UNMAP_BG=7 ; close mapped background data
SSF_LAST_DRAW=8 ; get coordinates of the last draw to the background
SSF_REDRAW_RECT=9 ; redraws a rectangular part of the background
SF_RD_TO_FLOPPY=16 ; save ramdisk on the floppy
SF_GET_BUTTON=17 ; get ID of the pressed button
SF_SYSTEM=18
SSF_UNFOCUS_WINDOW=1 ; take focus from the window of the given thread
SSF_TERMINATE_THREAD=2 ; terminate process/thread by the slot number
SSF_FOCUS_WINDOW=3 ; give focus to the window of the given thread
SSF_GET_IDLE_COUNT=4 ; get counter of idle cycles per second
SSF_GET_CPU_FREQUENCY=5 ; get CPU clock rate
SSF_RD_TO_HDD=6 ; save ramdisk to the file on hard disk
SSF_GET_ACTIVE_WINDOW=7 ; get slot number of the active window
SSF_SPEAKER=8
SSSF_GET_STATE=1
SSSF_TOGGLE=2
SSF_SHUTDOWN=9 ; system shutdown/reboot
SSF_MINIMIZE_WINDOW=10 ; minimize active window
SSF_INFO_DISC_SYS=11 ; get disk subsystem information
SSF_KERNEL_VERSION=13 ; get kernel version
SSF_WAIT_RETRACE=14 ; wait for screen retrace
SSF_CURSOR_CENTER=15 ; center mouse cursor on the screen
SSF_GET_FREE_RAM=16 ; get size of free RAM
SSF_GET_TOTAL_RAM=17 ; get total amount of RAM
SSF_TERMINATE_THREAD_ID=18 ; Terminate process/thread by the ID
SSF_MOUSE_SETTINGS=19
SSSF_GET_SPEED=0
SSSF_SET_SPEED=1
SSSF_GET_SPEEDUP=2
SSSF_SET_SPEEDUP=3 ; set mouse acceleration
SSSF_SET_POS=4 ; set mouse pointer position
SSSF_SET_BUTTON=5 ; simulate state of mouse buttons
SSSF_GET_DOUBLE_CLICK_DELAY=6
SSSF_SET_DOUBLE_CLICK_DELAY=7
SSF_GET_RAM_INFO=20 ; get information on RAM
SSF_GET_THREAD_SLOT=21 ; get slot number of process/thread by the ID
SSF_FOREIGN_WINDOW=22 ; operations with window of another thread by slot/ID
SSSF_MINIMIZE=0
SSSF_MINIMIZE_ID=1
SSSF_RESTORE=2
SSSF_RESTORE_ID=3
SSF_MINIMIZE_ALL=23
SSF_SET_SCREEN_LIMITS=24
SSF_WINDOW_BEHAVIOR=25 ; window focus relation with other windows
SSSF_GET_WB=1
SSSF_SET_WB=2
SF_MIDI=20
SSF_RESET=1
SSF_OUTPUT=2
SF_SYSTEM_SET=21
SSF_MPU_MIDI_BASE=1
SSF_KEYBOARD_LAYOUT=2
SSF_SYS_LANG=5
SSF_ACCESS_HD_LBA=11 ; setting of low-level access to HD
SSF_ACCESS_PCI=12 ; setting of low-level access to PCI
SF_SET_TIME_DATE=22
SF_WAIT_EVENT_TIMEOUT=23; wait for event with timeout
SF_CD=24
SSF_EJECT_TRAY=4
SSF_INSERT_TRAY=5
SF_SCREEN_PUT_IMAGE=25 ; put image on the background layer
SF_SYSTEM_GET=26
; Same as SF_SYSTEM_SET, plus:
SSF_TIME_COUNT=9
SSF_TIME_COUNT_PRO=10 ; get value of the high precision time counter
SF_GET_SYS_DATE=29
SF_CURRENT_FOLDER=30
SSF_SET_CF=1 ; set current folder for the thread
SSF_GET_CF=2
SSF_ADD_SYS_FOLDER=3 ; install the add.system directory for the kernel
SF_GET_PIXEL_OWNER=34 ; get slot number of the screen pixel owner
SF_GET_PIXEL=35 ; read the screen pixel color
SF_GET_IMAGE=36 ; read the screen area
SF_MOUSE_GET=37
SSF_SCREEN_POSITION=0
SSF_WINDOW_POSITION=1
SSF_BUTTON=2 ; states of the mouse buttons
SSF_BUTTON_EXT=3 ; states and events of the mouse buttons
SSF_LOAD_CURSOR=4
SSF_SET_CURSOR=5
SSF_DEL_CURSOR=6
SSF_SCROLL_DATA=7
SF_DRAW_LINE=38
SF_BACKGROUND_GET=39
;SSF_SIZE_BG=1
;SSF_PIXEL_BG=2
;SSF_MODE_BG=4
SF_SET_EVENTS_MASK=40 ; turn on/off desired events
SF_PORT_IN_OUT=43 ; input/output to a port
SF_SET_PORTS=46 ; reserve/free a group of input/output ports
SF_DRAW_NUMBER=47 ; draw number to the window
SF_STYLE_SETTINGS=48
SSF_APPLY=0 ; apply screen settings
SSF_SET_BUTTON_STYLE=1
SSF_SET_COLORS=2
SSF_GET_COLORS=3 ; get standard window colors
SSF_GET_SKIN_HEIGHT=4
SSF_GET_SCREEN_AREA=5 ; get screen working area
SSF_SET_SCREEN_AREA=6
SSF_GET_SKIN_MARGINS=7
SSF_SET_SKIN=8
SSF_GET_FONT_SMOOTH=9
SSF_SET_FONT_SMOOTH=10
SSF_GET_FONT_SIZE=11
SSF_SET_FONT_SIZE=12
SF_APM=49
SF_SET_WINDOW_SHAPE=50
SF_CREATE_THREAD=51
SF_CLIPBOARD=54
SSF_GET_SLOT_COUNT=0 ; get the number of slots in the clipboard
SSF_READ_CB=1
SSF_WRITE_CB=2
SSF_DEL_SLOT=3 ; delete the last slot in the clipboard
SSF_UNLOCK_BUFFER=4 ; emergency buffer unlock
SF_SPEAKER_PLAY=55
SF_PCI_BIOS=57
SF_IPC=60 ; Inter Process Communication
SSF_SET_AREA=1 ; set area for IPC receiving
SSF_SEND_MESSAGE=2
SF_GET_GRAPHICAL_PARAMS=61
SSF_SCREEN_SIZE=1
SSF_BITS_PER_PIXEL=2
SSF_BYTES_PER_LINE=3
SF_PCI=62
SSF_GET_VERSION=0 ; get version of PCI-interface
SSF_GET_LAST_BUS=1 ; get number of the last PCI-bus
SSF_GET_ADRR_MODE=2 ; get addressing mode of the PCI configuration space
SSF_READ_BYTE=4
SSF_READ_WORD=5
SSF_READ_DWORD=6
SSF_WRITE_BYTE=8
SSF_WRITE_WORD=9
SSF_WRITE_DWORD=10
SF_BOARD=63
SSF_DEBUG_WRITE=1
SSF_DEBUG_READ=2
SF_MEMORY_RESIZE=64 ; resize total application memory
SF_PUT_IMAGE_EXT=65 ; draw image with palette to the window
SF_KEYBOARD=66
SSF_SET_INPUT_MODE=1
SSF_GET_INPUT_MODE=2
SSF_GET_CONTROL_KEYS=3; get status of control keys
SSF_SET_SYS_HOTKEY=4
SSF_DEL_SYS_HOTKEY=5
SSF_LOCK_INPUT=6 ; block normal input
SSF_UNLOCK_INPUT=7 ; restore normal input
SF_CHANGE_WINDOW=67 ; change position/sizes of the window
SF_SYS_MISC=68
SSF_GET_TASK_SWITCH_COUNT=0
SSF_SWITCH_TASK=1
SSF_PERFORMANCE=2
SSSF_ALLOW_RDPMC=0
SSSF_CACHE_STATUS=1
SSSF_CACHE_ON=2
SSSF_CACHE_OFF=3
SSF_READ_MSR=3
SSF_WRITE_MSR=4
SSF_HEAP_INIT=11
SSF_MEM_ALLOC=12
SSF_MEM_FREE=13
SSF_WAIT_SIGNAL=14 ; wait for signal from another program/driver
SSF_LOAD_DRIVER=16
SSF_CONTROL_DRIVER=17
SSF_LOAD_DLL=19
SSF_MEM_REALLOC=20
SSF_LOAD_DRIVER_PE=21
SSF_MEM_OPEN=22 ; open named memory area
SSF_MEM_CLOSE=23
SSF_SET_EXCEPTION_HANDLER=24
SSF_SET_EXCEPTION_STATE=25
SSF_MEM_FREE_EXT=26
SSF_LOAD_FILE=27
SF_DEBUG=69
SSF_SET_MESSAGE_AREA=0
SSF_GET_REGISTERS=1
SSF_SET_REGISTERS=2
SSF_DETACH=3
SSF_SUSPEND=4
SSF_RESUME=5
SSF_READ_MEMORY=6
SSF_WRITE_MEMORY=7
SSF_TERMINATE=8
SSF_DEFINE_BREAKPOINT=9
SF_FILE=70
SSF_READ_FILE=0
SSF_READ_FOLDER=1
SSF_CREATE_FILE=2
SSF_WRITE_FILE=3
SSF_SET_END=4
SSF_GET_INFO=5
SSF_SET_INFO=6
SSF_START_APP=7
SSF_DELETE=8
SSF_CREATE_FOLDER=9
SF_SET_CAPTION=71
SF_SEND_MESSAGE=72
SF_BLITTER=73
SF_NETWORK_GET=74
SSF_DEVICE_COUNT=255 ; get number of active network devices
SSF_DEVICE_TYPE=0
SSF_DEVICE_NAME=1
SSF_RESET_DEVICE=2
SSF_STOP_DEVICE=3
SSF_DEVICE_POINER=4
SSF_TX_PACKET_COUNT=6
SSF_RX_PACKET_COUNT=7
SSF_TX_BYTE_COUNT=8
SSF_RX_BYTE_COUNT=9
SSF_LINK_STATUS=10
SF_NETWORK_SOCKET=75
SSF_OPEN=0
SSF_CLOSE=1
SSF_BIND=2
SSF_LISTEN=3
SSF_CONNECT=4
SSF_ACCEPT=5
SSF_SEND=6
SSF_RECEIVE=7
SSF_SET_OPTIONS=8
SSF_GET_OPTIONS=9
SSF_GET_PAIR=10
SF_NETWORK_PROTOCOL=76
SSF_ETHERNET_READ_MAC=0
SSF_IP4_PACKETS_SENT=10000h
SSF_IP4_PACKETS_RECEIVED=10001h
SSF_IP4_READ_IP=10002h
SSF_IP4_WRITE_IP=10003h
SSF_IP4_READ_DNS=10004h
SSF_IP4_WRITE_DNS=10005h
SSF_IP4_READ_SUBNET=10006h
SSF_IP4_WRITE_SUBNET=10007h
SSF_IP4_READ_GATEWAY=10008h
SSF_IP4_WRITE_GATEWAY=10009h
SSF_ICMP_PACKETS_SENT=20000h
SSF_ICMP_PACKETS_RECEIVED=20001h
SSF_ICMP_ECHO_REPLY=20003h
SSF_UDP_PACKETS_SENT=30000h
SSF_UDP_PACKETS_RECEIVED=30001h
SSF_TCP_PACKETS_SENT=40000h
SSF_TCP_PACKETS_RECEIVED=40001h
SSF_ARP_PACKETS_SENT=50000h
SSF_ARP_PACKETS_RECEIVED=50001h
SSF_ARP_GET_ENTRY_COUNT=50002h
SSF_ARP_READ_ENTRY=50003h
SSF_ARP_ADD_STATIC_ENTRY=50004h
SSF_ARP_DEL_ENTRY=50005h
SSF_ARP_SEND_ANNOUNCE=50006h
SSF_ARP_CONFLICTS_COUNT=50007h
SF_FUTEX=77
SSF_CREATE=0
SSF_DESTROY=1
SSF_WAIT=2
SSF_WAKE=3
; File system errors:
FSERR_SUCCESS=0
FSERR_UNSUPPORTED=2
FSERR_UNKNOWN=3
FSERR_FILE_NOT_FOUND=5
FSERR_END_OF_FILE=6
FSERR_INVALID_BUFFER=7
FSERR_DISK_FULL=8
FSERR_FAIL=9
FSERR_ACCESS_DENIED=10
FSERR_DEVICE_FAIL=11
FSERR_OUT_OF_MEMORY=12

View File

@ -0,0 +1,13 @@
; Macroinstructions for making exports data structure
macro export [name,sname]
{
forward
dd __#name#_export_name__,name
common
dd 0
forward
align 4
__#name#_export_name__ db sname,0
}

View File

@ -0,0 +1,49 @@
; Macroinstructions for making import section
macro library [name,string]
{ common
import.data:
forward
local _label
if defined name#.lookup
if name#.lookup.size
dd name#.lookup,_label
end if
end if
name#.referred = 1
common
dd 0
forward
if defined name#.lookup
if name#.lookup.size
align 4
db '/sys/lib/'
_label db string,0
end if
end if }
macro import name,[label,string]
{ common
align 4
if defined name#.referred
name#.lookup:
forward
if used label
local _label
label dd _label
end if
common
if $ > name#.lookup
dd 0
end if
name#.lookup.size=$ - name#.lookup
forward
if used label
align 4
_label db string,0
end if
common
end if }
macro api [name] {}

View File

@ -0,0 +1 @@
__CPU_type fix p5

View File

@ -0,0 +1,48 @@
; Macroinstructions for calling procedures (without defining)
macro stdcall proc,[arg] ; directly call STDCALL procedure
{ common
if ~ arg eq
reverse
pushd arg
common
end if
call proc }
macro invoke proc,[arg] ; indirectly call STDCALL procedure
{ common
if ~ arg eq
reverse
pushd arg
common
end if
call [proc] }
macro ccall proc,[arg] ; directly call CDECL procedure
{ common
size@ccall = 0
if ~ arg eq
reverse
pushd arg
size@ccall = size@ccall+4
common
end if
call proc
if size@ccall
add esp,size@ccall
end if }
macro cinvoke proc,[arg] ; indirectly call CDECL procedure
{ common
size@ccall = 0
if ~ arg eq
reverse
pushd arg
size@ccall = size@ccall+4
common
end if
call [proc]
if size@ccall
add esp,size@ccall
end if }

View File

@ -0,0 +1,476 @@
; Macroinstructions for defining data structures
macro struct@overridedefs [datadef] {
struc datadef [val:?] \{ \common
match any:no,force@alignment:@rstruct \\{ define field@struct -,align,datadef#.align \\}
define field@struct .,datadef,<val> \}
macro datadef [val:?] \{ \common
match any:no,force@alignment:@rstruct \\{ define field@struct -,align,datadef#.align \\}
define field@struct -,datadef,<val> \} }
;==============================================================
macro struct@overridersvs [datadef] {
match ddd,def.#datadef \{
struc datadef count \\{ \\common
match any:no,force@alignment:@rstruct \\\{ define field@struct -,align,ddd\#.align \\\}
define field@struct .,ddd,count dup (?) \\}
macro datadef count \\{ \\common
match any:no,force@alignment:@rstruct \\\{ define field@struct -,align,ddd\#.align \\\}
define field@struct -,ddd,count dup (?) \\} \} }
;==============================================================
macro struct@overridealgn [datadef] {
struc datadef amount:default.#datadef \{ define field@struct -,datadef,amount \}
macro datadef amount:default.#datadef \{ define field@struct -,datadef,amount \} }
;==============================================================
macro struct@restoredefs [datadef] {
restruc datadef
purge datadef }
;==============================================================
; GLOBAL ASSUMPTIONS FOR THIS MACRO SET
; THERE IS NO PRACTICAL SENSE TO ENCLOSE IN UNION OR STRUCT NO ONE FIELD
; THERE IS NO PRACTICAL SENSE TO ENCLOSE IN SUBUNION OR SUBSTRUCT ONLY 1 FIELD OR EVEN NO ONE
; THERE IS NO PRACTICAL SENSE TO ENCLOSE IN SUBUNION ONLY UNNAMED FIELDS
;==============================================================
macro struct definition {
match name tail, definition: \{
virtual
db \`name
load initial@struct byte from $$
if initial@struct = '.'
display 'Error: name of structure should not begin with a dot.',0Dh,0Ah
err
end if
end virtual
macro ends \\{
match , sub@struct \\\{
if $
display 'Error: definition of ',\`name,' contains illegal instructions.',0Dh,0Ah
err
end if
match any,datadef@directives \\\\{ struct@restoredefs any \\\\}
match any,datarsv@directives \\\\{ struct@restoredefs any \\\\}
match any,algnmnt@directives \\\\{ struct@restorealgn any \\\\}
purge union,struct,rstruct,ends
irpv fields,field@struct \\\\{
restore field@struct
\\\\common
restore @struct
make@struct name,fields
define fields@\#name fields \\\\}
end virtual \\\} ;end virtual must be after make@struct
match any, sub@struct \\\{
tmp@struct equ field@struct
restore field@struct
field@struct equ tmp@struct> \\\}
restore sub@struct \\}
;match :,tail \\{ \\}
match parent:,tail \\{ field@struct equ fields@\\#parent \\} \}
match any,datadef@directives \{ struct@overridedefs any \}
match any,datarsv@directives \{ struct@overridersvs any \}
match any,algnmnt@directives \{ struct@overridealgn any \}
irp datadef,union,struct,rstruct \{
macro datadef \\{
field@struct equ ,sub\#datadef,<
sub@struct equ sub\#datadef \\} \}
define @struct
sub@struct equ
virtual at 0 }
;==============================================================
macro union definition {
struct definition
define @union }
;==============================================================
macro rstruct definition {
struct definition
define @rstruct }
;==============================================================
macro make@struct name,[field,type,def] {
common
local CONVERTED,PREVIOUS,CURRENT
define CONVERTED name
define CURRENT 1
forward
PREVIOUS equ CURRENT
define CURRENT 1
local sub
match , field \{ define CURRENT 2
make@substruct type,name,sub def \}
match -, field \{ define CURRENT 0 \}
match =1:=0, PREVIOUS:CURRENT \{ CONVERTED equ CONVERTED, < <type def> \}
match =0:=0, PREVIOUS:CURRENT \{ CONVERTED equ CONVERTED , <type def> \}
match =1:=1, PREVIOUS:CURRENT \{ CONVERTED equ CONVERTED, , .#field, type, <def> \}
match =0:=1, PREVIOUS:CURRENT \{ CONVERTED equ CONVERTED >, .#field, type, <def> \}
match =1:=2, PREVIOUS:CURRENT \{ CONVERTED equ CONVERTED, , ., sub, \}
match =0:=2, PREVIOUS:CURRENT \{ CONVERTED equ CONVERTED >, ., sub, \}
match =2, CURRENT \{ define CURRENT 1 \}
common
local anonymous
match =0, CURRENT \{ CONVERTED equ CONVERTED >, anonymous,:, \}
match converted, CONVERTED \{
match no:no, @union:@rstruct \\{ define@struct converted \\}
match no:, @union:@rstruct \\{
restore @rstruct
define@rstruct converted \\}
match :no, @union:@rstruct \\{
restore @union
define@union converted \\} \} }
;==============================================================
macro define@union name,[anon,field,type,def] {
forward
match any, anon \{
irp anondef,any \\{
\\local anonsize
virtual at 0
anondef
anonsize = $
end virtual
if anonsize > $
rb anonsize - $
end if
\\} \}
if ~ field eq .
virtual at 0
name#field type def
sizeof.#name#field = $ - name#field
end virtual
if sizeof.#name#field > $
rb sizeof.#name#field - $
end if
else
virtual at 0
label name#.#type
rb sizeof.#type
end virtual
if sizeof.#type > $
rb sizeof.#type - $
end if
end if
common
sizeof.#name = $
restruc name
struc name value \{
\local \..base
match , @struct \\{ define field@struct .,name,value \\}
match no, @struct \\{
label \..base
last@union equ
forward
match any, last@union \\\{
virtual at \..base
field type def
end virtual \\\}
match , last@union \\\{
match , value \\\\{ field type def \\\\}
match any, value \\\\{ field type value \\\\} \\\}
last@union equ field
common
if sizeof.#name > $ - \..base
rb sizeof.#name - ($ - \..base)
end if
label . at \..base \\}
\}
macro name value \{
\local \..base
match , @struct \\{ define field@struct -,name,value \\}
match no, @struct \\{
label \..base
last@union equ
forward
match , last@union \\\{ match any, value \\\\{ field type value \\\\} \\\}
last@union equ field
common
if sizeof.#name > $ - \..base
rb sizeof.#name - ($ - \..base)
end if \\} \} }
;==============================================================
macro define@rstruct name,[anon,field,type,def] {
common
local list,..start,..size
list equ
virtual at -..size
..start:
forward
local anonsize
;!!! WE MAKING ASSUMPTION THAT UNNAMED FIELDS ARE JUST RESERVE SPACE
anonsize = $
match any, anon \{ irp anondef,any \\{ anondef \\} \}
anonsize = $-anonsize
; END OF ASSUMPTION
if ~ field eq .
name#field type def
sizeof.#name#field = $ - name#field
else
label name#.#type
rb sizeof.#type
end if
local value
match any, list \{ list equ list, \}
list equ list <value>
common
..size = $ - ..start
end virtual
sizeof.#name = ..size
restruc name
match values, list \{
struc name value \\{
match , @struct \\\{ define field@struct .,name,<values> \\\}
match no, @struct \\\{
forward
;!!! WE MAKING ASSUMPTION THAT UNNAMED FIELDS ARE JUST RESERVE SPACE
rb anonsize
; END of ASSUMPTION
match , value \\\\{ field type def \\\\}
match any, value \\\\{
field type value
if ~ field eq . ; MAIN PURPOSE OF THEESE 3 LINES - REALISATION OF LEGACY ALIGNMENT STYLE IN STRUCTURES
rb sizeof.#name#field - ($-field) ; BECAUSE ALIGNED FIELD PRECIDED WITH ANOTHER SHORTER SIZE FIELD - WE CAN EMULATE ALIGNMENT BY ADDING SEQUENCE OF ",?" TO END OF THAT SHORTER SIZE FIELD
end if ; 2ND PURPOSE - COMPARISON THAT DATA PASSED TO INITIALIZE STRUCTURE WILL FIT IN ITS MEMBERS; IN COMMON CASE MORE OPTIMAL SUCH COMPARISON FOR WHOLE STRUCTURE NOT PER FIELD
\\\\}
common
;if $-\\..base-sizeof.#name ; IF WE REMOVE 3 LINES ABOVE COMMENTED AS LEGACY
; err ; THEN WE MUST UNCOMMENT THESE 3 LINES
;end if ;
label . \\\}
\\}
macro name value \\{
\\local anonymous
match , @struct \\\{ define field@struct -,name,<values> \\\}
match no, @struct \\\{ anonymous name value \\\} \\} \} }
;==============================================================
macro define@struct name,[anon,field,type,def] {
common
local list
list equ
forward
local anonsize
;!!! WE MAKING ASSUMPTION THAT UNNAMED FIELDS ARE JUST RESERVE SPACE
anonsize = $
match any, anon \{ irp anondef,any \\{ anondef \\} \}
anonsize = $-anonsize
; END OF ASSUMPTION
if ~ field eq .
name#field type def
sizeof.#name#field = $ - name#field
else
label name#.#type
rb sizeof.#type
end if
local value
match any, list \{ list equ list, \}
list equ list <value>
common
sizeof.#name = $
restruc name
match values, list \{
struc name value \\{
\\local \\..base
match , @struct \\\{ define field@struct .,name,<values> \\\}
match no, @struct \\\{
label \\..base
forward
;!!! WE MAKING ASSUMPTION THAT UNNAMED FIELDS ARE JUST RESERVE SPACE
rb anonsize
; END of ASSUMPTION
match , value \\\\{ field type def \\\\}
match any, value \\\\{
field type value
if ~ field eq . ; MAIN PURPOSE OF THEESE 3 LINES - REALISATION OF LEGACY ALIGNMENT STYLE IN STRUCTURES
rb sizeof.#name#field - ($-field) ; BECAUSE ALIGNED FIELD PRECIDED WITH ANOTHER SHORTER SIZE FIELD - WE CAN EMULATE ALIGNMENT BY ADDING SEQUENCE OF ",?" TO END OF THAT SHORTER SIZE FIELD
end if ; 2ND PURPOSE - COMPARISON THAT DATA PASSED TO INITIALIZE STRUCTURE WILL FIT IN ITS MEMBERS; IN COMMON CASE MORE OPTIMAL SUCH COMPARISON FOR WHOLE STRUCTURE NOT PER FIELD
\\\\}
common
;if $-\\..base-sizeof.#name ; IF WE REMOVE 3 LINES ABOVE COMMENTED AS LEGACY
; err ; THEN WE MUST UNCOMMENT THESE 3 LINES
;end if ;
label . at \\..base \\\}
\\}
macro name value \\{
\\local anonymous
match , @struct \\\{ define field@struct -,name,<values> \\\}
match no, @struct \\\{ anonymous name value \\\} \\} \} }
;==============================================================
macro enable@substruct {
macro make@substruct substruct,parent,name,[field,type,def] \{
\common
\local CONVERTED,PREVIOUS,CURRENT
define CONVERTED parent,name
define CURRENT 1
\forward
PREVIOUS equ CURRENT
define CURRENT 1
\local sub
match , field \\{
match any, type \\\{
define CURRENT 2
enable@substruct
make@substruct type,parent,sub def
purge make@substruct \\\} \\}
match -, field \\{ define CURRENT 0 \\}
match =1:=0, PREVIOUS:CURRENT \\{ CONVERTED equ CONVERTED, < <type def> \\}
match =0:=0, PREVIOUS:CURRENT \\{ CONVERTED equ CONVERTED , <type def> \\}
match =1:=1, PREVIOUS:CURRENT \\{ CONVERTED equ CONVERTED, , .\#field, type, <def> \\}
match =0:=1, PREVIOUS:CURRENT \\{ CONVERTED equ CONVERTED >, .\#field, type, <def> \\}
match =1:=2, PREVIOUS:CURRENT \\{ CONVERTED equ CONVERTED, , ., sub, \\}
match =0:=2, PREVIOUS:CURRENT \\{ CONVERTED equ CONVERTED >, ., sub, \\}
match =2, CURRENT \\{ define CURRENT 1 \\}
\common
\local anonymous
match =0, CURRENT \\{ CONVERTED equ CONVERTED >,anonymous, :, \\}
match converted, CONVERTED \\{ define@\#substruct converted \\} \} }
;==============================================================
enable@substruct
;==============================================================
macro define@subunion parent,name,[anon,field,type,def] {
common
virtual at parent#.#name
forward
match any, anon \{
irp anondef,any \\{
\\local anonsize
virtual at 0
anondef
anonsize = $
end virtual
if anonsize > $ - parent#.#name
rb anonsize - ($-$$)
end if
\\} \}
if ~ field eq .
virtual at parent#.#name
parent#field type def
sizeof.#parent#field = $ - parent#field
end virtual
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
end if
common
sizeof.#name = $ - parent#.#name
end virtual
struc name value \{
label .\#name
last@union equ
forward
match any, last@union \\{
virtual at .\#name
field type def
end virtual \\}
match , last@union \\{
match , value \\\{ field type def \\\}
match any, value \\\{ field type value \\\} \\}
last@union equ field
common
rb sizeof.#name - ($ - .\#name) \}
macro name value \{
label .\#name
last@union equ
forward
match , last@union \\{ match any, value \\\{ field type value \\\} \\}
last@union equ field
common
rb sizeof.#name - ($ - .\#name) \} }
;==============================================================
macro define@subrstruct parent,name,[anon,field,type,def] {
common
local ..start,..size
virtual at parent#.#name-..size
..start:
forward
local value,anonsize
;!!! WE MAKING ASSUMPTION THAT UNNAMED FIELDS ARE JUST RESERVE SPACE
anonsize = $
match any, anon \{ irp anondef,any \\{ anondef \\} \}
anonsize = $-anonsize
; END OF ASSUMPTION
if ~ field eq .
parent#field type def
sizeof.#parent#field = $ - parent#field
else
label parent#.#type
rb sizeof.#type
end if
common
..size = $ - ..start
sizeof.#name = ..size
end virtual
struc name value \{
label .\#name
forward
;!!! WE MAKING ASSUMPTION THAT UNNAMED FIELDS ARE JUST RESERVE SPACE
rb anonsize
; END of ASSUMPTION
match , value \\{ field type def \\}
match any, value \\{
field type value
if ~ field eq . ; MAIN PURPOSE OF THEESE 3 LINES - REALISATION OF LEGACY ALIGNMENT STYLE IN STRUCTURES
rb sizeof.#parent#field - ($-field) ; BECAUSE ALIGNED FIELD PRECIDED WITH ANOTHER SHORTER SIZE FIELD - WE CAN EMULATE ALIGNMENT BY ADDING SEQUENCE OF ",?" TO END OF THAT SHORTER SIZE FIELD
end if \\} ; 2ND PURPOSE - COMPARISON THAT DATA PASSED TO INITIALIZE STRUCTURE WILL FIT IN ITS MEMBERS; IN COMMON CASE MORE OPTIMAL SUCH COMPARISON FOR WHOLE STRUCTURE NOT PER FIELD
common
;if $-.\#name-sizeof.#name ; IF WE REMOVE 3 LINES ABOVE COMMENTED AS LEGACY
; err ; THEN WE MUST UNCOMMENT THESE 3 LINES
;end if ;
\}
macro name value \{
\local ..anonymous
..anonymous name \} }
;==============================================================
macro define@substruct parent,name,[anon,field,type,def] {
common
virtual at parent#.#name
forward
local value,anonsize
;!!! WE MAKING ASSUMPTION THAT UNNAMED FIELDS ARE JUST RESERVE SPACE
anonsize = $
match any, anon \{ irp anondef,any \\{ anondef \\} \}
anonsize = $-anonsize
; END OF ASSUMPTION
if ~ field eq .
parent#field type def
sizeof.#parent#field = $ - parent#field
else
label parent#.#type
rb sizeof.#type
end if
common
sizeof.#name = $ - parent#.#name
end virtual
struc name value \{
label .\#name
forward
;!!! WE MAKING ASSUMPTION THAT UNNAMED FIELDS ARE JUST RESERVE SPACE
rb anonsize
; END of ASSUMPTION
match , value \\{ field type def \\}
match any, value \\{
field type value
if ~ field eq . ; MAIN PURPOSE OF THEESE 3 LINES - REALISATION OF LEGACY ALIGNMENT STYLE IN STRUCTURES
rb sizeof.#parent#field - ($-field) ; BECAUSE ALIGNED FIELD PRECIDED WITH ANOTHER SHORTER SIZE FIELD - WE CAN EMULATE ALIGNMENT BY ADDING SEQUENCE OF ",?" TO END OF THAT SHORTER SIZE FIELD
end if \\} ; 2ND PURPOSE - COMPARISON THAT DATA PASSED TO INITIALIZE STRUCTURE WILL FIT IN ITS MEMBERS; IN COMMON CASE MORE OPTIMAL SUCH COMPARISON FOR WHOLE STRUCTURE NOT PER FIELD
common
;if $-.\#name-sizeof.#name ; IF WE REMOVE 3 LINES ABOVE COMMENTED AS LEGACY
; err ; THEN WE MUST UNCOMMENT THESE 3 LINES
;end if ;
\}
macro name value \{
\local ..anonymous
..anonymous name \} }

View File

@ -0,0 +1,127 @@
macro reg_props type,size,[reg]
{
typeof.#reg = type
sizeof.#reg = size
}
?isReg32 equ in <eax,ebx,ecx,edx,esi,edi,ebp,esp>
?isReg32w8 equ in <eax,ebx,ecx,edx>
?isReg equ eqtype eax
?isInteger equ eqtype 0
?isFlatMem equ eqtype []
?isSegMem equ eqtype fs:[]
?isString equ eqtype ''
macro madd reg,a1,a2 { add reg,(a1) shl 16 + (a2) }
macro msub reg,a1,a2 { sub reg,(a1) shl 16 + (a2) }
macro mcr_mov arg1*,arg2*
{
if (arg1 ?isReg32) & ((arg2 ?isInteger) | (arg2 ?isString))
if ~(arg2)
xor arg1,arg1
else if (arg2) = 1
xor arg1,arg1
inc arg1
else if (arg2) = -1
or arg1,-1
else
mov arg1,arg2
end if
else
mov arg1,arg2
end if
}
macro mpack dest, hsrc, lsrc
{
if (hsrc ?isInteger)
if (lsrc ?isReg32)
lea dest, [(hsrc) shl 16 + lsrc]
else if (+lsrc ?isInteger) ;everething except memory opnd
mov dest, (hsrc) shl 16 + lsrc
else ;if (lsrc ?isFlatMem) | (lsrc ?isSegMem)
mov dest, lsrc
add dest, (hsrc) shl 16
end if
else
mov dest, hsrc
shl dest, 16
add dest, lsrc
end if
}
macro __mov reg,a,b { ; mike.dld
match any,a \{
if (~b eq)
mpack reg,a,b
else if ~(a eq reg)
mcr_mov reg,a
end if \}
}
macro regcall proc,a,b,c,d,e,f,g {
__mov eax,a
__mov ebx,b
__mov ecx,c
__mov edx,d
__mov esi,e
__mov edi,f
__mov ebp,g
call proc
}
macro reginvk proc,a,b,c,d,e,f,g {
__mov eax,a
__mov ebx,b
__mov ecx,c
__mov edx,d
__mov esi,e
__mov edi,f
__mov ebp,g
call [proc]
}
include 'config.inc'
;__CPU_type equ p5
SYSENTER_VAR equ 0
macro mcallb a,b,c,d,e,f { ; mike.dld, updated by Ghost for Fast System Calls
local ..ret_point
__mov ebx,b
__mov ecx,c
__mov edx,d
__mov esi,e
__mov edi,f
if __CPU_type eq p5
int 0x40
else
if __CPU_type eq p6
push ebp
mov ebp, esp
push ..ret_point ; it may be 2 or 5 byte
sysenter
..ret_point:
pop edx
pop ecx
else
if __CPU_type eq k6
push ecx
syscall
pop ecx
else
display 'ERROR : unknown CPU type (set to p5)', 10, 13
__CPU_type equ p5
int 0x40
end if
end if
end if
}
macro mcall a,b& { ; mike.dld, updated by Ghost for Fast System Calls
__mov eax,a
mcallb ,b
}

View File

@ -0,0 +1,191 @@
GetStrLength:
; string: [in] edi
; string length: [out] ecx
; [unchanged] ebx, edx, esi, edi, ebp, esp
or ecx, -1
xor eax, eax
cld
repne scasb
not ecx
sub edi,ecx
ret
GetProcAddress:
; hInstance (export table): [in] esi
; proc name: [in] edi
; proc address: [out] eax
; [unchanged] ebp, esp
call GetStrLength
mov edx, ecx
mov ebx, edi
mov eax, esi
.import_find:
mov esi, ebx
mov edi, [eax]
test edi, edi
jz .import_not_found
repe cmpsb
je .import_found
mov ecx, edx
add eax, 8
jmp .import_find
.import_not_found:
sub eax, 4
.import_found:
mov eax, [eax+4]
ret
ResolveImports:
; hInstance (export table): [in] esi
; lib.lookup table: [in] ebp
; ?isResolved: [out] eax
; [unchanged] esi, esp
.retFrom = 4
.import_loop:
mov edi, [ebp]
test edi, edi
jz .import_done
push esi
call GetProcAddress
pop esi
test eax, eax
jz .import_not_found
mov [ebp],eax
add ebp,4
jmp .import_loop
.import_not_found:
mov eax, sz_EPnotFound
mov ebx, sizeof.sz_EPnotFound
mov ecx, 3
mov edx, [ebp]
call ShowErrorWindow
or [LoadLibraries.errStatus+ResolveImports.retFrom],1
mcall SF_TERMINATE_PROCESS ;uncomment to stop after 1st error
jmp .import_loop
.import_done:
ret
@copy_path_wo_pdname:
; library name: [in] edx
; library path: [in] esi
; current directory path: [in] edi
; [out] no
; [unchanged] ebx, edx, ebp, esp
call GetStrLength
add edi,ecx
mov al, '/'
std
repne scasb
cld
sub edi,ecx
add ecx,2
xchg esi, edi
mov eax, ecx
shr ecx, 2
rep movsd
mov ecx, eax
and ecx, 3
rep movsb
mov esi, edx
xchg esi, edi
call GetStrLength
xchg esi, edi
mov eax, ecx
shr ecx, 2
rep movsd
mov ecx, eax
and ecx, 3
rep movsb
ret
LoadLibrary:
; library name: [in] edx
; hInstance (export table): [out] eax
; [unchanged] edx, ebp, esp
mov edi, cur_dir_path
mov esi, library_path
call @copy_path_wo_pdname
mcall SF_SYS_MISC,SSF_LOAD_DLL,library_path
test eax, eax
jnz .ret
lea ecx, [edx-9]
mcall SF_SYS_MISC,SSF_LOAD_DLL,ecx ; load of sys directory
.ret:
ret
LoadLibraries:
; [in/out] no
; [unchanged] esp
push 0
push import.data
virtual at esp+4
.errStatus dd ?
end virtual
.LoopLibraries:
mov eax, [esp]
mov ebp, [eax]
test ebp, ebp
jz .done
mov edx, [eax+4]
call LoadLibrary;edx=name
test eax, eax
jz .onError
mov esi,eax
mov eax, [esp]
call ResolveImports
add dword[esp],8
jmp .LoopLibraries
.onError:
mov eax, sz_cantLL
mov ebx, sizeof.sz_cantLL
mov ecx, 1
or [LoadLibraries.errStatus],1
mcall SF_TERMINATE_PROCESS ;uncomment to stop after 1st error
jmp .LoopLibraries
.done:
test [LoadLibraries.errStatus],1
jz .exit
mcall SF_TERMINATE_PROCESS
.exit:
add esp,8
ret
ShowErrorWindow:
; error string: [in] edx
; [unchanged] edx, ebp, esp
mov edi, [file_io_notify.flags]
xor ecx, [import_loader.state]
test ecx, ecx
jz .rns.FlagsInited
cmp ecx, 2
jz .rns.FlagsPreInited
.rns.FlagsPreInit:
mov esi, sz_system_error
mov ecx, sizeof.sz_system_error-1
cld
rep movsb
or [import_loader.state],1
jmp .rns.FlagsInit
.rns.FlagsPreInited:
add edi, sizeof.sz_system_error-1
.rns.FlagsInit:
mov esi, eax
xchg esi, edi
call GetStrLength
dec ecx
xchg esi, edi
rep movsb
xor [import_loader.state],2
jmp .rns.FlagsDone
.rns.FlagsInited:
lea edi, [edi+ebx-1+sizeof.sz_system_error-1]
.rns.FlagsDone:
mov esi, edx
xchg esi, edi
call GetStrLength
xchg esi, edi
rep movsb
mcall SF_FILE,file_io_notify
ret

View File

@ -0,0 +1,230 @@
struct EDIT_BOX
width dd ?
left dd ?
top dd ?
color dd ?
shift_color dd ?
focus_border_color dd ?
blur_border_color dd ?
text_color dd ?
max dd ?
text dd ?
mouse_variable dd ?
flags dd ?
size dd ?
pos dd ?
offset dd ?
cl_curs_x dw ?
cl_curs_y dw ?
shift dw ?
shift_old dw ?
height dd ?
char_width dd ?
ends
struct CHECK_BOX2
left_s dd ?
top_s dd ?
ch_text_margin dd ?
color dd ?
border_color dd ?
text_color dd ?
text dd ?
flags dd ?
size_of_str dd ?
ends
struct OPTION_BOX
option_group dd ?
left dw ?
top dw ?
ch_text_margin dd ?
ch_size dd ?
color dd ?
border_color dd ?
text_color dd ?
text dd ?
ch_text_length dd ?
flags dd ?
ends
struct TREE_LIST
box BOX
data_info dd ?
info_size dd ?
info_max_count dd ?
style dd ?
data_nodes dd ?
data_img dd ?
img_cx dw ?
img_cy dw ?
data_img_sys dd ?
ch_tim dd ?
tim_undo dd ?
cur_pos dd ?
col_bkg dd ?
col_zag dd ?
col_txt dd ?
capt_cy dd ?
info_capt_offs dw ?
info_capt_len dw ?
el_focus dd ?
p_scroll dd ?
on_press dd ?
ends
struct TEXT_EDITOR
wnd BOX
rec BOX
drag_m db ?
drag_k db ?
sel_x0 dd ?
sel_y0 dd ?
sel_x1 dd ?
sel_y1 dd ?
seln_x0 dd ?
seln_y0 dd ?
seln_x1 dd ?
seln_y1 dd ?
tex dd ?
tex_1 dd ?
tex_end dd ?
cur_x dd ?
cur_y dd ?
max_chars dd ?
colors_text_count dd ?
key_words_count dd ?
color_cursor dd ?
color_wnd_capt dd ?
color_wnd_work dd ?
color_wnd_bord dd ?
color_select dd ?
color_cur_text dd ?
color_wnd_text dd ?
syntax_file dd ?
syntax_file_size dd ?
text_colors dd ?
help_text_f1 dd ?
help_id dd ?
key_words_data dd ?
tim_ch dd ?
tim_undo dd ?
tim_ls dd ?
tim_co dd ?
el_focus dd ?
err_save dd ?
panel_id dd ?
key_new dd ?
symbol_new_line dd ?
scr_w dd ?
scr_h dd ?
arr_key_pos dd ?
buffer dd ?
buffer_find dd ?
cur_ins db ?
mode_color db ?
mode_invis db ?
gp_opt db ?
fun_on_key_ctrl_o dd ?
fun_on_key_ctrl_f dd ?
fun_on_key_ctrl_n dd ?
fun_on_key_ctrl_s dd ?
buffer_size dd ?
fun_find_err dd ?
fun_init_synt_err dd ?
fun_draw_panel_buttons dd ?
fun_draw_panel_find dd ?
fun_draw_panel_syntax dd ?
fun_save_err dd ?
increase_size dd ?
ptr_free_symb dd ?
font_size dd ?
ends
TED_OFFS_SEL = TEXT_EDITOR.sel_x0
TED_OFFS_SELN = TEXT_EDITOR.seln_x0
TED_OFFS_COUNT_COLORS = TEXT_EDITOR.colors_text_count
TED_OFFS_KEY_NEW = TEXT_EDITOR.key_new
TED_OFFS_SYMBOL_NEW_LINE = TEXT_EDITOR.symbol_new_line
struct SCROLL_BAR
x_size dw ?
x_pos dw ?
y_size dw ?
y_pos dw ?
btn_height dd ?
type dd ?
max_area dd ?
cur_area dd ?
position dd ?
bg_color dd ?
front_color dd ?
line_color dd ?
redraw dd ?
delta dw ?
delta2 dw ?
r_size_x dw ?
r_start_x dw ?
r_size_y dw ?
r_start_y dw ?
m_pos dd ?
m_pos_2 dd ?
m_keys dd ?
run_size dd ?
position2 dd ?
work_size dd ?
all_redraw dd ?
ar_offset dd ?
ends
SB_OFFS_SIZE_X = SCROLL_BAR.x_size
SB_OFFS_START_X = SCROLL_BAR.x_pos
SB_OFFS_SIZE_Y = SCROLL_BAR.y_size
SB_OFFS_START_Y = SCROLL_BAR.y_pos
SB_OFFS_MAX_AREA = SCROLL_BAR.max_area
SB_OFFS_CUR_AREA = SCROLL_BAR.cur_area
SB_OFFS_POSITION = SCROLL_BAR.position
SB_OFFS_BCKG_COL = SCROLL_BAR.bg_color
SB_OFFS_FRNT_COL = SCROLL_BAR.front_color
SB_OFFS_LINE_COL = SCROLL_BAR.line_color
SB_OFFS_REDRAW = SCROLL_BAR.redraw
SB_OFFS_DELTA2 = SCROLL_BAR.delta2
SB_OFFS_ALL_REDRAW = SCROLL_BAR.all_redraw
struct TOOLTIP
txt dd ?
next dd ?
zone_y dd ?
zone_x dd ?
zone_h dd ?
zone_w dd ?
col_txt dd ?
col_bkg dd ?
tm_wait dd ?
font_sz dd ?
mouse dd ?
bg_color dd ?
front_color dd ?
line_color dd ?
redraw dd ?
delta dw ?
delta2 dw ?
r_size_x dw ?
r_start_x dw ?
r_size_y dw ?
r_start_y dw ?
m_pos dd ?
m_pos_2 dd ?
m_keys dd ?
run_size dd ?
position2 dd ?
work_size dd ?
all_redraw dd ?
ar_offset dd ?
ends

View File

@ -0,0 +1,69 @@
struct BOX
left dd ?
top dd ?
width dd ?
height dd ?
ends
struct process_information
cpu_usage dd ? ; +0
window_stack_position dw ? ; +4
window_stack_value dw ? ; +6
dw ? ; +8
process_name TCHAR 12 dup(?) ; +10
memory_start dd ? ; +22
used_memory dd ? ; +26
PID dd ? ; +30
box BOX ; +34
slot_state dw ? ; +50
dw ? ; +52
client_box BOX ; +54
wnd_state db ? ; +70
align 1024
ends
struct system_colors
frame dd ? ;nonset1
grab dd ? ;nonset2
work_3d_dark dd ?
work_3d_light dd ?
grab_text dd ? ;window_title
work dd ?
work_button dd ?
work_button_text dd ?
work_text dd ?
work_graph dd ?
ends
struct FILEIO
cmd dd ?
offset dd ?
flags dd ?
count dd ?
buffer dd ?
; db ?
;name dd ?
ends
struct FILEDATE
Second db ?
Minute db ?
Hour db ?
db ?
Day db ?
Month db ?
Year dw ?
ends
struct FILEINFO
Attributes dd ?
IsUnicode db ?
db 3 dup(?)
DateCreate FILEDATE
DateAccess FILEDATE
DateModify FILEDATE
size dq ?
ends

View File

@ -0,0 +1,18 @@
struct OPEN_DLG
type dd ?
procinfo dd ?
com_area_name dd ?
com_area dd ?
opendir_path dd ?
dir_default_path dd ?
start_path dd ?
lp_drawwndproc dd ?
status dd ?
openfile_path dd ?
filename_area dd ?
filter_area dd ?
x_size dw ?
x_pos dw ?
y_size dw ?
y_pos dw ?
ends

View File

@ -0,0 +1,54 @@
; Kolibri programming headers (ASCII)
datadef@directives equ db,db.kol,dw,du,dd,dp,dq,dt
datarsv@directives equ rb,rw,rd,rp,rq,rt
algnmnt@directives equ
def.rb equ db
def.rw equ dw
def.rd equ dd
def.rp equ dp
def.rq equ dq
def.rt equ dt
db.align = 1
dw.align = 2
du.align = 2
dd.align = 4
dq.align = 8
sizeof.PTR =4
struc PTR [value:?] { common . dd value }
macro PTR [value:?] { common dd value }
sizeof.VOID =4
struc VOID [value:?] { common . dd value }
macro VOID [value:?] { common dd value }
;====== fundamental macros ======================
include 'kolibri/macro/struct.inc'
;====== OS specific macros ======================
include 'kolibri/macro/proc.inc'
include 'kolibri/macro/syscall.inc'
;====== file format specific macros =============
include 'kolibri/kex/import.inc'
include 'kolibri/kex/export.inc'
struc TCHAR [val:?] { common . db val }
sizeof.TCHAR = 1
struc ACHAR [val:?] { common . db val }
sizeof.ACHAR = 1
struc WCHAR [val:?] { common . du val }
sizeof.WCHAR = 2
;====== OS specific equates =====================
include 'kolibri/equates/syscalls.inc'
include 'kolibri/equates/kernel.inc'
include 'kolibri/equates/box_lib.inc'
include 'kolibri/equates/proc_lib.inc'
;====== COM technology equates ==================
force@alignment equ
;====== OS specific structures ==================
include 'kolibri/structs/kernel.inc'
include 'kolibri/structs/box_lib.inc'
include 'kolibri/structs/proc_lib.inc'

View File

@ -0,0 +1,37 @@
flat assembler version 1.73
Copyright (c) 1999-2020, Tomasz Grysztar.
All rights reserved.
This program is free for commercial and non-commercial use as long as
the following conditions are adhered to.
Copyright remains Tomasz Grysztar, and as such any Copyright notices
in the code are not to be removed.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
The licence and distribution terms for any publically available
version or derivative of this code cannot be changed. i.e. this code
cannot simply be copied and put under another distribution licence
(including the GNU Public Licence).

View File

@ -0,0 +1,623 @@
; flat assembler
; Copyright (c) 1999-2020, Tomasz Grysztar
; All rights reserved.
init_memory:
; mov ecx, 16*1024*1024
;
; allocate_memory:
mcall SF_SYSTEM, SSF_GET_FREE_RAM
cmp eax, 0x38000000 shr 9
jbe @f
mov eax, 0x38000000 shr 9
@@:
shl eax, 9
xchg eax, ecx
mov [memory_setting],ecx
mcall SF_SYS_MISC, SSF_MEM_ALLOC
or eax,eax
jz out_of_memory
mov [memblock], eax
mov [additional_memory],eax
add eax,[memory_setting]
mov [memory_end],eax
mov eax,[memory_setting]
shr eax,2
add eax,[additional_memory]
mov [additional_memory_end],eax
mov [memory_start],eax
ret
exit_program:
cmp [_mode],NORMAL_MODE
jne @f
mcall SF_SYS_MISC, SSF_MEM_FREE, [memblock]
mov esp,[processing_esp]
jmp still
@@:
or eax,-1
mcall
make_timestamp:
push ebx
mcall SF_SYSTEM_GET,SSF_TIME_COUNT
imul eax,10
pop ebx
ret
symbol_dump:
push edi
mov edx,[memory_end]
symb_dump:
cmp edx,[labels_list]
jbe symbols_dumped
sub edx,LABEL_STRUCTURE_SIZE
cmp dword [edx+24],0
je symb_dump ; do not dump anonymous symbols
test byte [edx+8],1
jz symb_dump ; do not dump symbols that didn't get defined
mov ax,[current_pass]
cmp ax,[edx+16]
jne symb_dump
test byte [edx+8],4 or 2
jnz symb_dump ; do not dump assembly-time variables
; do not dump variables defined with '='
cmp word [edx+12], 0
jnz symb_dump ; do not dump register-based variables
mov al, '0'
stosb
mov al, 'x'
stosb
mov eax, [edx+4]
mov ecx, 8
@@:
rol eax, 4
test al, 0xF
loopz @b
jz .nohigh
inc ecx
@@:
push eax
and al, 0xF
cmp al, 10
sbb al, 69h
das
stosb
pop eax
rol eax, 4
loop @b
mov eax, [edx]
mov ecx, 8
jmp .low
.nohigh:
mov eax, [edx]
mov ecx, 8
@@:
rol eax, 4
test al, 0xF
loopz @b
inc ecx
.low:
push eax
and al, 0xF
cmp al, 10
sbb al, 69h
das
stosb
pop eax
rol eax, 4
loop .low
mov al, ' '
stosb
mov esi,[edx+24]
movzx ecx,byte [esi-1]
rep movsb
mov ax,0A0Dh
stosw
jmp symb_dump
symbols_dumped:
mov edx,dbgfilename
push esi edi
mov esi, outfile
mov edi, edx
@@:
lodsb
stosb
test al, al
jnz @b
lea ecx, [edi-1]
@@:
dec edi
cmp edi, edx
jb @f
cmp byte [edi], '/'
jz @f
cmp byte [edi], '.'
jnz @b
mov ecx, edi
@@:
mov dword [ecx], '.dbg'
mov byte [ecx+4], 0
pop edi esi
call create
mov edx,[esp]
mov ecx,edi
sub ecx,edx
call write
call close
pop edi
ret
get_environment_variable:
mov ecx,[memory_end]
sub ecx,edi
cmp ecx,7
jb out_of_memory
cmp dword[esi],'INCL'
jne .finish
mov esi,_ramdisk
mov ecx,6
cld
rep movsb
.finish:
; stc
ret
alloc_handle:
call make_fullpaths
mov ebx, fileinfos+4
@@:
cmp dword [ebx], -1
jz .found
add ebx, 4+20+MAX_PATH
cmp ebx, fileinfos_end
jb @b
stc
ret
.found:
and dword [ebx+4], 0
and dword [ebx+8], 0
push esi edi ecx
mov esi, fullpath_open
lea edi, [ebx+20]
mov ecx, MAX_PATH
rep movsb
pop ecx edi esi
ret ; CF=0
create:
call alloc_handle
jc .ret
and dword [ebx-4], 0
mov dword [ebx], 2
.ret:
ret
open:
; call make_fullpaths
;; mov eax,fullpath_open
;; DEBUGF '"%s"\n',eax
; mov dword[file_info_open+8],-1
; mcall 58,file_info_open
; or eax,eax ; found
; jz @f
; cmp eax,6
; jne file_error
;@@: mov [filesize],ebx
; clc
; ret
;file_error:
; stc
; ret
call alloc_handle
jc .ret
mov dword [ebx], SSF_GET_INFO
and dword [ebx+12], 0
mov dword [ebx+16], fileinfo
mov eax, SF_FILE
push ebx
mcall
pop ebx
test eax, eax
jnz .fail
mov eax, dword[fileinfo.size]
mov [ebx-4], eax
and dword [ebx], 0
.ret:
ret
.fail:
or dword [ebx], -1 ; close handle
stc
ret
read:
; pusha
; mov edi,edx
; mov esi,[filepos]
; add esi,0x20000
; cld
; rep movsb
; popa
;; ret
mov [ebx+12], ecx
mov [ebx+16], edx
push ebx
mov eax, SF_FILE
mcall
xchg eax, [esp]
add [eax+4], ebx
adc [eax+8], dword 0
mov ebx, eax
pop eax
test eax, eax
jz .ok
cmp eax, 6
jz .ok
stc
.ok:
ret
close:
or dword [ebx], -1
ret
; ebx file handle
; ecx count of bytes to write
; edx pointer to buffer
write:
; pusha
; mov [file_info_write+8],ecx
; mov [file_info_write+12],edx
; mov [filesize],edx
; mov eax,58
; mov ebx,file_info_write
; mcall
; popa
; ret
mov [ebx+12], ecx
mov [ebx+16], edx
push ebx
mov eax, SF_FILE
mcall
xchg eax, [esp]
add [eax+4], ebx
adc [eax+8], dword 0
mov ebx, eax
pop eax
mov byte [ebx], 3
cmp eax, 1
cmc
ret
make_fullpaths:
pusha
push edx
mov esi,path ; open
; DEBUGF " '%s'",esi
mov edi,fullpath_open
cld
newc1:
movsb
cmp byte[esi],0;' '
jne newc1
mov esi,[esp]
cmp byte[esi],'/'
jne @f
mov edi,fullpath_open
@@:
lodsb
stosb
cmp al,0
jne @b
; mov ecx,12
; cld
; rep movsb
; mov byte[edi],0
mov esi,path ; write
mov edi,fullpath_write
cld
newc2:
movsb
cmp byte[esi],0;' '
jne newc2
mov esi,[esp]
cmp byte[esi],'/'
jne @f
mov edi,fullpath_write
@@:
lodsb
stosb
cmp al,0
jne @b
; mov ecx,12
; cld
; rep movsb
; mov byte[edi],0
mov esi,path ; start
mov edi,file_io_start.path
cld
newc3:
movsb
cmp byte[esi],0;' '
jne newc3
; mov esi,[esp]
pop esi
cmp byte[esi],'/'
jne @f
mov edi,file_io_start.path
@@:
lodsb
stosb
cmp al,0
jne @b
; mov ecx,12
; cld
; rep movsb
; mov byte[edi],0
; add esp,4
popa
ret
lseek:
cmp al,0
jnz @f
and dword [ebx+4], 0
and dword [ebx+8], 0
@@: cmp al,2
jnz @f
mov eax, [ebx-4]
mov [ebx+4], eax
and dword [ebx+8], 0
@@: add dword [ebx+4], edx
adc dword [ebx+8], 0
ret
display_character:
pusha
cmp [_mode],NORMAL_MODE
jne @f
cmp dl,13
jz dc2
cmp dl,0xa
jnz dc1
and [textxy],0x0000FFFF
add [textxy], 8 shl 16 and 0xFFFF0000 + 18
dc2:
popa
ret
dc1:
mov eax,[textxy]
cmp ax,word[bottom_right]
ja dc2
shr eax,16
cmp ax,word[bottom_right+2]
ja dc2
mov [dc],dl
mcall SF_DRAW_TEXT,[textxy],0x10000000,dc,1
add [textxy],0x00080000
popa
ret
@@:
mov eax,SF_BOARD
mov ebx,1
mov cl,dl
mcall
popa
ret
display_string:
pusha
@@:
cmp byte[esi],0
je @f
mov dl,[esi]
call display_character
add esi,1
jmp @b
@@:
popa
ret
display_number:
push ebx
mov ecx,1000000000
xor edx,edx
xor bl,bl
display_loop:
div ecx
push edx
cmp ecx,1
je display_digit
or bl,bl
jnz display_digit
or al,al
jz digit_ok
not bl
display_digit:
mov dl,al
add dl,30h
push ebx ecx
call display_character
pop ecx ebx
digit_ok:
mov eax,ecx
xor edx,edx
mov ecx,10
div ecx
mov ecx,eax
pop eax
or ecx,ecx
jnz display_loop
pop ebx
ret
display_user_messages:
; push [skinh]
; pop [textxy]
; add [textxy], 7 shl 16 +53
mov [displayed_count],0
call show_display_buffer
cmp [displayed_count],1
jb line_break_ok
je make_line_break
mov ax,word[last_displayed]
cmp ax,0A0Dh
je line_break_ok
cmp ax,0D0Ah
je line_break_ok
make_line_break:
mov esi,crlf
call display_string
line_break_ok:
ret
display_block:
pusha
@@: mov dl,[esi]
call display_character
inc esi
loop @b
popa
ret
fatal_error:
mov esi,error_prefix
call display_string
pop esi
call display_string
mov esi,error_suffix
call display_string
mov esi,crlf
call display_string
mov al,0FFh
jmp exit_program
assembler_error:
call display_user_messages
push dword 0
mov ebx,[current_line]
get_error_lines:
push ebx
test byte [ebx+7],80h
jz display_error_line
mov edx,ebx
find_definition_origin:
mov edx,[edx+12]
test byte [edx+7],80h
jnz find_definition_origin
push edx
mov ebx,[ebx+8]
jmp get_error_lines
display_error_line:
mov esi,[ebx]
call display_string
mov esi,line_number_start
call display_string
mov eax,[ebx+4]
and eax,7FFFFFFFh
call display_number
mov dl,']'
call display_character
pop esi
cmp ebx,esi
je line_number_ok
mov dl,20h
call display_character
push esi
mov esi,[esi]
movzx ecx,byte [esi]
inc esi
call display_block
mov esi,line_number_start
call display_string
pop esi
mov eax,[esi+4]
and eax,7FFFFFFFh
call display_number
mov dl,']'
call display_character
line_number_ok:
mov esi,line_data_start
call display_string
mov esi,ebx
mov edx,[esi]
call open
mov al,2
xor edx,edx
call lseek
mov edx,[esi+8]
sub eax,edx
push eax
xor al,al
call lseek
mov ecx,[esp]
mov edx,[additional_memory]
lea eax,[edx+ecx]
cmp eax,[additional_memory_end]
ja out_of_memory
call read
call close
pop ecx
mov esi,[additional_memory]
get_line_data:
mov al,[esi]
cmp al,0Ah
je display_line_data
cmp al,0Dh
je display_line_data
cmp al,1Ah
je display_line_data
or al,al
jz display_line_data
inc esi
loop get_line_data
display_line_data:
mov ecx,esi
mov esi,[additional_memory]
sub ecx,esi
call display_block
mov esi,crlf
call display_string
pop ebx
or ebx,ebx
jnz display_error_line
mov esi,error_prefix
call display_string
pop esi
call display_string
mov esi,error_suffix
call display_string
jmp exit_program

View File

@ -0,0 +1,31 @@
include 'lang.inc'
match =en,lang {
text db ' InFile:','OutFile:',' Path:'
.line_size = ($-text)/3
s_compile db 'COMPILE'
s_run db ' RUN '
s_debug db ' DEBUG '
s_dbgdescr db 'Generate debug information',0
}
match =ru,lang {
text db ' ‚å” ©«:','‚ëå” ©«:',' <20>ãâì:'
.line_size = ($-text)/3
s_compile db 'Š®¬¯¨«.'
s_run db ' <20>ã᪠'
s_debug db 'Žâ« ¤ª '
s_dbgdescr db '‘®§¤ ¢ âì ®â« ¤®ç­ãî ¨­ä®à¬ æ¨î',0
}
sz_EPnotFound db 'Not found entry point to ',0
sizeof.sz_EPnotFound = $-sz_EPnotFound
sz_cantLL db 'Can not load library ',0
sizeof.sz_cantLL = $-sz_cantLL
sz_system_error db 'System error: ',0
sizeof.sz_system_error = $-sz_system_error