flat assembler, the next generation

Check-in [405f908cac]
Login
Overview
Comment:Reduced memory usage of LOCAL-less macros
Timelines: family | ancestors | descendants | both | lowmem
Files: files | file ages | folders
SHA1:405f908cacc71e3e24e141f6a2846f3f8a55a9ec
User & Date: Tomasz on 2017-09-22 20:08:20
Other Links: manifest | tags
Context
2017-09-24
11:19
minor cleanup check-in: 9a42b486ec user: Tomasz tags: lowmem
2017-09-22
20:08
Reduced memory usage of LOCAL-less macros check-in: 405f908cac user: Tomasz tags: lowmem
2017-09-19
08:37
minor rearrangements and corrections check-in: d7f8ec884e user: Tomasz tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Modified source/assembler.inc from [ef7d32dc8f] to [6ba27cbd0b].

16
17
18
19
20
21
22

23
24
25
26
27
28
29
...
128
129
130
131
132
133
134

135
136
137
138
139
140
141
...
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
...
943
944
945
946
947
948
949
950



951
952
953
954



























































955
956
957
958
959
960
961
...
967
968
969
970
971
972
973


974
975
976
977
978
979
980
...
986
987
988
989
990
991
992
993
994
995
996

997
998
999
1000
1001







1002















1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
....
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
....
1121
1122
1123
1124
1125
1126
1127

1128

1129
1130
1131
1132
1133
1134
1135
....
1146
1147
1148
1149
1150
1151
1152

1153
1154
1155
1156
1157
1158
1159
1160
....
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250

1251
1252
1253
1254
1255
1256
1257
....
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
	name dd ?
	name_length dd ?
	text dd ?
	offset dd ?
	line_number dd ?
	number_of_attached_lines dd ?
	line_offset dd ?

	local_namespace dd ?
ends

struct RecognitionContext
	base_namespace dd ?
	current_label dd ?
ends
................................................................................
	mov	[storage_blocks],eax
	mov	[storage_free_space_length],eax
	mov	[tree_blocks],eax
	mov	[tree_reserve_length],eax
	mov	[value_definition_chain],eax
	mov	[retired_definition],eax
	mov	[global_parameter_length_maximum],eax


	mov	cl,10
	call	create_string_map
	mov	[file_source_cache],ebx

	mov	cl,12
	call	create_string_map
................................................................................
	pop	ebx
	test	eax,eax
	jz	main_source_file_not_found
	mov	[ebx+SourceEntry.type],SOURCE_FILE
      fill_main_source_entry:
	mov	[ebx+SourceEntry.name],esi
	mov	[ebx+SourceEntry.text],eax
	mov	edx,[global_parameter_namespace]
	mov	eax,[edx+SymbolTree_Root.next]
	test	eax,eax
	jnz	local_parameter_namespace_ok
	call	create_parameter_namespace
	mov	[edx+SymbolTree_Root.next],eax
      local_parameter_namespace_ok:
	mov	[local_parameter_namespace],eax
	mov	[ebx+SourceEntry.local_namespace],eax
	mov	ebx,[source_context]
	inc	[ebx+SourceContext.number_of_entries]
	mov	esi,zero_value
	mov	ecx,4+4
	call	create_output_area
	mov	[current_area],edx
	inc	[edx+ValueDefinition.reference_count]
................................................................................
    source_context_full:
	stc
	retn

create_parameter_namespace:
; out:
;  eax - SymbolTree_Root
; preserves: ebx, edx, esi, edi



	mov	ecx,sizeof.SymbolTree_Root + sizeof.SymbolTree_LocalNode
	call	create_tree_element
	or	[eax+SymbolTree_Root.attributes],SYMTREE_LOCAL
	or	[eax+SymbolTree_Root.flags],NAMESPACE_UNATTACHED



























































	retn

clone_source_context:
; in:
;  esi - SourceContext
;  edi - buffer
; out:
................................................................................
	assert	sizeof.SourceContext and 11b = 0
	mov	ecx,sizeof.SourceContext shr 2
	rep	movsd
	test	eax,eax
	jnz	clone_source_entry
	retn
    clone_source_entry:


	cmp	[esi+SourceEntry.type],SOURCE_MACRO
	jne	copy_source_entry
	mov	edx,[esi+SourceEntry.text]
	inc	[edx+ValueDefinition.reference_count]
	cmp	[source_context_affected],0
	je	copy_source_entry
	or	[edx+ValueDefinition.flags],VAL_IN_USE
................................................................................
	jnz	clone_source_entry
	retn

