-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpreproce.inc
2983 lines (2965 loc) · 57.3 KB
/
preproce.inc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
; flat assembler core
; Copyright (c) 1999-2022, Tomasz Grysztar.
; All rights reserved.
preprocessor:
mov edi,characters
xor al,al
make_characters_table:
stosb
inc al
jnz make_characters_table
mov esi,characters+'a'
mov edi,characters+'A'
mov ecx,26
rep movsb
mov edi,characters
mov esi,symbol_characters+1
movzx ecx,byte [esi-1]
xor eax,eax
mark_symbol_characters:
lodsb
mov byte [edi+eax],0
loop mark_symbol_characters
mov edi,locals_counter
mov ax,1 + '0' shl 8
stos word [edi]
mov edi,[memory_start]
mov [include_paths],edi
mov esi,include_variable
call get_environment_variable
xor al,al
stos byte [edi]
mov [memory_start],edi
mov eax,[additional_memory]
mov [free_additional_memory],eax
mov eax,[additional_memory_end]
mov [labels_list],eax
xor eax,eax
mov [source_start],eax
mov [tagged_blocks],eax
mov [hash_tree],eax
mov [error],eax
mov [macro_status],al
mov [current_line],eax
mov esi,[initial_definitions]
test esi,esi
jz predefinitions_ok
process_predefinitions:
movzx ecx,byte [esi]
test ecx,ecx
jz predefinitions_ok
inc esi
lea eax,[esi+ecx]
push eax
mov ch,10b
call add_preprocessor_symbol
pop esi
mov edi,[memory_start]
mov [edx+8],edi
convert_predefinition:
cmp edi,[memory_end]
jae out_of_memory
lods byte [esi]
or al,al
jz predefinition_converted
cmp al,20h
je convert_predefinition
mov ah,al
mov ebx,characters
xlat byte [ebx]
or al,al
jz predefinition_separator
cmp ah,27h
je predefinition_string
cmp ah,22h
je predefinition_string
mov byte [edi],1Ah
scas word [edi]
xchg al,ah
stos byte [edi]
mov ebx,characters
xor ecx,ecx
predefinition_symbol:
lods byte [esi]
stos byte [edi]
xlat byte [ebx]
or al,al
loopnzd predefinition_symbol
neg ecx
cmp ecx,255
ja invalid_definition
mov ebx,edi
sub ebx,ecx
mov byte [ebx-2],cl
found_predefinition_separator:
dec edi
mov ah,[esi-1]
predefinition_separator:
xchg al,ah
or al,al
jz predefinition_converted
cmp al,20h
je convert_predefinition
cmp al,3Bh
je invalid_definition
cmp al,5Ch
je predefinition_backslash
stos byte [edi]
jmp convert_predefinition
predefinition_string:
mov al,22h
stos byte [edi]
scas dword [edi]
mov ebx,edi
copy_predefinition_string:
lods byte [esi]
stos byte [edi]
or al,al
jz invalid_definition
cmp al,ah
jne copy_predefinition_string
lods byte [esi]
cmp al,ah
je copy_predefinition_string
dec esi
dec edi
mov eax,edi
sub eax,ebx
mov [ebx-4],eax
jmp convert_predefinition
predefinition_backslash:
mov byte [edi],0
lods byte [esi]
or al,al
jz invalid_definition
cmp al,20h
je invalid_definition
cmp al,3Bh
je invalid_definition
mov al,1Ah
stos byte [edi]
mov ecx,edi
mov ax,5C01h
stos word [edi]
dec esi
group_predefinition_backslashes:
lods byte [esi]
cmp al,5Ch
jne predefinition_backslashed_symbol
stos byte [edi]
inc byte [ecx]
jmp group_predefinition_backslashes
predefinition_backslashed_symbol:
cmp al,20h
je invalid_definition
cmp al,22h
je invalid_definition
cmp al,27h
je invalid_definition
cmp al,3Bh
je invalid_definition
mov ah,al
mov ebx,characters
xlat byte [ebx]
or al,al
jz predefinition_backslashed_symbol_character
mov al,ah
convert_predefinition_backslashed_symbol:
stos byte [edi]
xlat byte [ebx]
or al,al
jz found_predefinition_separator
inc byte [ecx]
jz invalid_definition
lods byte [esi]
jmp convert_predefinition_backslashed_symbol
predefinition_backslashed_symbol_character:
mov al,ah
stos byte [edi]
inc byte [ecx]
jmp convert_predefinition
predefinition_converted:
mov [memory_start],edi
sub edi,[edx+8]
mov [edx+12],edi
jmp process_predefinitions
predefinitions_ok:
mov esi,[input_file]
mov edx,esi
call open
jc main_file_not_found
mov edi,[memory_start]
call preprocess_file
cmp [macro_status],0
je process_postponed
mov eax,[error_line]
mov [current_line],eax
jmp incomplete_macro
process_postponed:
mov edx,hash_tree
mov ecx,32
find_postponed_list:
mov edx,[edx]
or edx,edx
loopnz find_postponed_list
jz preprocessing_finished
process_postponed_list:
mov eax,[edx]
or eax,eax
jz preprocessing_finished
push edx
mov ebx,edx
find_earliest_postponed:
mov eax,[edx]
or eax,eax
jz earliest_postponed_found
mov ebx,edx
mov edx,eax
jmp find_earliest_postponed
earliest_postponed_found:
mov [ebx],eax
call use_postponed_macro
pop edx
cmp [macro_status],0
je process_postponed_list
mov eax,[error_line]
mov [current_line],eax
jmp incomplete_macro
preprocessing_finished:
mov [source_start],edi
ret
use_postponed_macro:
lea esi,[edi-1]
push ecx esi
mov [struc_name],0
jmp use_macro
preprocess_file:
push [memory_end]
push esi
mov al,2
xor edx,edx
call lseek
push eax
xor al,al
xor edx,edx
call lseek
pop ecx
mov edx,[memory_end]
dec edx
mov byte [edx],1Ah
sub edx,ecx
jc out_of_memory
mov esi,edx
cmp edx,edi
jbe out_of_memory
mov [memory_end],edx
call read
call close
pop edx
xor ecx,ecx
mov ebx,esi
preprocess_source:
inc ecx
mov [current_line],edi
mov eax,edx
stos dword [edi]
mov eax,ecx
stos dword [edi]
mov eax,esi
sub eax,ebx
stos dword [edi]
xor eax,eax
stos dword [edi]
push ebx edx
call convert_line
call preprocess_line
pop edx ebx
next_line:
cmp byte [esi-1],0
je file_end
cmp byte [esi-1],1Ah
jne preprocess_source
file_end:
pop [memory_end]
clc
ret
convert_line:
push ecx
test [macro_status],0Fh
jz convert_line_data
mov ax,3Bh
stos word [edi]
convert_line_data:
cmp edi,[memory_end]
jae out_of_memory
lods byte [esi]
cmp al,20h
je convert_line_data
cmp al,9
je convert_line_data
mov ah,al
mov ebx,characters
xlat byte [ebx]
or al,al
jz convert_separator
cmp ah,27h
je convert_string
cmp ah,22h
je convert_string
mov byte [edi],1Ah
scas word [edi]
xchg al,ah
stos byte [edi]
mov ebx,characters
xor ecx,ecx
convert_symbol:
lods byte [esi]
stos byte [edi]
xlat byte [ebx]
or al,al
loopnzd convert_symbol
neg ecx
cmp ecx,255
ja name_too_long
mov ebx,edi
sub ebx,ecx
mov byte [ebx-2],cl
found_separator:
dec edi
mov ah,[esi-1]
convert_separator:
xchg al,ah
cmp al,20h
jb control_character
je convert_line_data
symbol_character:
cmp al,3Bh
je ignore_comment
cmp al,5Ch
je backslash_character
stos byte [edi]
jmp convert_line_data
control_character:
cmp al,1Ah
je line_end
cmp al,0Dh
je cr_character
cmp al,0Ah
je lf_character
cmp al,9
je convert_line_data
or al,al
jnz symbol_character
jmp line_end
lf_character:
lods byte [esi]
cmp al,0Dh
je line_end
dec esi
jmp line_end
cr_character:
lods byte [esi]
cmp al,0Ah
je line_end
dec esi
jmp line_end
convert_string:
mov al,22h
stos byte [edi]
scas dword [edi]
mov ebx,edi
copy_string:
lods byte [esi]
stos byte [edi]
cmp al,0Ah
je no_end_quote
cmp al,0Dh
je no_end_quote
or al,al
jz no_end_quote
cmp al,1Ah
je no_end_quote
cmp al,ah
jne copy_string
lods byte [esi]
cmp al,ah
je copy_string
dec esi
dec edi
mov eax,edi
sub eax,ebx
mov [ebx-4],eax
jmp convert_line_data
backslash_character:
mov byte [edi],0
lods byte [esi]
cmp al,20h
je concatenate_lines
cmp al,9
je concatenate_lines
cmp al,1Ah
je line_end
or al,al
jz line_end
cmp al,0Ah
je concatenate_lf
cmp al,0Dh
je concatenate_cr
cmp al,3Bh
je find_concatenated_line
mov al,1Ah
stos byte [edi]
mov ecx,edi
mov ax,5C01h
stos word [edi]
dec esi
group_backslashes:
lods byte [esi]
cmp al,5Ch
jne backslashed_symbol
stos byte [edi]
inc byte [ecx]
jz name_too_long
jmp group_backslashes
no_end_quote:
mov byte [ebx-5],0
jmp missing_end_quote
backslashed_symbol:
cmp al,1Ah
je extra_characters_on_line
or al,al
jz extra_characters_on_line
cmp al,0Ah
je extra_characters_on_line
cmp al,0Dh
je extra_characters_on_line
cmp al,20h
je extra_characters_on_line
cmp al,9
je extra_characters_on_line
cmp al,22h
je extra_characters_on_line
cmp al,27h
je extra_characters_on_line
cmp al,3Bh
je extra_characters_on_line
mov ah,al
mov ebx,characters
xlat byte [ebx]
or al,al
jz backslashed_symbol_character
mov al,ah
convert_backslashed_symbol:
stos byte [edi]
xlat byte [ebx]
or al,al
jz found_separator
inc byte [ecx]
jz name_too_long
lods byte [esi]
jmp convert_backslashed_symbol
backslashed_symbol_character:
mov al,ah
stos byte [edi]
inc byte [ecx]
jmp convert_line_data
concatenate_lines:
lods byte [esi]
cmp al,20h
je concatenate_lines
cmp al,9
je concatenate_lines
cmp al,1Ah
je line_end
or al,al
jz line_end
cmp al,0Ah
je concatenate_lf
cmp al,0Dh
je concatenate_cr
cmp al,3Bh
jne extra_characters_on_line
find_concatenated_line:
lods byte [esi]
cmp al,0Ah
je concatenate_lf
cmp al,0Dh
je concatenate_cr
or al,al
jz concatenate_ok
cmp al,1Ah
jne find_concatenated_line
jmp line_end
concatenate_lf:
lods byte [esi]
cmp al,0Dh
je concatenate_ok
dec esi
jmp concatenate_ok
concatenate_cr:
lods byte [esi]
cmp al,0Ah
je concatenate_ok
dec esi
concatenate_ok:
inc dword [esp]
jmp convert_line_data
ignore_comment:
lods byte [esi]
cmp al,0Ah
je lf_character
cmp al,0Dh
je cr_character
or al,al
jz line_end
cmp al,1Ah
jne ignore_comment
line_end:
xor al,al
stos byte [edi]
pop ecx
ret
lower_case:
mov edi,converted
mov ebx,characters
convert_case:
lods byte [esi]
xlat byte [ebx]
stos byte [edi]
loop convert_case
case_ok:
ret
get_directive:
push edi
mov edx,esi
mov ebp,ecx
call lower_case
pop edi
scan_directives:
mov esi,converted
movzx eax,byte [edi]
or al,al
jz no_directive
mov ecx,ebp
inc edi
mov ebx,edi
add ebx,eax
mov ah,[esi]
cmp ah,[edi]
jb no_directive
ja next_directive
cmp cl,al
jne next_directive
repe cmps byte [esi],[edi]
jb no_directive
je directive_found
next_directive:
mov edi,ebx
add edi,2
jmp scan_directives
no_directive:
mov esi,edx
mov ecx,ebp
stc
ret
directive_found:
call get_directive_handler_base
directive_handler:
lea esi,[edx+ebp]
movzx ecx,word [ebx]
add eax,ecx
clc
ret
get_directive_handler_base:
mov eax,[esp]
ret
preprocess_line:
mov eax,esp
sub eax,[stack_limit]
cmp eax,100h
jb stack_overflow
push ecx esi
preprocess_current_line:
mov esi,[current_line]
add esi,16
cmp word [esi],3Bh
jne line_start_ok
add esi,2
line_start_ok:
test [macro_status],0F0h
jnz macro_preprocessing
cmp byte [esi],1Ah
jne not_fix_constant
movzx edx,byte [esi+1]
lea edx,[esi+2+edx]
cmp word [edx],031Ah
jne not_fix_constant
mov ebx,characters
movzx eax,byte [edx+2]
xlat byte [ebx]
ror eax,8
mov al,[edx+3]
xlat byte [ebx]
ror eax,8
mov al,[edx+4]
xlat byte [ebx]
ror eax,16
cmp eax,'fix'
je define_fix_constant
not_fix_constant:
call process_fix_constants
jmp initial_preprocessing_ok
macro_preprocessing:
call process_macro_operators
initial_preprocessing_ok:
mov esi,[current_line]
add esi,16
mov al,[macro_status]
test al,2
jnz skip_macro_block
test al,1
jnz find_macro_block
preprocess_instruction:
mov [current_offset],esi
lods byte [esi]
movzx ecx,byte [esi]
inc esi
cmp al,1Ah
jne not_preprocessor_symbol
cmp cl,3
jb not_preprocessor_directive
push edi
mov edi,preprocessor_directives
call get_directive
pop edi
jc not_preprocessor_directive
mov byte [edx-2],3Bh
jmp near eax
not_preprocessor_directive:
xor ch,ch
call get_preprocessor_symbol
jc not_macro
mov byte [ebx-2],3Bh
mov [struc_name],0
jmp use_macro
not_macro:
mov [struc_name],esi
add esi,ecx
lods byte [esi]
cmp al,':'
je preprocess_label
cmp al,1Ah
jne not_preprocessor_symbol
lods byte [esi]
cmp al,3
jne not_symbolic_constant
mov ebx,characters
movzx eax,byte [esi]
xlat byte [ebx]
ror eax,8
mov al,[esi+1]
xlat byte [ebx]
ror eax,8
mov al,[esi+2]
xlat byte [ebx]
ror eax,16
cmp eax,'equ'
je define_equ_constant
mov al,3
not_symbolic_constant:
mov ch,1
mov cl,al
call get_preprocessor_symbol
jc not_preprocessor_symbol
push edx esi
mov esi,[struc_name]
mov [struc_label],esi
sub [struc_label],2
mov cl,[esi-1]
mov ch,10b
call get_preprocessor_symbol
jc struc_name_ok
test edx,edx
jz reserved_word_used_as_symbol
mov ecx,[edx+12]
add ecx,3
lea ebx,[edi+ecx]
mov ecx,edi
sub ecx,[struc_label]
lea esi,[edi-1]
lea edi,[ebx-1]
std
rep movs byte [edi],[esi]
cld
mov edi,[struc_label]
mov esi,[edx+8]
mov ecx,[edx+12]
add [struc_name],ecx
add [struc_name],3
call move_data
mov al,3Ah
stos byte [edi]
mov ax,3Bh
stos word [edi]
mov edi,ebx
pop esi
add esi,[edx+12]
add esi,3
pop edx
jmp use_macro
struc_name_ok:
mov edx,[struc_name]
movzx eax,byte [edx-1]
add edx,eax
push edi
lea esi,[edi-1]
mov ecx,edi
sub ecx,edx
std
rep movs byte [edi],[esi]
cld
pop edi
inc edi
mov al,3Ah
mov [edx],al
inc al
mov [edx+1],al
pop esi edx
inc esi
jmp use_macro
preprocess_label:
dec esi
sub esi,ecx
lea ebp,[esi-2]
mov ch,10b
call get_preprocessor_symbol
jnc symbolic_constant_in_label
lea esi,[esi+ecx+1]
cmp byte [esi],':'
jne preprocess_instruction
inc esi
jmp preprocess_instruction
symbolic_constant_in_label:
test edx,edx
jz reserved_word_used_as_symbol
mov ebx,[edx+8]
mov ecx,[edx+12]
add ecx,ebx
check_for_broken_label:
cmp ebx,ecx
je label_broken
cmp byte [ebx],1Ah
jne label_broken
movzx eax,byte [ebx+1]
lea ebx,[ebx+2+eax]
cmp ebx,ecx
je label_constant_ok
cmp byte [ebx],':'
jne label_broken
inc ebx
cmp byte [ebx],':'
jne check_for_broken_label
inc ebx
jmp check_for_broken_label
label_broken:
call replace_symbolic_constant
jmp line_preprocessed
label_constant_ok:
mov ecx,edi
sub ecx,esi
mov edi,[edx+12]
add edi,ebp
push edi
lea eax,[edi+ecx]
push eax
cmp esi,edi
je replace_label
jb move_rest_of_line_up
rep movs byte [edi],[esi]
jmp replace_label
move_rest_of_line_up:
lea esi,[esi+ecx-1]
lea edi,[edi+ecx-1]
std
rep movs byte [edi],[esi]
cld
replace_label:
mov ecx,[edx+12]
mov edi,[esp+4]
sub edi,ecx
mov esi,[edx+8]
rep movs byte [edi],[esi]
pop edi esi
inc esi
jmp preprocess_instruction
not_preprocessor_symbol:
mov esi,[current_offset]
call process_equ_constants
line_preprocessed:
pop esi ecx
ret
get_preprocessor_symbol:
push ebp edi esi
mov ebp,ecx
shl ebp,22
mov al,ch
and al,11b
movzx ecx,cl
cmp al,10b
jne no_preprocessor_special_symbol
cmp cl,4
jbe no_preprocessor_special_symbol
mov ax,'__'
cmp ax,[esi]
jne no_preprocessor_special_symbol
cmp ax,[esi+ecx-2]
jne no_preprocessor_special_symbol
add esi,2
sub ecx,4
push ebp
mov edi,preprocessor_special_symbols
call get_directive
pop ebp
jc preprocessor_special_symbol_not_recognized
add esi,2
xor edx,edx
jmp preprocessor_symbol_found
preprocessor_special_symbol_not_recognized:
add ecx,4
sub esi,2
no_preprocessor_special_symbol:
mov ebx,hash_tree
mov edi,10
follow_hashes_roots:
mov edx,[ebx]
or edx,edx
jz preprocessor_symbol_not_found
xor eax,eax
shl ebp,1
adc eax,0
lea ebx,[edx+eax*4]
dec edi
jnz follow_hashes_roots
mov edi,ebx
call calculate_hash
mov ebp,eax
and ebp,3FFh
shl ebp,10
xor ebp,eax
mov ebx,edi
mov edi,22
follow_hashes_tree:
mov edx,[ebx]
or edx,edx
jz preprocessor_symbol_not_found
xor eax,eax
shl ebp,1
adc eax,0
lea ebx,[edx+eax*4]
dec edi
jnz follow_hashes_tree
mov al,cl
mov edx,[ebx]
or edx,edx
jz preprocessor_symbol_not_found
compare_with_preprocessor_symbol:
mov edi,[edx+4]
cmp edi,1
jbe next_equal_hash
repe cmps byte [esi],[edi]
je preprocessor_symbol_found
mov cl,al
mov esi,[esp]
next_equal_hash:
mov edx,[edx]
or edx,edx
jnz compare_with_preprocessor_symbol
preprocessor_symbol_not_found:
pop esi edi ebp
stc
ret
preprocessor_symbol_found:
pop ebx edi ebp
clc
ret
calculate_hash:
xor ebx,ebx
mov eax,2166136261
mov ebp,16777619
fnv1a_hash:
xor al,[esi+ebx]
mul ebp
inc bl
cmp bl,cl
jb fnv1a_hash
ret
add_preprocessor_symbol:
push edi esi
xor eax,eax
or cl,cl
jz reshape_hash
cmp ch,11b
je preprocessor_symbol_name_ok
push ecx
movzx ecx,cl
mov edi,preprocessor_directives
call get_directive
jnc reserved_word_used_as_symbol
pop ecx
preprocessor_symbol_name_ok:
call calculate_hash
reshape_hash:
mov ebp,eax
and ebp,3FFh
shr eax,10
xor ebp,eax
shl ecx,22
or ebp,ecx
mov ebx,hash_tree
mov ecx,32
find_leave_for_symbol:
mov edx,[ebx]
or edx,edx
jz extend_hashes_tree
xor eax,eax
rol ebp,1
adc eax,0
lea ebx,[edx+eax*4]
dec ecx
jnz find_leave_for_symbol
mov edx,[ebx]
or edx,edx
jz add_symbol_entry
shr ebp,30
cmp ebp,11b
je reuse_symbol_entry
cmp dword [edx+4],0
jne add_symbol_entry
find_entry_to_reuse:
mov edi,[edx]
or edi,edi
jz reuse_symbol_entry
cmp dword [edi+4],0
jne reuse_symbol_entry
mov edx,edi
jmp find_entry_to_reuse
add_symbol_entry:
mov eax,edx
mov edx,[labels_list]
sub edx,16
cmp edx,[free_additional_memory]
jb out_of_memory
mov [labels_list],edx
mov [edx],eax
mov [ebx],edx
reuse_symbol_entry:
pop esi edi
mov [edx+4],esi
ret
extend_hashes_tree:
mov edx,[labels_list]
sub edx,8
cmp edx,[free_additional_memory]
jb out_of_memory
mov [labels_list],edx
xor eax,eax
mov [edx],eax
mov [edx+4],eax
shl ebp,1
adc eax,0
mov [ebx],edx
lea ebx,[edx+eax*4]
dec ecx
jnz extend_hashes_tree
mov edx,[labels_list]
sub edx,16
cmp edx,[free_additional_memory]
jb out_of_memory
mov [labels_list],edx
mov dword [edx],0
mov [ebx],edx
pop esi edi
mov [edx+4],esi
ret
define_fix_constant:
add edx,5
add esi,2
push edx
mov ch,11b
jmp define_preprocessor_constant
define_equ_constant:
add esi,3