Subversion Repositories Kolibri OS

Rev

Rev 1741 | Rev 4602 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1741 Rev 1999
1
;
1
;
2
;   LAUNCHER - €‚’Ž‡€“‘Š Žƒ€ŒŒ
2
;   LAUNCHER - €‚’Ž‡€“‘Š Žƒ€ŒŒ
3
;     Š®¤ ¯à®£à ¬¬ë ᮢᥬ ­¥ ®¯â¨¬¨§¨à®¢ ­, ­® ®ç¥­ì ¯à®áâ ¤«ï ¯®­¨¬ ­¨ï.
3
;     Š®¤ ¯à®£à ¬¬ë ᮢᥬ ­¥ ®¯â¨¬¨§¨à®¢ ­, ­® ®ç¥­ì ¯à®áâ ¤«ï ¯®­¨¬ ­¨ï.
4
;     â®â « ã­ç¥à £à㧨⠨­ä®à¬ æ¨î ® ¯à®£à ¬¬ å ¤«ï § ¯ã᪠ ¨§ ä ©« 
4
;     â®â « ã­ç¥à £à㧨⠨­ä®à¬ æ¨î ® ¯à®£à ¬¬ å ¤«ï § ¯ã᪠ ¨§ ä ©« 
5
;     AUTORUN.DAT. ”®à¬ â ®ç¥­ì ¯à®áâ ¨ ¢ ª®¬¬¥­â à¨ïå ­¥ ­ã¦¤ ¥âáï.
5
;     AUTORUN.DAT. ”®à¬ â ®ç¥­ì ¯à®áâ ¨ ¢ ª®¬¬¥­â à¨ïå ­¥ ­ã¦¤ ¥âáï.
6
;
6
;
7
;   Š®¬¯¨«¨àã©â¥ á ¯®¬®éìî FASM 1.52 ¨ ¢ëè¥
7
;   Š®¬¯¨«¨àã©â¥ á ¯®¬®éìî FASM 1.52 ¨ ¢ëè¥
8
;
8
;
9
include "../../../macros.inc"
9
include "../../../macros.inc"
10
 
10
 
11
  use32
11
  use32
12
  org    0x0
12
  org    0x0
13
  db     'MENUET01'              ; 8 byte id
13
  db     'MENUET01'              ; 8 byte id
14
  dd     0x01                    ; header version
14
  dd     0x01                    ; header version
15
  dd     START                   ; start of code
15
  dd     START                   ; start of code
16
  dd     I_END                   ; size of image
16
  dd     I_END                   ; size of image
17
  dd     0x8000                 ; memory for app
17
  dd     0x8000                 ; memory for app
18
  dd     0x8000                 ; esp
18
  dd     0x8000                 ; esp
19
  dd     0x0 , 0x0               ; I_Param , I_Icon
19
  dd     0x0 , 0x0               ; I_Param , I_Icon
20
 
20
 
21
;include "DEBUG.INC"
21
;include "DEBUG.INC"
22
 
22
 
23
START:                           ; start of execution
23
START:                           ; start of execution
24
 
24
 
25
;   mov  eax, 5
25
;   mov  eax, 5
26
;   mov  ebx, 10
26
;   mov  ebx, 10
27
;   mcall
27
;   mcall
28
 
28
 
29
;   mcall 18,15
29
;   mcall 18,15
30
 
30
 
31
   mov  eax, 70               ; load AUTORUN.DAT
31
   mov  eax, 70               ; load AUTORUN.DAT
32
   mov  ebx, autorun_dat_info
32
   mov  ebx, autorun_dat_info
33
   mcall
33
   mcall
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,'#'
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
49
   call get_number
50
;dps <"STARTING A PROGRAM",13,10>
50
;dps <"STARTING A PROGRAM",13,10>
51
   call run_program
51
   call run_program
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
58
   mcall
59
 
59
 
60
 
60
 
61
 run_program:     ; time to delay in eax
61
 run_program:     ; time to delay in eax
62
   push eax
62
   push eax
63
   mcall 70, start_info
63
   mcall 70, start_info
64
   pop  ebx
64
   pop  ebx
65
 
65
 
66
; if delay is negative, wait for termination
66
; if delay is negative, wait for termination
67
;   of the spawned process
67
;   of the spawned process
68
   test ebx, ebx
68
   test ebx, ebx
69
   js   must_wait_for_termination
69
   js   must_wait_for_termination
70
; otherwise, simply wait
70
; otherwise, simply wait
71
   mov  eax, 5
71
   mov  eax, 5
72
   mcall
72
   mcall
73
   ret
73
   ret
74
 must_wait_for_termination:
