Added SDK for FASM and some assembler examples.

git-svn-id: svn://kolibrios.org@1180 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
andrew_programmer 2009-09-26 21:40:38 +00:00
parent 4af4fa5809
commit 456168f5b2
15 changed files with 1752 additions and 0 deletions

View File

@ -0,0 +1,115 @@
;Hello world example
use32
db 'MENUET01'
dd 1
dd start
dd i_end
dd 0x1500
dd 0x1500
dd 0
dd 0
TRUE = 1
FALSE = 0
include 'libGUI.inc'
start:
;load libGUI labrari
push NULL ;use default system path to library
call LoadLibGUI
;create main window
CreateWindow
mov [window],eax
;change size of main window
SetWindowSizeRequest [window],90,60
;set callback function for button close window
SetCallbackFunction [window],DELETE_EVENT,callback_func_delete_window,NULL
;create control Button with text
mov [bdata.x],5
mov [bdata.y],5
mov [bdata.wight],70
mov [bdata.height],20
CreateButtonWithText bdata,btext
mov [button],eax
;set callback functions for button
SetCallbackFunction [button],BUTTON_ENTER_EVENT,callback_func1,NULL
SetCallbackFunction [button],BUTTON_PRESSED_EVENT,callback_func2,NULL
SetCallbackFunction [button],BUTTON_RELEASED_EVENT,callback_func3,NULL
SetCallbackFunction [button],BUTTON_LEAVE_EVENT,callback_func4,NULL
;pack control Text in window
PackControls [window],[button]
;start libGUI main loop
LibGUImain [window]
;void callback_func_delete_window(header_t *control,void *data)
callback_func_delete_window:
mov eax,[esp+4] ;control
QuitLibGUI eax
ret
;void callback_func1(header_t *control,void *data)
callback_func1:
;save esi befor use
push esi
mov esi,btext1
call gui_ksys_debug_out_str
pop esi
ret
;void callback_func2(header_t *control,void *data)
callback_func2:
;save esi befor use
push esi
mov esi,btext2
call gui_ksys_debug_out_str
pop esi
ret
;void callback_func3(header_t *control,void *data)
callback_func3:
;save esi befor use
push esi
mov esi,btext3
call gui_ksys_debug_out_str
pop esi
ret
;void callback_func4(header_t *control,void *data)
callback_func4:
;save esi befor use
push esi
mov esi,btext4
call gui_ksys_debug_out_str
pop esi
ret
align 4
;----------------------data--------------------
btext db 'Click Me!',0
btext1 db 13,10,'entry in button',0
btext2 db 13,10,'button pressed',0
btext3 db 13,10,'button released',0
btext4 db 13,10,'leave button',0
bdata gui_button_data_t
window rd 1;parent_t *window
button rd 1;gui_button_t *button
i_end:

View File

@ -0,0 +1,92 @@
;Hello world example
use32
db 'MENUET01'
dd 1
dd start
dd i_end
dd 0x1000
dd 0x1000
dd 0
dd 0
TRUE = 1
FALSE = 0
include 'libGUI.inc'
start:
;load libGUI labrari
push NULL ;use default system path to library
call LoadLibGUI
;create main window
CreateWindow
mov [window],eax
;change size of main window
SetWindowSizeRequest [window],220,142
;set callback function for button close window
SetCallbackFunction [window],DELETE_EVENT,callback_func_delete_window,NULL
;create control Image
mov [imgdata.x],5
mov [imgdata.y],5
mov [imgdata.wight],200
mov [imgdata.height],100
mov [imgdata.bits_per_pixel],32
CreateImage imgdata
mov [image],eax
;copy data from pointer to local variable
;for access to filds of structure
mov ecx,[image]
mov eax,[ecx+HEADER_SIZE+2] ;pointer to picture
xor ecx,ecx
for_size_y:
xor edx,edx
for_size_x:
;generate color
mov ebx,edx ;i
mov esi,ecx ;j
imul ebx,ebx ;i*i
imul esi,esi ;j*j
add ebx,esi ;i*i+j*J
mov esi,edx ;i
lea esi,[esi+2*esi] ;i*3
sub ebx,esi ;i*i+j*j-i*3
mov esi,ecx ;j
shl esi,1 ;j*2
add ebx,esi ;i*i+j*j-i*3+2*j
imul ebx,100 ;100*(i*i+j*j-i*3+2*j)
mov [eax],ebx
add eax,4
inc edx
cmp edx,200
jl for_size_x
inc ecx
cmp ecx,100
jl for_size_y
;pack control Text in window
PackControls [window],[image]
;start libGUI main loop
LibGUImain [window]
;void callback_func_delete_window(header_t *control,void *data)
callback_func_delete_window:
mov eax,[esp+4] ;control
QuitLibGUI eax
ret
align 4
;----------------data-----------------
imgdata gui_image_data_t
window rd 1;parent_t *window
image rd 1
i_end:

