Subversion Repositories Kolibri OS

Rev

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

Rev Author Line No. Line
31 halyavin 1
 
2
; Copyright (c) 1999-2016, Tomasz Grysztar.
6467 dunkaist 3
; All rights reserved.
31 halyavin 4
5
 
6
	mov	eax,[memory_end]
157 heavyiron 7
	mov	[labels_list],eax
8
	mov	eax,[additional_memory]
9
	mov	[free_additional_memory],eax
10
	xor	eax,eax
11
	mov	[current_locals_prefix],eax
12
	mov	[anonymous_reverse],eax
13
	mov	[anonymous_forward],eax
14
	mov	[hash_tree],eax
15
	mov	[blocks_stack],eax
16
	mov	[parsed_lines],eax
242 heavyiron 17
	mov	esi,[memory_start]
157 heavyiron 18
	mov	edi,[source_start]
19
      parser_loop:
31 halyavin 20
	mov	[current_line],esi
157 heavyiron 21
	lea	eax,[edi+100h]
22
	cmp	eax,[labels_list]
23
	jae	out_of_memory
24
	cmp	byte [esi+16],0
25
	je	empty_line
26
	cmp	byte [esi+16],3Bh
992 heavyiron 27
	je	empty_line
28
	mov	al,0Fh
157 heavyiron 29
	stos	byte [edi]
30
	mov	eax,esi
31
	stos	dword [edi]
32
	inc	[parsed_lines]
242 heavyiron 33
	add	esi,16
157 heavyiron 34
      parse_line:
109 heavyiron 35
	mov	[formatter_symbols_allowed],0
2287 heavyiron 36
	mov	[decorator_symbols_allowed],0
6467 dunkaist 37
	cmp	byte [esi],1Ah
157 heavyiron 38
	jne	empty_instruction
39
	push	edi
40
	add	esi,2
41
	movzx	ecx,byte [esi-1]
42
	cmp	byte [esi+ecx],':'
43
	je	simple_label
44
	cmp	byte [esi+ecx],'='
45
	je	constant_label
46
	call	get_instruction
47
	jnc	main_instruction_identified
48
	cmp	byte [esi+ecx],1Ah
49
	jne	no_data_label
50
	push	esi ecx
51
	lea	esi,[esi+ecx+2]
52
	movzx	ecx,byte [esi-1]
53
	call	get_data_directive
54
	jnc	data_label
55
	pop	ecx esi
56
      no_data_label:
109 heavyiron 57
	call	get_data_directive
157 heavyiron 58
	jnc	main_instruction_identified
59
	pop	edi
60
	sub	esi,2
61
	xor	bx,bx
62
	call	parse_line_contents
63
	jmp	parse_next_line
64
      simple_label:
109 heavyiron 65
	pop	edi
157 heavyiron 66
	call	identify_label
67
	cmp	byte [esi+1],':'
4039 heavyiron 68
	je	block_label
69
	mov	byte [edi],2
157 heavyiron 70
	inc	edi
71
	stos	dword [edi]
72
	inc	esi
73
	xor	al,al
74
	stos	byte [edi]
75
	jmp	parse_line
76
      block_label:
4039 heavyiron 77
	mov	byte [edi],4
78
	inc	edi
79
	stos	dword [edi]
80
	add	esi,2
81
	jmp	parse_line
82
      constant_label:
109 heavyiron 83
	pop	edi
157 heavyiron 84
	call	get_label_id
85
	mov	byte [edi],3
86
	inc	edi
87
	stos	dword [edi]
88
	xor	al,al
89
	stos	byte [edi]
90
	inc	esi
91
	xor	bx,bx
92
	call	parse_line_contents
93
	jmp	parse_next_line
94
      data_label:
109 heavyiron 95
	pop	ecx edx
157 heavyiron 96
	pop	edi
97
	push	eax ebx esi
98
	mov	esi,edx
99
	movzx	ecx,byte [esi-1]
100
	call	identify_label
101
	mov	byte [edi],2
102
	inc	edi
103
	stos	dword [edi]
104
	pop	esi ebx eax
105
	stos	byte [edi]
106
	push	edi
107
      main_instruction_identified:
109 heavyiron 108
	pop	edi
157 heavyiron 109
	mov	dl,al
110
	mov	al,1
111
	stos	byte [edi]
112
	mov	ax,bx
113
	stos	word [edi]
114
	mov	al,dl
115
	stos	byte [edi]
116
	cmp	bx,if_directive-instruction_handler
1189 heavyiron 117
	je	parse_block
157 heavyiron 118
	cmp	bx,repeat_directive-instruction_handler
1189 heavyiron 119
	je	parse_block
157 heavyiron 120
	cmp	bx,while_directive-instruction_handler
1189 heavyiron 121
	je	parse_block
157 heavyiron 122
	cmp	bx,end_directive-instruction_handler
1189 heavyiron 123
	je	parse_end_directive
157 heavyiron 124
	cmp	bx,else_directive-instruction_handler
1189 heavyiron 125
	je	parse_else
157 heavyiron 126
	cmp	bx,assert_directive-instruction_handler
2664 dunkaist 127
	je	parse_assert
128
      common_parse:
109 heavyiron 129
	call	parse_line_contents
157 heavyiron 130
	jmp	parse_next_line
131
      empty_instruction:
109 heavyiron 132
	lods	byte [esi]
157 heavyiron 133
	or	al,al
134
	jz	parse_next_line
135
	cmp	al,':'
136
	je	invalid_name
137
	dec	esi
992 heavyiron 138
	mov	[parenthesis_stack],0
1242 heavyiron 139
	call	parse_argument
157 heavyiron 140
	jmp	parse_next_line
141
      empty_line:
109 heavyiron 142
	add	esi,16
992 heavyiron 143
      skip_rest_of_line:
144
	call	skip_foreign_line
145
      parse_next_line:
31 halyavin 146
	cmp	esi,[source_start]
157 heavyiron 147
	jb	parser_loop
148
      source_parsed:
109 heavyiron 149
	cmp	[blocks_stack],0
157 heavyiron 150
	je	blocks_stack_ok
151
	pop	eax
152
	pop	[current_line]
153
	jmp	missing_end_directive
154
      blocks_stack_ok:
109 heavyiron 155
	xor	al,al
157 heavyiron 156
	stos	byte [edi]
157
	add	edi,0Fh
158
	and	edi,not 0Fh
159
	mov	[code_start],edi
160
	ret
161
      parse_block:
109 heavyiron 162
	mov	eax,esp
157 heavyiron 163
	sub	eax,100h
164
	jc	stack_overflow
165
	cmp	eax,[stack_limit]
166
	jb	stack_overflow
167
	push	[current_line]
168
	mov	ax,bx
169
	shl	eax,16
170
	push	eax
171
	inc	[blocks_stack]
172
	cmp	bx,if_directive-instruction_handler
1189 heavyiron 173
	je	parse_if
157 heavyiron 174
	cmp	bx,while_directive-instruction_handler
1189 heavyiron 175
	je	parse_while