release_source_context:
; in:
;  eax - SourceContext
; preserves: eax, ebx, esi, edi
	cmp	eax,[source_context]
	sete	[source_context_affected]
	push	eax
	mov	ecx,[eax+SourceContext.number_of_entries]

	add	eax,sizeof.SourceContext
	test	ecx,ecx
	jnz	release_source_entry
	pop	eax
	retn







    release_source_entry:















	cmp	[eax+SourceEntry.type],SOURCE_MACRO
	jne	source_entry_released
	mov	edx,[eax+SourceEntry.text]
	dec	[edx+ValueDefinition.reference_count]
	cmp	[source_context_affected],0
	je	source_entry_released
	and	[edx+ValueDefinition.flags],not VAL_IN_USE
      source_entry_released:
	add	eax,sizeof.SourceEntry
	loop	release_source_entry
	pop	eax
	retn

get_file_source_entry:
; out:
;  ebx - SourceEntry in the main SourceContext
; preserves: edx, esi, edi
	mov	ebx,[source_context]
................................................................................
	imul	eax,sizeof.SourceEntry
	lea	ebx,[ebx+sizeof.SourceContext+eax]
	xor	eax,eax
	mov	[preprocessed_context],eax
	xchg	eax,[ebx+SourceEntry.number_of_attached_lines]
	inc	eax
	add	[ebx+SourceEntry.line_number],eax
	mov	eax,[ebx+SourceEntry.local_namespace]
	mov	[parameter_namespace],eax
	test	[eax+SymbolTree_Root.flags],NAMESPACE_UNATTACHED
	jz	local_namespace_ok
	xor	eax,eax
    local_namespace_ok:
	mov	[local_namespace],eax
	cmp	[ebx+SourceEntry.type],SOURCE_MACRO
	je	get_line_from_macro
	mov	esi,[ebx+SourceEntry.text]
	mov	eax,[ebx+SourceEntry.offset]
	add	esi,eax
	mov	[ebx+SourceEntry.line_offset],eax
................................................................................
	mov	[line_start],esi
	xor	eax,eax
	mov	[line_context],eax
	mov	[embedded_context],eax
      ; clc
	retn
    source_ended:

	mov	ebx,[source_context]

	dec	[ebx+SourceContext.number_of_entries]
	jnz	get_line
	cmp	[ebx+sizeof.SourceContext+SourceEntry.type],SOURCE_MEMORY
	jne	no_more_lines
	mov	esi,[source_file]
	test	esi,esi
	jz	no_more_lines
................................................................................
	mov	ebx,[source_context]
	inc	[ebx+SourceContext.number_of_entries]
	add	ebx,sizeof.SourceContext
	mov	[ebx+SourceEntry.type],SOURCE_FILE
	mov	[ebx+SourceEntry.name],esi
	mov	[ebx+SourceEntry.text],eax
	mov	eax,[parameter_namespace]

	mov	[ebx+SourceEntry.local_namespace],eax
	jmp	get_line
    no_more_lines:
	stc
	retn
    get_line_from_macro:
	mov	edx,[ebx+SourceEntry.text]
	mov	esi,[edx+ValueDefinition.value]
................................................................................
	jmp	name_symbol_reproduced
    macro_line_ended:
	mov	edx,[ebx+SourceEntry.text]
	sub	esi,[edx+ValueDefinition.value]
	mov	[ebx+SourceEntry.offset],esi
	jmp	got_line
    macro_ended:
	mov	edx,[ebx+SourceEntry.text]
	and	[edx+ValueDefinition.flags],not VAL_IN_USE
	dec	[edx+ValueDefinition.reference_count]
	mov	ebx,[source_context]

	dec	[ebx+SourceContext.number_of_entries]
	jnz	get_line
	stc
	retn
    preprocess_symbol:
	mov	eax,edi
	sub	eax,[preprocessing_workspace.memory_start]
................................................................................
	xor	edx,edx
	call	move_to_next_symbol
	jnc	namespaces_ok
	retn
    use_current_namespace:
	mov	eax,[current_namespace]
	mov	[recognition_context.base_namespace],eax
	mov	edx,[local_namespace]
	test	edx,edx
	jz	no_structure_label
	mov	edx,[edx+SymbolTree_Root.current_label]
	test	edx,edx
	jz	no_structure_label
	mov	[recognition_context.current_label],edx
	jmp	namespaces_ok







>







 







>







 







<
<
<
<

|
<
|
|







 







|
>
>
>




>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







>
>







 







<
<
|

>


|
|

>
>
>
>
>
>
>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>




|
|


<
<
<







 







|

<
<
<
|







 







>

>







 







>
|







 







|
<
<

>







 







|







16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
...
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
...
586
587
588
589
590
591
592




593
594

595
596
597
598
599
600
601
602
603
...
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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
....
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
....
1047
1048
1049
1050
1051
1052
1053


1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092



1093
1094
1095
1096
1097
1098
1099
....
1117
1118
1119
1120
1121
1122
1123
1124
1125



1126
1127
1128
1129
1130
1131
1132
1133
....
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
....
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
....
1319
1320
1321
1322
1323
1324
1325
1326