View File

@ -0,0 +1,191 @@
;Hello world example
use32
db 'MENUET01'
dd 1
dd start
dd i_end
dd 0x1000
dd 0x1000
dd 0
dd 0
TRUE = 1
FALSE = 0
include 'libGUI.inc'
start:
;load libGUI labrari
push NULL ;use default system path to library
call LoadLibGUI
;create main window
CreateWindow
mov [window],eax
;change size of main window
SetWindowSizeRequest [window],320,57
;set callback function for button close window
SetCallbackFunction [window],DELETE_EVENT,callback_func_delete_window,NULL
;create control Text
mov [pbdata.x],5
mov [pbdata.y],5
mov [pbdata.wight],300;use default system libGUI font
mov [pbdata.height],25;use background for text
mov [pbdata.progress],dword 0.0
CreateProgressBar pbdata
mov [progress_bar],eax
;create timer for update progress level each 50 milliseconds
SetTimerCallbackForFunction [window],5,progress_bar_callback,[progress_bar]
;pack control Text in window
PackControls [window],[progress_bar]
;redraw progress bar automatically each 50 milleseconds
SetProgressBarPulse [progress_bar],5
;start libGUI main loop
LibGUImain [window]
;void progress_bar_callback(void *data)
progress_bar_callback:
mov eax,[esp+4];pointer to control progress bar
mov ecx,[eax+HEADER_SIZE];progress
mov [progress],ecx
mov [increment],dword 0.01
mov [digit],100
fld dword[increment]
fld dword[progress]
fadd st0,st1
fst dword [progress]
fild dword[digit]
fmul st0,st1
fistp dword[digit]
fstp st0 ;free progress
fstp st0 ;free increment
cmp [progress],dword 1.0
jl no_max_progress
mov [progress],dword 0.0
no_max_progress:
mov ecx,[progress]
mov [eax+HEADER_SIZE],ecx ;save new value of progress
;print progressvalue in string
push ebx ;save befor use
mov eax,txt
add eax,9
mov ebx,eax ;save eax
push eax
push [digit]
call dec_to_str
add ebx,eax
mov [ebx],byte '%'
mov [ebx+1],byte 0
pop ebx
;set text for progress bar
ProgressBarSetText [progress_bar],txt
ret
;void callback_func_delete_window(header_t *control,void *data)
callback_func_delete_window:
mov eax,[esp+4] ;control
QuitLibGUI eax
ret
;int dectostr(int digit,char *str)
dec_to_str:
mov eax,[esp+4];digit
mov ecx,[esp+8];string
push ebx esi edi ;save befor use
cmp eax,10
jl print_digit
mov ebx,eax ;save digit
mov edi,1
mov esi,10
next_i_div:
cdq ;extend to edx:eax
idiv esi ;eax=eax/esi
test eax,eax
jz no_mul_ten
imul edi,esi ;edi=edi*10
no_mul_ten:
mov eax,edx ;eax=eax % 10
cmp eax,esi
jae next_i_div
test eax,eax
jnz no_multyple_10
;print digit in string
mov [ecx],byte '1'
inc ecx
mov eax,ebx ;eax=digit
next_i_str_:
cdq ;extend to edx:eax
idiv edi ;eax=eax/edi
mov [ecx],byte '0'
inc ecx
mov eax,edx ;eax=eax % edi
cmp eax,10
jae next_i_str_
dec ecx
jmp exit_multyple
no_multyple_10:
;print digit in string
mov eax,ebx ;eax=digit
next_i_str:
cdq ;extend to edx:eax
idiv edi ;eax=eax/edi
add al,byte '0' ;al='0'+digit
mov [ecx],byte al
inc ecx
mov eax,edx ;eax=eax % edi
cmp eax,10
jae next_i_str
print_digit:
add al,byte '0'
mov [ecx],byte al
exit_multyple:
mov eax,ecx
pop edi esi ebx
sub eax,[esp+8] ;number of printed simbols
inc eax
ret 8
align 4
;----------------data-----------------
txt db 'PROGRESS ',0,0,0,0,0,0
pbdata gui_progress_bar_data_t
window rd 1
progress_bar rd 1
progress rd 1
increment rd 1
digit rd 1
i_end:

