Subversion Repositories Kolibri OS

Rev

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

Rev 157 Rev 174
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_relative_offset
620
	call	get_qword_value
-
 
621
	call	calculate_relative_offset
621
	neg	eax
622
	push	esi edi
622
	cmp	[next_pass_needed],0
623
	cmp	[next_pass_needed],0
623
	jne	load_address_ok
624
	jne	load_address_type_ok
624
	cmp	[value_type],0
625
	cmp	[value_type],0
625
	jne	invalid_use_of_symbol
626
	jne	invalid_use_of_symbol
626
      load_address_ok:
627
      load_address_type_ok:
627
	push	esi edi
628
	cmp	edx,-1
628
	mov	esi,edi
629
	jne	bad_load_address
-
 
630
	neg	eax
-
 
631
	mov	esi,edi
629
	sub	esi,eax
632
	sub	esi,eax
630
	jc	bad_load_address
633
	jc	bad_load_address
631
	cmp	esi,[org_start]
634
	cmp	esi,[org_start]
632
	jb	bad_load_address
635
	jb	bad_load_address
633
	mov	edi,value
636
	mov	edi,value
634
	movzx	ecx,[operand_size]
637
	movzx	ecx,[operand_size]
635
	cmp	ecx,eax
638
	cmp	ecx,eax
636
	ja	bad_load_address
639
	ja	bad_load_address
637
	rep	movs byte [edi],[esi]
640
	rep	movs byte [edi],[esi]
638
	jmp	value_loaded
641
	jmp	value_loaded
639
      bad_load_address:
642
      bad_load_address:
640
	cmp	[error_line],0
643
	cmp	[error_line],0
641
	jne	value_loaded
644
	jne	value_loaded
642
	mov	eax,[current_line]
645
	mov	eax,[current_line]
643
	mov	[error_line],eax
646
	mov	[error_line],eax
644
	mov	[error],value_out_of_range
647
	mov	[error],value_out_of_range
645
      value_loaded:
648
      value_loaded:
646
	pop	edi esi
649
	pop	edi esi
647
	mov	eax,dword [value]
650
	mov	eax,dword [value]
648
	mov	edx,dword [value+4]
651
	mov	edx,dword [value+4]
649
	pop	ebx
652
	pop	ebx
650
	xor	cx,cx
653
	xor	cx,cx
651
	jmp	make_constant
654
	jmp	make_constant
652
store_directive:
655
store_directive:
653
	cmp	byte [esi],11h
656
	cmp	byte [esi],11h
654
	je	sized_store
657
	je	sized_store
655
	lods	byte [esi]
658
	lods	byte [esi]
656
	cmp	al,'('
659
	cmp	al,'('
657
	jne	invalid_argument
660
	jne	invalid_argument
658
	call	get_byte_value
661
	call	get_byte_value
659
	xor	edx,edx
662
	xor	edx,edx
660
	movzx	eax,al
663
	movzx	eax,al
661
	mov	[operand_size],1
664
	mov	[operand_size],1
662
	jmp	store_value_ok
665
	jmp	store_value_ok
663
      sized_store:
666
      sized_store:
664
	call	get_value
667
	call	get_value
665
      store_value_ok:
668
      store_value_ok:
666
	cmp	[value_type],0
669
	cmp	[value_type],0
667
	jne	invalid_use_of_symbol
670
	jne	invalid_use_of_symbol
668
	mov	dword [value],eax
671
	mov	dword [value],eax
669
	mov	dword [value+4],edx
672
	mov	dword [value+4],edx
670
	lods	word [esi]
673
	lods	word [esi]
671
	cmp	ax,80h+'(' shl 8
674
	cmp	ax,80h+'(' shl 8
672
	jne	invalid_argument
675
	jne	invalid_argument
673
	cmp	byte [esi],'.'
676
	cmp	byte [esi],'.'
674
	je	invalid_value
677
	je	invalid_value
675
	call	get_relative_offset
678
	call	get_qword_value
-
 
679
	call	calculate_relative_offset
676
	neg	eax
680
	push	esi edi
677
	cmp	[next_pass_needed],0
681
	cmp	[next_pass_needed],0
678
	jne	store_address_ok
682
	jne	store_address_type_ok
679
	cmp	[value_type],0
683
	cmp	[value_type],0
680
	jne	invalid_use_of_symbol
684
	jne	invalid_use_of_symbol
681
      store_address_ok:
685
      store_address_type_ok:
682
	push	esi edi
686
	cmp	edx,-1
683
	sub	edi,eax
687
	jne	bad_store_address
-
 
688
	neg	eax
-
 
689
	sub	edi,eax
684
	jc	bad_store_address
690
	jc	bad_store_address
685
	cmp	edi,[org_start]
691
	cmp	edi,[org_start]
686
	jb	bad_store_address
692
	jb	bad_store_address
687
	mov	esi,value
693
	mov	esi,value
688
	movzx	ecx,[operand_size]
694
	movzx	ecx,[operand_size]
689
	cmp	ecx,eax
695
	cmp	ecx,eax
690
	ja	bad_store_address
696
	ja	bad_store_address
691
	rep	movs byte [edi],[esi]
697
	rep	movs byte [edi],[esi]
692
	mov	eax,edi
698
	mov	eax,edi
693
	pop	edi esi
699
	pop	edi esi
694
	cmp	edi,[undefined_data_end]
700
	cmp	edi,[undefined_data_end]
695
	jne	instruction_assembled
701
	jne	instruction_assembled
696
	cmp	eax,[undefined_data_start]
702
	cmp	eax,[undefined_data_start]
697
	jbe	instruction_assembled
703
	jbe	instruction_assembled
698
	mov	[undefined_data_start],eax
704
	mov	[undefined_data_start],eax
699
	jmp	instruction_assembled
705
	jmp	instruction_assembled
700
      bad_store_address:
706
      bad_store_address:
701
	pop	edi esi
707
	pop	edi esi
702
	cmp	[error_line],0
708
	cmp	[error_line],0
703
	jne	instruction_assembled
709
	jne	instruction_assembled
704
	mov	eax,[current_line]
710
	mov	eax,[current_line]
705
	mov	[error_line],eax
711
	mov	[error_line],eax
706
	mov	[error],value_out_of_range
712
	mov	[error],value_out_of_range
707
	jmp	instruction_assembled
713
	jmp	instruction_assembled
708
 
714
 
709
display_directive:
715
display_directive:
710
	lods	byte [esi]
716
	lods	byte [esi]
711
	cmp	al,'('
717
	cmp	al,'('
712
	jne	invalid_argument
718
	jne	invalid_argument
713
	cmp	byte [esi],0
719
	cmp	byte [esi],0
714
	jne	display_byte
720
	jne	display_byte
715
	inc	esi
721
	inc	esi
716
	lods	dword [esi]
722
	lods	dword [esi]
717
	mov	ecx,eax
723
	mov	ecx,eax
718
	push	edi
724
	push	edi
719
	mov	edi,[display_buffer]
725
	mov	edi,[display_buffer]
720
	sub	edi,4
726
	sub	edi,4
721
	sub	edi,eax
727
	sub	edi,eax
722
	mov	[display_buffer],edi
728
	mov	[display_buffer],edi
723
	rep	movs byte [edi],[esi]
729
	rep	movs byte [edi],[esi]
724
	stos	dword [edi]
730
	stos	dword [edi]
725
	pop	edi
731
	pop	edi
726
	inc	esi
732
	inc	esi
727
	jmp	display_next
733
	jmp	display_next
728
      display_byte:
734
      display_byte:
729
	call	get_byte_value
735
	call	get_byte_value
730
	push	edi
736
	push	edi
731
	mov	edi,[display_buffer]
737
	mov	edi,[display_buffer]
732
	sub	edi,4+1
738
	sub	edi,4+1
733
	mov	[display_buffer],edi
739
	mov	[display_buffer],edi
734
	stos	byte [edi]
740
	stos	byte [edi]
735
	mov	eax,1
741
	mov	eax,1
736
	stos	dword [edi]
742
	stos	dword [edi]
737
	pop	edi
743
	pop	edi
738
      display_next:
744
      display_next:
739
	cmp	edi,[display_buffer]
745
	cmp	edi,[display_buffer]
740
	ja	out_of_memory
746
	ja	out_of_memory
741
	lods	byte [esi]
747
	lods	byte [esi]
742
	cmp	al,','
748
	cmp	al,','
743
	je	display_directive
749
	je	display_directive
744
	dec	esi
750
	dec	esi
745
	jmp	instruction_assembled
751
	jmp	instruction_assembled
746
flush_display_buffer:
752
flush_display_buffer:
747
	mov	eax,[display_buffer]
753
	mov	eax,[display_buffer]
748
	or	eax,eax
754
	or	eax,eax
749
	jz	display_done
755
	jz	display_done
750
	mov	esi,[labels_list]
756
	mov	esi,[labels_list]
751
	cmp	esi,eax
757
	cmp	esi,eax
752
	je	display_done
758
	je	display_done
753
      display_messages:
759
      display_messages:
754
	sub	esi,4
760
	sub	esi,4
755
	mov	ecx,[esi]
761
	mov	ecx,[esi]
756
	sub	esi,ecx
762
	sub	esi,ecx
757
	push	esi
763
	push	esi
758
	call	display_block
764
	call	display_block
759
	pop	esi
765
	pop	esi
760
	cmp	esi,[display_buffer]
766
	cmp	esi,[display_buffer]
761
	jne	display_messages
767
	jne	display_messages
762
	mov	eax,[labels_list]
768
	mov	eax,[labels_list]
763
	mov	[display_buffer],eax
769
	mov	[display_buffer],eax
764
      display_done:
770
      display_done:
765
	ret
771
	ret
766
times_directive:
772
times_directive:
767
	lods	byte [esi]
773
	lods	byte [esi]
768
	cmp	al,'('
774
	cmp	al,'('
769
	jne	invalid_argument
775
	jne	invalid_argument
770
	cmp	byte [esi],'.'
776
	cmp	byte [esi],'.'
771
	je	invalid_value
777
	je	invalid_value
772
	call	get_dword_value
778
	call	get_dword_value
773
	cmp	[next_pass_needed],0
779
	cmp	[next_pass_needed],0
774
	jne	times_value_ok
780
	jne	times_value_ok
775
	cmp	[value_type],0
781
	cmp	[value_type],0
776
	jne	invalid_use_of_symbol
782
	jne	invalid_use_of_symbol
777
      times_value_ok:
783
      times_value_ok:
778
	cmp	eax,0
784
	cmp	eax,0
779
	je	zero_times
785
	je	zero_times
780
	jl	negative_times
786
	jl	negative_times
781
	cmp	byte [esi],':'
787
	cmp	byte [esi],':'
782
	jne	times_argument_ok
788
	jne	times_argument_ok
783
	inc	esi
789
	inc	esi
784
      times_argument_ok:
790
      times_argument_ok:
785
	push	[counter]
791
	push	[counter]
786
	push	[counter_limit]
792
	push	[counter_limit]
787
	mov	[counter_limit],eax
793
	mov	[counter_limit],eax
788
	mov	[counter],1
794
	mov	[counter],1
789
      times_loop:
795
      times_loop:
790
	mov	eax,esp
796
	mov	eax,esp
791
	sub	eax,100h
797
	sub	eax,100h
792
	jc	stack_overflow
798
	jc	stack_overflow
793
	cmp	eax,[stack_limit]
799
	cmp	eax,[stack_limit]
794
	jb	stack_overflow
800
	jb	stack_overflow
795
	push	esi
801
	push	esi
796
	or	[prefixed_instruction],-1
802
	or	[prefixed_instruction],-1
797
	call	continue_line
803
	call	continue_line
798
	mov	eax,[counter_limit]
804
	mov	eax,[counter_limit]
799
	cmp	[counter],eax
805
	cmp	[counter],eax
800
	je	times_done
806
	je	times_done
801
	inc	[counter]
807
	inc	[counter]
802
	pop	esi
808
	pop	esi
803
	jmp	times_loop
809
	jmp	times_loop
804
      times_done:
810
      times_done:
805
	pop	eax
811
	pop	eax
806
	pop	[counter_limit]
812
	pop	[counter_limit]
807
	pop	[counter]
813
	pop	[counter]
808
	jmp	instruction_assembled
814
	jmp	instruction_assembled
809
      negative_times:
815
      negative_times:
810
	cmp	[error_line],0
816
	cmp	[error_line],0
811
	jne	zero_times
817
	jne	zero_times
812
	mov	eax,[current_line]
818
	mov	eax,[current_line]
813
	mov	[error_line],eax
819
	mov	[error_line],eax
814
	mov	[error],invalid_value
820
	mov	[error],invalid_value
815
      zero_times:
821
      zero_times:
816
	call	skip_line
822
	call	skip_line
817
	jmp	instruction_assembled
823
	jmp	instruction_assembled
818
 
824
 
819
virtual_directive:
825
virtual_directive:
820
	lods	byte [esi]
826
	lods	byte [esi]
821
	cmp	al,80h
827
	cmp	al,80h
822
	jne	virtual_at_current
828
	jne	virtual_at_current
823
	lods	byte [esi]
829
	lods	byte [esi]
824
	cmp	al,'('
830
	cmp	al,'('
825
	jne	invalid_argument
831
	jne	invalid_argument
826
	cmp	byte [esi],'.'
832
	cmp	byte [esi],'.'
827
	je	invalid_value
833
	je	invalid_value
828
	call	get_address_value
834
	call	get_address_value
829
	mov	ebp,[address_symbol]
835
	mov	ebp,[address_symbol]
830
	xor	ch,ch
836
	xor	ch,ch
831
	or	bh,bh
837
	or	bh,bh
832
	jz	set_virtual
838
	jz	set_virtual
833
	mov	ch,1
839
	mov	ch,1
834
	jmp	set_virtual
840
	jmp	set_virtual
835
      virtual_at_current:
841
      virtual_at_current:
836
	dec	esi
842
	dec	esi
837
	mov	al,[labels_type]
843
	mov	al,[labels_type]
838
	mov	[value_type],al
844
	mov	[value_type],al
839
	mov	ebp,[org_symbol]
845
	mov	ebp,[org_symbol]
840
	mov	eax,edi
846
	mov	eax,edi
841
	xor	edx,edx
847
	xor	edx,edx
842
	sub	eax,dword [org_origin]
848
	sub	eax,dword [org_origin]
843
	sbb	edx,dword [org_origin+4]
849
	sbb	edx,dword [org_origin+4]
844
	mov	bx,word [org_registers]
850
	mov	bx,word [org_registers]
845
	mov	cx,word [org_registers+2]
851
	mov	cx,word [org_registers+2]
846
	xchg	bh,bl
852
	xchg	bh,bl
847
	xchg	ch,cl
853
	xchg	ch,cl
848
      set_virtual:
854
      set_virtual:
849
	push	[org_registers]
855
	push	[org_registers]
850
	mov	byte [org_registers],bh
856
	mov	byte [org_registers],bh
851
	mov	byte [org_registers+1],bl
857
	mov	byte [org_registers+1],bl
852
	mov	byte [org_registers+2],ch
858
	mov	byte [org_registers+2],ch
853
	mov	byte [org_registers+3],cl
859
	mov	byte [org_registers+3],cl
854
	call	allocate_structure_data
860
	call	allocate_structure_data
855
	mov	word [ebx],virtual_directive-assembler
861
	mov	word [ebx],virtual_directive-assembler
856
	not	eax
862
	not	eax
857
	not	edx
863
	not	edx
858
	add	eax,1
864
	add	eax,1
859
	adc	edx,0
865
	adc	edx,0
860
	add	eax,edi
866
	add	eax,edi
861
	adc	edx,0
867
	adc	edx,0
862
	xchg	dword [org_origin],eax
868
	xchg	dword [org_origin],eax
863
	xchg	dword [org_origin+4],edx
869
	xchg	dword [org_origin+4],edx
864
	mov	[ebx+10h],eax
870
	mov	[ebx+10h],eax
865
	mov	[ebx+14h],edx
871
	mov	[ebx+14h],edx
866
	pop	eax
872
	pop	eax
867
	mov	[ebx+18h],eax
873
	mov	[ebx+18h],eax
868
	mov	al,[virtual_data]
874
	mov	al,[virtual_data]
869
	mov	[ebx+2],al
875
	mov	[ebx+2],al
870
	mov	al,[labels_type]
876
	mov	al,[labels_type]
871
	mov	[ebx+3],al
877
	mov	[ebx+3],al
872
	mov	eax,edi
878
	mov	eax,edi
873
	xchg	eax,[org_start]
879
	xchg	eax,[org_start]
874
	mov	[ebx+0Ch],eax
880
	mov	[ebx+0Ch],eax
875
	xchg	ebp,[org_symbol]
881
	xchg	ebp,[org_symbol]
876
	mov	[ebx+1Ch],ebp
882
	mov	[ebx+1Ch],ebp
877
	mov	[ebx+8],edi
883
	mov	[ebx+8],edi
878
	mov	eax,[current_line]
884
	mov	eax,[current_line]
879
	mov	[ebx+4],eax
885
	mov	[ebx+4],eax
880
	or	[virtual_data],-1
886
	or	[virtual_data],-1
881
	mov	al,[value_type]
887
	mov	al,[value_type]
882
	test	al,1
888
	test	al,1
883
	jnz	invalid_use_of_symbol
889
	jnz	invalid_use_of_symbol
884
	mov	[labels_type],al
890
	mov	[labels_type],al
885
	jmp	instruction_assembled
891
	jmp	instruction_assembled
886
      allocate_structure_data:
892
      allocate_structure_data:
887
	mov	ebx,[structures_buffer]
893
	mov	ebx,[structures_buffer]
888
	sub	ebx,20h
894
	sub	ebx,20h
889
	cmp	ebx,[free_additional_memory]
895
	cmp	ebx,[free_additional_memory]
890
	jb	out_of_memory
896
	jb	out_of_memory
891
	mov	[structures_buffer],ebx
897
	mov	[structures_buffer],ebx
892
	ret
898
	ret
893
      find_structure_data:
899
      find_structure_data:
894
	mov	ebx,[structures_buffer]
900
	mov	ebx,[structures_buffer]
895
      scan_structures:
901
      scan_structures:
896
	cmp	ebx,[additional_memory_end]
902
	cmp	ebx,[additional_memory_end]
897
	je	no_such_structure
903
	je	no_such_structure
898
	cmp	ax,[ebx]
904
	cmp	ax,[ebx]
899
	je	structure_data_found
905
	je	structure_data_found
900
	add	ebx,20h
906
	add	ebx,20h
901
	jmp	scan_structures
907
	jmp	scan_structures
902
      structure_data_found:
908
      structure_data_found:
903
	ret
909
	ret
904
      no_such_structure:
910
      no_such_structure:
905
	stc
911
	stc
906
	ret
912
	ret
907
      end_virtual:
913
      end_virtual:
908
	call	find_structure_data
914
	call	find_structure_data
909
	jc	unexpected_instruction
915
	jc	unexpected_instruction
910
	mov	al,[ebx+2]
916
	mov	al,[ebx+2]
911
	mov	[virtual_data],al
917
	mov	[virtual_data],al
912
	mov	al,[ebx+3]
918
	mov	al,[ebx+3]
913
	mov	[labels_type],al
919
	mov	[labels_type],al
914
	mov	eax,[ebx+10h]
920
	mov	eax,[ebx+10h]
915
	mov	dword [org_origin],eax
921
	mov	dword [org_origin],eax
916
	mov	eax,[ebx+14h]
922
	mov	eax,[ebx+14h]
917
	mov	dword [org_origin+4],eax
923
	mov	dword [org_origin+4],eax
918
	mov	eax,[ebx+18h]
924
	mov	eax,[ebx+18h]
919
	mov	[org_registers],eax
925
	mov	[org_registers],eax
920
	mov	eax,[ebx+0Ch]
926
	mov	eax,[ebx+0Ch]
921
	mov	[org_start],eax
927
	mov	[org_start],eax
922
	mov	eax,[ebx+1Ch]
928
	mov	eax,[ebx+1Ch]
923
	mov	[org_symbol],eax
929
	mov	[org_symbol],eax
924
	mov	edi,[ebx+8]
930
	mov	edi,[ebx+8]
925
      remove_structure_data:
931
      remove_structure_data:
926
	push	esi edi
932
	push	esi edi
927
	mov	esi,[structures_buffer]
933
	mov	esi,[structures_buffer]
928
	mov	ecx,ebx
934
	mov	ecx,ebx
929
	sub	ecx,esi
935
	sub	ecx,esi
930
	lea	edi,[esi+20h]
936
	lea	edi,[esi+20h]
931
	mov	[structures_buffer],edi
937
	mov	[structures_buffer],edi
932
	shr	ecx,2
938
	shr	ecx,2
933
	rep	movs dword [edi],[esi]
939
	rep	movs dword [edi],[esi]
934
	pop	edi esi
940
	pop	edi esi
935
	ret
941
	ret
936
repeat_directive:
942
repeat_directive:
937
	cmp	[prefixed_instruction],0
943
	cmp	[prefixed_instruction],0
938
	jne	unexpected_instruction
944
	jne	unexpected_instruction
939
	lods	byte [esi]
945
	lods	byte [esi]
940
	cmp	al,'('
946
	cmp	al,'('
941
	jne	invalid_argument
947
	jne	invalid_argument
942
	cmp	byte [esi],'.'
948
	cmp	byte [esi],'.'
943
	je	invalid_value
949
	je	invalid_value
944
	call	get_dword_value
950
	call	get_dword_value
945
	cmp	[next_pass_needed],0
951
	cmp	[next_pass_needed],0
946
	jne	repeat_value_ok
952
	jne	repeat_value_ok
947
	cmp	[value_type],0
953
	cmp	[value_type],0
948
	jne	invalid_use_of_symbol
954
	jne	invalid_use_of_symbol
949
      repeat_value_ok:
955
      repeat_value_ok:
950
	cmp	eax,0
956
	cmp	eax,0
951
	je	zero_repeat
957
	je	zero_repeat
952
	jl	negative_repeat
958
	jl	negative_repeat
953
	call	allocate_structure_data