1327
1328
1329
1330
1331
1332
1333
1334
1335
....
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
	name dd ?
	name_length dd ?
	text dd ?
	offset dd ?
	line_number dd ?
	number_of_attached_lines dd ?
	line_offset dd ?
	parameter_namespace dd ?
	local_namespace dd ?
ends

struct RecognitionContext
	base_namespace dd ?
	current_label dd ?
ends
................................................................................
	mov	[storage_blocks],eax
	mov	[storage_free_space_length],eax
	mov	[tree_blocks],eax
	mov	[tree_reserve_length],eax
	mov	[value_definition_chain],eax
	mov	[retired_definition],eax
	mov	[global_parameter_length_maximum],eax
	mov	[parameter_namespace_pool],eax

	mov	cl,10
	call	create_string_map
	mov	[file_source_cache],ebx

	mov	cl,12
	call	create_string_map
................................................................................
	pop	ebx
	test	eax,eax
	jz	main_source_file_not_found
	mov	[ebx+SourceEntry.type],SOURCE_FILE
      fill_main_source_entry:
	mov	[ebx+SourceEntry.name],esi
	mov	[ebx+SourceEntry.text],eax




	call	create_parameter_namespace
	inc	[eax+SymbolTree_Root.reference_count]

	mov	[ebx+SourceEntry.parameter_namespace],eax
	and	[ebx+SourceEntry.local_namespace],0
	mov	ebx,[source_context]
	inc	[ebx+SourceContext.number_of_entries]
	mov	esi,zero_value
	mov	ecx,4+4
	call	create_output_area
	mov	[current_area],edx
	inc	[edx+ValueDefinition.reference_count]
................................................................................
    source_context_full:
	stc
	retn

create_parameter_namespace:
; out:
;  eax - SymbolTree_Root
; preserves: ebx, esi, edi
	mov	eax,[parameter_namespace_pool]
	test	eax,eax
	jnz	reuse_parameter_namespace
	mov	ecx,sizeof.SymbolTree_Root + sizeof.SymbolTree_LocalNode
	call	create_tree_element
	or	[eax+SymbolTree_Root.attributes],SYMTREE_LOCAL
	or	[eax+SymbolTree_Root.flags],NAMESPACE_UNATTACHED
	retn
    reuse_parameter_namespace:
	xor	edx,edx
	xchg	edx,[eax+SymbolTree_Root.reference_count]
	mov	[parameter_namespace_pool],edx
	push	eax ebx esi edi
	mov	ebx,eax
       ; test	 [ebx+SymbolTree_Root.attributes],SYMTREE_LOCAL
       ; jz	 internal_error
	xor	eax,eax
	mov	[ebx+SymbolTree_Root.current_label],eax
	add	ebx,sizeof.SymbolTree_Root
	mov	ecx,LOCAL_TREE_HEIGHT
    clear_node:
	mov	edi,ebx
	dec	cl
    clear_branch:
	cmp	dword [edi],0
	je	branch_cleared
	test	cl,cl
	jnz	clear_deeper_node
	mov	esi,[edi]
    clear_foliage:
	mov	eax,esi
	add	eax,sizeof.SymbolTree_Foliage
    clear_leaf:
	push	eax
	mov	eax,[eax+SymbolTree_Leaf.definition]
	test	eax,eax
	jz	clear_next_leaf
    deactivate_definition:
	and	[eax+ValueDefinition.pass],0
	mov	eax,[eax+ValueDefinition.previous]
	test	eax,eax
	jnz	deactivate_definition
    clear_next_leaf:
	pop	eax
	mov	eax,[eax+SymbolTree_Leaf.next]
	test	eax,eax
	jnz	clear_leaf
	mov	esi,[esi+SymbolTree_Foliage.next]
	test	esi,esi
	jnz	clear_foliage
    branch_cleared:
	add	edi,4
	lea	eax,[ebx+sizeof.SymbolTree_LocalNode]
	cmp	edi,eax
	jne	clear_branch
	inc	cl
	cmp	cl,LOCAL_TREE_HEIGHT
	je	tree_cleared
	pop	edi ebx
	jmp	branch_cleared
    clear_deeper_node:
	push	ebx edi
	mov	ebx,[edi]
	jmp	clear_node
    tree_cleared:
	pop	edi esi ebx eax
	retn

clone_source_context:
; in:
;  esi - SourceContext
;  edi - buffer
; out:
................................................................................
	assert	sizeof.SourceContext and 11b = 0
	mov	ecx,sizeof.SourceContext shr 2
	rep	movsd
	test	eax,eax
	jnz	clone_source_entry
	retn
    clone_source_entry:
	mov	edx,[esi+SourceEntry.parameter_namespace]
	inc	[edx+SymbolTree_Root.reference_count]
	cmp	[esi+SourceEntry.type],SOURCE_MACRO
	jne	copy_source_entry
	mov	edx,[esi+SourceEntry.text]
	inc	[edx+ValueDefinition.reference_count]
	cmp	[source_context_affected],0
	je	copy_source_entry
	or	[edx+ValueDefinition.flags],VAL_IN_USE