74
 must_wait_for_termination:
75
   mov  esi, eax  ; save slot for the future
75
   mov  esi, eax  ; save slot for the future
76
; get process slot
76
; get process slot
77
   mov  ecx, eax
77
   mov  ecx, eax
78
   mcall 18, 21
78
   mcall 18, 21
79
; if an error has occured, exit
79
; if an error has occured, exit
80
   test eax, eax
80
   test eax, eax
81
   jz   child_exited
81
   jz   child_exited
82
   mov  ecx, eax
82
   mov  ecx, eax
83
; wait
83
; wait
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  word [ebx+50], 9 ; the slot was freed?
89
   jz   child_exited
89
   jz   child_exited
90
   cmp  dword [ebx+30], esi ; the slot is still occupied by our child?
90
   cmp  dword [ebx+30], esi ; the slot is still occupied by our child?
91
   jz   wait_for_termination
91
   jz   wait_for_termination
92
 child_exited:
92
 child_exited:
93
   ret
93
   ret
94
 
94
 
95
 clear_strings:   ; clears buffers
95
 clear_strings:   ; clears buffers
96
   pushad
96
   pushad
97
 
97
 
98
   mov  ecx, 60
98
   mov  ecx, 60
99
   mov  edi, program
99
   mov  edi, program
100
   xor  al, al ;mov  al, ' '
100
   xor  al, al ;mov  al, ' '
101
   rep  stosb
101
   rep  stosb
102
 
102
 
103
   mov  ecx, 60
103
   mov  ecx, 60
104
   mov  edi, parameters
104
   mov  edi, parameters
105
   rep  stosb
105
   rep  stosb
106
 
106
 
107
   popad
107
   popad
108
 ret
108
 ret
109
 
109
 
110
 
110
 
111
 get_string: ; pointer to destination buffer in edi
111
 get_string: ; pointer to destination buffer in edi
112
   pushad
112
   pushad
113
   call skip_spaces
113
   call skip_spaces
114
   mov  esi, [position]
114
   mov  esi, [position]
115
;dpd esi
115
;dpd esi
116
;dps <13,10>
116
;dps <13,10>
117
   add  esi, file_data
117
   add  esi, file_data
-
 
118
   cmp  byte [esi], '"'
-
 
119
   jz   .quoted
118
  .start:
120
  .start:
119
   cmp  esi, [fileend]
121
   cmp  esi, [fileend]
120
   jae  exit
122
   jae  exit
121
   lodsb
123
   lodsb
122
   cmp  al, ' '
124
   cmp  al, ' '
123
   je   .finish
125
   jbe  .finish
124
   stosb
126
   stosb
125
   inc  [position]
127
   inc  [position]
126
   jmp  .start
128
   jmp  .start
127
  .finish:
129
  .finish:
128
   popad
130
   popad
129
 ret
131
   ret
-
 
132
  .quoted:
-
 
133
   inc  esi
-
 
134
   inc  [position]
-
 
135
  .quoted.start:
-
 
136
   cmp  esi, [fileend]
-
 
137
   jae  exit
-
 
138
   lodsb
-
 
139
   inc  [position]
-
 
140
   cmp  al, '"'
-
 
141
   je   .finish
-
 
142
   stosb
-
 
143
   jmp  .quoted.start
130
 
144
 
131
 
145
 
132
 get_number:
146
 get_number:
133
   push ebx esi
147
   push ebx esi
134
   call skip_spaces
148
   call skip_spaces
135
   mov  esi, [position]
149
   mov  esi, [position]
136
   add  esi, file_data
150
   add  esi, file_data
137
   xor  eax, eax
151
   xor  eax, eax
138
   cmp  byte [esi], '-'
152
   cmp  byte [esi], '-'
139
   jnz  @f
153
   jnz  @f
140
   inc  eax
154
   inc  eax
141
   inc  esi
155
   inc  esi
142
   inc  [position]
156
   inc  [position]
143
@@:
157
@@:
144
   push eax
158
   push eax
145
   xor  eax, eax
159
   xor  eax, eax
146
   xor  ebx, ebx
160
   xor  ebx, ebx
147
  .start:
161
  .start:
148
   cmp  esi, [fileend]
162
   cmp  esi, [fileend]
149
   jae  .finish
163
   jae  .finish
150
   lodsb
164
   lodsb
151
   sub  al, '0'
165
   sub  al, '0'
152
   cmp  al, 9
166
   cmp  al, 9
153
   ja   .finish
167
   ja   .finish
154
   lea  ebx,[ebx*4+ebx]
168
   lea  ebx,[ebx*4+ebx]
155
   lea  ebx,[ebx*2+eax]