959
	call	allocate_structure_data
954
	mov	word [ebx],repeat_directive-assembler
960
	mov	word [ebx],repeat_directive-assembler
955
	xchg	eax,[counter_limit]
961
	xchg	eax,[counter_limit]
956
	mov	[ebx+10h],eax
962
	mov	[ebx+10h],eax
957
	mov	eax,1
963
	mov	eax,1
958
	xchg	eax,[counter]
964
	xchg	eax,[counter]
959
	mov	[ebx+14h],eax
965
	mov	[ebx+14h],eax
960
	mov	[ebx+8],esi
966
	mov	[ebx+8],esi
961
	mov	eax,[current_line]
967
	mov	eax,[current_line]
962
	mov	[ebx+4],eax
968
	mov	[ebx+4],eax
963
	jmp	instruction_assembled
969
	jmp	instruction_assembled
964
      end_repeat:
970
      end_repeat:
965
	cmp	[prefixed_instruction],0
971
	cmp	[prefixed_instruction],0
966
	jne	unexpected_instruction
972
	jne	unexpected_instruction
967
	call	find_structure_data
973
	call	find_structure_data
968
	jc	unexpected_instruction
974
	jc	unexpected_instruction
969
	mov	eax,[counter_limit]
975
	mov	eax,[counter_limit]
970
	inc	[counter]
976
	inc	[counter]
971
	cmp	[counter],eax
977
	cmp	[counter],eax
972
	jbe	continue_repeating
978
	jbe	continue_repeating
973
      stop_repeat:
979
      stop_repeat:
974
	mov	eax,[ebx+10h]
980
	mov	eax,[ebx+10h]
975
	mov	[counter_limit],eax
981
	mov	[counter_limit],eax
976
	mov	eax,[ebx+14h]
982
	mov	eax,[ebx+14h]
977
	mov	[counter],eax
983
	mov	[counter],eax
978
	call	remove_structure_data
984
	call	remove_structure_data
979
	jmp	instruction_assembled
985
	jmp	instruction_assembled
980
      continue_repeating:
986
      continue_repeating:
981
	mov	esi,[ebx+8]
987
	mov	esi,[ebx+8]
982
	jmp	instruction_assembled
988
	jmp	instruction_assembled
983
      negative_repeat:
989
      negative_repeat:
984
	cmp	[error_line],0
990
	cmp	[error_line],0
985
	jne	zero_repeat
991
	jne	zero_repeat
986
	mov	eax,[current_line]
992
	mov	eax,[current_line]
987
	mov	[error_line],eax
993
	mov	[error_line],eax
988
	mov	[error],invalid_value
994
	mov	[error],invalid_value
989
      zero_repeat:
995
      zero_repeat:
990
	mov	al,[esi]
996
	mov	al,[esi]
991
	or	al,al
997
	or	al,al
992
	jz	missing_end_directive
998
	jz	missing_end_directive
993
	cmp	al,0Fh
999
	cmp	al,0Fh
994
	jne	extra_characters_on_line
1000
	jne	extra_characters_on_line
995
	call	find_end_repeat
1001
	call	find_end_repeat
996
	jmp	instruction_assembled
1002
	jmp	instruction_assembled
997
      find_end_repeat:
1003
      find_end_repeat:
998
	call	find_structure_end
1004
	call	find_structure_end
999
	cmp	ax,repeat_directive-assembler
1005
	cmp	ax,repeat_directive-assembler
1000
	jne	unexpected_instruction
1006
	jne	unexpected_instruction
1001
	ret
1007
	ret
1002
while_directive:
1008
while_directive:
1003
	cmp	[prefixed_instruction],0
1009
	cmp	[prefixed_instruction],0
1004
	jne	unexpected_instruction
1010
	jne	unexpected_instruction
1005
	call	allocate_structure_data
1011
	call	allocate_structure_data
1006
	mov	word [ebx],while_directive-assembler
1012
	mov	word [ebx],while_directive-assembler
1007
	mov	eax,1
1013
	mov	eax,1
1008
	xchg	eax,[counter]
1014
	xchg	eax,[counter]
1009
	mov	[ebx+10h],eax
1015
	mov	[ebx+10h],eax
1010
	mov	[ebx+8],esi
1016
	mov	[ebx+8],esi
1011
	mov	eax,[current_line]
1017
	mov	eax,[current_line]
1012
	mov	[ebx+4],eax
1018
	mov	[ebx+4],eax
1013
      do_while:
1019
      do_while:
1014
	push	ebx
1020
	push	ebx
1015
	call	calculate_logical_expression
1021
	call	calculate_logical_expression
1016
	or	al,al
1022
	or	al,al
1017
	jnz	while_true
1023
	jnz	while_true
1018
	mov	al,[esi]
1024
	mov	al,[esi]
1019
	or	al,al
1025
	or	al,al
1020
	jz	missing_end_directive
1026
	jz	missing_end_directive
1021
	cmp	al,0Fh
1027
	cmp	al,0Fh
1022
	jne	extra_characters_on_line
1028
	jne	extra_characters_on_line
1023
      stop_while:
1029
      stop_while:
1024
	call	find_end_while
1030
	call	find_end_while
1025
	pop	ebx
1031
	pop	ebx
1026
	mov	eax,[ebx+10h]
1032
	mov	eax,[ebx+10h]
1027
	mov	[counter],eax
1033
	mov	[counter],eax
1028
	call	remove_structure_data
1034
	call	remove_structure_data
1029
	jmp	instruction_assembled
1035
	jmp	instruction_assembled
1030
      while_true:
1036
      while_true:
1031
	pop	ebx
1037
	pop	ebx
1032
	jmp	instruction_assembled
1038
	jmp	instruction_assembled
1033
      end_while:
1039
      end_while:
1034
	cmp	[prefixed_instruction],0
1040
	cmp	[prefixed_instruction],0
1035
	jne	unexpected_instruction
1041
	jne	unexpected_instruction
1036
	call	find_structure_data
1042
	call	find_structure_data
1037
	jc	unexpected_instruction
1043
	jc	unexpected_instruction
1038
	mov	eax,[ebx+4]
1044
	mov	eax,[ebx+4]
1039
	mov	[current_line],eax
1045
	mov	[current_line],eax
1040
	inc	[counter]
1046
	inc	[counter]
1041
	jz	too_many_repeats
1047
	jz	too_many_repeats
1042
	mov	esi,[ebx+8]
1048
	mov	esi,[ebx+8]
1043
	jmp	do_while
1049
	jmp	do_while
1044
      find_end_while:
1050
      find_end_while:
1045
	call	find_structure_end
1051
	call	find_structure_end
1046
	cmp	ax,while_directive-assembler
1052
	cmp	ax,while_directive-assembler
1047
	jne	unexpected_instruction
1053
	jne	unexpected_instruction
1048
	ret
1054
	ret
1049
if_directive:
1055
if_directive:
1050
	cmp	[prefixed_instruction],0
1056
	cmp	[prefixed_instruction],0
1051
	jne	unexpected_instruction
1057
	jne	unexpected_instruction
1052
	call	calculate_logical_expression
1058
	call	calculate_logical_expression
1053
	mov	dl,al
1059
	mov	dl,al
1054
	mov	al,[esi]
1060
	mov	al,[esi]
1055
	or	al,al
1061
	or	al,al
1056
	jz	missing_end_directive
1062
	jz	missing_end_directive
1057
	cmp	al,0Fh
1063
	cmp	al,0Fh
1058
	jne	extra_characters_on_line
1064
	jne	extra_characters_on_line
1059
	or	dl,dl
1065
	or	dl,dl
1060
	jnz	if_true
1066
	jnz	if_true
1061
	call	find_else
1067
	call	find_else
1062
	jc	instruction_assembled
1068
	jc	instruction_assembled
1063
	mov	al,[esi]
1069
	mov	al,[esi]
1064
	cmp	al,1
1070
	cmp	al,1
1065
	jne	else_true
1071
	jne	else_true
1066
	cmp	word [esi+1],if_directive-assembler
1072
	cmp	word [esi+1],if_directive-assembler
1067
	jne	else_true
1073
	jne	else_true
1068
	add	esi,4
1074
	add	esi,4
1069
	jmp	if_directive
1075
	jmp	if_directive
1070
      if_true:
1076
      if_true:
1071
	xor	al,al
1077
	xor	al,al
1072
      make_if_structure:
1078
      make_if_structure:
1073
	call	allocate_structure_data
1079
	call	allocate_structure_data
1074
	mov	word [ebx],if_directive-assembler
1080
	mov	word [ebx],if_directive-assembler
1075
	mov	byte [ebx+2],al
1081
	mov	byte [ebx+2],al
1076
	mov	eax,[current_line]
1082
	mov	eax,[current_line]
1077
	mov	[ebx+4],eax
1083
	mov	[ebx+4],eax
1078
	jmp	instruction_assembled
1084
	jmp	instruction_assembled
1079
      else_true:
1085
      else_true:
1080
	or	al,al
1086
	or	al,al
1081
	jz	missing_end_directive
1087
	jz	missing_end_directive
1082
	cmp	al,0Fh
1088
	cmp	al,0Fh
1083
	jne	extra_characters_on_line
1089
	jne	extra_characters_on_line
1084
	or	al,-1
1090
	or	al,-1
1085
	jmp	make_if_structure
1091
	jmp	make_if_structure
1086
      else_directive:
1092
      else_directive:
1087
	cmp	[prefixed_instruction],0
1093
	cmp	[prefixed_instruction],0
1088
	jne	unexpected_instruction
1094
	jne	unexpected_instruction
1089
	mov	ax,if_directive-assembler
1095
	mov	ax,if_directive-assembler
1090
	call	find_structure_data
1096
	call	find_structure_data
1091
	jc	unexpected_instruction
1097
	jc	unexpected_instruction
1092
	cmp	byte [ebx+2],0
1098
	cmp	byte [ebx+2],0
1093
	jne	unexpected_instruction
1099
	jne	unexpected_instruction
1094
      found_else:
1100
      found_else:
1095
	mov	al,[esi]
1101
	mov	al,[esi]
1096
	cmp	al,1
1102
	cmp	al,1
1097
	jne	skip_else
1103
	jne	skip_else
1098
	cmp	word [esi+1],if_directive-assembler
1104
	cmp	word [esi+1],if_directive-assembler
1099
	jne	skip_else
1105
	jne	skip_else
1100
	add	esi,4
1106
	add	esi,4
1101
	call	find_else
1107
	call	find_else
1102
	jnc	found_else
1108
	jnc	found_else
1103
	call	remove_structure_data
1109
	call	remove_structure_data
1104
	jmp	instruction_assembled
1110
	jmp	instruction_assembled
1105
      skip_else:
1111
      skip_else:
1106
	or	al,al
1112
	or	al,al
1107
	jz	missing_end_directive
1113
	jz	missing_end_directive
1108
	cmp	al,0Fh
1114
	cmp	al,0Fh
1109
	jne	extra_characters_on_line
1115
	jne	extra_characters_on_line
1110
	call	find_end_if
1116
	call	find_end_if
1111
	call	remove_structure_data
1117
	call	remove_structure_data
1112
	jmp	instruction_assembled
1118
	jmp	instruction_assembled