157 heavyiron 176
	call	parse_line_contents
177
	jmp	parse_next_line
178
      parse_end_directive:
109 heavyiron 179
	cmp	byte [esi],1Ah
157 heavyiron 180
	jne	common_parse
181
	push	edi
182
	inc	esi
183
	movzx	ecx,byte [esi]
184
	inc	esi
185
	call	get_instruction
186
	pop	edi
187
	jnc	parse_end_block
188
	sub	esi,2
189
	jmp	common_parse
190
      parse_end_block:
109 heavyiron 191
	mov	dl,al
157 heavyiron 192
	mov	al,1
193
	stos	byte [edi]
194
	mov	ax,bx
195
	stos	word [edi]
196
	mov	al,dl
197
	stos	byte [edi]
198
	lods	byte [esi]
199
	or	al,al
200
	jnz	extra_characters_on_line
201
	cmp	bx,if_directive-instruction_handler
1189 heavyiron 202
	je	close_parsing_block
157 heavyiron 203
	cmp	bx,repeat_directive-instruction_handler
1189 heavyiron 204
	je	close_parsing_block
157 heavyiron 205
	cmp	bx,while_directive-instruction_handler
1189 heavyiron 206
	je	close_parsing_block
157 heavyiron 207
	jmp	parse_next_line
208
      close_parsing_block:
109 heavyiron 209
	cmp	[blocks_stack],0
157 heavyiron 210
	je	unexpected_instruction
211
	cmp	bx,[esp+2]
212
	jne	unexpected_instruction
213
	dec	[blocks_stack]
214
	pop	eax edx
215
	cmp	bx,if_directive-instruction_handler
1189 heavyiron 216
	jne	parse_next_line
157 heavyiron 217
	test	al,1100b
218
	jz	parse_next_line
219
	test	al,10000b
220
	jnz	parse_next_line
221
	sub	edi,8
222
	jmp	parse_next_line
223
      parse_if:
109 heavyiron 224
	push	edi
157 heavyiron 225
	call	parse_line_contents
226
	xor	al,al
227
	stos	byte [edi]
228
	xchg	esi,[esp]
229
	mov	edi,esi
230
	call	preevaluate_logical_expression
231
	pop	esi
232
	cmp	al,'0'
233
	je	parse_false_condition_block
234
	cmp	al,'1'
235
	je	parse_true_condition_block
236
	or	byte [esp],10000b
237
	jmp	parse_next_line
238
      parse_while:
109 heavyiron 239
	push	edi
157 heavyiron 240
	call	parse_line_contents
241
	xor	al,al
242
	stos	byte [edi]
243
	xchg	esi,[esp]
244
	mov	edi,esi
245
	call	preevaluate_logical_expression
246
	pop	esi
247
	cmp	al,'0'
248
	je	parse_false_condition_block
249
	cmp	al,'1'
250
	jne	parse_next_line
251
	stos	byte [edi]
252
	jmp	parse_next_line
253
      parse_false_condition_block:
109 heavyiron 254
	or	byte [esp],1
157 heavyiron 255
	sub	edi,4
256
	jmp	skip_parsing
257
      parse_true_condition_block:
109 heavyiron 258
	or	byte [esp],100b
157 heavyiron 259
	sub	edi,4
260
	jmp	parse_next_line
261
      parse_else:
109 heavyiron 262
	cmp	[blocks_stack],0
157 heavyiron 263
	je	unexpected_instruction
264
	cmp	word [esp+2],if_directive-instruction_handler
1189 heavyiron 265
	jne	unexpected_instruction
157 heavyiron 266
	lods	byte [esi]
267
	or	al,al
268
	jz	parse_pure_else
269
	cmp	al,1Ah
270
	jne	extra_characters_on_line
271
	push	edi
272
	movzx	ecx,byte [esi]
273
	inc	esi
274
	call	get_instruction
275
	jc	extra_characters_on_line
276
	pop	edi
277
	cmp	bx,if_directive-instruction_handler
1189 heavyiron 278
	jne	extra_characters_on_line
157 heavyiron 279
	test	byte [esp],100b
280
	jnz	skip_true_condition_else
281
	mov	dl,al
282
	mov	al,1
283
	stos	byte [edi]
284
	mov	ax,bx
285
	stos	word [edi]
286
	mov	al,dl
287
	stos	byte [edi]
288
	jmp	parse_if
289
      parse_assert:
2664 dunkaist 290
	push	edi
291
	call	parse_line_contents
292
	xor	al,al
293
	stos	byte [edi]
294
	xchg	esi,[esp]
295
	mov	edi,esi
296
	call	preevaluate_logical_expression
297
	pop	esi
298
	or	al,al
299
	jz	parse_next_line
300
	stos	byte [edi]
301
	jmp	parse_next_line
302
      skip_true_condition_else:
109 heavyiron 303
	sub	edi,4
157 heavyiron 304
	or	byte [esp],1
305
	jmp	skip_parsing_contents
306
      parse_pure_else:
109 heavyiron 307
	bts	dword [esp],1
157 heavyiron 308
	jc	unexpected_instruction
309
	test	byte [esp],100b
310
	jz	parse_next_line
311
	sub	edi,4
312
	or	byte [esp],1
313
	jmp	skip_parsing
314
      skip_parsing:
109 heavyiron 315
	cmp	esi,[source_start]
157 heavyiron 316
	jae	source_parsed
317
	mov	[current_line],esi
318
	add	esi,16
319
      skip_parsing_line:
109 heavyiron 320
	cmp	byte [esi],1Ah
157 heavyiron 321
	jne	skip_parsing_contents
322
	inc	esi
323
	movzx	ecx,byte [esi]
324
	inc	esi
325
	cmp	byte [esi+ecx],':'
326
	je	skip_parsing_label
327
	push	edi
328
	call	get_instruction
329
	pop	edi
330
	jnc	skip_parsing_instruction
331
	add	esi,ecx
332
	jmp	skip_parsing_contents
333
      skip_parsing_label:
109 heavyiron 334
	lea	esi,[esi+ecx+1]
157 heavyiron 335
	jmp	skip_parsing_line
336
      skip_parsing_instruction:
109 heavyiron 337
	cmp	bx,if_directive-instruction_handler
1189 heavyiron 338
	je	skip_parsing_block
157 heavyiron 339
	cmp	bx,repeat_directive-instruction_handler
1189 heavyiron 340
	je	skip_parsing_block
157 heavyiron 341
	cmp	bx,while_directive-instruction_handler
1189 heavyiron 342
	je	skip_parsing_block
157 heavyiron 343
	cmp	bx,end_directive-instruction_handler
1189 heavyiron 344
	je	skip_parsing_end_directive
157 heavyiron 345
	cmp	bx,else_directive-instruction_handler
1189 heavyiron 346
	je	skip_parsing_else
157 heavyiron 347
      skip_parsing_contents:
109 heavyiron 348
	lods	byte [esi]
157 heavyiron 349
	or	al,al
350
	jz	skip_parsing
351
	cmp	al,1Ah
352
	je	skip_parsing_symbol
