Subversion Repositories Kolibri OS

Rev

Rev 4039 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
31 halyavin 1
 
2
; Copyright (c) 1999-2013, Tomasz Grysztar.
4039 heavyiron 3
; All rights reserved.
31 halyavin 4
5
 
6
	mov	edi,characters
2665 dunkaist 7
	xor	al,al
8
      make_characters_table:
31 halyavin 9
	stosb
2665 dunkaist 10
	inc	al
11
	jnz	make_characters_table
12
	mov	esi,characters+'a'
13
	mov	edi,characters+'A'
14
	mov	ecx,26
15
	rep	movsb
16
	mov	edi,characters
17
	mov	esi,symbol_characters+1
18
	movzx	ecx,byte [esi-1]
19
	xor	eax,eax
20
      mark_symbol_characters:
31 halyavin 21
	lodsb
2665 dunkaist 22
	mov	byte [edi+eax],0
23
	loop	mark_symbol_characters
24
	mov	edi,locals_counter
25
	mov	ax,1 + '0' shl 8
26
	stos	word [edi]
27
	mov	edi,[memory_start]
28
	mov	[include_paths],edi
29
	mov	esi,include_variable
30
	call	get_environment_variable
31
	xor	al,al
32
	stos	byte [edi]
33
	mov	[memory_start],edi
34
	mov	eax,[additional_memory]
35
	mov	[free_additional_memory],eax
36
	mov	eax,[additional_memory_end]
37
	mov	[labels_list],eax
38
	xor	eax,eax
39
	mov	[source_start],eax
40
	mov	[tagged_blocks],eax
4039 heavyiron 41
	mov	[hash_tree],eax
2665 dunkaist 42
	mov	[error],eax
43
	mov	[macro_status],al
44
	mov	esi,[input_file]
45
	mov	edx,esi
46
	call	open
47
	jc	main_file_not_found
48
	mov	edi,[memory_start]
49
	call	preprocess_file
50
	cmp	[macro_status],0
4478 dunkaist 51
	je	process_postponed
52
	mov	eax,[error_line]
2665 dunkaist 53
	mov	[current_line],eax
54
	jmp	incomplete_macro
4478 dunkaist 55
      process_postponed:
56
	mov	edx,hash_tree
57
	mov	ecx,32
58
      find_postponed_list:
59
	mov	edx,[edx]
60
	or	edx,edx
61
	loopnz	find_postponed_list
62
	jz	preprocessing_finished
63
      process_postponed_list:
64
	mov	eax,[edx]
65
	or	eax,eax
66
	jz	preprocessing_finished
67
	push	edx
68
	mov	ebx,edx
69
      find_earliest_postponed:
70
	mov	eax,[edx]
71
	or	eax,eax
72
	jz	earliest_postponed_found
73
	mov	ebx,edx
74
	mov	edx,eax
75
	jmp	find_earliest_postponed
76
      earliest_postponed_found:
77
	mov	[ebx],eax
78
	call	use_postponed_macro
79
	pop	edx
80
	jmp	process_postponed_list
81
      preprocessing_finished:
82
	mov	[source_start],edi
2665 dunkaist 83
	ret
84
      use_postponed_macro:
4478 dunkaist 85
	lea	esi,[edi-1]
86
	push	ecx esi
87
	mov	[struc_name],0
88
	jmp	use_macro
89
31 halyavin 90
 
91
	push	[memory_end]
2665 dunkaist 92
	push	esi
93
	mov	al,2
94
	xor	edx,edx
95
	call	lseek
96
	push	eax
97
	xor	al,al
98
	xor	edx,edx
99
	call	lseek
100
	pop	ecx
101
	mov	edx,[memory_end]
102
	dec	edx
103
	mov	byte [edx],1Ah
104
	sub	edx,ecx
105
	jc	out_of_memory
106
	mov	esi,edx
107
	cmp	edx,edi
108
	jbe	out_of_memory
109
	mov	[memory_end],edx
110
	call	read
111
	call	close
112
	pop	edx
113
	xor	ecx,ecx
114
	mov	ebx,esi
115
      preprocess_source:
31 halyavin 116
	inc	ecx
2665 dunkaist 117
	mov	[current_line],edi
118
	mov	eax,edx
119
	stos	dword [edi]
120
	mov	eax,ecx
121
	stos	dword [edi]
122
	mov	eax,esi
123
	sub	eax,ebx
124
	stos	dword [edi]
125
	xor	eax,eax
126
	stos	dword [edi]
127
	push	ebx edx
128
	call	convert_line
129
	call	preprocess_line
130
	pop	edx ebx
131
      next_line:
31 halyavin 132
	cmp	byte [esi-1],0
2665 dunkaist 133
	je	file_end
134
	cmp	byte [esi-1],1Ah
135
	jne	preprocess_source
136
      file_end:
31 halyavin 137
	pop	[memory_end]
2665 dunkaist 138
	clc
139
	ret
140
31 halyavin 141
 
142
	push	ecx
2665 dunkaist 143
	test	[macro_status],0Fh
144
	jz	convert_line_data
145
	mov	ax,3Bh
146
	stos	word [edi]
147
      convert_line_data:
31 halyavin 148
	cmp	edi,[memory_end]
2665 dunkaist 149
	jae	out_of_memory
150
	lods	byte [esi]
151
	cmp	al,20h
152
	je	convert_line_data
153
	cmp	al,9
154
	je	convert_line_data
155
	mov	ah,al
156
	mov	ebx,characters
157
	xlat	byte [ebx]
158
	or	al,al
159
	jz	convert_separator
160
	cmp	ah,27h
161
	je	convert_string
162
	cmp	ah,22h
163
	je	convert_string
164
	mov	byte [edi],1Ah
165
	scas	word [edi]
166
	xchg	al,ah
167
	stos	byte [edi]
168
	mov	ebx,characters
169
	xor	ecx,ecx
170
      convert_symbol:
31 halyavin 171
	lods	byte [esi]
2665 dunkaist 172
	stos	byte [edi]
173
	xlat	byte [ebx]
174
	or	al,al
175
	loopnzd convert_symbol
176
	neg	ecx
177
	cmp	ecx,255
178
	ja	name_too_long
179
	mov	ebx,edi
180
	sub	ebx,ecx
181
	mov	byte [ebx-2],cl
182
      found_separator:
31 halyavin 183
	dec	edi
2665 dunkaist 184
	mov	ah,[esi-1]
185
      convert_separator:
31 halyavin 186
	xchg	al,ah
2665 dunkaist 187
	cmp	al,20h
188
	jb	control_character
189
	je	convert_line_data
190
      symbol_character:
31 halyavin 191
	cmp	al,3Bh
2665 dunkaist 192
	je	ignore_comment
193
	cmp	al,5Ch
194
	je	backslash_character
195
	stos	byte [edi]
196
	jmp	convert_line_data
197
      control_character:
31 halyavin 198
	cmp	al,1Ah
2665 dunkaist 199
	je	line_end
200
	cmp	al,0Dh
201
	je	cr_character
202
	cmp	al,0Ah
203
	je	lf_character
204
	cmp	al,9
205
	je	convert_line_data
206
	or	al,al
207
	jnz	symbol_character
208
	jmp	line_end
209
      lf_character:
31 halyavin 210
	lods	byte [esi]
2665 dunkaist 211
	cmp	al,0Dh
212
	je	line_end
213
	dec	esi
214
	jmp	line_end
215
      cr_character:
31 halyavin 216
	lods	byte [esi]
2665 dunkaist 217
	cmp	al,0Ah
218
	je	line_end
219
	dec	esi
220
	jmp	line_end
221
      convert_string:
31 halyavin 222
	mov	al,22h
2665 dunkaist 223
	stos	byte [edi]
224
	scas	dword [edi]
225
	mov	ebx,edi
226
      copy_string:
31 halyavin 227
	lods	byte [esi]
2665 dunkaist 228
	stos	byte [edi]
229
	cmp	al,0Ah
230
	je	no_end_quote
4039 heavyiron 231
	cmp	al,0Dh
2665 dunkaist 232
	je	no_end_quote
4039 heavyiron 233
	or	al,al
2665 dunkaist 234
	jz	no_end_quote
4039 heavyiron 235
	cmp	al,1Ah
2665 dunkaist 236
	je	no_end_quote
4039 heavyiron 237
	cmp	al,ah
2665 dunkaist 238
	jne	copy_string
239
	lods	byte [esi]
240
	cmp	al,ah
241
	je	copy_string
242
	dec	esi
243
	dec	edi
244
	mov	eax,edi
245
	sub	eax,ebx
246
	mov	[ebx-4],eax
247
	jmp	convert_line_data
248
      backslash_character:
31 halyavin 249
	mov	byte [edi],0
2665 dunkaist 250
	lods	byte [esi]
251
	cmp	al,20h
252
	je	concatenate_lines
253
	cmp	al,9
254
	je	concatenate_lines
255
	cmp	al,1Ah
256
	je	unexpected_end_of_file
257
	or	al,al
258
	jz	unexpected_end_of_file
259
	cmp	al,0Ah
260
	je	concatenate_lf
261
	cmp	al,0Dh
262
	je	concatenate_cr
263
	cmp	al,3Bh
264
	je	find_concatenated_line
265
	mov	al,1Ah
266
	stos	byte [edi]
267
	mov	ecx,edi
268
	mov	ax,5C01h
269
	stos	word [edi]
270
	dec	esi
271
      group_backslashes:
31 halyavin 272
	lods	byte [esi]
2665 dunkaist 273
	cmp	al,5Ch
274
	jne	backslashed_symbol
275
	stos	byte [edi]
276
	inc	byte [ecx]
277
	jmp	group_backslashes
278
      no_end_quote:
4039 heavyiron 279
	mov	byte [ebx-5],0
280
	jmp	missing_end_quote
281
      backslashed_symbol:
31 halyavin 282
	cmp	al,1Ah
2665 dunkaist 283
	je	unexpected_end_of_file
284
	or	al,al
285
	jz	unexpected_end_of_file
286
	cmp	al,0Ah
287
	je	extra_characters_on_line
288
	cmp	al,0Dh
289
	je	extra_characters_on_line
290
	cmp	al,20h
291
	je	extra_characters_on_line
292
	cmp	al,9
293
	je	extra_characters_on_line
294
	cmp	al,22h
295
	je	extra_characters_on_line
296
	cmp	al,27h
297
	je	extra_characters_on_line
298
	cmp	al,3Bh
299
	je	extra_characters_on_line
300
	mov	ah,al
301
	mov	ebx,characters
302
	xlat	byte [ebx]
303
	or	al,al
304
	jz	backslashed_symbol_character
305
	mov	al,ah
306
      convert_backslashed_symbol:
31 halyavin 307
	stos	byte [edi]
2665 dunkaist 308
	xlat	byte [ebx]
309
	or	al,al
310
	jz	found_separator
311
	inc	byte [ecx]
312
	jz	name_too_long
313
	lods	byte [esi]
314
	jmp	convert_backslashed_symbol
315
      backslashed_symbol_character:
31 halyavin 316
	mov	al,ah
2665 dunkaist 317
	stos	byte [edi]
318
	inc	byte [ecx]
319
	jmp	convert_line_data
320
      concatenate_lines:
31 halyavin 321
	lods	byte [esi]
2665 dunkaist 322
	cmp	al,20h
323
	je	concatenate_lines
324
	cmp	al,9
325
	je	concatenate_lines
326
	cmp	al,1Ah
327
	je	unexpected_end_of_file
328
	or	al,al
329
	jz	unexpected_end_of_file
330
	cmp	al,0Ah
331
	je	concatenate_lf
332
	cmp	al,0Dh
333
	je	concatenate_cr
334
	cmp	al,3Bh
335
	jne	extra_characters_on_line
336
      find_concatenated_line:
31 halyavin 337
	lods	byte [esi]
2665 dunkaist 338
	cmp	al,0Ah
339
	je	concatenate_lf
340
	cmp	al,0Dh
341
	je	concatenate_cr
342
	or	al,al
343
	jz	concatenate_ok
344
	cmp	al,1Ah
345
	jne	find_concatenated_line
346
	jmp	unexpected_end_of_file
347
      concatenate_lf:
31 halyavin 348
	lods	byte [esi]
2665 dunkaist 349
	cmp	al,0Dh
350
	je	concatenate_ok
351
	dec	esi
352
	jmp	concatenate_ok
353
      concatenate_cr:
31 halyavin 354
	lods	byte [esi]
2665 dunkaist 355
	cmp	al,0Ah
356
	je	concatenate_ok
357
	dec	esi
358
      concatenate_ok:
31 halyavin 359
	inc	dword [esp]
2665 dunkaist 360
	jmp	convert_line_data
