Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
31 | halyavin | 1 | |
2 | ; Copyright (c) 1999-2005, Tomasz Grysztar. |
||
3 | ; All rights reserved. |
||
4 | |||
5 | |||
6 | mov ecx,[memory_end] |
||
7 | mov edi,[labels_list] |
||
8 | sub ecx,edi |
||
9 | cmp edi,[code_start] |
||
10 | jbe out_of_memory |
||
11 | shr ecx,2 |
||
12 | xor eax,eax |
||
13 | rep stos dword [edi] |
||
14 | mov [stub_size],eax |
||
15 | mov [number_of_sections],eax |
||
16 | mov [current_pass],ax |
||
17 | assembler_loop: |
||
18 | mov eax,[labels_list] |
||
19 | mov [display_buffer],eax |
||
20 | mov eax,[additional_memory] |
||
21 | mov [free_additional_memory],eax |
||
22 | mov eax,[additional_memory_end] |
||
23 | mov [structures_buffer],eax |
||
24 | mov esi,[source_start] |
||
25 | mov edi,[code_start] |
||
26 | xor eax,eax |
||
27 | mov dword [adjustment],eax |
||
28 | mov dword [adjustment+4],eax |
||
29 | mov dword [org_origin],edi |
||
30 | mov dword [org_origin+4],eax |
||
31 | mov [org_start],edi |
||
32 | mov [org_registers],eax |
||
33 | mov [org_symbol],eax |
||
34 | mov [error_line],eax |
||
35 | mov [counter],eax |
||
36 | mov [format_flags],eax |
||
37 | mov [number_of_relocations],eax |
||
38 | mov [undefined_data_end],eax |
||
39 | mov [next_pass_needed],al |
||
40 | mov [output_format],al |
||
41 | mov [labels_type],al |
||
42 | mov [virtual_data],al |
||
43 | mov [code_type],16 |
||
44 | pass_loop: |
||
45 | call assemble_line |
||
46 | jnc pass_loop |
||
47 | mov eax,[additional_memory_end] |
||
48 | cmp eax,[structures_buffer] |
||
49 | je pass_done |
||
50 | sub eax,20h |
||
51 | mov eax,[eax+4] |
||
52 | mov [current_line],eax |
||
53 | jmp missing_end_directive |
||
54 | pass_done: |
||
55 | call close_pass |
||
56 | mov eax,[labels_list] |
||
57 | check_symbols: |
||
58 | cmp eax,[memory_end] |
||
59 | jae symbols_checked |
||
60 | test byte [eax+8],8 |
||
61 | jz symbol_defined_ok |
||
62 | mov cx,[current_pass] |
||
63 | cmp cx,[eax+18] |
||
64 | jne symbol_defined_ok |
||
65 | test byte [eax+8],1 |
||
66 | jz symbol_defined_ok |
||
67 | sub cx,[eax+16] |
||
68 | cmp cx,1 |
||
69 | jne symbol_defined_ok |
||
70 | and byte [eax+8],not 1 |
||
71 | or [next_pass_needed],-1 |
||
72 | symbol_defined_ok: |
||
73 | test byte [eax+8],10h |
||
74 | jz use_prediction_ok |
||
75 | mov cx,[current_pass] |
||
76 | and byte [eax+8],not 10h |
||
77 | test byte [eax+8],20h |
||
78 | jnz check_use_prediction |
||
79 | cmp cx,[eax+18] |
||
80 | jne use_prediction_ok |
||
81 | test byte [eax+8],8 |
||
82 | jz use_prediction_ok |
||
83 | jmp use_misprediction |
||
84 | check_use_prediction: |
||
85 | test byte [eax+8],8 |
||
86 | jz use_misprediction |
||
87 | cmp cx,[eax+18] |
||
88 | je use_prediction_ok |
||
89 | use_misprediction: |
||
90 | or [next_pass_needed],-1 |
||
91 | use_prediction_ok: |
||
92 | test byte [eax+8],40h |
||
93 | jz check_next_symbol |
||
94 | and byte [eax+8],not 40h |
||
95 | test byte [eax+8],4 |
||
96 | jnz define_misprediction |
||
97 | mov cx,[current_pass] |
||
98 | test byte [eax+8],80h |
||
99 | jnz check_define_prediction |
||
100 | cmp cx,[eax+16] |
||
101 | jne check_next_symbol |
||
102 | test byte [eax+8],1 |
||
103 | jz check_next_symbol |
||
104 | jmp define_misprediction |
||
105 | check_define_prediction: |
||
106 | test byte [eax+8],1 |
||
107 | jz define_misprediction |
||
108 | cmp cx,[eax+16] |
||
109 | je check_next_symbol |
||
110 | define_misprediction: |
||
111 | or [next_pass_needed],-1 |
||
112 | check_next_symbol: |
||
113 | add eax,24 |
||
114 | jmp check_symbols |
||
115 | symbols_checked: |
||
116 | cmp [next_pass_needed],0 |
||
117 | jne next_pass |
||
118 | mov eax,[error_line] |
||
119 | or eax,eax |
||
120 | jz assemble_ok |
||
121 | mov [current_line],eax |
||
122 | jmp near [error] |
||
123 | next_pass: |
||
124 | inc [current_pass] |
||
125 | mov ax,[current_pass] |
||
126 | cmp ax,[passes_limit] |
||
127 | je code_cannot_be_generated |
||
128 | jmp assembler_loop |
||
129 | assemble_ok: |
||
130 | ret |
||
131 | |||
132 | |||
133 | mov eax,[display_buffer] |
||
134 | sub eax,100h |
||
135 | cmp edi,eax |
||
136 | ja out_of_memory |
||
137 | lods byte [esi] |
||
138 | cmp al,1 |
||
139 | je assemble_instruction |
||
140 | jb source_end |
||
141 | cmp al,3 |
||
142 | jb define_label |
||
143 | je define_constant |
||
144 | cmp al,0Fh |
||
145 | je new_line |
||
146 | cmp al,13h |
||
147 | je code_type_setting |
||
148 | cmp al,10h |
||
149 | jne illegal_instruction |
||
150 | lods byte [esi] |
||
151 | jmp segment_prefix |
||
152 | code_type_setting: |
||
153 | lods byte [esi] |
||
154 | mov [code_type],al |
||
155 | jmp line_assembled |
||
156 | new_line: |
||
157 | lods dword [esi] |
||
158 | mov [current_line],eax |
||
159 | mov [prefixed_instruction],0 |
||
160 | continue_line: |
||
161 | cmp byte [esi],0Fh |
||
162 | je line_assembled |
||
163 | jmp assemble_line |
||
164 | define_label: |
||
165 | lods dword [esi] |
||
166 | cmp eax,0Fh |
||
167 | jb invalid_use_of_symbol |
||
168 | je reserved_word_used_as_symbol |
||
169 | mov ebx,eax |
||
170 | lods byte [esi] |
||
171 | mov cl,al |
||
172 | mov eax,edi |
||
173 | xor edx,edx |
||
174 | sub eax,dword [org_origin] |
||
175 | sbb edx,dword [org_origin+4] |
||
176 | mov ch,[labels_type] |
||
177 | cmp [virtual_data],0 |
||
178 | jne make_virtual_label |
||
179 | or byte [ebx+9],1 |
||
180 | xchg eax,[ebx] |
||
181 | xchg edx,[ebx+4] |
||
182 | sub eax,[ebx] |
||
183 | sbb edx,[ebx+4] |
||
184 | mov dword [adjustment],eax |
||
185 | mov dword [adjustment+4],edx |
||
186 | or eax,edx |
||
187 | setnz ah |
||
188 | jmp finish_label_symbol |
||
189 | make_virtual_label: |
||
190 | and byte [ebx+9],not 1 |
||
191 | cmp eax,[ebx] |
||
192 | mov [ebx],eax |
||
193 | setne ah |
||
194 | cmp edx,[ebx+4] |
||
195 | mov [ebx+4],edx |
||
196 | setne al |
||
197 | or ah,al |
||
198 | finish_label_symbol: |
||
199 | cmp cl,[ebx+10] |
||
200 | mov [ebx+10],cl |
||
201 | setne al |
||
202 | or ah,al |
||
203 | cmp ch,[ebx+11] |
||
204 | mov [ebx+11],ch |
||
205 | setne al |
||
206 | or ah,al |
||
207 | mov edx,[org_registers] |
||
208 | cmp edx,[ebx+12] |
||
209 | mov [ebx+12],edx |
||
210 | setne al |
||
211 | or ah,al |
||
212 | or ch,ch |
||
213 | jz label_symbol_ok |
||
214 | mov edx,[org_symbol] |
||
215 | cmp edx,[ebx+20] |
||
216 | mov [ebx+20],edx |
||
217 | setne al |
||
218 | or ah,al |
||
219 | label_symbol_ok: |
||
220 | mov cx,[current_pass] |
||
221 | xchg [ebx+16],cx |
||
222 | and byte [ebx+8],not 2 |
||
223 | test byte [ebx+8],1 |
||
224 | jz new_label |
||
225 | cmp cx,[ebx+16] |
||
226 | je symbol_already_defined |
||
227 | inc cx |
||
228 | sub cx,[ebx+16] |
||
229 | setnz al |
||
230 | or ah,al |
||
231 | jz continue_line |
||
232 | test byte [ebx+8],8 |
||
233 | jz continue_line |
||
234 | mov cx,[current_pass] |
||
235 | cmp cx,[ebx+18] |
||
236 | jne continue_line |
||
237 | or [next_pass_needed],-1 |
||
238 | jmp continue_line |
||
239 | new_label: |
||
240 | or byte [ebx+8],1 |
||
241 | jmp continue_line |
||
242 | define_constant: |
||
243 | lods dword [esi] |
||
244 | inc esi |
||
245 | cmp eax,0Fh |
||
246 | jb invalid_use_of_symbol |
||
247 | je reserved_word_used_as_symbol |
||
248 | mov edx,[eax+8] |
||
249 | push edx |
||
250 | cmp [current_pass],0 |
||
251 | je get_constant_value |
||
252 | test dl,4 |
||
253 | jnz get_constant_value |
||
254 | mov cx,[current_pass] |
||
255 | cmp cx,[eax+16] |
||
256 | je get_constant_value |
||
257 | and dl,not 1 |
||
258 | mov [eax+8],dl |
||
259 | get_constant_value: |
||
260 | push eax |
||
261 | mov al,byte [esi-1] |
||
262 | push eax |
||
263 | call get_value |
||
264 | pop ebx |
||
265 | mov ch,bl |
||
266 | pop ebx |
||
267 | pop dword [ebx+8] |
||
268 | cmp ebx,0Fh |
||
269 | jb invalid_use_of_symbol |
||
270 | je reserved_word_used_as_symbol |
||
271 | xor cl,cl |
||
272 | mov ch,[value_type] |
||
273 | cmp ch,3 |
||
274 | je invalid_use_of_symbol |
||
275 | make_constant: |
||
276 | and byte [ebx+9],not 1 |
||
277 | cmp eax,[ebx] |
||
278 | mov [ebx],eax |
||
279 | setne ah |
||
280 | cmp edx,[ebx+4] |
||
281 | mov [ebx+4],edx |
||
282 | setne al |
||
283 | or ah,al |
||
284 | cmp cl,[ebx+10] |
||
285 | mov [ebx+10],cl |
||
286 | setne al |
||
287 | or ah,al |
||
288 | cmp ch,[ebx+11] |
||
289 | mov [ebx+11],ch |
||
290 | setne al |
||
291 | or ah,al |
||
292 | xor edx,edx |
||
293 | cmp edx,[ebx+12] |
||
294 | mov [ebx+12],edx |
||
295 | setne al |
||
296 | or ah,al |
||
297 | or ch,ch |
||
298 | jz constant_symbol_ok |
||
299 | mov edx,[symbol_identifier] |
||
300 | cmp edx,[ebx+20] |
||
301 | mov [ebx+20],edx |
||
302 | setne al |
||
303 | or ah,al |
||
304 | constant_symbol_ok: |
||
305 | mov cx,[current_pass] |
||
306 | xchg [ebx+16],cx |
||
307 | test byte [ebx+8],1 |
||
308 | jz new_constant |
||
309 | cmp cx,[ebx+16] |
||
310 | jne redeclare_constant |
||
311 | test byte [ebx+8],2 |
||
312 | jz symbol_already_defined |
||
313 | or byte [ebx+8],4 |
||
314 | jmp instruction_assembled |
||
315 | redeclare_constant: |
||
316 | inc cx |
||
317 | sub cx,[ebx+16] |
||
318 | setnz al |
||
319 | or ah,al |
||
320 | jz instruction_assembled |
||
321 | test byte [ebx+8],4 |
||
322 | jnz instruction_assembled |
||
323 | test byte [ebx+8],8 |
||
324 | jz instruction_assembled |
||
325 | mov cx,[current_pass] |
||
326 | cmp cx,[ebx+18] |
||
327 | jne instruction_assembled |
||
328 | or [next_pass_needed],-1 |
||
329 | jmp instruction_assembled |
||
330 | new_constant: |
||
331 | or byte [ebx+8],1+2 |
||
332 | jmp instruction_assembled |
||
333 | assemble_instruction: |
||
334 | mov [operand_size],0 |
||
335 | mov [size_override],0 |
||
336 | mov [operand_prefix],0 |
||
337 | mov [rex_prefix],0 |
||
338 | mov [immediate_size],0 |
||
339 | movzx ebx,word [esi] |
||
340 | mov al,[esi+2] |
||
341 | add ebx,assembler |
||
342 | add esi,3 |
||
343 | jmp near ebx |
||
344 | instruction_assembled: |
||
345 | mov al,[esi] |
||
346 | cmp al,0Fh |
||
347 | je line_assembled |
||
348 | or al,al |
||
349 | jnz extra_characters_on_line |
||
350 | line_assembled: |
||
351 | clc |
||
352 | ret |
||
353 | source_end: |
||
354 | dec esi |
||
355 | stc |
||
356 | ret |
||
357 | skip_line: |
||
358 | call skip_symbol |
||
359 | jnc skip_line |
||
360 | ret |
||
361 | skip_symbol: |
||
362 | lods byte [esi] |
||
363 | or al,al |
||
364 | jz nothing_to_skip |
||
365 | cmp al,0Fh |
||
366 | je nothing_to_skip |
||
367 | cmp al,1 |
||
368 | je skip_instruction |
||
369 | cmp al,2 |
||
370 | je skip_label |
||
371 | cmp al,3 |
||
372 | je skip_label |
||
373 | cmp al,20h |
||
374 | jb skip_assembler_symbol |
||
375 | cmp al,'(' |
||
376 | je skip_expression |
||
377 | cmp al,'[' |
||
378 | je skip_address |
||
379 | skip_done: |
||
380 | clc |
||
381 | ret |
||
382 | skip_label: |
||
383 | add esi,2 |
||
384 | skip_instruction: |
||
385 | add esi,2 |
||
386 | skip_assembler_symbol: |
||
387 | inc esi |
||
388 | jmp skip_done |
||
389 | skip_address: |
||
390 | mov al,[esi] |
||
391 | and al,11110000b |
||
392 | cmp al,60h |
||
393 | jb skip_expression |
||
394 | cmp al,70h |
||
395 | ja skip_expression |
||
396 | inc esi |
||
397 | jmp skip_address |
||
398 | skip_expression: |
||
399 | lods byte [esi] |
||
400 | or al,al |
||
401 | jz skip_string |
||
402 | cmp al,'.' |
||
403 | je skip_fp_value |
||
404 | cmp al,')' |
||
405 | je skip_done |
||
406 | cmp al,']' |
||
407 | je skip_done |
||
408 | cmp al,0Fh |
||
409 | je skip_expression |
||
410 | cmp al,10h |
||
411 | je skip_register |
||
412 | cmp al,11h |
||
413 | je skip_label_value |
||
414 | cmp al,80h |
||
415 | jae skip_expression |
||
416 | movzx eax,al |
||
417 | add esi,eax |
||
418 | jmp skip_expression |
||
419 | skip_label_value: |
||
420 | add esi,3 |
||
421 | skip_register: |
||
422 | inc esi |
||
423 | jmp skip_expression |
||
424 | skip_fp_value: |
||
425 | add esi,12 |
||
426 | jmp skip_done |
||
427 | skip_string: |
||
428 | lods dword [esi] |
||
429 | add esi,eax |
||
430 | inc esi |
||
431 | jmp skip_done |
||
432 | nothing_to_skip: |
||
433 | dec esi |
||
434 | stc |
||
435 | ret |
||
436 | |||
437 | |||
438 | lods byte [esi] |
||
439 | cmp al,'(' |
||
440 | jne invalid_argument |
||
441 | cmp byte [esi],'.' |
||
442 | je invalid_value |
||
443 | call get_qword_value |
||
444 | mov cl,[value_type] |
||
445 | test cl,1 |
||
446 | jnz invalid_use_of_symbol |
||
447 | mov [labels_type],cl |
||
448 | mov ecx,edi |
||
449 | sub ecx,eax |
||
450 | sbb edx,0 |
||
451 | mov dword [org_origin],ecx |
||
452 | mov dword [org_origin+4],edx |
||
453 | mov [org_registers],0 |
||
454 | mov [org_start],edi |
||
455 | mov edx,[symbol_identifier] |
||
456 | mov [org_symbol],edx |
||
457 | cmp [output_format],1 |
||
458 | ja instruction_assembled |
||
459 | cmp edi,[code_start] |
||
460 | jne instruction_assembled |
||
461 | cmp eax,100h |
||
462 | jne instruction_assembled |
||
463 | bts [format_flags],0 |
||
464 | jmp instruction_assembled |
||
465 | label_directive: |
||
466 | lods byte [esi] |
||
467 | cmp al,2 |
||
468 | jne invalid_argument |
||
469 | lods dword [esi] |
||
470 | cmp eax,0Fh |
||
471 | jb invalid_use_of_symbol |
||
472 | je reserved_word_used_as_symbol |
||
473 | inc esi |
||
474 | mov ebx,eax |
||
475 | xor cl,cl |
||
476 | lods byte [esi] |
||
477 | cmp al,':' |
||
478 | je get_label_size |
||
479 | dec esi |
||
480 | cmp al,11h |
||
481 | jne label_size_ok |
||
482 | get_label_size: |
||
483 | lods word [esi] |
||
484 | cmp al,11h |
||
485 | jne invalid_argument |
||
486 | mov cl,ah |
||
487 | label_size_ok: |
||
488 | mov eax,edi |
||
489 | xor edx,edx |
||
490 | sub eax,dword [org_origin] |
||
491 | sbb edx,dword [org_origin+4] |
||
492 | mov ebp,[org_registers] |
||
493 | cmp byte [esi],80h |
||
494 | je get_free_label_value |
||
495 | mov ch,[labels_type] |
||
496 | push [org_symbol] |
||
497 | pop [address_symbol] |
||
498 | cmp [virtual_data],0 |
||
499 | jne make_free_label |
||
500 | or byte [ebx+9],1 |
||
501 | xchg eax,[ebx] |
||
502 | xchg edx,[ebx+4] |
||
503 | sub eax,[ebx] |
||
504 | sbb edx,[ebx+4] |
||
505 | mov dword [adjustment],eax |
||
506 | mov dword [adjustment+4],edx |
||
507 | or eax,edx |
||
508 | setne ah |
||
509 | jmp finish_label |
||
510 | get_free_label_value: |
||
511 | inc esi |
||
512 | lods byte [esi] |
||
513 | cmp al,'(' |
||
514 | jne invalid_argument |
||
515 | push dword [ebx+8] |
||
516 | push ebx ecx |
||
517 | and byte [ebx+8],not 1 |
||
518 | cmp byte [esi],'.' |
||
519 | je invalid_value |
||
520 | call get_address_value |
||
521 | or bh,bh |
||
522 | setnz ch |
||
523 | xchg ch,cl |
||
524 | mov bp,cx |
||
525 | shl ebp,16 |
||
526 | xchg bl,bh |
||
527 | mov bp,bx |
||
528 | pop ecx ebx |
||
529 | pop dword [ebx+8] |
||
530 | mov ch,[value_type] |
||
531 | or ch,ch |
||
532 | jz make_free_label |
||
533 | cmp ch,2 |
||
534 | jne invalid_use_of_symbol |
||
535 | make_free_label: |
||
536 | and byte [ebx+9],not 1 |
||
537 | cmp eax,[ebx] |
||
538 | mov [ebx],eax |
||
539 | setne ah |
||
540 | cmp edx,[ebx+4] |
||
541 | mov [ebx+4],edx |
||
542 | setne al |
||
543 | or ah,al |
||
544 | jmp finish_label |
||
545 | finish_label: |
||
546 | cmp cl,[ebx+10] |
||
547 | mov [ebx+10],cl |
||
548 | setne al |
||
549 | or ah,al |
||
550 | cmp ch,[ebx+11] |
||
551 | mov [ebx+11],ch |
||
552 | setne al |
||
553 | or ah,al |
||
554 | cmp ebp,[ebx+12] |
||
555 | mov [ebx+12],ebp |
||
556 | setne al |
||
557 | or ah,al |
||
558 | or ch,ch |
||
559 | jz free_label_symbol_ok |
||
560 | mov edx,[address_symbol] |
||
561 | cmp edx,[ebx+20] |
||
562 | mov [ebx+20],edx |
||
563 | setne al |
||
564 | or ah,al |
||
565 | free_label_symbol_ok: |
||
566 | mov cx,[current_pass] |
||
567 | xchg [ebx+16],cx |
||
568 | and byte [ebx+8],not 2 |
||
569 | test byte [ebx+8],1 |
||
570 | jz new_free_label |
||
571 | cmp cx,[ebx+16] |
||
572 | je symbol_already_defined |
||
573 | inc cx |
||
574 | sub cx,[ebx+16] |
||
575 | setnz al |
||
576 | or ah,al |
||
577 | jz instruction_assembled |
||
578 | test byte [ebx+8],8 |
||
579 | jz instruction_assembled |
||
580 | mov cx,[current_pass] |
||
581 | cmp cx,[ebx+18] |
||
582 | jne instruction_assembled |
||
583 | or [next_pass_needed],-1 |
||
584 | jmp instruction_assembled |
||
585 | new_free_label: |
||
586 | or byte [ebx+8],1 |
||
587 | jmp instruction_assembled |
||
588 | load_directive: |
||
589 | lods byte [esi] |
||
590 | cmp al,2 |
||
591 | jne invalid_argument |
||
592 | lods dword [esi] |
||
593 | cmp eax,0Fh |
||
594 | jb invalid_use_of_symbol |
||
595 | je reserved_word_used_as_symbol |
||
596 | inc esi |
||
597 | push eax |
||
598 | mov al,1 |
||
599 | cmp byte [esi],11h |
||
600 | jne load_size_ok |
||
601 | lods byte [esi] |
||
602 | lods byte [esi] |
||
603 | load_size_ok: |
||
604 | cmp al,8 |
||
605 | ja invalid_value |
||
606 | mov [operand_size],al |
||
607 | mov dword [value],0 |
||
608 | mov dword [value+4],0 |
||
609 | lods word [esi] |
||
610 | cmp ax,82h+'(' shl 8 |
||
611 | jne invalid_argument |
||
612 | load_from_code: |
||
613 | cmp byte [esi],'.' |
||
614 | je invalid_value |
||
615 | call get_relative_offset |
||
616 | neg eax |
||
617 | cmp [next_pass_needed],0 |
||
618 | jne load_address_ok |
||
619 | cmp [value_type],0 |
||
620 | jne invalid_use_of_symbol |
||
621 | load_address_ok: |
||
622 | push esi edi |
||
623 | mov esi,edi |
||
624 | sub esi,eax |
||
625 | jc bad_load_address |
||
626 | cmp esi,[org_start] |
||
627 | jb bad_load_address |
||
628 | mov edi,value |
||
629 | movzx ecx,[operand_size] |
||
630 | cmp ecx,eax |
||
631 | ja bad_load_address |
||
632 | rep movs byte [edi],[esi] |
||
633 | jmp value_loaded |
||
634 | bad_load_address: |
||
635 | cmp [error_line],0 |
||
636 | jne value_loaded |
||
637 | mov eax,[current_line] |
||
638 | mov [error_line],eax |
||
639 | mov [error],value_out_of_range |
||
640 | value_loaded: |
||
641 | pop edi esi |
||
642 | mov eax,dword [value] |
||
643 | mov edx,dword [value+4] |
||
644 | pop ebx |
||
645 | xor cx,cx |
||
646 | jmp make_constant |
||
647 | store_directive: |
||
648 | cmp byte [esi],11h |
||
649 | je sized_store |
||
650 | lods byte [esi] |
||
651 | cmp al,'(' |
||
652 | jne invalid_argument |
||
653 | call get_byte_value |
||
654 | xor edx,edx |
||
655 | movzx eax,al |
||
656 | mov [operand_size],1 |
||
657 | jmp store_value_ok |
||
658 | sized_store: |
||
659 | call get_value |
||
660 | store_value_ok: |
||
661 | cmp [value_type],0 |
||
662 | jne invalid_use_of_symbol |
||
663 | mov dword [value],eax |
||
664 | mov dword [value+4],edx |
||
665 | lods word [esi] |
||
666 | cmp ax,80h+'(' shl 8 |
||
667 | jne invalid_argument |
||
668 | cmp byte [esi],'.' |
||
669 | je invalid_value |
||
670 | call get_relative_offset |
||
671 | neg eax |
||
672 | cmp [next_pass_needed],0 |
||
673 | jne store_address_ok |
||
674 | cmp [value_type],0 |
||
675 | jne invalid_use_of_symbol |
||
676 | store_address_ok: |
||
677 | push esi edi |
||
678 | sub edi,eax |
||
679 | jc bad_store_address |
||
680 | cmp edi,[org_start] |
||
681 | jb bad_store_address |
||
682 | mov esi,value |
||
683 | movzx ecx,[operand_size] |
||
684 | cmp ecx,eax |
||
685 | ja bad_store_address |
||
686 | rep movs byte [edi],[esi] |
||
687 | mov eax,edi |
||
688 | pop edi esi |
||
689 | cmp edi,[undefined_data_end] |
||
690 | jne instruction_assembled |
||
691 | cmp eax,[undefined_data_start] |
||
692 | jbe instruction_assembled |
||
693 | mov [undefined_data_start],eax |
||
694 | jmp instruction_assembled |
||
695 | bad_store_address: |
||
696 | pop edi esi |
||
697 | cmp [error_line],0 |
||
698 | jne instruction_assembled |
||
699 | mov eax,[current_line] |
||
700 | mov [error_line],eax |
||
701 | mov [error],value_out_of_range |
||
702 | jmp instruction_assembled |
||
703 | |||
704 | |||
705 | lods byte [esi] |
||
706 | cmp al,'(' |
||
707 | jne invalid_argument |
||
708 | cmp byte [esi],0 |
||
709 | jne display_byte |
||
710 | inc esi |
||
711 | lods dword [esi] |
||
712 | mov ecx,eax |
||
713 | push edi |
||
714 | mov edi,[display_buffer] |
||
715 | sub edi,4 |
||
716 | sub edi,eax |
||
717 | mov [display_buffer],edi |
||
718 | rep movs byte [edi],[esi] |
||
719 | stos dword [edi] |
||
720 | pop edi |
||
721 | inc esi |
||
722 | jmp display_next |
||
723 | display_byte: |
||
724 | call get_byte_value |
||
725 | push edi |
||
726 | mov edi,[display_buffer] |
||
727 | sub edi,4+1 |
||
728 | mov [display_buffer],edi |
||
729 | stos byte [edi] |
||
730 | mov eax,1 |
||
731 | stos dword [edi] |
||
732 | pop edi |
||
733 | display_next: |
||
734 | cmp edi,[display_buffer] |
||
735 | ja out_of_memory |
||
736 | lods byte [esi] |
||
737 | cmp al,',' |
||
738 | je display_directive |
||
739 | dec esi |
||
740 | jmp instruction_assembled |
||
741 | flush_display_buffer: |
||
742 | mov eax,[display_buffer] |
||
743 | or eax,eax |
||
744 | jz display_done |
||
745 | mov esi,[labels_list] |
||
746 | cmp esi,eax |
||
747 | je display_done |
||
748 | display_messages: |
||
749 | sub esi,4 |
||
750 | mov ecx,[esi] |
||
751 | sub esi,ecx |
||
752 | push esi |
||
753 | call display_block |
||
754 | pop esi |
||
755 | cmp esi,[display_buffer] |
||
756 | jne display_messages |
||
757 | mov eax,[labels_list] |
||
758 | mov [display_buffer],eax |
||
759 | display_done: |
||
760 | ret |
||
761 | times_directive: |
||
762 | lods byte [esi] |
||
763 | cmp al,'(' |
||
764 | jne invalid_argument |
||
765 | cmp byte [esi],'.' |
||
766 | je invalid_value |
||
767 | call get_dword_value |
||
768 | cmp [next_pass_needed],0 |
||
769 | jne times_value_ok |
||
770 | cmp [value_type],0 |
||
771 | jne invalid_use_of_symbol |
||
772 | times_value_ok: |
||
773 | cmp eax,0 |
||
774 | je zero_times |
||
775 | jl negative_times |
||
776 | cmp byte [esi],':' |
||
777 | jne times_argument_ok |
||
778 | inc esi |
||
779 | times_argument_ok: |
||
780 | push [counter] |
||
781 | push [counter_limit] |
||
782 | mov [counter_limit],eax |
||
783 | mov [counter],1 |
||
784 | times_loop: |
||
785 | mov eax,esp |
||
786 | sub eax,100h |
||
787 | jc stack_overflow |
||
788 | cmp eax,[stack_limit] |
||
789 | jb stack_overflow |
||
790 | push esi |
||
791 | or [prefixed_instruction],-1 |
||
792 | call continue_line |
||
793 | mov eax,[counter_limit] |
||
794 | cmp [counter],eax |
||
795 | je times_done |
||
796 | inc [counter] |
||
797 | pop esi |
||
798 | jmp times_loop |
||
799 | times_done: |
||
800 | pop eax |
||
801 | pop [counter_limit] |
||
802 | pop [counter] |
||
803 | jmp instruction_assembled |
||
804 | negative_times: |
||
805 | cmp [error_line],0 |
||
806 | jne zero_times |
||
807 | mov eax,[current_line] |
||
808 | mov [error_line],eax |
||
809 | mov [error],invalid_value |
||
810 | zero_times: |
||
811 | call skip_line |
||
812 | jmp instruction_assembled |
||
813 | |||
814 | |||
815 | lods byte [esi] |
||
816 | cmp al,80h |
||
817 | jne virtual_at_current |
||
818 | lods byte [esi] |
||
819 | cmp al,'(' |
||
820 | jne invalid_argument |
||
821 | cmp byte [esi],'.' |
||
822 | je invalid_value |
||
823 | call get_address_value |
||
824 | mov ebp,[address_symbol] |
||
825 | xor ch,ch |
||
826 | or bh,bh |
||
827 | jz set_virtual |
||
828 | mov ch,1 |
||
829 | jmp set_virtual |
||
830 | virtual_at_current: |
||
831 | dec esi |
||
832 | mov al,[labels_type] |
||
833 | mov [value_type],al |
||
834 | mov ebp,[org_symbol] |
||
835 | mov eax,edi |
||
836 | xor edx,edx |
||
837 | sub eax,dword [org_origin] |
||
838 | sbb edx,dword [org_origin+4] |
||
839 | xor bx,bx |
||
840 | xor cx,cx |
||
841 | set_virtual: |
||
842 | push [org_registers] |
||
843 | mov byte [org_registers],bh |
||
844 | mov byte [org_registers+1],bl |
||
845 | mov byte [org_registers+2],ch |
||
846 | mov byte [org_registers+3],cl |
||
847 | call allocate_structure_data |
||
848 | mov word [ebx],virtual_directive-assembler |
||
849 | not eax |
||
850 | not edx |
||
851 | add eax,1 |
||
852 | adc edx,0 |
||
853 | add eax,edi |
||
854 | adc edx,0 |
||
855 | xchg dword [org_origin],eax |
||
856 | xchg dword [org_origin+4],edx |
||
857 | mov [ebx+10h],eax |
||
858 | mov [ebx+14h],edx |
||
859 | pop eax |
||
860 | mov [ebx+18h],eax |
||
861 | mov al,[virtual_data] |
||
862 | mov [ebx+2],al |
||
863 | mov al,[labels_type] |
||
864 | mov [ebx+3],al |
||
865 | mov eax,edi |
||
866 | xchg eax,[org_start] |
||
867 | mov [ebx+0Ch],eax |
||
868 | xchg ebp,[org_symbol] |
||
869 | mov [ebx+1Ch],ebp |
||
870 | mov [ebx+8],edi |
||
871 | mov eax,[current_line] |
||
872 | mov [ebx+4],eax |
||
873 | or [virtual_data],-1 |
||
874 | mov al,[value_type] |
||
875 | test al,1 |
||
876 | jnz invalid_use_of_symbol |
||
877 | mov [labels_type],al |
||
878 | jmp instruction_assembled |
||
879 | allocate_structure_data: |
||
880 | mov ebx,[structures_buffer] |
||
881 | sub ebx,20h |
||
882 | cmp ebx,[free_additional_memory] |
||
883 | jb out_of_memory |
||
884 | mov [structures_buffer],ebx |
||
885 | ret |
||
886 | find_structure_data: |
||
887 | mov ebx,[structures_buffer] |
||
888 | scan_structures: |
||
889 | cmp ebx,[additional_memory_end] |
||
890 | je no_such_structure |
||
891 | cmp ax,[ebx] |
||
892 | jne next_structure |
||
893 | clc |
||
894 | ret |
||
895 | next_structure: |
||
896 | cmp ax,if_directive-assembler |
||
897 | je check_structure_overlapping |
||
898 | cmp ax,repeat_directive-assembler |
||
899 | je check_structure_overlapping |
||
900 | cmp ax,while_directive-assembler |
||
901 | je check_structure_overlapping |
||
902 | add ebx,20h |
||
903 | jmp scan_structures |
||
904 | check_structure_overlapping: |
||
905 | cmp word [ebx],if_directive-assembler |
||
906 | je no_such_structure |
||
907 | cmp word [ebx],repeat_directive-assembler |
||
908 | je no_such_structure |
||
909 | cmp word [ebx],while_directive-assembler |
||
910 | je no_such_structure |
||
911 | add ebx,20h |
||
912 | jmp scan_structures |
||
913 | no_such_structure: |
||
914 | stc |
||
915 | ret |
||
916 | end_virtual: |
||
917 | call find_structure_data |
||
918 | jc unexpected_instruction |
||
919 | mov al,[ebx+2] |
||
920 | mov [virtual_data],al |
||
921 | mov al,[ebx+3] |
||
922 | mov [labels_type],al |
||
923 | mov eax,[ebx+10h] |
||
924 | mov dword [org_origin],eax |
||
925 | mov eax,[ebx+14h] |
||
926 | mov dword [org_origin+4],eax |
||
927 | mov eax,[ebx+18h] |
||
928 | mov [org_registers],eax |
||
929 | mov eax,[ebx+0Ch] |
||
930 | mov [org_start],eax |
||
931 | mov eax,[ebx+1Ch] |
||
932 | mov [org_symbol],eax |
||
933 | mov edi,[ebx+8] |
||
934 | remove_structure_data: |
||
935 | push esi edi |
||
936 | mov esi,[structures_buffer] |
||
937 | mov ecx,ebx |
||
938 | sub ecx,esi |
||
939 | lea edi,[esi+20h] |
||
940 | mov [structures_buffer],edi |
||
941 | shr ecx,2 |
||
942 | rep movs dword [edi],[esi] |
||
943 | pop edi esi |
||
944 | ret |
||
945 | repeat_directive: |
||
946 | cmp [prefixed_instruction],0 |
||
947 | jne unexpected_instruction |
||
948 | lods byte [esi] |
||
949 | cmp al,'(' |
||
950 | jne invalid_argument |
||
951 | cmp byte [esi],'.' |
||
952 | je invalid_value |
||
953 | call get_dword_value |
||
954 | cmp [next_pass_needed],0 |
||
955 | jne repeat_value_ok |
||
956 | cmp [value_type],0 |
||
957 | jne invalid_use_of_symbol |
||
958 | repeat_value_ok: |
||
959 | cmp eax,0 |
||
960 | je zero_repeat |
||
961 | jl negative_repeat |
||
962 | call allocate_structure_data |
||
963 | mov word [ebx],repeat_directive-assembler |
||
964 | xchg eax,[counter_limit] |
||
965 | mov [ebx+10h],eax |
||
966 | mov eax,1 |
||
967 | xchg eax,[counter] |
||
968 | mov [ebx+14h],eax |
||
969 | mov [ebx+8],esi |
||
970 | mov eax,[current_line] |
||
971 | mov [ebx+4],eax |
||
972 | jmp instruction_assembled |
||
973 | end_repeat: |
||
974 | cmp [prefixed_instruction],0 |
||
975 | jne unexpected_instruction |
||
976 | call find_structure_data |
||
977 | jc unexpected_instruction |
||
978 | mov eax,[counter_limit] |
||
979 | inc [counter] |
||
980 | cmp [counter],eax |
||
981 | jbe continue_repeating |
||
982 | stop_repeat: |
||
983 | mov eax,[ebx+10h] |
||
984 | mov [counter_limit],eax |
||
985 | mov eax,[ebx+14h] |
||
986 | mov [counter],eax |
||
987 | call remove_structure_data |
||
988 | jmp instruction_assembled |
||
989 | continue_repeating: |
||
990 | mov esi,[ebx+8] |
||
991 | jmp instruction_assembled |
||
992 | negative_repeat: |
||
993 | cmp [error_line],0 |
||
994 | jne zero_repeat |
||
995 | mov eax,[current_line] |
||
996 | mov [error_line],eax |
||
997 | mov [error],invalid_value |
||
998 | zero_repeat: |
||
999 | mov al,[esi] |
||
1000 | or al,al |
||
1001 | jz missing_end_directive |
||
1002 | cmp al,0Fh |
||
1003 | jne extra_characters_on_line |
||
1004 | call find_end_repeat |
||
1005 | jmp instruction_assembled |
||
1006 | find_end_repeat: |
||
1007 | call find_structure_end |
||
1008 | cmp ax,repeat_directive-assembler |
||
1009 | jne unexpected_instruction |
||
1010 | ret |
||
1011 | while_directive: |
||
1012 | cmp [prefixed_instruction],0 |
||
1013 | jne unexpected_instruction |
||
1014 | call allocate_structure_data |
||
1015 | mov word [ebx],while_directive-assembler |
||
1016 | mov eax,1 |
||
1017 | xchg eax,[counter] |
||
1018 | mov [ebx+10h],eax |
||
1019 | mov [ebx+8],esi |
||
1020 | mov eax,[current_line] |
||
1021 | mov [ebx+4],eax |
||
1022 | do_while: |
||
1023 | push ebx |
||
1024 | call calculate_logical_expression |
||
1025 | or al,al |
||
1026 | jnz while_true |
||
1027 | mov al,[esi] |
||
1028 | or al,al |
||
1029 | jz missing_end_directive |
||
1030 | cmp al,0Fh |
||
1031 | jne extra_characters_on_line |
||
1032 | stop_while: |
||
1033 | call find_end_while |
||
1034 | pop ebx |
||
1035 | mov eax,[ebx+10h] |
||
1036 | mov [counter],eax |
||
1037 | call remove_structure_data |
||
1038 | jmp instruction_assembled |
||
1039 | while_true: |
||
1040 | pop ebx |
||
1041 | jmp instruction_assembled |
||
1042 | end_while: |
||
1043 | cmp [prefixed_instruction],0 |
||
1044 | jne unexpected_instruction |
||
1045 | call find_structure_data |
||
1046 | jc unexpected_instruction |
||
1047 | mov eax,[ebx+4] |
||
1048 | mov [current_line],eax |
||
1049 | inc [counter] |
||
1050 | jz too_many_repeats |
||
1051 | mov esi,[ebx+8] |
||
1052 | jmp do_while |
||
1053 | find_end_while: |
||
1054 | call find_structure_end |
||
1055 | cmp ax,while_directive-assembler |
||
1056 | jne unexpected_instruction |
||
1057 | ret |
||
1058 | if_directive: |
||
1059 | cmp [prefixed_instruction],0 |
||
1060 | jne unexpected_instruction |
||
1061 | call calculate_logical_expression |
||
1062 | mov dl,al |
||
1063 | mov al,[esi] |
||
1064 | or al,al |
||
1065 | jz missing_end_directive |
||
1066 | cmp al,0Fh |
||
1067 | jne extra_characters_on_line |
||
1068 | or dl,dl |
||
1069 | jnz if_true |
||
1070 | call find_else |
||
1071 | jc instruction_assembled |
||
1072 | mov al,[esi] |
||
1073 | cmp al,1 |
||
1074 | jne else_true |
||
1075 | cmp word [esi+1],if_directive-assembler |
||
1076 | jne else_true |
||
1077 | add esi,4 |
||
1078 | jmp if_directive |
||
1079 | if_true: |
||
1080 | xor al,al |
||
1081 | make_if_structure: |
||
1082 | call allocate_structure_data |
||
1083 | mov word [ebx],if_directive-assembler |
||
1084 | mov byte [ebx+2],al |
||
1085 | mov eax,[current_line] |
||
1086 | mov [ebx+4],eax |
||
1087 | jmp instruction_assembled |
||
1088 | else_true: |
||
1089 | or al,al |
||
1090 | jz missing_end_directive |
||
1091 | cmp al,0Fh |
||
1092 | jne extra_characters_on_line |
||
1093 | or al,-1 |
||
1094 | jmp make_if_structure |
||
1095 | else_directive: |
||
1096 | cmp [prefixed_instruction],0 |
||
1097 | jne unexpected_instruction |
||
1098 | mov ax,if_directive-assembler |
||
1099 | call find_structure_data |
||
1100 | jc unexpected_instruction |
||
1101 | cmp byte [ebx+2],0 |
||
1102 | jne unexpected_instruction |
||
1103 | found_else: |
||
1104 | mov al,[esi] |
||
1105 | cmp al,1 |
||
1106 | jne skip_else |
||
1107 | cmp word [esi+1],if_directive-assembler |
||
1108 | jne skip_else |
||
1109 | add esi,4 |
||
1110 | call find_else |
||
1111 | jnc found_else |
||
1112 | call remove_structure_data |
||
1113 | jmp instruction_assembled |
||
1114 | skip_else: |
||
1115 | or al,al |
||
1116 | jz missing_end_directive |
||
1117 | cmp al,0Fh |
||
1118 | jne extra_characters_on_line |
||
1119 | call find_end_if |
||
1120 | call remove_structure_data |
||
1121 | jmp instruction_assembled |
||
1122 | end_if: |
||
1123 | cmp [prefixed_instruction],0 |
||
1124 | jne unexpected_instruction |
||
1125 | call find_structure_data |
||
1126 | jc unexpected_instruction |
||
1127 | call remove_structure_data |
||
1128 | jmp instruction_assembled |
||
1129 | find_else: |
||
1130 | call find_structure_end |
||
1131 | cmp ax,else_directive-assembler |
||
1132 | je else_found |
||
1133 | cmp ax,if_directive-assembler |
||
1134 | jne unexpected_instruction |
||
1135 | stc |
||
1136 | ret |
||
1137 | else_found: |
||
1138 | clc |
||
1139 | ret |
||
1140 | find_end_if: |
||
1141 | call find_structure_end |
||
1142 | cmp ax,if_directive-assembler |
||
1143 | jne unexpected_instruction |
||
1144 | ret |
||
1145 | find_structure_end: |
||
1146 | push [error_line] |
||
1147 | mov eax,[current_line] |
||
1148 | mov [error_line],eax |
||
1149 | find_end_directive: |
||
1150 | call skip_line |
||
1151 | lods byte [esi] |
||
1152 | cmp al,0Fh |
||
1153 | jne no_end_directive |
||
1154 | lods dword [esi] |
||
1155 | mov [current_line],eax |
||
1156 | skip_labels: |
||
1157 | cmp byte [esi],2 |
||
1158 | jne labels_ok |
||
1159 | add esi,6 |
||
1160 | jmp skip_labels |
||
1161 | labels_ok: |
||
1162 | cmp byte [esi],1 |
||
1163 | jne find_end_directive |
||
1164 | mov ax,[esi+1] |
||
1165 | cmp ax,prefix_instruction-assembler |
||
1166 | je find_end_directive |
||
1167 | add esi,4 |
||
1168 | cmp ax,repeat_directive-assembler |
||
1169 | je skip_repeat |
||
1170 | cmp ax,while_directive-assembler |
||
1171 | je skip_while |
||
1172 | cmp ax,if_directive-assembler |
||
1173 | je skip_if |
||
1174 | cmp ax,else_directive-assembler |
||
1175 | je structure_end |
||
1176 | cmp ax,end_directive-assembler |
||
1177 | jne find_end_directive |
||
1178 | cmp byte [esi],1 |
||
1179 | jne find_end_directive |
||
1180 | mov ax,[esi+1] |
||
1181 | add esi,4 |
||
1182 | cmp ax,repeat_directive-assembler |
||
1183 | je structure_end |
||
1184 | cmp ax,while_directive-assembler |
||
1185 | je structure_end |
||
1186 | cmp ax,if_directive-assembler |
||
1187 | jne find_end_directive |
||
1188 | structure_end: |
||
1189 | pop [error_line] |
||
1190 | ret |
||
1191 | no_end_directive: |
||
1192 | mov eax,[error_line] |
||
1193 | mov [current_line],eax |
||
1194 | jmp missing_end_directive |
||
1195 | skip_repeat: |
||
1196 | call find_end_repeat |
||
1197 | jmp find_end_directive |
||
1198 | skip_while: |
||
1199 | call find_end_while |
||
1200 | jmp find_end_directive |
||
1201 | skip_if: |
||
1202 | call skip_if_block |
||
1203 | jmp find_end_directive |
||
1204 | skip_if_block: |
||
1205 | call find_else |
||
1206 | jc if_block_skipped |
||
1207 | cmp byte [esi],1 |
||
1208 | jne skip_after_else |
||
1209 | cmp word [esi+1],if_directive-assembler |
||
1210 | jne skip_after_else |
||
1211 | add esi,4 |
||
1212 | jmp skip_if_block |
||
1213 | skip_after_else: |
||
1214 | call find_end_if |
||
1215 | if_block_skipped: |
||
1216 | ret |
||
1217 | end_directive: |
||
1218 | lods byte [esi] |
||
1219 | cmp al,1 |
||
1220 | jne invalid_argument |
||
1221 | lods word [esi] |
||
1222 | inc esi |
||
1223 | cmp ax,virtual_directive-assembler |
||
1224 | je end_virtual |
||
1225 | cmp ax,repeat_directive-assembler |
||
1226 | je end_repeat |
||
1227 | cmp ax,while_directive-assembler |
||
1228 | je end_while |
||
1229 | cmp ax,if_directive-assembler |
||
1230 | je end_if |
||
1231 | cmp ax,data_directive-assembler |
||
1232 | je end_data |
||
1233 | jmp invalid_argument |
||
1234 | break_directive: |
||
1235 | mov ebx,[structures_buffer] |
||
1236 | mov al,[esi] |
||
1237 | or al,al |
||
1238 | jz find_breakable_structure |
||
1239 | cmp al,0Fh |
||
1240 | jne extra_characters_on_line |
||
1241 | find_breakable_structure: |
||
1242 | cmp ebx,[additional_memory_end] |
||
1243 | je unexpected_instruction |
||
1244 | mov ax,[ebx] |
||
1245 | cmp ax,repeat_directive-assembler |
||
1246 | je break_repeat |
||
1247 | cmp ax,while_directive-assembler |
||
1248 | je break_while |
||
1249 | cmp ax,if_directive-assembler |
||
1250 | je break_if |
||
1251 | add ebx,20h |
||
1252 | jmp find_breakable_structure |
||
1253 | break_if: |
||
1254 | push [current_line] |
||
1255 | mov eax,[ebx+4] |
||
1256 | mov [current_line],eax |
||
1257 | call remove_structure_data |
||
1258 | call skip_if_block |
||
1259 | pop [current_line] |
||
1260 | mov ebx,[structures_buffer] |
||
1261 | jmp find_breakable_structure |
||
1262 | break_repeat: |
||
1263 | push ebx |
||
1264 | call find_end_repeat |
||
1265 | pop ebx |
||
1266 | jmp stop_repeat |
||
1267 | break_while: |
||
1268 | push ebx |
||
1269 | jmp stop_while |
||
1270 | |||
1271 | |||
1272 | call define_data |
||
1273 | lods byte [esi] |
||
1274 | cmp al,'(' |
||
1275 | je get_byte |
||
1276 | cmp al,'?' |
||
1277 | jne invalid_argument |
||
1278 | mov eax,edi |
||
1279 | mov byte [edi],0 |
||
1280 | inc edi |
||
1281 | jmp undefined_data |
||
1282 | get_byte: |
||
1283 | cmp byte [esi],0 |
||
1284 | je get_string |
||
1285 | call get_byte_value |
||
1286 | stos byte [edi] |
||
1287 | ret |
||
1288 | get_string: |
||
1289 | inc esi |
||
1290 | lods dword [esi] |
||
1291 | mov ecx,eax |
||
1292 | lea eax,[edi+ecx] |
||
1293 | cmp eax,[display_buffer] |
||
1294 | ja out_of_memory |
||
1295 | rep movs byte [edi],[esi] |
||
1296 | inc esi |
||
1297 | ret |
||
1298 | undefined_data: |
||
1299 | cmp [virtual_data],0 |
||
1300 | je mark_undefined_data |
||
1301 | ret |
||
1302 | mark_undefined_data: |
||
1303 | cmp eax,[undefined_data_end] |
||
1304 | je undefined_data_ok |
||
1305 | mov [undefined_data_start],eax |
||
1306 | undefined_data_ok: |
||
1307 | mov [undefined_data_end],edi |
||
1308 | ret |
||
1309 | define_data: |
||
1310 | cmp edi,[display_buffer] |
||
1311 | jae out_of_memory |
||
1312 | cmp byte [esi],'(' |
||
1313 | jne simple_data_value |
||
1314 | mov ebx,esi |
||
1315 | inc esi |
||
1316 | call skip_expression |
||
1317 | xchg esi,ebx |
||
1318 | cmp byte [ebx],81h |
||
1319 | jne simple_data_value |
||
1320 | inc esi |
||
1321 | call get_dword_value |
||
1322 | cmp [next_pass_needed],0 |
||
1323 | jne dup_value_ok |
||
1324 | cmp [value_type],0 |
||
1325 | jne invalid_use_of_symbol |
||
1326 | dup_value_ok: |
||
1327 | inc esi |
||
1328 | cmp eax,0 |
||
1329 | jg dup_positive |
||
1330 | cmp [error_line],0 |
||
1331 | jne dup_invalid |
||
1332 | mov eax,[current_line] |
||
1333 | mov [error_line],eax |
||
1334 | mov [error],invalid_value |
||
1335 | dup_invalid: |
||
1336 | mov eax,1 |
||
1337 | dup_positive: |
||
1338 | cmp byte [esi],'{' |
||
1339 | jne duplicate_single_data_value |
||
1340 | inc esi |
||
1341 | duplicate_data: |
||
1342 | push eax esi |
||
1343 | duplicated_values: |
||
1344 | cmp edi,[display_buffer] |
||
1345 | jae out_of_memory |
||
1346 | call near dword [esp+8] |
||
1347 | lods byte [esi] |
||
1348 | cmp al,',' |
||
1349 | je duplicated_values |
||
1350 | cmp al,'}' |
||
1351 | jne invalid_argument |
||
1352 | pop ebx eax |
||
1353 | dec eax |
||
1354 | jz data_defined |
||
1355 | mov esi,ebx |
||
1356 | jmp duplicate_data |
||
1357 | duplicate_single_data_value: |
||
1358 | cmp edi,[display_buffer] |
||
1359 | jae out_of_memory |
||
1360 | push eax esi |
||
1361 | call near dword [esp+8] |
||
1362 | pop ebx eax |
||
1363 | dec eax |
||
1364 | jz data_defined |
||
1365 | mov esi,ebx |
||
1366 | jmp duplicate_single_data_value |
||
1367 | simple_data_value: |
||
1368 | cmp edi,[display_buffer] |
||
1369 | jae out_of_memory |
||
1370 | call near dword [esp] |
||
1371 | data_defined: |
||
1372 | lods byte [esi] |
||
1373 | cmp al,',' |
||
1374 | je define_data |
||
1375 | dec esi |
||
1376 | add esp,4 |
||
1377 | jmp instruction_assembled |
||
1378 | data_unicode: |
||
1379 | or [base_code],-1 |
||
1380 | jmp define_words |
||
1381 | data_words: |
||
1382 | mov [base_code],0 |
||
1383 | define_words: |
||
1384 | call define_data |
||
1385 | lods byte [esi] |
||
1386 | cmp al,'(' |
||
1387 | je get_word |
||
1388 | cmp al,'?' |
||
1389 | jne invalid_argument |
||
1390 | mov eax,edi |
||
1391 | mov word [edi],0 |
||
1392 | scas word [edi] |
||
1393 | jmp undefined_data |
||
1394 | ret |
||
1395 | get_word: |
||
1396 | cmp [base_code],0 |
||
1397 | je word_data_value |
||
1398 | cmp byte [esi],0 |
||
1399 | je word_string |
||
1400 | word_data_value: |
||
1401 | call get_word_value |
||
1402 | call mark_relocation |
||
1403 | stos word [edi] |
||
1404 | ret |
||
1405 | word_string: |
||
1406 | inc esi |
||
1407 | lods dword [esi] |
||
1408 | mov ecx,eax |
||
1409 | jecxz word_string_ok |
||
1410 | lea eax,[edi+ecx*2] |
||
1411 | cmp eax,[display_buffer] |
||
1412 | ja out_of_memory |
||
1413 | xor ah,ah |
||
1414 | copy_word_string: |
||
1415 | lods byte [esi] |
||
1416 | stos word [edi] |
||
1417 | loop copy_word_string |
||
1418 | word_string_ok: |
||
1419 | inc esi |
||
1420 | ret |
||
1421 | data_dwords: |
||
1422 | call define_data |
||
1423 | lods byte [esi] |
||
1424 | cmp al,'(' |
||
1425 | je get_dword |
||
1426 | cmp al,'?' |
||
1427 | jne invalid_argument |
||
1428 | mov eax,edi |
||
1429 | mov dword [edi],0 |
||
1430 | scas dword [edi] |
||
1431 | jmp undefined_data |
||
1432 | get_dword: |
||
1433 | push esi |
||
1434 | call get_dword_value |
||
1435 | pop ebx |
||
1436 | cmp byte [esi],':' |
||
1437 | je complex_dword |
||
1438 | call mark_relocation |
||
1439 | stos dword [edi] |
||
1440 | ret |
||
1441 | complex_dword: |
||
1442 | mov esi,ebx |
||
1443 | cmp byte [esi],'.' |
||
1444 | je invalid_value |
||
1445 | call get_word_value |
||
1446 | push eax |
||
1447 | inc esi |
||
1448 | lods byte [esi] |
||
1449 | cmp al,'(' |
||
1450 | jne invalid_operand |
||
1451 | mov al,[value_type] |
||
1452 | push eax |
||
1453 | cmp byte [esi],'.' |
||
1454 | je invalid_value |
||
1455 | call get_word_value |
||
1456 | call mark_relocation |
||
1457 | stos word [edi] |
||
1458 | pop eax |
||
1459 | mov [value_type],al |
||
1460 | pop eax |
||
1461 | call mark_relocation |
||
1462 | stos word [edi] |
||
1463 | ret |
||
1464 | data_pwords: |
||
1465 | call define_data |
||
1466 | lods byte [esi] |
||
1467 | cmp al,'(' |
||
1468 | je get_pword |
||
1469 | cmp al,'?' |
||
1470 | jne invalid_argument |
||
1471 | mov eax,edi |
||
1472 | mov dword [edi],0 |
||
1473 | scas dword [edi] |
||
1474 | mov word [edi],0 |
||
1475 | scas word [edi] |
||
1476 | jmp undefined_data |
||
1477 | get_pword: |
||
1478 | push esi |
||
1479 | call get_pword_value |
||
1480 | pop ebx |
||
1481 | cmp byte [esi],':' |
||
1482 | je complex_pword |
||
1483 | call mark_relocation |
||
1484 | stos dword [edi] |
||
1485 | mov ax,dx |
||
1486 | stos word [edi] |
||
1487 | ret |
||
1488 | complex_pword: |
||
1489 | mov esi,ebx |
||
1490 | cmp byte [esi],'.' |
||
1491 | je invalid_value |
||
1492 | call get_word_value |
||
1493 | push eax |
||
1494 | inc esi |
||
1495 | lods byte [esi] |
||
1496 | cmp al,'(' |
||
1497 | jne invalid_operand |
||
1498 | mov al,[value_type] |
||
1499 | push eax |
||
1500 | cmp byte [esi],'.' |
||
1501 | je invalid_value |
||
1502 | call get_dword_value |
||
1503 | call mark_relocation |
||
1504 | stos dword [edi] |
||
1505 | pop eax |
||
1506 | mov [value_type],al |
||
1507 | pop eax |
||
1508 | call mark_relocation |
||
1509 | stos word [edi] |
||
1510 | ret |
||
1511 | data_qwords: |
||
1512 | call define_data |
||
1513 | lods byte [esi] |
||
1514 | cmp al,'(' |
||
1515 | je get_qword |
||
1516 | cmp al,'?' |
||
1517 | jne invalid_argument |
||
1518 | mov eax,edi |
||
1519 | mov dword [edi],0 |
||
1520 | scas dword [edi] |
||
1521 | mov dword [edi],0 |
||
1522 | scas dword [edi] |
||
1523 | jmp undefined_data |
||
1524 | get_qword: |
||
1525 | call get_qword_value |
||
1526 | call mark_relocation |
||
1527 | stos dword [edi] |
||
1528 | mov eax,edx |
||
1529 | stos dword [edi] |
||
1530 | ret |
||
1531 | data_twords: |
||
1532 | call define_data |
||
1533 | lods byte [esi] |
||
1534 | cmp al,'(' |
||
1535 | je get_tword |
||
1536 | cmp al,'?' |
||
1537 | jne invalid_argument |
||
1538 | mov eax,edi |
||
1539 | mov dword [edi],0 |
||
1540 | scas dword [edi] |
||
1541 | mov dword [edi],0 |
||
1542 | scas dword [edi] |
||
1543 | mov word [edi],0 |
||
1544 | scas word [edi] |
||
1545 | jmp undefined_data |
||
1546 | get_tword: |
||
1547 | cmp byte [esi],'.' |
||
1548 | jne complex_tword |
||
1549 | inc esi |
||
1550 | cmp word [esi+8],8000h |
||
1551 | je fp_zero_tword |
||
1552 | mov eax,[esi] |
||
1553 | stos dword [edi] |
||
1554 | mov eax,[esi+4] |
||
1555 | stos dword [edi] |
||
1556 | mov ax,[esi+8] |
||
1557 | add ax,3FFFh |
||
1558 | cmp ax,8000h |
||
1559 | jae value_out_of_range |
||
1560 | mov bl,[esi+11] |
||
1561 | shl bx,15 |
||
1562 | or ax,bx |
||
1563 | stos word [edi] |
||
1564 | add esi,13 |
||
1565 | ret |
||
1566 | fp_zero_tword: |
||
1567 | xor eax,eax |
||
1568 | stos dword [edi] |
||
1569 | stos dword [edi] |
||
1570 | mov al,[esi+11] |
||
1571 | shl ax,15 |
||
1572 | stos word [edi] |
||
1573 | add esi,13 |
||
1574 | ret |
||
1575 | complex_tword: |
||
1576 | call get_word_value |
||
1577 | push eax |
||
1578 | inc esi |
||
1579 | lods byte [esi] |
||
1580 | cmp al,'(' |
||
1581 | jne invalid_operand |
||
1582 | mov al,[value_type] |
||
1583 | push eax |
||
1584 | cmp byte [esi],'.' |
||
1585 | je invalid_value |
||
1586 | call get_qword_value |
||
1587 | call mark_relocation |
||
1588 | stos dword [edi] |
||
1589 | mov eax,edx |
||
1590 | stos dword [edi] |
||
1591 | pop eax |
||
1592 | mov [value_type],al |
||
1593 | pop eax |
||
1594 | call mark_relocation |
||
1595 | stos word [edi] |
||
1596 | ret |
||
1597 | data_file: |
||
1598 | lods word [esi] |
||
1599 | cmp ax,'(' |
||
1600 | jne invalid_argument |
||
1601 | add esi,4 |
||
1602 | call open_binary_file |
||
1603 | mov eax,[esi-4] |
||
1604 | lea esi,[esi+eax+1] |
||
1605 | mov al,2 |
||
1606 | xor edx,edx |
||
1607 | call lseek |
||
1608 | push eax |
||
1609 | xor edx,edx |
||
1610 | cmp byte [esi],':' |
||
1611 | jne position_ok |
||
1612 | inc esi |
||
1613 | cmp byte [esi],'(' |
||
1614 | jne invalid_argument |
||
1615 | inc esi |
||
1616 | cmp byte [esi],'.' |
||
1617 | je invalid_value |
||
1618 | push ebx |
||
1619 | call get_dword_value |
||
1620 | pop ebx |
||
1621 | mov edx,eax |
||
1622 | sub [esp],edx |
||
1623 | position_ok: |
||
1624 | cmp byte [esi],',' |
||
1625 | jne size_ok |
||
1626 | inc esi |
||
1627 | cmp byte [esi],'(' |
||
1628 | jne invalid_argument |
||
1629 | inc esi |
||
1630 | cmp byte [esi],'.' |
||
1631 | je invalid_value |
||
1632 | push ebx edx |
||
1633 | call get_dword_value |
||
1634 | pop edx ebx |
||
1635 | mov [esp],eax |
||
1636 | size_ok: |
||
1637 | xor al,al |
||
1638 | call lseek |
||
1639 | pop ecx |
||
1640 | mov edx,edi |
||
1641 | add edi,ecx |
||
1642 | jc out_of_memory |
||
1643 | cmp edi,[display_buffer] |
||
1644 | ja out_of_memory |
||
1645 | call read |
||
1646 | jc error_reading_file |
||
1647 | call close |
||
1648 | lods byte [esi] |
||
1649 | cmp al,',' |
||
1650 | je data_file |
||
1651 | dec esi |
||
1652 | jmp instruction_assembled |
||
1653 | open_binary_file: |
||
1654 | push esi |
||
1655 | push edi |
||
1656 | mov esi,[current_line] |
||
1657 | mov esi,[esi] |
||
1658 | get_current_path: |
||
1659 | lodsb |
||
1660 | stosb |
||
1661 | or al,al |
||
1662 | jnz get_current_path |
||
1663 | cut_current_path: |
||
1664 | cmp edi,[esp] |
||
1665 | je current_path_ok |
||
1666 | cmp byte [edi-1],'\' |
||
1667 | je current_path_ok |
||
1668 | cmp byte [edi-1],'/' |
||
1669 | je current_path_ok |
||
1670 | dec edi |
||
1671 | jmp cut_current_path |
||
1672 | current_path_ok: |
||
1673 | mov esi,[esp+4] |
||
1674 | call preprocess_path |
||
1675 | pop edx |
||
1676 | mov esi,edx |
||
1677 | call open |
||
1678 | jnc file_opened |
||
1679 | mov edi,esi |
||
1680 | mov esi,[esp] |
||
1681 | push edi |
||
1682 | call preprocess_path |
||
1683 | pop edx |
||
1684 | mov esi,edx |
||
1685 | call open |
||
1686 | jc file_not_found |
||
1687 | file_opened: |
||
1688 | mov edi,esi |
||
1689 | pop esi |
||
1690 | ret |
||
1691 | reserve_bytes: |
||
1692 | lods byte [esi] |
||
1693 | cmp al,'(' |
||
1694 | jne invalid_argument |
||
1695 | cmp byte [esi],'.' |
||
1696 | je invalid_value |
||
1697 | call get_dword_value |
||
1698 | cmp [next_pass_needed],0 |
||
1699 | jne rb_value_ok |
||
1700 | cmp [value_type],0 |
||
1701 | jne invalid_use_of_symbol |
||
1702 | rb_value_ok: |
||
1703 | cmp eax,0 |
||
1704 | jl reserve_negative |
||
1705 | mov ecx,eax |
||
1706 | mov edx,ecx |
||
1707 | add edx,edi |
||
1708 | jc out_of_memory |
||
1709 | cmp edx,[display_buffer] |
||
1710 | ja out_of_memory |
||
1711 | push edi |
||
1712 | cmp [next_pass_needed],0 |
||
1713 | je zero_bytes |
||
1714 | add edi,ecx |
||
1715 | jmp reserved_data |
||
1716 | zero_bytes: |
||
1717 | xor eax,eax |
||
1718 | shr ecx,1 |
||
1719 | jnc bytes_stosb_ok |
||
1720 | stos byte [edi] |
||
1721 | bytes_stosb_ok: |
||
1722 | shr ecx,1 |
||
1723 | jnc bytes_stosw_ok |
||
1724 | stos word [edi] |
||
1725 | bytes_stosw_ok: |
||
1726 | rep stos dword [edi] |
||
1727 | reserved_data: |
||
1728 | pop eax |
||
1729 | call undefined_data |
||
1730 | jmp instruction_assembled |
||
1731 | reserve_negative: |
||
1732 | cmp [error_line],0 |
||
1733 | jne instruction_assembled |
||
1734 | mov eax,[current_line] |
||
1735 | mov [error_line],eax |
||
1736 | mov [error],invalid_value |
||
1737 | jmp instruction_assembled |
||
1738 | reserve_words: |
||
1739 | lods byte [esi] |
||
1740 | cmp al,'(' |
||
1741 | jne invalid_argument |
||
1742 | cmp byte [esi],'.' |
||
1743 | je invalid_value |
||
1744 | call get_dword_value |
||
1745 | cmp [next_pass_needed],0 |
||
1746 | jne rw_value_ok |
||
1747 | cmp [value_type],0 |
||
1748 | jne invalid_use_of_symbol |
||
1749 | rw_value_ok: |
||
1750 | cmp eax,0 |
||
1751 | jl reserve_negative |
||
1752 | mov ecx,eax |
||
1753 | mov edx,ecx |
||
1754 | shl edx,1 |
||
1755 | jc out_of_memory |
||
1756 | add edx,edi |
||
1757 | jc out_of_memory |
||
1758 | cmp edx,[display_buffer] |
||
1759 | ja out_of_memory |
||
1760 | push edi |
||
1761 | cmp [next_pass_needed],0 |
||
1762 | je zero_words |
||
1763 | lea edi,[edi+ecx*2] |
||
1764 | jmp reserved_data |
||
1765 | zero_words: |
||
1766 | xor eax,eax |
||
1767 | shr ecx,1 |
||
1768 | jnc words_stosw_ok |
||
1769 | stos word [edi] |
||
1770 | words_stosw_ok: |
||
1771 | rep stos dword [edi] |
||
1772 | jmp reserved_data |
||
1773 | reserve_dwords: |
||
1774 | lods byte [esi] |
||
1775 | cmp al,'(' |
||
1776 | jne invalid_argument |
||
1777 | cmp byte [esi],'.' |
||
1778 | je invalid_value |
||
1779 | call get_dword_value |
||
1780 | cmp [next_pass_needed],0 |
||
1781 | jne rd_value_ok |
||
1782 | cmp [value_type],0 |
||
1783 | jne invalid_use_of_symbol |
||
1784 | rd_value_ok: |
||
1785 | cmp eax,0 |
||
1786 | jl reserve_negative |
||
1787 | mov ecx,eax |
||
1788 | mov edx,ecx |
||
1789 | shl edx,1 |
||
1790 | jc out_of_memory |
||
1791 | shl edx,1 |
||
1792 | jc out_of_memory |
||
1793 | add edx,edi |
||
1794 | jc out_of_memory |
||
1795 | cmp edx,[display_buffer] |
||
1796 | ja out_of_memory |
||
1797 | push edi |
||
1798 | cmp [next_pass_needed],0 |
||
1799 | je zero_dwords |
||
1800 | lea edi,[edi+ecx*4] |
||
1801 | jmp reserved_data |
||
1802 | zero_dwords: |
||
1803 | xor eax,eax |
||
1804 | rep stos dword [edi] |
||
1805 | jmp reserved_data |
||
1806 | reserve_pwords: |
||
1807 | lods byte [esi] |
||
1808 | cmp al,'(' |
||
1809 | jne invalid_argument |
||
1810 | cmp byte [esi],'.' |
||
1811 | je invalid_value |
||
1812 | call get_dword_value |
||
1813 | cmp [next_pass_needed],0 |
||
1814 | jne rp_value_ok |
||
1815 | cmp [value_type],0 |
||
1816 | jne invalid_use_of_symbol |
||
1817 | rp_value_ok: |
||
1818 | cmp eax,0 |
||
1819 | jl reserve_negative |
||
1820 | mov ecx,eax |
||
1821 | shl ecx,1 |
||
1822 | jc out_of_memory |
||
1823 | add ecx,eax |
||
1824 | mov edx,ecx |
||
1825 | shl edx,1 |
||
1826 | jc out_of_memory |
||
1827 | add edx,edi |
||
1828 | jc out_of_memory |
||
1829 | cmp edx,[display_buffer] |
||
1830 | ja out_of_memory |
||
1831 | push edi |
||
1832 | cmp [next_pass_needed],0 |
||
1833 | je zero_words |
||
1834 | lea edi,[edi+ecx*2] |
||
1835 | jmp reserved_data |
||
1836 | reserve_qwords: |
||
1837 | lods byte [esi] |
||
1838 | cmp al,'(' |
||
1839 | jne invalid_argument |
||
1840 | cmp byte [esi],'.' |
||
1841 | je invalid_value |
||
1842 | call get_dword_value |
||
1843 | cmp [next_pass_needed],0 |
||
1844 | jne rq_value_ok |
||
1845 | cmp [value_type],0 |
||
1846 | jne invalid_use_of_symbol |
||
1847 | rq_value_ok: |
||
1848 | cmp eax,0 |
||
1849 | jl reserve_negative |
||
1850 | mov ecx,eax |
||
1851 | shl ecx,1 |
||
1852 | jc out_of_memory |
||
1853 | mov edx,ecx |
||
1854 | shl edx,1 |
||
1855 | jc out_of_memory |
||
1856 | shl edx,1 |
||
1857 | jc out_of_memory |
||
1858 | add edx,edi |
||
1859 | jc out_of_memory |
||
1860 | cmp edx,[display_buffer] |
||
1861 | ja out_of_memory |
||
1862 | push edi |
||
1863 | cmp [next_pass_needed],0 |
||
1864 | je zero_dwords |
||
1865 | lea edi,[edi+ecx*4] |
||
1866 | jmp reserved_data |
||
1867 | reserve_twords: |
||
1868 | lods byte [esi] |
||
1869 | cmp al,'(' |
||
1870 | jne invalid_argument |
||
1871 | cmp byte [esi],'.' |
||
1872 | je invalid_value |
||
1873 | call get_dword_value |
||
1874 | cmp [next_pass_needed],0 |
||
1875 | jne rt_value_ok |
||
1876 | cmp [value_type],0 |
||
1877 | jne invalid_use_of_symbol |
||
1878 | rt_value_ok: |
||
1879 | cmp eax,0 |
||
1880 | jl reserve_negative |
||
1881 | mov ecx,eax |
||
1882 | shl ecx,2 |
||
1883 | jc out_of_memory |
||
1884 | add ecx,eax |
||
1885 | mov edx,ecx |
||
1886 | shl edx,1 |
||
1887 | jc out_of_memory |
||
1888 | add edx,edi |
||
1889 | jc out_of_memory |
||
1890 | cmp edx,[display_buffer] |
||
1891 | ja out_of_memory |
||
1892 | push edi |
||
1893 | cmp [next_pass_needed],0 |
||
1894 | je zero_words |
||
1895 | lea edi,[edi+ecx*2] |
||
1896 | jmp reserved_data |
||
1897 | align_directive: |
||
1898 | lods byte [esi] |
||
1899 | cmp al,'(' |
||
1900 | jne invalid_argument |
||
1901 | cmp byte [esi],'.' |
||
1902 | je invalid_value |
||
1903 | call get_dword_value |
||
1904 | cmp [value_type],0 |
||
1905 | jne invalid_use_of_symbol |
||
1906 | mov edx,eax |
||
1907 | dec edx |
||
1908 | test eax,edx |
||
1909 | jnz invalid_value |
||
1910 | or eax,eax |
||
1911 | jz invalid_value |
||
1912 | cmp eax,1 |
||
1913 | je instruction_assembled |
||
1914 | mov ecx,edi |
||
1915 | sub ecx,dword [org_origin] |
||
1916 | cmp [org_registers],0 |
||
1917 | jne section_not_aligned_enough |
||
1918 | cmp [labels_type],0 |
||
1919 | je make_alignment |
||
1920 | cmp [output_format],3 |
||
1921 | je pe_alignment |
||
1922 | mov ebx,[org_symbol] |
||
1923 | cmp byte [ebx],0 |
||
1924 | jne section_not_aligned_enough |
||
1925 | cmp eax,[ebx+10h] |
||
1926 | jbe make_alignment |
||
1927 | jmp section_not_aligned_enough |
||
1928 | pe_alignment: |
||
1929 | cmp eax,1000h |
||
1930 | ja section_not_aligned_enough |
||
1931 | make_alignment: |
||
1932 | dec eax |
||
1933 | and ecx,eax |
||
1934 | jz instruction_assembled |
||
1935 | neg ecx |
||
1936 | add ecx,eax |
||
1937 | inc ecx |
||
1938 | mov edx,ecx |
||
1939 | add edx,edi |
||
1940 | jc out_of_memory |
||
1941 | cmp edx,[display_buffer] |
||
1942 | ja out_of_memory |
||
1943 | push edi |
||
1944 | cmp [next_pass_needed],0 |
||
1945 | je nops |
||
1946 | add edi,ecx |
||
1947 | jmp reserved_data |
||
1948 | nops: |
||
1949 | mov eax,90909090h |
||
1950 | shr ecx,1 |
||
1951 | jnc nops_stosb_ok |
||
1952 | stos byte [edi] |
||
1953 | nops_stosb_ok: |
||
1954 | shr ecx,1 |
||
1955 | jnc nops_stosw_ok |
||
1956 | stos word [edi] |
||
1957 | nops_stosw_ok: |
||
1958 | rep stos dword [edi] |
||
1959 | jmp reserved_data |
||
1960 |