View File

@ -0,0 +1,111 @@
;Hello world example
use32
db 'MENUET01'
dd 1
dd start
dd i_end
dd 0x10000
dd 0x10000
dd 0
dd 0
TRUE = 1
FALSE = 0
include 'libGUI.inc'
start:
;load libGUI labrari
push NULL ;use default system path to library
call LoadLibGUI
;create main window
CreateWindow
mov [window],eax
;change size of main window
SetWindowSizeRequest [window],270,282
;set callback function for button close window
SetCallbackFunction [window],DELETE_EVENT,callback_func_delete_window,NULL
;create control HorizontalScrollBar
mov [swdata.x],5
mov [swdata.y],5
mov [swdata.wight],250
mov [swdata.height],250
CreateScrolledWindow swdata
mov [scrolled_window],eax
;create buttons
mov ecx,10
next_j:
mov edx,10
next_i:
mov esi,edx ;i
mov edi,ecx ;j
dec esi ;i-1
dec edi ;j-1
imul esi,75 ;(i-1)*75
imul edi,25 ;(j-1)*25
add esi,10 ;10+(i-1)*75
add edi,10 ;10+(j-1)*25
mov [bdata.x],esi
mov [bdata.y],edi
mov [bdata.wight],70
mov [bdata.height],20
push ecx edx esi edi;save registers befor call
CreateButtonWithText bdata,btxt
mov [button],eax
;set callback functions for scroll bars
SetCallbackFunction [button],BUTTON_PRESSED_EVENT,callback_func,NULL
;pack control Button in ScrolledWindow
ScrolledWindowPackControls [scrolled_window],[button]
pop edi esi edx ecx
dec edx
jnz next_i
dec ecx
jnz next_j
;pack scrolled window in window
PackControls [window],[scrolled_window]
;start libGUI main loop
LibGUImain [window]
;void callback_func(header_t *control,void *data)
callback_func:
mov eax,[esp+4];pointer to control
push esi;save befor use
mov esi,message
call gui_ksys_debug_out_str
pop esi
ret
;void callback_func_delete_window(header_t *control,void *data)
callback_func_delete_window:
mov eax,[esp+4] ;control
QuitLibGUI eax
ret
align 4
;----------------data-----------------
btxt db 'button',0
message db 13,10,'pressed button',0
bdata gui_button_data_t
swdata gui_scrolled_window_data_t
window rd 1
scrolled_window rd 1
button rd 1
i_end:

View File