361
      ignore_comment:
31 halyavin 362
	lods	byte [esi]
2665 dunkaist 363
	cmp	al,0Ah
364
	je	lf_character
365
	cmp	al,0Dh
366
	je	cr_character
367
	or	al,al
368
	jz	line_end
369
	cmp	al,1Ah
370
	jne	ignore_comment
371
      line_end:
31 halyavin 372
	xor	al,al
2665 dunkaist 373
	stos	byte [edi]
374
	pop	ecx
375
	ret
376
31 halyavin 377
 
109 heavyiron 378
	mov	edi,converted
2665 dunkaist 379
	mov	ebx,characters
380
      convert_case:
109 heavyiron 381
	lods	byte [esi]
2665 dunkaist 382
	xlat	byte [ebx]
383
	stos	byte [edi]
384
	loop	convert_case
385
      case_ok:
109 heavyiron 386
	ret
2665 dunkaist 387
109 heavyiron 388
 
389
	push	edi
2665 dunkaist 390
	mov	edx,esi
391
	mov	ebp,ecx
392
	call	lower_case
393
	pop	edi
394
      scan_directives:
109 heavyiron 395
	mov	esi,converted
2665 dunkaist 396
	movzx	eax,byte [edi]
397
	or	al,al
398
	jz	no_directive
399
	mov	ecx,ebp
400
	inc	edi
401
	mov	ebx,edi
402
	add	ebx,eax
403
	mov	ah,[esi]
404
	cmp	ah,[edi]
405
	jb	no_directive
406
	ja	next_directive
407
	cmp	cl,al
408
	jne	next_directive
409
	repe	cmps byte [esi],[edi]
410
	jb	no_directive
411
	je	directive_ok
412
      next_directive:
109 heavyiron 413
	mov	edi,ebx
2665 dunkaist 414
	add	edi,2
415
	jmp	scan_directives
416
      no_directive:
109 heavyiron 417
	mov	esi,edx
2665 dunkaist 418
	mov	ecx,ebp
419
	stc
420
	ret
421
      directive_ok:
109 heavyiron 422
	lea	esi,[edx+ebp]
2665 dunkaist 423
	call	directive_handler
424
      directive_handler:
1189 heavyiron 425
	pop	ecx
2665 dunkaist 426
	movzx	eax,word [ebx]
427
	add	eax,ecx
428
	clc
429
	ret
430
109 heavyiron 431
 
31 halyavin 432
	mov	eax,esp
2665 dunkaist 433
	sub	eax,100h
434
	jc	stack_overflow
435
	cmp	eax,[stack_limit]
436
	jb	stack_overflow
437
	push	ecx esi
438
      preprocess_current_line:
31 halyavin 439
	mov	esi,[current_line]
2665 dunkaist 440
	add	esi,16
441
	cmp	word [esi],3Bh
442
	jne	line_start_ok
443
	add	esi,2
444
      line_start_ok:
31 halyavin 445
	test	[macro_status],0F0h
2665 dunkaist 446
	jnz	macro_preprocessing
447
	cmp	byte [esi],1Ah
448
	jne	not_fix_constant
449
	movzx	edx,byte [esi+1]
450
	lea	edx,[esi+2+edx]
451
	cmp	word [edx],031Ah
452
	jne	not_fix_constant
453
	mov	ebx,characters
454
	movzx	eax,byte [edx+2]
455
	xlat	byte [ebx]
456
	ror	eax,8
457
	mov	al,[edx+3]
458
	xlat	byte [ebx]
459
	ror	eax,8
460
	mov	al,[edx+4]
461
	xlat	byte [ebx]
462
	ror	eax,16
463
	cmp	eax,'fix'
464
	je	define_fix_constant
465
      not_fix_constant:
31 halyavin 466
	call	process_fix_constants
2665 dunkaist 467
	jmp	initial_preprocessing_ok
468
      macro_preprocessing:
31 halyavin 469
	call	process_macro_operators
2665 dunkaist 470
      initial_preprocessing_ok:
31 halyavin 471
	mov	esi,[current_line]
2665 dunkaist 472
	add	esi,16
473
	mov	al,[macro_status]
474
	test	al,2
475
	jnz	skip_macro_block
476
	test	al,1
477
	jnz	find_macro_block
478
      preprocess_instruction:
31 halyavin 479
	mov	[current_offset],esi
2665 dunkaist 480
	lods	byte [esi]
481
	movzx	ecx,byte [esi]
482
	inc	esi
483
	cmp	al,1Ah
484
	jne	not_preprocessor_symbol
485
	cmp	cl,3
486
	jb	not_preprocessor_directive
487
	push	edi
488
	mov	edi,preprocessor_directives
489
	call	get_directive
490
	pop	edi
491
	jc	not_preprocessor_directive
492
	mov	byte [edx-2],3Bh
493
	jmp	near eax
494
      not_preprocessor_directive:
31 halyavin 495
	xor	ch,ch
2665 dunkaist 496
	call	get_preprocessor_symbol
497
	jc	not_macro
498
	mov	byte [ebx-2],3Bh
499
	mov	[struc_name],0
500
	jmp	use_macro
501
      not_macro:
31 halyavin 502
	mov	[struc_name],esi
2665 dunkaist 503
	add	esi,ecx
504
	lods	byte [esi]
505
	cmp	al,':'
506
	je	preprocess_label
507
	cmp	al,1Ah
508
	jne	not_preprocessor_symbol
509
	lods	byte [esi]
510
	cmp	al,3
511
	jne	not_symbolic_constant
512
	mov	ebx,characters
513
	movzx	eax,byte [esi]
514
	xlat	byte [ebx]
515
	ror	eax,8
516
	mov	al,[esi+1]
517
	xlat	byte [ebx]
518
	ror	eax,8
519
	mov	al,[esi+2]
520
	xlat	byte [ebx]
521
	ror	eax,16
522
	cmp	eax,'equ'
523
	je	define_equ_constant
524
	mov	al,3
525
      not_symbolic_constant:
31 halyavin 526
	mov	ch,1
2665 dunkaist 527
	mov	cl,al
528
	call	get_preprocessor_symbol
529
	jc	not_preprocessor_symbol
530
	push	edx esi
531
	mov	esi,[struc_name]
532
	mov	[struc_label],esi
533
	sub	[struc_label],2
534
	mov	cl,[esi-1]
535
	mov	ch,10b
536
	call	get_preprocessor_symbol
537
	jc	struc_name_ok
538
	mov	ecx,[edx+12]
539
	add	ecx,3
540
	lea	ebx,[edi+ecx]
541
	mov	ecx,edi
542
	sub	ecx,[struc_label]
543
	lea	esi,[edi-1]
544
	lea	edi,[ebx-1]
545
	std
546
	rep	movs byte [edi],[esi]
547
	cld
548
	mov	edi,[struc_label]
549
	mov	esi,[edx+8]
550
	mov	ecx,[edx+12]
551
	add	[struc_name],ecx
552
	add	[struc_name],3
553
	call	move_data
554
	mov	al,3Ah
555
	stos	byte [edi]
556
	mov	ax,3Bh
557
	stos	word [edi]
558
	mov	edi,ebx
559
	pop	esi
560
	add	esi,[edx+12]
561
	add	esi,3
562
	pop	edx
563
	jmp	use_macro
564
      struc_name_ok:
31 halyavin 565
	mov	edx,[struc_name]
2665 dunkaist 566
	movzx	eax,byte [edx-1]
567
	add	edx,eax
568
	push	edi
569
	lea	esi,[edi-1]
570
	mov	ecx,edi
571
	sub	ecx,edx
572
	std
573
	rep	movs byte [edi],[esi]
574
	cld
575
	pop	edi
576
	inc	edi
577
	mov	al,3Ah
578
	mov	[edx],al
579
	inc	al
580
	mov	[edx+1],al
581
	pop	esi edx
582
	inc	esi
583
	jmp	use_macro
584
      preprocess_label:
31 halyavin 585
	dec	esi
2665 dunkaist 586
	sub	esi,ecx
587
	lea	ebp,[esi-2]
588
	mov	ch,10b
589
	call	get_preprocessor_symbol
590
	jnc	symbolic_constant_in_label
591
	lea	esi,[esi+ecx+1]
592
	cmp	byte [esi],':'
4039 heavyiron 593
	jne	preprocess_instruction
594
	inc	esi
595
	jmp	preprocess_instruction
2665 dunkaist 596
      symbolic_constant_in_label:
31 halyavin 597
	mov	ebx,[edx+8]
2665 dunkaist 598
	mov	ecx,[edx+12]
599
	add	ecx,ebx
600
      check_for_broken_label:
31 halyavin 601
	cmp	ebx,ecx
2665 dunkaist 602
	je	label_broken
603
	cmp	byte [ebx],1Ah
604
	jne	label_broken
605
	movzx	eax,byte [ebx+1]
606
	lea	ebx,[ebx+2+eax]
607
	cmp	ebx,ecx
608
	je	label_constant_ok
609
	cmp	byte [ebx],':'
610
	jne	label_broken
611
	inc	ebx
612
	cmp	byte [ebx],':'
4039 heavyiron 613
	jne	check_for_broken_label
614
	inc	ebx
615
	jmp	check_for_broken_label
2665 dunkaist 616
      label_broken:
31 halyavin 617
	push	line_preprocessed
2665 dunkaist 618
	jmp	replace_symbolic_constant
619
      label_constant_ok:
31 halyavin 620
	mov	ecx,edi
2665 dunkaist 621
	sub	ecx,esi
622
	mov	edi,[edx+12]
623
	add	edi,ebp
624
	push	edi
625
	lea	eax,[edi+ecx]
626
	push	eax
627
	cmp	esi,edi
628
	je	replace_label
629
	jb	move_rest_of_line_up
630
	rep	movs byte [edi],[esi]
631
	jmp	replace_label
632
      move_rest_of_line_up:
31 halyavin 633
	lea	esi,[esi+ecx-1]
2665 dunkaist 634
	lea	edi,[edi+ecx-1]
635
	std
636
	rep	movs byte [edi],[esi]
637
	cld
638
      replace_label:
31 halyavin 639
	mov	ecx,[edx+12]
2665 dunkaist 640
	mov	edi,[esp+4]
641
	sub	edi,ecx
642
	mov	esi,[edx+8]
643
	rep	movs byte [edi],[esi]
644
	pop	edi esi
645
	inc	esi
646
	jmp	preprocess_instruction
647
      not_preprocessor_symbol:
31 halyavin 648
	mov	esi,[current_offset]
2665 dunkaist 649
	call	process_equ_constants
650
      line_preprocessed:
31 halyavin 651
	pop	esi ecx
2665 dunkaist 652
	ret
653
31 halyavin 654
 
655
	push	ebp edi esi
2665 dunkaist 656
	mov	ebp,ecx
657
	shl	ebp,22
658
	movzx	ecx,cl
659
	mov	ebx,hash_tree
660
	mov	edi,10
661
      follow_hashes_roots:
31 halyavin 662
	mov	edx,[ebx]
2665 dunkaist 663
	or	edx,edx
664
	jz	preprocessor_symbol_not_found
665
	xor	eax,eax
666
	shl	ebp,1
667
	adc	eax,0
668
	lea	ebx,[edx+eax*4]
669
	dec	edi
670
	jnz	follow_hashes_roots
671
	mov	edi,ebx
672
	call	calculate_hash
673
	mov	ebp,eax
674
	and	ebp,3FFh
675
	shl	ebp,10
676
	xor	ebp,eax
677
	mov	ebx,edi
678
	mov	edi,22
679
      follow_hashes_tree:
31 halyavin 680
	mov	edx,[ebx]
2665 dunkaist 681
	or	edx,edx
682
	jz	preprocessor_symbol_not_found
683
	xor	eax,eax
684
	shl	ebp,1
685
	adc	eax,0
686
	lea	ebx,[edx+eax*4]
687
	dec	edi
688
	jnz	follow_hashes_tree
689
	mov	al,cl
690
	mov	edx,[ebx]
691
	or	edx,edx
692
	jz	preprocessor_symbol_not_found
693
      compare_with_preprocessor_symbol:
31 halyavin 694
	mov	edi,[edx+4]
2665 dunkaist 695
	cmp	edi,1
696
	jbe	next_equal_hash
697
	repe	cmps byte [esi],[edi]
698
	je	preprocessor_symbol_found
699
	mov	cl,al
700
	mov	esi,[esp]
701
      next_equal_hash:
31 halyavin 702
	mov	edx,[edx]
2665 dunkaist 703
	or	edx,edx
704
	jnz	compare_with_preprocessor_symbol
705
      preprocessor_symbol_not_found:
31 halyavin 706
	pop	esi edi ebp