169
   lea  ebx,[ebx*2+eax]
156
   inc  [position]
170
   inc  [position]
157
   jmp  .start
171
   jmp  .start
158
  .finish:
172
  .finish:
159
   pop  eax
173
   pop  eax
160
   dec  eax
174
   dec  eax
161
   jnz  @f
175
   jnz  @f
162
   neg  ebx
176
   neg  ebx
163
@@:
177
@@:
164
   mov  eax, ebx
178
   mov  eax, ebx
165
   pop  esi ebx
179
   pop  esi ebx
166
 ret
180
 ret
167
 
181
 
168
 
182
 
169
 skip_spaces:
183
 skip_spaces:
170
   push esi
184
   push esi
171
   xor  eax, eax
185
   xor  eax, eax
172
   mov  esi, [position]
186
   mov  esi, [position]
173
   add  esi, file_data
187
   add  esi, file_data
174
  .start:
188
  .start:
175
   cmp  esi, [fileend]
189
   cmp  esi, [fileend]
176
   jae  .finish
190
   jae  .finish
177
   lodsb
191
   lodsb
178
   cmp  al, ' '
192
   cmp  al, ' '
179
   jne  .finish
193
   ja   .finish
180
   inc  [position]
194
   inc  [position]
181
   jmp  .start
195
   jmp  .start
182
  .finish:
196
  .finish:
183
;dps "NOW AL = "
197
;dps "NOW AL = "
184
;mov [tmp],al
198
;mov [tmp],al
185
;mov edx, tmp
199
;mov edx, tmp
186
;call debug_outstr
200
;call debug_outstr
187
;dps <13,10>
201
;dps <13,10>
188
   pop  esi
202
   pop  esi
189
 ret
203
 ret
190
 
204
 
191
 
205
 
192
 next_line:
206
 next_line:
193
   mov  esi, [position]
207
   mov  esi, [position]
194
   add  esi, file_data
208
   add  esi, file_data
195
  .start:
209
  .start:
196
   cmp  esi, [fileend]
210
   cmp  esi, [fileend]
197
   jae  exit
211
   jae  exit
198
   lodsb
212
   lodsb
199
   cmp  al, 13
213
   cmp  al, 13
200
   je   .finish
214
   je   .finish
201
   cmp  al, 10
215
   cmp  al, 10
202
   je   .finish
216
   je   .finish
203
   inc  [position]
217
   inc  [position]
204
   jmp  .start
218
   jmp  .start
205
  .finish:
219
  .finish:
206
   inc  [position]
220
   inc  [position]
207
   cmp  esi, [fileend]
221
   cmp  esi, [fileend]
208
   jae  exit
222
   jae  exit
209
   lodsb
223
   lodsb
210
   cmp  al, 13
224
   cmp  al, 13
211
   je   .finish
225
   je   .finish
212
   cmp  al, 10
226
   cmp  al, 10
213
   je   .finish
227
   je   .finish
214
   ret
228
   ret
215
 
229
 
216
 
230
 
217
 
231
 
218
; DATA:
232
; DATA:
219
 position          dd 0            ; position in file
233
 position          dd 0            ; position in file
220
 
234
 
221
 autorun_dat_info:                 ; AUTORUN.DAT
235
 autorun_dat_info:                 ; AUTORUN.DAT
222
   .mode           dd 0            ; read file
236
   .mode           dd 0            ; read file
223
   .start_block    dd 0            ; block to read
237
   .start_block    dd 0            ; block to read
224
                   dd 0
238
                   dd 0
225
   .blocks         dd 16*512       ; 16*512 bytes max
239
   .blocks         dd 16*512       ; 16*512 bytes max
226
   .address        dd file_data
240
   .address        dd file_data
227
   db "AUTORUN.DAT",0
241
   db "AUTORUN.DAT",0
228
 
242
 
229
 start_info:
243
 start_info:
230
   .mode           dd 7
244
   .mode           dd 7
231
                   dd 0
245
                   dd 0
232
   .params         dd parameters
246
   .params         dd parameters
233
                   dd 0
247
                   dd 0
234
                   dd 0
248
                   dd 0
235
   .path: ;      
249
   .path: ;      
236
 
250
 
237
I_END:
251
I_END:
238
 
252
 
239
 program           rb 61 ; 60 + [0] char
253
 program           rb 61 ; 60 + [0] char
240
 parameters        rb 61
254
 parameters        rb 61
241
 
255
 
242
 processinfo       rb 1024
256
 processinfo       rb 1024
243
 fileend           dd ?
257
 fileend           dd ?
244
 
258
 
245
 file_data         rb 16*512
259
 file_data         rb 16*512