................................................................................
	jnz	clone_source_entry
	retn

release_source_context:
; in:
;  eax - SourceContext
; preserves: eax, ebx, esi, edi


	push	eax ebx
	mov	ecx,[eax+SourceContext.number_of_entries]
	mov	ebx,eax
	add	eax,sizeof.SourceContext
	test	ecx,ecx
	jnz	release_source_entries
	pop	ebx eax
	retn
    release_source_entries:
	call	release_source_entry
	add	eax,sizeof.SourceEntry
	loop	release_source_entries
	pop	ebx eax
	retn

release_source_entry:
; in:
;  eax - SourceEntry
;  ebx - SourceContext
; preserves: eax, ebx, ecx, esi, edi
	mov	edx,[eax+SourceEntry.parameter_namespace]
	dec	[edx+SymbolTree_Root.reference_count]
	jnz	local_namespace_released
	test	[edx+SymbolTree_Root.flags],NAMESPACE_UNATTACHED
	jz	local_namespace_released
	push	eax
	mov	eax,[parameter_namespace_pool]
	mov	[edx+SymbolTree_Root.reference_count],eax
	mov	[parameter_namespace_pool],edx
	pop	eax
      local_namespace_released:
	cmp	[eax+SourceEntry.type],SOURCE_MACRO
	jne	source_entry_released
	mov	edx,[eax+SourceEntry.text]
	dec	[edx+ValueDefinition.reference_count]
	cmp	ebx,[source_context]
	jne	source_entry_released
	and	[edx+ValueDefinition.flags],not VAL_IN_USE
      source_entry_released:



	retn

get_file_source_entry:
; out:
;  ebx - SourceEntry in the main SourceContext
; preserves: edx, esi, edi
	mov	ebx,[source_context]
................................................................................
	imul	eax,sizeof.SourceEntry
	lea	ebx,[ebx+sizeof.SourceContext+eax]
	xor	eax,eax
	mov	[preprocessed_context],eax
	xchg	eax,[ebx+SourceEntry.number_of_attached_lines]
	inc	eax
	add	[ebx+SourceEntry.line_number],eax
	mov	eax,[ebx+SourceEntry.parameter_namespace]
	mov	[parameter_namespace],eax



	mov	eax,[ebx+SourceEntry.local_namespace]
	mov	[local_namespace],eax
	cmp	[ebx+SourceEntry.type],SOURCE_MACRO
	je	get_line_from_macro
	mov	esi,[ebx+SourceEntry.text]
	mov	eax,[ebx+SourceEntry.offset]
	add	esi,eax
	mov	[ebx+SourceEntry.line_offset],eax
................................................................................
	mov	[line_start],esi
	xor	eax,eax
	mov	[line_context],eax
	mov	[embedded_context],eax
      ; clc
	retn
    source_ended:
	mov	eax,ebx
	mov	ebx,[source_context]
	call	release_source_entry
	dec	[ebx+SourceContext.number_of_entries]
	jnz	get_line
	cmp	[ebx+sizeof.SourceContext+SourceEntry.type],SOURCE_MEMORY
	jne	no_more_lines
	mov	esi,[source_file]
	test	esi,esi
	jz	no_more_lines
................................................................................
	mov	ebx,[source_context]
	inc	[ebx+SourceContext.number_of_entries]
	add	ebx,sizeof.SourceContext
	mov	[ebx+SourceEntry.type],SOURCE_FILE
	mov	[ebx+SourceEntry.name],esi
	mov	[ebx+SourceEntry.text],eax
	mov	eax,[parameter_namespace]
	mov	[ebx+SourceEntry.parameter_namespace],eax
	and	[ebx+SourceEntry.local_namespace],0
	jmp	get_line
    no_more_lines:
	stc
	retn
    get_line_from_macro:
	mov	edx,[ebx+SourceEntry.text]
	mov	esi,[edx+ValueDefinition.value]
................................................................................
	jmp	name_symbol_reproduced
    macro_line_ended:
	mov	edx,[ebx+SourceEntry.text]
	sub	esi,[edx+ValueDefinition.value]
	mov	[ebx+SourceEntry.offset],esi
	jmp	got_line
    macro_ended:
	mov	eax,ebx


	mov	ebx,[source_context]
	call	release_source_entry
	dec	[ebx+SourceContext.number_of_entries]
	jnz	get_line
	stc
	retn
    preprocess_symbol:
	mov	eax,edi
	sub	eax,[preprocessing_workspace.memory_start]
