Subversion Repositories Kolibri OS

Rev

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