Rev 3528 | Rev 6258 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3528 | Rev 3529 | ||
---|---|---|---|
Line -... | Line 1... | ||
- | 1 | ; à®á⮩ ¯à¨¬¥à ¯à®£à ¬¬ë ¤«ï KolibriOS |
|
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
2 | ; ®§¢ã稢 ¥â ª®¤ ¦ ⮩ ª« ¢¨è¨ |
- | 3 | ; |
|
- | 4 | ; ®¬¯¨«¨à®¢ âì FASM'®¬ |
|
- | 5 | ; ®¦® ®âªàëâì example.asm ç¥à¥§ ¯à®£à ¬¬ã FASM (¥ñ ïà«ëª ¥áâì |
|
- | 6 | ; à ¡®ç¥¬ á⮫¥) |
|
- | 7 | ; ¬®¦® ¯à®áâ® ¦ âì F9 ¢ Tinypad'¥. ®£ ª®¬¯¨«ï樨 |
|
- | 8 | ; ®â®¡à ¦ ¥âáï ¤®áª¥ ®â« ¤ª¨ (¯à®£à ¬¬ BOARD) |
|
- | 9 | ; |
|
- | 10 | ; â® ¢ ¦® § âì ¯à¨ ¯à®£à ¬¬¨à®¢ ¨¨ ¯®¤ ®«¨¡à¨: |
|
- | 11 | ; ®¬¥à äãªæ¨¨ ¯®¬¥é ¥âáï ¢ ॣ¨áâà eax. |
|
- | 12 | ; 맮¢ á¨á⥬®© äãªæ¨¨ ®áãé¥á⢫ï¥âáï ª®¬ ¤®© "int 0x40". |
|
- | 13 | ; ᥠॣ¨áâàë, ªà®¬¥  㪠§ ëå ¢ ¢®§¢à é ¥¬®¬ § 票¨, |
|
- | 14 | ; ¢ª«îç ï ॣ¨áâà ä« £®¢ eflags, á®åà ïîâáï. |
|
- | 15 | ; |
|
- | 16 | ; ਬ¥à: |
|
- | 17 | ; mov eax, 1 ;ãªæ¨ï 1 - ¯®áâ ¢¨âì â®çªã ¢ ®ª¥ |
|
2 | ; ; |
18 | ; ;ᯨ᮪ á¨áäãªæ¨© á¬. ¢ DOCPACK - sysfuncr.txt |
3 | ; EXAMPLE APPLICATION ; |
19 | ; mov ebx, 10 ; ª®®à¤¨ â x=10 |
4 | ; ; |
20 | ; mov ecx, 20 ; ª®®à¤¨ â y=10 |
5 | ; Compile with FASM ; |
21 | ; mov edx, 0xFFFfff ;梥â â®çª¨ |
6 | ; ; |
22 | ; int 0x40 ;¢ë§¢ âì äãªæ¨î |
- | 23 | ; |
|
- | 24 | ; ®¦¥ á ¬®¥ á ¨á¯®«ì§®¢ ¨¥¬ ¬ ªà®á : |
|
- | 25 | ; mcall 1, 10, 20, 0xFFFfff |
|
7 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
26 | ;--------------------------------------------------------------------- |
Line -... | Line 27... | ||
- | 27 | ||
8 | 28 | use32 ; ¢ª«îç¨âì 32-¡¨âë© à¥¦¨¬ áᥬ¡«¥à |
|
Line -... | Line 29... | ||
- | 29 | org 0x0 ; ¤à¥á æ¨ï á ã«ï |
|
- | 30 | ||
- | 31 | db 'MENUET01' ; 8-¡ ©âë© ¨¤¥â¨ä¨ª â®à MenuetOS |
|
- | 32 | dd 0x01 ; ¢¥àá¨ï § £®«®¢ª (¢á¥£¤ 1) |
|
- | 33 | dd START ; ¤à¥á ¯¥à¢®© ª®¬ ¤ë |
|
- | 34 | dd I_END ; à §¬¥à ¯à®£à ¬¬ë |
|
9 | ; The header |
35 | dd 0x1000 ; ª®«¨ç¥á⢮ ¯ ¬ï⨠|
- | 36 | dd 0x1000 ; ¤à¥á ¢¥àè¨ë áâíª |
|
Line -... | Line 37... | ||
- | 37 | dd 0x0 ; ¤à¥á ¡ãä¥à ¤«ï ¯ à ¬¥â஢ |
|
10 | 38 | dd 0x0 ; § १¥à¢¨à®¢ ® |
|
Line 11... | Line -... | ||
11 | use32 ; Tell compiler to use 32 bit instructions |
- | |
12 | - | ||
13 | org 0x0 ; the base address of code, always 0x0 |
- | |
14 | - | ||
15 | db 'MENUET01' |
- | |
16 | dd 0x01 |
- | |
17 | dd START |
- | |
- | 39 | ||
- | 40 | include 'lang.inc' |
|
- | 41 | include 'macros.inc' ; ¬ ªà®áë ®¡«¥£ç îâ ¦¨§ì áᥬ¡«¥à騪®¢! |
|
Line 18... | Line 42... | ||
18 | dd I_END |
42 | |
Line 19... | Line 43... | ||
19 | dd 0x100000 |
43 | ;--------------------------------------------------------------------- |
Line 20... | Line -... | ||
20 | dd 0x7fff0 |
- | |
21 | dd 0, 0 |
44 | ;--- ---------------------------------------------- |
Line 22... | Line 45... | ||
22 | 45 | ;--------------------------------------------------------------------- |
|
- | 46 | ||
23 | ; The code area |
47 | START: |
Line 24... | Line 48... | ||
24 | 48 | ||
25 | include 'macros.inc' |
- | |
26 | 49 | red: ; ¯¥à¥à¨á®¢ âì ®ª® |
|
Line 27... | Line 50... | ||
27 | START: ; start of execution |
50 | |
28 | call draw_window ; draw the window |
51 | call draw_window ; ¢ë§ë¢ ¥¬ ¯à®æ¥¤ãàã ®âà¨á®¢ª¨ ®ª |
- | 52 | ||
- | 53 | ;--------------------------------------------------------------------- |
|
- | 54 | ;--- ---------------------------------------- |
|
29 | 55 | ;--------------------------------------------------------------------- |
|
Line 30... | Line -... | ||
30 | ; After the window is drawn, it's practical to have the main loop. |
- | |
31 | ; Events are distributed from here. |
- | |
32 | 56 | ||
Line 33... | Line -... | ||
33 | event_wait: |
- | |
34 | mov eax, 10 ; function 10 : wait until event |
- | |
35 | mcall ; event type is returned in eax |
- | |
Line 36... | Line 57... | ||
36 | 57 | still: |
|
Line 37... | Line -... | ||
37 | cmp eax, 1 ; Event redraw request ? |
- | |
Line 38... | Line 58... | ||
38 | je red ; Expl.: there has been activity on screen and |
58 | mcall 10 ; äãªæ¨ï 10 - ¦¤ âì ᮡëâ¨ï |
39 | ; parts of the applications has to be redrawn. |
59 | |
40 | - | ||
Line 41... | Line -... | ||
41 | cmp eax, 2 ; Event key in buffer ? |
- | |
42 | je key ; Expl.: User has pressed a key while the |
60 | cmp eax,1 ; ¯¥à¥à¨á®¢ âì ®ª® ? |
43 | ; app is at the top of the window stack. |
- | |
44 | - | ||
Line 45... | Line -... | ||
45 | cmp eax, 3 ; Event button in buffer ? |
- | |
46 | je button ; Expl.: User has pressed one of the |
61 | je red ; ¥á«¨ ¤ - ¬¥âªã red |
47 | ; applications buttons. |
62 | cmp eax,2 ; ¦ â ª« ¢¨è ? |
Line 48... | Line 63... | ||
48 | 63 | je key ; ¥á«¨ ¤ - key |
|
49 | jmp event_wait |
64 | cmp eax,3 ; ¦ â ª®¯ª ? |
50 | 65 | je button ; ¥á«¨ ¤ - button |
|
51 | ; The next section reads the event and processes data. |
66 | |
Line 52... | Line 67... | ||
52 | 67 | jmp still ; ¥á«¨ ¤à㣮¥ ᮡë⨥ - ¢ ç «® 横« |
|
53 | red: ; Redraw event handler |
68 | |
Line 54... | Line 69... | ||
54 | call draw_window ; We call the window_draw function and |
69 | |
- | 70 | ;--------------------------------------------------------------------- |
|
55 | jmp event_wait ; jump back to event_wait |
71 | |
- | 72 | ||
- | 73 | key: ; ¦ â ª« ¢¨è ª« ¢¨ âãॠ|
|
56 | 74 | mcall 2 ; äãªæ¨ï 2 - áç¨â âì ª®¤ ᨬ¢®« (¢ ah) |
|
57 | key: ; Keypress event handler |
75 | |
58 | mov eax, 2 ; The key is returned in ah. The key must be |
76 | mov [Music+1], ah ; § ¯¨á âì ª®¤ ᨬ¢®« ª ª ª®¤ ®âë |
59 | mcall ; read and cleared from the system queue. |
77 | |
- | 78 | ; äãªæ¨ï 55-55: á¨áâ¥¬ë© ¤¨ ¬¨ª ("PlayNote") |
|
- | 79 | ; esi - ¤à¥á ¬¥«®¤¨¨ |
|
60 | jmp event_wait ; Just read the key, ignore it and jump to event_wait. |
80 | |
- | 81 | ; mov eax,55 |
|
- | 82 | ; mov ebx,eax |
|
61 | 83 | ; mov esi,Music |
|
- | 84 | ; int 0x40 |
|
- | 85 | ||
62 | button: ; Buttonpress event handler |
86 | ; ¨«¨ ª®à®âª®: |
Line 63... | Line 87... | ||
63 | mov eax,17 ; The button number defined in window_draw |
87 | mcall 55, eax, , , Music |
64 | mcall ; is returned to ah. |
- | |
65 | - | ||
66 | cmp ah,1 ; button id=1 ? |
- | |
67 | jne noclose |
- | |
68 | mov eax,-1 ; Function -1 : close this program |
- | |
69 | mcall |
- | |
70 | - | ||
71 | noclose: |
- | |
72 | jmp event_wait ; This is for ignored events, useful at development |
- | |
73 | - | ||
74 | ; ********************************************* |
- | |
75 | ; ****** WINDOW DEFINITIONS AND DRAW ******** |
- | |
76 | ; ********************************************* |
- | |
77 | ; |
- | |
78 | ; The static window parts are drawn in this function. The window canvas can |
- | |
79 | ; be accessed later from any parts of this code (thread) for displaying |
- | |
80 | ; processes or recorded data, for example. |
- | |
81 | ; |
- | |
82 | ; The static parts *must* be placed within the fn 12 , ebx = 1 and ebx = 2. |
- | |
83 | - | ||
84 | draw_window: |
- | |
85 | mov eax, 12 ; function 12: tell os about windowdraw |
- | |
86 | mov ebx, 1 ; 1, start of draw |
- | |
87 | mcall |
- | |
88 | - | ||
89 | mov eax, 0 ; function 0 : define and draw window |
- | |
90 | mov ebx, 100 * 65536 + 300 ; [x start] *65536 + [x size] |
- | |
91 | mov ecx, 100 * 65536 + 120 ; [y start] *65536 + [y size] |
- | |
92 | mov edx, 0x14ffffff ; color of work area RRGGBB |
- | |
93 | ; 0x02000000 = window type 4 (fixed size, skinned window) |
- | |
94 | mov esi, 0x808899ff ; color of grab bar RRGGBB |
- | |
95 | ; 0x80000000 = color glide |
- | |
96 | mov edi, title |
- | |
97 | mcall |
- | |
98 | - | ||
99 | mov ebx, 25 * 65536 + 35 ; draw info text with function 4 |
- | |
100 | mov ecx, 0x224466 |
- | |
101 | mov edx, text |
- | |
102 | mov esi, 40 |
- | |
Line 103... | Line -... | ||
103 | mov eax, 4 |
- | |
104 | 88 | ||
105 | .newline: ; text from the DATA AREA |
89 | jmp still ; ¢¥àãâìáï ª ç «ã 横« |
106 | mcall |
- | |
Line -... | Line 90... | ||
- | 90 | ||
107 | add ebx, 10 |
91 | ;--------------------------------------------------------------------- |
Line 108... | Line -... | ||
108 | add edx, 40 |
- | |
Line 109... | Line -... | ||
109 | cmp byte[edx], 0 |
- | |
110 | jne .newline |
- | |
111 | - | ||
112 | mov eax, 12 ; function 12:tell os about windowdraw |
- | |
113 | mov ebx, 2 ; 2, end of draw |
- | |
114 | mcall |
- | |
115 | - | ||
116 | ret |
- | |
117 | - | ||
118 | ; ********************************************* |
- | |
119 | ; ************* DATA AREA ***************** |
- | |
120 | ; ********************************************* |
- | |
121 | ; |
- | |
122 | ; Data can be freely mixed with code to any parts of the image. |
- | |
123 | ; Only the header information is required at the beginning of the image. |
- | |
124 | - | ||
125 | text db "It look's like you have just compiled " |
- | |
126 | db "your first program for KolibriOS. " |
- | |
127 | db " " |
- | |
128 | db "Congratulations! ", 0 |
- | |
129 | 92 | ||
- | 93 | button: |
|
- | 94 | mcall 17 ; 17 - ¯®«ãç¨âì ¨¤¥â¨ä¨ª â®à ¦ ⮩ ª®¯ª¨ |
|
- | 95 | ||
- | 96 | cmp ah, 1 ; ¥á«¨ ¦ â ª®¯ª á ®¬¥à®¬ 1, |
|
- | 97 | jne still ; ¢¥àãâìáï |
|
- | 98 | ||
- | 99 | .exit: |
|
- | 100 | mcall -1 ; ¨ ç¥ ª®¥æ ¯à®£à ¬¬ë |
|
- | 101 | ||
- | 102 | ||
- | 103 | ||
- | 104 | ;--------------------------------------------------------------------- |
|
- | 105 | ;--- ---------------------------------- |
|
- | 106 | ;--------------------------------------------------------------------- |
|
- | 107 | ||
- | 108 | draw_window: |
|
- | 109 | ||
- | 110 | mcall 12, 1 ; äãªæ¨ï 12: á®®¡é¨âì ®¡ ®âà¨á®¢ª¥ ®ª |
|
- | 111 | ; 1 - ç¨ ¥¬ à¨á®¢ âì |
|
- | 112 | ||
- | 113 | ; ¤ «¥¥: á ç « ¤«¨ë© ¢ ਠâ (§ ª®¬¬¥â¨à®¢ ë©) |
|
- | 114 | ; § ⥬ ª®à®âª¨© «®£ á ¨á¯®«ì§®¢ ¨¥¬ ¬ ªà®á®¢ |
|
- | 115 | ||
- | 116 | ||
- | 117 | ; ð |
|
- | 118 | ; mov eax,0 ; äãªæ¨ï 0 : ®¯à¥¤¥«¨âì ¨ ®âà¨á®¢ âì ®ª® |
|
- | 119 | ; mov ebx,200*65536+200 ; [x áâ àâ] *65536 + [x à §¬¥à] |
|
- | 120 | ; mov ecx,200*65536+50 ; [y áâ àâ] *65536 + [y à §¬¥à] |
|
- | 121 | ; mov edx,0x33aabbcc ; 梥â à ¡®ç¥© ®¡« á⨠RRGGBB,8->color gl |
|
- | 122 | ; mov edi,header ; |
|
- | 123 | ; int 0x40 |
|
- | 124 | ||
- | 125 | mcall 0, <200,200>, <200,50>, 0x33AABBCC,,title |
|
- | 126 | ||
- | 127 | ||
- | 128 | ||
- | 129 | ; mov eax,4 |
|
- | 130 | ; mov ebx,3 shl 16 + 8 |
|
- | 131 | ; mov ecx,0 |
|
- | 132 | ; mov edx,message |
|
- | 133 | ; mov esi,message.size |
|
- | 134 | ; int 0x40 |
|
- | 135 | ||
- | 136 | mcall 4, <3, 8>, 0, message, message.size |
|
- | 137 | ||
- | 138 | mcall 12, 2 ; äãªæ¨ï 12: á®®¡é¨âì ®¡ ®âà¨á®¢ª¥ ®ª |
|
- | 139 | ; 2, § ª®ç¨«¨ à¨á®¢ âì |
|
- | 140 | ||
- | 141 | ret ; ¢ë室¨¬ ¨§ ¯à®æ¥¤ãàë |
|
- | 142 | ||
- | 143 | ||
- | 144 | ;--------------------------------------------------------------------- |
|
- | 145 | ;--- ---------------------------------------------- |
|
- | 146 | ;--------------------------------------------------------------------- |
|
- | 147 | ||
- | 148 | ; ®â â ª ï ¢®â ª®à®âª ï "¬¥«®¤¨ï". |