1113
      end_if:
1119
      end_if:
1114
	cmp	[prefixed_instruction],0
1120
	cmp	[prefixed_instruction],0
1115
	jne	unexpected_instruction
1121
	jne	unexpected_instruction
1116
	call	find_structure_data
1122
	call	find_structure_data
1117
	jc	unexpected_instruction
1123
	jc	unexpected_instruction
1118
	call	remove_structure_data
1124
	call	remove_structure_data
1119
	jmp	instruction_assembled
1125
	jmp	instruction_assembled
1120
      find_else:
1126
      find_else:
1121
	call	find_structure_end
1127
	call	find_structure_end
1122
	cmp	ax,else_directive-assembler
1128
	cmp	ax,else_directive-assembler
1123
	je	else_found
1129
	je	else_found
1124
	cmp	ax,if_directive-assembler
1130
	cmp	ax,if_directive-assembler
1125
	jne	unexpected_instruction
1131
	jne	unexpected_instruction
1126
	stc
1132
	stc
1127
	ret
1133
	ret
1128
      else_found:
1134
      else_found:
1129
	clc
1135
	clc
1130
	ret
1136
	ret
1131
      find_end_if:
1137
      find_end_if:
1132
	call	find_structure_end
1138
	call	find_structure_end
1133
	cmp	ax,if_directive-assembler
1139
	cmp	ax,if_directive-assembler
1134
	jne	unexpected_instruction
1140
	jne	unexpected_instruction
1135
	ret
1141
	ret
1136
      find_structure_end:
1142
      find_structure_end:
1137
	push	[error_line]
1143
	push	[error_line]
1138
	mov	eax,[current_line]
1144
	mov	eax,[current_line]
1139
	mov	[error_line],eax
1145
	mov	[error_line],eax
1140
      find_end_directive:
1146
      find_end_directive:
1141
	call	skip_line
1147
	call	skip_line
1142
	lods	byte [esi]
1148
	lods	byte [esi]
1143
	cmp	al,0Fh
1149
	cmp	al,0Fh
1144
	jne	no_end_directive
1150
	jne	no_end_directive
1145
	lods	dword [esi]
1151
	lods	dword [esi]
1146
	mov	[current_line],eax
1152
	mov	[current_line],eax
1147
      skip_labels:
1153
      skip_labels:
1148
	cmp	byte [esi],2
1154
	cmp	byte [esi],2
1149
	jne	labels_ok
1155
	jne	labels_ok
1150
	add	esi,6
1156
	add	esi,6
1151
	jmp	skip_labels
1157
	jmp	skip_labels
1152
      labels_ok:
1158
      labels_ok:
1153
	cmp	byte [esi],1
1159
	cmp	byte [esi],1
1154
	jne	find_end_directive
1160
	jne	find_end_directive
1155
	mov	ax,[esi+1]
1161
	mov	ax,[esi+1]
1156
	cmp	ax,prefix_instruction-assembler
1162
	cmp	ax,prefix_instruction-assembler
1157
	je	find_end_directive
1163
	je	find_end_directive
1158
	add	esi,4
1164
	add	esi,4
1159
	cmp	ax,repeat_directive-assembler
1165
	cmp	ax,repeat_directive-assembler
1160
	je	skip_repeat
1166
	je	skip_repeat
1161
	cmp	ax,while_directive-assembler
1167
	cmp	ax,while_directive-assembler
1162
	je	skip_while
1168
	je	skip_while
1163
	cmp	ax,if_directive-assembler
1169
	cmp	ax,if_directive-assembler
1164
	je	skip_if
1170
	je	skip_if
1165
	cmp	ax,else_directive-assembler
1171
	cmp	ax,else_directive-assembler
1166
	je	structure_end
1172
	je	structure_end
1167
	cmp	ax,end_directive-assembler
1173
	cmp	ax,end_directive-assembler
1168
	jne	find_end_directive
1174
	jne	find_end_directive
1169
	cmp	byte [esi],1
1175
	cmp	byte [esi],1
1170
	jne	find_end_directive
1176
	jne	find_end_directive
1171
	mov	ax,[esi+1]
1177
	mov	ax,[esi+1]
1172
	add	esi,4
1178
	add	esi,4
1173
	cmp	ax,repeat_directive-assembler
1179
	cmp	ax,repeat_directive-assembler
1174
	je	structure_end
1180
	je	structure_end
1175
	cmp	ax,while_directive-assembler
1181
	cmp	ax,while_directive-assembler
1176
	je	structure_end
1182
	je	structure_end
1177
	cmp	ax,if_directive-assembler
1183
	cmp	ax,if_directive-assembler
1178
	jne	find_end_directive
1184
	jne	find_end_directive
1179
      structure_end:
1185
      structure_end:
1180
	pop	[error_line]
1186
	pop	[error_line]
1181
	ret
1187
	ret
1182
      no_end_directive:
1188
      no_end_directive:
1183
	mov	eax,[error_line]
1189
	mov	eax,[error_line]
1184
	mov	[current_line],eax
1190
	mov	[current_line],eax
1185
	jmp	missing_end_directive
1191
	jmp	missing_end_directive
1186
      skip_repeat:
1192
      skip_repeat:
1187
	call	find_end_repeat
1193
	call	find_end_repeat
1188
	jmp	find_end_directive
1194
	jmp	find_end_directive
1189
      skip_while:
1195
      skip_while:
1190
	call	find_end_while
1196
	call	find_end_while
1191
	jmp	find_end_directive
1197
	jmp	find_end_directive
1192
      skip_if:
1198
      skip_if:
1193
	call	skip_if_block
1199
	call	skip_if_block
1194
	jmp	find_end_directive
1200
	jmp	find_end_directive
1195
      skip_if_block:
1201
      skip_if_block:
1196
	call	find_else
1202
	call	find_else
1197
	jc	if_block_skipped
1203
	jc	if_block_skipped
1198
	cmp	byte [esi],1
1204
	cmp	byte [esi],1
1199
	jne	skip_after_else
1205
	jne	skip_after_else
1200
	cmp	word [esi+1],if_directive-assembler
1206
	cmp	word [esi+1],if_directive-assembler
1201
	jne	skip_after_else
1207
	jne	skip_after_else
1202
	add	esi,4
1208
	add	esi,4
1203
	jmp	skip_if_block
1209
	jmp	skip_if_block
1204
      skip_after_else:
1210
      skip_after_else:
1205
	call	find_end_if
1211
	call	find_end_if
1206
      if_block_skipped:
1212
      if_block_skipped:
1207
	ret
1213
	ret
1208
end_directive:
1214
end_directive:
1209
	lods	byte [esi]
1215
	lods	byte [esi]
1210
	cmp	al,1
1216
	cmp	al,1
1211
	jne	invalid_argument
1217
	jne	invalid_argument
1212
	lods	word [esi]
1218
	lods	word [esi]
1213
	inc	esi
1219
	inc	esi
1214
	cmp	ax,virtual_directive-assembler
1220
	cmp	ax,virtual_directive-assembler
1215
	je	end_virtual
1221
	je	end_virtual
1216
	cmp	ax,repeat_directive-assembler
1222
	cmp	ax,repeat_directive-assembler
1217
	je	end_repeat
1223
	je	end_repeat
1218
	cmp	ax,while_directive-assembler
1224
	cmp	ax,while_directive-assembler
1219
	je	end_while
1225
	je	end_while
1220
	cmp	ax,if_directive-assembler
1226
	cmp	ax,if_directive-assembler
1221
	je	end_if
1227
	je	end_if
1222
	cmp	ax,data_directive-assembler
1228
	cmp	ax,data_directive-assembler
1223
	je	end_data
1229
	je	end_data
1224
	jmp	invalid_argument
1230
	jmp	invalid_argument
1225
break_directive:
1231
break_directive:
1226
	mov	ebx,[structures_buffer]
1232
	mov	ebx,[structures_buffer]
1227
	mov	al,[esi]
1233
	mov	al,[esi]
1228
	or	al,al
1234
	or	al,al
1229
	jz	find_breakable_structure
1235
	jz	find_breakable_structure
1230
	cmp	al,0Fh
1236
	cmp	al,0Fh
1231
	jne	extra_characters_on_line
1237
	jne	extra_characters_on_line
1232
      find_breakable_structure:
1238
      find_breakable_structure:
1233
	cmp	ebx,[additional_memory_end]
1239
	cmp	ebx,[additional_memory_end]
1234
	je	unexpected_instruction
1240
	je	unexpected_instruction
1235
	mov	ax,[ebx]
1241
	mov	ax,[ebx]
1236
	cmp	ax,repeat_directive-assembler
1242
	cmp	ax,repeat_directive-assembler
1237
	je	break_repeat
1243
	je	break_repeat
1238
	cmp	ax,while_directive-assembler
1244
	cmp	ax,while_directive-assembler
1239
	je	break_while
1245
	je	break_while
1240
	cmp	ax,if_directive-assembler
1246
	cmp	ax,if_directive-assembler
1241
	je	break_if
1247
	je	break_if
1242
	add	ebx,20h
1248
	add	ebx,20h
1243
	jmp	find_breakable_structure
1249
	jmp	find_breakable_structure
1244
      break_if:
1250
      break_if:
1245
	push	[current_line]
1251
	push	[current_line]
1246
	mov	eax,[ebx+4]
1252
	mov	eax,[ebx+4]
1247
	mov	[current_line],eax
1253
	mov	[current_line],eax
1248
	call	remove_structure_data
1254
	call	remove_structure_data
1249
	call	skip_if_block
1255
	call	skip_if_block
1250
	pop	[current_line]
1256
	pop	[current_line]
1251
	mov	ebx,[structures_buffer]
1257
	mov	ebx,[structures_buffer]
1252
	jmp	find_breakable_structure
1258
	jmp	find_breakable_structure
1253
      break_repeat:
1259
      break_repeat:
1254
	push	ebx
1260
	push	ebx
1255
	call	find_end_repeat
1261
	call	find_end_repeat
1256
	pop	ebx
1262
	pop	ebx
1257
	jmp	stop_repeat
1263
	jmp	stop_repeat
1258
      break_while:
1264
      break_while:
1259
	push	ebx
1265
	push	ebx
1260
	jmp	stop_while
1266
	jmp	stop_while
1261
 
1267
 
1262
data_bytes:
1268
data_bytes:
1263
	call	define_data
1269
	call	define_data
1264
	lods	byte [esi]
1270
	lods	byte [esi]
1265
	cmp	al,'('
1271
	cmp	al,'('
1266
	je	get_byte
1272
	je	get_byte
1267
	cmp	al,'?'
1273
	cmp	al,'?'
1268
	jne	invalid_argument
1274
	jne	invalid_argument
1269
	mov	eax,edi
1275
	mov	eax,edi
1270
	mov	byte [edi],0
1276
	mov	byte [edi],0
1271
	inc	edi
1277
	inc	edi
1272
	jmp	undefined_data
1278
	jmp	undefined_data
1273
      get_byte:
1279
      get_byte:
1274
	cmp	byte [esi],0
1280
	cmp	byte [esi],0
1275
	je	get_string
1281
	je	get_string
1276
	call	get_byte_value
1282
	call	get_byte_value