353
	cmp	al,3Bh
354
	je	skip_parsing_symbol
355
	cmp	al,22h
356
	je	skip_parsing_string
357
	jmp	skip_parsing_contents
358
      skip_parsing_symbol:
109 heavyiron 359
	lods	byte [esi]
157 heavyiron 360
	movzx	eax,al
361
	add	esi,eax
362
	jmp	skip_parsing_contents
363
      skip_parsing_string:
109 heavyiron 364
	lods	dword [esi]
157 heavyiron 365
	add	esi,eax
366
	jmp	skip_parsing_contents
367
      skip_parsing_block:
109 heavyiron 368
	mov	eax,esp
157 heavyiron 369
	sub	eax,100h
370
	jc	stack_overflow
371
	cmp	eax,[stack_limit]
372
	jb	stack_overflow
373
	push	[current_line]
374
	mov	ax,bx
375
	shl	eax,16
376
	push	eax
377
	inc	[blocks_stack]
378
	jmp	skip_parsing_contents
379
      skip_parsing_end_directive:
109 heavyiron 380
	cmp	byte [esi],1Ah
157 heavyiron 381
	jne	skip_parsing_contents
382
	push	edi
383
	inc	esi
384
	movzx	ecx,byte [esi]
385
	inc	esi
386
	call	get_instruction
387
	pop	edi
388
	jnc	skip_parsing_end_block
389
	add	esi,ecx
390
	jmp	skip_parsing_contents
391
      skip_parsing_end_block:
109 heavyiron 392
	lods	byte [esi]
157 heavyiron 393
	or	al,al
394
	jnz	extra_characters_on_line
395
	cmp	bx,if_directive-instruction_handler
1189 heavyiron 396
	je	close_skip_parsing_block
157 heavyiron 397
	cmp	bx,repeat_directive-instruction_handler
1189 heavyiron 398
	je	close_skip_parsing_block
157 heavyiron 399
	cmp	bx,while_directive-instruction_handler
1189 heavyiron 400
	je	close_skip_parsing_block
157 heavyiron 401
	jmp	skip_parsing
402
      close_skip_parsing_block:
109 heavyiron 403
	cmp	[blocks_stack],0
157 heavyiron 404
	je	unexpected_instruction
405
	cmp	bx,[esp+2]
406
	jne	unexpected_instruction
407
	dec	[blocks_stack]
408
	pop	eax edx
409
	test	al,1
410
	jz	skip_parsing
411
	cmp	bx,if_directive-instruction_handler
1189 heavyiron 412
	jne	parse_next_line
157 heavyiron 413
	test	al,10000b
414
	jz	parse_next_line
415
	mov	al,0Fh
416
	stos	byte [edi]
417
	mov	eax,[current_line]
418
	stos	dword [edi]
419
	inc	[parsed_lines]
242 heavyiron 420
	mov	eax,1 + (end_directive-instruction_handler) shl 8
1189 heavyiron 421
	stos	dword [edi]
157 heavyiron 422
	mov	eax,1 + (if_directive-instruction_handler) shl 8
1189 heavyiron 423
	stos	dword [edi]
157 heavyiron 424
	jmp	parse_next_line
425
      skip_parsing_else:
109 heavyiron 426
	cmp	[blocks_stack],0
157 heavyiron 427
	je	unexpected_instruction
428
	cmp	word [esp+2],if_directive-instruction_handler
1189 heavyiron 429
	jne	unexpected_instruction
157 heavyiron 430
	lods	byte [esi]
431
	or	al,al
432
	jz	skip_parsing_pure_else
433
	cmp	al,1Ah
434
	jne	extra_characters_on_line
435
	push	edi
436
	movzx	ecx,byte [esi]
437
	inc	esi
438
	call	get_instruction
439
	jc	extra_characters_on_line
440
	pop	edi
441
	cmp	bx,if_directive-instruction_handler
1189 heavyiron 442
	jne	extra_characters_on_line
157 heavyiron 443
	mov	al,[esp]
444
	test	al,1
445
	jz	skip_parsing_contents
446
	test	al,100b
447
	jnz	skip_parsing_contents
448
	test	al,10000b
449
	jnz	parse_else_if
450
	xor	al,al
451
	mov	[esp],al
452
	mov	al,0Fh
453
	stos	byte [edi]
454
	mov	eax,[current_line]
455
	stos	dword [edi]
456
	inc	[parsed_lines]
242 heavyiron 457
      parse_else_if:
109 heavyiron 458
	mov	eax,1 + (if_directive-instruction_handler) shl 8
1189 heavyiron 459
	stos	dword [edi]
157 heavyiron 460
	jmp	parse_if
461
      skip_parsing_pure_else:
109 heavyiron 462
	bts	dword [esp],1
157 heavyiron 463
	jc	unexpected_instruction
464
	mov	al,[esp]
465
	test	al,1
466
	jz	skip_parsing
467
	test	al,100b
468
	jnz	skip_parsing
469
	and	al,not 1
470
	or	al,1000b
471
	mov	[esp],al
472
	jmp	parse_next_line
473
31 halyavin 474
 
109 heavyiron 475
	mov	[parenthesis_stack],0
157 heavyiron 476
      parse_instruction_arguments:
109 heavyiron 477
	cmp	bx,prefix_instruction-instruction_handler
1189 heavyiron 478
	je	allow_embedded_instruction
157 heavyiron 479
	cmp	bx,times_directive-instruction_handler
1189 heavyiron 480
	je	parse_times_directive
157 heavyiron 481
	cmp	bx,end_directive-instruction_handler
1189 heavyiron 482
	je	allow_embedded_instruction
157 heavyiron 483
	cmp	bx,label_directive-instruction_handler
1189 heavyiron 484
	je	parse_label_directive
157 heavyiron 485
	cmp	bx,segment_directive-instruction_handler
1189 heavyiron 486
	je	parse_segment_directive
2287 heavyiron 487
	cmp	bx,load_directive-instruction_handler
1189 heavyiron 488
	je	parse_load_directive
157 heavyiron 489
	cmp	bx,extrn_directive-instruction_handler
1189 heavyiron 490
	je	parse_extrn_directive
157 heavyiron 491
	cmp	bx,public_directive-instruction_handler
1189 heavyiron 492
	je	parse_public_directive
157 heavyiron 493
	cmp	bx,section_directive-instruction_handler
2287 heavyiron 494
	je	parse_formatter_argument
495
	cmp	bx,format_directive-instruction_handler
496
	je	parse_formatter_argument
497
	cmp	bx,data_directive-instruction_handler
498
	je	parse_formatter_argument
499
	jmp	parse_argument
500
      parse_formatter_argument:
501
	or	[formatter_symbols_allowed],-1
502
      parse_argument:
109 heavyiron 503
	lea	eax,[edi+100h]
157 heavyiron 504
	cmp	eax,[labels_list]
505
	jae	out_of_memory
506
	lods	byte [esi]
507
	cmp	al,':'
508
	je	instruction_separator
509
	cmp	al,','
510
	je	separator
511
	cmp	al,'='