................................................................................
	xor	edx,edx
	call	move_to_next_symbol
	jnc	namespaces_ok
	retn
    use_current_namespace:
	mov	eax,[current_namespace]
	mov	[recognition_context.base_namespace],eax
	mov	edx,[parameter_namespace]
	test	edx,edx
	jz	no_structure_label
	mov	edx,[edx+SymbolTree_Root.current_label]
	test	edx,edx
	jz	no_structure_label
	mov	[recognition_context.current_label],edx
	jmp	namespaces_ok

Modified source/directives.inc from [cb66b11b44] to [246ac57a20].

721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
....
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
....
1169
1170
1171
1172
1173
1174
1175



1176
1177
1178
1179
1180
1181
1182
....
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403

3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
....
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
....
3602
3603
3604
3605
3606
3607
3608
3609

3610
3611
3612
3613
3614
3615
3616
3617
3618
....
3659
3660
3661
3662
3663
3664
3665







3666









































3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
	rep	movsd
	retn
      context_reset_token:
	add	esi,sizeof.RecognitionContext
      store_current_context:
	mov	eax,[current_namespace]
	mov	[edi+RecognitionContext.base_namespace],eax
	mov	ecx,[local_namespace]
	jecxz	context_with_no_structure_label
	mov	ecx,[ecx+SymbolTree_Root.current_label]
	jecxz	context_with_no_structure_label
	mov	[edi+RecognitionContext.current_label],ecx
	add	edi,sizeof.RecognitionContext
	retn
      context_with_no_structure_label:
................................................................................
    include_read:
	mov	edx,eax
	call	create_source_entry
	jc	include_stack_limit_exceeded
	mov	[ebx+SourceEntry.type],SOURCE_FILE
	mov	[ebx+SourceEntry.name],esi
	mov	[ebx+SourceEntry.text],edx
	mov	edx,[local_parameter_namespace]
	mov	eax,[edx+SymbolTree_Root.next]
	test	eax,eax
	jnz	new_parameter_namespace_ok
	call	create_parameter_namespace
	mov	[edx+SymbolTree_Root.next],eax
      new_parameter_namespace_ok:
	mov	[ebx+SourceEntry.local_namespace],eax
	pop	esi
	jmp	instruction_assembled
    include_stack_limit_exceeded:
	pop	esi
    stack_limit_exceeded:
	mov	edx,_stack_limit_exceeded
	call	register_error
................................................................................
	mov	edx,eax
	call	create_source_entry
	jc	include_stack_limit_exceeded
	mov	[ebx+SourceEntry.type],SOURCE_MEMORY
	mov	[ebx+SourceEntry.name],esi
	mov	[ebx+SourceEntry.text],edx
	mov	eax,[parameter_namespace]



	mov	[ebx+SourceEntry.local_namespace],eax
	pop	esi
	jmp	instruction_assembled

assert_condition:
	call	get_condition_value
	test	al,al
................................................................................
	lodsd
	add	esi,eax
	jmp	measure_macro_header
    macro_header_measured:
	mov	[instruction_body],esi
	dec	esi
	mov	[line_end],esi
	mov	eax,ebx
	push	eax
	xor	ebx,ebx
	xor	ecx,ecx
	mov	dl,SYMCLASS_PARAMETER
	call	get_abstract_symbol
	mov	edx,[ebx+SymbolTree_Leaf.definition]
	test	edx,edx
	jz	create_namespace_counter
	mov	ecx,[current_pass]
	cmp	ecx,[edx+ValueDefinition.pass]
	je	create_local_namespace
	mov	[edx+ValueDefinition.pass],ecx
	and	[edx+ValueDefinition.value],0
	jmp	create_local_namespace
    create_namespace_counter:
	mov	ecx,sizeof.ValueDefinition
	call	create_tree_element
	jc	out_of_memory
	mov	[ebx+SymbolTree_Leaf.definition],eax
	mov	edx,eax
	inc	[edx+ValueDefinition.reference_count]
	mov	[edx+ValueDefinition.type],VALTYPE_PLAIN
	mov	ecx,[current_pass]
	mov	[edx+ValueDefinition.pass],ecx
    create_local_namespace:
	inc	[edx+ValueDefinition.value]
	mov	ecx,[edx+ValueDefinition.value]
	pop	eax
	xor	ebx,ebx
	mov	dl,SYMCLASS_PARAMETER
	call	get_abstract_symbol
	call	get_local_namespace
	mov	[new_local_namespace],ebx

	mov	edx,[instruction_value]
    local_namespace_ready:
	mov	esi,[edx+ValueDefinition.value]
	or	[symbol_definition],1
	mov	ebx,[new_local_namespace]
	mov	eax,[label_branch]
	mov	[ebx+SymbolTree_Root.current_label],eax
	cmp	byte [esi],'('
	jne	prepare_macro_parameters
	inc	esi
	mov	ebx,[new_local_namespace]
	mov	dl,SYMCLASS_PARAMETER
	call	identify_symbol_in_namespace
	jc	invalid_argument
	test	ebx,ebx
	jz	invalid_argument
	cmp	edi,[new_local_namespace]
	jne	invalid_argument
	push	esi
	push	[line_end] [embedded_context]
	mov	eax,[line_context]
	mov	[embedded_context],eax
	mov	esi,[line_start]
	mov	eax,[label_instruction_start]