1277
	stos	byte [edi]
1283
	stos	byte [edi]
1278
	ret
1284
	ret
1279
      get_string:
1285
      get_string:
1280
	inc	esi
1286
	inc	esi
1281
	lods	dword [esi]
1287
	lods	dword [esi]
1282
	mov	ecx,eax
1288
	mov	ecx,eax
1283
	lea	eax,[edi+ecx]
1289
	lea	eax,[edi+ecx]
1284
	cmp	eax,[display_buffer]
1290
	cmp	eax,[display_buffer]
1285
	ja	out_of_memory
1291
	ja	out_of_memory
1286
	rep	movs byte [edi],[esi]
1292
	rep	movs byte [edi],[esi]
1287
	inc	esi
1293
	inc	esi
1288
	ret
1294
	ret
1289
      undefined_data:
1295
      undefined_data:
1290
	cmp	[virtual_data],0
1296
	cmp	[virtual_data],0
1291
	je	mark_undefined_data
1297
	je	mark_undefined_data
1292
	ret
1298
	ret
1293
      mark_undefined_data:
1299
      mark_undefined_data:
1294
	cmp	eax,[undefined_data_end]
1300
	cmp	eax,[undefined_data_end]
1295
	je	undefined_data_ok
1301
	je	undefined_data_ok
1296
	mov	[undefined_data_start],eax
1302
	mov	[undefined_data_start],eax
1297
      undefined_data_ok:
1303
      undefined_data_ok:
1298
	mov	[undefined_data_end],edi
1304
	mov	[undefined_data_end],edi
1299
	ret
1305
	ret
1300
      define_data:
1306
      define_data:
1301
	cmp	edi,[display_buffer]
1307
	cmp	edi,[display_buffer]
1302
	jae	out_of_memory
1308
	jae	out_of_memory
1303
	cmp	byte [esi],'('
1309
	cmp	byte [esi],'('
1304
	jne	simple_data_value
1310
	jne	simple_data_value
1305
	mov	ebx,esi
1311
	mov	ebx,esi
1306
	inc	esi
1312
	inc	esi
1307
	call	skip_expression
1313
	call	skip_expression
1308
	xchg	esi,ebx
1314
	xchg	esi,ebx
1309
	cmp	byte [ebx],81h
1315
	cmp	byte [ebx],81h
1310
	jne	simple_data_value
1316
	jne	simple_data_value
1311
	inc	esi
1317
	inc	esi
1312
	call	get_dword_value
1318
	call	get_dword_value
1313
	cmp	[next_pass_needed],0
1319
	cmp	[next_pass_needed],0
1314
	jne	dup_value_ok
1320
	jne	dup_value_ok
1315
	cmp	[value_type],0
1321
	cmp	[value_type],0
1316
	jne	invalid_use_of_symbol
1322
	jne	invalid_use_of_symbol
1317
      dup_value_ok:
1323
      dup_value_ok:
1318
	inc	esi
1324
	inc	esi
1319
	cmp	eax,0
1325
	cmp	eax,0
1320
	jg	dup_positive
1326
	jg	dup_positive
1321
	cmp	[error_line],0
1327
	cmp	[error_line],0
1322
	jne	dup_invalid
1328
	jne	dup_invalid
1323
	mov	eax,[current_line]
1329
	mov	eax,[current_line]
1324
	mov	[error_line],eax
1330
	mov	[error_line],eax
1325
	mov	[error],invalid_value
1331
	mov	[error],invalid_value
1326
      dup_invalid:
1332
      dup_invalid:
1327
	mov	eax,1
1333
	mov	eax,1
1328
      dup_positive:
1334
      dup_positive:
1329
	cmp	byte [esi],'{'
1335
	cmp	byte [esi],'{'
1330
	jne	duplicate_single_data_value
1336
	jne	duplicate_single_data_value
1331
	inc	esi
1337
	inc	esi
1332
      duplicate_data:
1338
      duplicate_data:
1333
	push	eax esi
1339
	push	eax esi
1334
      duplicated_values:
1340
      duplicated_values:
1335
	cmp	edi,[display_buffer]
1341
	cmp	edi,[display_buffer]
1336
	jae	out_of_memory
1342
	jae	out_of_memory
1337
	call	near dword [esp+8]
1343
	call	near dword [esp+8]
1338
	lods	byte [esi]
1344
	lods	byte [esi]
1339
	cmp	al,','
1345
	cmp	al,','
1340
	je	duplicated_values
1346
	je	duplicated_values
1341
	cmp	al,'}'
1347
	cmp	al,'}'
1342
	jne	invalid_argument
1348
	jne	invalid_argument
1343
	pop	ebx eax
1349
	pop	ebx eax
1344
	dec	eax
1350
	dec	eax
1345
	jz	data_defined
1351
	jz	data_defined
1346
	mov	esi,ebx
1352
	mov	esi,ebx
1347
	jmp	duplicate_data
1353
	jmp	duplicate_data
1348
      duplicate_single_data_value:
1354
      duplicate_single_data_value:
1349
	cmp	edi,[display_buffer]
1355
	cmp	edi,[display_buffer]
1350
	jae	out_of_memory
1356
	jae	out_of_memory
1351
	push	eax esi
1357
	push	eax esi
1352
	call	near dword [esp+8]
1358
	call	near dword [esp+8]
1353
	pop	ebx eax
1359
	pop	ebx eax
1354
	dec	eax
1360
	dec	eax
1355
	jz	data_defined
1361
	jz	data_defined
1356
	mov	esi,ebx
1362
	mov	esi,ebx
1357
	jmp	duplicate_single_data_value
1363
	jmp	duplicate_single_data_value
1358
      simple_data_value:
1364
      simple_data_value:
1359
	cmp	edi,[display_buffer]
1365
	cmp	edi,[display_buffer]
1360
	jae	out_of_memory
1366
	jae	out_of_memory
1361
	call	near dword [esp]
1367
	call	near dword [esp]
1362
      data_defined:
1368
      data_defined:
1363
	lods	byte [esi]
1369
	lods	byte [esi]
1364
	cmp	al,','
1370
	cmp	al,','
1365
	je	define_data
1371
	je	define_data
1366
	dec	esi
1372
	dec	esi
1367
	add	esp,4
1373
	add	esp,4
1368
	jmp	instruction_assembled
1374
	jmp	instruction_assembled
1369
data_unicode:
1375
data_unicode:
1370
	or	[base_code],-1
1376
	or	[base_code],-1
1371
	jmp	define_words
1377
	jmp	define_words
1372
data_words:
1378
data_words:
1373
	mov	[base_code],0
1379
	mov	[base_code],0
1374
      define_words:
1380
      define_words:
1375
	call	define_data
1381
	call	define_data
1376
	lods	byte [esi]
1382
	lods	byte [esi]
1377
	cmp	al,'('
1383
	cmp	al,'('
1378
	je	get_word
1384
	je	get_word
1379
	cmp	al,'?'
1385
	cmp	al,'?'
1380
	jne	invalid_argument
1386
	jne	invalid_argument
1381
	mov	eax,edi
1387
	mov	eax,edi
1382
	mov	word [edi],0
1388
	mov	word [edi],0
1383
	scas	word [edi]
1389
	scas	word [edi]
1384
	jmp	undefined_data
1390
	jmp	undefined_data
1385
	ret
1391
	ret
1386
      get_word:
1392
      get_word:
1387
	cmp	[base_code],0
1393
	cmp	[base_code],0
1388
	je	word_data_value
1394
	je	word_data_value
1389
	cmp	byte [esi],0
1395
	cmp	byte [esi],0
1390
	je	word_string
1396
	je	word_string
1391
      word_data_value:
1397
      word_data_value:
1392
	call	get_word_value
1398
	call	get_word_value
1393
	call	mark_relocation
1399
	call	mark_relocation
1394
	stos	word [edi]
1400
	stos	word [edi]
1395
	ret
1401
	ret
1396
      word_string:
1402
      word_string:
1397
	inc	esi
1403
	inc	esi
1398
	lods	dword [esi]
1404
	lods	dword [esi]
1399
	mov	ecx,eax
1405
	mov	ecx,eax
1400
	jecxz	word_string_ok
1406
	jecxz	word_string_ok
1401
	lea	eax,[edi+ecx*2]
1407
	lea	eax,[edi+ecx*2]
1402
	cmp	eax,[display_buffer]
1408
	cmp	eax,[display_buffer]
1403
	ja	out_of_memory
1409
	ja	out_of_memory
1404
	xor	ah,ah
1410
	xor	ah,ah
1405
      copy_word_string:
1411
      copy_word_string:
1406
	lods	byte [esi]
1412
	lods	byte [esi]
1407
	stos	word [edi]
1413
	stos	word [edi]
1408
	loop	copy_word_string
1414
	loop	copy_word_string
1409
      word_string_ok:
1415
      word_string_ok:
1410
	inc	esi
1416
	inc	esi
1411
	ret
1417
	ret
1412
data_dwords:
1418
data_dwords:
1413
	call	define_data
1419
	call	define_data
1414
	lods	byte [esi]
1420
	lods	byte [esi]
1415
	cmp	al,'('
1421
	cmp	al,'('
1416
	je	get_dword
1422
	je	get_dword
1417
	cmp	al,'?'
1423
	cmp	al,'?'
1418
	jne	invalid_argument
1424
	jne	invalid_argument
1419
	mov	eax,edi
1425
	mov	eax,edi
1420
	mov	dword [edi],0
1426
	mov	dword [edi],0
1421
	scas	dword [edi]
1427
	scas	dword [edi]
1422
	jmp	undefined_data
1428
	jmp	undefined_data
1423
      get_dword:
1429
      get_dword:
1424
	push	esi
1430
	push	esi
1425
	call	get_dword_value
1431
	call	get_dword_value
1426
	pop	ebx
1432
	pop	ebx
1427
	cmp	byte [esi],':'
1433
	cmp	byte [esi],':'
1428
	je	complex_dword
1434
	je	complex_dword
1429
	call	mark_relocation
1435
	call	mark_relocation
1430
	stos	dword [edi]
1436
	stos	dword [edi]
1431
	ret
1437
	ret
1432
      complex_dword:
1438
      complex_dword:
1433
	mov	esi,ebx
1439
	mov	esi,ebx
1434
	cmp	byte [esi],'.'
1440
	cmp	byte [esi],'.'
1435
	je	invalid_value
1441
	je	invalid_value
1436
	call	get_word_value
1442
	call	get_word_value
1437
	push	eax
1443
	push	eax
1438
	inc	esi
1444
	inc	esi
1439
	lods	byte [esi]
1445
	lods	byte [esi]
1440
	cmp	al,'('
1446
	cmp	al,'('
1441
	jne	invalid_operand
1447
	jne	invalid_operand
1442
	mov	al,[value_type]
1448
	mov	al,[value_type]
1443
	push	eax
1449
	push	eax
1444
	cmp	byte [esi],'.'
1450
	cmp	byte [esi],'.'
1445
	je	invalid_value
1451
	je	invalid_value
1446
	call	get_word_value
1452
	call	get_word_value
1447
	call	mark_relocation
1453
	call	mark_relocation
1448
	stos	word [edi]
1454
	stos	word [edi]