512
	je	expression_comparator
2665 dunkaist 513
	cmp	al,'|'
157 heavyiron 514
	je	separator
515
	cmp	al,'&'
516
	je	separator
517
	cmp	al,'~'
518
	je	separator
519
	cmp	al,'>'
520
	je	greater
521
	cmp	al,'<'
522
	je	less
523
	cmp	al,')'
524
	je	close_parenthesis
525
	or	al,al
526
	jz	contents_parsed
527
	cmp	al,'['
528
	je	address_argument
529
	cmp	al,']'
530
	je	separator
531
	cmp	al,'{'
532
	je	open_decorator
6467 dunkaist 533
	cmp	al,'}'
157 heavyiron 534
	je	close_decorator
6467 dunkaist 535
	cmp	al,'#'
157 heavyiron 536
	je	unallowed_character
537
	cmp	al,'`'
538
	je	unallowed_character
539
	cmp	al,3Bh
4039 heavyiron 540
	je	foreign_argument
541
	cmp	[decorator_symbols_allowed],0
6467 dunkaist 542
	je	not_a_separator
543
	cmp	al,'-'
544
	je	separator
545
      not_a_separator:
546
	dec	esi
157 heavyiron 547
	cmp	al,1Ah
548
	jne	expression_argument
549
	push	edi
550
	mov	edi,directive_operators
551
	call	get_operator
552
	or	al,al
553
	jnz	operator_argument
554
	inc	esi
555
	movzx	ecx,byte [esi]
556
	inc	esi
557
	call	get_symbol
558
	jnc	symbol_argument
559
	cmp	ecx,1
560
	jne	check_argument
561
	cmp	byte [esi],'?'
562
	jne	check_argument
563
	pop	edi
564
	movs	byte [edi],[esi]
565
	jmp	argument_parsed
566
      foreign_argument:
4039 heavyiron 567
	dec	esi
568
	call	skip_foreign_line
569
	jmp	contents_parsed
570
      symbol_argument:
109 heavyiron 571
	pop	edi
157 heavyiron 572
	stos	word [edi]
573
	jmp	argument_parsed
574
      operator_argument:
109 heavyiron 575
	pop	edi
157 heavyiron 576
	cmp	al,85h
577
	je	ptr_argument
578
	stos	byte [edi]
579
	cmp	al,80h
580
	je	forced_multipart_expression
4039 heavyiron 581
	cmp	al,8Ch
2287 heavyiron 582
	je	forced_expression
583
	cmp	al,81h
157 heavyiron 584
	je	forced_parenthesis
585
	cmp	al,82h
586
	je	parse_from_operator
587
	cmp	al,89h
588
	je	parse_label_operator
589
	cmp	al,0F8h
2665 dunkaist 590
	je	forced_expression
591
	jmp	argument_parsed
157 heavyiron 592
      instruction_separator:
2665 dunkaist 593
	stos	byte [edi]
594
      allow_embedded_instruction:
109 heavyiron 595
	cmp	byte [esi],1Ah
157 heavyiron 596
	jne	parse_argument
597
	push	edi
598
	inc	esi
599
	movzx	ecx,byte [esi]
600
	inc	esi
601
	call	get_instruction
602
	jnc	embedded_instruction
603
	call	get_data_directive
604
	jnc	embedded_instruction
605
	pop	edi
606
	sub	esi,2
607
	jmp	parse_argument
608
      embedded_instruction:
109 heavyiron 609
	pop	edi
157 heavyiron 610
	mov	dl,al
611
	mov	al,1
612
	stos	byte [edi]
613
	mov	ax,bx
614
	stos	word [edi]
615
	mov	al,dl
616
	stos	byte [edi]
617
	jmp	parse_instruction_arguments
618
      parse_times_directive:
109 heavyiron 619
	mov	al,'('
157 heavyiron 620
	stos	byte [edi]
621
	call	convert_expression
622
	mov	al,')'
623
	stos	byte [edi]
624
	cmp	byte [esi],':'
625
	jne	allow_embedded_instruction
626
	movs	byte [edi],[esi]
627
	jmp	allow_embedded_instruction
628
      parse_segment_directive:
2287 heavyiron 629
	or	[formatter_symbols_allowed],-1
630
      parse_label_directive:
31 halyavin 631
	cmp	byte [esi],1Ah
157 heavyiron 632
	jne	argument_parsed
633
	push	esi
634
	inc	esi
635
	movzx	ecx,byte [esi]
636
	inc	esi
637
	call	identify_label
638
	pop	ebx
639
	cmp	eax,0Fh
640
	je	non_label_identified
641
	mov	byte [edi],2
642
	inc	edi
643
	stos	dword [edi]
644
	xor	al,al
645
	stos	byte [edi]
646
	jmp	argument_parsed
647
      non_label_identified:
109 heavyiron 648
	mov	esi,ebx
157 heavyiron 649
	jmp	argument_parsed
650
      parse_load_directive:
31 halyavin 651
	cmp	byte [esi],1Ah
157 heavyiron 652
	jne	argument_parsed
653
	push	esi
654
	inc	esi
655
	movzx	ecx,byte [esi]
656
	inc	esi
657
	call	get_label_id
658
	pop	ebx
659
	cmp	eax,0Fh
660
	je	non_label_identified
661
	mov	byte [edi],2
662
	inc	edi
663
	stos	dword [edi]
664
	xor	al,al
665
	stos	byte [edi]
666
	jmp	argument_parsed
667
      parse_public_directive:
31 halyavin 668
	cmp	byte [esi],1Ah
157 heavyiron 669
	jne	parse_argument
670
	inc	esi
671
	push	esi
672
	movzx	ecx,byte [esi]
673
	inc	esi
674
	push	esi ecx
624 heavyiron 675
	push	edi
676
	or	[formatter_symbols_allowed],-1
2287 heavyiron 677
	call	get_symbol
624 heavyiron 678
	mov	[formatter_symbols_allowed],0
2287 heavyiron 679
	pop	edi
624 heavyiron 680
	jc	parse_public_label
681
	cmp	al,1Dh
682
	jne	parse_public_label
683
	add	esp,12
684
	stos	word [edi]
685
	jmp	parse_public_directive
686
      parse_public_label:
687
	pop	ecx esi
688
	mov	al,2
157 heavyiron 689
	stos	byte [edi]
690
	call	get_label_id
691
	stos	dword [edi]
692
	mov	ax,8600h
693
	stos	word [edi]
694
	pop	ebx
695
	push	ebx esi edi
696
	mov	edi,directive_operators
697
	call	get_operator
698
	pop	edi edx ebx
699
	cmp	al,86h
700
	je	argument_parsed
701
	mov	esi,edx
702
	xchg	esi,ebx
703
	movzx	ecx,byte [esi]
704
	inc	esi
705
	mov	ax,'('
706
	stos	word [edi]
707
	mov	eax,ecx
708
	stos	dword [edi]
709
	rep	movs byte [edi],[esi]
710
	xor	al,al
711
	stos	byte [edi]
712
	xchg	esi,ebx
