Rev 4095 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4095 | Rev 4602 | ||
---|---|---|---|
Line -... | Line 1... | ||
- | 1 | ;----------------------------------------------------------------------------- |
|
1 | ; |
2 | ; |
2 | ; LAUNCHER - |
3 | ; LAUNCHER - startup of programs |
3 | ; ®¤ ¯à®£à ¬¬ë ᮢᥬ ¥ ®¯â¨¬¨§¨à®¢ , ® ®ç¥ì ¯à®áâ ¤«ï ¯®¨¬ ¨ï. |
- | |
4 | ; â®â « ãç¥à £à㧨⠨ä®à¬ æ¨î ® ¯à®£à ¬¬ å ¤«ï § ¯ã᪠¨§ ä ©« |
- | |
5 | ; AUTORUN.DAT. ®à¬ â ®ç¥ì ¯à®áâ ¨ ¢ ª®¬¬¥â à¨ïå ¥ 㦤 ¥âáï. |
- | |
6 | ; |
4 | ; |
7 | ; ®¬¯¨«¨àã©â¥ á ¯®¬®éìî FASM 1.52 ¨ ¢ëè¥ |
5 | ; Compile with FASM 1.52 or newer |
8 | ; |
6 | ; |
- | 7 | ;----------------------------------------------------------------------------- |
|
9 | include "../../../macros.inc" |
8 | ; last update: 02/03/2014 |
10 | - | ||
- | 9 | ; changed by: Marat Zakiyanov aka Mario79, aka Mario |
|
- | 10 | ; changes: Reducing the consumption of RAM, 4 KB instead of 32 KB. |
|
- | 11 | ; Output to BOARD information about running applications. |
|
- | 12 | ; Cleaning of the source code. |
|
- | 13 | ; notice: Only 2 KB of memory for AUTORUN.DAT - be careful! |
|
- | 14 | ;----------------------------------------------------------------------------- |
|
11 | use32 |
15 | use32 |
12 | org 0x0 |
16 | org 0x0 |
13 | db 'MENUET01' ; 8 byte id |
17 | db 'MENUET01' ; 8 byte id |
14 | dd 0x01 ; header version |
18 | dd 0x01 ; header version |
15 | dd START ; start of code |
19 | dd START ; start of code |
16 | dd I_END ; size of image |
20 | dd IM_END ; size of image |
17 | dd 0x8000 ; memory for app |
21 | dd I_END ; memory for app |
18 | dd 0x8000 ; esp |
22 | dd stack_top ; esp |
19 | dd 0x0 , 0x0 ; I_Param , I_Icon |
23 | dd 0x0 ; I_Param |
20 | - | ||
- | 24 | dd 0x0 ; I_Icon |
|
- | 25 | ;----------------------------------------------------------------------------- |
|
21 | ;include "DEBUG.INC" |
26 | include "../../../macros.inc" |
Line -... | Line 27... | ||
- | 27 | ||
- | 28 | define __DEBUG__ 1 |
|
- | 29 | define __DEBUG_LEVEL__ 1 |
|
- | 30 | include "../../../debug-fdo.inc" |
|
22 | 31 | ;----------------------------------------------------------------------------- |
|
23 | START: ; start of execution |
- | |
24 | - | ||
25 | ; mov eax, 5 |
- | |
26 | ; mov ebx, 10 |
- | |
27 | ; mcall |
- | |
28 | - | ||
29 | ; mcall 18,15 |
- | |
30 | 32 | START: ; start of execution |
|
31 | mov eax, 70 ; load AUTORUN.DAT |
- | |
32 | mov ebx, autorun_dat_info |
- | |
33 | mcall |
33 | mcall 70,autorun_dat_info ; load AUTORUN.DAT |
34 | add ebx, file_data |
34 | add ebx,file_data |
35 | mov [fileend], ebx |
- | |
- | 35 | mov [fileend],ebx |
|
36 | 36 | ;----------------------------------------------------------------------------- |
|
37 | ; this cycle does not contain an obvious exit condition, |
37 | ; this cycle does not contain an obvious exit condition, |
38 | ; but auxiliary procedures (like "get_string") will exit |
38 | ; but auxiliary procedures (like "get_string") will exit |
39 | ; at EOF |
39 | ; at EOF |
40 | start_program: |
40 | start_program: |
41 | call skip_spaces |
41 | call skip_spaces |
42 | cmp al,'#' |
42 | cmp al,byte '#' |
43 | jz skip_this_string |
43 | jz skip_this_string |
44 | call clear_strings |
44 | call clear_strings |
45 | mov edi, program |
45 | mov edi,program |
46 | call get_string |
46 | call get_string |
47 | mov edi, parameters |
47 | mov edi,parameters |
48 | call get_string |
48 | call get_string |
49 | call get_number |
- | |
50 | ;dps <"STARTING A PROGRAM",13,10> |
49 | call get_number |
- | 50 | call run_program |
|
51 | call run_program |
51 | ;-------------------------------------- |
52 | skip_this_string: |
52 | skip_this_string: |
53 | call next_line |
53 | call next_line |
54 | jmp start_program |
- | |
- | 54 | jmp start_program |
|
55 | 55 | ;----------------------------------------------------------------------------- |
|
56 | exit: |
56 | exit: |
57 | or eax, -1 |
57 | or eax,-1 |
58 | mcall |
- | |
59 | - | ||
- | 58 | mcall |
|
60 | 59 | ;----------------------------------------------------------------------------- |
|
- | 60 | run_program: ; time to delay in eax |
|
61 | run_program: ; time to delay in eax |
61 | DEBUGF 1, "Launch: %s Parameter: %s\n",program,parameters |
62 | push eax |
62 | push eax |
63 | mcall 70, start_info |
63 | mcall 70,start_info |
64 | pop ebx |
- | |
65 | 64 | pop ebx |
|
66 | ; if delay is negative, wait for termination |
65 | ; if delay is negative, wait for termination |
67 | ; of the spawned process |
66 | ; of the spawned process |
68 | test ebx, ebx |
67 | test ebx,ebx |
69 | js must_wait_for_termination |
68 | js must_wait_for_termination |
70 | ; otherwise, simply wait |
- | |
71 | mov eax, 5 |
69 | ; otherwise, simply wait |
72 | mcall |
70 | mcall 5 |
- | 71 | ret |
|
73 | ret |
72 | ;----------------------------------------------------------------------------- |
74 | must_wait_for_termination: |
73 | must_wait_for_termination: |
75 | mov esi, eax ; save slot for the future |
74 | mov esi,eax ; save slot for the future |
76 | ; get process slot |
75 | ; get process slot |
77 | mov ecx, eax |
76 | mov ecx,eax |
78 | mcall 18, 21 |
77 | mcall 18,21 |
79 | ; if an error has occured, exit |
78 | ; if an error has occured, exit |
80 | test eax, eax |
79 | test eax,eax |
- | 80 | jz child_exited |
|
81 | jz child_exited |
81 | |
82 | mov ecx, eax |
82 | mov ecx,eax |
83 | ; wait |
83 | ;-------------------------------------- |
84 | wait_for_termination: |
84 | wait_for_termination: |
85 | mcall 5, 1 |
85 | mcall 5,1 |
86 | mov ebx, processinfo |
86 | mov ebx, processinfo |
87 | mcall 9 |
87 | mcall 9 |
88 | cmp word [ebx+50], 9 ; the slot was freed? |
88 | cmp [ebx+50],word 9 ; the slot was freed? |
- | 89 | jz child_exited |
|
89 | jz child_exited |
90 | |
90 | cmp dword [ebx+30], esi ; the slot is still occupied by our child? |
91 | cmp [ebx+30],dword esi ; the slot is still occupied by our child? |
- | 92 | jz wait_for_termination |
|
91 | jz wait_for_termination |
93 | ;-------------------------------------- |
92 | child_exited: |
94 | child_exited: |
93 | ret |
- | |
- | 95 | ret |
|
94 | 96 | ;----------------------------------------------------------------------------- |
|
95 | clear_strings: ; clears buffers |
97 | clear_strings: ; clears buffers |
96 | pushad |
- | |
97 | 98 | pushad |
|
98 | mov ecx, 60 |
99 | mov ecx,60+1 |
99 | mov edi, program |
100 | mov edi,program |
100 | xor al, al ;mov al, ' ' |
101 | xor al,al |
101 | rep stosb |
- | |
102 | 102 | rep stosb |
|
103 | mov ecx, 60 |
103 | mov ecx,60+1 |
104 | mov edi, parameters |
104 | mov edi,parameters |
105 | rep stosb |
- | |
106 | 105 | rep stosb |
|
107 | popad |
106 | popad |
108 | ret |
- | |
109 | - | ||
- | 107 | ret |
|
110 | 108 | ;----------------------------------------------------------------------------- |
|
111 | get_string: ; pointer to destination buffer in edi |
109 | get_string: ; pointer to destination buffer in edi |
112 | pushad |
110 | pushad |
113 | call skip_spaces |
111 | call skip_spaces |
114 | mov esi, [position] |
- | |
115 | ;dpd esi |
- | |
116 | ;dps <13,10> |
112 | mov esi,[position] |
117 | add esi, file_data |
113 | add esi,file_data |
118 | cmp byte [esi], '"' |
114 | cmp [esi],byte '"' |
- | 115 | jz .quoted |
|
119 | jz .quoted |
116 | ;-------------------------------------- |
120 | .start: |
117 | .start: |
121 | cmp esi, [fileend] |
118 | cmp esi,[fileend] |
- | 119 | jae exit |
|
122 | jae exit |
120 | |
123 | lodsb |
121 | lodsb |
124 | cmp al, ' ' |
122 | cmp al,byte ' ' |
- | 123 | jbe .finish |
|
125 | jbe .finish |
124 | |
126 | stosb |
125 | stosb |
127 | inc [position] |
126 | inc dword [position] |
- | 127 | jmp .start |
|
128 | jmp .start |
128 | ;-------------------------------------- |
129 | .finish: |
129 | .finish: |
130 | popad |
130 | popad |
- | 131 | ret |
|
131 | ret |
132 | ;-------------------------------------- |
132 | .quoted: |
133 | .quoted: |
133 | inc esi |
134 | inc esi |
- | 135 | inc dword [position] |
|
134 | inc [position] |
136 | ;-------------------------------------- |
135 | .quoted.start: |
137 | .quoted.start: |
136 | cmp esi, [fileend] |
138 | cmp esi,[fileend] |
- | 139 | jae exit |
|
137 | jae exit |
140 | |
138 | lodsb |
141 | lodsb |
139 | inc [position] |
142 | inc dword [position] |
140 | cmp al, '"' |
143 | cmp al,byte '"' |
- | 144 | je .finish |
|
141 | je .finish |
145 | |
142 | stosb |
146 | stosb |
143 | jmp .quoted.start |
- | |
144 | - | ||
- | 147 | jmp .quoted.start |
|
145 | 148 | ;----------------------------------------------------------------------------- |
|
146 | get_number: |
149 | get_number: |
147 | push ebx esi |
150 | push ebx esi |
148 | call skip_spaces |
151 | call skip_spaces |
149 | mov esi, [position] |
152 | mov esi,[position] |
150 | add esi, file_data |
153 | add esi,file_data |
151 | xor eax, eax |
154 | xor eax,eax |
152 | cmp byte [esi], '-' |
155 | cmp [esi],byte '-' |
- | 156 | jnz @f |
|
153 | jnz @f |
157 | |
154 | inc eax |
158 | inc eax |
155 | inc esi |
159 | inc esi |
- | 160 | inc dword [position] |
|
156 | inc [position] |
161 | ;-------------------------------------- |
157 | @@: |
162 | @@: |
158 | push eax |
163 | push eax |
159 | xor eax, eax |
164 | xor eax,eax |
- | 165 | xor ebx,ebx |
|
160 | xor ebx, ebx |
166 | ;-------------------------------------- |
161 | .start: |
167 | .start: |
162 | cmp esi, [fileend] |
168 | cmp esi,[fileend] |
- | 169 | jae .finish |
|
163 | jae .finish |
170 | |
164 | lodsb |
171 | lodsb |
165 | sub al, '0' |
172 | sub al,byte '0' |
166 | cmp al, 9 |
173 | cmp al,9 |
- | 174 | ja .finish |
|
167 | ja .finish |
175 | |
168 | lea ebx,[ebx*4+ebx] |
176 | lea ebx,[ebx*4+ebx] |
169 | lea ebx,[ebx*2+eax] |
177 | lea ebx,[ebx*2+eax] |
170 | inc [position] |
178 | inc dword [position] |
- | 179 | jmp .start |
|
171 | jmp .start |
180 | ;-------------------------------------- |
172 | .finish: |
181 | .finish: |
173 | pop eax |
182 | pop eax |
174 | dec eax |
183 | dec eax |
- | 184 | jnz @f |
|
175 | jnz @f |
185 | |
- | 186 | neg ebx |
|
176 | neg ebx |
187 | ;-------------------------------------- |
177 | @@: |
188 | @@: |
178 | mov eax, ebx |
189 | mov eax,ebx |
179 | pop esi ebx |
190 | pop esi ebx |
180 | ret |
- | |
181 | - | ||
- | 191 | ret |
|
182 | 192 | ;----------------------------------------------------------------------------- |
|
183 | skip_spaces: |
193 | skip_spaces: |
184 | push esi |
194 | push esi |
185 | xor eax, eax |
195 | xor eax,eax |
186 | mov esi, [position] |
196 | mov esi,[position] |
- | 197 | add esi,file_data |
|
187 | add esi, file_data |
198 | ;-------------------------------------- |
188 | .start: |
199 | .start: |
189 | cmp esi, [fileend] |
200 | cmp esi,[fileend] |
- | 201 | jae .finish |
|
190 | jae .finish |
202 | |
191 | lodsb |
203 | lodsb |
192 | cmp al, ' ' |
204 | cmp al,byte ' ' |
- | 205 | ja .finish |
|
193 | ja .finish |
206 | |
194 | inc [position] |
207 | inc dword [position] |
- | 208 | jmp .start |
|
195 | jmp .start |
209 | ;-------------------------------------- |
196 | .finish: |
- | |
197 | ;dps "NOW AL = " |
- | |
198 | ;mov [tmp],al |
- | |
199 | ;mov edx, tmp |
- | |
200 | ;call debug_outstr |
- | |
201 | ;dps <13,10> |
210 | .finish: |
202 | pop esi |
211 | pop esi |
203 | ret |
- | |
204 | - | ||
- | 212 | ret |
|
205 | 213 | ;----------------------------------------------------------------------------- |
|
206 | next_line: |
214 | next_line: |
207 | mov esi, [position] |
215 | mov esi,[position] |
- | 216 | add esi,file_data |
|
208 | add esi, file_data |
217 | ;-------------------------------------- |
209 | .start: |
218 | .start: |
210 | cmp esi, [fileend] |
219 | cmp esi,[fileend] |
- | 220 | jae exit |
|
211 | jae exit |
221 | |
212 | lodsb |
222 | lodsb |
213 | cmp al, 13 |
223 | cmp al,13 |
- | 224 | je .finish |
|
214 | je .finish |
225 | |
215 | cmp al, 10 |
226 | cmp al,10 |
- | 227 | je .finish |
|
216 | je .finish |
228 | |
217 | inc [position] |
229 | inc dword [position] |
- | 230 | jmp .start |
|
218 | jmp .start |
231 | ;-------------------------------------- |
219 | .finish: |
232 | .finish: |
220 | inc [position] |
233 | inc dword [position] |
221 | cmp esi, [fileend] |
234 | cmp esi,[fileend] |
- | 235 | jae exit |
|
222 | jae exit |
236 | |
223 | lodsb |
237 | lodsb |
224 | cmp al, 13 |
238 | cmp al,13 |
- | 239 | je .finish |
|
225 | je .finish |
240 | |
226 | cmp al, 10 |
241 | cmp al,10 |
227 | je .finish |
- | |
228 | ret |
- | |
229 | - | ||
Line -... | Line 242... | ||
- | 242 | je .finish |
|
- | 243 | ||
230 | 244 | ret |
|
231 | 245 | ;----------------------------------------------------------------------------- |
|
232 | ; DATA: |
- | |
- | 246 | ; DATA: |
|
- | 247 | ;----------------------------------------------------------------------------- |
|
233 | position dd 0 ; position in file |
248 | include_debug_strings |
234 | 249 | ;----------------------------------------------------------------------------- |
|
235 | autorun_dat_info: ; AUTORUN.DAT |
250 | autorun_dat_info: ; AUTORUN.DAT |
236 | .mode dd 0 ; read file |
251 | .mode dd 0 ; read file |
237 | .start_block dd 0 ; block to read |
252 | .start_block dd 0 ; block to read |
238 | dd 0 |
253 | dd 0 |
239 | .blocks dd 16*512 ; 16*512 bytes max |
254 | .blocks dd 4*512 ; 2 Kb max for AUTORUN.DAT |
240 | .address dd file_data |
- | |
- | 255 | .address dd file_data |
|
241 | db "/SYS/SETTINGS/AUTORUN.DAT",0 |
256 | db "/SYS/SETTINGS/AUTORUN.DAT",0 |
242 | 257 | ;----------------------------------------------------------------------------- |
|
243 | start_info: |
258 | start_info: |
244 | .mode dd 7 |
259 | .mode dd 7 |
245 | dd 0 |
260 | dd 0 |
246 | .params dd parameters |
261 | .params dd parameters |
- | 262 | dd 0 |
|
- | 263 | dd 0 |
|
- | 264 | .path: |
|
- | 265 | ;----------------------------------------------------------------------------- |
|
- | 266 | IM_END: |
|
- | 267 | ;----------------------------------------------------------------------------- |
|
- | 268 | align 4 |
|
- | 269 | processinfo: |
|
247 | dd 0 |
270 | ;----------------------------------------------------------------------------- |
- | 271 | program: |
|
- | 272 | rb 61 ; 60 + [0] char |
|
- | 273 | ;----------------------------------------------------------------------------- |
|
- | 274 | parameters: |
|
- | 275 | rb 61 |
|
- | 276 | ;----------------------------------------------------------------------------- |
|
- | 277 | rb 1024-61*2 |
|
- | 278 | ;----------------------------------------------------------------------------- |
|
- | 279 | position: |
|
- | 280 | rd 1 ; position in file |
|
248 | dd 0 |
281 | ;----------------------------------------------------------------------------- |
- | 282 | fileend: |
|
- | 283 | rd 1 |
|
- | 284 | ;----------------------------------------------------------------------------- |
|
- | 285 | align 4 |
|
- | 286 | file_data: |
|
- | 287 | rb 4*512 ; 2 Kb for AUTORUN.DAT |
|
- | 288 | ;----------------------------------------------------------------------------- |
|
- | 289 | align 4 |
|
- | 290 | rb 256 |
|
249 | .path: ; |
291 | stack_top: |
250 | - | ||
251 | I_END: |
292 | ;----------------------------------------------------------------------------- |
252 | - | ||
253 | program rb 61 ; 60 + [0] char |
- | |
254 | parameters rb 61 |
- | |
255 | - | ||
256 | processinfo rb 1024 |
- | |
257 | fileend dd ? |
- |