-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathassemble.inc
2235 lines (2225 loc) · 43.3 KB
/
assemble.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.
assembler:
xor eax,eax
mov [stub_size],eax
mov [current_pass],ax
mov [resolver_flags],eax
mov [number_of_sections],eax
mov [actual_fixups_size],eax
assembler_loop:
mov eax,[labels_list]
mov [tagged_blocks],eax
mov eax,[additional_memory]
mov [free_additional_memory],eax
mov eax,[additional_memory_end]
mov [structures_buffer],eax
mov esi,[source_start]
mov edi,[code_start]
xor eax,eax
mov dword [adjustment],eax
mov dword [adjustment+4],eax
mov [addressing_space],eax
mov [error_line],eax
mov [counter],eax
mov [format_flags],eax
mov [number_of_relocations],eax
mov [undefined_data_end],eax
mov [file_extension],eax
mov [next_pass_needed],al
mov [output_format],al
mov [adjustment_sign],al
mov [evex_mode],al
mov [code_type],16
call init_addressing_space
pass_loop:
call assemble_line
jnc pass_loop
mov eax,[additional_memory_end]
cmp eax,[structures_buffer]
je pass_done
sub eax,18h
mov eax,[eax+4]
mov [current_line],eax
jmp missing_end_directive
pass_done:
call close_pass
mov eax,[labels_list]
check_symbols:
cmp eax,[memory_end]
jae symbols_checked
test byte [eax+8],8
jz symbol_defined_ok
mov cx,[current_pass]
cmp cx,[eax+18]
jne symbol_defined_ok
test byte [eax+8],1
jz symbol_defined_ok
sub cx,[eax+16]
cmp cx,1
jne symbol_defined_ok
and byte [eax+8],not 1
or [next_pass_needed],-1
symbol_defined_ok:
test byte [eax+8],10h
jz use_prediction_ok
mov cx,[current_pass]
and byte [eax+8],not 10h
test byte [eax+8],20h
jnz check_use_prediction
cmp cx,[eax+18]
jne use_prediction_ok
test byte [eax+8],8
jz use_prediction_ok
jmp use_misprediction
check_use_prediction:
test byte [eax+8],8
jz use_misprediction
cmp cx,[eax+18]
je use_prediction_ok
use_misprediction:
or [next_pass_needed],-1
use_prediction_ok:
test byte [eax+8],40h
jz check_next_symbol
and byte [eax+8],not 40h
test byte [eax+8],4
jnz define_misprediction
mov cx,[current_pass]
test byte [eax+8],80h
jnz check_define_prediction
cmp cx,[eax+16]
jne check_next_symbol
test byte [eax+8],1
jz check_next_symbol
jmp define_misprediction
check_define_prediction:
test byte [eax+8],1
jz define_misprediction
cmp cx,[eax+16]
je check_next_symbol
define_misprediction:
or [next_pass_needed],-1
check_next_symbol:
add eax,LABEL_STRUCTURE_SIZE
jmp check_symbols
symbols_checked:
cmp [next_pass_needed],0
jne next_pass
mov eax,[error_line]
or eax,eax
jz assemble_ok
mov [current_line],eax
cmp [error],undefined_symbol
jne error_confirmed
mov eax,[error_info]
or eax,eax
jz error_confirmed
test byte [eax+8],1
jnz next_pass
error_confirmed:
call error_handler
error_handler:
mov eax,[error]
sub eax,error_handler
add [esp],eax
ret
next_pass:
inc [current_pass]
mov ax,[current_pass]
cmp ax,[passes_limit]
je code_cannot_be_generated
jmp assembler_loop
assemble_ok:
ret
create_addressing_space:
mov ebx,[addressing_space]
test ebx,ebx
jz init_addressing_space
test byte [ebx+0Ah],1
jnz illegal_instruction
mov eax,edi
sub eax,[ebx+18h]
mov [ebx+1Ch],eax
init_addressing_space:
mov ebx,[tagged_blocks]
mov dword [ebx-4],10h
mov dword [ebx-8],24h
sub ebx,8+24h
cmp ebx,edi
jbe out_of_memory
mov [tagged_blocks],ebx
mov [addressing_space],ebx
xor eax,eax
mov [ebx],edi
mov [ebx+4],eax
mov [ebx+8],eax
mov [ebx+10h],eax
mov [ebx+14h],eax
mov [ebx+18h],edi
mov [ebx+1Ch],eax
mov [ebx+20h],eax
ret
assemble_line:
mov eax,[tagged_blocks]
sub eax,100h
cmp edi,eax
ja out_of_memory
lods byte [esi]
cmp al,1
je assemble_instruction
jb source_end
cmp al,3
jb define_label
je define_constant
cmp al,4
je label_addressing_space
cmp al,0Fh
je new_line
cmp al,13h
je code_type_setting
cmp al,10h
jne illegal_instruction
lods byte [esi]
jmp segment_prefix
code_type_setting:
lods byte [esi]
mov [code_type],al
jmp instruction_assembled
new_line:
lods dword [esi]
mov [current_line],eax
and [prefix_flags],0
cmp [symbols_file],0
je continue_line
cmp [next_pass_needed],0
jne continue_line
mov ebx,[tagged_blocks]
mov dword [ebx-4],1
mov dword [ebx-8],14h
sub ebx,8+14h
cmp ebx,edi
jbe out_of_memory
mov [tagged_blocks],ebx
mov [ebx],eax
mov [ebx+4],edi
mov eax,[addressing_space]
mov [ebx+8],eax
mov al,[code_type]
mov [ebx+10h],al
continue_line:
cmp byte [esi],0Fh
je line_assembled
jmp assemble_line
define_label:
lods dword [esi]
cmp eax,0Fh
jb invalid_use_of_symbol
je reserved_word_used_as_symbol
mov ebx,eax
lods byte [esi]
mov [label_size],al
call make_label
jmp continue_line
make_label:
mov eax,edi
xor edx,edx
xor cl,cl
mov ebp,[addressing_space]
sub eax,[ds:ebp]
sbb edx,[ds:ebp+4]
sbb cl,[ds:ebp+8]
jp label_value_ok
call recoverable_overflow
label_value_ok:
mov [address_sign],cl
test byte [ds:ebp+0Ah],1
jnz make_virtual_label
or byte [ebx+9],1
xchg eax,[ebx]
xchg edx,[ebx+4]
mov ch,[ebx+9]
shr ch,1
and ch,1
neg ch
sub eax,[ebx]
sbb edx,[ebx+4]
sbb ch,cl
mov dword [adjustment],eax
mov dword [adjustment+4],edx
mov [adjustment_sign],ch
or al,ch
or eax,edx
setnz ah
jmp finish_label
make_virtual_label:
and byte [ebx+9],not 1
cmp eax,[ebx]
mov [ebx],eax
setne ah
cmp edx,[ebx+4]
mov [ebx+4],edx
setne al
or ah,al
finish_label:
mov ebp,[addressing_space]
mov ch,[ds:ebp+9]
mov cl,[label_size]
mov edx,[ds:ebp+14h]
mov ebp,[ds:ebp+10h]
finish_label_symbol:
mov al,[address_sign]
xor al,[ebx+9]
and al,10b
or ah,al
xor [ebx+9],al
cmp cl,[ebx+10]
mov [ebx+10],cl
setne al
or ah,al
cmp ch,[ebx+11]
mov [ebx+11],ch
setne al
or ah,al
cmp ebp,[ebx+12]
mov [ebx+12],ebp
setne al
or ah,al
or ch,ch
jz label_symbol_ok
cmp edx,[ebx+20]
mov [ebx+20],edx
setne al
or ah,al
label_symbol_ok:
mov cx,[current_pass]
xchg [ebx+16],cx
mov edx,[current_line]
mov [ebx+28],edx
and byte [ebx+8],not 2
test byte [ebx+8],1
jz new_label
cmp cx,[ebx+16]
je symbol_already_defined
btr dword [ebx+8],10
jc requalified_label
inc cx
sub cx,[ebx+16]
setnz al
or ah,al
jz label_made
test byte [ebx+8],8
jz label_made
mov cx,[current_pass]
cmp cx,[ebx+18]
jne label_made
requalified_label:
or [next_pass_needed],-1
label_made:
ret
new_label:
or byte [ebx+8],1
ret
define_constant:
lods dword [esi]
inc esi
cmp eax,0Fh
jb invalid_use_of_symbol
je reserved_word_used_as_symbol
push eax
or [operand_flags],1
call get_value
pop ebx
xor cl,cl
mov ch,[value_type]
cmp ch,3
je invalid_use_of_symbol
make_constant:
and byte [ebx+9],not 1
cmp eax,[ebx]
mov [ebx],eax
setne ah
cmp edx,[ebx+4]
mov [ebx+4],edx
setne al
or ah,al
mov al,[value_sign]
xor al,[ebx+9]
and al,10b
or ah,al
xor [ebx+9],al
cmp cl,[ebx+10]
mov [ebx+10],cl
setne al
or ah,al
cmp ch,[ebx+11]
mov [ebx+11],ch
setne al
or ah,al
xor edx,edx
cmp edx,[ebx+12]
mov [ebx+12],edx
setne al
or ah,al
or ch,ch
jz constant_symbol_ok
mov edx,[symbol_identifier]
cmp edx,[ebx+20]
mov [ebx+20],edx
setne al
or ah,al
constant_symbol_ok:
mov cx,[current_pass]
xchg [ebx+16],cx
mov edx,[current_line]
mov [ebx+28],edx
test byte [ebx+8],1
jz new_constant
cmp cx,[ebx+16]
jne redeclare_constant
test byte [ebx+8],2
jz symbol_already_defined
or byte [ebx+8],4
and byte [ebx+9],not 4
jmp instruction_assembled
redeclare_constant:
btr dword [ebx+8],10
jc requalified_constant
inc cx
sub cx,[ebx+16]
setnz al
or ah,al
jz instruction_assembled
test byte [ebx+8],4
jnz instruction_assembled
test byte [ebx+8],8
jz instruction_assembled
mov cx,[current_pass]
cmp cx,[ebx+18]
jne instruction_assembled
requalified_constant:
or [next_pass_needed],-1
jmp instruction_assembled
new_constant:
or byte [ebx+8],1+2
jmp instruction_assembled
label_addressing_space:
lods dword [esi]
cmp eax,0Fh
jb invalid_use_of_symbol
je reserved_word_used_as_symbol
mov cx,[current_pass]
test byte [eax+8],1
jz make_addressing_space_label
cmp cx,[eax+16]
je symbol_already_defined
test byte [eax+9],4
jnz make_addressing_space_label
or [next_pass_needed],-1
make_addressing_space_label:
mov dx,[eax+8]
and dx,not (2 or 100h)
or dx,1 or 4 or 400h
mov [eax+8],dx
mov [eax+16],cx
mov edx,[current_line]
mov [eax+28],edx
mov ebx,[addressing_space]
mov [eax],ebx
or byte [ebx+0Ah],2
jmp continue_line
assemble_instruction:
; mov [operand_size],0
; mov [operand_flags],0
; mov [operand_prefix],0
; mov [rex_prefix],0
and dword [operand_size],0
; mov [opcode_prefix],0
; mov [vex_required],0
; mov [vex_register],0
; mov [immediate_size],0
and dword [opcode_prefix],0
call instruction_handler
instruction_handler:
movzx ebx,word [esi]
mov al,[esi+2]
add esi,3
add [esp],ebx
ret
instruction_assembled:
test [prefix_flags],not 1
jnz illegal_instruction
mov al,[esi]
cmp al,0Fh
je line_assembled
or al,al
jnz extra_characters_on_line
line_assembled:
clc
ret
source_end:
dec esi
stc
ret
org_directive:
lods byte [esi]
cmp al,'('
jne invalid_argument
cmp byte [esi],'.'
je invalid_value
call get_qword_value
mov cl,[value_type]
test cl,1
jnz invalid_use_of_symbol
push eax
mov ebx,[addressing_space]
mov eax,edi
sub eax,[ebx+18h]
mov [ebx+1Ch],eax
test byte [ebx+0Ah],1
jnz in_virtual
call init_addressing_space
jmp org_space_ok
in_virtual:
call close_virtual_addressing_space
call init_addressing_space
or byte [ebx+0Ah],1
org_space_ok:
pop eax
mov [ebx+9],cl
mov cl,[value_sign]
sub [ebx],eax
sbb [ebx+4],edx
sbb byte [ebx+8],cl
jp org_value_ok
call recoverable_overflow
org_value_ok:
mov edx,[symbol_identifier]
mov [ebx+14h],edx
cmp [output_format],1
ja instruction_assembled
cmp edi,[code_start]
jne instruction_assembled
cmp eax,100h
jne instruction_assembled
bts [format_flags],0
jmp instruction_assembled
label_directive:
lods byte [esi]
cmp al,2
jne invalid_argument
lods dword [esi]
cmp eax,0Fh
jb invalid_use_of_symbol
je reserved_word_used_as_symbol
inc esi
mov ebx,eax
mov [label_size],0
lods byte [esi]
cmp al,':'
je get_label_size
dec esi
cmp al,11h
jne label_size_ok
get_label_size:
lods word [esi]
cmp al,11h
jne invalid_argument
mov [label_size],ah
label_size_ok:
cmp byte [esi],80h
je get_free_label_value
call make_label
jmp instruction_assembled
get_free_label_value:
inc esi
lods byte [esi]
cmp al,'('
jne invalid_argument
push ebx ecx
or byte [ebx+8],4
cmp byte [esi],'.'
je invalid_value
call get_address_value
or bh,bh
setnz ch
xchg ch,cl
mov bp,cx
shl ebp,16
xchg bl,bh
mov bp,bx
pop ecx ebx
and byte [ebx+8],not 4
mov ch,[value_type]
test ch,1
jnz invalid_use_of_symbol
make_free_label:
and byte [ebx+9],not 1
cmp eax,[ebx]
mov [ebx],eax
setne ah
cmp edx,[ebx+4]
mov [ebx+4],edx
setne al
or ah,al
mov edx,[address_symbol]
mov cl,[label_size]
call finish_label_symbol
jmp instruction_assembled
load_directive:
lods byte [esi]
cmp al,2
jne invalid_argument
lods dword [esi]
cmp eax,0Fh
jb invalid_use_of_symbol
je reserved_word_used_as_symbol
inc esi
push eax
mov al,1
cmp byte [esi],11h
jne load_size_ok
lods byte [esi]
lods byte [esi]
load_size_ok:
cmp al,8
ja invalid_value
mov [operand_size],al
and dword [value],0
and dword [value+4],0
lods byte [esi]
cmp al,82h
jne invalid_argument
call get_data_point
jc value_loaded
push esi edi
mov esi,ebx
mov edi,value
rep movs byte [edi],[esi]
pop edi esi
value_loaded:
mov [value_sign],0
mov eax,dword [value]
mov edx,dword [value+4]
pop ebx
xor cx,cx
jmp make_constant
get_data_point:
lods byte [esi]
cmp al,':'
je get_data_offset
cmp al,'('
jne invalid_argument
mov ebx,[addressing_space]
mov ecx,edi
sub ecx,[ebx+18h]
mov [ebx+1Ch],ecx
cmp byte [esi],11h
jne get_data_address
cmp word [esi+1+4],'):'
jne get_data_address
inc esi
lods dword [esi]
add esi,2
cmp byte [esi],'('
jne invalid_argument
inc esi
cmp eax,0Fh
jbe reserved_word_used_as_symbol
mov edx,undefined_symbol
test byte [eax+8],1
jz addressing_space_unavailable
mov edx,symbol_out_of_scope
mov cx,[eax+16]
cmp cx,[current_pass]
jne addressing_space_unavailable
test byte [eax+9],4
jz invalid_use_of_symbol
mov ebx,eax
mov ax,[current_pass]
mov [ebx+18],ax
or byte [ebx+8],8
call store_label_reference
get_addressing_space:
mov ebx,[ebx]
get_data_address:
push ebx
cmp byte [esi],'.'
je invalid_value
or [operand_flags],1
call get_address_value
pop ebp
call calculate_relative_offset
cmp [next_pass_needed],0
jne data_address_type_ok
cmp [value_type],0
jne invalid_use_of_symbol
data_address_type_ok:
mov ebx,edi
xor ecx,ecx
add ebx,eax
adc edx,ecx
mov eax,ebx
sub eax,[ds:ebp+18h]
sbb edx,ecx
jnz bad_data_address
mov cl,[operand_size]
add eax,ecx
cmp eax,[ds:ebp+1Ch]
ja bad_data_address
clc
ret
addressing_space_unavailable:
cmp [error_line],0
jne get_data_address
push [current_line]
pop [error_line]
mov [error],edx
mov [error_info],eax
jmp get_data_address
bad_data_address:
call recoverable_overflow
stc
ret
get_data_offset:
cmp [output_format],2
jae invalid_operand
lods byte [esi]
cmp al,'('
jne invalid_argument
cmp byte [esi],'.'
je invalid_value
call get_dword_value
cmp [value_type],0
je data_offset_ok
call recoverable_invalid_address
data_offset_ok:
add eax,[code_start]
jc bad_data_address
mov ebx,eax
movzx ecx,[operand_size]
add eax,ecx
jc bad_data_address
mov edx,[addressing_space]
test byte [edx+0Ah],1
jnz data_offset_from_virtual
cmp eax,edi
ja bad_data_address
clc
ret
data_offset_from_virtual:
cmp eax,[undefined_data_end]
ja bad_data_address
clc
ret
store_directive:
cmp byte [esi],11h
je sized_store
lods byte [esi]
cmp al,'('
jne invalid_argument
call get_byte_value
xor edx,edx
movzx eax,al
mov [operand_size],1
jmp store_value_ok
sized_store:
or [operand_flags],1
call get_value
store_value_ok:
cmp [value_type],0
jne invalid_use_of_symbol
mov dword [value],eax
mov dword [value+4],edx
lods byte [esi]
cmp al,80h
jne invalid_argument
call get_data_point
jc instruction_assembled
push esi edi
mov esi,value
mov edi,ebx
rep movs byte [edi],[esi]
mov eax,edi
pop edi esi
cmp ebx,[undefined_data_end]
jae instruction_assembled
cmp eax,[undefined_data_start]
jbe instruction_assembled
mov [undefined_data_start],eax
jmp instruction_assembled
display_directive:
lods byte [esi]
cmp al,'('
jne invalid_argument
cmp byte [esi],0
jne display_byte
inc esi
lods dword [esi]
mov ecx,eax
push edi
mov edi,[tagged_blocks]
sub edi,8
sub edi,eax
cmp edi,[esp]
jbe out_of_memory
mov [tagged_blocks],edi
rep movs byte [edi],[esi]
stos dword [edi]
xor eax,eax
stos dword [edi]
pop edi
inc esi
jmp display_next
display_byte:
call get_byte_value
push edi
mov edi,[tagged_blocks]
sub edi,8+1
mov [tagged_blocks],edi
stos byte [edi]
mov eax,1
stos dword [edi]
dec eax
stos dword [edi]
pop edi
display_next:
cmp edi,[tagged_blocks]
ja out_of_memory
lods byte [esi]
cmp al,','
je display_directive
dec esi
jmp instruction_assembled
show_display_buffer:
mov eax,[tagged_blocks]
or eax,eax
jz display_done
mov esi,[labels_list]
cmp esi,eax
je display_done
display_messages:
sub esi,8
mov eax,[esi+4]
mov ecx,[esi]
sub esi,ecx
cmp eax,10h
je write_addressing_space
test eax,eax
jnz skip_block
push esi
call display_block
pop esi
skip_block:
cmp esi,[tagged_blocks]
jne display_messages
display_done:
ret
write_addressing_space:
mov ecx,[esi+20h]
jecxz skip_block
push esi
mov edi,[free_additional_memory]
mov esi,[output_file]
test esi,esi
jz addressing_space_written
xor ebx,ebx
copy_output_path:
lodsb
cmp edi,[structures_buffer]
jae out_of_memory
stosb
test al,al
jz output_path_copied
cmp al,'/'
je new_path_segment
cmp al,'\'
je new_path_segment
cmp al,'.'
jne copy_output_path
mov ebx,edi
jmp copy_output_path
new_path_segment:
xor ebx,ebx
jmp copy_output_path
output_path_copied:
test ebx,ebx
jnz append_extension
mov byte [edi-1],'.'
mov ebx,edi
append_extension:
mov edi,ebx
add ebx,ecx
inc ebx
cmp ebx,[structures_buffer]
jae out_of_memory
mov esi,[esp]
mov esi,[esi+18h]
sub esi,ecx
rep movs byte [edi],[esi]
xor al,al
stos byte [edi]
mov edx,[free_additional_memory]
call create
jc write_failed
mov esi,[esp]
mov edx,[esi+18h]
mov ecx,[esi+1Ch]
call write
jc write_failed
call close
addressing_space_written:
pop esi
jmp skip_block
times_directive:
lods byte [esi]
cmp al,'('
jne invalid_argument
cmp byte [esi],'.'
je invalid_value
call get_count_value
cmp eax,0
je zero_times
cmp byte [esi],':'
jne times_argument_ok
inc esi
times_argument_ok:
push [counter]
push [counter_limit]
mov [counter_limit],eax
mov [counter],1
times_loop:
mov eax,esp
sub eax,[stack_limit]
cmp eax,100h
jb stack_overflow
push esi
or [prefix_flags],1
call continue_line
mov eax,[counter_limit]
cmp [counter],eax
je times_done
inc [counter]
pop esi
jmp times_loop
times_done:
pop eax
pop [counter_limit]
pop [counter]
jmp instruction_assembled
zero_times:
call skip_symbol
jnc zero_times
jmp instruction_assembled
virtual_directive:
lods byte [esi]
cmp al,'('
je continue_virtual_area
cmp al,80h
jne virtual_at_current
lods byte [esi]
cmp al,'('
jne invalid_argument
cmp byte [esi],'.'
je invalid_value
call get_address_value
mov ebp,[address_symbol]
or bh,bh
setnz ch
jmp set_virtual
virtual_at_current:
dec esi
virtual_fallback:
mov ebp,[addressing_space]
mov al,[ds:ebp+9]
mov [value_type],al
mov eax,edi
xor edx,edx
xor cl,cl
sub eax,[ds:ebp]
sbb edx,[ds:ebp+4]
sbb cl,[ds:ebp+8]
mov [address_sign],cl
mov bx,[ds:ebp+10h]
mov cx,[ds:ebp+10h+2]
xchg bh,bl
xchg ch,cl
mov ebp,[ds:ebp+14h]
set_virtual:
xchg bl,bh
xchg cl,ch
shl ecx,16
mov cx,bx
push ecx eax
mov ebx,[addressing_space]
test byte [ebx+0Ah],1
jnz non_virtual_end_ok
mov eax,edi
xchg eax,[undefined_data_end]
cmp eax,edi
je non_virtual_end_ok
mov [undefined_data_start],edi
non_virtual_end_ok:
call allocate_virtual_structure_data
call init_addressing_space
or byte [ebx+0Ah],1
cmp byte [esi],86h
jne addressing_space_extension_ok
cmp word [esi+1],'('
jne invalid_argument
mov ecx,[esi+3]
add esi,3+4
add [ebx+18h],ecx
mov [ebx+20h],ecx
or byte [ebx+0Ah],2
push ebx
mov ebx,characters
get_extension:
lods byte [esi]
stos byte [edi]
xlat byte [ebx]
test al,al
jz invalid_argument
loop get_extension
inc esi
pop ebx
addressing_space_extension_ok:
pop eax
mov cl,[address_sign]
not eax
not edx