@ -0,0 +1,110 @@
;Hello world example
use32
db 'MENUET01'
dd 1
dd start
dd i_end
dd 0x1000
dd 0x1000
dd 0
dd 0
TRUE = 1
FALSE = 0
include 'libGUI.inc'
start:
;load libGUI labrari
push NULL ;use default system path to library
call LoadLibGUI
;create main window
CreateWindow
mov [window],eax
;change size of main window
SetWindowSizeRequest [window],270,207
;set callback function for button close window
SetCallbackFunction [window],DELETE_EVENT,callback_func_delete_window,NULL
;create control HorizontalScrollBar
mov [hsbdata.x],5
mov [hsbdata.y],5
mov [hsbdata.wight],250
mov [hsbdata.height],16
mov [hsbdata.ruller_size],dword 0.2 ;ruler size 0..1
mov [hsbdata.ruller_pos],dword 0.5 ;ruler position 0..1
mov [hsbdata.ruller_step],dword 0.1 ;ruler step 0..1
CreateHorizontalScrollBar hsbdata
mov [hscroll_bar],eax
;create control HorizontalScrollBar
mov [vsbdata.x],5
mov [vsbdata.y],26
mov [vsbdata.wight],16
mov [vsbdata.height],150
mov [vsbdata.ruller_size],dword 0.5 ;ruler size 0..1
mov [vsbdata.ruller_pos],dword 0.05 ;ruler position 0..1
mov [vsbdata.ruller_step],dword 0.1 ;ruler step 0..1
CreateVerticalScrollBar vsbdata
mov [vscroll_bar],eax
;set callback functions for scroll bars
SetCallbackFunction [hscroll_bar],SCROLLBAR_CHANGED_EVENT,hscroll_bar_callback,NULL
SetCallbackFunction [vscroll_bar],SCROLLBAR_CHANGED_EVENT,vscroll_bar_callback,NULL
;pack controls in window
PackControls [window],[hscroll_bar]
PackControls [window],[vscroll_bar]
;start libGUI main loop
LibGUImain [window]
;void hscroll_bar_callback(header_ *control,void *data)
hscroll_bar_callback:
mov eax,[esp+4];pointer to control scroll bar
push ebx
mov ebx,[eax+HEADER_SIZE];size of ruler
mov ecx,[eax+HEADER_SIZE+4];position of ruler
mov edx,[eax+HEADER_SIZE+8];step change position of ruler by press
;buttons of scroll bar
pop ebx
ret
;void hscroll_bar_callback(header_ *control,void *data)
vscroll_bar_callback:
mov eax,[esp+4];pointer to control scroll bar
push ebx ;save befor use
mov ebx,[eax+HEADER_SIZE];size of ruler
mov ecx,[eax+HEADER_SIZE+4];position of ruler
mov edx,[eax+HEADER_SIZE+8];step change position of ruler by press
;buttons of scroll bar
pop ebx
ret
;void callback_func_delete_window(header_t *control,void *data)
callback_func_delete_window:
mov eax,[esp+4] ;control
QuitLibGUI eax
ret
align 4
;----------------data-----------------
hsbdata gui_scroll_bar_data_t
vsbdata gui_scroll_bar_data_t
window rd 1
hscroll_bar rd 1
vscroll_bar rd 1
i_end:

View File

@ -0,0 +1,63 @@
;Hello world example
use32
db 'MENUET01'
dd 1
dd start
dd i_end
dd 0x800
dd 0x800
dd 0
dd 0
TRUE = 1
FALSE = 0
include 'libGUI.inc'
start:
;load libGUI labrari
push NULL ;use default system path to library
call LoadLibGUI
;create main window
CreateWindow
mov [window],eax
;change size of main window
SetWindowSizeRequest [window],92,46
;set callback function for button close window
SetCallbackFunction [window],DELETE_EVENT,callback_func_delete_window,NULL
;create control Text
mov [txtdata.x],5
mov [txtdata.y],5
mov [txtdata.font],NULL;use default system libGUI font
mov [txtdata.background],TRUE;use background for text
mov [txtdata.color],0xffffff;text color
mov [txtdata.background_color],0xff8000
mov [txtdata.text],txt
CreateText txtdata
mov [text],eax
;pack control Text in window
PackControls [window],[text]
;start libGUI main loop
LibGUImain [window]
;void callback_func_delete_window(header_t *control,void *data)
callback_func_delete_window:
mov eax,[esp+4] ;control
QuitLibGUI eax
ret
align 4
;----------------data-----------------
txt db 'Hello world!',0
txtdata gui_text_data_t
window rd 1;parent_t *window
text rd 1;gui_text_data_t *text
i_end:

File diff suppressed because it is too large Load Diff