Subversion Repositories Kolibri OS

Rev

Rev 220 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

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