1449
	pop	eax
1455
	pop	eax
1450
	mov	[value_type],al
1456
	mov	[value_type],al
1451
	pop	eax
1457
	pop	eax
1452
	call	mark_relocation
1458
	call	mark_relocation
1453
	stos	word [edi]
1459
	stos	word [edi]
1454
	ret
1460
	ret
1455
data_pwords:
1461
data_pwords:
1456
	call	define_data
1462
	call	define_data
1457
	lods	byte [esi]
1463
	lods	byte [esi]
1458
	cmp	al,'('
1464
	cmp	al,'('
1459
	je	get_pword
1465
	je	get_pword
1460
	cmp	al,'?'
1466
	cmp	al,'?'
1461
	jne	invalid_argument
1467
	jne	invalid_argument
1462
	mov	eax,edi
1468
	mov	eax,edi
1463
	mov	dword [edi],0
1469
	mov	dword [edi],0
1464
	scas	dword [edi]
1470
	scas	dword [edi]
1465
	mov	word [edi],0
1471
	mov	word [edi],0
1466
	scas	word [edi]
1472
	scas	word [edi]
1467
	jmp	undefined_data
1473
	jmp	undefined_data
1468
      get_pword:
1474
      get_pword:
1469
	push	esi
1475
	push	esi
1470
	call	get_pword_value
1476
	call	get_pword_value
1471
	pop	ebx
1477
	pop	ebx
1472
	cmp	byte [esi],':'
1478
	cmp	byte [esi],':'
1473
	je	complex_pword
1479
	je	complex_pword
1474
	call	mark_relocation
1480
	call	mark_relocation
1475
	stos	dword [edi]
1481
	stos	dword [edi]
1476
	mov	ax,dx
1482
	mov	ax,dx
1477
	stos	word [edi]
1483
	stos	word [edi]
1478
	ret
1484
	ret
1479
      complex_pword:
1485
      complex_pword:
1480
	mov	esi,ebx
1486
	mov	esi,ebx
1481
	cmp	byte [esi],'.'
1487
	cmp	byte [esi],'.'
1482
	je	invalid_value
1488
	je	invalid_value
1483
	call	get_word_value
1489
	call	get_word_value
1484
	push	eax
1490
	push	eax
1485
	inc	esi
1491
	inc	esi
1486
	lods	byte [esi]
1492
	lods	byte [esi]
1487
	cmp	al,'('
1493
	cmp	al,'('
1488
	jne	invalid_operand
1494
	jne	invalid_operand
1489
	mov	al,[value_type]
1495
	mov	al,[value_type]
1490
	push	eax
1496
	push	eax
1491
	cmp	byte [esi],'.'
1497
	cmp	byte [esi],'.'
1492
	je	invalid_value
1498
	je	invalid_value
1493
	call	get_dword_value
1499
	call	get_dword_value
1494
	call	mark_relocation
1500
	call	mark_relocation
1495
	stos	dword [edi]
1501
	stos	dword [edi]
1496
	pop	eax
1502
	pop	eax
1497
	mov	[value_type],al
1503
	mov	[value_type],al
1498
	pop	eax
1504
	pop	eax
1499
	call	mark_relocation
1505
	call	mark_relocation
1500
	stos	word [edi]
1506
	stos	word [edi]
1501
	ret
1507
	ret
1502
data_qwords:
1508
data_qwords:
1503
	call	define_data
1509
	call	define_data
1504
	lods	byte [esi]
1510
	lods	byte [esi]
1505
	cmp	al,'('
1511
	cmp	al,'('
1506
	je	get_qword
1512
	je	get_qword
1507
	cmp	al,'?'
1513
	cmp	al,'?'
1508
	jne	invalid_argument
1514
	jne	invalid_argument
1509
	mov	eax,edi
1515
	mov	eax,edi
1510
	mov	dword [edi],0
1516
	mov	dword [edi],0
1511
	scas	dword [edi]
1517
	scas	dword [edi]
1512
	mov	dword [edi],0
1518
	mov	dword [edi],0
1513
	scas	dword [edi]
1519
	scas	dword [edi]
1514
	jmp	undefined_data
1520
	jmp	undefined_data
1515
      get_qword:
1521
      get_qword:
1516
	call	get_qword_value
1522
	call	get_qword_value
1517
	call	mark_relocation
1523
	call	mark_relocation
1518
	stos	dword [edi]
1524
	stos	dword [edi]
1519
	mov	eax,edx
1525
	mov	eax,edx
1520
	stos	dword [edi]
1526
	stos	dword [edi]
1521
	ret
1527
	ret
1522
data_twords:
1528
data_twords:
1523
	call	define_data
1529
	call	define_data
1524
	lods	byte [esi]
1530
	lods	byte [esi]
1525
	cmp	al,'('
1531
	cmp	al,'('
1526
	je	get_tword
1532
	je	get_tword
1527
	cmp	al,'?'
1533
	cmp	al,'?'
1528
	jne	invalid_argument
1534
	jne	invalid_argument
1529
	mov	eax,edi
1535
	mov	eax,edi
1530
	mov	dword [edi],0
1536
	mov	dword [edi],0
1531
	scas	dword [edi]
1537
	scas	dword [edi]
1532
	mov	dword [edi],0
1538
	mov	dword [edi],0
1533
	scas	dword [edi]
1539
	scas	dword [edi]
1534
	mov	word [edi],0
1540
	mov	word [edi],0
1535
	scas	word [edi]
1541
	scas	word [edi]
1536
	jmp	undefined_data
1542
	jmp	undefined_data
1537
      get_tword:
1543
      get_tword:
1538
	cmp	byte [esi],'.'
1544
	cmp	byte [esi],'.'
1539
	jne	complex_tword
1545
	jne	complex_tword
1540
	inc	esi
1546
	inc	esi
1541
	cmp	word [esi+8],8000h
1547
	cmp	word [esi+8],8000h
1542
	je	fp_zero_tword
1548
	je	fp_zero_tword
1543
	mov	eax,[esi]
1549
	mov	eax,[esi]
1544
	stos	dword [edi]
1550
	stos	dword [edi]
1545
	mov	eax,[esi+4]
1551
	mov	eax,[esi+4]
1546
	stos	dword [edi]
1552
	stos	dword [edi]
1547
	mov	ax,[esi+8]
1553
	mov	ax,[esi+8]
1548
	add	ax,3FFFh
1554
	add	ax,3FFFh
1549
	cmp	ax,8000h
1555
	cmp	ax,8000h
1550
	jae	value_out_of_range
1556
	jae	value_out_of_range
1551
	mov	bl,[esi+11]
1557
	mov	bl,[esi+11]
1552
	shl	bx,15
1558
	shl	bx,15
1553
	or	ax,bx
1559
	or	ax,bx
1554
	stos	word [edi]
1560
	stos	word [edi]
1555
	add	esi,13
1561
	add	esi,13
1556
	ret
1562
	ret
1557
      fp_zero_tword:
1563
      fp_zero_tword:
1558
	xor	eax,eax
1564
	xor	eax,eax
1559
	stos	dword [edi]
1565
	stos	dword [edi]
1560
	stos	dword [edi]
1566
	stos	dword [edi]
1561
	mov	al,[esi+11]
1567
	mov	al,[esi+11]
1562
	shl	ax,15
1568
	shl	ax,15
1563
	stos	word [edi]
1569
	stos	word [edi]
1564
	add	esi,13
1570
	add	esi,13
1565
	ret
1571
	ret
1566
      complex_tword:
1572
      complex_tword:
1567
	call	get_word_value
1573
	call	get_word_value
1568
	push	eax
1574
	push	eax
1569
	inc	esi
1575
	inc	esi
1570
	lods	byte [esi]
1576
	lods	byte [esi]
1571
	cmp	al,'('
1577
	cmp	al,'('
1572
	jne	invalid_operand
1578
	jne	invalid_operand
1573
	mov	al,[value_type]
1579
	mov	al,[value_type]
1574
	push	eax
1580
	push	eax
1575
	cmp	byte [esi],'.'
1581
	cmp	byte [esi],'.'
1576
	je	invalid_value
1582
	je	invalid_value
1577
	call	get_qword_value
1583
	call	get_qword_value
1578
	call	mark_relocation
1584
	call	mark_relocation
1579
	stos	dword [edi]
1585
	stos	dword [edi]
1580
	mov	eax,edx
1586
	mov	eax,edx
1581
	stos	dword [edi]
1587
	stos	dword [edi]
1582
	pop	eax
1588
	pop	eax
1583
	mov	[value_type],al
1589
	mov	[value_type],al
1584
	pop	eax
1590
	pop	eax
1585
	call	mark_relocation
1591
	call	mark_relocation
1586
	stos	word [edi]
1592
	stos	word [edi]
1587
	ret
1593
	ret
1588
data_file:
1594
data_file:
1589
	lods	word [esi]
1595
	lods	word [esi]
1590
	cmp	ax,'('
1596
	cmp	ax,'('
1591
	jne	invalid_argument
1597
	jne	invalid_argument
1592
	add	esi,4
1598
	add	esi,4
1593
	call	open_binary_file
1599
	call	open_binary_file
1594
	mov	eax,[esi-4]
1600
	mov	eax,[esi-4]
1595
	lea	esi,[esi+eax+1]
1601
	lea	esi,[esi+eax+1]
1596
	mov	al,2
1602
	mov	al,2
1597
	xor	edx,edx
1603
	xor	edx,edx
1598
	call	lseek
1604
	call	lseek
1599
	push	eax
1605
	push	eax
1600
	xor	edx,edx
1606
	xor	edx,edx
1601
	cmp	byte [esi],':'
1607
	cmp	byte [esi],':'
1602
	jne	position_ok
1608
	jne	position_ok
1603
	inc	esi
1609
	inc	esi
1604
	cmp	byte [esi],'('
1610
	cmp	byte [esi],'('
1605
	jne	invalid_argument
1611
	jne	invalid_argument
1606
	inc	esi
1612
	inc	esi
1607
	cmp	byte [esi],'.'
1613
	cmp	byte [esi],'.'
1608
	je	invalid_value
1614
	je	invalid_value
1609
	push	ebx
1615
	push	ebx
1610
	call	get_dword_value
1616
	call	get_dword_value
1611
	pop	ebx
1617
	pop	ebx
1612
	mov	edx,eax
1618
	mov	edx,eax
1613
	sub	[esp],edx
1619
	sub	[esp],edx
1614
      position_ok:
1620
      position_ok:
1615
	cmp	byte [esi],','
1621
	cmp	byte [esi],','
1616
	jne	size_ok
1622
	jne	size_ok
1617
	inc	esi
1623
	inc	esi
1618
	cmp	byte [esi],'('
1624
	cmp	byte [esi],'('
1619
	jne	invalid_argument
1625
	jne	invalid_argument
1620
	inc	esi
1626
	inc	esi
1621
	cmp	byte [esi],'.'
1627
	cmp	byte [esi],'.'
1622
	je	invalid_value
1628
	je	invalid_value
1623
	push	ebx edx
1629
	push	ebx edx
1624
	call	get_dword_value
1630
	call	get_dword_value
1625
	pop	edx ebx
1631
	pop	edx ebx