................................................................................
    prepare_macro_parameters:
	mov	edi,[expression_workspace.memory_start]
	add	edi,sizeof.LineExcerpt
	xor	eax,eax
	mov	[macro_greedy],al
	mov	[number_of_parameters],eax
    macro_parameter_declaration:
	mov	ebx,[new_local_namespace]
	mov	dl,SYMCLASS_PARAMETER
	push	edi
	call	identify_symbol_in_namespace
	mov	eax,edi
	pop	edi
	jc	macro_parameters_declared
	test	ebx,ebx
	jz	invalid_argument
	cmp	eax,[new_local_namespace]
	jne	invalid_argument
	mov	eax,[number_of_parameters]
	shl	eax,2
	add	eax,[assembly_stack_base]
	lea	ecx,[eax+4]
	cmp	ecx,[assembly_stack_end]
	jbe	store_macro_parameter_leaf
................................................................................
	pop	eax
	jc	stack_limit_exceeded
	mov	[ebx+SourceEntry.type],SOURCE_MACRO
	mov	[ebx+SourceEntry.text],edx
	mov	[ebx+SourceEntry.offset],eax
	or	[edx+ValueDefinition.flags],VAL_IN_USE
	inc	[edx+ValueDefinition.reference_count]
	mov	eax,[new_local_namespace]

	mov	[local_namespace],eax
	mov	[ebx+SourceEntry.local_namespace],eax
	mov	ecx,[instruction_branch]
	test	ecx,ecx
	jz	instruction_assembled
	mov	eax,[ecx+SymbolTree_Foliage.name_data]
	mov	[ebx+SourceEntry.name],eax
	mov	eax,[ecx+SymbolTree_Foliage.name_length]
	mov	[ebx+SourceEntry.name_length],eax
................................................................................
local_directive:
	test	[assembly_mode],AMODE_SKIP
	jnz	assembly_line
	test	[assembly_mode],AMODE_DEFINITION
	jnz	add_line_to_macro
	mov	ebx,[local_namespace]
	test	ebx,ebx







	jz	unexpected_instruction









































	or	[symbol_definition],1
	mov	dl,SYMCLASS_PARAMETER
	call	identify_symbol_in_namespace
	jc	missing_argument
	test	ebx,ebx
	jz	invalid_argument
	cmp	edi,[local_namespace]
	jne	invalid_argument
	or	[ebx+SymbolTree_Leaf.flags],SYM_VARIABLE
	call	update_value_definition
	mov	eax,[current_pass]
	mov	[edx+ValueDefinition.pass],eax
	mov	[edx+ValueDefinition.type],VALTYPE_NATIVE_COMMAND
	mov	eax,local_symbol_name







|







 







<
<
<
<

|
|
|







 







>
>
>







 







<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
>

<


|





|





|







 







|








|







 







|
>
|
|







 







>
>
>
>
>
>
>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>






|







721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
....
1054
1055
1056
1057
1058
1059
1060




1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
....
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
....
3362
3363
3364
3365
3366
3367
3368

















3369
















3370
3371

3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
....
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
....
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
....
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
	rep	movsd
	retn
      context_reset_token:
	add	esi,sizeof.RecognitionContext
      store_current_context:
	mov	eax,[current_namespace]
	mov	[edi+RecognitionContext.base_namespace],eax
	mov	ecx,[parameter_namespace]
	jecxz	context_with_no_structure_label
	mov	ecx,[ecx+SymbolTree_Root.current_label]
	jecxz	context_with_no_structure_label
	mov	[edi+RecognitionContext.current_label],ecx
	add	edi,sizeof.RecognitionContext
	retn
      context_with_no_structure_label:
................................................................................
    include_read:
	mov	edx,eax
	call	create_source_entry
	jc	include_stack_limit_exceeded
	mov	[ebx+SourceEntry.type],SOURCE_FILE
	mov	[ebx+SourceEntry.name],esi
	mov	[ebx+SourceEntry.text],edx




	call	create_parameter_namespace
	inc	[eax+SymbolTree_Root.reference_count]
	mov	[ebx+SourceEntry.parameter_namespace],eax
	and	[ebx+SourceEntry.local_namespace],0
	pop	esi
	jmp	instruction_assembled
    include_stack_limit_exceeded:
	pop	esi
    stack_limit_exceeded:
	mov	edx,_stack_limit_exceeded
	call	register_error