713
	jmp	argument_parsed
714
      parse_extrn_directive:
31 halyavin 715
	cmp	byte [esi],22h
157 heavyiron 716
	je	parse_quoted_extrn
717
	cmp	byte [esi],1Ah
718
	jne	parse_argument
719
	push	esi
720
	movzx	ecx,byte [esi+1]
721
	add	esi,2
722
	mov	ax,'('
723
	stos	word [edi]
724
	mov	eax,ecx
725
	stos	dword [edi]
726
	rep	movs byte [edi],[esi]
727
	mov	ax,8600h
728
	stos	word [edi]
729
	pop	esi
730
      parse_label_operator:
31 halyavin 731
	cmp	byte [esi],1Ah
157 heavyiron 732
	jne	argument_parsed
733
	inc	esi
734
	movzx	ecx,byte [esi]
735
	inc	esi
736
	mov	al,2
737
	stos	byte [edi]
738
	call	get_label_id
739
	stos	dword [edi]
740
	xor	al,al
741
	stos	byte [edi]
742
	jmp	argument_parsed
743
      parse_from_operator:
31 halyavin 744
	cmp	byte [esi],22h
157 heavyiron 745
	jne	forced_multipart_expression
4039 heavyiron 746
	jmp	argument_parsed
157 heavyiron 747
      parse_quoted_extrn:
31 halyavin 748
	inc	esi
157 heavyiron 749
	mov	ax,'('
750
	stos	word [edi]
751
	lods	dword [esi]
752
	mov	ecx,eax
753
	stos	dword [edi]
754
	rep	movs byte [edi],[esi]
755
	xor	al,al
756
	stos	byte [edi]
757
	push	esi edi
758
	mov	edi,directive_operators
759
	call	get_operator
760
	mov	edx,esi
761
	pop	edi esi
762
	cmp	al,86h
763
	jne	argument_parsed
764
	stos	byte [edi]
765
	mov	esi,edx
766
	jmp	parse_label_operator
767
      ptr_argument:
31 halyavin 768
	call	parse_address
157 heavyiron 769
	jmp	address_parsed
770
      check_argument:
31 halyavin 771
	push	esi ecx
157 heavyiron 772
	sub	esi,2
773
	mov	edi,single_operand_operators
774
	call	get_operator
775
	pop	ecx esi
776
	or	al,al
777
	jnz	not_instruction
778
	call	get_instruction
779
	jnc	embedded_instruction
780
	call	get_data_directive
781
	jnc	embedded_instruction
782
      not_instruction:
31 halyavin 783
	pop	edi
157 heavyiron 784
	sub	esi,2
785
      expression_argument:
31 halyavin 786
	cmp	byte [esi],22h
157 heavyiron 787
	jne	not_string
788
	mov	eax,[esi+1]
789
	lea	ebx,[esi+5+eax]
790
	push	ebx ecx esi edi
791
	call	parse_expression
4039 heavyiron 792
	pop	eax edx ecx ebx
157 heavyiron 793
	cmp	esi,ebx
794
	jne	expression_argument_parsed
4039 heavyiron 795
	mov	edi,eax
157 heavyiron 796
	mov	esi,edx
797
      string_argument:
31 halyavin 798
	inc	esi
157 heavyiron 799
	mov	ax,'('
800
	stos	word [edi]
801
	lods	dword [esi]
802
	mov	ecx,eax
803
	stos	dword [edi]
804
	shr	ecx,1
805
	jnc	string_movsb_ok
806
	movs	byte [edi],[esi]
807
      string_movsb_ok:
31 halyavin 808
	shr	ecx,1
157 heavyiron 809
	jnc	string_movsw_ok
810
	movs	word [edi],[esi]
811
      string_movsw_ok:
31 halyavin 812
	rep	movs dword [edi],[esi]
157 heavyiron 813
	xor	al,al
814
	stos	byte [edi]
815
	jmp	expression_argument_parsed
4039 heavyiron 816
      parse_expression:
817
	mov	al,'('
818
	stos	byte [edi]
819
	call	convert_expression
820
	mov	al,')'
821
	stos	byte [edi]
822
	ret
823
      not_string:
31 halyavin 824
	cmp	byte [esi],'('
157 heavyiron 825
	jne	expression
826
	mov	eax,esp
827
	sub	eax,100h
828
	jc	stack_overflow
829
	cmp	eax,[stack_limit]
830
	jb	stack_overflow
831
	push	esi edi
832
	inc	esi
833
	mov	al,91h
6467 dunkaist 834
	stos	byte [edi]
157 heavyiron 835
	inc	[parenthesis_stack]
836
	jmp	parse_argument
837
      expression_comparator:
2665 dunkaist 838
	stos	byte [edi]
839
	jmp	forced_expression
840
      greater:
841
	cmp	byte [esi],'='
842
	jne	separator
843
	inc	esi
844
	mov	al,0F2h
845
	jmp	separator
846
      less:
847
	cmp	byte [edi-1],0F6h
848
	je	separator
849
	cmp	byte [esi],'>'
850
	je	not_equal
851
	cmp	byte [esi],'='
852
	jne	separator
853
	inc	esi
854
	mov	al,0F3h
855
	jmp	separator
856
      not_equal:
857
	inc	esi
858
	mov	al,0F1h
859
	jmp	expression_comparator
860
      expression:
31 halyavin 861
	call	parse_expression
4039 heavyiron 862
	jmp	expression_argument_parsed
863
      forced_expression:
31 halyavin 864
	xor	al,al
2287 heavyiron 865
	xchg	al,[formatter_symbols_allowed]
866
	push	eax
867
	call	parse_expression
4039 heavyiron 868
      forced_expression_parsed:
869
	pop	eax
2287 heavyiron 870
	mov	[formatter_symbols_allowed],al
871
	jmp	argument_parsed
157 heavyiron 872
      forced_multipart_expression:
4039 heavyiron 873
	xor	al,al
874
	xchg	al,[formatter_symbols_allowed]
875
	push	eax
876
	call	parse_expression
877
	cmp	byte [esi],':'
878
	jne	forced_expression_parsed
879
	movs	byte [edi],[esi]
880
	call	parse_expression
881
	jmp	forced_expression_parsed
882
      address_argument:
31 halyavin 883
	call	parse_address
157 heavyiron 884
	lods	byte [esi]
885
	cmp	al,']'
886
	je	address_parsed
887
	cmp	al,','
6467 dunkaist 888
	je	divided_address
889
	dec	esi
157 heavyiron 890
	mov	al,')'
891
	stos	byte [edi]
892
	jmp	argument_parsed
893
      divided_address:
6467 dunkaist 894
	mov	ax,'),'
895
	stos	word [edi]
896
	jmp	expression
897
      address_parsed:
31 halyavin 898
	mov	al,']'
157 heavyiron 899
	stos	byte [edi]
900
	jmp	argument_parsed
901
      parse_address:
31 halyavin 902
	mov	al,'['
157 heavyiron 903
	stos	byte [edi]
904
	cmp	word [esi],021Ah
905
	jne	convert_address
