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