2665 dunkaist 707
	stc
708
	ret
709
      preprocessor_symbol_found:
31 halyavin 710
	pop	ebx edi ebp
2665 dunkaist 711
	clc
712
	ret
713
      calculate_hash:
31 halyavin 714
	xor	ebx,ebx
2665 dunkaist 715
	mov	eax,2166136261
716
	mov	ebp,16777619
717
      fnv1a_hash:
31 halyavin 718
	xor	al,[esi+ebx]
2665 dunkaist 719
	mul	ebp
720
	inc	bl
721
	cmp	bl,cl
722
	jb	fnv1a_hash
723
	ret
724
add_preprocessor_symbol:
31 halyavin 725
	push	edi esi
2665 dunkaist 726
	xor	eax,eax
4478 dunkaist 727
	or	cl,cl
728
	jz	reshape_hash
729
	cmp	ch,11b
2665 dunkaist 730
	je	preprocessor_symbol_name_ok
731
	push	ecx
732
	movzx	ecx,cl
733
	mov	edi,preprocessor_directives
734
	call	get_directive
735
	jnc	reserved_word_used_as_symbol
736
	pop	ecx
737
      preprocessor_symbol_name_ok:
992 heavyiron 738
	call	calculate_hash
2665 dunkaist 739
      reshape_hash:
4478 dunkaist 740
	mov	ebp,eax
2665 dunkaist 741
	and	ebp,3FFh
742
	shr	eax,10
743
	xor	ebp,eax
744
	shl	ecx,22
745
	or	ebp,ecx
746
	mov	ebx,hash_tree
747
	mov	ecx,32
748
      find_leave_for_symbol:
31 halyavin 749
	mov	edx,[ebx]
2665 dunkaist 750
	or	edx,edx
751
	jz	extend_hashes_tree
752
	xor	eax,eax
753
	rol	ebp,1
754
	adc	eax,0
755
	lea	ebx,[edx+eax*4]
756
	dec	ecx
757
	jnz	find_leave_for_symbol
758
	mov	edx,[ebx]
759
	or	edx,edx
760
	jz	add_symbol_entry
761
	shr	ebp,30
762
	cmp	ebp,11b
763
	je	reuse_symbol_entry
764
	cmp	dword [edx+4],0
765
	jne	add_symbol_entry
766
      find_entry_to_reuse:
31 halyavin 767
	mov	edi,[edx]
2665 dunkaist 768
	or	edi,edi
769
	jz	reuse_symbol_entry
770
	cmp	dword [edi+4],0
771
	jne	reuse_symbol_entry
772
	mov	edx,edi
773
	jmp	find_entry_to_reuse
774
      add_symbol_entry:
31 halyavin 775
	mov	eax,edx
2665 dunkaist 776
	mov	edx,[labels_list]
777
	sub	edx,16
778
	cmp	edx,[free_additional_memory]
779
	jb	out_of_memory
780
	mov	[labels_list],edx
781
	mov	[edx],eax
782
	mov	[ebx],edx
783
      reuse_symbol_entry:
31 halyavin 784
	pop	esi edi
2665 dunkaist 785
	mov	[edx+4],esi
786
	ret
787
      extend_hashes_tree:
31 halyavin 788
	mov	edx,[labels_list]
2665 dunkaist 789
	sub	edx,8
790
	cmp	edx,[free_additional_memory]
791
	jb	out_of_memory
792
	mov	[labels_list],edx
793
	xor	eax,eax
794
	mov	[edx],eax
795
	mov	[edx+4],eax
796
	shl	ebp,1
797
	adc	eax,0
798
	mov	[ebx],edx
799
	lea	ebx,[edx+eax*4]
800
	dec	ecx
801
	jnz	extend_hashes_tree
802
	mov	edx,[labels_list]
803
	sub	edx,16
804
	cmp	edx,[free_additional_memory]
805
	jb	out_of_memory
806
	mov	[labels_list],edx
807
	mov	dword [edx],0
808
	mov	[ebx],edx
809
	pop	esi edi
810
	mov	[edx+4],esi
811
	ret
812
31 halyavin 813
 
814
	add	edx,5
2665 dunkaist 815
	add	esi,2
816
	push	edx
817
	mov	ch,11b
818
	jmp	define_preprocessor_constant
819
define_equ_constant:
31 halyavin 820
	add	esi,3
2665 dunkaist 821
	push	esi
822
	call	process_equ_constants
823
	mov	esi,[struc_name]
824
	mov	ch,10b
825
      define_preprocessor_constant:
109 heavyiron 826
	mov	byte [esi-2],3Bh
2665 dunkaist 827
	mov	cl,[esi-1]
828
	call	add_preprocessor_symbol
829
	pop	ebx
830
	mov	ecx,edi
831
	dec	ecx
832
	sub	ecx,ebx
833
	mov	[edx+8],ebx
834
	mov	[edx+12],ecx
835
	jmp	line_preprocessed
836
define_symbolic_constant:
109 heavyiron 837
	lods	byte [esi]
2665 dunkaist 838
	cmp	al,1Ah
839
	jne	invalid_name
840
	lods	byte [esi]
841
	mov	cl,al
842
	mov	ch,10b
843
	call	add_preprocessor_symbol
844
	movzx	eax,byte [esi-1]
845
	add	esi,eax
846
	lea	ecx,[edi-1]
847
	sub	ecx,esi
848
	mov	[edx+8],esi
849
	mov	[edx+12],ecx
850
	jmp	line_preprocessed
851
109 heavyiron 852
 
31 halyavin 853
	mov	ch,1
2665 dunkaist 854
	jmp	make_macro
855
define_macro:
31 halyavin 856
	xor	ch,ch
2665 dunkaist 857
      make_macro:
31 halyavin 858
	lods	byte [esi]
2665 dunkaist 859
	cmp	al,1Ah
860
	jne	invalid_name
861
	lods	byte [esi]
862
	mov	cl,al
863
	call	add_preprocessor_symbol
864
	mov	eax,[current_line]
865
	mov	[edx+12],eax
866
	movzx	eax,byte [esi-1]
867
	add	esi,eax
868
	mov	[edx+8],esi
869
	mov	al,[macro_status]
870
	and	al,0F0h
871
	or	al,1
872
	mov	[macro_status],al
873
	mov	eax,[current_line]
874
	mov	[error_line],eax
875
	xor	ebp,ebp
876
	lods	byte [esi]
877
	or	al,al
878
	jz	line_preprocessed
879
	cmp	al,'{'
880
	je	found_macro_block
881
	dec	esi
882
      skip_macro_arguments:
31 halyavin 883
	lods	byte [esi]
2665 dunkaist 884
	cmp	al,1Ah
885
	je	skip_macro_argument
886
	cmp	al,'['
887
	jne	invalid_macro_arguments
888
	or	ebp,-1
889
	jz	invalid_macro_arguments
890
	lods	byte [esi]
891
	cmp	al,1Ah
892
	jne	invalid_macro_arguments
893
      skip_macro_argument:
31 halyavin 894
	movzx	eax,byte [esi]
2665 dunkaist 895
	inc	esi
896
	add	esi,eax
897
	lods	byte [esi]
898
	cmp	al,'='
899
	je	macro_argument_with_default_value
900
	cmp	al,'*'
901
	jne	macro_argument_end
902
	lods	byte [esi]
903
      macro_argument_end:
31 halyavin 904
	cmp	al,','
2665 dunkaist 905
	je	skip_macro_arguments
906
	cmp	al,']'
907
	jne	end_macro_arguments
908
	lods	byte [esi]
909
	not	ebp
910
      end_macro_arguments:
31 halyavin 911
	or	ebp,ebp
2665 dunkaist 912
	jnz	invalid_macro_arguments
913
	or	al,al
914
	jz	line_preprocessed
915
	cmp	al,'{'
916
	je	found_macro_block
917
	jmp	invalid_macro_arguments
918
      macro_argument_with_default_value:
2664 dunkaist 919
	or	[default_argument_value],-1
2665 dunkaist 920
	call	skip_macro_argument_value
921
	inc	esi
922
	jmp	macro_argument_end
923
      skip_macro_argument_value:
2664 dunkaist 924
	cmp	byte [esi],'<'
2665 dunkaist 925
	jne	simple_argument
926
	mov	ecx,1
927
	inc	esi
928
      enclosed_argument:
2664 dunkaist 929
	lods	byte [esi]
2665 dunkaist 930
	or	al,al
931
	jz	invalid_macro_arguments
932
	cmp	al,1Ah
933
	je	enclosed_symbol
934
	cmp	al,22h
935
	je	enclosed_string
936
	cmp	al,'>'
937
	je	enclosed_argument_end
938
	cmp	al,'<'
939
	jne	enclosed_argument
940
	inc	ecx
941
	jmp	enclosed_argument
942
      enclosed_symbol:
2664 dunkaist 943
	movzx	eax,byte [esi]
2665 dunkaist 944
	inc	esi
945
	add	esi,eax
946
	jmp	enclosed_argument
947
      enclosed_string:
2664 dunkaist 948
	lods	dword [esi]
2665 dunkaist 949
	add	esi,eax
950
	jmp	enclosed_argument
951
      enclosed_argument_end:
2664 dunkaist 952
	loop	enclosed_argument
2665 dunkaist 953
	lods	byte [esi]
954
	or	al,al
955
	jz	argument_value_end
956
	cmp	al,','
957
	je	argument_value_end
958
	cmp	[default_argument_value],0
959
	je	invalid_macro_arguments
960
	cmp	al,'{'
961
	je	argument_value_end
962
	or	ebp,ebp
963
	jz	invalid_macro_arguments
964
	cmp	al,']'
965
	je	argument_value_end
966
	jmp	invalid_macro_arguments
967
      simple_argument:
2664 dunkaist 968
	lods	byte [esi]
2665 dunkaist 969
	or	al,al
970
	jz	argument_value_end
971
	cmp	al,','
972
	je	argument_value_end
973
	cmp	al,22h
974
	je	argument_string
975
	cmp	al,1Ah
976
	je	argument_symbol
977
	cmp	[default_argument_value],0
978
	je	simple_argument
979
	cmp	al,'{'
980
	je	argument_value_end
981
	or	ebp,ebp
982
	jz	simple_argument
983
	cmp	al,']'
984
	je	argument_value_end
985
      argument_symbol:
2664 dunkaist 986
	movzx	eax,byte [esi]
2665 dunkaist 987
	inc	esi
988
	add	esi,eax
989
	jmp	simple_argument
990
      argument_string:
2664 dunkaist 991
	lods	dword [esi]
2665 dunkaist 992
	add	esi,eax
993
	jmp	simple_argument
994
      argument_value_end:
2664 dunkaist 995
	dec	esi
2665 dunkaist 996
	ret
997
      find_macro_block:
31 halyavin 998
	add	esi,2
2665 dunkaist 999
	lods	byte [esi]
1000
	or	al,al
1001
	jz	line_preprocessed
1002
	cmp	al,'{'
1003
	jne	unexpected_characters
1004
      found_macro_block:
31 halyavin 1005
	or	[macro_status],2
2665 dunkaist 1006
      skip_macro_block:
31 halyavin 1007
	lods	byte [esi]
2665 dunkaist 1008
	cmp	al,1Ah
1009
	je	skip_macro_symbol
1010
	cmp	al,3Bh
1011
	je	skip_macro_symbol
1012
	cmp	al,22h
1013
	je	skip_macro_string
1014
	or	al,al
1015
	jz	line_preprocessed
1016
	cmp	al,'}'
1017
	jne	skip_macro_block
1018
	mov	al,[macro_status]
1019
	and	[macro_status],0F0h
1020
	test	al,8
1021
	jnz	use_instant_macro
1022
	cmp	byte [esi],0
1023
	je	line_preprocessed
1024
	mov	ecx,edi
1025
	sub	ecx,esi
1026
	mov	edx,esi
1027
	lea	esi,[esi+ecx-1]
1028
	lea	edi,[edi+1+16]
1029
	mov	ebx,edi
1030
	dec	edi
1031
	std
1032
	rep	movs byte [edi],[esi]
1033
	cld
1034
	mov	edi,edx
1035
	xor	al,al
1036
	stos	byte [edi]
1037
	mov	esi,[current_line]
1038
	mov	[current_line],edi
1039
	mov	ecx,4
1040
	rep	movs dword [edi],[esi]
1041
	mov	edi,ebx
1042
	jmp	initial_preprocessing_ok
1043
      skip_macro_symbol:
31 halyavin 1044
	movzx	eax,byte [esi]
2665 dunkaist 1045
	inc	esi
1046
	add	esi,eax
1047
	jmp	skip_macro_block
1048
      skip_macro_string:
31 halyavin 1049
	lods	dword [esi]
2665 dunkaist 1050
	add	esi,eax
1051
	jmp	skip_macro_block
1052
postpone_directive:
4478 dunkaist 1053
	push	esi
1054
	mov	esi,edx
1055
	xor	ecx,ecx
1056
	call	add_preprocessor_symbol
1057
	mov	eax,[current_line]
1058
	mov	[edx+12],eax
1059
	pop	esi
1060
	mov	[edx+8],esi
1061
	mov	al,[macro_status]
1062
	and	al,0F0h
1063
	or	al,1
1064
	mov	[macro_status],al
1065
	mov	eax,[current_line]
1066
	mov	[error_line],eax
1067
	lods	byte [esi]
1068
	or	al,al
1069
	jz	line_preprocessed
1070
	cmp	al,'{'
1071
	jne	unexpected_characters
1072
	jmp	found_macro_block
1073
rept_directive:
31 halyavin 1074
	mov	[base_code],0
2665 dunkaist 1075
	jmp	define_instant_macro
1076
irp_directive:
31 halyavin 1077
	mov	[base_code],1
2665 dunkaist 1078
	jmp	define_instant_macro
1079
irps_directive:
31 halyavin 1080
	mov	[base_code],2
2665 dunkaist 1081
	jmp	define_instant_macro
1082
match_directive:
31 halyavin 1083
	mov	[base_code],10h
2665 dunkaist 1084
define_instant_macro:
31 halyavin 1085
	mov	al,[macro_status]
2665 dunkaist 1086
	and	al,0F0h
1087
	or	al,8+1
1088
	mov	[macro_status],al
1089
	mov	eax,[current_line]
1090
	mov	[error_line],eax
1091
	mov	[instant_macro_start],esi
1092
	cmp	[base_code],10h
1093
	je	prepare_match
1094
      skip_parameters:
1189 heavyiron 1095
	lods	byte [esi]
2665 dunkaist 1096
	or	al,al
1097
	jz	parameters_skipped
1098
	cmp	al,'{'
1099
	je	parameters_skipped
1100
	cmp	al,22h
1101
	je	skip_quoted_parameter
1102
	cmp	al,1Ah
1103
	jne	skip_parameters
1104
	lods	byte [esi]
1105
	movzx	eax,al
1106
	add	esi,eax
1107
	jmp	skip_parameters
1108
      skip_quoted_parameter:
1189 heavyiron 1109
	lods	dword [esi]
2665 dunkaist 1110
	add	esi,eax
1111
	jmp	skip_parameters
1112
      parameters_skipped:
1189 heavyiron 1113
	dec	esi
2665 dunkaist 1114
	mov	[parameters_end],esi
1115
	lods	byte [esi]
1116
	cmp	al,'{'
1117
	je	found_macro_block
1118
	or	al,al
1119
	jnz	invalid_macro_arguments
1120
	jmp	line_preprocessed
1121
prepare_match:
31 halyavin 1122
	call	skip_pattern
2665 dunkaist 1123
	mov	[value_type],80h+10b
1124
	call	process_symbolic_constants
1125
	jmp	parameters_skipped
1126
      skip_pattern:
31 halyavin 1127
	lods	byte [esi]
2665 dunkaist 1128
	or	al,al
1129
	jz	invalid_macro_arguments
1130
	cmp	al,','
1131
	je	pattern_skipped
1132
	cmp	al,22h
1133
	je	skip_quoted_string_in_pattern
1134
	cmp	al,1Ah
1135
	je	skip_symbol_in_pattern
1136
	cmp	al,'='
1137
	jne	skip_pattern
1138
	mov	al,[esi]
1139
	cmp	al,1Ah
1140
	je	skip_pattern
1141
	cmp	al,22h
1142
	je	skip_pattern
1143
	inc	esi
1144
	jmp	skip_pattern
1145
      skip_symbol_in_pattern:
31 halyavin 1146
	lods	byte [esi]
2665 dunkaist 1147
	movzx	eax,al
1148
	add	esi,eax
1149
	jmp	skip_pattern
1150
      skip_quoted_string_in_pattern:
31 halyavin 1151
	lods	dword [esi]
2665 dunkaist 1152
	add	esi,eax
1153
	jmp	skip_pattern
1154
      pattern_skipped:
31 halyavin 1155
	ret
2665 dunkaist 1156
31 halyavin 1157
 
1158
	xor	ch,ch
2665 dunkaist 1159
	jmp	restore_preprocessor_symbol
1160
purge_struc:
31 halyavin 1161
	mov	ch,1
2665 dunkaist 1162
	jmp	restore_preprocessor_symbol
1163
restore_equ_constant:
31 halyavin 1164
	mov	ch,10b
2665 dunkaist 1165
      restore_preprocessor_symbol:
31 halyavin 1166
	push	ecx
2665 dunkaist 1167
	lods	byte [esi]
1168
	cmp	al,1Ah
1169
	jne	invalid_name
1170
	lods	byte [esi]
1171
	mov	cl,al
1172
	call	get_preprocessor_symbol
1173
	jc	no_symbol_to_restore
1174
	mov	dword [edx+4],0
1175
	jmp	symbol_restored
1176
      no_symbol_to_restore:
31 halyavin 1177
	add	esi,ecx
2665 dunkaist 1178
      symbol_restored:
31 halyavin 1179
	pop	ecx
2665 dunkaist 1180
	lods	byte [esi]
1181
	cmp	al,','
1182
	je	restore_preprocessor_symbol
1183
	or	al,al
1184
	jnz	extra_characters_on_line
1185
	jmp	line_preprocessed
1186
31 halyavin 1187
 
1188
	mov	[value_type],11b
2665 dunkaist 1189
	jmp	process_symbolic_constants
1190
process_equ_constants:
31 halyavin 1191
	mov	[value_type],10b
2665 dunkaist 1192
      process_symbolic_constants:
31 halyavin 1193
	mov	ebp,esi
2665 dunkaist 1194
	lods	byte [esi]
1195
	cmp	al,1Ah
1196
	je	check_symbol
1197
	cmp	al,22h
1198
	je	ignore_string
1199
	cmp	al,'{'
1200
	je	check_brace
1201
	or	al,al
1202
	jnz	process_symbolic_constants
1203
	ret
1204
      ignore_string:
31 halyavin 1205
	lods	dword [esi]
2665 dunkaist 1206
	add	esi,eax
1207
	jmp	process_symbolic_constants
1208
      check_brace:
31 halyavin 1209
	test	[value_type],80h
2665 dunkaist 1210
	jz	process_symbolic_constants
1211
	ret
1212
      no_replacing:
31 halyavin 1213
	movzx	ecx,byte [esi-1]
2665 dunkaist 1214
	add	esi,ecx
1215
	jmp	process_symbolic_constants
1216
      check_symbol:
31 halyavin 1217
	mov	cl,[esi]
2665 dunkaist 1218
	inc	esi
1219
	mov	ch,[value_type]
1220
	call	get_preprocessor_symbol
1221
	jc	no_replacing
1222
	mov	[current_section],edi
1223
      replace_symbolic_constant:
31 halyavin 1224
	mov	ecx,[edx+12]
2665 dunkaist 1225
	mov	edx,[edx+8]
1226
	xchg	esi,edx
1227
	call	move_data
1228
	mov	esi,edx
1229
      process_after_replaced:
31 halyavin 1230
	lods	byte [esi]
2665 dunkaist 1231
	cmp	al,1Ah
1232
	je	symbol_after_replaced
1233
	stos	byte [edi]
1234
	cmp	al,22h
1235
	je	string_after_replaced
1236
	cmp	al,'{'
1237
	je	brace_after_replaced
1238
	or	al,al
1239
	jnz	process_after_replaced
1240
	mov	ecx,edi
1241
	sub	ecx,esi
1242
	mov	edi,ebp
1243
	call	move_data
1244
	mov	esi,edi
1245
	ret
1246
      move_data:
31 halyavin 1247
	lea	eax,[edi+ecx]
2665 dunkaist 1248
	cmp	eax,[memory_end]
1249
	jae	out_of_memory
1250
	shr	ecx,1
1251
	jnc	movsb_ok
1252
	movs	byte [edi],[esi]
1253
      movsb_ok:
31 halyavin 1254
	shr	ecx,1
2665 dunkaist 1255
	jnc	movsw_ok
1256
	movs	word [edi],[esi]
1257
      movsw_ok:
31 halyavin 1258
	rep	movs dword [edi],[esi]
2665 dunkaist 1259
	ret
1260
      string_after_replaced:
31 halyavin 1261
	lods	dword [esi]
2665 dunkaist 1262
	stos	dword [edi]
1263
	mov	ecx,eax
1264
	call	move_data
1265
	jmp	process_after_replaced
1266
      brace_after_replaced:
31 halyavin 1267
	test	[value_type],80h
2665 dunkaist 1268
	jz	process_after_replaced
1269
	mov	edx,edi
1270
	mov	ecx,[current_section]
1271
	sub	edx,ecx
1272
	sub	ecx,esi
1273
	rep	movs byte [edi],[esi]
1274
	mov	ecx,edi
1275
	sub	ecx,esi
1276
	mov	edi,ebp
1277
	call	move_data
1278
	lea	esi,[ebp+edx]
1279
	ret
1280
      symbol_after_replaced:
31 halyavin 1281
	mov	cl,[esi]
2665 dunkaist 1282
	inc	esi
1283
	mov	ch,[value_type]
1284
	call	get_preprocessor_symbol
1285
	jnc	replace_symbolic_constant
1286
	movzx	ecx,byte [esi-1]
1287
	mov	al,1Ah
1288
	mov	ah,cl
1289
	stos	word [edi]
1290
	call	move_data
1291
	jmp	process_after_replaced
1292
process_macro_operators:
31 halyavin 1293
	xor	dl,dl
2665 dunkaist 1294
	mov	ebp,edi
1295
      before_macro_operators:
31 halyavin 1296
	mov	edi,esi
2665 dunkaist 1297
	lods	byte [esi]
1298
	cmp	al,'`'
1299
	je	symbol_conversion
1300
	cmp	al,'#'
1301
	je	concatenation
1302
	cmp	al,1Ah
1303
	je	symbol_before_macro_operators
1304
	cmp	al,3Bh
1305
	je	no_more_macro_operators
1306
	cmp	al,22h
1307
	je	string_before_macro_operators
1308
	xor	dl,dl
1309
	or	al,al
1310
	jnz	before_macro_operators
1311
	mov	edi,esi
1312
	ret
1313
      no_more_macro_operators:
31 halyavin 1314
	mov	edi,ebp
2665 dunkaist 1315
	ret
1316
      symbol_before_macro_operators:
31 halyavin 1317
	mov	dl,1Ah
2665 dunkaist 1318
	mov	ebx,esi
1319
	lods	byte [esi]
1320
	movzx	ecx,al
1321
	jecxz	symbol_before_macro_operators_ok
1322
	mov	edi,esi
1323
	cmp	byte [esi],'\'
1324
	je	escaped_symbol
1325
      symbol_before_macro_operators_ok:
31 halyavin 1326
	add	esi,ecx
2665 dunkaist 1327
	jmp	before_macro_operators
1328
      string_before_macro_operators:
31 halyavin 1329
	mov	dl,22h
2665 dunkaist 1330
	mov	ebx,esi
1331
	lods	dword [esi]
1332
	add	esi,eax
1333
	jmp	before_macro_operators
1334
      escaped_symbol:
31 halyavin 1335
	dec	byte [edi-1]
2665 dunkaist 1336
	dec	ecx
1337
	inc	esi
1338
	cmp	ecx,1
1339
	rep	movs byte [edi],[esi]
1340
	jne	after_macro_operators
1341
	mov	al,[esi-1]
1342
	mov	ecx,ebx
1343
	mov	ebx,characters
1344
	xlat	byte [ebx]
1345
	mov	ebx,ecx
1346
	or	al,al
1347
	jnz	after_macro_operators
1348
	sub	edi,3
1349
	mov	al,[esi-1]
1350
	stos	byte [edi]
1351
	xor	dl,dl
1352
	jmp	after_macro_operators
1353
      reduce_symbol_conversion:
109 heavyiron 1354
	inc	esi
2665 dunkaist 1355
      symbol_conversion:
31 halyavin 1356
	mov	edx,esi
2665 dunkaist 1357
	mov	al,[esi]
1358
	cmp	al,1Ah
1359
	jne	symbol_character_conversion
1360
	lods	word [esi]
1361
	movzx	ecx,ah
1362
	lea	ebx,[edi+3]
1363
	jecxz	convert_to_quoted_string
1364
	cmp	byte [esi],'\'
1365
	jne	convert_to_quoted_string
