Rev 529 | Rev 1741 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 529 | Rev 1013 | ||
---|---|---|---|
Line 24... | Line 24... | ||
24 | 24 | ||
25 | ; mov eax, 5 |
25 | ; mov eax, 5 |
26 | ; mov ebx, 10 |
26 | ; mov ebx, 10 |
Line 27... | Line 27... | ||
27 | ; mcall |
27 | ; mcall |
Line 28... | Line 28... | ||
28 | 28 | ||
29 | mcall 18,15 |
29 | ; mcall 18,15 |
30 | 30 | ||
- | 31 | mov eax, 70 ; load AUTORUN.DAT |
|
- | 32 | mov ebx, autorun_dat_info |
|
Line 31... | Line -... | ||
31 | mov eax, 70 ; load AUTORUN.DAT |
- | |
32 | mov ebx, autorun_dat_info |
33 | mcall |
33 | mcall |
34 | add ebx, file_data |
34 | 35 | mov [fileend], ebx |
|
35 | call get_number |
- | |
36 | mov [number_of_files], eax |
- | |
37 | ;dps "NUMBER OF FILES: " |
- | |
38 | ;dpd eax |
36 | |
- | 37 | ; this cycle does not contain an obvious exit condition, |
|
- | 38 | ; but auxiliary procedures (like "get_string") will exit |
|
39 | ;dps <13,10> |
39 | ; at EOF |
40 | call next_line |
40 | start_program: |
41 | 41 | call skip_spaces |
|
42 | start_program: |
42 | cmp al,'#' |
43 | ;dps <"STARTING A PROGRAM",13,10> |
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 |
- | 48 | call get_string |
|
47 | mov edi, parameters |
49 | call get_number |
48 | call get_string |
- | |
49 | call get_number |
50 | ;dps <"STARTING A PROGRAM",13,10> |
Line 50... | Line 51... | ||
50 | call run_program |
51 | call run_program |
51 | call next_line |
52 | skip_this_string: |
52 | dec [number_of_files] |
53 | call next_line |
Line 60... | Line 61... | ||
60 | run_program: ; time to delay in eax |
61 | run_program: ; time to delay in eax |
61 | push eax |
62 | push eax |
62 | mcall 70, start_info |
63 | mcall 70, start_info |
63 | pop ebx |
64 | pop ebx |
Line -... | Line 65... | ||
- | 65 | ||
- | 66 | ; if delay is negative, wait for termination |
|
- | 67 | ; of the spawned process |
|
- | 68 | test ebx, ebx |
|
- | 69 | js must_wait_for_termination |
|
64 | 70 | ; otherwise, simply wait |
|
65 | mov eax, 5 |
71 | mov eax, 5 |
66 | mcall |
72 | mcall |
- | 73 | ret |
|
- | 74 | must_wait_for_termination: |
|
- | 75 | mov esi, eax ; save slot for the future |
|
- | 76 | ; get process slot |
|
- | 77 | mov ecx, eax |
|
- | 78 | mcall 18, 21 |
|
- | 79 | ; if an error has occured, exit |
|
- | 80 | test eax, eax |
|
- | 81 | jz child_exited |
|
67 | ret |
82 | mov ecx, eax |
- | 83 | ; wait |
|
- | 84 | wait_for_termination: |
|
- | 85 | mcall 5, 1 |
|
- | 86 | mov ebx, processinfo |
|
- | 87 | mcall 9 |
|
- | 88 | cmp word [ebx+50], 9 ; the slot was freed? |
|
- | 89 | jz child_exited |
|
- | 90 | cmp dword [ebx+30], esi ; the slot is still occupied by our child? |
|
- | 91 | jz wait_for_termination |
|
- | 92 | child_exited: |
|
Line 68... | Line 93... | ||
68 | 93 | ret |
|
69 | 94 | ||
Line 70... | Line 95... | ||
70 | clear_strings: ; clears buffers |
95 | clear_strings: ; clears buffers |
Line 89... | Line 114... | ||
89 | mov esi, [position] |
114 | mov esi, [position] |
90 | ;dpd esi |
115 | ;dpd esi |
91 | ;dps <13,10> |
116 | ;dps <13,10> |
92 | add esi, file_data |
117 | add esi, file_data |
93 | .start: |
118 | .start: |
- | 119 | cmp esi, [fileend] |
|
- | 120 | jae exit |
|
94 | lodsb |
121 | lodsb |
95 | cmp al, ' ' |
122 | cmp al, ' ' |
96 | je .finish |
123 | je .finish |
97 | stosb |
124 | stosb |
98 | inc [position] |
125 | inc [position] |
Line 106... | Line 133... | ||
106 | push ebx esi |
133 | push ebx esi |
107 | call skip_spaces |
134 | call skip_spaces |
108 | mov esi, [position] |
135 | mov esi, [position] |
109 | add esi, file_data |
136 | add esi, file_data |
110 | xor eax, eax |
137 | xor eax, eax |
- | 138 | cmp byte [esi], '-' |
|
- | 139 | jnz @f |
|
- | 140 | inc eax |
|
- | 141 | inc esi |
|
- | 142 | inc [position] |
|
- | 143 | @@: |
|
- | 144 | push eax |
|
- | 145 | xor eax, eax |
|
111 | xor ebx, ebx |
146 | xor ebx, ebx |
112 | .start: |
147 | .start: |
- | 148 | cmp esi, [fileend] |
|
- | 149 | jae .finish |
|
113 | lodsb |
150 | lodsb |
114 | sub al, '0' |
151 | sub al, '0' |
115 | cmp al, 9 |
152 | cmp al, 9 |
116 | ja .finish |
153 | ja .finish |
117 | lea ebx,[ebx*4+ebx] |
154 | lea ebx,[ebx*4+ebx] |
118 | lea ebx,[ebx*2+eax] |
155 | lea ebx,[ebx*2+eax] |
119 | inc [position] |
156 | inc [position] |
120 | jmp .start |
157 | jmp .start |
121 | .finish: |
158 | .finish: |
- | 159 | pop eax |
|
- | 160 | dec eax |
|
- | 161 | jnz @f |
|
- | 162 | neg ebx |
|
- | 163 | @@: |
|
122 | mov eax, ebx |
164 | mov eax, ebx |
123 | pop esi ebx |
165 | pop esi ebx |
124 | ret |
166 | ret |
Line 125... | Line 167... | ||
125 | 167 | ||
126 | 168 | ||
127 | skip_spaces: |
169 | skip_spaces: |
128 | pushad |
170 | push esi |
129 | xor eax, eax |
171 | xor eax, eax |
130 | mov esi, [position] |
172 | mov esi, [position] |
- | 173 | add esi, file_data |
|
- | 174 | .start: |
|
131 | add esi, file_data |
175 | cmp esi, [fileend] |
132 | .start: |
176 | jae .finish |
133 | lodsb |
177 | lodsb |
134 | cmp al, ' ' |
178 | cmp al, ' ' |
135 | jne .finish |
179 | jne .finish |
Line 139... | Line 183... | ||
139 | ;dps "NOW AL = " |
183 | ;dps "NOW AL = " |
140 | ;mov [tmp],al |
184 | ;mov [tmp],al |
141 | ;mov edx, tmp |
185 | ;mov edx, tmp |
142 | ;call debug_outstr |
186 | ;call debug_outstr |
143 | ;dps <13,10> |
187 | ;dps <13,10> |
144 | popad |
188 | pop esi |
145 | ret |
189 | ret |
Line 146... | Line 190... | ||
146 | 190 | ||
147 | - | ||
148 | next_line: |
191 | |
149 | pushad |
192 | next_line: |
150 | mov esi, [position] |
193 | mov esi, [position] |
- | 194 | add esi, file_data |
|
- | 195 | .start: |
|
151 | add esi, file_data |
196 | cmp esi, [fileend] |
152 | .start: |
197 | jae exit |
153 | lodsb |
198 | lodsb |
- | 199 | cmp al, 13 |
|
- | 200 | je .finish |
|
154 | cmp al, 13 |
201 | cmp al, 10 |
155 | je .finish |
202 | je .finish |
156 | inc [position] |
203 | inc [position] |
157 | jmp .start |
204 | jmp .start |
- | 205 | .finish: |
|
158 | .finish: |
206 | inc [position] |
159 | add [position], 2 |
207 | cmp esi, [fileend] |
160 | inc esi |
- | |
161 | lodsb |
- | |
162 | cmp al, '#' |
208 | jae exit |
163 | je .skipline |
209 | lodsb |
164 | cmp al, 13 |
210 | cmp al, 13 |
165 | jne .donotskip |
211 | je .finish |
166 | .skipline: |
- | |
167 | call next_line |
- | |
168 | .donotskip: |
212 | cmp al, 10 |
Line 169... | Line 213... | ||
169 | popad |
213 | je .finish |
Line 193... | Line 237... | ||
193 | I_END: |
237 | I_END: |
Line 194... | Line 238... | ||
194 | 238 | ||
195 | program rb 61 ; 60 + [0] char |
239 | program rb 61 ; 60 + [0] char |
Line -... | Line 240... | ||
- | 240 | parameters rb 61 |
|
196 | parameters rb 61 |
241 | |
Line 197... | Line 242... | ||
197 | 242 | processinfo rb 1024 |