1626
	mov	[esp],eax
1632
	mov	[esp],eax
1627
      size_ok:
1633
      size_ok:
1628
	xor	al,al
1634
	xor	al,al
1629
	call	lseek
1635
	call	lseek
1630
	pop	ecx
1636
	pop	ecx
1631
	mov	edx,edi
1637
	mov	edx,edi
1632
	add	edi,ecx
1638
	add	edi,ecx
1633
	jc	out_of_memory
1639
	jc	out_of_memory
1634
	cmp	edi,[display_buffer]
1640
	cmp	edi,[display_buffer]
1635
	ja	out_of_memory
1641
	ja	out_of_memory
1636
	call	read
1642
	call	read
1637
	jc	error_reading_file
1643
	jc	error_reading_file
1638
	call	close
1644
	call	close
1639
	lods	byte [esi]
1645
	lods	byte [esi]
1640
	cmp	al,','
1646
	cmp	al,','
1641
	je	data_file
1647
	je	data_file
1642
	dec	esi
1648
	dec	esi
1643
	jmp	instruction_assembled
1649
	jmp	instruction_assembled
1644
      open_binary_file:
1650
      open_binary_file:
1645
	push	esi
1651
	push	esi
1646
	push	edi
1652
	push	edi
1647
	mov	esi,[current_line]
1653
	mov	esi,[current_line]
1648
	mov	esi,[esi]
1654
	mov	esi,[esi]
1649
      get_current_path:
1655
      get_current_path:
1650
	lodsb
1656
	lodsb
1651
	stosb
1657
	stosb
1652
	or	al,al
1658
	or	al,al
1653
	jnz	get_current_path
1659
	jnz	get_current_path
1654
      cut_current_path:
1660
      cut_current_path:
1655
	cmp	edi,[esp]
1661
	cmp	edi,[esp]
1656
	je	current_path_ok
1662
	je	current_path_ok
1657
	cmp	byte [edi-1],'\'
1663
	cmp	byte [edi-1],'\'
1658
	je	current_path_ok
1664
	je	current_path_ok
1659
	cmp	byte [edi-1],'/'
1665
	cmp	byte [edi-1],'/'
1660
	je	current_path_ok
1666
	je	current_path_ok
1661
	dec	edi
1667
	dec	edi
1662
	jmp	cut_current_path
1668
	jmp	cut_current_path
1663
      current_path_ok:
1669
      current_path_ok:
1664
	mov	esi,[esp+4]
1670
	mov	esi,[esp+4]
1665
	call	preprocess_path
1671
	call	preprocess_path
1666
	pop	edx
1672
	pop	edx
1667
	mov	esi,edx
1673
	mov	esi,edx
1668
	call	open
1674
	call	open
1669
	jnc	file_opened
1675
	jnc	file_opened
1670
	mov	edi,esi
1676
	mov	edi,esi
1671
	mov	esi,[esp]
1677
	mov	esi,[esp]
1672
	push	edi
1678
	push	edi
1673
	call	preprocess_path
1679
	call	preprocess_path
1674
	pop	edx
1680
	pop	edx
1675
	mov	esi,edx
1681
	mov	esi,edx
1676
	call	open
1682
	call	open
1677
	jc	file_not_found
1683
	jc	file_not_found
1678
      file_opened:
1684
      file_opened:
1679
	mov	edi,esi
1685
	mov	edi,esi
1680
	pop	esi
1686
	pop	esi
1681
	ret
1687
	ret
1682
reserve_bytes:
1688
reserve_bytes:
1683
	lods	byte [esi]
1689
	lods	byte [esi]
1684
	cmp	al,'('
1690
	cmp	al,'('
1685
	jne	invalid_argument
1691
	jne	invalid_argument
1686
	cmp	byte [esi],'.'
1692
	cmp	byte [esi],'.'
1687
	je	invalid_value
1693
	je	invalid_value
1688
	call	get_dword_value
1694
	call	get_dword_value
1689
	cmp	[next_pass_needed],0
1695
	cmp	[next_pass_needed],0
1690
	jne	rb_value_ok
1696
	jne	rb_value_ok
1691
	cmp	[value_type],0
1697
	cmp	[value_type],0
1692
	jne	invalid_use_of_symbol
1698
	jne	invalid_use_of_symbol
1693
      rb_value_ok:
1699
      rb_value_ok:
1694
	cmp	eax,0
1700
	cmp	eax,0
1695
	jl	reserve_negative
1701
	jl	reserve_negative
1696
	mov	ecx,eax
1702
	mov	ecx,eax
1697
	mov	edx,ecx
1703
	mov	edx,ecx
1698
	add	edx,edi
1704
	add	edx,edi
1699
	jc	out_of_memory
1705
	jc	out_of_memory
1700
	cmp	edx,[display_buffer]
1706
	cmp	edx,[display_buffer]
1701
	ja	out_of_memory
1707
	ja	out_of_memory
1702
	push	edi
1708
	push	edi
1703
	cmp	[next_pass_needed],0
1709
	cmp	[next_pass_needed],0
1704
	je	zero_bytes
1710
	je	zero_bytes
1705
	add	edi,ecx
1711
	add	edi,ecx
1706
	jmp	reserved_data
1712
	jmp	reserved_data
1707
      zero_bytes:
1713
      zero_bytes:
1708
	xor	eax,eax
1714
	xor	eax,eax
1709
	shr	ecx,1
1715
	shr	ecx,1
1710
	jnc	bytes_stosb_ok
1716
	jnc	bytes_stosb_ok
1711
	stos	byte [edi]
1717
	stos	byte [edi]
1712
      bytes_stosb_ok:
1718
      bytes_stosb_ok:
1713
	shr	ecx,1
1719
	shr	ecx,1
1714
	jnc	bytes_stosw_ok
1720
	jnc	bytes_stosw_ok
1715
	stos	word [edi]
1721
	stos	word [edi]
1716
      bytes_stosw_ok:
1722
      bytes_stosw_ok:
1717
	rep	stos dword [edi]
1723
	rep	stos dword [edi]
1718
      reserved_data:
1724
      reserved_data:
1719
	pop	eax
1725
	pop	eax
1720
	call	undefined_data
1726
	call	undefined_data
1721
	jmp	instruction_assembled
1727
	jmp	instruction_assembled
1722
      reserve_negative:
1728
      reserve_negative:
1723
	cmp	[error_line],0
1729
	cmp	[error_line],0
1724
	jne	instruction_assembled
1730
	jne	instruction_assembled
1725
	mov	eax,[current_line]
1731
	mov	eax,[current_line]
1726
	mov	[error_line],eax
1732
	mov	[error_line],eax
1727
	mov	[error],invalid_value
1733
	mov	[error],invalid_value
1728
	jmp	instruction_assembled
1734
	jmp	instruction_assembled
1729
reserve_words:
1735
reserve_words:
1730
	lods	byte [esi]
1736
	lods	byte [esi]
1731
	cmp	al,'('
1737
	cmp	al,'('
1732
	jne	invalid_argument
1738
	jne	invalid_argument
1733
	cmp	byte [esi],'.'
1739
	cmp	byte [esi],'.'
1734
	je	invalid_value
1740
	je	invalid_value
1735
	call	get_dword_value
1741
	call	get_dword_value
1736
	cmp	[next_pass_needed],0
1742
	cmp	[next_pass_needed],0
1737
	jne	rw_value_ok
1743
	jne	rw_value_ok
1738
	cmp	[value_type],0
1744
	cmp	[value_type],0
1739
	jne	invalid_use_of_symbol
1745
	jne	invalid_use_of_symbol
1740
      rw_value_ok:
1746
      rw_value_ok:
1741
	cmp	eax,0
1747
	cmp	eax,0
1742
	jl	reserve_negative
1748
	jl	reserve_negative
1743
	mov	ecx,eax
1749
	mov	ecx,eax
1744
	mov	edx,ecx
1750
	mov	edx,ecx
1745
	shl	edx,1
1751
	shl	edx,1
1746
	jc	out_of_memory
1752
	jc	out_of_memory
1747
	add	edx,edi
1753
	add	edx,edi
1748
	jc	out_of_memory
1754
	jc	out_of_memory
1749
	cmp	edx,[display_buffer]
1755
	cmp	edx,[display_buffer]
1750
	ja	out_of_memory
1756
	ja	out_of_memory
1751
	push	edi
1757
	push	edi
1752
	cmp	[next_pass_needed],0
1758
	cmp	[next_pass_needed],0
1753
	je	zero_words
1759
	je	zero_words
1754
	lea	edi,[edi+ecx*2]
1760
	lea	edi,[edi+ecx*2]
1755
	jmp	reserved_data
1761
	jmp	reserved_data
1756
      zero_words:
1762
      zero_words:
1757
	xor	eax,eax
1763
	xor	eax,eax
1758
	shr	ecx,1
1764
	shr	ecx,1
1759
	jnc	words_stosw_ok
1765
	jnc	words_stosw_ok
1760
	stos	word [edi]
1766
	stos	word [edi]
1761
      words_stosw_ok:
1767
      words_stosw_ok:
1762
	rep	stos dword [edi]
1768
	rep	stos dword [edi]
1763
	jmp	reserved_data
1769
	jmp	reserved_data
1764
reserve_dwords:
1770
reserve_dwords:
1765
	lods	byte [esi]
1771
	lods	byte [esi]
1766
	cmp	al,'('
1772
	cmp	al,'('
1767
	jne	invalid_argument
1773
	jne	invalid_argument
1768
	cmp	byte [esi],'.'
1774
	cmp	byte [esi],'.'
1769
	je	invalid_value
1775
	je	invalid_value
1770
	call	get_dword_value
1776
	call	get_dword_value
1771
	cmp	[next_pass_needed],0
1777
	cmp	[next_pass_needed],0
1772
	jne	rd_value_ok
1778
	jne	rd_value_ok
1773
	cmp	[value_type],0
1779
	cmp	[value_type],0
1774
	jne	invalid_use_of_symbol
1780
	jne	invalid_use_of_symbol
1775
      rd_value_ok:
1781
      rd_value_ok:
1776
	cmp	eax,0
1782
	cmp	eax,0
1777
	jl	reserve_negative
1783
	jl	reserve_negative
1778
	mov	ecx,eax
1784
	mov	ecx,eax
1779
	mov	edx,ecx
1785
	mov	edx,ecx
1780
	shl	edx,1
1786
	shl	edx,1
1781
	jc	out_of_memory
1787
	jc	out_of_memory
1782
	shl	edx,1
1788
	shl	edx,1
1783
	jc	out_of_memory
1789
	jc	out_of_memory
1784
	add	edx,edi
1790
	add	edx,edi
1785
	jc	out_of_memory
1791
	jc	out_of_memory
1786
	cmp	edx,[display_buffer]
1792
	cmp	edx,[display_buffer]
1787
	ja	out_of_memory
1793
	ja	out_of_memory
1788
	push	edi
1794
	push	edi
1789
	cmp	[next_pass_needed],0
1795
	cmp	[next_pass_needed],0
1790
	je	zero_dwords
1796
	je	zero_dwords
1791
	lea	edi,[edi+ecx*4]
1797
	lea	edi,[edi+ecx*4]