1366
	inc	esi
1367
	dec	ecx
1368
	dec	ebx
1369
	jmp	convert_to_quoted_string
1370
      symbol_character_conversion:
109 heavyiron 1371
	cmp	al,22h
2665 dunkaist 1372
	je	after_macro_operators
1373
	cmp	al,'`'
1374
	je	reduce_symbol_conversion
1375
	lea	ebx,[edi+5]
1376
	xor	ecx,ecx
1377
	or	al,al
1378
	jz	convert_to_quoted_string
1379
	cmp	al,'#'
1380
	je	convert_to_quoted_string
1381
	inc	ecx
1382
      convert_to_quoted_string:
109 heavyiron 1383
	sub	ebx,edx
2665 dunkaist 1384
	ja	shift_line_data
1385
	mov	al,22h
1386
	mov	dl,al
1387
	stos	byte [edi]
1388
	mov	ebx,edi
1389
	mov	eax,ecx
1390
	stos	dword [edi]
1391
	rep	movs byte [edi],[esi]
1392
	cmp	edi,esi
1393
	je	before_macro_operators
1394
	jmp	after_macro_operators
1395
      shift_line_data:
31 halyavin 1396
	push	ecx
2665 dunkaist 1397
	mov	edx,esi
1398
	lea	esi,[ebp-1]
1399
	add	ebp,ebx
1400
	lea	edi,[ebp-1]
1401
	lea	ecx,[esi+1]
1402
	sub	ecx,edx
1403
	std
1404
	rep	movs byte [edi],[esi]
1405
	cld
1406
	pop	eax
1407
	sub	edi,3
1408
	mov	dl,22h
1409
	mov	[edi-1],dl
1410
	mov	ebx,edi
1411
	mov	[edi],eax
1412
	lea	esi,[edi+4+eax]
1413
	jmp	before_macro_operators
1414
      concatenation:
31 halyavin 1415
	cmp	dl,1Ah
2665 dunkaist 1416
	je	symbol_concatenation
1417
	cmp	dl,22h
1418
	je	string_concatenation
1419
      no_concatenation:
31 halyavin 1420
	cmp	esi,edi
2665 dunkaist 1421
	je	before_macro_operators
1422
	jmp	after_macro_operators
1423
      symbol_concatenation:
31 halyavin 1424
	cmp	byte [esi],1Ah
2665 dunkaist 1425
	jne	no_concatenation
1426
	inc	esi
1427
	lods	byte [esi]
1428
	movzx	ecx,al
1429
	jecxz	do_symbol_concatenation
1430
	cmp	byte [esi],'\'
1431
	je	concatenate_escaped_symbol
1432
      do_symbol_concatenation:
31 halyavin 1433
	add	[ebx],cl
2665 dunkaist 1434
	jc	name_too_long
1435
	rep	movs byte [edi],[esi]
1436
	jmp	after_macro_operators
1437
      concatenate_escaped_symbol:
242 heavyiron 1438
	inc	esi
2665 dunkaist 1439
	dec	ecx
1440
	jz	do_symbol_concatenation
1441
	movzx	eax,byte [esi]
1442
	cmp	byte [characters+eax],0
1443
	jne	do_symbol_concatenation
1444
	sub	esi,3
1445
	jmp	no_concatenation
1446
      string_concatenation:
31 halyavin 1447
	cmp	byte [esi],22h
2665 dunkaist 1448
	je	do_string_concatenation
1449
	cmp	byte [esi],'`'
1450
	jne	no_concatenation
1451
      concatenate_converted_symbol:
109 heavyiron 1452
	inc	esi
2665 dunkaist 1453
	mov	al,[esi]
1454
	cmp	al,'`'
1455
	je	concatenate_converted_symbol
1456
	cmp	al,22h
1457
	je	do_string_concatenation
1458
	cmp	al,1Ah
1459
	jne	concatenate_converted_symbol_character
1460
	inc	esi
1461
	lods	byte [esi]
1462
	movzx	ecx,al
1463
	jecxz	finish_concatenating_converted_symbol
1464
	cmp	byte [esi],'\'
1465
	jne	finish_concatenating_converted_symbol
1466
	inc	esi
1467
	dec	ecx
1468
      finish_concatenating_converted_symbol:
242 heavyiron 1469
	add	[ebx],ecx
2665 dunkaist 1470
	rep	movs byte [edi],[esi]
1471
	jmp	after_macro_operators
1472
      concatenate_converted_symbol_character:
109 heavyiron 1473
	or	al,al
2665 dunkaist 1474
	jz	after_macro_operators
1475
	cmp	al,'#'
1476
	je	after_macro_operators
1477
	inc	dword [ebx]
1478
	movs	byte [edi],[esi]
1479
	jmp	after_macro_operators
1480
      do_string_concatenation:
31 halyavin 1481
	inc	esi
2665 dunkaist 1482
	lods	dword [esi]
1483
	mov	ecx,eax
1484
	add	[ebx],eax
1485
	rep	movs byte [edi],[esi]
1486
      after_macro_operators:
31 halyavin 1487
	lods	byte [esi]
2665 dunkaist 1488
	cmp	al,'`'
1489
	je	symbol_conversion
1490
	cmp	al,'#'
1491
	je	concatenation
1492
	stos	byte [edi]
1493
	cmp	al,1Ah
1494
	je	symbol_after_macro_operators
1495
	cmp	al,3Bh
1496
	je	no_more_macro_operators
1497
	cmp	al,22h
1498
	je	string_after_macro_operators
1499
	xor	dl,dl
1500
	or	al,al
1501
	jnz	after_macro_operators
1502
	ret
1503
      symbol_after_macro_operators:
31 halyavin 1504
	mov	dl,1Ah
2665 dunkaist 1505
	mov	ebx,edi
1506
	lods	byte [esi]
1507
	stos	byte [edi]
1508
	movzx	ecx,al
1509
	jecxz	symbol_after_macro_operatorss_ok
1510
	cmp	byte [esi],'\'
1511
	je	escaped_symbol
1512
      symbol_after_macro_operatorss_ok:
31 halyavin 1513
	rep	movs byte [edi],[esi]
2665 dunkaist 1514
	jmp	after_macro_operators
1515
      string_after_macro_operators:
31 halyavin 1516
	mov	dl,22h
2665 dunkaist 1517
	mov	ebx,edi
1518
	lods	dword [esi]
1519
	stos	dword [edi]
1520
	mov	ecx,eax
1521
	rep	movs byte [edi],[esi]
1522
	jmp	after_macro_operators
1523
31 halyavin 1524
 
1525
	push	[free_additional_memory]
2665 dunkaist 1526
	push	[macro_symbols]
1527
	mov	[macro_symbols],0
1528
	push	[counter_limit]
1529
	push	dword [edx+4]
1530
	mov	dword [edx+4],1
1531
	push	edx
1532
	mov	ebx,esi
1533
	mov	esi,[edx+8]
1534
	mov	eax,[edx+12]
1535
	mov	[macro_line],eax
1536
	mov	[counter_limit],0
1537
	xor	ebp,ebp
1538
      process_macro_arguments:
31 halyavin 1539
	mov	al,[esi]
2665 dunkaist 1540
	or	al,al
1541
	jz	arguments_end
1542
	cmp	al,'{'
1543
	je	arguments_end
1544
	inc	esi
1545
	cmp	al,'['
1546
	jne	get_macro_arguments
1547
	mov	ebp,esi
1548
	inc	esi
1549
	inc	[counter_limit]
1550
      get_macro_arguments:
31 halyavin 1551
	call	get_macro_argument
2665 dunkaist 1552
	lods	byte [esi]
1553
	cmp	al,','
1554
	je	next_argument
1555
	cmp	al,']'
1556
	je	next_arguments_group
1557
	dec	esi
1558
	jmp	arguments_end
1559
      next_argument:
31 halyavin 1560
	cmp	byte [ebx],','
2665 dunkaist 1561
	jne	process_macro_arguments
1562
	inc	ebx
1563
	jmp	process_macro_arguments
1564
      next_arguments_group:
31 halyavin 1565
	cmp	byte [ebx],','
2665 dunkaist 1566
	jne	arguments_end
1567
	inc	ebx
1568
	inc	[counter_limit]
1569
	mov	esi,ebp
1570
	jmp	process_macro_arguments
1571
      get_macro_argument:
31 halyavin 1572
	lods	byte [esi]
2665 dunkaist 1573
	movzx	ecx,al
1574
	mov	eax,[counter_limit]
1575
	call	add_macro_symbol
1576
	add	esi,ecx
1577
	xchg	esi,ebx
1578
	mov	[edx+12],esi
1579
	mov	[default_argument_value],0
1580
	call	skip_macro_argument_value
1581
	call	finish_macro_argument
1582
	xchg	esi,ebx
1583
	cmp	byte [esi],'='
1584
	je	argument_with_default_value
1585
	cmp	byte [esi],'*'
1586
	jne	macro_argument_ok
1587
	cmp	dword [edx+8],0
1588
	je	invalid_macro_arguments
1589
	inc	esi
1590
      macro_argument_ok:
31 halyavin 1591
	ret
2665 dunkaist 1592
      finish_macro_argument:
2664 dunkaist 1593
	mov	eax,[edx+12]
2665 dunkaist 1594
	mov	ecx,esi
1595
	sub	ecx,eax
1596
	cmp	byte [eax],'<'
1597
	jne	argument_value_length_ok
1598
	inc	dword [edx+12]
1599
	sub	ecx,2
1600
	or	ecx,80000000h
1601
      argument_value_length_ok:
2664 dunkaist 1602
	mov	[edx+8],ecx
2665 dunkaist 1603
	ret
1604
      argument_with_default_value:
2664 dunkaist 1605
	inc	esi
2665 dunkaist 1606
	push	esi
1607
	or	[default_argument_value],-1
1608
	call	skip_macro_argument_value
1609
	pop	eax
1610
	cmp	dword [edx+8],0
1611
	jne	macro_argument_ok
1612
	mov	[edx+12],eax
1613
	call	finish_macro_argument
1614
	jmp	macro_argument_ok
1615
      arguments_end:
31 halyavin 1616
	cmp	byte [ebx],0
2665 dunkaist 1617
	jne	invalid_macro_arguments
1618
	mov	eax,[esp+4]
1619
	dec	eax
1620
	call	process_macro
1621
	pop	edx
1622
	pop	dword [edx+4]
1623
	pop	[counter_limit]
1624
	pop	[macro_symbols]
1625
	pop	[free_additional_memory]
1626
	jmp	line_preprocessed
1627
use_instant_macro:
31 halyavin 1628
	push	edi [current_line] esi
2665 dunkaist 1629
	mov	eax,[error_line]
1630
	mov	[current_line],eax
1631
	mov	[macro_line],eax
1632
	mov	esi,[instant_macro_start]
1633
	cmp	[base_code],10h
1634
	jae	do_match
1635
	cmp	[base_code],0
1636
	jne	do_irp
1637
	call	precalculate_value
1638
	cmp	eax,0
1639
	jl	value_out_of_range
1640
	push	[free_additional_memory]
1641
	push	[macro_symbols]
1642
	mov	[macro_symbols],0
1643
	push	[counter_limit]
1644
	mov	[struc_name],0
1645
	mov	[counter_limit],eax
1646
	lods	byte [esi]
1647
	or	al,al
1648
	jz	rept_counters_ok
1649
	cmp	al,'{'
1650
	je	rept_counters_ok
1651
	cmp	al,1Ah
1652
	jne	invalid_macro_arguments
1653
      add_rept_counter:
31 halyavin 1654
	lods	byte [esi]
2665 dunkaist 1655
	movzx	ecx,al
1656
	xor	eax,eax
1657
	call	add_macro_symbol
1658
	add	esi,ecx
1659
	xor	eax,eax
1660
	mov	dword [edx+12],eax
1661
	inc	eax
1662
	mov	dword [edx+8],eax
1663
	lods	byte [esi]
1664
	cmp	al,':'
1665
	jne	rept_counter_added
1666
	push	edx
1667
	call	precalculate_value
1668
	mov	edx,eax
1669
	add	edx,[counter_limit]
1670
	jo	value_out_of_range
1671
	pop	edx
1672
	mov	dword [edx+8],eax
1673
	lods	byte [esi]
1674
      rept_counter_added:
31 halyavin 1675
	cmp	al,','
2665 dunkaist 1676
	jne	rept_counters_ok
1677
	lods	byte [esi]
1678
	cmp	al,1Ah
1679
	jne	invalid_macro_arguments
1680
	jmp	add_rept_counter
1681
      rept_counters_ok:
31 halyavin 1682
	dec	esi
2665 dunkaist 1683
	cmp	[counter_limit],0