906
	push	esi
907
	add	esi,4
908
	lea	ebx,[esi+1]
909
	cmp	byte [esi],':'
910
	pop	esi
911
	jne	convert_address
912
	add	esi,2
913
	mov	ecx,2
914
	push	ebx edi
915
	call	get_symbol
916
	pop	edi esi
917
	jc	unknown_segment_prefix
918
	cmp	al,10h
919
	jne	unknown_segment_prefix
920
	mov	al,ah
921
	and	ah,11110000b
922
	cmp	ah,30h
6467 dunkaist 923
	jne	unknown_segment_prefix
157 heavyiron 924
	add	al,30h
6467 dunkaist 925
	stos	byte [edi]
157 heavyiron 926
	jmp	convert_address
927
      unknown_segment_prefix:
109 heavyiron 928
	sub	esi,5
157 heavyiron 929
      convert_address:
31 halyavin 930
	push	edi
157 heavyiron 931
	mov	edi,address_sizes
932
	call	get_operator
933
	pop	edi
934
	or	al,al
935
	jz	convert_expression
936
	add	al,70h
937
	stos	byte [edi]
938
	jmp	convert_expression
939
      forced_parenthesis:
31 halyavin 940
	cmp	byte [esi],'('
157 heavyiron 941
	jne	argument_parsed
942
	inc	esi
943
	mov	al,91h
6467 dunkaist 944
	jmp	separator
157 heavyiron 945
      unallowed_character:
31 halyavin 946
	mov	al,0FFh
157 heavyiron 947
	jmp	separator
948
      open_decorator:
6467 dunkaist 949
	inc	[decorator_symbols_allowed]
950
	jmp	separator
951
      close_decorator:
952
	dec	[decorator_symbols_allowed]
953
	jmp	separator
954
      close_parenthesis:
31 halyavin 955
	mov	al,92h
6467 dunkaist 956
      separator:
31 halyavin 957
	stos	byte [edi]
157 heavyiron 958
      argument_parsed:
31 halyavin 959
	cmp	[parenthesis_stack],0
157 heavyiron 960
	je	parse_argument
961
	dec	[parenthesis_stack]
962
	add	esp,8
963
	jmp	argument_parsed
964
      expression_argument_parsed:
4039 heavyiron 965
	cmp	[parenthesis_stack],0
157 heavyiron 966
	je	parse_argument
967
	cmp	byte [esi],')'
968
	jne	argument_parsed
969
	dec	[parenthesis_stack]
970
	pop	edi esi
971
	jmp	expression
972
      contents_parsed:
109 heavyiron 973
	cmp	[parenthesis_stack],0
157 heavyiron 974
	je	contents_ok
242 heavyiron 975
	dec	[parenthesis_stack]
976
	add	esp,8
977
	jmp	contents_parsed
978
      contents_ok:
979
	ret
157 heavyiron 980
31 halyavin 981
 
109 heavyiron 982
	cmp	byte [esi],'.'
157 heavyiron 983
	je	local_label_name
984
	call	get_label_id
985
	cmp	eax,10h
986
	jb	label_identified
987
	or	ebx,ebx
988
	jz	anonymous_label_name
989
	dec	ebx
990
	mov	[current_locals_prefix],ebx
991
      label_identified:
109 heavyiron 992
	ret
157 heavyiron 993
      anonymous_label_name:
109 heavyiron 994
	cmp	byte [esi-1],'@'
157 heavyiron 995
	je	anonymous_label_name_ok
996
	mov	eax,0Fh
997
      anonymous_label_name_ok:
109 heavyiron 998
	ret
157 heavyiron 999
      local_label_name:
109 heavyiron 1000
	call	get_label_id
157 heavyiron 1001
	ret
1002
109 heavyiron 1003
 
31 halyavin 1004
	cmp	byte [esi],1Ah
157 heavyiron 1005
	jne	get_simple_operator
1006
	mov	edx,esi
1007
	push	ebp
1008
	inc	esi
1009
	lods	byte [esi]
1010
	movzx	ebp,al
1011
	push	edi
1012
	mov	ecx,ebp
1013
	call	lower_case
1014
	pop	edi
1015
      check_operator:
31 halyavin 1016
	mov	esi,converted
157 heavyiron 1017
	movzx	ecx,byte [edi]
1018
	jecxz	no_operator
1019
	inc	edi
1020
	mov	ebx,edi
1021
	add	ebx,ecx
1022
	cmp	ecx,ebp
1023
	jne	next_operator
1024
	repe	cmps byte [esi],[edi]
1025
	je	operator_found
1026
	jb	no_operator
2665 dunkaist 1027
      next_operator:
31 halyavin 1028
	mov	edi,ebx
157 heavyiron 1029
	inc	edi
1030
	jmp	check_operator
1031
      no_operator:
31 halyavin 1032
	mov	esi,edx
157 heavyiron 1033
	mov	ecx,ebp
1034
	pop	ebp
1035
      no_simple_operator:
31 halyavin 1036
	xor	al,al
157 heavyiron 1037
	ret
1038
      operator_found:
31 halyavin 1039
	lea	esi,[edx+2+ebp]
157 heavyiron 1040
	mov	ecx,ebp
1041
	pop	ebp
1042
	mov	al,[edi]
1043
	ret
1044
      get_simple_operator:
31 halyavin 1045
	mov	al,[esi]
157 heavyiron 1046
	cmp	al,22h
1047
	je	no_simple_operator
1048
      simple_operator:
31 halyavin 1049
	cmp	byte [edi],1
157 heavyiron 1050
	jb	no_simple_operator
1051
	ja	simple_next_operator
1052
	cmp	al,[edi+1]
1053
	je	simple_operator_found
1054
      simple_next_operator:
31 halyavin 1055
	movzx	ecx,byte [edi]
157 heavyiron 1056
	lea	edi,[edi+1+ecx+1]
1057
	jmp	simple_operator
1058
      simple_operator_found:
31 halyavin 1059
	inc	esi
157 heavyiron 1060
	mov	al,[edi+2]
1061
	ret
1062
31 halyavin 1063
 
1064
	push	esi
157 heavyiron 1065
	mov	ebp,ecx
1066
	call	lower_case
1067
	mov	ecx,ebp
1068
	cmp	cl,11
1069
	ja	no_symbol
1070
	sub	cl,1
6467 dunkaist 1071
	jc	no_symbol
157 heavyiron 1072
	movzx	ebx,word [symbols+ecx*4]
1073
	add	ebx,symbols
1074
	movzx	edx,word [symbols+ecx*4+2]
1075
      scan_symbols:
31 halyavin 1076
	or	edx,edx
157 heavyiron 1077
	jz	no_symbol
1078
	mov	eax,edx
1079
	shr	eax,1
1080
	lea	edi,[ebp+2]
1081
	imul	eax,edi
1082
	lea	edi,[ebx+eax]
1083
	mov	esi,converted
1084
	mov	ecx,ebp
1085
	repe	cmps byte [esi],[edi]
1086
	ja	symbols_up
1087
	jb	symbols_down