1792
	jmp	reserved_data
1798
	jmp	reserved_data
1793
      zero_dwords:
1799
      zero_dwords:
1794
	xor	eax,eax
1800
	xor	eax,eax
1795
	rep	stos dword [edi]
1801
	rep	stos dword [edi]
1796
	jmp	reserved_data
1802
	jmp	reserved_data
1797
reserve_pwords:
1803
reserve_pwords:
1798
	lods	byte [esi]
1804
	lods	byte [esi]
1799
	cmp	al,'('
1805
	cmp	al,'('
1800
	jne	invalid_argument
1806
	jne	invalid_argument
1801
	cmp	byte [esi],'.'
1807
	cmp	byte [esi],'.'
1802
	je	invalid_value
1808
	je	invalid_value
1803
	call	get_dword_value
1809
	call	get_dword_value
1804
	cmp	[next_pass_needed],0
1810
	cmp	[next_pass_needed],0
1805
	jne	rp_value_ok
1811
	jne	rp_value_ok
1806
	cmp	[value_type],0
1812
	cmp	[value_type],0
1807
	jne	invalid_use_of_symbol
1813
	jne	invalid_use_of_symbol
1808
      rp_value_ok:
1814
      rp_value_ok:
1809
	cmp	eax,0
1815
	cmp	eax,0
1810
	jl	reserve_negative
1816
	jl	reserve_negative
1811
	mov	ecx,eax
1817
	mov	ecx,eax
1812
	shl	ecx,1
1818
	shl	ecx,1
1813
	jc	out_of_memory
1819
	jc	out_of_memory
1814
	add	ecx,eax
1820
	add	ecx,eax
1815
	mov	edx,ecx
1821
	mov	edx,ecx
1816
	shl	edx,1
1822
	shl	edx,1
1817
	jc	out_of_memory
1823
	jc	out_of_memory
1818
	add	edx,edi
1824
	add	edx,edi
1819
	jc	out_of_memory
1825
	jc	out_of_memory
1820
	cmp	edx,[display_buffer]
1826
	cmp	edx,[display_buffer]
1821
	ja	out_of_memory
1827
	ja	out_of_memory
1822
	push	edi
1828
	push	edi
1823
	cmp	[next_pass_needed],0
1829
	cmp	[next_pass_needed],0
1824
	je	zero_words
1830
	je	zero_words
1825
	lea	edi,[edi+ecx*2]
1831
	lea	edi,[edi+ecx*2]
1826
	jmp	reserved_data
1832
	jmp	reserved_data
1827
reserve_qwords:
1833
reserve_qwords:
1828
	lods	byte [esi]
1834
	lods	byte [esi]
1829
	cmp	al,'('
1835
	cmp	al,'('
1830
	jne	invalid_argument
1836
	jne	invalid_argument
1831
	cmp	byte [esi],'.'
1837
	cmp	byte [esi],'.'
1832
	je	invalid_value
1838
	je	invalid_value
1833
	call	get_dword_value
1839
	call	get_dword_value
1834
	cmp	[next_pass_needed],0
1840
	cmp	[next_pass_needed],0
1835
	jne	rq_value_ok
1841
	jne	rq_value_ok
1836
	cmp	[value_type],0
1842
	cmp	[value_type],0
1837
	jne	invalid_use_of_symbol
1843
	jne	invalid_use_of_symbol
1838
      rq_value_ok:
1844
      rq_value_ok:
1839
	cmp	eax,0
1845
	cmp	eax,0
1840
	jl	reserve_negative
1846
	jl	reserve_negative
1841
	mov	ecx,eax
1847
	mov	ecx,eax
1842
	shl	ecx,1
1848
	shl	ecx,1
1843
	jc	out_of_memory
1849
	jc	out_of_memory
1844
	mov	edx,ecx
1850
	mov	edx,ecx
1845
	shl	edx,1
1851
	shl	edx,1
1846
	jc	out_of_memory
1852
	jc	out_of_memory
1847
	shl	edx,1
1853
	shl	edx,1
1848
	jc	out_of_memory
1854
	jc	out_of_memory
1849
	add	edx,edi
1855
	add	edx,edi
1850
	jc	out_of_memory
1856
	jc	out_of_memory
1851
	cmp	edx,[display_buffer]
1857
	cmp	edx,[display_buffer]
1852
	ja	out_of_memory
1858
	ja	out_of_memory
1853
	push	edi
1859
	push	edi
1854
	cmp	[next_pass_needed],0
1860
	cmp	[next_pass_needed],0
1855
	je	zero_dwords
1861
	je	zero_dwords
1856
	lea	edi,[edi+ecx*4]
1862
	lea	edi,[edi+ecx*4]
1857
	jmp	reserved_data
1863
	jmp	reserved_data
1858
reserve_twords:
1864
reserve_twords:
1859
	lods	byte [esi]
1865
	lods	byte [esi]
1860
	cmp	al,'('
1866
	cmp	al,'('
1861
	jne	invalid_argument
1867
	jne	invalid_argument
1862
	cmp	byte [esi],'.'
1868
	cmp	byte [esi],'.'
1863
	je	invalid_value
1869
	je	invalid_value
1864
	call	get_dword_value
1870
	call	get_dword_value
1865
	cmp	[next_pass_needed],0
1871
	cmp	[next_pass_needed],0
1866
	jne	rt_value_ok
1872
	jne	rt_value_ok
1867
	cmp	[value_type],0
1873
	cmp	[value_type],0
1868
	jne	invalid_use_of_symbol
1874
	jne	invalid_use_of_symbol
1869
      rt_value_ok:
1875
      rt_value_ok:
1870
	cmp	eax,0
1876
	cmp	eax,0
1871
	jl	reserve_negative
1877
	jl	reserve_negative
1872
	mov	ecx,eax
1878
	mov	ecx,eax
1873
	shl	ecx,2
1879
	shl	ecx,2
1874
	jc	out_of_memory
1880
	jc	out_of_memory
1875
	add	ecx,eax
1881
	add	ecx,eax
1876
	mov	edx,ecx
1882
	mov	edx,ecx
1877
	shl	edx,1
1883
	shl	edx,1
1878
	jc	out_of_memory
1884
	jc	out_of_memory
1879
	add	edx,edi
1885
	add	edx,edi
1880
	jc	out_of_memory
1886
	jc	out_of_memory
1881
	cmp	edx,[display_buffer]
1887
	cmp	edx,[display_buffer]
1882
	ja	out_of_memory
1888
	ja	out_of_memory
1883
	push	edi
1889
	push	edi
1884
	cmp	[next_pass_needed],0
1890
	cmp	[next_pass_needed],0
1885
	je	zero_words
1891
	je	zero_words
1886
	lea	edi,[edi+ecx*2]
1892
	lea	edi,[edi+ecx*2]
1887
	jmp	reserved_data
1893
	jmp	reserved_data
1888
align_directive:
1894
align_directive:
1889
	lods	byte [esi]
1895
	lods	byte [esi]
1890
	cmp	al,'('
1896
	cmp	al,'('
1891
	jne	invalid_argument
1897
	jne	invalid_argument
1892
	cmp	byte [esi],'.'
1898
	cmp	byte [esi],'.'
1893
	je	invalid_value
1899
	je	invalid_value
1894
	call	get_dword_value
1900
	call	get_dword_value
1895
	cmp	[value_type],0
1901
	cmp	[value_type],0
1896
	jne	invalid_use_of_symbol
1902
	jne	invalid_use_of_symbol
1897
	mov	edx,eax
1903
	mov	edx,eax
1898
	dec	edx
1904
	dec	edx
1899
	test	eax,edx
1905
	test	eax,edx
1900
	jnz	negative_times
1906
	jnz	negative_times
1901
	or	eax,eax
1907
	or	eax,eax
1902
	jz	negative_times
1908
	jz	negative_times
1903
	cmp	eax,1
1909
	cmp	eax,1
1904
	je	instruction_assembled
1910
	je	instruction_assembled
1905
	mov	ecx,edi
1911
	mov	ecx,edi
1906
	sub	ecx,dword [org_origin]
1912
	sub	ecx,dword [org_origin]
1907
	cmp	[org_registers],0
1913
	cmp	[org_registers],0
1908
	jne	section_not_aligned_enough
1914
	jne	section_not_aligned_enough
1909
	cmp	[labels_type],0
1915
	cmp	[labels_type],0
1910
	je	make_alignment
1916
	je	make_alignment
1911
	cmp	[output_format],3
1917
	cmp	[output_format],3
1912
	je	pe_alignment
1918
	je	pe_alignment
1913
	mov	ebx,[org_symbol]
1919
	mov	ebx,[org_symbol]
1914
	cmp	byte [ebx],0
1920
	cmp	byte [ebx],0
1915
	jne	section_not_aligned_enough
1921
	jne	section_not_aligned_enough
1916
	cmp	eax,[ebx+10h]
1922
	cmp	eax,[ebx+10h]
1917
	jbe	make_alignment
1923
	jbe	make_alignment
1918
	jmp	section_not_aligned_enough
1924
	jmp	section_not_aligned_enough
1919
      pe_alignment:
1925
      pe_alignment:
1920
	cmp	eax,1000h
1926
	cmp	eax,1000h
1921
	ja	section_not_aligned_enough
1927
	ja	section_not_aligned_enough
1922
      make_alignment:
1928
      make_alignment:
1923
	dec	eax
1929
	dec	eax
1924
	and	ecx,eax
1930
	and	ecx,eax
1925
	jz	instruction_assembled
1931
	jz	instruction_assembled
1926
	neg	ecx
1932
	neg	ecx
1927
	add	ecx,eax
1933
	add	ecx,eax
1928
	inc	ecx
1934
	inc	ecx
1929
	mov	edx,ecx
1935
	mov	edx,ecx
1930
	add	edx,edi
1936
	add	edx,edi
1931
	jc	out_of_memory
1937
	jc	out_of_memory
1932
	cmp	edx,[display_buffer]
1938
	cmp	edx,[display_buffer]
1933
	ja	out_of_memory
1939
	ja	out_of_memory
1934
	push	edi
1940
	push	edi
1935
	cmp	[next_pass_needed],0
1941
	cmp	[next_pass_needed],0
1936
	je	nops
1942
	je	nops
1937
	add	edi,ecx
1943
	add	edi,ecx
1938
	jmp	reserved_data
1944
	jmp	reserved_data
1939
      nops:
1945
      nops:
1940
	mov	eax,90909090h
1946
	mov	eax,90909090h
1941
	shr	ecx,1
1947
	shr	ecx,1
1942
	jnc	nops_stosb_ok
1948
	jnc	nops_stosb_ok
1943
	stos	byte [edi]
1949
	stos	byte [edi]
1944
      nops_stosb_ok:
1950
      nops_stosb_ok:
1945
	shr	ecx,1
1951
	shr	ecx,1
1946
	jnc	nops_stosw_ok
1952
	jnc	nops_stosw_ok
1947
	stos	word [edi]
1953
	stos	word [edi]
1948
      nops_stosw_ok:
1954
      nops_stosw_ok:
1949
	rep	stos dword [edi]
1955
	rep	stos dword [edi]
1950
	jmp	reserved_data
1956
	jmp	reserved_data