1684
	je	instant_macro_finish
1685
      instant_macro_parameters_ok:
31 halyavin 1686
	xor	eax,eax
2665 dunkaist 1687
	call	process_macro
1688
      instant_macro_finish:
872 heavyiron 1689
	pop	[counter_limit]
2665 dunkaist 1690
	pop	[macro_symbols]
1691
	pop	[free_additional_memory]
1692
      instant_macro_done:
31 halyavin 1693
	pop	ebx esi edx
2665 dunkaist 1694
	cmp	byte [ebx],0
1695
	je	line_preprocessed
1696
	mov	[current_line],edi
1697
	mov	ecx,4
1698
	rep	movs dword [edi],[esi]
1699
	test	[macro_status],0Fh
1700
	jz	instant_macro_attached_line
1701
	mov	ax,3Bh
1702
	stos	word [edi]
1703
      instant_macro_attached_line:
31 halyavin 1704
	mov	esi,ebx
2665 dunkaist 1705
	sub	edx,ebx
1706
	mov	ecx,edx
1707
	call	move_data
1708
	jmp	initial_preprocessing_ok
1709
      precalculate_value:
1189 heavyiron 1710
	push	edi
2665 dunkaist 1711
	call	convert_expression
1712
	mov	al,')'
1713
	stosb
1714
	push	esi
1715
	mov	esi,[esp+4]
1716
	mov	[error_line],0
1717
	mov	[value_size],0
1718
	call	calculate_expression
1719
	cmp	[error_line],0
1720
	je	value_precalculated
1721
	jmp	[error]
1722
      value_precalculated:
1723
	mov	eax,[edi]
1724
	mov	ecx,[edi+4]
1725
	cdq
1726
	cmp	edx,ecx
1727
	jne	value_out_of_range
1728
	cmp	dl,[edi+13]
1729
	jne	value_out_of_range
1730
	pop	esi edi
1731
	ret
1732
do_irp:
31 halyavin 1733
	cmp	byte [esi],1Ah
2665 dunkaist 1734
	jne	invalid_macro_arguments
1735
	movzx	eax,byte [esi+1]
1736
	lea	esi,[esi+2+eax]
1737
	lods	byte [esi]
1738
	cmp	[base_code],1
1739
	ja	irps_name_ok
1740
	cmp	al,'='
1741
	je	irp_with_default_value
1742
	cmp	al,'*'
1743
	jne	irp_name_ok
1744
	lods	byte [esi]
1745
      irp_name_ok:
31 halyavin 1746
	cmp	al,','
2665 dunkaist 1747
	jne	invalid_macro_arguments
1748
	jmp	irp_parameters_start
1749
      irp_with_default_value:
2664 dunkaist 1750
	xor	ebp,ebp
2665 dunkaist 1751
	or	[default_argument_value],-1
1752
	call	skip_macro_argument_value
1753
	inc	esi
1754
	jmp	irp_parameters_start
4039 heavyiron 1755
      irps_name_ok:
31 halyavin 1756
	cmp	al,','
2665 dunkaist 1757
	jne	invalid_macro_arguments
1758
	mov	al,[esi]
1759
	or	al,al
1760
	jz	instant_macro_done
1761
	cmp	al,'{'
1762
	je	instant_macro_done
1763
      irp_parameters_start:
31 halyavin 1764
	xor	eax,eax
2665 dunkaist 1765
	push	[free_additional_memory]
1766
	push	[macro_symbols]
1767
	mov	[macro_symbols],eax
1768
	push	[counter_limit]
1769
	mov	[counter_limit],eax
1770
	mov	[struc_name],eax
1771
	mov	ebx,esi
1772
	cmp	[base_code],1
1773
	ja	get_irps_parameter
1774
	mov	edx,[parameters_end]
1775
	mov	al,[edx]
1776
	push	eax
1777
	mov	byte [edx],0
1778
      get_irp_parameter:
31 halyavin 1779
	inc	[counter_limit]
2665 dunkaist 1780
	mov	esi,[instant_macro_start]
1781
	inc	esi
1782
	call	get_macro_argument
1783
	cmp	byte [ebx],','
1784
	jne	irp_parameters_end
1785
	inc	ebx
1786
	jmp	get_irp_parameter
1787
      irp_parameters_end:
31 halyavin 1788
	mov	esi,ebx
2665 dunkaist 1789
	pop	eax
1790
	mov	[esi],al
1791
	jmp	instant_macro_parameters_ok
1792
      get_irps_parameter:
31 halyavin 1793
	mov	esi,[instant_macro_start]
2665 dunkaist 1794
	inc	esi
1795
	lods	byte [esi]
1796
	movzx	ecx,al
1797
	inc	[counter_limit]
1798
	mov	eax,[counter_limit]
1799
	call	add_macro_symbol
1800
	mov	[edx+12],ebx
1801
	cmp	byte [ebx],1Ah
1802
	je	irps_symbol
1803
	cmp	byte [ebx],22h
1804
	je	irps_quoted_string
1805
	mov	eax,1
1806
	jmp	irps_parameter_ok
1807
      irps_quoted_string:
31 halyavin 1808
	mov	eax,[ebx+1]
2665 dunkaist 1809
	add	eax,1+4
1810
	jmp	irps_parameter_ok
1811
      irps_symbol:
31 halyavin 1812
	movzx	eax,byte [ebx+1]
2665 dunkaist 1813
	add	eax,1+1
1814
      irps_parameter_ok:
31 halyavin 1815
	mov	[edx+8],eax
2665 dunkaist 1816
	add	ebx,eax
1817
	cmp	byte [ebx],0
1818
	je	irps_parameters_end
1819
	cmp	byte [ebx],'{'
1820
	jne	get_irps_parameter
1821
      irps_parameters_end:
31 halyavin 1822
	mov	esi,ebx
2665 dunkaist 1823
	jmp	instant_macro_parameters_ok
1824
do_match:
31 halyavin 1825
	mov	ebx,esi
2665 dunkaist 1826
	call	skip_pattern
1827
	call	exact_match
1828
	mov	edx,edi
1829
	mov	al,[ebx]
1830
	cmp	al,1Ah
1831
	je	free_match
1832
	cmp	al,','
1833
	jne	instant_macro_done
1834
	cmp	esi,[parameters_end]
1835
	je	matched_pattern
1836
	jmp	instant_macro_done
1837
      free_match:
31 halyavin 1838
	add	edx,12
2665 dunkaist 1839
	cmp	edx,[memory_end]
1840
	ja	out_of_memory
1841
	mov	[edx-12],ebx
1842
	mov	[edx-8],esi
1843
	call	skip_match_element
1844
	jc	try_different_matching
1845
	mov	[edx-4],esi
1846
	movzx	eax,byte [ebx+1]
1847
	lea	ebx,[ebx+2+eax]
1848
	cmp	byte [ebx],1Ah
1849
	je	free_match
1850
      find_exact_match:
31 halyavin 1851
	call	exact_match
2665 dunkaist 1852
	cmp	esi,[parameters_end]
1853
	je	end_matching
1854
	cmp	byte [ebx],1Ah
1855
	je	free_match
1856
	mov	ebx,[edx-12]
1857
	movzx	eax,byte [ebx+1]
1858
	lea	ebx,[ebx+2+eax]
1859
	mov	esi,[edx-4]
1860
	jmp	match_more_elements
1861
      try_different_matching:
31 halyavin 1862
	sub	edx,12
2665 dunkaist 1863
	cmp	edx,edi
1864
	je	instant_macro_done
1865
	mov	ebx,[edx-12]
1866
	movzx	eax,byte [ebx+1]
1867
	lea	ebx,[ebx+2+eax]
1868
	cmp	byte [ebx],1Ah
1869
	je	try_different_matching
1870
	mov	esi,[edx-4]
1871
      match_more_elements:
31 halyavin 1872
	call	skip_match_element
2665 dunkaist 1873
	jc	try_different_matching
1874
	mov	[edx-4],esi
1875
	jmp	find_exact_match
1876
      skip_match_element:
31 halyavin 1877
	cmp	esi,[parameters_end]
2665 dunkaist 1878
	je	cannot_match
1879
	mov	al,[esi]
1880
	cmp	al,1Ah
1881
	je	skip_match_symbol
1882
	cmp	al,22h
1883
	je	skip_match_quoted_string
1884
	add	esi,1
1885
	ret
1886
      skip_match_quoted_string:
31 halyavin 1887
	mov	eax,[esi+1]
2665 dunkaist 1888
	add	esi,5
1889
	jmp	skip_match_ok
1890
      skip_match_symbol:
31 halyavin 1891
	movzx	eax,byte [esi+1]
2665 dunkaist 1892
	add	esi,2
1893
      skip_match_ok:
31 halyavin 1894
	add	esi,eax
2665 dunkaist 1895
	ret
1896
      cannot_match:
31 halyavin 1897
	stc
2665 dunkaist 1898
	ret
1899
      exact_match:
31 halyavin 1900
	cmp	esi,[parameters_end]
2665 dunkaist 1901
	je	exact_match_complete
1902
	mov	ah,[esi]
1903
	mov	al,[ebx]
1904
	cmp	al,','
1905
	je	exact_match_complete
1906
	cmp	al,1Ah
1907
	je	exact_match_complete
1908
	cmp	al,'='
1909
	je	match_verbatim
1910
	call	match_elements
1911
	je	exact_match
1912
      exact_match_complete:
31 halyavin 1913
	ret
2665 dunkaist 1914
      match_verbatim:
31 halyavin 1915
	inc	ebx
2665 dunkaist 1916
	call	match_elements
1917
	je	exact_match
1918
	dec	ebx
1919
	ret
1920
      match_elements:
31 halyavin 1921
	mov	al,[ebx]
2665 dunkaist 1922
	cmp	al,1Ah
1923
	je	match_symbols
1924
	cmp	al,22h
1925
	je	match_quoted_strings
1926
	cmp	al,ah
1927
	je	symbol_characters_matched
1928
	ret
1929
      symbol_characters_matched:
31 halyavin 1930
	lea	ebx,[ebx+1]
2665 dunkaist 1931
	lea	esi,[esi+1]
1932
	ret
1933
      match_quoted_strings:
31 halyavin 1934
	mov	ecx,[ebx+1]
2665 dunkaist 1935
	add	ecx,5
1936
	jmp	compare_elements
1937
      match_symbols:
31 halyavin 1938
	movzx	ecx,byte [ebx+1]
2665 dunkaist 1939
	add	ecx,2
1940
      compare_elements:
31 halyavin 1941
	mov	eax,esi
2665 dunkaist 1942
	mov	ebp,edi
1943
	mov	edi,ebx
1944
	repe	cmps byte [esi],[edi]
1945
	jne	elements_mismatch
1946
	mov	ebx,edi
1947
	mov	edi,ebp
1948
	ret
1949
      elements_mismatch:
31 halyavin 1950
	mov	esi,eax
2665 dunkaist 1951
	mov	edi,ebp
1952
	ret
1953
      end_matching:
31 halyavin 1954
	cmp	byte [ebx],','
2665 dunkaist 1955
	jne	instant_macro_done
1956
      matched_pattern:
31 halyavin 1957
	xor	eax,eax
2665 dunkaist 1958
	push	[free_additional_memory]
1959
	push	[macro_symbols]
1960
	mov	[macro_symbols],eax
1961
	push	[counter_limit]
1962
	mov	[counter_limit],eax
1963
	mov	[struc_name],eax
1964
	push	esi edi edx
1965
      add_matched_symbol:
31 halyavin 1966
	cmp	edi,[esp]
2665 dunkaist 1967
	je	matched_symbols_ok
1968
	mov	esi,[edi]
1969
	inc	esi
1970
	lods	byte [esi]
1971
	movzx	ecx,al
1972
	xor	eax,eax
1973
	call	add_macro_symbol
1974
	mov	eax,[edi+4]
1975
	mov	dword [edx+12],eax
1976
	mov	ecx,[edi+8]
1977
	sub	ecx,eax
1978
	mov	dword [edx+8],ecx
1979
	add	edi,12
1980
	jmp	add_matched_symbol
1981
      matched_symbols_ok:
31 halyavin 1982
	pop	edx edi esi
2665 dunkaist 1983
	jmp	instant_macro_parameters_ok
1984
31 halyavin 1985
 
1986
	push	dword [macro_status]
2665 dunkaist 1987
	or	[macro_status],10h
1988
	push	[counter]
1989
	push	[macro_block]
1990
	push	[macro_block_line]
1991
	push	[macro_block_line_number]
1992
	push	[struc_label]
1993
	push	[struc_name]
1994
	push	eax
1995
	push	[current_line]
1996
	lods	byte [esi]
