Changed structure of svn repository

git-svn-id: svn://kolibrios.org@109 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
heavyiron
2006-07-28 13:39:16 +00:00
parent 5aa9386dcc
commit 630234432f
673 changed files with 20707 additions and 28013 deletions
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+4
View File
@@ -0,0 +1,4 @@
@erase lang.inc
@echo lang fix en >lang.inc
@fasm fasm.asm fasm
@pause
+4
View File
@@ -0,0 +1,4 @@
@erase lang.inc
@echo lang fix ru >lang.inc
@fasm fasm.asm fasm
@pause
+131
View File
@@ -0,0 +1,131 @@
; flat assembler core
; Copyright (c) 1999-2006, Tomasz Grysztar.
; All rights reserved.
out_of_memory:
call fatal_error
db 'out of memory',0
stack_overflow:
call fatal_error
db 'out of stack space',0
main_file_not_found:
call fatal_error
db 'source file not found',0
unexpected_end_of_file:
call fatal_error
db 'unexpected end of file',0
code_cannot_be_generated:
call fatal_error
db 'code cannot be generated',0
format_limitations_exceeded:
call fatal_error
db 'format limitations exceeded',0
write_failed:
call fatal_error
db 'write failed',0
file_not_found:
call assembler_error
db 'file not found',0
error_reading_file:
call assembler_error
db 'error reading file',0
invalid_file_format:
call assembler_error
db 'invalid file format',0
invalid_macro_arguments:
call assembler_error
db 'invalid macro arguments',0
incomplete_macro:
call assembler_error
db 'incomplete macro',0
unexpected_characters:
call assembler_error
db 'unexpected characters',0
invalid_argument:
call assembler_error
db 'invalid argument',0
illegal_instruction:
call assembler_error
db 'illegal instruction',0
invalid_operand:
call assembler_error
db 'invalid operand',0
invalid_operand_size:
call assembler_error
db 'invalid size of operand',0
operand_size_not_specified:
call assembler_error
db 'operand size not specified',0
operand_sizes_do_not_match:
call assembler_error
db 'operand sizes do not match',0
invalid_address_size:
call assembler_error
db 'invalid size of address value',0
address_sizes_do_not_agree:
call assembler_error
db 'address sizes do not agree',0
prefix_conflict:
call assembler_error
db 'disallowed combination of registers',0
long_immediate_not_encodable:
call assembler_error
db 'not encodable with long immediate',0
relative_jump_out_of_range:
call assembler_error
db 'relative jump out of range',0
invalid_expression:
call assembler_error
db 'invalid expression',0
invalid_address:
call assembler_error
db 'invalid address',0
invalid_value:
call assembler_error
db 'invalid value',0
value_out_of_range:
call assembler_error
db 'value out of range',0
undefined_symbol:
call assembler_error
db 'undefined symbol',0
invalid_use_of_symbol:
call assembler_error
db 'invalid use of symbol',0
name_too_long:
call assembler_error
db 'name too long',0
invalid_name:
call assembler_error
db 'invalid name',0
reserved_word_used_as_symbol:
call assembler_error
db 'reserved word used as symbol',0
symbol_already_defined:
call assembler_error
db 'symbol already defined',0
missing_end_quote:
call assembler_error
db 'missing end quote',0
missing_end_directive:
call assembler_error
db 'missing end directive',0
unexpected_instruction:
call assembler_error
db 'unexpected instruction',0
extra_characters_on_line:
call assembler_error
db 'extra characters on line',0
section_not_aligned_enough:
call assembler_error
db 'section is not aligned enough',0
setting_already_specified:
call assembler_error
db 'setting already specified',0
data_already_defined:
call assembler_error
db 'data already defined',0
too_many_repeats:
call assembler_error
db 'too many repeats',0
File diff suppressed because it is too large Load Diff
+551
View File
@@ -0,0 +1,551 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; flat assembler source ;;
;; Copyright (c) 1999-2006, Tomasz Grysztar ;;
;; All rights reserved. ;;
;; ;;
;; Menuet port by VT ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
NORMAL_MODE = 8
CONSOLE_MODE = 32
MAGIC1 = 6*(text.line_size-1)+6*2+2
MAGIC2 = 14
MAGIC3 = 1
MAGIC4 = 7
OUTPUTXY = (5+MAGIC4) shl 16 + MAGIC2*3+MAGIC3+MAGIC4+1+2
MAX_PATH = 100
APP_MEMORY = 0x00800000
;; Menuet header
use32
org 0x0
db 'MENUET01' ; 8 byte id
dd 0x01 ; header version
dd START ; program start
dd program_end ; program image size
dd APP_MEMORY ; required amount of memory
dd 0xDFFF0 ; stack
dd params,0x0 ; parameters,icon
include 'lang.inc'
include 'fasm.inc'
center fix true
START: ; Start of execution
cmp [params],0
jz noparams
mov ecx,10
mov al,' '
mov edi,infile
push ecx
cld
rep stosd
mov ecx,[esp]
mov edi,outfile
rep stosd
pop ecx
mov edi,path
rep stosd
mov esi,params
; DEBUGF "params: %s\n",esi
mov edi,infile
call mov_param_str
; mov edi,infile
; DEBUGF " input: %s\n",edi
inc esi
mov edi,outfile
call mov_param_str
; mov edi,outfile
; DEBUGF "output: %s\n",edi
inc esi
mov edi,path
call mov_param_str
; mov edi,path
; DEBUGF " path: %s\n",edi
cmp [esi], dword ',run'
jne @f
mov [_run_outfile],1
@@:
mov [_mode],CONSOLE_MODE
jmp start
noparams:
call draw_window
still:
mcall 10 ; Wait here for event
dec eax ; Redraw request
jz red
dec eax ; Key in buffer
jz key
dec eax ; Button in buffer
jz button
jmp still
red: ; Redraw
call draw_window
jmp still
key: ; Key
mcall 2 ; Read it and ignore
jmp still
button: ; Button in Window
mcall 17
cmp ah,2 ; Start compiling
je start
cmp ah,3 ; Start compiled file
jnz norunout
mov edx,outfile
call make_fullpaths
mcall 58,file_info_start
; xor ecx,ecx
jmp still
norunout:
mov ecx,[skinh]
add ecx,MAGIC3+MAGIC2/2-3
mov [ya],ecx
cmp ah,11 ; Infile
je f1
cmp ah,12 ; Outfile
je f2
cmp ah,13 ; Path
je f3
dec ah ; Close application
jnz still
mcall -1
skinh dd ?
draw_window:
pusha
mcall 12,1 ; Start of draw
get_sys_colors 1,0
mcall 0,<50,280>,<50,250>,[sc.work] ; Draw Window
draw_caption header,header.size ; Draw Window Label Text
mov ecx,[skinh-2]
mov cx,word[skinh]
madd ecx,MAGIC3,MAGIC3
mov ebx,[pinfo.x_size]
madd ebx,5,-5
push ecx
madd ecx,MAGIC2*3+2,MAGIC2*3+2
mcall 38,,,[sc.work_graph]
pop ecx
sub ebx,MAGIC1+3
mcall
madd ecx,MAGIC2,MAGIC2
mcall
madd ecx,MAGIC2,MAGIC2
mcall
madd ecx,MAGIC2,MAGIC2
mcall
push ebx
mpack ebx,MAGIC1+5,MAGIC1+5
sub cx,MAGIC2*3
mcall
mov ebx,[esp-2]
pop bx
mcall
add esp,2
mpack ebx,5,MAGIC1-1
mpack ecx,[skinh],MAGIC2-2
madd ecx,MAGIC3+1,0
mcall 8,,,0x4000000B ; Button: Enter Infile
madd ecx,MAGIC2,0
mcall ,,,0x4000000C ; Button: Enter Outfile
madd ecx,MAGIC2,0
mcall ,,,0x4000000D ; Button: Enter Path
mpack ebx,[pinfo.x_size],MAGIC1
msub ebx,MAGIC1+5+1,0
mpack ecx,[skinh],MAGIC2*3/2-1
madd ecx,MAGIC3,0
mcall ,,,0x00000002,[sc.work_button]
madd ecx,MAGIC2*3/2+1,0
mcall ,,,0x00000003
mpack ebx,5+6,[skinh] ; Draw Window Text
add bx,MAGIC3+MAGIC2/2-3
mov ecx,[sc.work_text]
mov edx,text
mov esi,text.line_size
mov eax,4
newline:
mcall
add ebx,MAGIC2
add edx,text.line_size
cmp byte[edx],'x'
jne newline
mov ebx,[pinfo.x_size]
sub ebx,MAGIC1+5+1-9
shl ebx,16
mov bx,word[skinh]
add bx,MAGIC3+(MAGIC2*3/2-1)/2-3
mcall ,,[sc.work_button_text],s_compile,7
add ebx,MAGIC2*3/2+1
mcall ,,,s_run
mpack ebx,MAGIC1+5+6,[skinh]
add ebx,MAGIC3+MAGIC2/2-3+MAGIC2*0
mov esi,[pinfo.x_size]
sub esi,MAGIC1*2+5*2+6+3
mov eax,esi
mov cl,6
div cl
cmp al,MAX_PATH
jbe @f
mov al,MAX_PATH
@@: movzx esi,al
mcall 4,,[sc.work_text],infile
add ebx,MAGIC2
mcall ,,,outfile
add ebx,MAGIC2
mcall ,,,path
call draw_messages
mcall 12,2 ; End of Draw
popa
ret
bottom_right dd ?
draw_messages:
mov eax,13 ; clear work area
mpack ebx,5+MAGIC4-2,[pinfo.x_size]
sub ebx,5*2+MAGIC4*2-1-2*2
mpack ecx,[skinh],[pinfo.y_size]
madd ecx,MAGIC2*3+MAGIC3+MAGIC4+1,-(MAGIC2*3+MAGIC3+MAGIC4*2+5)+2
mov word[bottom_right+2],bx
mov word[bottom_right],cx
msub [bottom_right],7,11
add [bottom_right],OUTPUTXY
sub ecx,[skinh]
mov edx,[sc.work]
int 0x40
_cy = 0
_sy = 2
_cx = 4
_sx = 6
push ebx ecx
mpack ebx,5+MAGIC4-3,5+MAGIC4-2
add bx,[esp+_cx]
mov ecx,[esp+_sy-2]
mov cx,[esp+_sy]
msub ecx,1,1
mcall 38,,,[sc.work_graph]
mov si,[esp+_cy]
add cx,si
shl esi,16
add ecx,esi
madd ecx,1,1
mcall
mpack ebx,5+MAGIC4-3,5+MAGIC4-3
mov esi,[esp+_sy-2]
mov si,cx
mov ecx,esi
mcall
mov si,[esp+_cx]
add bx,si
shl esi,16
add ebx,esi
madd ebx,1,1
mcall
pop ecx ebx
ret
; read string
f1: mov [addr],infile
add [ya],MAGIC2*0
jmp rk
f2: mov [addr],outfile
add [ya],MAGIC2*1
jmp rk
f3: mov [addr],path
add [ya],MAGIC2*2
rk:
mov edi,[addr]
mov al,0
mov ecx,MAX_PATH
add edi,ecx
dec edi
std
repe scasb
sub ecx,MAX_PATH
neg ecx
mov al,$1C ; ''
add edi,2
push edi
cld
rep stosb
call print_text
pop edi
f11:mcall 10
cmp eax,2
jne read_done
mcall; 2
shr eax,8
cmp al,13
je read_done
cmp al,8
jne nobs
cmp edi,[addr]
je f11
sub edi,1
mov byte[edi],$1C ; '_'
call print_text
jmp f11
nobs:
movzx ebx,al
sub ebx,$20
jle f11
sub al,[sub_table+ebx]
keyok:
mov ecx,[addr]
add ecx,MAX_PATH
cmp edi,ecx
jae f11
mov [edi],al
call print_text
inc edi
jmp f11
read_done:
mov ecx,[addr]
add ecx,MAX_PATH
sub ecx,edi
mov al,0;' '
cld
rep stosb
call print_text
jmp still
print_text:
mpack ebx,MAGIC1+5+6,[pinfo.x_size]
sub ebx,MAGIC1*2+5*2+6+3
movzx esi,bx
mov ecx,[ya-2]
mov cx,8
mcall 13,,,[sc.work]
mpack ebx,MAGIC1+5+6,[ya]
mov eax,esi
mov cl,6
div cl
cmp al,MAX_PATH
jbe @f
mov al,MAX_PATH
@@: movzx esi,al
mcall 4,,[sc.work_text],[addr]
ret
; DATA
sz header,'FASM FOR MENUET'
text:
db ' INFILE:'
.line_size = $-text
db 'OUTFILE:'
db ' PATH:'
db 'x'
s_compile db 'COMPILE'
s_run db ' RUN '
infile db 'EXAMPLE.ASM'
times MAX_PATH+$-infile db 0
outfile db 'EXAMPLE'
times MAX_PATH+$-outfile db 0
path db '/RD/1/'
times MAX_PATH+$-path db 0
lf db 13,10,0
addr dd 0x0
ya dd 0x0
zero db 0x0
mov_param_str:
@@:
mov al,[esi]
cmp al,','
je @f
cmp al,0
je @f
mov [edi],al
inc esi
inc edi
jmp @b
@@:
mov al,0
stosb
ret
start:
cmp [_mode],NORMAL_MODE
jne @f
call draw_messages
push [skinh]
pop [textxy]
add [textxy],OUTPUTXY
@@:
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
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
mov eax,58
mov ebx,file_info_start
xor ecx,ecx
int 0x40
@@:
jmp exit_program
include 'system.inc'
include 'version.inc'
include 'errors.inc'
include 'expressi.inc'
include 'preproce.inc'
include 'parser.inc'
include 'assemble.inc'
include 'formats.inc'
include 'x86_64.inc'
include 'tables.inc'
_logo db 'flat assembler version ',VERSION_STRING,13,10,0
_passes_suffix db ' passes, ',0
_seconds_suffix db ' seconds, ',0
_bytes_suffix db ' bytes.',13,10,0
_include db 'INCLUDE',0
_counter db 4,'0000'
_mode dd NORMAL_MODE
_run_outfile 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
;include_debug_strings
params db 0 ; 'TINYPAD.ASM,TINYPAD,/HD/1/TPAD4/',
program_end:
rb 1000h
align 4
include 'variable.inc'
program_base dd ?
buffer_address dd ?
memory_setting dd ?
start_time dd ?
sc system_colors
pinfo process_information
+147
View File
@@ -0,0 +1,147 @@
center fix false
SYSTEMCOLORS fix sc
PROCESSINFO fix pinfo
macro get_sys_colors wnd_skin,font_1 {
mcall 48,3,SYSTEMCOLORS,sizeof.system_colors
if wnd_skin <> 0
or [SYSTEMCOLORS+system_colors.work],0x03000000
end if
if font_1 <> 0
or [SYSTEMCOLORS+system_colors.grab_text],0x10000000
end if
}
macro draw_caption _edx,_esi {
mov edx,_edx
mov esi,_esi
call __draw_caption
}
macro mpack dest, hsrc, lsrc
{
if (hsrc eqtype 0) & (lsrc eqtype 0)
mov dest, (hsrc) shl 16 + lsrc
else
if (hsrc eqtype 0) & (~lsrc eqtype 0)
mov dest, (hsrc) shl 16
add dest, lsrc
else
mov dest, hsrc
shl dest, 16
add dest, lsrc
end if
end if
}
macro __mov reg,a,b {
if (~a eq)&(~b eq)
mpack reg,a,b
else if (~a eq)&(b eq)
mov reg,a
end if
}
macro mcall a,b,c,d,e,f {
__mov eax,a
__mov ebx,b
__mov ecx,c
__mov edx,d
__mov esi,e
__mov edi,f
int 0x40
}
macro sz name,[data] {
if used name
common
label name
forward
db data
common
.size = $-name
end if
}
macro lsz name,[lng,data] {
if used name
common
label name
forward
if lang eq lng
db data
end if
common
.size = $-name
end if
}
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)
}
macro jmpe reg,def,[val,lab] {
forward
cmp reg,val
je lab
common
if ~def eq
jmp def
end if
}
macro func name {
if used name
name:
}
macro endf {
end if
}
@^ fix macro comment {
^@ fix }
; structure definition helper
;include '%fasminc%struct.inc'
include 'struct.inc'
; structures used in MeOS
struct process_information
cpu_usage dd ? ; +0
window_stack_position dw ? ; +4
window_stack_value dw ? ; +6
not_used1 dw ? ; +8
process_name db 12 dup(?) ; +10
memory_start dd ? ; +22
used_memory dd ? ; +26
PID dd ? ; +30
x_start dd ? ; +34
y_start dd ? ; +38
x_size dd ? ; +42
y_size dd ? ; +46
slot_state dw ? ; +50
not_used2 db 1024-52 dup(?)
ends
struct system_colors
frame dd ?
grab dd ?
grab_button dd ?
grab_button_text dd ?
grab_text dd ?
work dd ?
work_button dd ?
work_button_text dd ?
work_text dd ?
work_graph dd ?
ends
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
+180
View File
@@ -0,0 +1,180 @@
; Macroinstructions for defining data structures
macro struct name
{ fields@struct equ name
match child parent, name \{ fields@struct equ child,fields@\#parent \}
sub@struct equ
struc db [val] \{ \common fields@struct equ fields@struct,.,db,<val> \}
struc dw [val] \{ \common fields@struct equ fields@struct,.,dw,<val> \}
struc du [val] \{ \common fields@struct equ fields@struct,.,du,<val> \}
struc dd [val] \{ \common fields@struct equ fields@struct,.,dd,<val> \}
struc dp [val] \{ \common fields@struct equ fields@struct,.,dp,<val> \}
struc dq [val] \{ \common fields@struct equ fields@struct,.,dq,<val> \}
struc dt [val] \{ \common fields@struct equ fields@struct,.,dt,<val> \}
struc rb count \{ fields@struct equ fields@struct,.,db,count dup (?) \}
struc rw count \{ fields@struct equ fields@struct,.,dw,count dup (?) \}
struc rd count \{ fields@struct equ fields@struct,.,dd,count dup (?) \}
struc rp count \{ fields@struct equ fields@struct,.,dp,count dup (?) \}
struc rq count \{ fields@struct equ fields@struct,.,dq,count dup (?) \}
struc rt count \{ fields@struct equ fields@struct,.,dt,count dup (?) \}
macro db [val] \{ \common \local anonymous
fields@struct equ fields@struct,anonymous,db,<val> \}
macro dw [val] \{ \common \local anonymous
fields@struct equ fields@struct,anonymous,dw,<val> \}
macro du [val] \{ \common \local anonymous
fields@struct equ fields@struct,anonymous,du,<val> \}
macro dd [val] \{ \common \local anonymous
fields@struct equ fields@struct,anonymous,dd,<val> \}
macro dp [val] \{ \common \local anonymous
fields@struct equ fields@struct,anonymous,dp,<val> \}
macro dq [val] \{ \common \local anonymous
fields@struct equ fields@struct,anonymous,dq,<val> \}
macro dt [val] \{ \common \local anonymous
fields@struct equ fields@struct,anonymous,dt,<val> \}
macro rb count \{ \local anonymous
fields@struct equ fields@struct,anonymous,db,count dup (?) \}
macro rw count \{ \local anonymous
fields@struct equ fields@struct,anonymous,dw,count dup (?) \}
macro rd count \{ \local anonymous
fields@struct equ fields@struct,anonymous,dd,count dup (?) \}
macro rp count \{ \local anonymous
fields@struct equ fields@struct,anonymous,dp,count dup (?) \}
macro rq count \{ \local anonymous
fields@struct equ fields@struct,anonymous,dq,count dup (?) \}
macro rt count \{ \local anonymous
fields@struct equ fields@struct,anonymous,dt,count dup (?) \}
macro union \{ fields@struct equ fields@struct,,union,<
sub@struct equ union \}
macro struct \{ fields@struct equ fields@struct,,substruct,<
sub@struct equ substruct \}
virtual at 0 }
macro ends
{ match , sub@struct \{ restruc db,dw,du,dd,dp,dq,dt
restruc rb,rw,rd,rp,rq,rt
purge db,dw,du,dd,dp,dq,dt
purge rb,rw,rd,rp,rq,rt
purge union,struct
match name=,fields,fields@struct \\{ fields@struct equ
make@struct name,fields
fields@\\#name equ fields \\}
end virtual \}
match any, sub@struct \{ fields@struct equ fields@struct> \}
restore sub@struct }
macro make@struct name,[field,type,def]
{ common
if $
display 'Error: definition of ',`name,' contains illegal instructions.',0Dh,0Ah
err
end if
local define
define equ name
forward
local sub
match , field \{ make@substruct type,name,sub def
define equ define,.,sub, \}
match any, field \{ define equ define,.#field,type,<def> \}
common
match fields, define \{ define@struct fields \} }
macro define@struct name,[field,type,def]
{ common
local list
list equ
forward
if ~ field eq .
name#field type def
sizeof.#name#field = $ - name#field
else
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 \\{
match any, fields@struct \\\{ fields@struct equ fields@struct,.,name,<values> \\\}
match , fields@struct \\\{ label .
forward
match , value \\\\{ field type def \\\\}
match any, value \\\\{ field type value
if ~ field eq .
rb sizeof.#name#field - ($-field)
end if \\\\}
common \\\} \\} \} }
macro enable@substruct
{ macro make@substruct substruct,parent,name,[field,type,def]
\{ \common
\local define
define equ parent,name
\forward
\local sub
match , field \\{ match any, type \\\{ enable@substruct
make@substruct type,name,sub def
purge make@substruct
define equ define,.,sub, \\\} \\}
match any, field \\{ define equ define,.\#field,type,<def> \\}
\common
match fields, define \\{ define@\#substruct fields \\} \} }
enable@substruct
macro define@union parent,name,[field,type,def]
{ common
virtual at 0
forward
if ~ field eq .
virtual at 0
parent#field type def
sizeof.#parent#field = $ - parent#field
end virtual
if sizeof.#parent#field > $
rb sizeof.#parent#field - $
end if
else if sizeof.#type > $
rb sizeof.#type - $
end if
common
sizeof.#name = $
end virtual
struc name [value] \{ \common
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 define@substruct parent,name,[field,type,def]
{ common
virtual at 0
forward
if ~ field eq .
parent#field type def
sizeof.#parent#field = $ - parent#field
else
rb sizeof.#type
end if
local value
common
sizeof.#name = $
end virtual
struc name value \{
label .\#name
forward
match , value \\{ field type def \\}
match any, value \\{ field type value
if ~ field eq .
rb sizeof.#parent#field - ($-field)
end if \\}
common \} }
+462
View File
@@ -0,0 +1,462 @@
; flat assembler version 1.60
; Copyright (c) 1999-2005, Tomasz Grysztar
; All rights reserved.
;
; MenuetOS system.inc by VT
file_info_open: dd 0,0,0xffffff,0x20000,0xf0000
fullpath_open:; db '/HD/1/EXAMPLE.ASM'
times MAX_PATH db 0
file_info_write: dd 1,0,0,0,0xf0000
fullpath_write:; db '/HD/1/EXAMPLE'
times MAX_PATH db 0
file_info_start: dd 16,0,0,0,0xf0000
fullpath_start:; db '/HD/1/EXAMPLE'
times MAX_PATH db 0
_ramdisk db '/RD/1/'
filepos dd 0x0
; info by Privalov: starting from FASM 1.51
; ~3/8 - additional memory
; ~5/8 - main memory
init_memory:
mov [memory_start],0x100000
mov [memory_end],0x100000+(APP_MEMORY-0x100000)/8*5
mov [additional_memory],0x100000+(APP_MEMORY-0x100000)/8*5
mov [additional_memory_end],APP_MEMORY
ret
exit_program:
cmp [_mode],NORMAL_MODE
je still
or eax,-1
int 0x40
make_timestamp:
push ebx
mcall 26,9
imul eax,10
pop ebx
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
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
create:
call make_fullpaths
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
int 0x40
popa
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,fullpath_start
cld
newc3:
movsb
cmp byte[esi],0;' '
jne newc3
; mov esi,[esp]
pop esi
cmp byte[esi],'/'
jne @f
mov edi,fullpath_start
@@:
lodsb
stosb
cmp al,0
jne @b
; mov ecx,12
; cld
; rep movsb
; mov byte[edi],0
; add esp,4
popa
ret
read:
pusha
mov edi,edx
mov esi,[filepos]
add esi,0x20000
cld
rep movsb
popa
; ret
close: ret
lseek:
cmp al,0
jnz @f
mov [filepos],0
@@: cmp al,1
jnz @f
@@: cmp al,2
jnz @f
mov eax,[filesize]
mov [filepos],eax
@@: mov eax,[filepos]
add eax,edx
mov [filepos],eax
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],OUTPUTXY and 0xFFFF0000 + 10
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 4,[textxy],[sc.work_text],dc,1
add [textxy],0x00060000
popa
ret
@@: mov eax,63
mov ebx,1
mov cl,dl
int 0x40
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],OUTPUTXY
mov [displayed_count],0
call flush_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,lf
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,lf
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,cr_lf
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
__draw_caption:
; mcall 48,4
; mov [skinh],eax
; mov ebx,eax
; shr ebx,1
; adc ebx,1+0x000A0000-4
; mcall 4,,[sc.grab_text],s_title,[s_title.size]
mcall 48,4
mov [skinh],eax
shr eax,1
adc eax,0
add eax,1-4
push ax
if center eq true
mcall 9,PROCESSINFO,-1
mov ebx,[PROCESSINFO+process_information.x_size]
shr ebx,1
sub ebx,header.size*6/2 + 8
else
mov ebx,8
end if
shl ebx,16
pop bx
mcall 4,,[SYSTEMCOLORS+system_colors.grab_text]
ret
character db ?,0
bytes_count dd ?
textxy dd 0x000500A0
dc db 0x0
filesize dd 0x0
displayed_count dd ?
last_displayed rb 2
error_prefix db 'error: ',0
error_suffix db '.',0
line_data_start db ':'
cr_lf db 0Dh,0Ah,0
line_number_start db ' [',0
macro dm string { db string,0 }
+119
View File
@@ -0,0 +1,119 @@
; flat assembler core variables
; Copyright (c) 1999-2006, 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 ?
input_file dd ?
output_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 ?
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 ?
org_origin dq ?
org_registers dd ?
org_start dd ?
org_symbol dd ?
undefined_data_start dd ?
undefined_data_end dd ?
counter dd ?
counter_limit dd ?
error_line dd ?
error dd ?
display_buffer 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 ?
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 ?
resource_data dd ?
resource_size dd ?
parenthesis_stack dd ?
blocks_stack dd ?
next_pass_needed db ?
macro_status db ?
output_format db ?
code_type db ?
labels_type db ?
prefixed_instruction db ?
virtual_data db ?
fp_sign db ?
fp_format db ?
value_size db ?
size_override db ?
address_size db ?
operand_size db ?
size_declared db ?
value_undefined db ?
value_type db ?
compare_type db ?
base_code db ?
extended_code db ?
postbyte_register db ?
segment_register db ?
mmx_size db ?
jump_type db ?
push_size db ?
operand_prefix db ?
rex_prefix db ?
immediate_size db ?
characters rb 100h
converted rb 100h
+39
View File
@@ -0,0 +1,39 @@
; flat assembler version 1.67
; Copyright (c) 1999-2006, 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.67.5"
VERSION_MAJOR = 1
VERSION_MINOR = 67
File diff suppressed because it is too large Load Diff