1088
	mov	ax,[edi]
2287 heavyiron 1089
	cmp	al,18h
1090
	jb	symbol_ok
1091
	cmp	al,1Fh
6467 dunkaist 1092
	je	decorator_symbol
1093
	cmp	[formatter_symbols_allowed],0
2287 heavyiron 1094
	je	no_symbol
1095
      symbol_ok:
1096
	pop	esi
157 heavyiron 1097
	add	esi,ebp
1098
	clc
1099
	ret
1100
      decorator_symbol:
6467 dunkaist 1101
	cmp	[decorator_symbols_allowed],0
1102
	jne	symbol_ok
1103
      no_symbol:
31 halyavin 1104
	pop	esi
157 heavyiron 1105
	mov	ecx,ebp
1106
	stc
1107
	ret
1108
      symbols_down:
109 heavyiron 1109
	shr	edx,1
157 heavyiron 1110
	jmp	scan_symbols
1111
      symbols_up:
109 heavyiron 1112
	lea	ebx,[edi+ecx+2]
157 heavyiron 1113
	shr	edx,1
1114
	adc	edx,-1
1115
	jmp	scan_symbols
1116
31 halyavin 1117
 
109 heavyiron 1118
	push	esi
157 heavyiron 1119
	mov	ebp,ecx
1120
	call	lower_case
1121
	mov	ecx,ebp
1122
	cmp	cl,4
1123
	ja	no_instruction
1124
	sub	cl,2
1125
	jc	no_instruction
1126
	movzx	ebx,word [data_directives+ecx*4]
1127
	add	ebx,data_directives
1128
	movzx	edx,word [data_directives+ecx*4+2]
1129
	jmp	scan_instructions
1130
109 heavyiron 1131
 
31 halyavin 1132
	push	esi
157 heavyiron 1133
	mov	ebp,ecx
1134
	call	lower_case
1135
	mov	ecx,ebp
1136
	cmp	cl,16
2287 heavyiron 1137
	ja	no_instruction
157 heavyiron 1138
	sub	cl,2
1139
	jc	no_instruction
1140
	movzx	ebx,word [instructions+ecx*4]
1141
	add	ebx,instructions
1142
	movzx	edx,word [instructions+ecx*4+2]
1143
      scan_instructions:
31 halyavin 1144
	or	edx,edx
157 heavyiron 1145
	jz	no_instruction
1146
	mov	eax,edx
1147
	shr	eax,1
1148
	lea	edi,[ebp+3]
1149
	imul	eax,edi
1150
	lea	edi,[ebx+eax]
1151
	mov	esi,converted
1152
	mov	ecx,ebp
1153
	repe	cmps byte [esi],[edi]
1154
	ja	instructions_up
1155
	jb	instructions_down
1156
	pop	esi
1157
	add	esi,ebp
1158
	mov	al,[edi]
1159
	mov	bx,[edi+1]
1160
	clc
1161
	ret
1162
      no_instruction:
31 halyavin 1163
	pop	esi
157 heavyiron 1164
	mov	ecx,ebp
1165
	stc
1166
	ret
1167
      instructions_down:
109 heavyiron 1168
	shr	edx,1
157 heavyiron 1169
	jmp	scan_instructions
1170
      instructions_up:
109 heavyiron 1171
	lea	ebx,[edi+ecx+3]
157 heavyiron 1172
	shr	edx,1
1173
	adc	edx,-1
1174
	jmp	scan_instructions
1175
31 halyavin 1176
 
1177
	cmp	ecx,100h
157 heavyiron 1178
	jae	name_too_long
1179
	cmp	byte [esi],'@'
1180
	je	anonymous_label
1181
	cmp	byte [esi],'.'
1182
	jne	standard_label
1183
	cmp	byte [esi+1],'.'
1184
	je	standard_label
1185
	cmp	[current_locals_prefix],0
1186
	je	standard_label
1187
	push	edi
1188
	mov	edi,[additional_memory_end]
1189
	sub	edi,2
1190
	sub	edi,ecx
1191
	push	ecx esi
1192
	mov	esi,[current_locals_prefix]
1193
	lods	byte [esi]
1194
	movzx	ecx,al
1195
	sub	edi,ecx
1196
	cmp	edi,[free_additional_memory]
1197
	jb	out_of_memory
1198
	mov	word [edi],0
1199
	add	edi,2
1200
	mov	ebx,edi
1201
	rep	movs byte [edi],[esi]
1202
	pop	esi ecx
1203
	add	al,cl
1204
	jc	name_too_long
1205
	rep	movs byte [edi],[esi]
1206
	pop	edi
1207
	push	ebx esi
1208
	movzx	ecx,al
1209
	mov	byte [ebx-1],al
1210
	mov	esi,ebx
1211
	call	get_label_id
1212
	pop	esi ebx
1213
	cmp	ebx,[eax+24]
1214
	jne	composed_label_id_ok
1215
	lea	edx,[ebx-2]
1216
	mov	[additional_memory_end],edx
1217
      composed_label_id_ok:
109 heavyiron 1218
	ret
157 heavyiron 1219
      anonymous_label:
31 halyavin 1220
	cmp	ecx,2
157 heavyiron 1221
	jne	standard_label
1222
	mov	al,[esi+1]
1223
	mov	ebx,characters
1224
	xlat	byte [ebx]
1225
	cmp	al,'@'
1226
	je	new_anonymous
1227
	cmp	al,'b'
1228
	je	anonymous_back
1229
	cmp	al,'r'
1230
	je	anonymous_back
1231
	cmp	al,'f'
1232
	jne	standard_label
1233
	add	esi,2
1234
	mov	eax,[anonymous_forward]
1235
	or	eax,eax
1236
	jnz	anonymous_ok
1237
	mov	eax,[current_line]
1238
	mov	[error_line],eax
1239
	call	allocate_label
1240
	mov	[anonymous_forward],eax
1241
      anonymous_ok:
31 halyavin 1242
	xor	ebx,ebx
157 heavyiron 1243
	ret
1244
      anonymous_back:
31 halyavin 1245
	mov	eax,[anonymous_reverse]
157 heavyiron 1246
	add	esi,2
2287 heavyiron 1247
	or	eax,eax
157 heavyiron 1248
	jz	bogus_anonymous
2287 heavyiron 1249
	jmp	anonymous_ok
157 heavyiron 1250
      bogus_anonymous:
2287 heavyiron 1251
	call	allocate_label
1252
	mov	[anonymous_reverse],eax
1253
	jmp	anonymous_ok
1254
      new_anonymous:
31 halyavin 1255
	add	esi,2
157 heavyiron 1256
	mov	eax,[anonymous_forward]
1257
	or	eax,eax
1258
	jnz	new_anonymous_ok
1259
	call	allocate_label
1260
      new_anonymous_ok:
31 halyavin 1261
	mov	[anonymous_reverse],eax
157 heavyiron 1262
	mov	[anonymous_forward],0
1263
	jmp	anonymous_ok
1264
      standard_label:
31 halyavin 1265
	cmp	byte [esi],'%'