1997
	cmp	al,'{'
1998
	je	macro_instructions_start
1999
	or	al,al
2000
	jnz	unexpected_characters
2001
      find_macro_instructions:
31 halyavin 2002
	mov	[macro_line],esi
2665 dunkaist 2003
	add	esi,16+2
2004
	lods	byte [esi]
2005
	or	al,al
2006
	jz	find_macro_instructions
2007
	cmp	al,'{'
2008
	je	macro_instructions_start
2009
	cmp	al,3Bh
2010
	jne	unexpected_characters
2011
	call	skip_foreign_symbol
2012
	jmp	find_macro_instructions
2013
      macro_instructions_start:
31 halyavin 2014
	mov	ecx,80000000h
2665 dunkaist 2015
	mov	[macro_block],esi
2016
	mov	eax,[macro_line]
2017
	mov	[macro_block_line],eax
2018
	mov	[macro_block_line_number],ecx
2019
	xor	eax,eax
2020
	mov	[counter],eax
2021
	cmp	[counter_limit],eax
2022
	je	process_macro_line
2023
	inc	[counter]
2024
      process_macro_line:
31 halyavin 2025
	lods	byte [esi]
2665 dunkaist 2026
	or	al,al
2027
	jz	process_next_line
2028
	cmp	al,'}'
2029
	je	macro_block_processed
2030
	dec	esi
2031
	mov	[current_line],edi
2032
	lea	eax,[edi+10h]
2033
	cmp	eax,[memory_end]
2034
	jae	out_of_memory
2035
	mov	eax,[esp+4]
2036
	or	eax,eax
2037
	jz	instant_macro_line_header
2038
	stos	dword [edi]
2039
	mov	eax,ecx
2040
	stos	dword [edi]
2041
	mov	eax,[esp]
2042
	stos	dword [edi]
2043
	mov	eax,[macro_line]
2044
	stos	dword [edi]
2045
	jmp	macro_line_header_ok
2046
      instant_macro_line_header:
31 halyavin 2047
	mov	eax,[esp]
4478 dunkaist 2048
	add	eax,16
2049
      find_defining_directive:
2050
	inc	eax
2051
	cmp	byte [eax-1],3Bh
2052
	je	defining_directive_ok
2053
	cmp	byte [eax-1],1Ah
2054
	jne	find_defining_directive
2055
	push	eax
2056
	movzx	eax,byte [eax]
2057
	inc	eax
2058
	add	[esp],eax
2059
	pop	eax
2060
	jmp	find_defining_directive
2061
      defining_directive_ok:
2062
	stos	dword [edi]
2665 dunkaist 2063
	mov	eax,ecx
2064
	stos	dword [edi]
2065
	mov	eax,[macro_line]
2066
	stos	dword [edi]
2067
	stos	dword [edi]
2068
      macro_line_header_ok:
31 halyavin 2069
	or	[macro_status],20h
2665 dunkaist 2070
	push	ebx ecx
2071
	test	[macro_status],0Fh
2072
	jz	process_macro_line_element
2073
	mov	ax,3Bh
2074
	stos	word [edi]
2075
      process_macro_line_element:
31 halyavin 2076
	lea	eax,[edi+100h]
2665 dunkaist 2077
	cmp	eax,[memory_end]
2078
	jae	out_of_memory
2079
	lods	byte [esi]
2080
	cmp	al,'}'
2081
	je	macro_line_processed
2082
	or	al,al
2083
	jz	macro_line_processed
2084
	cmp	al,1Ah
2085
	je	process_macro_symbol
2086
	cmp	al,3Bh
2087
	je	macro_foreign_line
2088
	and	[macro_status],not 20h
2089
	stos	byte [edi]
2090
	cmp	al,22h
2091
	jne	process_macro_line_element
2092
      copy_macro_string:
31 halyavin 2093
	mov	ecx,[esi]
2665 dunkaist 2094
	add	ecx,4
2095
	call	move_data
2096
	jmp	process_macro_line_element
2097
      process_macro_symbol:
31 halyavin 2098
	push	esi edi
2665 dunkaist 2099
	test	[macro_status],20h
2100
	jz	not_macro_directive
2101
	movzx	ecx,byte [esi]
2102
	inc	esi
2103
	mov	edi,macro_directives
2104
	call	get_directive
2105
	jnc	process_macro_directive
2106
	dec	esi
2107
	jmp	not_macro_directive
2108
      process_macro_directive:
31 halyavin 2109
	mov	edx,eax
2665 dunkaist 2110
	pop	edi eax
2111
	mov	byte [edi],0
2112
	inc	edi
2113
	pop	ecx ebx
2114
	jmp	near edx
2115
      not_macro_directive:
31 halyavin 2116
	and	[macro_status],not 20h
2665 dunkaist 2117
	movzx	ecx,byte [esi]
2118
	inc	esi
2119
	mov	eax,[counter]
2120
	call	get_macro_symbol
2121
	jnc	group_macro_symbol
2122
	xor	eax,eax
2123
	cmp	[counter],eax
2124
	je	multiple_macro_symbol_values
2125
	call	get_macro_symbol
2126
	jc	not_macro_symbol
2127
      replace_macro_symbol:
31 halyavin 2128
	pop	edi eax
2665 dunkaist 2129
	mov	ecx,[edx+8]
2130
	mov	edx,[edx+12]
2131
	or	edx,edx
2132
	jz	replace_macro_counter
2133
	and	ecx,not 80000000h
2134
	xchg	esi,edx
2135
	call	move_data
2136
	mov	esi,edx
2137
	jmp	process_macro_line_element
2138
      group_macro_symbol:
31 halyavin 2139
	xor	eax,eax
2665 dunkaist 2140
	cmp	[counter],eax
2141
	je	replace_macro_symbol
2142
	push	esi edx
2143
	sub	esi,ecx
2144
	call	get_macro_symbol
2145
	mov	ebx,edx
2146
	pop	edx esi
2147
	jc	replace_macro_symbol
2148
	cmp	edx,ebx
2149
	ja	replace_macro_symbol
2150
	mov	edx,ebx
2151
	jmp	replace_macro_symbol
2152
      multiple_macro_symbol_values:
31 halyavin 2153
	inc	eax
2665 dunkaist 2154
	push	eax
2155
	call	get_macro_symbol
2156
	pop	eax
2157
	jc	not_macro_symbol
2158
	pop	edi
2159
	push	ecx
2160
	mov	ecx,[edx+8]
2161
	mov	edx,[edx+12]
2162
	xchg	esi,edx
2163
	btr	ecx,31
2164
	jc	enclose_macro_symbol_value
2165
	rep	movs byte [edi],[esi]
2166
	jmp	macro_symbol_value_ok
2167
      enclose_macro_symbol_value:
31 halyavin 2168
	mov	byte [edi],'<'
2665 dunkaist 2169
	inc	edi
2170
	rep	movs byte [edi],[esi]
2171
	mov	byte [edi],'>'
2172
	inc	edi
2173
      macro_symbol_value_ok:
31 halyavin 2174
	cmp	eax,[counter_limit]
2665 dunkaist 2175
	je	multiple_macro_symbol_values_ok
2176
	mov	byte [edi],','
2177
	inc	edi
2178
	mov	esi,edx
2179
	pop	ecx
2180
	push	edi
2181
	sub	esi,ecx
2182
	jmp	multiple_macro_symbol_values
2183
      multiple_macro_symbol_values_ok:
31 halyavin 2184
	pop	ecx eax
2665 dunkaist 2185
	mov	esi,edx
2186
	jmp	process_macro_line_element
2187
      replace_macro_counter:
31 halyavin 2188
	mov	eax,[counter]
2665 dunkaist 2189
	and	eax,not 80000000h
2190
	jz	group_macro_counter
2191
	add	ecx,eax
2192
	dec	ecx
2193
	call	store_number_symbol
2194
	jmp	process_macro_line_element
2195
      group_macro_counter:
31 halyavin 2196
	mov	edx,ecx
2665 dunkaist 2197
	xor	ecx,ecx
2198
      multiple_macro_counter_values:
31 halyavin 2199
	push	ecx edx
2665 dunkaist 2200
	add	ecx,edx
2201
	call	store_number_symbol
2202
	pop	edx ecx
2203
	inc	ecx
2204
	cmp	ecx,[counter_limit]
2205
	je	process_macro_line_element
2206
	mov	byte [edi],','
2207
	inc	edi
2208
	jmp	multiple_macro_counter_values
2209
      store_number_symbol:
31 halyavin 2210
	cmp	ecx,0
2665 dunkaist 2211
	jge	numer_symbol_sign_ok
2212
	neg	ecx
2213
	mov	al,'-'
2214
	stos	byte [edi]
2215
      numer_symbol_sign_ok:
1189 heavyiron 2216
	mov	ax,1Ah
2665 dunkaist 2217
	stos	word [edi]
2218
	push	edi
2219
	mov	eax,ecx
2220
	mov	ecx,1000000000
2221
	xor	edx,edx
2222
	xor	bl,bl
2223
      store_number_digits:
31 halyavin 2224
	div	ecx
2665 dunkaist 2225
	push	edx
2226
	or	bl,bl
2227
	jnz	store_number_digit
2228
	cmp	ecx,1
2229
	je	store_number_digit
2230
	or	al,al
2231
	jz	number_digit_ok
2232
	not	bl
2233
      store_number_digit:
31 halyavin 2234
	add	al,30h
2665 dunkaist 2235
	stos	byte [edi]
2236
      number_digit_ok:
31 halyavin 2237
	mov	eax,ecx
2665 dunkaist 2238
	xor	edx,edx
2239
	mov	ecx,10
2240
	div	ecx
2241
	mov	ecx,eax
2242
	pop	eax
2243
	or	ecx,ecx
2244
	jnz	store_number_digits
2245
	pop	ebx
2246
	mov	eax,edi
2247
	sub	eax,ebx
2248
	mov	[ebx-1],al
2249
	ret
2250
      not_macro_symbol:
31 halyavin 2251
	pop	edi esi
2665 dunkaist 2252
	mov	al,1Ah
2253
	stos	byte [edi]
2254
	mov	al,[esi]
2255
	inc	esi
2256
	stos	byte [edi]
2257
	cmp	byte [esi],'.'
2258
	jne	copy_raw_symbol
2259
	mov	ebx,[esp+8+8]
2260
	or	ebx,ebx
2261
	jz	copy_raw_symbol
2262
	cmp	al,1
2263
	je	copy_struc_name
2264
	xchg	esi,ebx
2265
	movzx	ecx,byte [esi-1]
2266
	add	[edi-1],cl
2267
	jc	name_too_long
2268
	rep	movs byte [edi],[esi]
2269
	xchg	esi,ebx
2270
      copy_raw_symbol:
31 halyavin 2271
	movzx	ecx,al
2665 dunkaist 2272
	rep	movs byte [edi],[esi]
2273
	jmp	process_macro_line_element
2274
      copy_struc_name:
31 halyavin 2275
	inc	esi
2665 dunkaist 2276
	xchg	esi,ebx
2277
	movzx	ecx,byte [esi-1]
2278
	mov	[edi-1],cl
2279
	rep	movs byte [edi],[esi]
2280
	xchg	esi,ebx
2281
	mov	eax,[esp+8+12]
2282
	cmp	byte [eax],3Bh
2283
	je	process_macro_line_element
2284
	cmp	byte [eax],1Ah
2285
	jne	disable_replaced_struc_name
2286
	mov	byte [eax],3Bh
2287
	jmp	process_macro_line_element
2288
      disable_replaced_struc_name:
31 halyavin 2289
	mov	ebx,[esp+8+8]
2665 dunkaist 2290
	push	esi edi
2291
	lea	edi,[ebx-3]
2292
	lea	esi,[edi-2]
2293
	lea	ecx,[esi+1]
2294
	sub	ecx,eax
2295
	std
2296
	rep	movs byte [edi],[esi]
2297
	cld
2298
	mov	word [eax],3Bh
2299
	pop	edi esi
2300
	jmp	process_macro_line_element
2301
      skip_foreign_symbol:
31 halyavin 2302
	lods	byte [esi]
2665 dunkaist 2303
	movzx	eax,al
2304
	add	esi,eax
2305
      skip_foreign_line:
31 halyavin 2306
	lods	byte [esi]
2665 dunkaist 2307
	cmp	al,1Ah
2308
	je	skip_foreign_symbol
2309
	cmp	al,3Bh
2310
	je	skip_foreign_symbol
2311
	cmp	al,22h
2312
	je	skip_foreign_string
2313
	or	al,al
2314
	jnz	skip_foreign_line
2315
	ret
2316
      skip_foreign_string:
31 halyavin 2317
	lods	dword [esi]
