Subversion Repositories Kolibri OS

Rev

Rev 2665 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

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