157 heavyiron 1266
	je	get_predefined_id
1267
	cmp	byte [esi],'$'
1268
	je	current_address_label
2287 heavyiron 1269
	cmp	byte [esi],'?'
1270
	jne	find_label
157 heavyiron 1271
	cmp	ecx,1
2287 heavyiron 1272
	jne	find_label
1273
	inc	esi
1274
	mov	eax,0Fh
1275
	ret
1276
      current_address_label:
1277
	cmp	ecx,2
157 heavyiron 1278
	ja	find_label
1279
	inc	esi
1280
	jb	get_current_offset_id
1281
	inc	esi
1282
	cmp	byte [esi-1],'$'
1283
	je	get_org_origin_id
1284
	sub	esi,2
6467 dunkaist 1285
	jmp	find_label
157 heavyiron 1286
      get_current_offset_id:
31 halyavin 1287
	xor	eax,eax
157 heavyiron 1288
	ret
1289
      get_counter_id:
31 halyavin 1290
	mov	eax,1
157 heavyiron 1291
	ret
1292
      get_timestamp_id:
31 halyavin 1293
	mov	eax,2
157 heavyiron 1294
	ret
1295
      get_org_origin_id:
31 halyavin 1296
	mov	eax,3
157 heavyiron 1297
	ret
1298
      get_predefined_id:
31 halyavin 1299
	cmp	ecx,2
157 heavyiron 1300
	ja	find_label
1301
	inc	esi
1302
	cmp	cl,1
1303
	je	get_counter_id
1304
	lods	byte [esi]
1305
	mov	ebx,characters
1306
	xlat	[ebx]
1307
	cmp	al,'t'
1308
	je	get_timestamp_id
1309
	sub	esi,2
1310
      find_label:
31 halyavin 1311
	xor	ebx,ebx
157 heavyiron 1312
	mov	eax,2166136261
1313
	mov	ebp,16777619
1314
      hash_label:
31 halyavin 1315
	xor	al,[esi+ebx]
157 heavyiron 1316
	mul	ebp
1317
	inc	bl
1318
	cmp	bl,cl
1319
	jb	hash_label
1320
	mov	ebp,eax
1321
	shl	eax,8
1322
	and	ebp,0FFh shl 24
1323
	xor	ebp,eax
1324
	or	ebp,ebx
1325
	mov	[label_hash],ebp
1326
	push	edi esi
1327
	push	ecx
1328
	mov	ecx,32
1329
	mov	ebx,hash_tree
1330
      follow_tree:
31 halyavin 1331
	mov	edx,[ebx]
157 heavyiron 1332
	or	edx,edx
1333
	jz	extend_tree
1334
	xor	eax,eax
1335
	shl	ebp,1
1336
	adc	eax,0
1337
	lea	ebx,[edx+eax*4]
1338
	dec	ecx
1339
	jnz	follow_tree
1340
	mov	[label_leaf],ebx
1341
	pop	edx
1342
	mov	eax,[ebx]
1343
	or	eax,eax
1344
	jz	add_label
1345
	mov	ebx,esi
1346
	mov	ebp,[label_hash]
1347
      compare_labels:
31 halyavin 1348
	mov	esi,ebx
157 heavyiron 1349
	mov	ecx,edx
1350
	mov	edi,[eax+4]
1351
	mov	edi,[edi+24]
1352
	repe	cmps byte [esi],[edi]
1353
	je	label_found
1354
	mov	eax,[eax]
1355
	or	eax,eax
1356
	jnz	compare_labels
1357
	jmp	add_label
1358
      label_found:
31 halyavin 1359
	add	esp,4
157 heavyiron 1360
	pop	edi
1361
	mov	eax,[eax+4]
1362
	ret
1363
      extend_tree:
31 halyavin 1364
	mov	edx,[free_additional_memory]
157 heavyiron 1365
	lea	eax,[edx+8]
1366
	cmp	eax,[additional_memory_end]
1367
	ja	out_of_memory
1368
	mov	[free_additional_memory],eax
1369
	xor	eax,eax
1370
	mov	[edx],eax
1371
	mov	[edx+4],eax
1372
	shl	ebp,1
1373
	adc	eax,0
1374
	mov	[ebx],edx
1375
	lea	ebx,[edx+eax*4]
1376
	dec	ecx
1377
	jnz	extend_tree
1378
	mov	[label_leaf],ebx
1379
	pop	edx
1380
      add_label:
31 halyavin 1381
	mov	ecx,edx
157 heavyiron 1382
	pop	esi
1383
	cmp	byte [esi-2],0
1384
	je	label_name_ok
1385
	mov	al,[esi]
1386
	cmp	al,30h
1387
	jb	name_first_char_ok
1388
	cmp	al,39h
1389
	jbe	numeric_name
6467 dunkaist 1390
      name_first_char_ok:
31 halyavin 1391
	cmp	al,'$'
340 heavyiron 1392
	jne	check_for_reserved_word
1393
      numeric_name:
6467 dunkaist 1394
	add	esi,ecx
1395
      reserved_word:
340 heavyiron 1396
	mov	eax,0Fh
1397
	pop	edi
1398
	ret
1399
      check_for_reserved_word:
31 halyavin 1400
	call	get_instruction
157 heavyiron 1401
	jnc	reserved_word
1402
	call	get_data_directive
1403
	jnc	reserved_word
1404
	call	get_symbol
1405
	jnc	reserved_word
1406
	sub	esi,2
1407
	mov	edi,operators
1408
	call	get_operator
1409
	or	al,al
1410
	jnz	reserved_word
1411
	mov	edi,single_operand_operators
1412
	call	get_operator
1413
	or	al,al
1414
	jnz	reserved_word
1415
	mov	edi,directive_operators
1416
	call	get_operator
1417
	or	al,al
1418
	jnz	reserved_word
1419
	inc	esi
1420
	movzx	ecx,byte [esi]
1421
	inc	esi
1422
      label_name_ok:
31 halyavin 1423
	mov	edx,[free_additional_memory]
157 heavyiron 1424
	lea	eax,[edx+8]
1425
	cmp	eax,[additional_memory_end]
1426
	ja	out_of_memory
1427
	mov	[free_additional_memory],eax
1428
	mov	ebx,esi
1429
	add	esi,ecx
1430
	mov	eax,[label_leaf]
1431
	mov	edi,[eax]
1432
	mov	[edx],edi
1433
	mov	[eax],edx
1434
	call	allocate_label
1435
	mov	[edx+4],eax
1436
	mov	[eax+24],ebx
1437
	pop	edi
1438
	ret
1439
      allocate_label:
109 heavyiron 1440
	mov	eax,[labels_list]
157 heavyiron 1441
	mov	ecx,LABEL_STRUCTURE_SIZE shr 2
1442
      initialize_label:
109 heavyiron 1443
	sub	eax,4
157 heavyiron 1444
	mov	dword [eax],0
1445
	loop	initialize_label
1446
	mov	[labels_list],eax
1447
	ret
1448
31 halyavin 1449
 
109 heavyiron 1450
>