2665 dunkaist 2318
	add	esi,eax
2319
	jmp	skip_foreign_line
2320
      macro_foreign_line:
31 halyavin 2321
	call	skip_foreign_symbol
2665 dunkaist 2322
      macro_line_processed:
31 halyavin 2323
	mov	byte [edi],0
2665 dunkaist 2324
	inc	edi
2325
	push	eax
2326
	call	preprocess_line
2327
	pop	eax
2328
	pop	ecx ebx
2329
	cmp	al,'}'
2330
	je	macro_block_processed
2331
      process_next_line:
31 halyavin 2332
	inc	ecx
2665 dunkaist 2333
	mov	[macro_line],esi
2334
	add	esi,16+2
2335
	jmp	process_macro_line
2336
      macro_block_processed:
31 halyavin 2337
	call	close_macro_block
2665 dunkaist 2338
	jc	process_macro_line
2339
	pop	[current_line]
2340
	add	esp,12
2341
	pop	[macro_block_line_number]
2342
	pop	[macro_block_line]
2343
	pop	[macro_block]
2344
	pop	[counter]
2345
	pop	eax
2346
	and	al,0F0h
2347
	and	[macro_status],0Fh
2348
	or	[macro_status],al
2349
	ret
2350
31 halyavin 2351
 
2352
	lods	byte [esi]
2665 dunkaist 2353
	cmp	al,1Ah
2354
	jne	invalid_argument
2355
	mov	byte [edi-1],3Bh
2356
	xor	al,al
2357
	stos	byte [edi]
2358
      make_local_symbol:
31 halyavin 2359
	push	ecx
2665 dunkaist 2360
	lods	byte [esi]
2361
	movzx	ecx,al
2362
	mov	eax,[counter]
2363
	call	add_macro_symbol
2364
	mov	[edx+12],edi
2365
	movzx	eax,[locals_counter]
2366
	add	eax,ecx
2367
	inc	eax
2368
	cmp	eax,100h
2369
	jae	name_too_long
2370
	lea	ebp,[edi+2+eax]
2371
	cmp	ebp,[memory_end]
2372
	jae	out_of_memory
2373
	mov	ah,al
2374
	mov	al,1Ah
2375
	stos	word [edi]
2376
	rep	movs byte [edi],[esi]
2377
	mov	al,'?'
2378
	stos	byte [edi]
2379
	push	esi
2380
	mov	esi,locals_counter+1
2381
	movzx	ecx,[locals_counter]
2382
	rep	movs byte [edi],[esi]
2383
	pop	esi
2384
	mov	eax,edi
2385
	sub	eax,[edx+12]
2386
	mov	[edx+8],eax
2387
	xor	al,al
2388
	stos	byte [edi]
2389
	mov	eax,locals_counter
2390
	movzx	ecx,byte [eax]
2391
      counter_loop:
31 halyavin 2392
	inc	byte [eax+ecx]
2665 dunkaist 2393
	cmp	byte [eax+ecx],'9'+1
2394
	jb	counter_ok
2395
	jne	letter_digit
2396
	mov	byte [eax+ecx],'A'
2397
	jmp	counter_ok
2398
      letter_digit:
31 halyavin 2399
	cmp	byte [eax+ecx],'Z'+1
2665 dunkaist 2400
	jb	counter_ok
2401
	jne	small_letter_digit
2402
	mov	byte [eax+ecx],'a'
2403
	jmp	counter_ok
2404
      small_letter_digit:
692 heavyiron 2405
	cmp	byte [eax+ecx],'z'+1
2665 dunkaist 2406
	jb	counter_ok
2407
	mov	byte [eax+ecx],'0'
2408
	loop	counter_loop
2409
	inc	byte [eax]
2410
	movzx	ecx,byte [eax]
2411
	mov	byte [eax+ecx],'0'
2412
      counter_ok:
31 halyavin 2413
	pop	ecx
2665 dunkaist 2414
	lods	byte [esi]
2415
	cmp	al,'}'
2416
	je	macro_block_processed
2417
	or	al,al
2418
	jz	process_next_line
2419
	cmp	al,','
2420
	jne	extra_characters_on_line
2421
	dec	edi
2422
	lods	byte [esi]
2423
	cmp	al,1Ah
2424
	je	make_local_symbol
2425
	jmp	invalid_argument
2426
common_block:
31 halyavin 2427
	call	close_macro_block
2665 dunkaist 2428
	jc	process_macro_line
2429
	mov	[counter],0
2430
	jmp	new_macro_block
2431
forward_block:
31 halyavin 2432
	cmp	[counter_limit],0
2665 dunkaist 2433
	je	common_block
2434
	call	close_macro_block
2435
	jc	process_macro_line
2436
	mov	[counter],1
2437
	jmp	new_macro_block
2438
reverse_block:
31 halyavin 2439
	cmp	[counter_limit],0
2665 dunkaist 2440
	je	common_block
2441
	call	close_macro_block
2442
	jc	process_macro_line
2443
	mov	eax,[counter_limit]
2444
	or	eax,80000000h
2445
	mov	[counter],eax
2446
      new_macro_block:
31 halyavin 2447
	mov	[macro_block],esi
2665 dunkaist 2448
	mov	eax,[macro_line]
2449
	mov	[macro_block_line],eax
2450
	mov	[macro_block_line_number],ecx
2451
	jmp	process_macro_line
2452
close_macro_block:
31 halyavin 2453
	cmp	[counter],0
2665 dunkaist 2454
	je	block_closed
2455
	jl	reverse_counter
2456
	mov	eax,[counter]
2457
	cmp	eax,[counter_limit]
2458
	je	block_closed
2459
	inc	[counter]
2460
	jmp	continue_block
2461
      reverse_counter:
31 halyavin 2462
	mov	eax,[counter]
2665 dunkaist 2463
	dec	eax
2464
	cmp	eax,80000000h
2465
	je	block_closed
2466
	mov	[counter],eax
2467
      continue_block:
31 halyavin 2468
	mov	esi,[macro_block]
2665 dunkaist 2469
	mov	eax,[macro_block_line]
2470
	mov	[macro_line],eax
2471
	mov	ecx,[macro_block_line_number]
2472
	stc
2473
	ret
2474
      block_closed:
31 halyavin 2475
	clc
2665 dunkaist 2476
	ret
2477
get_macro_symbol:
31 halyavin 2478
	push	ecx
2665 dunkaist 2479
	call	find_macro_symbol_leaf
2480
	jc	macro_symbol_not_found
2481
	mov	edx,[ebx]
2482
	mov	ebx,esi
2483
      try_macro_symbol:
31 halyavin 2484
	or	edx,edx
2665 dunkaist 2485
	jz	macro_symbol_not_found
2486
	mov	ecx,[esp]
2487
	mov	edi,[edx+4]
2488
	repe	cmps byte [esi],[edi]
2489
	je	macro_symbol_found
2490
	mov	esi,ebx
2491
	mov	edx,[edx]
2492
	jmp	try_macro_symbol
2493
      macro_symbol_found:
31 halyavin 2494
	pop	ecx
2665 dunkaist 2495
	clc
2496
	ret
2497
      macro_symbol_not_found:
31 halyavin 2498
	pop	ecx
2665 dunkaist 2499
	stc
2500
	ret
2501
      find_macro_symbol_leaf:
31 halyavin 2502
	shl	eax,8
2665 dunkaist 2503
	mov	al,cl
2504
	mov	ebp,eax
2505
	mov	ebx,macro_symbols
2506
      follow_macro_symbols_tree:
31 halyavin 2507
	mov	edx,[ebx]
2665 dunkaist 2508
	or	edx,edx
2509
	jz	no_such_macro_symbol
2510
	xor	eax,eax
2511
	shr	ebp,1
2512
	adc	eax,0
2513
	lea	ebx,[edx+eax*4]
2514
	or	ebp,ebp
2515
	jnz	follow_macro_symbols_tree
2516
	add	ebx,8
2517
	clc
2518
	ret
2519
      no_such_macro_symbol:
31 halyavin 2520
	stc
2665 dunkaist 2521
	ret
2522
add_macro_symbol:
31 halyavin 2523
	push	ebx ebp
2665 dunkaist 2524
	call	find_macro_symbol_leaf
2525
	jc	extend_macro_symbol_tree
2526
	mov	eax,[ebx]
2527
      make_macro_symbol:
31 halyavin 2528
	mov	edx,[free_additional_memory]
2665 dunkaist 2529
	add	edx,16
2530
	cmp	edx,[labels_list]
2531
	ja	out_of_memory
2532
	xchg	edx,[free_additional_memory]
2533
	mov	[ebx],edx
2534
	mov	[edx],eax
2535
	mov	[edx+4],esi
2536
	pop	ebp ebx
2537
	ret
2538
      extend_macro_symbol_tree:
31 halyavin 2539
	mov	edx,[free_additional_memory]
2665 dunkaist 2540
	add	edx,16
2541
	cmp	edx,[labels_list]
2542
	ja	out_of_memory
2543
	xchg	edx,[free_additional_memory]
2544
	xor	eax,eax
2545
	mov	[edx],eax
2546
	mov	[edx+4],eax
2547
	mov	[edx+8],eax
2548
	mov	[edx+12],eax
2549
	shr	ebp,1
2550
	adc	eax,0
2551
	mov	[ebx],edx
2552
	lea	ebx,[edx+eax*4]
2553
	or	ebp,ebp
2554
	jnz	extend_macro_symbol_tree
2555
	add	ebx,8
2556
	xor	eax,eax
2557
	jmp	make_macro_symbol
2558
31 halyavin 2559
 
2560
	lods	byte [esi]
2665 dunkaist 2561
	cmp	al,22h
2562
	jne	invalid_argument
2563
	lods	dword [esi]
2564
	cmp	byte [esi+eax],0
2565
	jne	extra_characters_on_line
2566
	push	esi
2567
	push	edi
2568
	mov	ebx,[current_line]
2569
      find_current_file_path:
31 halyavin 2570
	mov	esi,[ebx]
2665 dunkaist 2571
	test	byte [ebx+7],80h
2572
	jz	copy_current_file_path
2573
	mov	ebx,[ebx+8]
2574
	jmp	find_current_file_path
2575
      copy_current_file_path:
31 halyavin 2576
	lods	byte [esi]
2665 dunkaist 2577
	stos	byte [edi]
2578
	or	al,al
2579
	jnz	copy_current_file_path
2580
      cut_current_file_name:
31 halyavin 2581
	cmp	edi,[esp]
2665 dunkaist 2582
	je	current_file_path_ok
2583
	cmp	byte [edi-1],'\'
2584
	je	current_file_path_ok
2585
	cmp	byte [edi-1],'/'
2586
	je	current_file_path_ok
2587
	dec	edi
2588
	jmp	cut_current_file_name
2589
      current_file_path_ok:
31 halyavin 2590
	mov	esi,[esp+4]
2665 dunkaist 2591
	call	expand_path
2592
	pop	edx
2593
	mov	esi,edx
2594
	call	open
2595
	jnc	include_path_ok
2596
	mov	ebp,[include_paths]
2597
      try_include_directories:
31 halyavin 2598
	mov	edi,esi
2665 dunkaist 2599
	mov	esi,ebp
2600
	cmp	byte [esi],0
2601
	je	try_in_current_directory
2602
	push	ebp
2603
	push	edi
2604
	call	get_include_directory
2605
	mov	[esp+4],esi
2606
	mov	esi,[esp+8]
2607
	call	expand_path
2608
	pop	edx
2609
	mov	esi,edx
2610
	call	open
2611
	pop	ebp
2612
	jnc	include_path_ok
2613
	jmp	try_include_directories
2614
	mov	edi,esi
2615
      try_in_current_directory:
31 halyavin 2616
	mov	esi,[esp]
2665 dunkaist 2617
	push	edi
2618
	call	expand_path
2619
	pop	edx
2620
	mov	esi,edx
2621
	call	open
2622
	jc	file_not_found
2623
      include_path_ok:
31 halyavin 2624
	mov	edi,[esp]
2665 dunkaist 2625
      copy_preprocessed_path:
31 halyavin 2626
	lods	byte [esi]
2665 dunkaist 2627
	stos	byte [edi]
2628
	or	al,al
2629
	jnz	copy_preprocessed_path
2630
	pop	esi
2631
	lea	ecx,[edi-1]
2632
	sub	ecx,esi
2633
	mov	[esi-4],ecx
2634
	push	dword [macro_status]
2635
	and	[macro_status],0Fh
2636
	call	preprocess_file
2637
	pop	eax
2638
	and	al,0F0h
2639
	and	[macro_status],0Fh
2640
	or	[macro_status],al
2641
	jmp	line_preprocessed
2642
>