................................................................................
	mov	edx,eax
	call	create_source_entry
	jc	include_stack_limit_exceeded
	mov	[ebx+SourceEntry.type],SOURCE_MEMORY
	mov	[ebx+SourceEntry.name],esi
	mov	[ebx+SourceEntry.text],edx
	mov	eax,[parameter_namespace]
	inc	[eax+SymbolTree_Root.reference_count]
	mov	[ebx+SourceEntry.parameter_namespace],eax
	mov	eax,[local_namespace]
	mov	[ebx+SourceEntry.local_namespace],eax
	pop	esi
	jmp	instruction_assembled

assert_condition:
	call	get_condition_value
	test	al,al
................................................................................
	lodsd
	add	esi,eax
	jmp	measure_macro_header
    macro_header_measured:
	mov	[instruction_body],esi
	dec	esi
	mov	[line_end],esi

















	call	create_parameter_namespace
















	mov	[new_parameter_namespace],eax
	mov	edx,[instruction_value]

	mov	esi,[edx+ValueDefinition.value]
	or	[symbol_definition],1
	mov	ebx,[new_parameter_namespace]
	mov	eax,[label_branch]
	mov	[ebx+SymbolTree_Root.current_label],eax
	cmp	byte [esi],'('
	jne	prepare_macro_parameters
	inc	esi
	mov	ebx,[new_parameter_namespace]
	mov	dl,SYMCLASS_PARAMETER
	call	identify_symbol_in_namespace
	jc	invalid_argument
	test	ebx,ebx
	jz	invalid_argument
	cmp	edi,[new_parameter_namespace]
	jne	invalid_argument
	push	esi
	push	[line_end] [embedded_context]
	mov	eax,[line_context]
	mov	[embedded_context],eax
	mov	esi,[line_start]
	mov	eax,[label_instruction_start]
................................................................................
    prepare_macro_parameters:
	mov	edi,[expression_workspace.memory_start]
	add	edi,sizeof.LineExcerpt
	xor	eax,eax
	mov	[macro_greedy],al
	mov	[number_of_parameters],eax
    macro_parameter_declaration:
	mov	ebx,[new_parameter_namespace]
	mov	dl,SYMCLASS_PARAMETER
	push	edi
	call	identify_symbol_in_namespace
	mov	eax,edi
	pop	edi
	jc	macro_parameters_declared
	test	ebx,ebx
	jz	invalid_argument
	cmp	eax,[new_parameter_namespace]
	jne	invalid_argument
	mov	eax,[number_of_parameters]
	shl	eax,2
	add	eax,[assembly_stack_base]
	lea	ecx,[eax+4]
	cmp	ecx,[assembly_stack_end]
	jbe	store_macro_parameter_leaf
................................................................................
	pop	eax
	jc	stack_limit_exceeded
	mov	[ebx+SourceEntry.type],SOURCE_MACRO
	mov	[ebx+SourceEntry.text],edx
	mov	[ebx+SourceEntry.offset],eax
	or	[edx+ValueDefinition.flags],VAL_IN_USE
	inc	[edx+ValueDefinition.reference_count]
	mov	eax,[new_parameter_namespace]
	inc	[eax+SymbolTree_Root.reference_count]
	mov	[ebx+SourceEntry.parameter_namespace],eax
	and	[ebx+SourceEntry.local_namespace],0
	mov	ecx,[instruction_branch]
	test	ecx,ecx
	jz	instruction_assembled
	mov	eax,[ecx+SymbolTree_Foliage.name_data]
	mov	[ebx+SourceEntry.name],eax
	mov	eax,[ecx+SymbolTree_Foliage.name_length]
	mov	[ebx+SourceEntry.name_length],eax
................................................................................
local_directive:
	test	[assembly_mode],AMODE_SKIP
	jnz	assembly_line
	test	[assembly_mode],AMODE_DEFINITION
	jnz	add_line_to_macro
	mov	ebx,[local_namespace]
	test	ebx,ebx
	jnz	define_local_symbol
	mov	ebx,[source_context]
	mov	eax,[ebx+SourceContext.number_of_entries]
	dec	eax
	imul	eax,sizeof.SourceEntry
	lea	ebx,[ebx+sizeof.SourceContext+eax]
	cmp	[ebx+SourceEntry.type],SOURCE_MACRO
	jne	illegal_instruction
	push	esi
	push	ebx
	mov	eax,[ebx+SourceEntry.name]
	push	eax
	xor	ebx,ebx
	xor	ecx,ecx
	mov	dl,SYMCLASS_PARAMETER
	call	get_abstract_symbol
	mov	edx,[ebx+SymbolTree_Leaf.definition]
	test	edx,edx
	jz	create_namespace_counter
	mov	ecx,[current_pass]
	cmp	ecx,[edx+ValueDefinition.pass]
	je	create_local_namespace
	mov	[edx+ValueDefinition.pass],ecx
	and	[edx+ValueDefinition.value],0
	jmp	create_local_namespace
    create_namespace_counter:
	mov	ecx,sizeof.ValueDefinition
	call	create_tree_element
	jc	out_of_memory
	mov	[ebx+SymbolTree_Leaf.definition],eax
	mov	edx,eax
	inc	[edx+ValueDefinition.reference_count]
	mov	[edx+ValueDefinition.type],VALTYPE_PLAIN
	mov	ecx,[current_pass]
	mov	[edx+ValueDefinition.pass],ecx
    create_local_namespace:
	inc	[edx+ValueDefinition.value]
	mov	ecx,[edx+ValueDefinition.value]
	pop	eax
	xor	ebx,ebx
	mov	dl,SYMCLASS_PARAMETER
	call	get_abstract_symbol
	call	get_local_namespace
	mov	[local_namespace],ebx
	pop	eax
	mov	[eax+SourceEntry.local_namespace],ebx
	pop	esi
    define_local_symbol:
	mov	ebx,[parameter_namespace]
	or	[symbol_definition],1
	mov	dl,SYMCLASS_PARAMETER
	call	identify_symbol_in_namespace
	jc	missing_argument
	test	ebx,ebx
	jz	invalid_argument
	cmp	edi,[parameter_namespace]
	jne	invalid_argument
	or	[ebx+SymbolTree_Leaf.flags],SYM_VARIABLE
	call	update_value_definition
	mov	eax,[current_pass]
	mov	[edx+ValueDefinition.pass],eax
	mov	[edx+ValueDefinition.type],VALTYPE_NATIVE_COMMAND
	mov	eax,local_symbol_name

Modified source/symbols.inc from [9a3954f0a5] to [43d763de11].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15

struct SymbolTree_Root
	attributes db ? 		 ; SYMTREE_#
	flags db ?			 ; NAMESPACE_#
	reserved dw ?
	parent_branch dd ?		 ; pointer to namespace SymbolTree_Foliage
	current_label dd ?		 ; pointer to selected SymbolTree_Foliage
	next dd ?			 ; pointer to another SymbolTree_Root
      ; root_node SymbolTree_Node
ends

struct SymbolTree_Node
	branches rd 1 shl TREE_NODE_BITS
ends








|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15

struct SymbolTree_Root
	attributes db ? 		 ; SYMTREE_#
	flags db ?			 ; NAMESPACE_#
	reserved dw ?
	parent_branch dd ?		 ; pointer to namespace SymbolTree_Foliage
	current_label dd ?		 ; pointer to selected SymbolTree_Foliage
	reference_count dd ?
      ; root_node SymbolTree_Node
ends

struct SymbolTree_Node
	branches rd 1 shl TREE_NODE_BITS
ends

Modified source/variables.inc from [600590186e] to [f675d20628].

22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
...
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
file_source_cache dd ?
memory_source_cache dd ?
file_data_cache dd ?

operator_table dd ?
root_namespace dd ?
global_parameter_namespace dd ?
local_parameter_namespace dd ?
interceptor_symbol dd ?
label_interceptor_symbol dd ?
global_parameter_length_maximum dd ?
proxy_number dd ?

source_context dd ?
source_context_maximum_length dd ?
................................................................................
further_whitespace dd ?
zero_digits dd ?
decimal_places dd ?
literal_exponent dd ?
update_function dd ?
argument_start dd ?
macro_parameters_context dd ?
new_local_namespace dd ?
file_name dd ?
string_end dd ?
message_end dd ?
data_area_symbol dd ?
data_area dd ?
data_offset dd ?
file_offset dq ?







|







 







|







22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
...
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
file_source_cache dd ?
memory_source_cache dd ?
file_data_cache dd ?

operator_table dd ?
root_namespace dd ?
global_parameter_namespace dd ?
parameter_namespace_pool dd ?
interceptor_symbol dd ?
label_interceptor_symbol dd ?
global_parameter_length_maximum dd ?
proxy_number dd ?

source_context dd ?
source_context_maximum_length dd ?
................................................................................
further_whitespace dd ?
zero_digits dd ?
decimal_places dd ?
literal_exponent dd ?
update_function dd ?
argument_start dd ?
macro_parameters_context dd ?
new_parameter_namespace dd ?
file_name dd ?
string_end dd ?
message_end dd ?
data_area_symbol dd ?
data_area dd ?
data_offset dd ?
file_offset dq ?

Modified source/version.inc from [fcb207ffad] to [69c1b1625b].

1
VERSION equ "hxhsr"
|
1
VERSION equ "hxmfv"