Subversion Repositories Kolibri OS

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
9353 leency 1
 
2
; Copyright (c) 1999-2019, Tomasz Grysztar.
3
; All rights reserved.
4
5
 
6
	cmp	[code_type],64
7
	je	illegal_instruction
8
simple_instruction:
9
	stos	byte [edi]
10
	jmp	instruction_assembled
11
simple_instruction_only64:
12
	cmp	[code_type],64
13
	jne	illegal_instruction
14
	jmp	simple_instruction
15
simple_instruction_16bit_except64:
16
	cmp	[code_type],64
17
	je	illegal_instruction
18
simple_instruction_16bit:
19
	cmp	[code_type],16
20
	jne	size_prefix
21
	stos	byte [edi]
22
	jmp	instruction_assembled
23
      size_prefix:
24
	mov	ah,al
25
	mov	al,66h
26
	stos	word [edi]
27
	jmp	instruction_assembled
28
simple_instruction_32bit_except64:
29
	cmp	[code_type],64
30
	je	illegal_instruction
31
simple_instruction_32bit:
32
	cmp	[code_type],16
33
	je	size_prefix
34
	stos	byte [edi]
35
	jmp	instruction_assembled
36
iret_instruction:
37
	cmp	[code_type],64
38
	jne	simple_instruction
39
simple_instruction_64bit:
40
	cmp	[code_type],64
41
	jne	illegal_instruction
42
	mov	ah,al
43
	mov	al,48h
44
	stos	word [edi]
45
	jmp	instruction_assembled
46
simple_extended_instruction_64bit:
47
	cmp	[code_type],64
48
	jne	illegal_instruction
49
	mov	byte [edi],48h
50
	inc	edi
51
simple_extended_instruction:
52
	mov	ah,al
53
	mov	al,0Fh
54
	stos	word [edi]
55
	jmp	instruction_assembled
56
simple_extended_instruction_f3:
57
	mov	byte [edi],0F3h
58
	inc	edi
59
	jmp	simple_extended_instruction
60
prefix_instruction:
61
	stos	byte [edi]
62
	or	[prefix_flags],1
63
	jmp	continue_line
64
segment_prefix:
65
	mov	ah,al
66
	shr	ah,4
67
	cmp	ah,3
68
	jne	illegal_instruction
69
	and	al,1111b
70
	mov	[segment_register],al
71
	call	store_segment_prefix
72
	or	[prefix_flags],1
73
	jmp	continue_line
74
bnd_prefix_instruction:
75
	stos	byte [edi]
76
	or	[prefix_flags],1 + 10h
77
	jmp	continue_line
78
int_instruction:
79
	lods	byte [esi]
80
	call	get_size_operator
81
	cmp	ah,1
82
	ja	invalid_operand_size
83
	cmp	al,'('
84
	jne	invalid_operand
85
	call	get_byte_value
86
	test	eax,eax
87
	jns	int_imm_ok
88
	call	recoverable_overflow
89
      int_imm_ok:
90
	mov	ah,al
91
	mov	al,0CDh
92
	stos	word [edi]
93
	jmp	instruction_assembled
94
aa_instruction:
95
	cmp	[code_type],64
96
	je	illegal_instruction
97
	push	eax
98
	mov	bl,10
99
	cmp	byte [esi],'('
100
	jne	aa_store
101
	inc	esi
102
	xor	al,al
103
	xchg	al,[operand_size]
104
	cmp	al,1
105
	ja	invalid_operand_size
106
	call	get_byte_value
107
	mov	bl,al
108
      aa_store:
109
	cmp	[operand_size],0
110
	jne	invalid_operand
111
	pop	eax
112
	mov	ah,bl
113
	stos	word [edi]
114
	jmp	instruction_assembled
115
116
 
117
	mov	[base_code],al
118
	lods	byte [esi]
119
	call	get_size_operator
120
	cmp	al,10h
121
	je	basic_reg
122
	cmp	al,'['
123
	jne	invalid_operand
124
      basic_mem:
125
	call	get_address
126
	push	edx ebx ecx
127
	lods	byte [esi]
128
	cmp	al,','
129
	jne	invalid_operand
130
	lods	byte [esi]
131
	call	get_size_operator
132
	cmp	al,'('
133
	je	basic_mem_imm
134
	cmp	al,10h
135
	jne	invalid_operand
136
      basic_mem_reg:
137
	lods	byte [esi]
138
	call	convert_register
139
	mov	[postbyte_register],al
140
	pop	ecx ebx edx
141
	mov	al,ah
142
	cmp	al,1
143
	je	instruction_ready
144
	call	operand_autodetect
145
	inc	[base_code]
146
      instruction_ready:
147
	call	store_instruction
148
	jmp	instruction_assembled
149
      basic_mem_imm:
150
	mov	al,[operand_size]
151
	cmp	al,1
152
	jb	basic_mem_imm_nosize
153
	je	basic_mem_imm_8bit
154
	cmp	al,2
155
	je	basic_mem_imm_16bit
156
	cmp	al,4
157
	je	basic_mem_imm_32bit
158
	cmp	al,8
159
	jne	invalid_operand_size
160
      basic_mem_imm_64bit:
161
	cmp	[size_declared],0
162
	jne	long_immediate_not_encodable
163
	call	operand_64bit
164
	call	get_simm32
165
	cmp	[value_type],4
166
	jae	long_immediate_not_encodable
167
	jmp	basic_mem_imm_32bit_ok
168
      basic_mem_imm_nosize:
169
	call	recoverable_unknown_size
170
      basic_mem_imm_8bit:
171
	call	get_byte_value
172
	mov	byte [value],al
173
	mov	al,[base_code]
174
	shr	al,3
175
	mov	[postbyte_register],al
176
	pop	ecx ebx edx
177
	mov	[base_code],80h
178
	call	store_instruction_with_imm8
179
	jmp	instruction_assembled
180
      basic_mem_imm_16bit:
181
	call	operand_16bit
182
	call	get_word_value
183
	mov	word [value],ax
184
	mov	al,[base_code]
185
	shr	al,3
186
	mov	[postbyte_register],al
187
	pop	ecx ebx edx
188
	cmp	[value_type],0
189
	jne	basic_mem_imm_16bit_store
190
	cmp	[size_declared],0
191
	jne	basic_mem_imm_16bit_store
192
	cmp	word [value],80h
193
	jb	basic_mem_simm_8bit
194
	cmp	word [value],-80h
195
	jae	basic_mem_simm_8bit
196
      basic_mem_imm_16bit_store:
197
	mov	[base_code],81h
198
	call	store_instruction_with_imm16
199
	jmp	instruction_assembled
200
      basic_mem_simm_8bit:
201
	mov	[base_code],83h
202
	call	store_instruction_with_imm8
203
	jmp	instruction_assembled
204
      basic_mem_imm_32bit:
205
	call	operand_32bit
206
	call	get_dword_value
207
      basic_mem_imm_32bit_ok:
208
	mov	dword [value],eax
209
	mov	al,[base_code]
210
	shr	al,3
211
	mov	[postbyte_register],al
212
	pop	ecx ebx edx
213
	cmp	[value_type],0
214
	jne	basic_mem_imm_32bit_store
215
	cmp	[size_declared],0
216
	jne	basic_mem_imm_32bit_store
217
	cmp	dword [value],80h
218
	jb	basic_mem_simm_8bit
219
	cmp	dword [value],-80h
220
	jae	basic_mem_simm_8bit
221
      basic_mem_imm_32bit_store:
222
	mov	[base_code],81h
223
	call	store_instruction_with_imm32
224
	jmp	instruction_assembled
225
      get_simm32:
226
	call	get_qword_value
227
	mov	ecx,edx
228
	cdq
229
	cmp	ecx,edx
230
	jne	value_out_of_range
231
	cmp	[value_type],4
232
	jne	get_simm32_ok
233
	mov	[value_type],2
234
      get_simm32_ok:
235
	ret
236
      basic_reg:
237
	lods	byte [esi]
238
	call	convert_register
239
	mov	[postbyte_register],al
240
	lods	byte [esi]
241
	cmp	al,','
242
	jne	invalid_operand
243
	lods	byte [esi]
244
	call	get_size_operator
245
	cmp	al,10h
246
	je	basic_reg_reg
247
	cmp	al,'('
248
	je	basic_reg_imm
249
	cmp	al,'['
250
	jne	invalid_operand
251
      basic_reg_mem:
252
	call	get_address
253
	mov	al,[operand_size]
254
	cmp	al,1
255
	je	basic_reg_mem_8bit
256
	call	operand_autodetect
257
	add	[base_code],3
258
	jmp	instruction_ready
259
      basic_reg_mem_8bit:
260
	add	[base_code],2
261
	jmp	instruction_ready
262
      basic_reg_reg:
263
	lods	byte [esi]
264
	call	convert_register
265
	mov	bl,[postbyte_register]
266
	mov	[postbyte_register],al
267
	mov	al,ah
268
	cmp	al,1
269
	je	nomem_instruction_ready
270
	call	operand_autodetect
271
	inc	[base_code]
272
      nomem_instruction_ready:
273
	call	store_nomem_instruction
274
	jmp	instruction_assembled
275
      basic_reg_imm:
276
	mov	al,[operand_size]
277
	cmp	al,1
278
	je	basic_reg_imm_8bit
279
	cmp	al,2
280
	je	basic_reg_imm_16bit
281
	cmp	al,4
282
	je	basic_reg_imm_32bit
283
	cmp	al,8
284
	jne	invalid_operand_size
285
      basic_reg_imm_64bit:
286
	cmp	[size_declared],0
287
	jne	long_immediate_not_encodable
288
	call	operand_64bit
289
	call	get_simm32
290
	cmp	[value_type],4
291
	jae	long_immediate_not_encodable
292
	jmp	basic_reg_imm_32bit_ok
293
      basic_reg_imm_8bit:
294
	call	get_byte_value
295
	mov	dl,al
296
	mov	bl,[base_code]
297
	shr	bl,3
298
	xchg	bl,[postbyte_register]
299
	or	bl,bl
300
	jz	basic_al_imm
301
	mov	[base_code],80h
302
	call	store_nomem_instruction
303
	mov	al,dl
304
	stos	byte [edi]
305
	jmp	instruction_assembled
306
      basic_al_imm:
307
	mov	al,[base_code]
308
	add	al,4
309
	stos	byte [edi]
310
	mov	al,dl
311
	stos	byte [edi]
312
	jmp	instruction_assembled
313
      basic_reg_imm_16bit:
314
	call	operand_16bit
315
	call	get_word_value
316
	mov	dx,ax
317
	mov	bl,[base_code]
318
	shr	bl,3
319
	xchg	bl,[postbyte_register]
320
	cmp	[value_type],0
321
	jne	basic_reg_imm_16bit_store
322
	cmp	[size_declared],0
323
	jne	basic_reg_imm_16bit_store
324
	cmp	dx,80h
325
	jb	basic_reg_simm_8bit
326
	cmp	dx,-80h
327
	jae	basic_reg_simm_8bit
328
      basic_reg_imm_16bit_store:
329
	or	bl,bl
330
	jz	basic_ax_imm
331
	mov	[base_code],81h
332
	call	store_nomem_instruction
333
      basic_store_imm_16bit:
334
	mov	ax,dx
335
	call	mark_relocation
336
	stos	word [edi]
337
	jmp	instruction_assembled
338
      basic_reg_simm_8bit:
339
	mov	[base_code],83h
340
	call	store_nomem_instruction
341
	mov	al,dl
342
	stos	byte [edi]
343
	jmp	instruction_assembled
344
      basic_ax_imm:
345
	add	[base_code],5
346
	call	store_classic_instruction_code
347
	jmp	basic_store_imm_16bit
348
      basic_reg_imm_32bit:
349
	call	operand_32bit
350
	call	get_dword_value
351
      basic_reg_imm_32bit_ok:
352
	mov	edx,eax
353
	mov	bl,[base_code]
354
	shr	bl,3
355
	xchg	bl,[postbyte_register]
356
	cmp	[value_type],0
357
	jne	basic_reg_imm_32bit_store
358
	cmp	[size_declared],0
359
	jne	basic_reg_imm_32bit_store
360
	cmp	edx,80h
361
	jb	basic_reg_simm_8bit
362
	cmp	edx,-80h
363
	jae	basic_reg_simm_8bit
364
      basic_reg_imm_32bit_store:
365
	or	bl,bl
366
	jz	basic_eax_imm
367
	mov	[base_code],81h
368
	call	store_nomem_instruction
369
      basic_store_imm_32bit:
370
	mov	eax,edx
371
	call	mark_relocation
372
	stos	dword [edi]
373
	jmp	instruction_assembled
374
      basic_eax_imm:
375
	add	[base_code],5
376
	call	store_classic_instruction_code
377
	jmp	basic_store_imm_32bit
378
      recoverable_unknown_size:
379
	cmp	[error_line],0
380
	jne	ignore_unknown_size
381
	push	[current_line]
382
	pop	[error_line]
383
	mov	[error],operand_size_not_specified
384
      ignore_unknown_size:
385
	ret
386
single_operand_instruction:
387
	mov	[base_code],0F6h
388
	mov	[postbyte_register],al
389
	lods	byte [esi]
390
	call	get_size_operator
391
	cmp	al,10h
392
	je	single_reg
393
	cmp	al,'['
394
	jne	invalid_operand
395
      single_mem:
396
	call	get_address
397
	mov	al,[operand_size]
398
	cmp	al,1
399
	je	single_mem_8bit
400
	jb	single_mem_nosize
401
	call	operand_autodetect
402
	inc	[base_code]
403
	jmp	instruction_ready
404
      single_mem_nosize:
405
	call	recoverable_unknown_size
406
      single_mem_8bit:
407
	jmp	instruction_ready
408
      single_reg:
409
	lods	byte [esi]
410
	call	convert_register
411
	mov	bl,al
412
	mov	al,ah
413
	cmp	al,1
414
	je	single_reg_8bit
415
	call	operand_autodetect
416
	inc	[base_code]
417
      single_reg_8bit:
418
	jmp	nomem_instruction_ready
419
mov_instruction:
420
	mov	[base_code],88h
421
	lods	byte [esi]
422
	call	get_size_operator
423
	cmp	al,10h
424
	je	mov_reg
425
	cmp	al,14h
426
	je	mov_creg
427
	cmp	al,'['
428
	jne	invalid_operand
429
      mov_mem:
430
	call	get_address
431
	push	edx ebx ecx
432
	lods	byte [esi]
433
	cmp	al,','
434
	jne	invalid_operand
435
	lods	byte [esi]
436
	call	get_size_operator
437
	cmp	al,'('
438
	je	mov_mem_imm
439
	cmp	al,10h
440
	jne	invalid_operand
441
      mov_mem_reg:
442
	lods	byte [esi]
443
	cmp	al,30h
444
	jb	mov_mem_general_reg
445
	cmp	al,40h
446
	jb	mov_mem_sreg
447
      mov_mem_general_reg:
448
	call	convert_register
449
	mov	[postbyte_register],al
450
	pop	ecx ebx edx
451
	cmp	ah,1
452
	je	mov_mem_reg_8bit
453
	inc	[base_code]
454
	mov	al,ah
455
	call	operand_autodetect
456
	mov	al,[postbyte_register]
457
	or	al,bl
458
	or	al,bh
459
	jz	mov_mem_ax
460
	jmp	instruction_ready
461
      mov_mem_reg_8bit:
462
	or	al,bl
463
	or	al,bh
464
	jnz	instruction_ready
465
      mov_mem_al:
466
	test	ch,22h
467
	jnz	mov_mem_address16_al
468
	test	ch,44h
469
	jnz	mov_mem_address32_al
470
	test	ch,88h
471
	jnz	mov_mem_address64_al
472
	or	ch,ch
473
	jnz	invalid_address_size
474
	call	check_mov_address64
475
	cmp	al,0
476
	jg	mov_mem_address64_al
477
	jl	instruction_ready
478
	cmp	[code_type],16
479
	jne	mov_mem_address32_al
480
	cmp	edx,10000h
481
	jb	mov_mem_address16_al
482
      mov_mem_address32_al:
483
	call	store_segment_prefix_if_necessary
484
	call	address_32bit_prefix
485
	mov	[base_code],0A2h
486
      store_mov_address32:
487
	call	store_classic_instruction_code
488
	call	store_address_32bit_value
489
	jmp	instruction_assembled
490
      mov_mem_address16_al:
491
	call	store_segment_prefix_if_necessary
492
	call	address_16bit_prefix
493
	mov	[base_code],0A2h
494
      store_mov_address16:
495
	cmp	[code_type],64
496
	je	invalid_address
497
	call	store_classic_instruction_code
498
	mov	eax,edx
499
	stos	word [edi]
500
	cmp	edx,10000h
501
	jge	value_out_of_range
502
	jmp	instruction_assembled
503
      check_mov_address64:
504
	cmp	[code_type],64
505
	jne	no_address64
506
	mov	eax,[address_high]
507
	or	eax,eax
508
	jz	no_address64
509
	bt	edx,31
510
	adc	eax,0
511
	jz	address64_simm32
512
      address64_required:
513
	mov	al,1
514
	ret
515
      address64_simm32:
516
	mov	al,-1
517
	ret
518
      no_address64:
519
	xor	al,al
520
	ret
521
      mov_mem_address64_al:
522
	call	store_segment_prefix_if_necessary
523
	mov	[base_code],0A2h
524
      store_mov_address64:
525
	call	store_classic_instruction_code
526
	call	store_address_64bit_value
527
	jmp	instruction_assembled
528
      mov_mem_ax:
529
	test	ch,22h
530
	jnz	mov_mem_address16_ax
531
	test	ch,44h
532
	jnz	mov_mem_address32_ax
533
	test	ch,88h
534
	jnz	mov_mem_address64_ax
535
	or	ch,ch
536
	jnz	invalid_address_size
537
	call	check_mov_address64
538
	cmp	al,0
539
	jg	mov_mem_address64_ax
540
	jl	instruction_ready
541
	cmp	[code_type],16
542
	jne	mov_mem_address32_ax
543
	cmp	edx,10000h
544
	jb	mov_mem_address16_ax
545
      mov_mem_address32_ax:
546
	call	store_segment_prefix_if_necessary
547
	call	address_32bit_prefix
548
	mov	[base_code],0A3h
549
	jmp	store_mov_address32
550
      mov_mem_address16_ax:
551
	call	store_segment_prefix_if_necessary
552
	call	address_16bit_prefix
553
	mov	[base_code],0A3h
554
	jmp	store_mov_address16
555
      mov_mem_address64_ax:
556
	call	store_segment_prefix_if_necessary
557
	mov	[base_code],0A3h
558
	jmp	store_mov_address64
559
      mov_mem_sreg:
560
	sub	al,31h
561
	mov	[postbyte_register],al
562
	pop	ecx ebx edx
563
	mov	ah,[operand_size]
564
	or	ah,ah
565
	jz	mov_mem_sreg_store
566
	cmp	ah,2
567
	jne	invalid_operand_size
568
      mov_mem_sreg_store:
569
	mov	[base_code],8Ch
570
	jmp	instruction_ready
571
      mov_mem_imm:
572
	mov	al,[operand_size]
573
	cmp	al,1
574
	jb	mov_mem_imm_nosize
575
	je	mov_mem_imm_8bit
576
	cmp	al,2
577
	je	mov_mem_imm_16bit
578
	cmp	al,4
579
	je	mov_mem_imm_32bit
580
	cmp	al,8
581
	jne	invalid_operand_size
582
      mov_mem_imm_64bit:
583
	cmp	[size_declared],0
584
	jne	long_immediate_not_encodable
585
	call	operand_64bit
586
	call	get_simm32
587
	cmp	[value_type],4
588
	jae	long_immediate_not_encodable
589
	jmp	mov_mem_imm_32bit_store
590
      mov_mem_imm_nosize:
591
	call	recoverable_unknown_size
592
      mov_mem_imm_8bit:
593
	call	get_byte_value
594
	mov	byte [value],al
595
	mov	[postbyte_register],0
596
	mov	[base_code],0C6h
597
	pop	ecx ebx edx
598
	call	store_instruction_with_imm8
599
	jmp	instruction_assembled
600
      mov_mem_imm_16bit:
601
	call	operand_16bit
602
	call	get_word_value
603
	mov	word [value],ax
604
	mov	[postbyte_register],0
605
	mov	[base_code],0C7h
606
	pop	ecx ebx edx
607
	call	store_instruction_with_imm16
608
	jmp	instruction_assembled
609
      mov_mem_imm_32bit:
610
	call	operand_32bit
611
	call	get_dword_value
612
      mov_mem_imm_32bit_store:
613
	mov	dword [value],eax
614
	mov	[postbyte_register],0
615
	mov	[base_code],0C7h
616
	pop	ecx ebx edx
617
	call	store_instruction_with_imm32
618
	jmp	instruction_assembled
619
      mov_reg:
620
	lods	byte [esi]
621
	mov	ah,al
622
	sub	ah,10h
623
	and	ah,al
624
	test	ah,0F0h
625
	jnz	mov_sreg
626
	call	convert_register
627
	mov	[postbyte_register],al
628
	lods	byte [esi]
629
	cmp	al,','
630
	jne	invalid_operand
631
	lods	byte [esi]
632
	call	get_size_operator
633
	cmp	al,'['
634
	je	mov_reg_mem
635
	cmp	al,'('
636
	je	mov_reg_imm
637
	cmp	al,14h
638
	je	mov_reg_creg
639
	cmp	al,10h
640
	jne	invalid_operand
641
      mov_reg_reg:
642
	lods	byte [esi]
643
	mov	ah,al
644
	sub	ah,10h
645
	and	ah,al
646
	test	ah,0F0h
647
	jnz	mov_reg_sreg
648
	call	convert_register
649
	mov	bl,[postbyte_register]
650
	mov	[postbyte_register],al
651
	mov	al,ah
652
	cmp	al,1
653
	je	mov_reg_reg_8bit
654
	call	operand_autodetect
655
	inc	[base_code]
656
      mov_reg_reg_8bit:
657
	jmp	nomem_instruction_ready
658
      mov_reg_sreg:
659
	mov	bl,[postbyte_register]
660
	mov	ah,al
661
	and	al,1111b
662
	mov	[postbyte_register],al
663
	shr	ah,4
664
	cmp	ah,3
665
	jne	invalid_operand
666
	dec	[postbyte_register]
667
	cmp	[operand_size],8
668
	je	mov_reg_sreg64
669
	cmp	[operand_size],4
670
	je	mov_reg_sreg32
671
	cmp	[operand_size],2
672
	jne	invalid_operand_size
673
	call	operand_16bit
674
	jmp	mov_reg_sreg_store
675
      mov_reg_sreg64:
676
	call	operand_64bit
677
	jmp	mov_reg_sreg_store
678
      mov_reg_sreg32:
679
	call	operand_32bit
680
      mov_reg_sreg_store:
681
	mov	[base_code],8Ch
682
	jmp	nomem_instruction_ready
683
      mov_reg_creg:
684
	lods	byte [esi]
685
	mov	bl,al
686
	shr	al,4
687
	cmp	al,4
688
	ja	invalid_operand
689
	add	al,20h
690
	mov	[extended_code],al
691
	and	bl,1111b
692
	xchg	bl,[postbyte_register]
693
	mov	[base_code],0Fh
694
	cmp	[code_type],64
695
	je	mov_reg_creg_64bit
696
	cmp	[operand_size],4
697
	jne	invalid_operand_size
698
	cmp	[postbyte_register],8
699
	jb	mov_reg_creg_store
700
	cmp	[extended_code],20h
701
	jne	mov_reg_creg_store
702
	mov	al,0F0h
703
	stos	byte [edi]
704
	mov	[postbyte_register],0
705
      mov_reg_creg_store:
706
	jmp	nomem_instruction_ready
707
      mov_reg_creg_64bit:
708
	cmp	[operand_size],8
709
	jne	invalid_operand_size
710
	jmp	nomem_instruction_ready
711
      mov_reg_mem:
712
	add	[base_code],2
713
	call	get_address
714
	mov	al,[operand_size]
715
	cmp	al,1
716
	je	mov_reg_mem_8bit
717
	inc	[base_code]
718
	call	operand_autodetect
719
	mov	al,[postbyte_register]
720
	or	al,bl
721
	or	al,bh
722
	jz	mov_ax_mem
723
	jmp	instruction_ready
724
      mov_reg_mem_8bit:
725
	mov	al,[postbyte_register]
726
	or	al,bl
727
	or	al,bh
728
	jz	mov_al_mem
729
	jmp	instruction_ready
730
      mov_al_mem:
731
	test	ch,22h
732
	jnz	mov_al_mem_address16
733
	test	ch,44h
734
	jnz	mov_al_mem_address32
735
	test	ch,88h
736
	jnz	mov_al_mem_address64
737
	or	ch,ch
738
	jnz	invalid_address_size
739
	call	check_mov_address64
740
	cmp	al,0
741
	jg	mov_al_mem_address64
742
	jl	instruction_ready
743
	cmp	[code_type],16
744
	jne	mov_al_mem_address32
745
	cmp	edx,10000h
746
	jb	mov_al_mem_address16
747
      mov_al_mem_address32:
748
	call	store_segment_prefix_if_necessary
749
	call	address_32bit_prefix
750
	mov	[base_code],0A0h
751
	jmp	store_mov_address32
752
      mov_al_mem_address16:
753
	call	store_segment_prefix_if_necessary
754
	call	address_16bit_prefix
755
	mov	[base_code],0A0h
756
	jmp	store_mov_address16
757
      mov_al_mem_address64:
758
	call	store_segment_prefix_if_necessary
759
	mov	[base_code],0A0h
760
	jmp	store_mov_address64
761
      mov_ax_mem:
762
	test	ch,22h
763
	jnz	mov_ax_mem_address16
764
	test	ch,44h
765
	jnz	mov_ax_mem_address32
766
	test	ch,88h
767
	jnz	mov_ax_mem_address64
768
	or	ch,ch
769
	jnz	invalid_address_size
770
	call	check_mov_address64
771
	cmp	al,0
772
	jg	mov_ax_mem_address64
773
	jl	instruction_ready
774
	cmp	[code_type],16
775
	jne	mov_ax_mem_address32
776
	cmp	edx,10000h
777
	jb	mov_ax_mem_address16
778
      mov_ax_mem_address32:
779
	call	store_segment_prefix_if_necessary
780
	call	address_32bit_prefix
781
	mov	[base_code],0A1h
782
	jmp	store_mov_address32
783
      mov_ax_mem_address16:
784
	call	store_segment_prefix_if_necessary
785
	call	address_16bit_prefix
786
	mov	[base_code],0A1h
787
	jmp	store_mov_address16
788
      mov_ax_mem_address64:
789
	call	store_segment_prefix_if_necessary
790
	mov	[base_code],0A1h
791
	jmp	store_mov_address64
792
      mov_reg_imm:
793
	mov	al,[operand_size]
794
	cmp	al,1
795
	je	mov_reg_imm_8bit
796
	cmp	al,2
797
	je	mov_reg_imm_16bit
798
	cmp	al,4
799
	je	mov_reg_imm_32bit
800
	cmp	al,8
801
	jne	invalid_operand_size
802
      mov_reg_imm_64bit:
803
	call	operand_64bit
804
	call	get_qword_value
805
	mov	ecx,edx
806
	cmp	[size_declared],0
807
	jne	mov_reg_imm_64bit_store
808
	cmp	[value_type],4
809
	jae	mov_reg_imm_64bit_store
810
	cdq
811
	cmp	ecx,edx
812
	je	mov_reg_64bit_imm_32bit
813
      mov_reg_imm_64bit_store:
814
	push	eax ecx
815
	mov	al,0B8h
816
	call	store_mov_reg_imm_code
817
	pop	edx eax
818
	call	mark_relocation
819
	stos	dword [edi]
820
	mov	eax,edx
821
	stos	dword [edi]
822
	jmp	instruction_assembled
823
      mov_reg_imm_8bit:
824
	call	get_byte_value
825
	mov	dl,al
826
	mov	al,0B0h
827
	call	store_mov_reg_imm_code
828
	mov	al,dl
829
	stos	byte [edi]
830
	jmp	instruction_assembled
831
      mov_reg_imm_16bit:
832
	call	get_word_value
833
	mov	dx,ax
834
	call	operand_16bit
835
	mov	al,0B8h
836
	call	store_mov_reg_imm_code
837
	mov	ax,dx
838
	call	mark_relocation
839
	stos	word [edi]
840
	jmp	instruction_assembled
841
      mov_reg_imm_32bit:
842
	call	operand_32bit
843
	call	get_dword_value
844
	mov	edx,eax
845
	mov	al,0B8h
846
	call	store_mov_reg_imm_code
847
      mov_store_imm_32bit:
848
	mov	eax,edx
849
	call	mark_relocation
850
	stos	dword [edi]
851
	jmp	instruction_assembled
852
      store_mov_reg_imm_code:
853
	mov	ah,[postbyte_register]
854
	test	ah,1000b
855
	jz	mov_reg_imm_prefix_ok
856
	or	[rex_prefix],41h
857
      mov_reg_imm_prefix_ok:
858
	and	ah,111b
859
	add	al,ah
860
	mov	[base_code],al
861
	call	store_classic_instruction_code
862
	ret
863
      mov_reg_64bit_imm_32bit:
864
	mov	edx,eax
865
	mov	bl,[postbyte_register]
866
	mov	[postbyte_register],0
867
	mov	[base_code],0C7h
868
	call	store_nomem_instruction
869
	jmp	mov_store_imm_32bit
870
      mov_sreg:
871
	mov	ah,al
872
	and	al,1111b
873
	mov	[postbyte_register],al
874
	shr	ah,4
875
	cmp	ah,3
876
	jne	invalid_operand
877
	cmp	al,2
878
	je	illegal_instruction
879
	dec	[postbyte_register]
880
	lods	byte [esi]
881
	cmp	al,','
882
	jne	invalid_operand
883
	lods	byte [esi]
884
	call	get_size_operator
885
	cmp	al,'['
886
	je	mov_sreg_mem
887
	cmp	al,10h
888
	jne	invalid_operand
889
      mov_sreg_reg:
890
	lods	byte [esi]
891
	call	convert_register
892
	or	ah,ah
893
	jz	mov_sreg_reg_size_ok
894
	cmp	ah,2
895
	jne	invalid_operand_size
896
	mov	bl,al
897
      mov_sreg_reg_size_ok:
898
	mov	[base_code],8Eh
899
	jmp	nomem_instruction_ready
900
      mov_sreg_mem:
901
	call	get_address
902
	mov	al,[operand_size]
903
	or	al,al
904
	jz	mov_sreg_mem_size_ok
905
	cmp	al,2
906
	jne	invalid_operand_size
907
      mov_sreg_mem_size_ok:
908
	mov	[base_code],8Eh
909
	jmp	instruction_ready
910
      mov_creg:
911
	lods	byte [esi]
912
	mov	ah,al
913
	shr	ah,4
914
	cmp	ah,4
915
	ja	invalid_operand
916
	add	ah,22h
917
	mov	[extended_code],ah
918
	and	al,1111b
919
	mov	[postbyte_register],al
920
	mov	[base_code],0Fh
921
	lods	byte [esi]
922
	cmp	al,','
923
	jne	invalid_operand
924
	call	take_register
925
	mov	bl,al
926
	cmp	[code_type],64
927
	je	mov_creg_64bit
928
	cmp	ah,4
929
	jne	invalid_operand_size
930
	cmp	[postbyte_register],8
931
	jb	mov_creg_store
932
	cmp	[extended_code],22h
933
	jne	mov_creg_store
934
	mov	al,0F0h
935
	stos	byte [edi]
936
	mov	[postbyte_register],0
937
      mov_creg_store:
938
	jmp	nomem_instruction_ready
939
      mov_creg_64bit:
940
	cmp	ah,8
941
	je	mov_creg_store
942
	jmp	invalid_operand_size
943
test_instruction:
944
	mov	[base_code],84h
945
	lods	byte [esi]
946
	call	get_size_operator
947
	cmp	al,10h
948
	je	test_reg
949
	cmp	al,'['
950
	jne	invalid_operand
951
      test_mem:
952
	call	get_address
953
	push	edx ebx ecx
954
	lods	byte [esi]
955
	cmp	al,','
956
	jne	invalid_operand
957
	lods	byte [esi]
958
	call	get_size_operator
959
	cmp	al,'('
960
	je	test_mem_imm
961
	cmp	al,10h
962
	jne	invalid_operand
963
      test_mem_reg:
964
	lods	byte [esi]
965
	call	convert_register
966
	mov	[postbyte_register],al
967
	pop	ecx ebx edx
968
	mov	al,ah
969
	cmp	al,1
970
	je	test_mem_reg_8bit
971
	call	operand_autodetect
972
	inc	[base_code]
973
      test_mem_reg_8bit:
974
	jmp	instruction_ready
975
      test_mem_imm:
976
	mov	al,[operand_size]
977
	cmp	al,1
978
	jb	test_mem_imm_nosize
979
	je	test_mem_imm_8bit
980
	cmp	al,2
981
	je	test_mem_imm_16bit
982
	cmp	al,4
983
	je	test_mem_imm_32bit
984
	cmp	al,8
985
	jne	invalid_operand_size
986
      test_mem_imm_64bit:
987
	cmp	[size_declared],0
988
	jne	long_immediate_not_encodable
989
	call	operand_64bit
990
	call	get_simm32
991
	cmp	[value_type],4
992
	jae	long_immediate_not_encodable
993
	jmp	test_mem_imm_32bit_store
994
      test_mem_imm_nosize:
995
	call	recoverable_unknown_size
996
      test_mem_imm_8bit:
997
	call	get_byte_value
998
	mov	byte [value],al
999
	mov	[postbyte_register],0
1000
	mov	[base_code],0F6h
1001
	pop	ecx ebx edx
1002
	call	store_instruction_with_imm8
1003
	jmp	instruction_assembled
1004
      test_mem_imm_16bit:
1005
	call	operand_16bit
1006
	call	get_word_value
1007
	mov	word [value],ax
1008
	mov	[postbyte_register],0
1009
	mov	[base_code],0F7h
1010
	pop	ecx ebx edx
1011
	call	store_instruction_with_imm16
1012
	jmp	instruction_assembled
1013
      test_mem_imm_32bit:
1014
	call	operand_32bit
1015
	call	get_dword_value
1016
      test_mem_imm_32bit_store:
1017
	mov	dword [value],eax
1018
	mov	[postbyte_register],0
1019
	mov	[base_code],0F7h
1020
	pop	ecx ebx edx
1021
	call	store_instruction_with_imm32
1022
	jmp	instruction_assembled
1023
      test_reg:
1024
	lods	byte [esi]
1025
	call	convert_register
1026
	mov	[postbyte_register],al
1027
	lods	byte [esi]
1028
	cmp	al,','
1029
	jne	invalid_operand
1030
	lods	byte [esi]
1031
	call	get_size_operator
1032
	cmp	al,'['
1033
	je	test_reg_mem
1034
	cmp	al,'('
1035
	je	test_reg_imm
1036
	cmp	al,10h
1037
	jne	invalid_operand
1038
      test_reg_reg:
1039
	lods	byte [esi]
1040
	call	convert_register
1041
	mov	bl,[postbyte_register]
1042
	mov	[postbyte_register],al
1043
	mov	al,ah
1044
	cmp	al,1
1045
	je	test_reg_reg_8bit
1046
	call	operand_autodetect
1047
	inc	[base_code]
1048
      test_reg_reg_8bit:
1049
	jmp	nomem_instruction_ready
1050
      test_reg_imm:
1051
	mov	al,[operand_size]
1052
	cmp	al,1
1053
	je	test_reg_imm_8bit
1054
	cmp	al,2
1055
	je	test_reg_imm_16bit
1056
	cmp	al,4
1057
	je	test_reg_imm_32bit
1058
	cmp	al,8
1059
	jne	invalid_operand_size
1060
      test_reg_imm_64bit:
1061
	cmp	[size_declared],0
1062
	jne	long_immediate_not_encodable
1063
	call	operand_64bit
1064
	call	get_simm32
1065
	cmp	[value_type],4
1066
	jae	long_immediate_not_encodable
1067
	jmp	test_reg_imm_32bit_store
1068
      test_reg_imm_8bit:
1069
	call	get_byte_value
1070
	mov	dl,al
1071
	mov	bl,[postbyte_register]
1072
	mov	[postbyte_register],0
1073
	mov	[base_code],0F6h
1074
	or	bl,bl
1075
	jz	test_al_imm
1076
	call	store_nomem_instruction
1077
	mov	al,dl
1078
	stos	byte [edi]
1079
	jmp	instruction_assembled
1080
      test_al_imm:
1081
	mov	[base_code],0A8h
1082
	call	store_classic_instruction_code
1083
	mov	al,dl
1084
	stos	byte [edi]
1085
	jmp	instruction_assembled
1086
      test_reg_imm_16bit:
1087
	call	operand_16bit
1088
	call	get_word_value
1089
	mov	dx,ax
1090
	mov	bl,[postbyte_register]
1091
	mov	[postbyte_register],0
1092
	mov	[base_code],0F7h
1093
	or	bl,bl
1094
	jz	test_ax_imm
1095
	call	store_nomem_instruction
1096
	mov	ax,dx
1097
	call	mark_relocation
1098
	stos	word [edi]
1099
	jmp	instruction_assembled
1100
      test_ax_imm:
1101
	mov	[base_code],0A9h
1102
	call	store_classic_instruction_code
1103
	mov	ax,dx
1104
	stos	word [edi]
1105
	jmp	instruction_assembled
1106
      test_reg_imm_32bit:
1107
	call	operand_32bit
1108
	call	get_dword_value
1109
      test_reg_imm_32bit_store:
1110
	mov	edx,eax
1111
	mov	bl,[postbyte_register]
1112
	mov	[postbyte_register],0
1113
	mov	[base_code],0F7h
1114
	or	bl,bl
1115
	jz	test_eax_imm
1116
	call	store_nomem_instruction
1117
	mov	eax,edx
1118
	call	mark_relocation
1119
	stos	dword [edi]
1120
	jmp	instruction_assembled
1121
      test_eax_imm:
1122
	mov	[base_code],0A9h
1123
	call	store_classic_instruction_code
1124
	mov	eax,edx
1125
	stos	dword [edi]
1126
	jmp	instruction_assembled
1127
      test_reg_mem:
1128
	call	get_address
1129
	mov	al,[operand_size]
1130
	cmp	al,1
1131
	je	test_reg_mem_8bit
1132
	call	operand_autodetect
1133
	inc	[base_code]
1134
      test_reg_mem_8bit:
1135
	jmp	instruction_ready
1136
xchg_instruction:
1137
	mov	[base_code],86h
1138
	lods	byte [esi]
1139
	call	get_size_operator
1140
	cmp	al,10h
1141
	je	xchg_reg
1142
	cmp	al,'['
1143
	jne	invalid_operand
1144
      xchg_mem:
1145
	call	get_address
1146
	push	edx ebx ecx
1147
	lods	byte [esi]
1148
	cmp	al,','
1149
	jne	invalid_operand
1150
	lods	byte [esi]
1151
	call	get_size_operator
1152
	cmp	al,10h
1153
	je	test_mem_reg
1154
	jmp	invalid_operand
1155
      xchg_reg:
1156
	lods	byte [esi]
1157
	call	convert_register
1158
	mov	[postbyte_register],al
1159
	lods	byte [esi]
1160
	cmp	al,','
1161
	jne	invalid_operand
1162
	lods	byte [esi]
1163
	call	get_size_operator
1164
	cmp	al,'['
1165
	je	test_reg_mem
1166
	cmp	al,10h
1167
	jne	invalid_operand
1168
      xchg_reg_reg:
1169
	lods	byte [esi]
1170
	call	convert_register
1171
	mov	bl,al
1172
	mov	al,ah
1173
	cmp	al,1
1174
	je	xchg_reg_reg_8bit
1175
	call	operand_autodetect
1176
	cmp	[postbyte_register],0
1177
	je	xchg_ax_reg
1178
	or	bl,bl
1179
	jnz	xchg_reg_reg_store
1180
	mov	bl,[postbyte_register]
1181
      xchg_ax_reg:
1182
	cmp	[code_type],64
1183
	jne	xchg_ax_reg_ok
1184
	cmp	ah,4
1185
	jne	xchg_ax_reg_ok
1186
	or	bl,bl
1187
	jz	xchg_reg_reg_store
1188
      xchg_ax_reg_ok:
1189
	test	bl,1000b
1190
	jz	xchg_ax_reg_store
1191
	or	[rex_prefix],41h
1192
	and	bl,111b
1193
      xchg_ax_reg_store:
1194
	add	bl,90h
1195
	mov	[base_code],bl
1196
	call	store_classic_instruction_code
1197
	jmp	instruction_assembled
1198
      xchg_reg_reg_store:
1199
	inc	[base_code]
1200
      xchg_reg_reg_8bit:
1201
	jmp	nomem_instruction_ready
1202
push_instruction:
1203
	mov	[push_size],al
1204
      push_next:
1205
	lods	byte [esi]
1206
	call	get_size_operator
1207
	cmp	al,10h
1208
	je	push_reg
1209
	cmp	al,'('
1210
	je	push_imm
1211
	cmp	al,'['
1212
	jne	invalid_operand
1213
      push_mem:
1214
	call	get_address
1215
	mov	al,[operand_size]
1216
	mov	ah,[push_size]
1217
	cmp	al,2
1218
	je	push_mem_16bit
1219
	cmp	al,4
1220
	je	push_mem_32bit
1221
	cmp	al,8
1222
	je	push_mem_64bit
1223
	or	al,al
1224
	jnz	invalid_operand_size
1225
	cmp	ah,2
1226
	je	push_mem_16bit
1227
	cmp	ah,4
1228
	je	push_mem_32bit
1229
	cmp	ah,8
1230
	je	push_mem_64bit
1231
	call	recoverable_unknown_size
1232
	jmp	push_mem_store
1233
      push_mem_16bit:
1234
	test	ah,not 2
1235
	jnz	invalid_operand_size
1236
	call	operand_16bit
1237
	jmp	push_mem_store
1238
      push_mem_32bit:
1239
	test	ah,not 4
1240
	jnz	invalid_operand_size
1241
	cmp	[code_type],64
1242
	je	illegal_instruction
1243
	call	operand_32bit
1244
	jmp	push_mem_store
1245
      push_mem_64bit:
1246
	test	ah,not 8
1247
	jnz	invalid_operand_size
1248
	cmp	[code_type],64
1249
	jne	illegal_instruction
1250
      push_mem_store:
1251
	mov	[base_code],0FFh
1252
	mov	[postbyte_register],110b
1253
	call	store_instruction
1254
	jmp	push_done
1255
      push_reg:
1256
	lods	byte [esi]
1257
	mov	ah,al
1258
	sub	ah,10h
1259
	and	ah,al
1260
	test	ah,0F0h
1261
	jnz	push_sreg
1262
	call	convert_register
1263
	test	al,1000b
1264
	jz	push_reg_ok
1265
	or	[rex_prefix],41h
1266
	and	al,111b
1267
      push_reg_ok:
1268
	add	al,50h
1269
	mov	[base_code],al
1270
	mov	al,ah
1271
	mov	ah,[push_size]
1272
	cmp	al,2
1273
	je	push_reg_16bit
1274
	cmp	al,4
1275
	je	push_reg_32bit
1276
	cmp	al,8
1277
	jne	invalid_operand_size
1278
      push_reg_64bit:
1279
	test	ah,not 8
1280
	jnz	invalid_operand_size
1281
	cmp	[code_type],64
1282
	jne	illegal_instruction
1283
	jmp	push_reg_store
1284
      push_reg_32bit:
1285
	test	ah,not 4
1286
	jnz	invalid_operand_size
1287
	cmp	[code_type],64
1288
	je	illegal_instruction
1289
	call	operand_32bit
1290
	jmp	push_reg_store
1291
      push_reg_16bit:
1292
	test	ah,not 2
1293
	jnz	invalid_operand_size
1294
	call	operand_16bit
1295
      push_reg_store:
1296
	call	store_classic_instruction_code
1297
	jmp	push_done
1298
      push_sreg:
1299
	mov	bl,al
1300
	mov	dl,[operand_size]
1301
	mov	dh,[push_size]
1302
	cmp	dl,2
1303
	je	push_sreg16
1304
	cmp	dl,4
1305
	je	push_sreg32
1306
	cmp	dl,8
1307
	je	push_sreg64
1308
	or	dl,dl
1309
	jnz	invalid_operand_size
1310
	cmp	dh,2
1311
	je	push_sreg16
1312
	cmp	dh,4
1313
	je	push_sreg32
1314
	cmp	dh,8
1315
	je	push_sreg64
1316
	jmp	push_sreg_store
1317
      push_sreg16:
1318
	test	dh,not 2
1319
	jnz	invalid_operand_size
1320
	call	operand_16bit
1321
	jmp	push_sreg_store
1322
      push_sreg32:
1323
	test	dh,not 4
1324
	jnz	invalid_operand_size
1325
	cmp	[code_type],64
1326
	je	illegal_instruction
1327
	call	operand_32bit
1328
	jmp	push_sreg_store
1329
      push_sreg64:
1330
	test	dh,not 8
1331
	jnz	invalid_operand_size
1332
	cmp	[code_type],64
1333
	jne	illegal_instruction
1334
      push_sreg_store:
1335
	mov	al,bl
1336
	cmp	al,40h
1337
	jae	invalid_operand
1338
	sub	al,31h
1339
	jc	invalid_operand
1340
	cmp	al,4
1341
	jae	push_sreg_386
1342
	shl	al,3
1343
	add	al,6
1344
	mov	[base_code],al
1345
	cmp	[code_type],64
1346
	je	illegal_instruction
1347
	jmp	push_reg_store
1348
      push_sreg_386:
1349
	sub	al,4
1350
	shl	al,3
1351
	add	al,0A0h
1352
	mov	[extended_code],al
1353
	mov	[base_code],0Fh
1354
	jmp	push_reg_store
1355
      push_imm:
1356
	mov	al,[operand_size]
1357
	mov	ah,[push_size]
1358
	or	al,al
1359
	je	push_imm_size_ok
1360
	or	ah,ah
1361
	je	push_imm_size_ok
1362
	cmp	al,ah
1363
	jne	invalid_operand_size
1364
      push_imm_size_ok:
1365
	cmp	al,2
1366
	je	push_imm_16bit
1367
	cmp	al,4
1368
	je	push_imm_32bit
1369
	cmp	al,8
1370
	je	push_imm_64bit
1371
	cmp	ah,2
1372
	je	push_imm_optimized_16bit
1373
	cmp	ah,4
1374
	je	push_imm_optimized_32bit
1375
	cmp	ah,8
1376
	je	push_imm_optimized_64bit
1377
	or	al,al
1378
	jnz	invalid_operand_size
1379
	cmp	[code_type],16
1380
	je	push_imm_optimized_16bit
1381
	cmp	[code_type],32
1382
	je	push_imm_optimized_32bit
1383
      push_imm_optimized_64bit:
1384
	cmp	[code_type],64
1385
	jne	illegal_instruction
1386
	call	get_simm32
1387
	mov	edx,eax
1388
	cmp	[value_type],0
1389
	jne	push_imm_32bit_store
1390
	cmp	eax,-80h
1391
	jl	push_imm_32bit_store
1392
	cmp	eax,80h
1393
	jge	push_imm_32bit_store
1394
	jmp	push_imm_8bit
1395
      push_imm_optimized_32bit:
1396
	cmp	[code_type],64
1397
	je	illegal_instruction
1398
	call	get_dword_value
1399
	mov	edx,eax
1400
	call	operand_32bit
1401
	cmp	[value_type],0
1402
	jne	push_imm_32bit_store
1403
	cmp	eax,-80h
1404
	jl	push_imm_32bit_store
1405
	cmp	eax,80h
1406
	jge	push_imm_32bit_store
1407
	jmp	push_imm_8bit
1408
      push_imm_optimized_16bit:
1409
	call	get_word_value
1410
	mov	dx,ax
1411
	call	operand_16bit
1412
	cmp	[value_type],0
1413
	jne	push_imm_16bit_store
1414
	cmp	ax,-80h
1415
	jl	push_imm_16bit_store
1416
	cmp	ax,80h
1417
	jge	push_imm_16bit_store
1418
      push_imm_8bit:
1419
	mov	ah,al
1420
	mov	[base_code],6Ah
1421
	call	store_classic_instruction_code
1422
	mov	al,ah
1423
	stos	byte [edi]
1424
	jmp	push_done
1425
      push_imm_16bit:
1426
	call	get_word_value
1427
	mov	dx,ax
1428
	call	operand_16bit
1429
      push_imm_16bit_store:
1430
	mov	[base_code],68h
1431
	call	store_classic_instruction_code
1432
	mov	ax,dx
1433
	call	mark_relocation
1434
	stos	word [edi]
1435
	jmp	push_done
1436
      push_imm_64bit:
1437
	cmp	[code_type],64
1438
	jne	illegal_instruction
1439
	call	get_simm32
1440
	mov	edx,eax
1441
	jmp	push_imm_32bit_store
1442
      push_imm_32bit:
1443
	cmp	[code_type],64
1444
	je	illegal_instruction
1445
	call	get_dword_value
1446
	mov	edx,eax
1447
	call	operand_32bit
1448
      push_imm_32bit_store:
1449
	mov	[base_code],68h
1450
	call	store_classic_instruction_code
1451
	mov	eax,edx
1452
	call	mark_relocation
1453
	stos	dword [edi]
1454
      push_done:
1455
	lods	byte [esi]
1456
	dec	esi
1457
	cmp	al,0Fh
1458
	je	instruction_assembled
1459
	or	al,al
1460
	jz	instruction_assembled
1461
;	 mov	 [operand_size],0
1462
;	 mov	 [operand_flags],0
1463
;	 mov	 [operand_prefix],0
1464
;	 mov	 [rex_prefix],0
1465
	and	dword [operand_size],0
1466
	jmp	push_next
1467
pop_instruction:
1468
	mov	[push_size],al
1469
      pop_next:
1470
	lods	byte [esi]
1471
	call	get_size_operator
1472
	cmp	al,10h
1473
	je	pop_reg
1474
	cmp	al,'['
1475
	jne	invalid_operand
1476
      pop_mem:
1477
	call	get_address
1478
	mov	al,[operand_size]
1479
	mov	ah,[push_size]
1480
	cmp	al,2
1481
	je	pop_mem_16bit
1482
	cmp	al,4
1483
	je	pop_mem_32bit
1484
	cmp	al,8
1485
	je	pop_mem_64bit
1486
	or	al,al
1487
	jnz	invalid_operand_size
1488
	cmp	ah,2
1489
	je	pop_mem_16bit
1490
	cmp	ah,4
1491
	je	pop_mem_32bit
1492
	cmp	ah,8
1493
	je	pop_mem_64bit
1494
	call	recoverable_unknown_size
1495
	jmp	pop_mem_store
1496
      pop_mem_16bit:
1497
	test	ah,not 2
1498
	jnz	invalid_operand_size
1499
	call	operand_16bit
1500
	jmp	pop_mem_store
1501
      pop_mem_32bit:
1502
	test	ah,not 4
1503
	jnz	invalid_operand_size
1504
	cmp	[code_type],64
1505
	je	illegal_instruction
1506
	call	operand_32bit
1507
	jmp	pop_mem_store
1508
      pop_mem_64bit:
1509
	test	ah,not 8
1510
	jnz	invalid_operand_size
1511
	cmp	[code_type],64
1512
	jne	illegal_instruction
1513
      pop_mem_store:
1514
	mov	[base_code],08Fh
1515
	mov	[postbyte_register],0
1516
	call	store_instruction
1517
	jmp	pop_done
1518
      pop_reg:
1519
	lods	byte [esi]
1520
	mov	ah,al
1521
	sub	ah,10h
1522
	and	ah,al
1523
	test	ah,0F0h
1524
	jnz	pop_sreg
1525
	call	convert_register
1526
	test	al,1000b
1527
	jz	pop_reg_ok
1528
	or	[rex_prefix],41h
1529
	and	al,111b
1530
      pop_reg_ok:
1531
	add	al,58h
1532
	mov	[base_code],al
1533
	mov	al,ah
1534
	mov	ah,[push_size]
1535
	cmp	al,2
1536
	je	pop_reg_16bit
1537
	cmp	al,4
1538
	je	pop_reg_32bit
1539
	cmp	al,8
1540
	je	pop_reg_64bit
1541
	jmp	invalid_operand_size
1542
      pop_reg_64bit:
1543
	test	ah,not 8
1544
	jnz	invalid_operand_size
1545
	cmp	[code_type],64
1546
	jne	illegal_instruction
1547
	jmp	pop_reg_store
1548
      pop_reg_32bit:
1549
	test	ah,not 4
1550
	jnz	invalid_operand_size
1551
	cmp	[code_type],64
1552
	je	illegal_instruction
1553
	call	operand_32bit
1554
	jmp	pop_reg_store
1555
      pop_reg_16bit:
1556
	test	ah,not 2
1557
	jnz	invalid_operand_size
1558
	call	operand_16bit
1559
      pop_reg_store:
1560
	call	store_classic_instruction_code
1561
      pop_done:
1562
	lods	byte [esi]
1563
	dec	esi
1564
	cmp	al,0Fh
1565
	je	instruction_assembled
1566
	or	al,al
1567
	jz	instruction_assembled
1568
;	 mov	 [operand_size],0
1569
;	 mov	 [operand_flags],0
1570
;	 mov	 [operand_prefix],0
1571
;	 mov	 [rex_prefix],0
1572
	and	dword [operand_size],0
1573
	jmp	pop_next
1574
      pop_sreg:
1575
	mov	dl,[operand_size]
1576
	mov	dh,[push_size]
1577
	cmp	al,32h
1578
	je	pop_cs
1579
	mov	bl,al
1580
	cmp	dl,2
1581
	je	pop_sreg16
1582
	cmp	dl,4
1583
	je	pop_sreg32
1584
	cmp	dl,8
1585
	je	pop_sreg64
1586
	or	dl,dl
1587
	jnz	invalid_operand_size
1588
	cmp	dh,2
1589
	je	pop_sreg16
1590
	cmp	dh,4
1591
	je	pop_sreg32
1592
	cmp	dh,8
1593
	je	pop_sreg64
1594
	jmp	pop_sreg_store
1595
      pop_sreg16:
1596
	test	dh,not 2
1597
	jnz	invalid_operand_size
1598
	call	operand_16bit
1599
	jmp	pop_sreg_store
1600
      pop_sreg32:
1601
	test	dh,not 4
1602
	jnz	invalid_operand_size
1603
	cmp	[code_type],64
1604
	je	illegal_instruction
1605
	call	operand_32bit
1606
	jmp	pop_sreg_store
1607
      pop_sreg64:
1608
	test	dh,not 8
1609
	jnz	invalid_operand_size
1610
	cmp	[code_type],64
1611
	jne	illegal_instruction
1612
      pop_sreg_store:
1613
	mov	al,bl
1614
	cmp	al,40h
1615
	jae	invalid_operand
1616
	sub	al,31h
1617
	jc	invalid_operand
1618
	cmp	al,4
1619
	jae	pop_sreg_386
1620
	shl	al,3
1621
	add	al,7
1622
	mov	[base_code],al
1623
	cmp	[code_type],64
1624
	je	illegal_instruction
1625
	jmp	pop_reg_store
1626
      pop_cs:
1627
	cmp	[code_type],16
1628
	jne	illegal_instruction
1629
	cmp	dl,2
1630
	je	pop_cs_store
1631
	or	dl,dl
1632
	jnz	invalid_operand_size
1633
	cmp	dh,2
1634
	je	pop_cs_store
1635
	or	dh,dh
1636
	jnz	illegal_instruction
1637
      pop_cs_store:
1638
	test	dh,not 2
1639
	jnz	invalid_operand_size
1640
	mov	al,0Fh
1641
	stos	byte [edi]
1642
	jmp	pop_done
1643
      pop_sreg_386:
1644
	sub	al,4
1645
	shl	al,3
1646
	add	al,0A1h
1647
	mov	[extended_code],al
1648
	mov	[base_code],0Fh
1649
	jmp	pop_reg_store
1650
inc_instruction:
1651
	mov	[base_code],al
1652
	lods	byte [esi]
1653
	call	get_size_operator
1654
	cmp	al,10h
1655
	je	inc_reg
1656
	cmp	al,'['
1657
	je	inc_mem
1658
	jne	invalid_operand
1659
      inc_mem:
1660
	call	get_address
1661
	mov	al,[operand_size]
1662
	cmp	al,1
1663
	je	inc_mem_8bit
1664
	jb	inc_mem_nosize
1665
	call	operand_autodetect
1666
	mov	al,0FFh
1667
	xchg	al,[base_code]
1668
	mov	[postbyte_register],al
1669
	jmp	instruction_ready
1670
      inc_mem_nosize:
1671
	call	recoverable_unknown_size
1672
      inc_mem_8bit:
1673
	mov	al,0FEh
1674
	xchg	al,[base_code]
1675
	mov	[postbyte_register],al
1676
	jmp	instruction_ready
1677
      inc_reg:
1678
	lods	byte [esi]
1679
	call	convert_register
1680
	mov	bl,al
1681
	mov	al,0FEh
1682
	xchg	al,[base_code]
1683
	mov	[postbyte_register],al
1684
	mov	al,ah
1685
	cmp	al,1
1686
	je	inc_reg_8bit
1687
	call	operand_autodetect
1688
	cmp	[code_type],64
1689
	je	inc_reg_long_form
1690
	mov	al,[postbyte_register]
1691
	shl	al,3
1692
	add	al,bl
1693
	add	al,40h
1694
	mov	[base_code],al
1695
	call	store_classic_instruction_code
1696
	jmp	instruction_assembled
1697
      inc_reg_long_form:
1698
	inc	[base_code]
1699
      inc_reg_8bit:
1700
	jmp	nomem_instruction_ready
1701
set_instruction:
1702
	mov	[base_code],0Fh
1703
	mov	[extended_code],al
1704
	lods	byte [esi]
1705
	call	get_size_operator
1706
	cmp	al,10h
1707
	je	set_reg
1708
	cmp	al,'['
1709
	jne	invalid_operand
1710
      set_mem:
1711
	call	get_address
1712
	cmp	[operand_size],1
1713
	ja	invalid_operand_size
1714
	mov	[postbyte_register],0
1715
	jmp	instruction_ready
1716
      set_reg:
1717
	lods	byte [esi]
1718
	call	convert_register
1719
	cmp	ah,1
1720
	jne	invalid_operand_size
1721
	mov	bl,al
1722
	mov	[postbyte_register],0
1723
	jmp	nomem_instruction_ready
1724
arpl_instruction:
1725
	cmp	[code_type],64
1726
	je	illegal_instruction
1727
	mov	[base_code],63h
1728
	lods	byte [esi]
1729
	call	get_size_operator
1730
	cmp	al,10h
1731
	je	arpl_reg
1732
	cmp	al,'['
1733
	jne	invalid_operand
1734
	call	get_address
1735
	lods	byte [esi]
1736
	cmp	al,','
1737
	jne	invalid_operand
1738
	call	take_register
1739
	mov	[postbyte_register],al
1740
	cmp	ah,2
1741
	jne	invalid_operand_size
1742
	jmp	instruction_ready
1743
      arpl_reg:
1744
	lods	byte [esi]
1745
	call	convert_register
1746
	cmp	ah,2
1747
	jne	invalid_operand_size
1748
	mov	bl,al
1749
	lods	byte [esi]
1750
	cmp	al,','
1751
	jne	invalid_operand
1752
	call	take_register
1753
	mov	[postbyte_register],al
1754
	jmp	nomem_instruction_ready
1755
bound_instruction:
1756
	cmp	[code_type],64
1757
	je	illegal_instruction
1758
	call	take_register
1759
	mov	[postbyte_register],al
1760
	lods	byte [esi]
1761
	cmp	al,','
1762
	jne	invalid_operand
1763
	lods	byte [esi]
1764
	call	get_size_operator
1765
	cmp	al,'['
1766
	jne	invalid_operand
1767
	call	get_address
1768
	mov	al,[operand_size]
1769
	cmp	al,2
1770
	je	bound_store
1771
	cmp	al,4
1772
	jne	invalid_operand_size
1773
      bound_store:
1774
	call	operand_autodetect
1775
	mov	[base_code],62h
1776
	jmp	instruction_ready
1777
enter_instruction:
1778
	lods	byte [esi]
1779
	call	get_size_operator
1780
	cmp	ah,2
1781
	je	enter_imm16_size_ok
1782
	or	ah,ah
1783
	jnz	invalid_operand_size
1784
      enter_imm16_size_ok:
1785
	cmp	al,'('
1786
	jne	invalid_operand
1787
	call	get_word_value
1788
	cmp	[next_pass_needed],0
1789
	jne	enter_imm16_ok
1790
	cmp	[value_type],0
1791
	jne	invalid_use_of_symbol
1792
	test	eax,eax
1793
	js	value_out_of_range
1794
      enter_imm16_ok:
1795
	push	eax
1796
	mov	[operand_size],0
1797
	lods	byte [esi]
1798
	cmp	al,','
1799
	jne	invalid_operand
1800
	lods	byte [esi]
1801
	call	get_size_operator
1802
	cmp	ah,1
1803
	je	enter_imm8_size_ok
1804
	or	ah,ah
1805
	jnz	invalid_operand_size
1806
      enter_imm8_size_ok:
1807
	cmp	al,'('
1808
	jne	invalid_operand
1809
	call	get_byte_value
1810
	cmp	[next_pass_needed],0
1811
	jne	enter_imm8_ok
1812
	test	eax,eax
1813
	js	value_out_of_range
1814
      enter_imm8_ok:
1815
	mov	dl,al
1816
	pop	ebx
1817
	mov	al,0C8h
1818
	stos	byte [edi]
1819
	mov	ax,bx
1820
	stos	word [edi]
1821
	mov	al,dl
1822
	stos	byte [edi]
1823
	jmp	instruction_assembled
1824
ret_instruction_only64:
1825
	cmp	[code_type],64
1826
	jne	illegal_instruction
1827
	jmp	ret_instruction
1828
ret_instruction_32bit_except64:
1829
	cmp	[code_type],64
1830
	je	illegal_instruction
1831
ret_instruction_32bit:
1832
	call	operand_32bit
1833
	jmp	ret_instruction
1834
ret_instruction_16bit:
1835
	call	operand_16bit
1836
	jmp	ret_instruction
1837
ret_instruction_64bit:
1838
	call	operand_64bit
1839
ret_instruction:
1840
	and	[prefix_flags],not 10h
1841
      ret_common:
1842
	mov	[base_code],al
1843
	lods	byte [esi]
1844
	dec	esi
1845
	or	al,al
1846
	jz	simple_ret
1847
	cmp	al,0Fh
1848
	je	simple_ret
1849
	lods	byte [esi]
1850
	call	get_size_operator
1851
	or	ah,ah
1852
	jz	ret_imm
1853
	cmp	ah,2
1854
	je	ret_imm
1855
	jmp	invalid_operand_size
1856
      ret_imm:
1857
	cmp	al,'('
1858
	jne	invalid_operand
1859
	call	get_word_value
1860
	cmp	[next_pass_needed],0
1861
	jne	ret_imm_ok
1862
	cmp	[value_type],0
1863
	jne	invalid_use_of_symbol
1864
	test	eax,eax
1865
	js	value_out_of_range
1866
      ret_imm_ok:
1867
	cmp	[size_declared],0
1868
	jne	ret_imm_store
1869
	or	ax,ax
1870
	jz	simple_ret
1871
      ret_imm_store:
1872
	mov	dx,ax
1873
	call	store_classic_instruction_code
1874
	mov	ax,dx
1875
	stos	word [edi]
1876
	jmp	instruction_assembled
1877
      simple_ret:
1878
	inc	[base_code]
1879
	call	store_classic_instruction_code
1880
	jmp	instruction_assembled
1881
retf_instruction:
1882
	cmp	[code_type],64
1883
	jne	ret_common
1884
retf_instruction_64bit:
1885
	call	operand_64bit
1886
	jmp	ret_common
1887
retf_instruction_32bit:
1888
	call	operand_32bit
1889
	jmp	ret_common
1890
retf_instruction_16bit:
1891
	call	operand_16bit
1892
	jmp	ret_common
1893
lea_instruction:
1894
	mov	[base_code],8Dh
1895
	call	take_register
1896
	mov	[postbyte_register],al
1897
	lods	byte [esi]
1898
	cmp	al,','
1899
	jne	invalid_operand
1900
	xor	al,al
1901
	xchg	al,[operand_size]
1902
	push	eax
1903
	lods	byte [esi]
1904
	call	get_size_operator
1905
	cmp	al,'['
1906
	jne	invalid_operand
1907
	or	[operand_flags],1
1908
	call	get_address
1909
	pop	eax
1910
	mov	[operand_size],al
1911
	call	operand_autodetect
1912
	jmp	instruction_ready
1913
ls_instruction:
1914
	or	al,al
1915
	jz	les_instruction
1916
	cmp	al,3
1917
	jz	lds_instruction
1918
	add	al,0B0h
1919
	mov	[extended_code],al
1920
	mov	[base_code],0Fh
1921
	jmp	ls_code_ok
1922
      les_instruction:
1923
	mov	[base_code],0C4h
1924
	jmp	ls_short_code
1925
      lds_instruction:
1926
	mov	[base_code],0C5h
1927
      ls_short_code:
1928
	cmp	[code_type],64
1929
	je	illegal_instruction
1930
      ls_code_ok:
1931
	call	take_register
1932
	mov	[postbyte_register],al
1933
	lods	byte [esi]
1934
	cmp	al,','
1935
	jne	invalid_operand
1936
	add	[operand_size],2
1937
	lods	byte [esi]
1938
	call	get_size_operator
1939
	cmp	al,'['
1940
	jne	invalid_operand
1941
	call	get_address
1942
	mov	al,[operand_size]
1943
	cmp	al,4
1944
	je	ls_16bit
1945
	cmp	al,6
1946
	je	ls_32bit
1947
	cmp	al,10
1948
	je	ls_64bit
1949
	jmp	invalid_operand_size
1950
      ls_16bit:
1951
	call	operand_16bit
1952
	jmp	instruction_ready
1953
      ls_32bit:
1954
	call	operand_32bit
1955
	jmp	instruction_ready
1956
      ls_64bit:
1957
	call	operand_64bit
1958
	jmp	instruction_ready
1959
sh_instruction:
1960
	mov	[postbyte_register],al
1961
	lods	byte [esi]
1962
	call	get_size_operator
1963
	cmp	al,10h
1964
	je	sh_reg
1965
	cmp	al,'['
1966
	jne	invalid_operand
1967
      sh_mem:
1968
	call	get_address
1969
	push	edx ebx ecx
1970
	mov	al,[operand_size]
1971
	push	eax
1972
	mov	[operand_size],0
1973
	lods	byte [esi]
1974
	cmp	al,','
1975
	jne	invalid_operand
1976
	lods	byte [esi]
1977
	call	get_size_operator
1978
	cmp	al,'('
1979
	je	sh_mem_imm
1980
	cmp	al,10h
1981
	jne	invalid_operand
1982
      sh_mem_reg:
1983
	lods	byte [esi]
1984
	cmp	al,11h
1985
	jne	invalid_operand
1986
	pop	eax ecx ebx edx
1987
	cmp	al,1
1988
	je	sh_mem_cl_8bit
1989
	jb	sh_mem_cl_nosize
1990
	call	operand_autodetect
1991
	mov	[base_code],0D3h
1992
	jmp	instruction_ready
1993
      sh_mem_cl_nosize:
1994
	call	recoverable_unknown_size
1995
      sh_mem_cl_8bit:
1996
	mov	[base_code],0D2h
1997
	jmp	instruction_ready
1998
      sh_mem_imm:
1999
	mov	al,[operand_size]
2000
	or	al,al
2001
	jz	sh_mem_imm_size_ok
2002
	cmp	al,1
2003
	jne	invalid_operand_size
2004
      sh_mem_imm_size_ok:
2005
	call	get_byte_value
2006
	mov	byte [value],al
2007
	pop	eax ecx ebx edx
2008
	cmp	al,1
2009
	je	sh_mem_imm_8bit
2010
	jb	sh_mem_imm_nosize
2011
	call	operand_autodetect
2012
	cmp	byte [value],1
2013
	je	sh_mem_1
2014
	mov	[base_code],0C1h
2015
	call	store_instruction_with_imm8
2016
	jmp	instruction_assembled
2017
      sh_mem_1:
2018
	mov	[base_code],0D1h
2019
	jmp	instruction_ready
2020
      sh_mem_imm_nosize:
2021
	call	recoverable_unknown_size
2022
      sh_mem_imm_8bit:
2023
	cmp	byte [value],1
2024
	je	sh_mem_1_8bit
2025
	mov	[base_code],0C0h
2026
	call	store_instruction_with_imm8
2027
	jmp	instruction_assembled
2028
      sh_mem_1_8bit:
2029
	mov	[base_code],0D0h
2030
	jmp	instruction_ready
2031
      sh_reg:
2032
	lods	byte [esi]
2033
	call	convert_register
2034
	mov	bx,ax
2035
	mov	[operand_size],0
2036
	lods	byte [esi]
2037
	cmp	al,','
2038
	jne	invalid_operand
2039
	lods	byte [esi]
2040
	call	get_size_operator
2041
	cmp	al,'('
2042
	je	sh_reg_imm
2043
	cmp	al,10h
2044
	jne	invalid_operand
2045
      sh_reg_reg:
2046
	lods	byte [esi]
2047
	cmp	al,11h
2048
	jne	invalid_operand
2049
	mov	al,bh
2050
	cmp	al,1
2051
	je	sh_reg_cl_8bit
2052
	call	operand_autodetect
2053
	mov	[base_code],0D3h
2054
	jmp	nomem_instruction_ready
2055
      sh_reg_cl_8bit:
2056
	mov	[base_code],0D2h
2057
	jmp	nomem_instruction_ready
2058
      sh_reg_imm:
2059
	mov	al,[operand_size]
2060
	or	al,al
2061
	jz	sh_reg_imm_size_ok
2062
	cmp	al,1
2063
	jne	invalid_operand_size
2064
      sh_reg_imm_size_ok:
2065
	push	ebx
2066
	call	get_byte_value
2067
	mov	dl,al
2068
	pop	ebx
2069
	mov	al,bh
2070
	cmp	al,1
2071
	je	sh_reg_imm_8bit
2072
	call	operand_autodetect
2073
	cmp	dl,1
2074
	je	sh_reg_1
2075
	mov	[base_code],0C1h
2076
	call	store_nomem_instruction
2077
	mov	al,dl
2078
	stos	byte [edi]
2079
	jmp	instruction_assembled
2080
      sh_reg_1:
2081
	mov	[base_code],0D1h
2082
	jmp	nomem_instruction_ready
2083
      sh_reg_imm_8bit:
2084
	cmp	dl,1
2085
	je	sh_reg_1_8bit
2086
	mov	[base_code],0C0h
2087
	call	store_nomem_instruction
2088
	mov	al,dl
2089
	stos	byte [edi]
2090
	jmp	instruction_assembled
2091
      sh_reg_1_8bit:
2092
	mov	[base_code],0D0h
2093
	jmp	nomem_instruction_ready
2094
shd_instruction:
2095
	mov	[base_code],0Fh
2096
	mov	[extended_code],al
2097
	lods	byte [esi]
2098
	call	get_size_operator
2099
	cmp	al,10h
2100
	je	shd_reg
2101
	cmp	al,'['
2102
	jne	invalid_operand
2103
      shd_mem:
2104
	call	get_address
2105
	push	edx ebx ecx
2106
	lods	byte [esi]
2107
	cmp	al,','
2108
	jne	invalid_operand
2109
	call	take_register
2110
	mov	[postbyte_register],al
2111
	lods	byte [esi]
2112
	cmp	al,','
2113
	jne	invalid_operand
2114
	mov	al,ah
2115
	mov	[operand_size],0
2116
	push	eax
2117
	lods	byte [esi]
2118
	call	get_size_operator
2119
	cmp	al,'('
2120
	je	shd_mem_reg_imm
2121
	cmp	al,10h
2122
	jne	invalid_operand
2123
	lods	byte [esi]
2124
	cmp	al,11h
2125
	jne	invalid_operand
2126
	pop	eax ecx ebx edx
2127
	call	operand_autodetect
2128
	inc	[extended_code]
2129
	jmp	instruction_ready
2130
      shd_mem_reg_imm:
2131
	mov	al,[operand_size]
2132
	or	al,al
2133
	jz	shd_mem_reg_imm_size_ok
2134
	cmp	al,1
2135
	jne	invalid_operand_size
2136
      shd_mem_reg_imm_size_ok:
2137
	call	get_byte_value
2138
	mov	byte [value],al
2139
	pop	eax ecx ebx edx
2140
	call	operand_autodetect
2141
	call	store_instruction_with_imm8
2142
	jmp	instruction_assembled
2143
      shd_reg:
2144
	lods	byte [esi]
2145
	call	convert_register
2146
	mov	[postbyte_register],al
2147
	lods	byte [esi]
2148
	cmp	al,','
2149
	jne	invalid_operand
2150
	call	take_register
2151
	mov	bl,[postbyte_register]
2152
	mov	[postbyte_register],al
2153
	mov	al,ah
2154
	push	eax ebx
2155
	lods	byte [esi]
2156
	cmp	al,','
2157
	jne	invalid_operand
2158
	mov	[operand_size],0
2159
	lods	byte [esi]
2160
	call	get_size_operator
2161
	cmp	al,'('
2162
	je	shd_reg_reg_imm
2163
	cmp	al,10h
2164
	jne	invalid_operand
2165
	lods	byte [esi]
2166
	cmp	al,11h
2167
	jne	invalid_operand
2168
	pop	ebx eax
2169
	call	operand_autodetect
2170
	inc	[extended_code]
2171
	jmp	nomem_instruction_ready
2172
      shd_reg_reg_imm:
2173
	mov	al,[operand_size]
2174
	or	al,al
2175
	jz	shd_reg_reg_imm_size_ok
2176
	cmp	al,1
2177
	jne	invalid_operand_size
2178
      shd_reg_reg_imm_size_ok:
2179
	call	get_byte_value
2180
	mov	dl,al
2181
	pop	ebx eax
2182
	call	operand_autodetect
2183
	call	store_nomem_instruction
2184
	mov	al,dl
2185
	stos	byte [edi]
2186
	jmp	instruction_assembled
2187
movx_instruction:
2188
	mov	[base_code],0Fh
2189
	mov	[extended_code],al
2190
	call	take_register
2191
	mov	[postbyte_register],al
2192
	mov	al,ah
2193
	push	eax
2194
	lods	byte [esi]
2195
	cmp	al,','
2196
	jne	invalid_operand
2197
	mov	[operand_size],0
2198
	lods	byte [esi]
2199
	call	get_size_operator
2200
	cmp	al,10h
2201
	je	movx_reg
2202
	cmp	al,'['
2203
	jne	invalid_operand
2204
	call	get_address
2205
	pop	eax
2206
	mov	ah,[operand_size]
2207
	or	ah,ah
2208
	jz	movx_unknown_size
2209
	cmp	ah,al
2210
	jae	invalid_operand_size
2211
	cmp	ah,1
2212
	je	movx_mem_store
2213
	cmp	ah,2
2214
	jne	invalid_operand_size
2215
	inc	[extended_code]
2216
      movx_mem_store:
2217
	call	operand_autodetect
2218
	jmp	instruction_ready
2219
      movx_unknown_size:
2220
	cmp	al,2
2221
	je	movx_mem_store
2222
	call	recoverable_unknown_size
2223
	jmp	movx_mem_store
2224
      movx_reg:
2225
	lods	byte [esi]
2226
	call	convert_register
2227
	pop	ebx
2228
	xchg	bl,al
2229
	cmp	ah,al
2230
	jae	invalid_operand_size
2231
	cmp	ah,1
2232
	je	movx_reg_8bit
2233
	cmp	ah,2
2234
	je	movx_reg_16bit
2235
	jmp	invalid_operand_size
2236
      movx_reg_8bit:
2237
	call	operand_autodetect
2238
	jmp	nomem_instruction_ready
2239
      movx_reg_16bit:
2240
	call	operand_autodetect
2241
	inc	[extended_code]
2242
	jmp	nomem_instruction_ready
2243
movsxd_instruction:
2244
	mov	[base_code],al
2245
	call	take_register
2246
	mov	[postbyte_register],al
2247
	cmp	ah,8
2248
	jne	invalid_operand_size
2249
	lods	byte [esi]
2250
	cmp	al,','
2251
	jne	invalid_operand
2252
	mov	[operand_size],0
2253
	lods	byte [esi]
2254
	call	get_size_operator
2255
	cmp	al,10h
2256
	je	movsxd_reg
2257
	cmp	al,'['
2258
	jne	invalid_operand
2259
	call	get_address
2260
	cmp	[operand_size],4
2261
	je	movsxd_mem_store
2262
	cmp	[operand_size],0
2263
	jne	invalid_operand_size
2264
      movsxd_mem_store:
2265
	call	operand_64bit
2266
	jmp	instruction_ready
2267
      movsxd_reg:
2268
	lods	byte [esi]
2269
	call	convert_register
2270
	cmp	ah,4
2271
	jne	invalid_operand_size
2272
	mov	bl,al
2273
	call	operand_64bit
2274
	jmp	nomem_instruction_ready
2275
bt_instruction:
2276
	mov	[postbyte_register],al
2277
	shl	al,3
2278
	add	al,83h
2279
	mov	[extended_code],al
2280
	mov	[base_code],0Fh
2281
	lods	byte [esi]
2282
	call	get_size_operator
2283
	cmp	al,10h
2284
	je	bt_reg
2285
	cmp	al,'['
2286
	jne	invalid_operand
2287
	call	get_address
2288
	push	eax ebx ecx
2289
	lods	byte [esi]
2290
	cmp	al,','
2291
	jne	invalid_operand
2292
	cmp	byte [esi],'('
2293
	je	bt_mem_imm
2294
	cmp	byte [esi],11h
2295
	jne	bt_mem_reg
2296
	cmp	byte [esi+2],'('
2297
	je	bt_mem_imm
2298
      bt_mem_reg:
2299
	call	take_register
2300
	mov	[postbyte_register],al
2301
	pop	ecx ebx edx
2302
	mov	al,ah
2303
	call	operand_autodetect
2304
	jmp	instruction_ready
2305
      bt_mem_imm:
2306
	xor	al,al
2307
	xchg	al,[operand_size]
2308
	push	eax
2309
	lods	byte [esi]
2310
	call	get_size_operator
2311
	cmp	al,'('
2312
	jne	invalid_operand
2313
	mov	al,[operand_size]
2314
	or	al,al
2315
	jz	bt_mem_imm_size_ok
2316
	cmp	al,1
2317
	jne	invalid_operand_size
2318
      bt_mem_imm_size_ok:
2319
	call	get_byte_value
2320
	mov	byte [value],al
2321
	pop	eax
2322
	or	al,al
2323
	jz	bt_mem_imm_nosize
2324
	call	operand_autodetect
2325
      bt_mem_imm_store:
2326
	pop	ecx ebx edx
2327
	mov	[extended_code],0BAh
2328
	call	store_instruction_with_imm8
2329
	jmp	instruction_assembled
2330
      bt_mem_imm_nosize:
2331
	call	recoverable_unknown_size
2332
	jmp	bt_mem_imm_store
2333
      bt_reg:
2334
	lods	byte [esi]
2335
	call	convert_register
2336
	mov	bl,al
2337
	lods	byte [esi]
2338
	cmp	al,','
2339
	jne	invalid_operand
2340
	cmp	byte [esi],'('
2341
	je	bt_reg_imm
2342
	cmp	byte [esi],11h
2343
	jne	bt_reg_reg
2344
	cmp	byte [esi+2],'('
2345
	je	bt_reg_imm
2346
      bt_reg_reg:
2347
	call	take_register
2348
	mov	[postbyte_register],al
2349
	mov	al,ah
2350
	call	operand_autodetect
2351
	jmp	nomem_instruction_ready
2352
      bt_reg_imm:
2353
	xor	al,al
2354
	xchg	al,[operand_size]
2355
	push	eax ebx
2356
	lods	byte [esi]
2357
	call	get_size_operator
2358
	cmp	al,'('
2359
	jne	invalid_operand
2360
	mov	al,[operand_size]
2361
	or	al,al
2362
	jz	bt_reg_imm_size_ok
2363
	cmp	al,1
2364
	jne	invalid_operand_size
2365
      bt_reg_imm_size_ok:
2366
	call	get_byte_value
2367
	mov	byte [value],al
2368
	pop	ebx eax
2369
	call	operand_autodetect
2370
      bt_reg_imm_store:
2371
	mov	[extended_code],0BAh
2372
	call	store_nomem_instruction
2373
	mov	al,byte [value]
2374
	stos	byte [edi]
2375
	jmp	instruction_assembled
2376
bs_instruction:
2377
	mov	[extended_code],al
2378
	mov	[base_code],0Fh
2379
	call	get_reg_mem
2380
	jc	bs_reg_reg
2381
	mov	al,[operand_size]
2382
	call	operand_autodetect
2383
	jmp	instruction_ready
2384
      bs_reg_reg:
2385
	mov	al,ah
2386
	call	operand_autodetect
2387
	jmp	nomem_instruction_ready
2388
      get_reg_mem:
2389
	call	take_register
2390
	mov	[postbyte_register],al
2391
	lods	byte [esi]
2392
	cmp	al,','
2393
	jne	invalid_operand
2394
	lods	byte [esi]
2395
	call	get_size_operator
2396
	cmp	al,10h
2397
	je	get_reg_reg
2398
	cmp	al,'['
2399
	jne	invalid_argument
2400
	call	get_address
2401
	clc
2402
	ret
2403
      get_reg_reg:
2404
	lods	byte [esi]
2405
	call	convert_register
2406
	mov	bl,al
2407
	stc
2408
	ret
2409
ud_instruction:
2410
	mov	[extended_code],al
2411
	mov	[base_code],0Fh
2412
	call	get_reg_mem
2413
	jc	ud_reg_reg
2414
	cmp	[operand_size],4
2415
	jne	invalid_operand_size
2416
	jmp	instruction_ready
2417
      ud_reg_reg:
2418
	cmp	ah,4
2419
	jne	invalid_operand_size
2420
	jmp	nomem_instruction_ready
2421
2422
 
2423
	mov	[base_code],0F6h
2424
	mov	[postbyte_register],5
2425
	lods	byte [esi]
2426
	call	get_size_operator
2427
	cmp	al,10h
2428
	je	imul_reg
2429
	cmp	al,'['
2430
	jne	invalid_operand
2431
      imul_mem:
2432
	call	get_address
2433
	mov	al,[operand_size]
2434
	cmp	al,1
2435
	je	imul_mem_8bit
2436
	jb	imul_mem_nosize
2437
	call	operand_autodetect
2438
	inc	[base_code]
2439
	jmp	instruction_ready
2440
      imul_mem_nosize:
2441
	call	recoverable_unknown_size
2442
      imul_mem_8bit:
2443
	jmp	instruction_ready
2444
      imul_reg:
2445
	lods	byte [esi]
2446
	call	convert_register
2447
	cmp	byte [esi],','
2448
	je	imul_reg_
2449
	mov	bl,al
2450
	mov	al,ah
2451
	cmp	al,1
2452
	je	imul_reg_8bit
2453
	call	operand_autodetect
2454
	inc	[base_code]
2455
      imul_reg_8bit:
2456
	jmp	nomem_instruction_ready
2457
      imul_reg_:
2458
	mov	[postbyte_register],al
2459
	inc	esi
2460
	cmp	byte [esi],'('
2461
	je	imul_reg_imm
2462
	cmp	byte [esi],11h
2463
	jne	imul_reg_noimm
2464
	cmp	byte [esi+2],'('
2465
	je	imul_reg_imm
2466
      imul_reg_noimm:
2467
	lods	byte [esi]
2468
	call	get_size_operator
2469
	cmp	al,10h
2470
	je	imul_reg_reg
2471
	cmp	al,'['
2472
	jne	invalid_operand
2473
      imul_reg_mem:
2474
	call	get_address
2475
	push	edx ebx ecx
2476
	cmp	byte [esi],','
2477
	je	imul_reg_mem_imm
2478
	mov	al,[operand_size]
2479
	call	operand_autodetect
2480
	pop	ecx ebx edx
2481
	mov	[base_code],0Fh
2482
	mov	[extended_code],0AFh
2483
	jmp	instruction_ready
2484
      imul_reg_mem_imm:
2485
	inc	esi
2486
	lods	byte [esi]
2487
	call	get_size_operator
2488
	cmp	al,'('
2489
	jne	invalid_operand
2490
	mov	al,[operand_size]
2491
	cmp	al,2
2492
	je	imul_reg_mem_imm_16bit
2493
	cmp	al,4
2494
	je	imul_reg_mem_imm_32bit
2495
	cmp	al,8
2496
	jne	invalid_operand_size
2497
      imul_reg_mem_imm_64bit:
2498
	cmp	[size_declared],0
2499
	jne	long_immediate_not_encodable
2500
	call	operand_64bit
2501
	call	get_simm32
2502
	cmp	[value_type],4
2503
	jae	long_immediate_not_encodable
2504
	jmp	imul_reg_mem_imm_32bit_ok
2505
      imul_reg_mem_imm_16bit:
2506
	call	operand_16bit
2507
	call	get_word_value
2508
	mov	word [value],ax
2509
	cmp	[value_type],0
2510
	jne	imul_reg_mem_imm_16bit_store
2511
	cmp	[size_declared],0
2512
	jne	imul_reg_mem_imm_16bit_store
2513
	cmp	ax,-80h
2514
	jl	imul_reg_mem_imm_16bit_store
2515
	cmp	ax,80h
2516
	jl	imul_reg_mem_imm_8bit_store
2517
      imul_reg_mem_imm_16bit_store:
2518
	pop	ecx ebx edx
2519
	mov	[base_code],69h
2520
	call	store_instruction_with_imm16
2521
	jmp	instruction_assembled
2522
      imul_reg_mem_imm_32bit:
2523
	call	operand_32bit
2524
	call	get_dword_value
2525
      imul_reg_mem_imm_32bit_ok:
2526
	mov	dword [value],eax
2527
	cmp	[value_type],0
2528
	jne	imul_reg_mem_imm_32bit_store
2529
	cmp	[size_declared],0
2530
	jne	imul_reg_mem_imm_32bit_store
2531
	cmp	eax,-80h
2532
	jl	imul_reg_mem_imm_32bit_store
2533
	cmp	eax,80h
2534
	jl	imul_reg_mem_imm_8bit_store
2535
      imul_reg_mem_imm_32bit_store:
2536
	pop	ecx ebx edx
2537
	mov	[base_code],69h
2538
	call	store_instruction_with_imm32
2539
	jmp	instruction_assembled
2540
      imul_reg_mem_imm_8bit_store:
2541
	pop	ecx ebx edx
2542
	mov	[base_code],6Bh
2543
	call	store_instruction_with_imm8
2544
	jmp	instruction_assembled
2545
      imul_reg_imm:
2546
	mov	bl,[postbyte_register]
2547
	dec	esi
2548
	jmp	imul_reg_reg_imm
2549
      imul_reg_reg:
2550
	lods	byte [esi]
2551
	call	convert_register
2552
	mov	bl,al
2553
	cmp	byte [esi],','
2554
	je	imul_reg_reg_imm
2555
	mov	al,ah
2556
	call	operand_autodetect
2557
	mov	[base_code],0Fh
2558
	mov	[extended_code],0AFh
2559
	jmp	nomem_instruction_ready
2560
      imul_reg_reg_imm:
2561
	inc	esi
2562
	lods	byte [esi]
2563
	call	get_size_operator
2564
	cmp	al,'('
2565
	jne	invalid_operand
2566
	mov	al,[operand_size]
2567
	cmp	al,2
2568
	je	imul_reg_reg_imm_16bit
2569
	cmp	al,4
2570
	je	imul_reg_reg_imm_32bit
2571
	cmp	al,8
2572
	jne	invalid_operand_size
2573
      imul_reg_reg_imm_64bit:
2574
	cmp	[size_declared],0
2575
	jne	long_immediate_not_encodable
2576
	call	operand_64bit
2577
	push	ebx
2578
	call	get_simm32
2579
	cmp	[value_type],4
2580
	jae	long_immediate_not_encodable
2581
	jmp	imul_reg_reg_imm_32bit_ok
2582
      imul_reg_reg_imm_16bit:
2583
	call	operand_16bit
2584
	push	ebx
2585
	call	get_word_value
2586
	pop	ebx
2587
	mov	dx,ax
2588
	cmp	[value_type],0
2589
	jne	imul_reg_reg_imm_16bit_store
2590
	cmp	[size_declared],0
2591
	jne	imul_reg_reg_imm_16bit_store
2592
	cmp	ax,-80h
2593
	jl	imul_reg_reg_imm_16bit_store
2594
	cmp	ax,80h
2595
	jl	imul_reg_reg_imm_8bit_store
2596
      imul_reg_reg_imm_16bit_store:
2597
	mov	[base_code],69h
2598
	call	store_nomem_instruction
2599
	mov	ax,dx
2600
	call	mark_relocation
2601
	stos	word [edi]
2602
	jmp	instruction_assembled
2603
      imul_reg_reg_imm_32bit:
2604
	call	operand_32bit
2605
	push	ebx
2606
	call	get_dword_value
2607
      imul_reg_reg_imm_32bit_ok:
2608
	pop	ebx
2609
	mov	edx,eax
2610
	cmp	[value_type],0
2611
	jne	imul_reg_reg_imm_32bit_store
2612
	cmp	[size_declared],0
2613
	jne	imul_reg_reg_imm_32bit_store
2614
	cmp	eax,-80h
2615
	jl	imul_reg_reg_imm_32bit_store
2616
	cmp	eax,80h
2617
	jl	imul_reg_reg_imm_8bit_store
2618
      imul_reg_reg_imm_32bit_store:
2619
	mov	[base_code],69h
2620
	call	store_nomem_instruction
2621
	mov	eax,edx
2622
	call	mark_relocation
2623
	stos	dword [edi]
2624
	jmp	instruction_assembled
2625
      imul_reg_reg_imm_8bit_store:
2626
	mov	[base_code],6Bh
2627
	call	store_nomem_instruction
2628
	mov	al,dl
2629
	stos	byte [edi]
2630
	jmp	instruction_assembled
2631
in_instruction:
2632
	call	take_register
2633
	or	al,al
2634
	jnz	invalid_operand
2635
	lods	byte [esi]
2636
	cmp	al,','
2637
	jne	invalid_operand
2638
	mov	al,ah
2639
	push	eax
2640
	mov	[operand_size],0
2641
	lods	byte [esi]
2642
	call	get_size_operator
2643
	cmp	al,'('
2644
	je	in_imm
2645
	cmp	al,10h
2646
	je	in_reg
2647
	jmp	invalid_operand
2648
      in_reg:
2649
	lods	byte [esi]
2650
	cmp	al,22h
2651
	jne	invalid_operand
2652
	pop	eax
2653
	cmp	al,1
2654
	je	in_al_dx
2655
	cmp	al,2
2656
	je	in_ax_dx
2657
	cmp	al,4
2658
	jne	invalid_operand_size
2659
      in_ax_dx:
2660
	call	operand_autodetect
2661
	mov	[base_code],0EDh
2662
	call	store_classic_instruction_code
2663
	jmp	instruction_assembled
2664
      in_al_dx:
2665
	mov	al,0ECh
2666
	stos	byte [edi]
2667
	jmp	instruction_assembled
2668
      in_imm:
2669
	mov	al,[operand_size]
2670
	or	al,al
2671
	jz	in_imm_size_ok
2672
	cmp	al,1
2673
	jne	invalid_operand_size
2674
      in_imm_size_ok:
2675
	call	get_byte_value
2676
	mov	dl,al
2677
	pop	eax
2678
	cmp	al,1
2679
	je	in_al_imm
2680
	cmp	al,2
2681
	je	in_ax_imm
2682
	cmp	al,4
2683
	jne	invalid_operand_size
2684
      in_ax_imm:
2685
	call	operand_autodetect
2686
	mov	[base_code],0E5h
2687
	call	store_classic_instruction_code
2688
	mov	al,dl
2689
	stos	byte [edi]
2690
	jmp	instruction_assembled
2691
      in_al_imm:
2692
	mov	al,0E4h
2693
	stos	byte [edi]
2694
	mov	al,dl
2695
	stos	byte [edi]
2696
	jmp	instruction_assembled
2697
out_instruction:
2698
	lods	byte [esi]
2699
	call	get_size_operator
2700
	cmp	al,'('
2701
	je	out_imm
2702
	cmp	al,10h
2703
	jne	invalid_operand
2704
	lods	byte [esi]
2705
	cmp	al,22h
2706
	jne	invalid_operand
2707
	lods	byte [esi]
2708
	cmp	al,','
2709
	jne	invalid_operand
2710
	mov	[operand_size],0
2711
	call	take_register
2712
	or	al,al
2713
	jnz	invalid_operand
2714
	mov	al,ah
2715
	cmp	al,1
2716
	je	out_dx_al
2717
	cmp	al,2
2718
	je	out_dx_ax
2719
	cmp	al,4
2720
	jne	invalid_operand_size
2721
      out_dx_ax:
2722
	call	operand_autodetect
2723
	mov	[base_code],0EFh
2724
	call	store_classic_instruction_code
2725
	jmp	instruction_assembled
2726
      out_dx_al:
2727
	mov	al,0EEh
2728
	stos	byte [edi]
2729
	jmp	instruction_assembled
2730
      out_imm:
2731
	mov	al,[operand_size]
2732
	or	al,al
2733
	jz	out_imm_size_ok
2734
	cmp	al,1
2735
	jne	invalid_operand_size
2736
      out_imm_size_ok:
2737
	call	get_byte_value
2738
	mov	dl,al
2739
	lods	byte [esi]
2740
	cmp	al,','
2741
	jne	invalid_operand
2742
	mov	[operand_size],0
2743
	call	take_register
2744
	or	al,al
2745
	jnz	invalid_operand
2746
	mov	al,ah
2747
	cmp	al,1
2748
	je	out_imm_al
2749
	cmp	al,2
2750
	je	out_imm_ax
2751
	cmp	al,4
2752
	jne	invalid_operand_size
2753
      out_imm_ax:
2754
	call	operand_autodetect
2755
	mov	[base_code],0E7h
2756
	call	store_classic_instruction_code
2757
	mov	al,dl
2758
	stos	byte [edi]
2759
	jmp	instruction_assembled
2760
      out_imm_al:
2761
	mov	al,0E6h
2762
	stos	byte [edi]
2763
	mov	al,dl
2764
	stos	byte [edi]
2765
	jmp	instruction_assembled
2766
2767
 
2768
	mov	[postbyte_register],10b
2769
	mov	[base_code],0E8h
2770
	mov	[extended_code],9Ah
2771
	jmp	process_jmp
2772
jmp_instruction:
2773
	mov	[postbyte_register],100b
2774
	mov	[base_code],0E9h
2775
	mov	[extended_code],0EAh
2776
      process_jmp:
2777
	lods	byte [esi]
2778
	call	get_jump_operator
2779
	test	[prefix_flags],10h
2780
	jz	jmp_type_ok
2781
	test	[jump_type],not 2
2782
	jnz	illegal_instruction
2783
	mov	[jump_type],2
2784
	and	[prefix_flags],not 10h
2785
      jmp_type_ok:
2786
	call	get_size_operator
2787
	cmp	al,'('
2788
	je	jmp_imm
2789
	mov	[base_code],0FFh
2790
	cmp	al,10h
2791
	je	jmp_reg
2792
	cmp	al,'['
2793
	jne	invalid_operand
2794
      jmp_mem:
2795
	cmp	[jump_type],1
2796
	je	illegal_instruction
2797
	call	get_address
2798
	mov	edx,eax
2799
	mov	al,[operand_size]
2800
	or	al,al
2801
	jz	jmp_mem_size_not_specified
2802
	cmp	al,2
2803
	je	jmp_mem_16bit
2804
	cmp	al,4
2805
	je	jmp_mem_32bit
2806
	cmp	al,6
2807
	je	jmp_mem_48bit
2808
	cmp	al,8
2809
	je	jmp_mem_64bit
2810
	cmp	al,10
2811
	je	jmp_mem_80bit
2812
	jmp	invalid_operand_size
2813
      jmp_mem_size_not_specified:
2814
	cmp	[jump_type],3
2815
	je	jmp_mem_far
2816
	cmp	[jump_type],2
2817
	je	jmp_mem_near
2818
	call	recoverable_unknown_size
2819
      jmp_mem_near:
2820
	cmp	[code_type],16
2821
	je	jmp_mem_16bit
2822
	cmp	[code_type],32
2823
	je	jmp_mem_near_32bit
2824
      jmp_mem_64bit:
2825
	cmp	[jump_type],3
2826
	je	invalid_operand_size
2827
	cmp	[code_type],64
2828
	jne	illegal_instruction
2829
	jmp	instruction_ready
2830
      jmp_mem_far:
2831
	cmp	[code_type],16
2832
	je	jmp_mem_far_32bit
2833
      jmp_mem_48bit:
2834
	call	operand_32bit
2835
      jmp_mem_far_store:
2836
	cmp	[jump_type],2
2837
	je	invalid_operand_size
2838
	inc	[postbyte_register]
2839
	jmp	instruction_ready
2840
      jmp_mem_80bit:
2841
	call	operand_64bit
2842
	jmp	jmp_mem_far_store
2843
      jmp_mem_far_32bit:
2844
	call	operand_16bit
2845
	jmp	jmp_mem_far_store
2846
      jmp_mem_32bit:
2847
	cmp	[jump_type],3
2848
	je	jmp_mem_far_32bit
2849
	cmp	[jump_type],2
2850
	je	jmp_mem_near_32bit
2851
	cmp	[code_type],16
2852
	je	jmp_mem_far_32bit
2853
      jmp_mem_near_32bit:
2854
	cmp	[code_type],64
2855
	je	illegal_instruction
2856
	call	operand_32bit
2857
	jmp	instruction_ready
2858
      jmp_mem_16bit:
2859
	cmp	[jump_type],3
2860
	je	invalid_operand_size
2861
	call	operand_16bit
2862
	jmp	instruction_ready
2863
      jmp_reg:
2864
	test	[jump_type],1
2865
	jnz	invalid_operand
2866
	lods	byte [esi]
2867
	call	convert_register
2868
	mov	bl,al
2869
	mov	al,ah
2870
	cmp	al,2
2871
	je	jmp_reg_16bit
2872
	cmp	al,4
2873
	je	jmp_reg_32bit
2874
	cmp	al,8
2875
	jne	invalid_operand_size
2876
      jmp_reg_64bit:
2877
	cmp	[code_type],64
2878
	jne	illegal_instruction
2879
	jmp	nomem_instruction_ready
2880
      jmp_reg_32bit:
2881
	cmp	[code_type],64
2882
	je	illegal_instruction
2883
	call	operand_32bit
2884
	jmp	nomem_instruction_ready
2885
      jmp_reg_16bit:
2886
	call	operand_16bit
2887
	jmp	nomem_instruction_ready
2888
      jmp_imm:
2889
	cmp	byte [esi],'.'
2890
	je	invalid_value
2891
	mov	ebx,esi
2892
	dec	esi
2893
	call	skip_symbol
2894
	xchg	esi,ebx
2895
	cmp	byte [ebx],':'
2896
	je	jmp_far
2897
	cmp	[jump_type],3
2898
	je	invalid_operand
2899
      jmp_near:
2900
	mov	al,[operand_size]
2901
	cmp	al,2
2902
	je	jmp_imm_16bit
2903
	cmp	al,4
2904
	je	jmp_imm_32bit
2905
	cmp	al,8
2906
	je	jmp_imm_64bit
2907
	or	al,al
2908
	jnz	invalid_operand_size
2909
	cmp	[code_type],16
2910
	je	jmp_imm_16bit
2911
	cmp	[code_type],64
2912
	je	jmp_imm_64bit
2913
      jmp_imm_32bit:
2914
	cmp	[code_type],64
2915
	je	invalid_operand_size
2916
	call	get_address_dword_value
2917
	cmp	[code_type],16
2918
	jne	jmp_imm_32bit_prefix_ok
2919
	mov	byte [edi],66h
2920
	inc	edi
2921
      jmp_imm_32bit_prefix_ok:
2922
	call	calculate_jump_offset
2923
	cdq
2924
	call	check_for_short_jump
2925
	jc	jmp_short
2926
      jmp_imm_32bit_store:
2927
	mov	edx,eax
2928
	sub	edx,3
2929
	jno	jmp_imm_32bit_ok
2930
	cmp	[code_type],64
2931
	je	jump_out_of_range
2932
      jmp_imm_32bit_ok:
2933
	mov	al,[base_code]
2934
	stos	byte [edi]
2935
	mov	eax,edx
2936
	call	mark_relocation
2937
	stos	dword [edi]
2938
	jmp	instruction_assembled
2939
      jmp_imm_64bit:
2940
	cmp	[code_type],64
2941
	jne	invalid_operand_size
2942
	call	get_address_qword_value
2943
	call	calculate_jump_offset
2944
	mov	ecx,edx
2945
	cdq
2946
	cmp	edx,ecx
2947
	jne	jump_out_of_range
2948
	call	check_for_short_jump
2949
	jnc	jmp_imm_32bit_store
2950
      jmp_short:
2951
	mov	ah,al
2952
	mov	al,0EBh
2953
	stos	word [edi]
2954
	jmp	instruction_assembled
2955
      jmp_imm_16bit:
2956
	call	get_address_word_value
2957
	cmp	[code_type],16
2958
	je	jmp_imm_16bit_prefix_ok
2959
	mov	byte [edi],66h
2960
	inc	edi
2961
      jmp_imm_16bit_prefix_ok:
2962
	call	calculate_jump_offset
2963
	cwde
2964
	cdq
2965
	call	check_for_short_jump
2966
	jc	jmp_short
2967
	cmp	[value_type],0
2968
	jne	invalid_use_of_symbol
2969
	mov	edx,eax
2970
	dec	edx
2971
	mov	al,[base_code]
2972
	stos	byte [edi]
2973
	mov	eax,edx
2974
	stos	word [edi]
2975
	jmp	instruction_assembled
2976
      calculate_jump_offset:
2977
	add	edi,2
2978
	mov	ebp,[addressing_space]
2979
	call	calculate_relative_offset
2980
	sub	edi,2
2981
	ret
2982
      check_for_short_jump:
2983
	cmp	[jump_type],1
2984
	je	forced_short
2985
	ja	no_short_jump
2986
	cmp	[base_code],0E8h
2987
	je	no_short_jump
2988
	cmp	[value_type],0
2989
	jne	no_short_jump
2990
	cmp	eax,80h
2991
	jb	short_jump
2992
	cmp	eax,-80h
2993
	jae	short_jump
2994
      no_short_jump:
2995
	clc
2996
	ret
2997
      forced_short:
2998
	cmp	[base_code],0E8h
2999
	je	illegal_instruction
3000
	cmp	[next_pass_needed],0
3001
	jne	jmp_short_value_type_ok
3002
	cmp	[value_type],0
3003
	jne	invalid_use_of_symbol
3004
      jmp_short_value_type_ok:
3005
	cmp	eax,-80h
3006
	jae	short_jump
3007
	cmp	eax,80h
3008
	jae	jump_out_of_range
3009
      short_jump:
3010
	stc
3011
	ret
3012
      jump_out_of_range:
3013
	cmp	[error_line],0
3014
	jne	instruction_assembled
3015
	mov	eax,[current_line]
3016
	mov	[error_line],eax
3017
	mov	[error],relative_jump_out_of_range
3018
	jmp	instruction_assembled
3019
      jmp_far:
3020
	cmp	[jump_type],2
3021
	je	invalid_operand
3022
	cmp	[code_type],64
3023
	je	illegal_instruction
3024
	mov	al,[extended_code]
3025
	mov	[base_code],al
3026
	call	get_word_value
3027
	push	eax
3028
	inc	esi
3029
	lods	byte [esi]
3030
	cmp	al,'('
3031
	jne	invalid_operand
3032
	mov	al,[value_type]
3033
	push	eax [symbol_identifier]
3034
	cmp	byte [esi],'.'
3035
	je	invalid_value
3036
	mov	al,[operand_size]
3037
	cmp	al,4
3038
	je	jmp_far_16bit
3039
	cmp	al,6
3040
	je	jmp_far_32bit
3041
	or	al,al
3042
	jnz	invalid_operand_size
3043
	cmp	[code_type],16
3044
	jne	jmp_far_32bit
3045
      jmp_far_16bit:
3046
	call	get_word_value
3047
	mov	ebx,eax
3048
	call	operand_16bit
3049
	call	store_classic_instruction_code
3050
	mov	ax,bx
3051
	call	mark_relocation
3052
	stos	word [edi]
3053
      jmp_far_segment:
3054
	pop	[symbol_identifier] eax
3055
	mov	[value_type],al
3056
	pop	eax
3057
	call	mark_relocation
3058
	stos	word [edi]
3059
	jmp	instruction_assembled
3060
      jmp_far_32bit:
3061
	call	get_dword_value
3062
	mov	ebx,eax
3063
	call	operand_32bit
3064
	call	store_classic_instruction_code
3065
	mov	eax,ebx
3066
	call	mark_relocation
3067
	stos	dword [edi]
3068
	jmp	jmp_far_segment
3069
conditional_jump:
3070
	mov	[base_code],al
3071
	and	[prefix_flags],not 10h
3072
	lods	byte [esi]
3073
	call	get_jump_operator
3074
	cmp	[jump_type],3
3075
	je	invalid_operand
3076
	call	get_size_operator
3077
	cmp	al,'('
3078
	jne	invalid_operand
3079
	cmp	byte [esi],'.'
3080
	je	invalid_value
3081
	mov	al,[operand_size]
3082
	cmp	al,2
3083
	je	conditional_jump_16bit
3084
	cmp	al,4
3085
	je	conditional_jump_32bit
3086
	cmp	al,8
3087
	je	conditional_jump_64bit
3088
	or	al,al
3089
	jnz	invalid_operand_size
3090
	cmp	[code_type],16
3091
	je	conditional_jump_16bit
3092
	cmp	[code_type],64
3093
	je	conditional_jump_64bit
3094
      conditional_jump_32bit:
3095
	cmp	[code_type],64
3096
	je	invalid_operand_size
3097
	call	get_address_dword_value
3098
	cmp	[code_type],16
3099
	jne	conditional_jump_32bit_prefix_ok
3100
	mov	byte [edi],66h
3101
	inc	edi
3102
      conditional_jump_32bit_prefix_ok:
3103
	call	calculate_jump_offset
3104
	cdq
3105
	call	check_for_short_jump
3106
	jc	conditional_jump_short
3107
      conditional_jump_32bit_store:
3108
	mov	edx,eax
3109
	sub	edx,4
3110
	jno	conditional_jump_32bit_range_ok
3111
	cmp	[code_type],64
3112
	je	jump_out_of_range
3113
      conditional_jump_32bit_range_ok:
3114
	mov	ah,[base_code]
3115
	add	ah,10h
3116
	mov	al,0Fh
3117
	stos	word [edi]
3118
	mov	eax,edx
3119
	call	mark_relocation
3120
	stos	dword [edi]
3121
	jmp	instruction_assembled
3122
      conditional_jump_64bit:
3123
	cmp	[code_type],64
3124
	jne	invalid_operand_size
3125
	call	get_address_qword_value
3126
	call	calculate_jump_offset
3127
	mov	ecx,edx
3128
	cdq
3129
	cmp	edx,ecx
3130
	jne	jump_out_of_range
3131
	call	check_for_short_jump
3132
	jnc	conditional_jump_32bit_store
3133
      conditional_jump_short:
3134
	mov	ah,al
3135
	mov	al,[base_code]
3136
	stos	word [edi]
3137
	jmp	instruction_assembled
3138
      conditional_jump_16bit:
3139
	call	get_address_word_value
3140
	cmp	[code_type],16
3141
	je	conditional_jump_16bit_prefix_ok
3142
	mov	byte [edi],66h
3143
	inc	edi
3144
      conditional_jump_16bit_prefix_ok:
3145
	call	calculate_jump_offset
3146
	cwde
3147
	cdq
3148
	call	check_for_short_jump
3149
	jc	conditional_jump_short
3150
	cmp	[value_type],0
3151
	jne	invalid_use_of_symbol
3152
	mov	edx,eax
3153
	sub	dx,2
3154
	mov	ah,[base_code]
3155
	add	ah,10h
3156
	mov	al,0Fh
3157
	stos	word [edi]
3158
	mov	eax,edx
3159
	stos	word [edi]
3160
	jmp	instruction_assembled
3161
loop_instruction_16bit:
3162
	cmp	[code_type],64
3163
	je	illegal_instruction
3164
	cmp	[code_type],16
3165
	je	loop_instruction
3166
	mov	[operand_prefix],67h
3167
	jmp	loop_instruction
3168
loop_instruction_32bit:
3169
	cmp	[code_type],32
3170
	je	loop_instruction
3171
	mov	[operand_prefix],67h
3172
      jmp     loop_instruction
3173
loop_instruction_64bit:
3174
	cmp	[code_type],64
3175
	jne	illegal_instruction
3176
loop_instruction:
3177
	mov	[base_code],al
3178
	lods	byte [esi]
3179
	call	get_jump_operator
3180
	cmp	[jump_type],1
3181
	ja	invalid_operand
3182
	call	get_size_operator
3183
	cmp	al,'('
3184
	jne	invalid_operand
3185
	cmp	byte [esi],'.'
3186
	je	invalid_value
3187
	mov	al,[operand_size]
3188
	cmp	al,2
3189
	je	loop_jump_16bit
3190
	cmp	al,4
3191
	je	loop_jump_32bit
3192
	cmp	al,8
3193
	je	loop_jump_64bit
3194
	or	al,al
3195
	jnz	invalid_operand_size
3196
	cmp	[code_type],16
3197
	je	loop_jump_16bit
3198
	cmp	[code_type],64
3199
	je	loop_jump_64bit
3200
      loop_jump_32bit:
3201
	cmp	[code_type],64
3202
	je	invalid_operand_size
3203
	call	get_address_dword_value
3204
	cmp	[code_type],16
3205
	jne	loop_jump_32bit_prefix_ok
3206
	mov	byte [edi],66h
3207
	inc	edi
3208
      loop_jump_32bit_prefix_ok:
3209
	call	loop_counter_size
3210
	call	calculate_jump_offset
3211
	cdq
3212
      make_loop_jump:
3213
	call	check_for_short_jump
3214
	jc	conditional_jump_short
3215
	scas	word [edi]
3216
	jmp	jump_out_of_range
3217
      loop_counter_size:
3218
	cmp	[operand_prefix],0
3219
	je	loop_counter_size_ok
3220
	push	eax
3221
	mov	al,[operand_prefix]
3222
	stos	byte [edi]
3223
	pop	eax
3224
      loop_counter_size_ok:
3225
	ret
3226
      loop_jump_64bit:
3227
	cmp	[code_type],64
3228
	jne	invalid_operand_size
3229
	call	get_address_qword_value
3230
	call	loop_counter_size
3231
	call	calculate_jump_offset
3232
	mov	ecx,edx
3233
	cdq
3234
	cmp	edx,ecx
3235
	jne	jump_out_of_range
3236
	jmp	make_loop_jump
3237
      loop_jump_16bit:
3238
	call	get_address_word_value
3239
	cmp	[code_type],16
3240
	je	loop_jump_16bit_prefix_ok
3241
	mov	byte [edi],66h
3242
	inc	edi
3243
      loop_jump_16bit_prefix_ok:
3244
	call	loop_counter_size
3245
	call	calculate_jump_offset
3246
	cwde
3247
	cdq
3248
	jmp	make_loop_jump
3249
3250
 
3251
	lods	byte [esi]
3252
	call	get_size_operator
3253
	cmp	al,'['
3254
	jne	invalid_operand
3255
	call	get_address
3256
	or	eax,eax
3257
	jnz	invalid_address
3258
	or	bl,ch
3259
	jnz	invalid_address
3260
	cmp	[segment_register],1
3261
	ja	invalid_address
3262
	push	ebx
3263
	lods	byte [esi]
3264
	cmp	al,','
3265
	jne	invalid_operand
3266
	lods	byte [esi]
3267
	call	get_size_operator
3268
	cmp	al,'['
3269
	jne	invalid_operand
3270
	call	get_address
3271
	pop	edx
3272
	or	eax,eax
3273
	jnz	invalid_address
3274
	or	bl,ch
3275
	jnz	invalid_address
3276
	mov	al,dh
3277
	mov	ah,bh
3278
	shr	al,4
3279
	shr	ah,4
3280
	cmp	al,ah
3281
	jne	address_sizes_do_not_agree
3282
	and	bh,111b
3283
	and	dh,111b
3284
	cmp	bh,6
3285
	jne	invalid_address
3286
	cmp	dh,7
3287
	jne	invalid_address
3288
	cmp	al,2
3289
	je	movs_address_16bit
3290
	cmp	al,4
3291
	je	movs_address_32bit
3292
	cmp	[code_type],64
3293
	jne	invalid_address_size
3294
	jmp	movs_store
3295
      movs_address_32bit:
3296
	call	address_32bit_prefix
3297
	jmp	movs_store
3298
      movs_address_16bit:
3299
	cmp	[code_type],64
3300
	je	invalid_address_size
3301
	call	address_16bit_prefix
3302
      movs_store:
3303
	xor	ebx,ebx
3304
	call	store_segment_prefix_if_necessary
3305
	mov	al,0A4h
3306
      movs_check_size:
3307
	mov	bl,[operand_size]
3308
	cmp	bl,1
3309
	je	simple_instruction
3310
	inc	al
3311
	cmp	bl,2
3312
	je	simple_instruction_16bit
3313
	cmp	bl,4
3314
	je	simple_instruction_32bit
3315
	cmp	bl,8
3316
	je	simple_instruction_64bit
3317
	or	bl,bl
3318
	jnz	invalid_operand_size
3319
	call	recoverable_unknown_size
3320
	jmp	simple_instruction
3321
lods_instruction:
3322
	lods	byte [esi]
3323
	call	get_size_operator
3324
	cmp	al,'['
3325
	jne	invalid_operand
3326
	call	get_address
3327
	or	eax,eax
3328
	jnz	invalid_address
3329
	or	bl,ch
3330
	jnz	invalid_address
3331
	cmp	bh,26h
3332
	je	lods_address_16bit
3333
	cmp	bh,46h
3334
	je	lods_address_32bit
3335
	cmp	bh,86h
3336
	jne	invalid_address
3337
	cmp	[code_type],64
3338
	jne	invalid_address_size
3339
	jmp	lods_store
3340
      lods_address_32bit:
3341
	call	address_32bit_prefix
3342
	jmp	lods_store
3343
      lods_address_16bit:
3344
	cmp	[code_type],64
3345
	je	invalid_address_size
3346
	call	address_16bit_prefix
3347
      lods_store:
3348
	xor	ebx,ebx
3349
	call	store_segment_prefix_if_necessary
3350
	mov	al,0ACh
3351
	jmp	movs_check_size
3352
stos_instruction:
3353
	mov	[base_code],al
3354
	lods	byte [esi]
3355
	call	get_size_operator
3356
	cmp	al,'['
3357
	jne	invalid_operand
3358
	call	get_address
3359
	or	eax,eax
3360
	jnz	invalid_address
3361
	or	bl,ch
3362
	jnz	invalid_address
3363
	cmp	bh,27h
3364
	je	stos_address_16bit
3365
	cmp	bh,47h
3366
	je	stos_address_32bit
3367
	cmp	bh,87h
3368
	jne	invalid_address
3369
	cmp	[code_type],64
3370
	jne	invalid_address_size
3371
	jmp	stos_store
3372
      stos_address_32bit:
3373
	call	address_32bit_prefix
3374
	jmp	stos_store
3375
      stos_address_16bit:
3376
	cmp	[code_type],64
3377
	je	invalid_address_size
3378
	call	address_16bit_prefix
3379
      stos_store:
3380
	cmp	[segment_register],1
3381
	ja	invalid_address
3382
	mov	al,[base_code]
3383
	jmp	movs_check_size
3384
cmps_instruction:
3385
	lods	byte [esi]
3386
	call	get_size_operator
3387
	cmp	al,'['
3388
	jne	invalid_operand
3389
	call	get_address
3390
	or	eax,eax
3391
	jnz	invalid_address
3392
	or	bl,ch
3393
	jnz	invalid_address
3394
	mov	al,[segment_register]
3395
	push	eax ebx
3396
	lods	byte [esi]
3397
	cmp	al,','
3398
	jne	invalid_operand
3399
	lods	byte [esi]
3400
	call	get_size_operator
3401
	cmp	al,'['
3402
	jne	invalid_operand
3403
	call	get_address
3404
	or	eax,eax
3405
	jnz	invalid_address
3406
	or	bl,ch
3407
	jnz	invalid_address
3408
	pop	edx eax
3409
	cmp	[segment_register],1
3410
	ja	invalid_address
3411
	mov	[segment_register],al
3412
	mov	al,dh
3413
	mov	ah,bh
3414
	shr	al,4
3415
	shr	ah,4
3416
	cmp	al,ah
3417
	jne	address_sizes_do_not_agree
3418
	and	bh,111b
3419
	and	dh,111b
3420
	cmp	bh,7
3421
	jne	invalid_address
3422
	cmp	dh,6
3423
	jne	invalid_address
3424
	cmp	al,2
3425
	je	cmps_address_16bit
3426
	cmp	al,4
3427
	je	cmps_address_32bit
3428
	cmp	[code_type],64
3429
	jne	invalid_address_size
3430
	jmp	cmps_store
3431
      cmps_address_32bit:
3432
	call	address_32bit_prefix
3433
	jmp	cmps_store
3434
      cmps_address_16bit:
3435
	cmp	[code_type],64
3436
	je	invalid_address_size
3437
	call	address_16bit_prefix
3438
      cmps_store:
3439
	xor	ebx,ebx
3440
	call	store_segment_prefix_if_necessary
3441
	mov	al,0A6h
3442
	jmp	movs_check_size
3443
ins_instruction:
3444
	lods	byte [esi]
3445
	call	get_size_operator
3446
	cmp	al,'['
3447
	jne	invalid_operand
3448
	call	get_address
3449
	or	eax,eax
3450
	jnz	invalid_address
3451
	or	bl,ch
3452
	jnz	invalid_address
3453
	cmp	bh,27h
3454
	je	ins_address_16bit
3455
	cmp	bh,47h
3456
	je	ins_address_32bit
3457
	cmp	bh,87h
3458
	jne	invalid_address
3459
	cmp	[code_type],64
3460
	jne	invalid_address_size
3461
	jmp	ins_store
3462
      ins_address_32bit:
3463
	call	address_32bit_prefix
3464
	jmp	ins_store
3465
      ins_address_16bit:
3466
	cmp	[code_type],64
3467
	je	invalid_address_size
3468
	call	address_16bit_prefix
3469
      ins_store:
3470
	cmp	[segment_register],1
3471
	ja	invalid_address
3472
	lods	byte [esi]
3473
	cmp	al,','
3474
	jne	invalid_operand
3475
	lods	byte [esi]
3476
	cmp	al,10h
3477
	jne	invalid_operand
3478
	lods	byte [esi]
3479
	cmp	al,22h
3480
	jne	invalid_operand
3481
	mov	al,6Ch
3482
      ins_check_size:
3483
	cmp	[operand_size],8
3484
	jne	movs_check_size
3485
	jmp	invalid_operand_size
3486
outs_instruction:
3487
	lods	byte [esi]
3488
	cmp	al,10h
3489
	jne	invalid_operand
3490
	lods	byte [esi]
3491
	cmp	al,22h
3492
	jne	invalid_operand
3493
	lods	byte [esi]
3494
	cmp	al,','
3495
	jne	invalid_operand
3496
	lods	byte [esi]
3497
	call	get_size_operator
3498
	cmp	al,'['
3499
	jne	invalid_operand
3500
	call	get_address
3501
	or	eax,eax
3502
	jnz	invalid_address
3503
	or	bl,ch
3504
	jnz	invalid_address
3505
	cmp	bh,26h
3506
	je	outs_address_16bit
3507
	cmp	bh,46h
3508
	je	outs_address_32bit
3509
	cmp	bh,86h
3510
	jne	invalid_address
3511
	cmp	[code_type],64
3512
	jne	invalid_address_size
3513
	jmp	outs_store
3514
      outs_address_32bit:
3515
	call	address_32bit_prefix
3516
	jmp	outs_store
3517
      outs_address_16bit:
3518
	cmp	[code_type],64
3519
	je	invalid_address_size
3520
	call	address_16bit_prefix
3521
      outs_store:
3522
	xor	ebx,ebx
3523
	call	store_segment_prefix_if_necessary
3524
	mov	al,6Eh
3525
	jmp	ins_check_size
3526
xlat_instruction:
3527
	lods	byte [esi]
3528
	call	get_size_operator
3529
	cmp	al,'['
3530
	jne	invalid_operand
3531
	call	get_address
3532
	or	eax,eax
3533
	jnz	invalid_address
3534
	or	bl,ch
3535
	jnz	invalid_address
3536
	cmp	bh,23h
3537
	je	xlat_address_16bit
3538
	cmp	bh,43h
3539
	je	xlat_address_32bit
3540
	cmp	bh,83h
3541
	jne	invalid_address
3542
	cmp	[code_type],64
3543
	jne	invalid_address_size
3544
	jmp	xlat_store
3545
      xlat_address_32bit:
3546
	call	address_32bit_prefix
3547
	jmp	xlat_store
3548
      xlat_address_16bit:
3549
	cmp	[code_type],64
3550
	je	invalid_address_size
3551
	call	address_16bit_prefix
3552
      xlat_store:
3553
	call	store_segment_prefix_if_necessary
3554
	mov	al,0D7h
3555
	cmp	[operand_size],1
3556
	jbe	simple_instruction
3557
	jmp	invalid_operand_size
3558
3559
 
3560
	mov	ah,al
3561
	shr	ah,4
3562
	and	al,111b
3563
	mov	[base_code],0Fh
3564
	mov	[extended_code],ah
3565
	mov	[postbyte_register],al
3566
	lods	byte [esi]
3567
	call	get_size_operator
3568
	cmp	al,10h
3569
	je	pm_reg
3570
      pm_mem:
3571
	cmp	al,'['
3572
	jne	invalid_operand
3573
	call	get_address
3574
	mov	al,[operand_size]
3575
	cmp	al,2
3576
	je	pm_mem_store
3577
	or	al,al
3578
	jnz	invalid_operand_size
3579
      pm_mem_store:
3580
	jmp	instruction_ready
3581
      pm_reg:
3582
	lods	byte [esi]
3583
	call	convert_register
3584
	mov	bl,al
3585
	cmp	ah,2
3586
	jne	invalid_operand_size
3587
	jmp	nomem_instruction_ready
3588
pm_store_word_instruction:
3589
	mov	ah,al
3590
	shr	ah,4
3591
	and	al,111b
3592
	mov	[base_code],0Fh
3593
	mov	[extended_code],ah
3594
	mov	[postbyte_register],al
3595
	lods	byte [esi]
3596
	call	get_size_operator
3597
	cmp	al,10h
3598
	jne	pm_mem
3599
	lods	byte [esi]
3600
	call	convert_register
3601
	mov	bl,al
3602
	mov	al,ah
3603
	call	operand_autodetect
3604
	jmp	nomem_instruction_ready
3605
lgdt_instruction:
3606
	mov	[base_code],0Fh
3607
	mov	[extended_code],1
3608
	mov	[postbyte_register],al
3609
	lods	byte [esi]
3610
	call	get_size_operator
3611
	cmp	al,'['
3612
	jne	invalid_operand
3613
	call	get_address
3614
	mov	al,[operand_size]
3615
	cmp	al,6
3616
	je	lgdt_mem_48bit
3617
	cmp	al,10
3618
	je	lgdt_mem_80bit
3619
	or	al,al
3620
	jnz	invalid_operand_size
3621
	jmp	lgdt_mem_store
3622
      lgdt_mem_80bit:
3623
	cmp	[code_type],64
3624
	jne	illegal_instruction
3625
	jmp	lgdt_mem_store
3626
      lgdt_mem_48bit:
3627
	cmp	[code_type],64
3628
	je	illegal_instruction
3629
	cmp	[postbyte_register],2
3630
	jb	lgdt_mem_store
3631
	call	operand_32bit
3632
      lgdt_mem_store:
3633
	jmp	instruction_ready
3634
lar_instruction:
3635
	mov	[extended_code],al
3636
	mov	[base_code],0Fh
3637
	call	take_register
3638
	mov	[postbyte_register],al
3639
	lods	byte [esi]
3640
	cmp	al,','
3641
	jne	invalid_operand
3642
	xor	al,al
3643
	xchg	al,[operand_size]
3644
	call	operand_autodetect
3645
	lods	byte [esi]
3646
	call	get_size_operator
3647
	cmp	al,10h
3648
	je	lar_reg_reg
3649
	cmp	al,'['
3650
	jne	invalid_operand
3651
	call	get_address
3652
	mov	al,[operand_size]
3653
	or	al,al
3654
	jz	lar_reg_mem
3655
	cmp	al,2
3656
	jne	invalid_operand_size
3657
      lar_reg_mem:
3658
	jmp	instruction_ready
3659
      lar_reg_reg:
3660
	lods	byte [esi]
3661
	call	convert_register
3662
	cmp	ah,2
3663
	jne	invalid_operand_size
3664
	mov	bl,al
3665
	jmp	nomem_instruction_ready
3666
invlpg_instruction:
3667
	mov	[base_code],0Fh
3668
	mov	[extended_code],1
3669
	mov	[postbyte_register],7
3670
	lods	byte [esi]
3671
	call	get_size_operator
3672
	cmp	al,'['
3673
	jne	invalid_operand
3674
	call	get_address
3675
	jmp	instruction_ready
3676
mcommit_instruction:
3677
	mov	byte [edi],0F3h
3678
	inc	edi
3679
	jmp	simple_instruction_0f_01
3680
swapgs_instruction:
3681
	cmp	[code_type],64
3682
	jne	illegal_instruction
3683
simple_instruction_0f_01:
3684
	mov	ah,al
3685
	mov	al,0Fh
3686
	stos	byte [edi]
3687
	mov	al,1
3688
	stos	word [edi]
3689
	jmp	instruction_assembled
3690
3691
 
3692
	mov	[base_code],0Fh
3693
	mov	[extended_code],al
3694
	lods	byte [esi]
3695
	call	get_size_operator
3696
	cmp	al,10h
3697
	je	basic_486_reg
3698
	cmp	al,'['
3699
	jne	invalid_operand
3700
	call	get_address
3701
	push	edx ebx ecx
3702
	lods	byte [esi]
3703
	cmp	al,','
3704
	jne	invalid_operand
3705
	call	take_register
3706
	mov	[postbyte_register],al
3707
	pop	ecx ebx edx
3708
	mov	al,ah
3709
	cmp	al,1
3710
	je	basic_486_mem_reg_8bit
3711
	call	operand_autodetect
3712
	inc	[extended_code]
3713
      basic_486_mem_reg_8bit:
3714
	jmp	instruction_ready
3715
      basic_486_reg:
3716
	lods	byte [esi]
3717
	call	convert_register
3718
	mov	[postbyte_register],al
3719
	lods	byte [esi]
3720
	cmp	al,','
3721
	jne	invalid_operand
3722
	call	take_register
3723
	mov	bl,al
3724
	xchg	bl,[postbyte_register]
3725
	mov	al,ah
3726
	cmp	al,1
3727
	je	basic_486_reg_reg_8bit
3728
	call	operand_autodetect
3729
	inc	[extended_code]
3730
      basic_486_reg_reg_8bit:
3731
	jmp	nomem_instruction_ready
3732
bswap_instruction:
3733
	call	take_register
3734
	test	al,1000b
3735
	jz	bswap_reg_code_ok
3736
	or	[rex_prefix],41h
3737
	and	al,111b
3738
      bswap_reg_code_ok:
3739
	add	al,0C8h
3740
	mov	[extended_code],al
3741
	mov	[base_code],0Fh
3742
	cmp	ah,8
3743
	je	bswap_reg64
3744
	cmp	ah,4
3745
	jne	invalid_operand_size
3746
	call	operand_32bit
3747
	call	store_classic_instruction_code
3748
	jmp	instruction_assembled
3749
      bswap_reg64:
3750
	call	operand_64bit
3751
	call	store_classic_instruction_code
3752
	jmp	instruction_assembled
3753
cmpxchgx_instruction:
3754
	mov	[base_code],0Fh
3755
	mov	[extended_code],0C7h
3756
	mov	[postbyte_register],al
3757
	lods	byte [esi]
3758
	call	get_size_operator
3759
	cmp	al,'['
3760
	jne	invalid_operand
3761
	call	get_address
3762
	mov	ah,1
3763
	xchg	[postbyte_register],ah
3764
	mov	al,[operand_size]
3765
	or	al,al
3766
	jz	cmpxchgx_size_ok
3767
	cmp	al,ah
3768
	jne	invalid_operand_size
3769
      cmpxchgx_size_ok:
3770
	cmp	ah,16
3771
	jne	cmpxchgx_store
3772
	call	operand_64bit
3773
      cmpxchgx_store:
3774
	jmp	instruction_ready
3775
nop_instruction:
3776
	mov	ah,[esi]
3777
	cmp	ah,10h
3778
	je	extended_nop
3779
	cmp	ah,11h
3780
	je	extended_nop
3781
	cmp	ah,'['
3782
	je	extended_nop
3783
	stos	byte [edi]
3784
	jmp	instruction_assembled
3785
      extended_nop:
3786
	mov	[base_code],0Fh
3787
	mov	[extended_code],1Fh
3788
	mov	[postbyte_register],0
3789
	lods	byte [esi]
3790
	call	get_size_operator
3791
	cmp	al,10h
3792
	je	extended_nop_reg
3793
	cmp	al,'['
3794
	jne	invalid_operand
3795
	call	get_address
3796
	mov	al,[operand_size]
3797
	or	al,al
3798
	jz	extended_nop_store
3799
	call	operand_autodetect
3800
      extended_nop_store:
3801
	jmp	instruction_ready
3802
      extended_nop_reg:
3803
	lods	byte [esi]
3804
	call	convert_register
3805
	mov	bl,al
3806
	mov	al,ah
3807
	call	operand_autodetect
3808
	jmp	nomem_instruction_ready
3809
3810
 
3811
	mov	[postbyte_register],al
3812
	mov	[base_code],0D8h
3813
	lods	byte [esi]
3814
	call	get_size_operator
3815
	cmp	al,10h
3816
	je	basic_fpu_streg
3817
	cmp	al,'['
3818
	je	basic_fpu_mem
3819
	dec	esi
3820
	mov	ah,[postbyte_register]
3821
	cmp	ah,2
3822
	jb	invalid_operand
3823
	cmp	ah,3
3824
	ja	invalid_operand
3825
	mov	bl,1
3826
	jmp	nomem_instruction_ready
3827
      basic_fpu_mem:
3828
	call	get_address
3829
	mov	al,[operand_size]
3830
	cmp	al,4
3831
	je	basic_fpu_mem_32bit
3832
	cmp	al,8
3833
	je	basic_fpu_mem_64bit
3834
	or	al,al
3835
	jnz	invalid_operand_size
3836
	call	recoverable_unknown_size
3837
      basic_fpu_mem_32bit:
3838
	jmp	instruction_ready
3839
      basic_fpu_mem_64bit:
3840
	mov	[base_code],0DCh
3841
	jmp	instruction_ready
3842
      basic_fpu_streg:
3843
	lods	byte [esi]
3844
	call	convert_fpu_register
3845
	mov	bl,al
3846
	mov	ah,[postbyte_register]
3847
	cmp	ah,2
3848
	je	basic_fpu_single_streg
3849
	cmp	ah,3
3850
	je	basic_fpu_single_streg
3851
	or	al,al
3852
	jz	basic_fpu_st0
3853
	test	ah,110b
3854
	jz	basic_fpu_streg_st0
3855
	xor	[postbyte_register],1
3856
      basic_fpu_streg_st0:
3857
	lods	byte [esi]
3858
	cmp	al,','
3859
	jne	invalid_operand
3860
	lods	byte [esi]
3861
	call	get_size_operator
3862
	cmp	al,10h
3863
	jne	invalid_operand
3864
	lods	byte [esi]
3865
	call	convert_fpu_register
3866
	or	al,al
3867
	jnz	invalid_operand
3868
	mov	[base_code],0DCh
3869
	jmp	nomem_instruction_ready
3870
      basic_fpu_st0:
3871
	lods	byte [esi]
3872
	cmp	al,','
3873
	jne	invalid_operand
3874
	lods	byte [esi]
3875
	call	get_size_operator
3876
	cmp	al,10h
3877
	jne	invalid_operand
3878
	lods	byte [esi]
3879
	call	convert_fpu_register
3880
	mov	bl,al
3881
      basic_fpu_single_streg:
3882
	mov	[base_code],0D8h
3883
	jmp	nomem_instruction_ready
3884
simple_fpu_instruction:
3885
	mov	ah,al
3886
	or	ah,11000000b
3887
	mov	al,0D9h
3888
	stos	word [edi]
3889
	jmp	instruction_assembled
3890
fi_instruction:
3891
	mov	[postbyte_register],al
3892
	lods	byte [esi]
3893
	call	get_size_operator
3894
	cmp	al,'['
3895
	jne	invalid_operand
3896
	call	get_address
3897
	mov	al,[operand_size]
3898
	cmp	al,2
3899
	je	fi_mem_16bit
3900
	cmp	al,4
3901
	je	fi_mem_32bit
3902
	or	al,al
3903
	jnz	invalid_operand_size
3904
	call	recoverable_unknown_size
3905
      fi_mem_32bit:
3906
	mov	[base_code],0DAh
3907
	jmp	instruction_ready
3908
      fi_mem_16bit:
3909
	mov	[base_code],0DEh
3910
	jmp	instruction_ready
3911
fld_instruction:
3912
	mov	[postbyte_register],al
3913
	lods	byte [esi]
3914
	call	get_size_operator
3915
	cmp	al,10h
3916
	je	fld_streg
3917
	cmp	al,'['
3918
	jne	invalid_operand
3919
	call	get_address
3920
	mov	al,[operand_size]
3921
	cmp	al,4
3922
	je	fld_mem_32bit
3923
	cmp	al,8
3924
	je	fld_mem_64bit
3925
	cmp	al,10
3926
	je	fld_mem_80bit
3927
	or	al,al
3928
	jnz	invalid_operand_size
3929
	call	recoverable_unknown_size
3930
      fld_mem_32bit:
3931
	mov	[base_code],0D9h
3932
	jmp	instruction_ready
3933
      fld_mem_64bit:
3934
	mov	[base_code],0DDh
3935
	jmp	instruction_ready
3936
      fld_mem_80bit:
3937
	mov	al,[postbyte_register]
3938
	cmp	al,0
3939
	je	fld_mem_80bit_store
3940
	dec	[postbyte_register]
3941
	cmp	al,3
3942
	je	fld_mem_80bit_store
3943
	jmp	invalid_operand_size
3944
      fld_mem_80bit_store:
3945
	add	[postbyte_register],5
3946
	mov	[base_code],0DBh
3947
	jmp	instruction_ready
3948
      fld_streg:
3949
	lods	byte [esi]
3950
	call	convert_fpu_register
3951
	mov	bl,al
3952
	cmp	[postbyte_register],2
3953
	jae	fst_streg
3954
	mov	[base_code],0D9h
3955
	jmp	nomem_instruction_ready
3956
      fst_streg:
3957
	mov	[base_code],0DDh
3958
	jmp	nomem_instruction_ready
3959
fild_instruction:
3960
	mov	[postbyte_register],al
3961
	lods	byte [esi]
3962
	call	get_size_operator
3963
	cmp	al,'['
3964
	jne	invalid_operand
3965
	call	get_address
3966
	mov	al,[operand_size]
3967
	cmp	al,2
3968
	je	fild_mem_16bit
3969
	cmp	al,4
3970
	je	fild_mem_32bit
3971
	cmp	al,8
3972
	je	fild_mem_64bit
3973
	or	al,al
3974
	jnz	invalid_operand_size
3975
	call	recoverable_unknown_size
3976
      fild_mem_32bit:
3977
	mov	[base_code],0DBh
3978
	jmp	instruction_ready
3979
      fild_mem_16bit:
3980
	mov	[base_code],0DFh
3981
	jmp	instruction_ready
3982
      fild_mem_64bit:
3983
	mov	al,[postbyte_register]
3984
	cmp	al,1
3985
	je	fisttp_64bit_store
3986
	jb	fild_mem_64bit_store
3987
	dec	[postbyte_register]
3988
	cmp	al,3
3989
	je	fild_mem_64bit_store
3990
	jmp	invalid_operand_size
3991
      fild_mem_64bit_store:
3992
	add	[postbyte_register],5
3993
	mov	[base_code],0DFh
3994
	jmp	instruction_ready
3995
      fisttp_64bit_store:
3996
	mov	[base_code],0DDh
3997
	jmp	instruction_ready
3998
fbld_instruction:
3999
	mov	[postbyte_register],al
4000
	lods	byte [esi]
4001
	call	get_size_operator
4002
	cmp	al,'['
4003
	jne	invalid_operand
4004
	call	get_address
4005
	mov	al,[operand_size]
4006
	or	al,al
4007
	jz	fbld_mem_80bit
4008
	cmp	al,10
4009
	je	fbld_mem_80bit
4010
	jmp	invalid_operand_size
4011
      fbld_mem_80bit:
4012
	mov	[base_code],0DFh
4013
	jmp	instruction_ready
4014
faddp_instruction:
4015
	mov	[postbyte_register],al
4016
	mov	[base_code],0DEh
4017
	mov	edx,esi
4018
	lods	byte [esi]
4019
	call	get_size_operator
4020
	cmp	al,10h
4021
	je	faddp_streg
4022
	mov	esi,edx
4023
	mov	bl,1
4024
	jmp	nomem_instruction_ready
4025
      faddp_streg:
4026
	lods	byte [esi]
4027
	call	convert_fpu_register
4028
	mov	bl,al
4029
	lods	byte [esi]
4030
	cmp	al,','
4031
	jne	invalid_operand
4032
	lods	byte [esi]
4033
	call	get_size_operator
4034
	cmp	al,10h
4035
	jne	invalid_operand
4036
	lods	byte [esi]
4037
	call	convert_fpu_register
4038
	or	al,al
4039
	jnz	invalid_operand
4040
	jmp	nomem_instruction_ready
4041
fcompp_instruction:
4042
	mov	ax,0D9DEh
4043
	stos	word [edi]
4044
	jmp	instruction_assembled
4045
fucompp_instruction:
4046
	mov	ax,0E9DAh
4047
	stos	word [edi]
4048
	jmp	instruction_assembled
4049
fxch_instruction:
4050
	mov	dx,01D9h
4051
	jmp	fpu_single_operand
4052
ffreep_instruction:
4053
	mov	dx,00DFh
4054
	jmp	fpu_single_operand
4055
ffree_instruction:
4056
	mov	dl,0DDh
4057
	mov	dh,al
4058
      fpu_single_operand:
4059
	mov	ebx,esi
4060
	lods	byte [esi]
4061
	call	get_size_operator
4062
	cmp	al,10h
4063
	je	fpu_streg
4064
	or	dh,dh
4065
	jz	invalid_operand
4066
	mov	esi,ebx
4067
	shl	dh,3
4068
	or	dh,11000001b
4069
	mov	ax,dx
4070
	stos	word [edi]
4071
	jmp	instruction_assembled
4072
      fpu_streg:
4073
	lods	byte [esi]
4074
	call	convert_fpu_register
4075
	shl	dh,3
4076
	or	dh,al
4077
	or	dh,11000000b
4078
	mov	ax,dx
4079
	stos	word [edi]
4080
	jmp	instruction_assembled
4081
4082
 
4083
	mov	byte [edi],9Bh
4084
	inc	edi
4085
fldenv_instruction:
4086
	mov	[base_code],0D9h
4087
	jmp	fpu_mem
4088
fstenv_instruction_16bit:
4089
	mov	byte [edi],9Bh
4090
	inc	edi
4091
fldenv_instruction_16bit:
4092
	call	operand_16bit
4093
	jmp	fldenv_instruction
4094
fstenv_instruction_32bit:
4095
	mov	byte [edi],9Bh
4096
	inc	edi
4097
fldenv_instruction_32bit:
4098
	call	operand_32bit
4099
	jmp	fldenv_instruction
4100
fsave_instruction_32bit:
4101
	mov	byte [edi],9Bh
4102
	inc	edi
4103
fnsave_instruction_32bit:
4104
	call	operand_32bit
4105
	jmp	fnsave_instruction
4106
fsave_instruction_16bit:
4107
	mov	byte [edi],9Bh
4108
	inc	edi
4109
fnsave_instruction_16bit:
4110
	call	operand_16bit
4111
	jmp	fnsave_instruction
4112
fsave_instruction:
4113
	mov	byte [edi],9Bh
4114
	inc	edi
4115
fnsave_instruction:
4116
	mov	[base_code],0DDh
4117
      fpu_mem:
4118
	mov	[postbyte_register],al
4119
	lods	byte [esi]
4120
	call	get_size_operator
4121
	cmp	al,'['
4122
	jne	invalid_operand
4123
	call	get_address
4124
	cmp	[operand_size],0
4125
	jne	invalid_operand_size
4126
	jmp	instruction_ready
4127
fstcw_instruction:
4128
	mov	byte [edi],9Bh
4129
	inc	edi
4130
fldcw_instruction:
4131
	mov	[postbyte_register],al
4132
	mov	[base_code],0D9h
4133
	lods	byte [esi]
4134
	call	get_size_operator
4135
	cmp	al,'['
4136
	jne	invalid_operand
4137
	call	get_address
4138
	mov	al,[operand_size]
4139
	or	al,al
4140
	jz	fldcw_mem_16bit
4141
	cmp	al,2
4142
	je	fldcw_mem_16bit
4143
	jmp	invalid_operand_size
4144
      fldcw_mem_16bit:
4145
	jmp	instruction_ready
4146
fstsw_instruction:
4147
	mov	al,9Bh
4148
	stos	byte [edi]
4149
fnstsw_instruction:
4150
	mov	[base_code],0DDh
4151
	mov	[postbyte_register],7
4152
	lods	byte [esi]
4153
	call	get_size_operator
4154
	cmp	al,10h
4155
	je	fstsw_reg
4156
	cmp	al,'['
4157
	jne	invalid_operand
4158
	call	get_address
4159
	mov	al,[operand_size]
4160
	or	al,al
4161
	jz	fstsw_mem_16bit
4162
	cmp	al,2
4163
	je	fstsw_mem_16bit
4164
	jmp	invalid_operand_size
4165
      fstsw_mem_16bit:
4166
	jmp	instruction_ready
4167
      fstsw_reg:
4168
	lods	byte [esi]
4169
	call	convert_register
4170
	cmp	ax,0200h
4171
	jne	invalid_operand
4172
	mov	ax,0E0DFh
4173
	stos	word [edi]
4174
	jmp	instruction_assembled
4175
finit_instruction:
4176
	mov	byte [edi],9Bh
4177
	inc	edi
4178
fninit_instruction:
4179
	mov	ah,al
4180
	mov	al,0DBh
4181
	stos	word [edi]
4182
	jmp	instruction_assembled
4183
fcmov_instruction:
4184
	mov	dh,0DAh
4185
	jmp	fcomi_streg
4186
fcomi_instruction:
4187
	mov	dh,0DBh
4188
	jmp	fcomi_streg
4189
fcomip_instruction:
4190
	mov	dh,0DFh
4191
      fcomi_streg:
4192
	mov	dl,al
4193
	lods	byte [esi]
4194
	call	get_size_operator
4195
	cmp	al,10h
4196
	jne	invalid_operand
4197
	lods	byte [esi]
4198
	call	convert_fpu_register
4199
	mov	ah,al
4200
	cmp	byte [esi],','
4201
	je	fcomi_st0_streg
4202
	add	ah,dl
4203
	mov	al,dh
4204
	stos	word [edi]
4205
	jmp	instruction_assembled
4206
      fcomi_st0_streg:
4207
	or	ah,ah
4208
	jnz	invalid_operand
4209
	inc	esi
4210
	lods	byte [esi]
4211
	call	get_size_operator
4212
	cmp	al,10h
4213
	jne	invalid_operand
4214
	lods	byte [esi]
4215
	call	convert_fpu_register
4216
	mov	ah,al
4217
	add	ah,dl
4218
	mov	al,dh
4219
	stos	word [edi]
4220
	jmp	instruction_assembled
4221
4222
 
4223
	mov	[base_code],0Fh
4224
	mov	[extended_code],al
4225
      mmx_instruction:
4226
	lods	byte [esi]
4227
	call	get_size_operator
4228
	cmp	al,10h
4229
	jne	invalid_operand
4230
	lods	byte [esi]
4231
	call	convert_mmx_register
4232
	call	make_mmx_prefix
4233
	mov	[postbyte_register],al
4234
	lods	byte [esi]
4235
	cmp	al,','
4236
	jne	invalid_operand
4237
	lods	byte [esi]
4238
	call	get_size_operator
4239
	cmp	al,10h
4240
	je	mmx_mmreg_mmreg
4241
	cmp	al,'['
4242
	jne	invalid_operand
4243
      mmx_mmreg_mem:
4244
	call	get_address
4245
	jmp	instruction_ready
4246
      mmx_mmreg_mmreg:
4247
	lods	byte [esi]
4248
	call	convert_mmx_register
4249
	mov	bl,al
4250
	jmp	nomem_instruction_ready
4251
mmx_bit_shift_instruction:
4252
	mov	[base_code],0Fh
4253
	mov	[extended_code],al
4254
	lods	byte [esi]
4255
	call	get_size_operator
4256
	cmp	al,10h
4257
	jne	invalid_operand
4258
	lods	byte [esi]
4259
	call	convert_mmx_register
4260
	call	make_mmx_prefix
4261
	mov	[postbyte_register],al
4262
	lods	byte [esi]
4263
	cmp	al,','
4264
	jne	invalid_operand
4265
	mov	[operand_size],0
4266
	lods	byte [esi]
4267
	call	get_size_operator
4268
	cmp	al,10h
4269
	je	mmx_mmreg_mmreg
4270
	cmp	al,'('
4271
	je	mmx_ps_mmreg_imm8
4272
	cmp	al,'['
4273
	je	mmx_mmreg_mem
4274
	jmp	invalid_operand
4275
      mmx_ps_mmreg_imm8:
4276
	call	get_byte_value
4277
	mov	byte [value],al
4278
	test	[operand_size],not 1
4279
	jnz	invalid_value
4280
	mov	bl,[extended_code]
4281
	mov	al,bl
4282
	shr	bl,4
4283
	and	al,1111b
4284
	add	al,70h
4285
	mov	[extended_code],al
4286
	sub	bl,0Ch
4287
	shl	bl,1
4288
	xchg	bl,[postbyte_register]
4289
	call	store_nomem_instruction
4290
	mov	al,byte [value]
4291
	stos	byte [edi]
4292
	jmp	instruction_assembled
4293
pmovmskb_instruction:
4294
	mov	[base_code],0Fh
4295
	mov	[extended_code],al
4296
	call	take_register
4297
	cmp	ah,4
4298
	je	pmovmskb_reg_size_ok
4299
	cmp	[code_type],64
4300
	jne	invalid_operand_size
4301
	cmp	ah,8
4302
	jnz	invalid_operand_size
4303
      pmovmskb_reg_size_ok:
4304
	mov	[postbyte_register],al
4305
	mov	[operand_size],0
4306
	lods	byte [esi]
4307
	cmp	al,','
4308
	jne	invalid_operand
4309
	lods	byte [esi]
4310
	call	get_size_operator
4311
	cmp	al,10h
4312
	jne	invalid_operand
4313
	lods	byte [esi]
4314
	call	convert_mmx_register
4315
	mov	bl,al
4316
	call	make_mmx_prefix
4317
	cmp	[extended_code],0C5h
4318
	je	mmx_nomem_imm8
4319
	jmp	nomem_instruction_ready
4320
      mmx_imm8:
4321
	push	ebx ecx edx
4322
	xor	cl,cl
4323
	xchg	cl,[operand_size]
4324
	lods	byte [esi]
4325
	cmp	al,','
4326
	jne	invalid_operand
4327
	lods	byte [esi]
4328
	call	get_size_operator
4329
	test	ah,not 1
4330
	jnz	invalid_operand_size
4331
	mov	[operand_size],cl
4332
	cmp	al,'('
4333
	jne	invalid_operand
4334
	call	get_byte_value
4335
	mov	byte [value],al
4336
	pop	edx ecx ebx
4337
	call	store_instruction_with_imm8
4338
	jmp	instruction_assembled
4339
      mmx_nomem_imm8:
4340
	call	store_nomem_instruction
4341
	call	append_imm8
4342
	jmp	instruction_assembled
4343
      append_imm8:
4344
	mov	[operand_size],0
4345
	lods	byte [esi]
4346
	cmp	al,','
4347
	jne	invalid_operand
4348
	lods	byte [esi]
4349
	call	get_size_operator
4350
	test	ah,not 1
4351
	jnz	invalid_operand_size
4352
	cmp	al,'('
4353
	jne	invalid_operand
4354
	call	get_byte_value
4355
	stosb
4356
	ret
4357
pinsrw_instruction:
4358
	mov	[extended_code],al
4359
	mov	[base_code],0Fh
4360
	lods	byte [esi]
4361
	call	get_size_operator
4362
	cmp	al,10h
4363
	jne	invalid_operand
4364
	lods	byte [esi]
4365
	call	convert_mmx_register
4366
	call	make_mmx_prefix
4367
	mov	[postbyte_register],al
4368
	mov	[operand_size],0
4369
	lods	byte [esi]
4370
	cmp	al,','
4371
	jne	invalid_operand
4372
	lods	byte [esi]
4373
	call	get_size_operator
4374
	cmp	al,10h
4375
	je	pinsrw_mmreg_reg
4376
	cmp	al,'['
4377
	jne	invalid_operand
4378
	call	get_address
4379
	cmp	[operand_size],0
4380
	je	mmx_imm8
4381
	cmp	[operand_size],2
4382
	jne	invalid_operand_size
4383
	jmp	mmx_imm8
4384
      pinsrw_mmreg_reg:
4385
	lods	byte [esi]
4386
	call	convert_register
4387
	cmp	ah,4
4388
	jne	invalid_operand_size
4389
	mov	bl,al
4390
	jmp	mmx_nomem_imm8
4391
pshufw_instruction:
4392
	mov	[mmx_size],8
4393
	mov	[opcode_prefix],al
4394
	jmp	pshuf_instruction
4395
pshufd_instruction:
4396
	mov	[mmx_size],16
4397
	mov	[opcode_prefix],al
4398
      pshuf_instruction:
4399
	mov	[base_code],0Fh
4400
	mov	[extended_code],70h
4401
	lods	byte [esi]
4402
	call	get_size_operator
4403
	cmp	al,10h
4404
	jne	invalid_operand
4405
	lods	byte [esi]
4406
	call	convert_mmx_register
4407
	cmp	ah,[mmx_size]
4408
	jne	invalid_operand_size
4409
	mov	[postbyte_register],al
4410
	lods	byte [esi]
4411
	cmp	al,','
4412
	jne	invalid_operand
4413
	lods	byte [esi]
4414
	call	get_size_operator
4415
	cmp	al,10h
4416
	je	pshuf_mmreg_mmreg
4417
	cmp	al,'['
4418
	jne	invalid_operand
4419
	call	get_address
4420
	jmp	mmx_imm8
4421
      pshuf_mmreg_mmreg:
4422
	lods	byte [esi]
4423
	call	convert_mmx_register
4424
	mov	bl,al
4425
	jmp	mmx_nomem_imm8
4426
movd_instruction:
4427
	mov	[base_code],0Fh
4428
	mov	[extended_code],7Eh
4429
	lods	byte [esi]
4430
	call	get_size_operator
4431
	cmp	al,10h
4432
	je	movd_reg
4433
	cmp	al,'['
4434
	jne	invalid_operand
4435
	call	get_address
4436
	test	[operand_size],not 4
4437
	jnz	invalid_operand_size
4438
	call	get_mmx_source_register
4439
	jmp	instruction_ready
4440
      movd_reg:
4441
	lods	byte [esi]
4442
	cmp	al,0B0h
4443
	jae	movd_mmreg
4444
	call	convert_register
4445
	cmp	ah,4
4446
	jne	invalid_operand_size
4447
	mov	bl,al
4448
	call	get_mmx_source_register
4449
	jmp	nomem_instruction_ready
4450
      movd_mmreg:
4451
	mov	[extended_code],6Eh
4452
	call	convert_mmx_register
4453
	mov	[postbyte_register],al
4454
	call	make_mmx_prefix
4455
	mov	[operand_size],0
4456
	lods	byte [esi]
4457
	cmp	al,','
4458
	jne	invalid_operand
4459
	lods	byte [esi]
4460
	call	get_size_operator
4461
	cmp	al,10h
4462
	je	movd_mmreg_reg
4463
	cmp	al,'['
4464
	jne	invalid_operand
4465
	call	get_address
4466
	test	[operand_size],not 4
4467
	jnz	invalid_operand_size
4468
	jmp	instruction_ready
4469
      movd_mmreg_reg:
4470
	lods	byte [esi]
4471
	call	convert_register
4472
	cmp	ah,4
4473
	jne	invalid_operand_size
4474
	mov	bl,al
4475
	jmp	nomem_instruction_ready
4476
      get_mmx_source_register:
4477
	mov	[operand_size],0
4478
	lods	byte [esi]
4479
	cmp	al,','
4480
	jne	invalid_operand
4481
	lods	byte [esi]
4482
	call	get_size_operator
4483
	cmp	al,10h
4484
	jne	invalid_operand
4485
	lods	byte [esi]
4486
	call	convert_mmx_register
4487
	mov	[postbyte_register],al
4488
      make_mmx_prefix:
4489
	cmp	[operand_size],16
4490
	jne	no_mmx_prefix
4491
	mov	[operand_prefix],66h
4492
      no_mmx_prefix:
4493
	ret
4494
movq_instruction:
4495
	mov	[base_code],0Fh
4496
	lods	byte [esi]
4497
	call	get_size_operator
4498
	cmp	al,10h
4499
	je	movq_reg
4500
	cmp	al,'['
4501
	jne	invalid_operand
4502
	call	get_address
4503
	test	[operand_size],not 8
4504
	jnz	invalid_operand_size
4505
	call	get_mmx_source_register
4506
	mov	al,7Fh
4507
	cmp	ah,8
4508
	je	movq_mem_ready
4509
	mov	al,0D6h
4510
     movq_mem_ready:
4511
	mov	[extended_code],al
4512
	jmp	instruction_ready
4513
     movq_reg:
4514
	lods	byte [esi]
4515
	cmp	al,0B0h
4516
	jae	movq_mmreg
4517
	call	convert_register
4518
	cmp	ah,8
4519
	jne	invalid_operand_size
4520
	mov	bl,al
4521
	mov	[extended_code],7Eh
4522
	call	operand_64bit
4523
	call	get_mmx_source_register
4524
	jmp	nomem_instruction_ready
4525
     movq_mmreg:
4526
	call	convert_mmx_register
4527
	mov	[postbyte_register],al
4528
	mov	[extended_code],6Fh
4529
	mov	[mmx_size],ah
4530
	cmp	ah,16
4531
	jne	movq_mmreg_
4532
	mov	[extended_code],7Eh
4533
	mov	[opcode_prefix],0F3h
4534
      movq_mmreg_:
4535
	lods	byte [esi]
4536
	cmp	al,','
4537
	jne	invalid_operand
4538
	mov	[operand_size],0
4539
	lods	byte [esi]
4540
	call	get_size_operator
4541
	cmp	al,10h
4542
	je	movq_mmreg_reg
4543
	cmp	al,'['
4544
	jne	invalid_operand
4545
	call	get_address
4546
	test	[operand_size],not 8
4547
	jnz	invalid_operand_size
4548
	jmp	instruction_ready
4549
      movq_mmreg_reg:
4550
	lods	byte [esi]
4551
	cmp	al,0B0h
4552
	jae	movq_mmreg_mmreg
4553
	mov	[operand_size],0
4554
	call	convert_register
4555
	cmp	ah,8
4556
	jne	invalid_operand_size
4557
	mov	[extended_code],6Eh
4558
	mov	[opcode_prefix],0
4559
	mov	bl,al
4560
	cmp	[mmx_size],16
4561
	jne	movq_mmreg_reg_store
4562
	mov	[opcode_prefix],66h
4563
      movq_mmreg_reg_store:
4564
	call	operand_64bit
4565
	jmp	nomem_instruction_ready
4566
      movq_mmreg_mmreg:
4567
	call	convert_mmx_register
4568
	cmp	ah,[mmx_size]
4569
	jne	invalid_operand_size
4570
	mov	bl,al
4571
	jmp	nomem_instruction_ready
4572
movdq_instruction:
4573
	mov	[opcode_prefix],al
4574
	mov	[base_code],0Fh
4575
	mov	[extended_code],6Fh
4576
	lods	byte [esi]
4577
	call	get_size_operator
4578
	cmp	al,10h
4579
	je	movdq_mmreg
4580
	cmp	al,'['
4581
	jne	invalid_operand
4582
	call	get_address
4583
	lods	byte [esi]
4584
	cmp	al,','
4585
	jne	invalid_operand
4586
	lods	byte [esi]
4587
	call	get_size_operator
4588
	cmp	al,10h
4589
	jne	invalid_operand
4590
	lods	byte [esi]
4591
	call	convert_xmm_register
4592
	mov	[postbyte_register],al
4593
	mov	[extended_code],7Fh
4594
	jmp	instruction_ready
4595
      movdq_mmreg:
4596
	lods	byte [esi]
4597
	call	convert_xmm_register
4598
	mov	[postbyte_register],al
4599
	lods	byte [esi]
4600
	cmp	al,','
4601
	jne	invalid_operand
4602
	lods	byte [esi]
4603
	call	get_size_operator
4604
	cmp	al,10h
4605
	je	movdq_mmreg_mmreg
4606
	cmp	al,'['
4607
	jne	invalid_operand
4608
	call	get_address
4609
	jmp	instruction_ready
4610
      movdq_mmreg_mmreg:
4611
	lods	byte [esi]
4612
	call	convert_xmm_register
4613
	mov	bl,al
4614
	jmp	nomem_instruction_ready
4615
lddqu_instruction:
4616
	lods	byte [esi]
4617
	call	get_size_operator
4618
	cmp	al,10h
4619
	jne	invalid_operand
4620
	lods	byte [esi]
4621
	call	convert_xmm_register
4622
	push	eax
4623
	lods	byte [esi]
4624
	cmp	al,','
4625
	jne	invalid_operand
4626
	lods	byte [esi]
4627
	call	get_size_operator
4628
	cmp	al,'['
4629
	jne	invalid_operand
4630
	call	get_address
4631
	pop	eax
4632
	mov	[postbyte_register],al
4633
	mov	[opcode_prefix],0F2h
4634
	mov	[base_code],0Fh
4635
	mov	[extended_code],0F0h
4636
	jmp	instruction_ready
4637
4638
 
4639
	mov	[opcode_prefix],0F2h
4640
	mov	[mmx_size],8
4641
	jmp	movq2dq_
4642
movq2dq_instruction:
4643
	mov	[opcode_prefix],0F3h
4644
	mov	[mmx_size],16
4645
      movq2dq_:
4646
	lods	byte [esi]
4647
	call	get_size_operator
4648
	cmp	al,10h
4649
	jne	invalid_operand
4650
	lods	byte [esi]
4651
	call	convert_mmx_register
4652
	cmp	ah,[mmx_size]
4653
	jne	invalid_operand_size
4654
	mov	[postbyte_register],al
4655
	mov	[operand_size],0
4656
	lods	byte [esi]
4657
	cmp	al,','
4658
	jne	invalid_operand
4659
	lods	byte [esi]
4660
	call	get_size_operator
4661
	cmp	al,10h
4662
	jne	invalid_operand
4663
	lods	byte [esi]
4664
	call	convert_mmx_register
4665
	xor	[mmx_size],8+16
4666
	cmp	ah,[mmx_size]
4667
	jne	invalid_operand_size
4668
	mov	bl,al
4669
	mov	[base_code],0Fh
4670
	mov	[extended_code],0D6h
4671
	jmp	nomem_instruction_ready
4672
4673
 
4674
	mov	[immediate_size],1
4675
sse_ps_instruction:
4676
	mov	[mmx_size],16
4677
	jmp	sse_instruction
4678
sse_pd_instruction_imm8:
4679
	mov	[immediate_size],1
4680
sse_pd_instruction:
4681
	mov	[mmx_size],16
4682
	mov	[opcode_prefix],66h
4683
	jmp	sse_instruction
4684
sse_ss_instruction:
4685
	mov	[mmx_size],4
4686
	mov	[opcode_prefix],0F3h
4687
	jmp	sse_instruction
4688
sse_sd_instruction:
4689
	mov	[mmx_size],8
4690
	mov	[opcode_prefix],0F2h
4691
	jmp	sse_instruction
4692
cmp_pd_instruction:
4693
	mov	[opcode_prefix],66h
4694
cmp_ps_instruction:
4695
	mov	[mmx_size],16
4696
	mov	byte [value],al
4697
	mov	al,0C2h
4698
	jmp	sse_instruction
4699
cmp_ss_instruction:
4700
	mov	[mmx_size],4
4701
	mov	[opcode_prefix],0F3h
4702
	jmp	cmp_sx_instruction
4703
cmpsd_instruction:
4704
	mov	al,0A7h
4705
	mov	ah,[esi]
4706
	or	ah,ah
4707
	jz	simple_instruction_32bit
4708
	cmp	ah,0Fh
4709
	je	simple_instruction_32bit
4710
	mov	al,-1
4711
cmp_sd_instruction:
4712
	mov	[mmx_size],8
4713
	mov	[opcode_prefix],0F2h
4714
      cmp_sx_instruction:
4715
	mov	byte [value],al
4716
	mov	al,0C2h
4717
	jmp	sse_instruction
4718
comiss_instruction:
4719
	mov	[mmx_size],4
4720
	jmp	sse_instruction
4721
comisd_instruction:
4722
	mov	[mmx_size],8
4723
	mov	[opcode_prefix],66h
4724
	jmp	sse_instruction
4725
cvtdq2pd_instruction:
4726
	mov	[opcode_prefix],0F3h
4727
cvtps2pd_instruction:
4728
	mov	[mmx_size],8
4729
	jmp	sse_instruction
4730
cvtpd2dq_instruction:
4731
	mov	[mmx_size],16
4732
	mov	[opcode_prefix],0F2h
4733
	jmp	sse_instruction
4734
movshdup_instruction:
4735
	mov	[mmx_size],16
4736
	mov	[opcode_prefix],0F3h
4737
sse_instruction:
4738
	mov	[base_code],0Fh
4739
	mov	[extended_code],al
4740
	lods	byte [esi]
4741
	call	get_size_operator
4742
	cmp	al,10h
4743
	jne	invalid_operand
4744
      sse_xmmreg:
4745
	lods	byte [esi]
4746
	call	convert_xmm_register
4747
      sse_reg:
4748
	mov	[postbyte_register],al
4749
	mov	[operand_size],0
4750
	lods	byte [esi]
4751
	cmp	al,','
4752
	jne	invalid_operand
4753
	lods	byte [esi]
4754
	call	get_size_operator
4755
	cmp	al,10h
4756
	je	sse_xmmreg_xmmreg
4757
      sse_reg_mem:
4758
	cmp	al,'['
4759
	jne	invalid_operand
4760
	call	get_address
4761
	cmp	[operand_size],0
4762
	je	sse_mem_size_ok
4763
	mov	al,[mmx_size]
4764
	cmp	[operand_size],al
4765
	jne	invalid_operand_size
4766
      sse_mem_size_ok:
4767
	mov	al,[extended_code]
4768
	mov	ah,[supplemental_code]
4769
	cmp	al,0C2h
4770
	je	sse_cmp_mem_ok
4771
	cmp	ax,443Ah
4772
	je	sse_cmp_mem_ok
4773
	cmp	[immediate_size],1
4774
	je	mmx_imm8
4775
	cmp	[immediate_size],-1
4776
	jne	sse_ok
4777
	call	take_additional_xmm0
4778
	mov	[immediate_size],0
4779
      sse_ok:
4780
	jmp	instruction_ready
4781
      sse_cmp_mem_ok:
4782
	cmp	byte [value],-1
4783
	je	mmx_imm8
4784
	call	store_instruction_with_imm8
4785
	jmp	instruction_assembled
4786
      sse_xmmreg_xmmreg:
4787
	cmp	[operand_prefix],66h
4788
	jne	sse_xmmreg_xmmreg_ok
4789
	cmp	[extended_code],12h
4790
	je	invalid_operand
4791
	cmp	[extended_code],16h
4792
	je	invalid_operand
4793
      sse_xmmreg_xmmreg_ok:
4794
	lods	byte [esi]
4795
	call	convert_xmm_register
4796
	mov	bl,al
4797
	mov	al,[extended_code]
4798
	mov	ah,[supplemental_code]
4799
	cmp	al,0C2h
4800
	je	sse_cmp_nomem_ok
4801
	cmp	ax,443Ah
4802
	je	sse_cmp_nomem_ok
4803
	cmp	[immediate_size],1
4804
	je	mmx_nomem_imm8
4805
	cmp	[immediate_size],-1
4806
	jne	sse_nomem_ok
4807
	call	take_additional_xmm0
4808
	mov	[immediate_size],0
4809
      sse_nomem_ok:
4810
	jmp	nomem_instruction_ready
4811
      sse_cmp_nomem_ok:
4812
	cmp	byte [value],-1
4813
	je	mmx_nomem_imm8
4814
	call	store_nomem_instruction
4815
	mov	al,byte [value]
4816
	stosb
4817
	jmp	instruction_assembled
4818
      take_additional_xmm0:
4819
	cmp	byte [esi],','
4820
	jne	additional_xmm0_ok
4821
	inc	esi
4822
	lods	byte [esi]
4823
	cmp	al,10h
4824
	jne	invalid_operand
4825
	lods	byte [esi]
4826
	call	convert_xmm_register
4827
	test	al,al
4828
	jnz	invalid_operand
4829
      additional_xmm0_ok:
4830
	ret
4831
4832
 
4833
	mov	[postbyte_register],al
4834
	mov	[opcode_prefix],66h
4835
	mov	[base_code],0Fh
4836
	mov	[extended_code],73h
4837
	lods	byte [esi]
4838
	call	get_size_operator
4839
	cmp	al,10h
4840
	jne	invalid_operand
4841
	lods	byte [esi]
4842
	call	convert_xmm_register
4843
	mov	bl,al
4844
	jmp	mmx_nomem_imm8
4845
movpd_instruction:
4846
	mov	[opcode_prefix],66h
4847
movps_instruction:
4848
	mov	[base_code],0Fh
4849
	mov	[extended_code],al
4850
	mov	[mmx_size],16
4851
	jmp	sse_mov_instruction
4852
movss_instruction:
4853
	mov	[mmx_size],4
4854
	mov	[opcode_prefix],0F3h
4855
	jmp	sse_movs
4856
movsd_instruction:
4857
	mov	al,0A5h
4858
	mov	ah,[esi]
4859
	or	ah,ah
4860
	jz	simple_instruction_32bit
4861
	cmp	ah,0Fh
4862
	je	simple_instruction_32bit
4863
	mov	[mmx_size],8
4864
	mov	[opcode_prefix],0F2h
4865
      sse_movs:
4866
	mov	[base_code],0Fh
4867
	mov	[extended_code],10h
4868
	jmp	sse_mov_instruction
4869
sse_mov_instruction:
4870
	lods	byte [esi]
4871
	call	get_size_operator
4872
	cmp	al,10h
4873
	je	sse_xmmreg
4874
      sse_mem:
4875
	cmp	al,'['
4876
	jne	invalid_operand
4877
	inc	[extended_code]
4878
	call	get_address
4879
	cmp	[operand_size],0
4880
	je	sse_mem_xmmreg
4881
	mov	al,[mmx_size]
4882
	cmp	[operand_size],al
4883
	jne	invalid_operand_size
4884
	mov	[operand_size],0
4885
      sse_mem_xmmreg:
4886
	lods	byte [esi]
4887
	cmp	al,','
4888
	jne	invalid_operand
4889
	lods	byte [esi]
4890
	call	get_size_operator
4891
	cmp	al,10h
4892
	jne	invalid_operand
4893
	lods	byte [esi]
4894
	call	convert_xmm_register
4895
	mov	[postbyte_register],al
4896
	jmp	instruction_ready
4897
movlpd_instruction:
4898
	mov	[opcode_prefix],66h
4899
movlps_instruction:
4900
	mov	[base_code],0Fh
4901
	mov	[extended_code],al
4902
	mov	[mmx_size],8
4903
	lods	byte [esi]
4904
	call	get_size_operator
4905
	cmp	al,10h
4906
	jne	sse_mem
4907
	lods	byte [esi]
4908
	call	convert_xmm_register
4909
	mov	[postbyte_register],al
4910
	mov	[operand_size],0
4911
	lods	byte [esi]
4912
	cmp	al,','
4913
	jne	invalid_operand
4914
	lods	byte [esi]
4915
	call	get_size_operator
4916
	jmp	sse_reg_mem
4917
movhlps_instruction:
4918
	mov	[base_code],0Fh
4919
	mov	[extended_code],al
4920
	mov	[mmx_size],0
4921
	lods	byte [esi]
4922
	call	get_size_operator
4923
	cmp	al,10h
4924
	jne	invalid_operand
4925
	lods	byte [esi]
4926
	call	convert_xmm_register
4927
	mov	[postbyte_register],al
4928
	lods	byte [esi]
4929
	cmp	al,','
4930
	jne	invalid_operand
4931
	lods	byte [esi]
4932
	call	get_size_operator
4933
	cmp	al,10h
4934
	je	sse_xmmreg_xmmreg_ok
4935
	jmp	invalid_operand
4936
maskmovq_instruction:
4937
	mov	cl,8
4938
	jmp	maskmov_instruction
4939
maskmovdqu_instruction:
4940
	mov	cl,16
4941
	mov	[opcode_prefix],66h
4942
      maskmov_instruction:
4943
	mov	[base_code],0Fh
4944
	mov	[extended_code],0F7h
4945
	lods	byte [esi]
4946
	call	get_size_operator
4947
	cmp	al,10h
4948
	jne	invalid_operand
4949
	lods	byte [esi]
4950
	call	convert_mmx_register
4951
	cmp	ah,cl
4952
	jne	invalid_operand_size
4953
	mov	[postbyte_register],al
4954
	lods	byte [esi]
4955
	cmp	al,','
4956
	jne	invalid_operand
4957
	lods	byte [esi]
4958
	call	get_size_operator
4959
	cmp	al,10h
4960
	jne	invalid_operand
4961
	lods	byte [esi]
4962
	call	convert_mmx_register
4963
	mov	bl,al
4964
	jmp	nomem_instruction_ready
4965
movmskpd_instruction:
4966
	mov	[opcode_prefix],66h
4967
movmskps_instruction:
4968
	mov	[base_code],0Fh
4969
	mov	[extended_code],50h
4970
	call	take_register
4971
	mov	[postbyte_register],al
4972
	cmp	ah,4
4973
	je	movmskps_reg_ok
4974
	cmp	ah,8
4975
	jne	invalid_operand_size
4976
	cmp	[code_type],64
4977
	jne	invalid_operand
4978
      movmskps_reg_ok:
4979
	mov	[operand_size],0
4980
	lods	byte [esi]
4981
	cmp	al,','
4982
	jne	invalid_operand
4983
	lods	byte [esi]
4984
	call	get_size_operator
4985
	cmp	al,10h
4986
	je	sse_xmmreg_xmmreg_ok
4987
	jmp	invalid_operand
4988
4989
 
4990
	mov	[opcode_prefix],66h
4991
cvtpi2ps_instruction:
4992
	mov	[base_code],0Fh
4993
	mov	[extended_code],al
4994
	lods	byte [esi]
4995
	call	get_size_operator
4996
	cmp	al,10h
4997
	jne	invalid_operand
4998
	lods	byte [esi]
4999
	call	convert_xmm_register
5000
	mov	[postbyte_register],al
5001
	mov	[operand_size],0
5002
	lods	byte [esi]
5003
	cmp	al,','
5004
	jne	invalid_operand
5005
	lods	byte [esi]
5006
	call	get_size_operator
5007
	cmp	al,10h
5008
	je	cvtpi_xmmreg_xmmreg
5009
	cmp	al,'['
5010
	jne	invalid_operand
5011
	call	get_address
5012
	cmp	[operand_size],0
5013
	je	cvtpi_size_ok
5014
	cmp	[operand_size],8
5015
	jne	invalid_operand_size
5016
      cvtpi_size_ok:
5017
	jmp	instruction_ready
5018
      cvtpi_xmmreg_xmmreg:
5019
	lods	byte [esi]
5020
	call	convert_mmx_register
5021
	cmp	ah,8
5022
	jne	invalid_operand_size
5023
	mov	bl,al
5024
	jmp	nomem_instruction_ready
5025
cvtsi2ss_instruction:
5026
	mov	[opcode_prefix],0F3h
5027
	jmp	cvtsi_instruction
5028
cvtsi2sd_instruction:
5029
	mov	[opcode_prefix],0F2h
5030
      cvtsi_instruction:
5031
	mov	[base_code],0Fh
5032
	mov	[extended_code],al
5033
	lods	byte [esi]
5034
	call	get_size_operator
5035
	cmp	al,10h
5036
	jne	invalid_operand
5037
	lods	byte [esi]
5038
	call	convert_xmm_register
5039
	mov	[postbyte_register],al
5040
      cvtsi_xmmreg:
5041
	mov	[operand_size],0
5042
	lods	byte [esi]
5043
	cmp	al,','
5044
	jne	invalid_operand
5045
	lods	byte [esi]
5046
	call	get_size_operator
5047
	cmp	al,10h
5048
	je	cvtsi_xmmreg_reg
5049
	cmp	al,'['
5050
	jne	invalid_operand
5051
	call	get_address
5052
	cmp	[operand_size],0
5053
	je	cvtsi_size_ok
5054
	cmp	[operand_size],4
5055
	je	cvtsi_size_ok
5056
	cmp	[operand_size],8
5057
	jne	invalid_operand_size
5058
	call	operand_64bit
5059
      cvtsi_size_ok:
5060
	jmp	instruction_ready
5061
      cvtsi_xmmreg_reg:
5062
	lods	byte [esi]
5063
	call	convert_register
5064
	cmp	ah,4
5065
	je	cvtsi_xmmreg_reg_store
5066
	cmp	ah,8
5067
	jne	invalid_operand_size
5068
	call	operand_64bit
5069
      cvtsi_xmmreg_reg_store:
5070
	mov	bl,al
5071
	jmp	nomem_instruction_ready
5072
cvtps2pi_instruction:
5073
	mov	[mmx_size],8
5074
	jmp	cvtpd_instruction
5075
cvtpd2pi_instruction:
5076
	mov	[opcode_prefix],66h
5077
	mov	[mmx_size],16
5078
      cvtpd_instruction:
5079
	mov	[base_code],0Fh
5080
	mov	[extended_code],al
5081
	lods	byte [esi]
5082
	call	get_size_operator
5083
	cmp	al,10h
5084
	jne	invalid_operand
5085
	lods	byte [esi]
5086
	call	convert_mmx_register
5087
	cmp	ah,8
5088
	jne	invalid_operand_size
5089
	mov	[operand_size],0
5090
	jmp	sse_reg
5091
cvtss2si_instruction:
5092
	mov	[opcode_prefix],0F3h
5093
	mov	[mmx_size],4
5094
	jmp	cvt2si_instruction
5095
cvtsd2si_instruction:
5096
	mov	[opcode_prefix],0F2h
5097
	mov	[mmx_size],8
5098
      cvt2si_instruction:
5099
	mov	[extended_code],al
5100
	mov	[base_code],0Fh
5101
	call	take_register
5102
	mov	[operand_size],0
5103
	cmp	ah,4
5104
	je	sse_reg
5105
	cmp	ah,8
5106
	jne	invalid_operand_size
5107
	call	operand_64bit
5108
	jmp	sse_reg
5109
5110
 
5111
	mov	[base_code],0Fh
5112
	mov	[extended_code],38h
5113
	mov	[supplemental_code],al
5114
	jmp	mmx_instruction
5115
palignr_instruction:
5116
	mov	[base_code],0Fh
5117
	mov	[extended_code],3Ah
5118
	mov	[supplemental_code],0Fh
5119
	lods	byte [esi]
5120
	call	get_size_operator
5121
	cmp	al,10h
5122
	jne	invalid_operand
5123
	lods	byte [esi]
5124
	call	convert_mmx_register
5125
	call	make_mmx_prefix
5126
	mov	[postbyte_register],al
5127
	lods	byte [esi]
5128
	cmp	al,','
5129
	jne	invalid_operand
5130
	lods	byte [esi]
5131
	call	get_size_operator
5132
	cmp	al,10h
5133
	je	palignr_mmreg_mmreg
5134
	cmp	al,'['
5135
	jne	invalid_operand
5136
	call	get_address
5137
	jmp	mmx_imm8
5138
      palignr_mmreg_mmreg:
5139
	lods	byte [esi]
5140
	call	convert_mmx_register
5141
	mov	bl,al
5142
	jmp	mmx_nomem_imm8
5143
amd3dnow_instruction:
5144
	mov	[base_code],0Fh
5145
	mov	[extended_code],0Fh
5146
	mov	byte [value],al
5147
	lods	byte [esi]
5148
	call	get_size_operator
5149
	cmp	al,10h
5150
	jne	invalid_operand
5151
	lods	byte [esi]
5152
	call	convert_mmx_register
5153
	cmp	ah,8
5154
	jne	invalid_operand_size
5155
	mov	[postbyte_register],al
5156
	lods	byte [esi]
5157
	cmp	al,','
5158
	jne	invalid_operand
5159
	lods	byte [esi]
5160
	call	get_size_operator
5161
	cmp	al,10h
5162
	je	amd3dnow_mmreg_mmreg
5163
	cmp	al,'['
5164
	jne	invalid_operand
5165
	call	get_address
5166
	call	store_instruction_with_imm8
5167
	jmp	instruction_assembled
5168
      amd3dnow_mmreg_mmreg:
5169
	lods	byte [esi]
5170
	call	convert_mmx_register
5171
	cmp	ah,8
5172
	jne	invalid_operand_size
5173
	mov	bl,al
5174
	call	store_nomem_instruction
5175
	mov	al,byte [value]
5176
	stos	byte [edi]
5177
	jmp	instruction_assembled
5178
5179
 
5180
	mov	[immediate_size],-1
5181
	jmp	sse4_instruction_38
5182
sse4_instruction_66_38_xmm0:
5183
	mov	[immediate_size],-1
5184
sse4_instruction_66_38:
5185
	mov	[opcode_prefix],66h
5186
sse4_instruction_38:
5187
	mov	[mmx_size],16
5188
	mov	[supplemental_code],al
5189
	mov	al,38h
5190
	jmp	sse_instruction
5191
sse4_ss_instruction_66_3a_imm8:
5192
	mov	[immediate_size],1
5193
	mov	cl,4
5194
	jmp	sse4_instruction_66_3a_setup
5195
sse4_sd_instruction_66_3a_imm8:
5196
	mov	[immediate_size],1
5197
	mov	cl,8
5198
	jmp	sse4_instruction_66_3a_setup
5199
sse4_instruction_66_3a_imm8:
5200
	mov	[immediate_size],1
5201
	mov	cl,16
5202
      sse4_instruction_66_3a_setup:
5203
	mov	[opcode_prefix],66h
5204
      sse4_instruction_3a_setup:
5205
	mov	[supplemental_code],al
5206
	mov	al,3Ah
5207
	mov	[mmx_size],cl
5208
	jmp	sse_instruction
5209
sse4_instruction_3a_imm8:
5210
	mov	[immediate_size],1
5211
	mov	cl,16
5212
	jmp	sse4_instruction_3a_setup
5213
pclmulqdq_instruction:
5214
	mov	byte [value],al
5215
	mov	al,44h
5216
	mov	cl,16
5217
	jmp	sse4_instruction_66_3a_setup
5218
extractps_instruction:
5219
	call	setup_66_0f_3a
5220
	lods	byte [esi]
5221
	call	get_size_operator
5222
	cmp	al,10h
5223
	je	extractps_reg
5224
	cmp	al,'['
5225
	jne	invalid_operand
5226
	call	get_address
5227
	cmp	[operand_size],4
5228
	je	extractps_size_ok
5229
	cmp	[operand_size],0
5230
	jne	invalid_operand_size
5231
      extractps_size_ok:
5232
	push	edx ebx ecx
5233
	mov	[operand_size],0
5234
	lods	byte [esi]
5235
	cmp	al,','
5236
	jne	invalid_operand
5237
	lods	byte [esi]
5238
	call	get_size_operator
5239
	cmp	al,10h
5240
	jne	invalid_operand
5241
	lods	byte [esi]
5242
	call	convert_xmm_register
5243
	mov	[postbyte_register],al
5244
	pop	ecx ebx edx
5245
	jmp	mmx_imm8
5246
      extractps_reg:
5247
	lods	byte [esi]
5248
	call	convert_register
5249
	push	eax
5250
	mov	[operand_size],0
5251
	lods	byte [esi]
5252
	cmp	al,','
5253
	jne	invalid_operand
5254
	lods	byte [esi]
5255
	call	get_size_operator
5256
	cmp	al,10h
5257
	jne	invalid_operand
5258
	lods	byte [esi]
5259
	call	convert_xmm_register
5260
	mov	[postbyte_register],al
5261
	pop	ebx
5262
	mov	al,bh
5263
	cmp	al,4
5264
	je	mmx_nomem_imm8
5265
	cmp	al,8
5266
	jne	invalid_operand_size
5267
	cmp	[code_type],64
5268
	jne	illegal_instruction
5269
	jmp	mmx_nomem_imm8
5270
      setup_66_0f_3a:
5271
	mov	[extended_code],3Ah
5272
	mov	[supplemental_code],al
5273
	mov	[base_code],0Fh
5274
	mov	[opcode_prefix],66h
5275
	ret
5276
insertps_instruction:
5277
	call	setup_66_0f_3a
5278
	lods	byte [esi]
5279
	call	get_size_operator
5280
	cmp	al,10h
5281
	jne	invalid_operand
5282
	lods	byte [esi]
5283
	call	convert_xmm_register
5284
	mov	[postbyte_register],al
5285
	mov	[operand_size],0
5286
	lods	byte [esi]
5287
	cmp	al,','
5288
	jne	invalid_operand
5289
	lods	byte [esi]
5290
	call	get_size_operator
5291
	cmp	al,10h
5292
	je	insertps_xmmreg_reg
5293
	cmp	al,'['
5294
	jne	invalid_operand
5295
	call	get_address
5296
	cmp	[operand_size],4
5297
	je	insertps_size_ok
5298
	cmp	[operand_size],0
5299
	jne	invalid_operand_size
5300
      insertps_size_ok:
5301
	jmp	mmx_imm8
5302
      insertps_xmmreg_reg:
5303
	lods	byte [esi]
5304
	call	convert_mmx_register
5305
	mov	bl,al
5306
	jmp	mmx_nomem_imm8
5307
pextrq_instruction:
5308
	mov	[mmx_size],8
5309
	jmp	pextr_instruction
5310
pextrd_instruction:
5311
	mov	[mmx_size],4
5312
	jmp	pextr_instruction
5313
pextrw_instruction:
5314
	mov	[mmx_size],2
5315
	jmp	pextr_instruction
5316
pextrb_instruction:
5317
	mov	[mmx_size],1
5318
      pextr_instruction:
5319
	call	setup_66_0f_3a
5320
	lods	byte [esi]
5321
	call	get_size_operator
5322
	cmp	al,10h
5323
	je	pextr_reg
5324
	cmp	al,'['
5325
	jne	invalid_operand
5326
	call	get_address
5327
	mov	al,[mmx_size]
5328
	cmp	al,[operand_size]
5329
	je	pextr_size_ok
5330
	cmp	[operand_size],0
5331
	jne	invalid_operand_size
5332
      pextr_size_ok:
5333
	cmp	al,8
5334
	jne	pextr_prefix_ok
5335
	call	operand_64bit
5336
      pextr_prefix_ok:
5337
	push	edx ebx ecx
5338
	mov	[operand_size],0
5339
	lods	byte [esi]
5340
	cmp	al,','
5341
	jne	invalid_operand
5342
	lods	byte [esi]
5343
	call	get_size_operator
5344
	cmp	al,10h
5345
	jne	invalid_operand
5346
	lods	byte [esi]
5347
	call	convert_xmm_register
5348
	mov	[postbyte_register],al
5349
	pop	ecx ebx edx
5350
	jmp	mmx_imm8
5351
      pextr_reg:
5352
	lods	byte [esi]
5353
	call	convert_register
5354
	cmp	[mmx_size],4
5355
	ja	pextrq_reg
5356
	cmp	ah,4
5357
	je	pextr_reg_size_ok
5358
	cmp	[code_type],64
5359
	jne	pextr_invalid_size
5360
	cmp	ah,8
5361
	je	pextr_reg_size_ok
5362
      pextr_invalid_size:
5363
	jmp	invalid_operand_size
5364
      pextrq_reg:
5365
	cmp	ah,8
5366
	jne	pextr_invalid_size
5367
	call	operand_64bit
5368
      pextr_reg_size_ok:
5369
	mov	[operand_size],0
5370
	push	eax
5371
	lods	byte [esi]
5372
	cmp	al,','
5373
	jne	invalid_operand
5374
	lods	byte [esi]
5375
	call	get_size_operator
5376
	cmp	al,10h
5377
	jne	invalid_operand
5378
	lods	byte [esi]
5379
	call	convert_mmx_register
5380
	mov	ebx,eax
5381
	pop	eax
5382
	mov	[postbyte_register],al
5383
	mov	al,ah
5384
	cmp	[mmx_size],2
5385
	jne	pextr_reg_store
5386
	mov	[opcode_prefix],0
5387
	mov	[extended_code],0C5h
5388
	call	make_mmx_prefix
5389
	jmp	mmx_nomem_imm8
5390
      pextr_reg_store:
5391
	cmp	bh,16
5392
	jne	invalid_operand_size
5393
	xchg	bl,[postbyte_register]
5394
	jmp	mmx_nomem_imm8
5395
pinsrb_instruction:
5396
	mov	[mmx_size],1
5397
	jmp	pinsr_instruction
5398
pinsrd_instruction:
5399
	mov	[mmx_size],4
5400
	jmp	pinsr_instruction
5401
pinsrq_instruction:
5402
	mov	[mmx_size],8
5403
	call	operand_64bit
5404
      pinsr_instruction:
5405
	call	setup_66_0f_3a
5406
	lods	byte [esi]
5407
	call	get_size_operator
5408
	cmp	al,10h
5409
	jne	invalid_operand
5410
	lods	byte [esi]
5411
	call	convert_xmm_register
5412
	mov	[postbyte_register],al
5413
      pinsr_xmmreg:
5414
	mov	[operand_size],0
5415
	lods	byte [esi]
5416
	cmp	al,','
5417
	jne	invalid_operand
5418
	lods	byte [esi]
5419
	call	get_size_operator
5420
	cmp	al,10h
5421
	je	pinsr_xmmreg_reg
5422
	cmp	al,'['
5423
	jne	invalid_operand
5424
	call	get_address
5425
	cmp	[operand_size],0
5426
	je	mmx_imm8
5427
	mov	al,[mmx_size]
5428
	cmp	al,[operand_size]
5429
	je	mmx_imm8
5430
	jmp	invalid_operand_size
5431
      pinsr_xmmreg_reg:
5432
	lods	byte [esi]
5433
	call	convert_register
5434
	mov	bl,al
5435
	cmp	[mmx_size],8
5436
	je	pinsrq_xmmreg_reg
5437
	cmp	ah,4
5438
	je	mmx_nomem_imm8
5439
	jmp	invalid_operand_size
5440
      pinsrq_xmmreg_reg:
5441
	cmp	ah,8
5442
	je	mmx_nomem_imm8
5443
	jmp	invalid_operand_size
5444
pmovsxbw_instruction:
5445
	mov	[mmx_size],8
5446
	jmp	pmovsx_instruction
5447
pmovsxbd_instruction:
5448
	mov	[mmx_size],4
5449
	jmp	pmovsx_instruction
5450
pmovsxbq_instruction:
5451
	mov	[mmx_size],2
5452
	jmp	pmovsx_instruction
5453
pmovsxwd_instruction:
5454
	mov	[mmx_size],8
5455
	jmp	pmovsx_instruction
5456
pmovsxwq_instruction:
5457
	mov	[mmx_size],4
5458
	jmp	pmovsx_instruction
5459
pmovsxdq_instruction:
5460
	mov	[mmx_size],8
5461
      pmovsx_instruction:
5462
	call	setup_66_0f_38
5463
	lods	byte [esi]
5464
	call	get_size_operator
5465
	cmp	al,10h
5466
	jne	invalid_operand
5467
	lods	byte [esi]
5468
	call	convert_xmm_register
5469
	mov	[postbyte_register],al
5470
	lods	byte [esi]
5471
	cmp	al,','
5472
	jne	invalid_operand
5473
	mov	[operand_size],0
5474
	lods	byte [esi]
5475
	call	get_size_operator
5476
	cmp	al,10h
5477
	je	pmovsx_xmmreg_reg
5478
	cmp	al,'['
5479
	jne	invalid_operand
5480
	call	get_address
5481
	cmp	[operand_size],0
5482
	je	instruction_ready
5483
	mov	al,[mmx_size]
5484
	cmp	al,[operand_size]
5485
	jne	invalid_operand_size
5486
	jmp	instruction_ready
5487
      pmovsx_xmmreg_reg:
5488
	lods	byte [esi]
5489
	call	convert_xmm_register
5490
	mov	bl,al
5491
	jmp	nomem_instruction_ready
5492
      setup_66_0f_38:
5493
	mov	[extended_code],38h
5494
	mov	[supplemental_code],al
5495
	mov	[base_code],0Fh
5496
	mov	[opcode_prefix],66h
5497
	ret
5498
5499
 
5500
	call	operand_64bit
5501
xsaves_instruction:
5502
	mov	ah,0C7h
5503
	jmp	xsave_common
5504
fxsave_instruction_64bit:
5505
	call	operand_64bit
5506
fxsave_instruction:
5507
	mov	ah,0AEh
5508
	xor	cl,cl
5509
      xsave_common:
5510
	mov	[base_code],0Fh
5511
	mov	[extended_code],ah
5512
	mov	[postbyte_register],al
5513
	mov	[mmx_size],cl
5514
	lods	byte [esi]
5515
	call	get_size_operator
5516
	cmp	al,'['
5517
	jne	invalid_operand
5518
	call	get_address
5519
	mov	ah,[operand_size]
5520
	or	ah,ah
5521
	jz	xsave_size_ok
5522
	cmp	ah,[mmx_size]
5523
	jne	invalid_operand_size
5524
      xsave_size_ok:
5525
	jmp	instruction_ready
5526
clflush_instruction:
5527
	mov	ah,0AEh
5528
	mov	cl,1
5529
	jmp	xsave_common
5530
cldemote_instruction:
5531
	mov	ah,1Ch
5532
	mov	cl,1
5533
	jmp	xsave_common
5534
stmxcsr_instruction:
5535
	mov	ah,0AEh
5536
	mov	cl,4
5537
	jmp	xsave_common
5538
prefetch_instruction:
5539
	mov	[extended_code],18h
5540
      prefetch_mem_8bit:
5541
	mov	[base_code],0Fh
5542
	mov	[postbyte_register],al
5543
	lods	byte [esi]
5544
	call	get_size_operator
5545
	cmp	al,'['
5546
	jne	invalid_operand
5547
	or	ah,ah
5548
	jz	prefetch_size_ok
5549
	cmp	ah,1
5550
	jne	invalid_operand_size
5551
      prefetch_size_ok:
5552
	call	get_address
5553
	jmp	instruction_ready
5554
amd_prefetch_instruction:
5555
	mov	[extended_code],0Dh
5556
	jmp	prefetch_mem_8bit
5557
clflushopt_instruction:
5558
	mov	[extended_code],0AEh
5559
	mov	[opcode_prefix],66h
5560
	jmp	prefetch_mem_8bit
5561
pcommit_instruction:
5562
	mov	byte [edi],66h
5563
	inc	edi
5564
fence_instruction:
5565
	mov	bl,al
5566
	mov	ax,0AE0Fh
5567
	stos	word [edi]
5568
	mov	al,bl
5569
	stos	byte [edi]
5570
	jmp	instruction_assembled
5571
pause_instruction:
5572
	mov	ax,90F3h
5573
	stos	word [edi]
5574
	jmp	instruction_assembled
5575
movntq_instruction:
5576
	mov	[mmx_size],8
5577
	jmp	movnt_instruction
5578
movntpd_instruction:
5579
	mov	[opcode_prefix],66h
5580
movntps_instruction:
5581
	mov	[mmx_size],16
5582
      movnt_instruction:
5583
	mov	[extended_code],al
5584
	mov	[base_code],0Fh
5585
	lods	byte [esi]
5586
	call	get_size_operator
5587
	cmp	al,'['
5588
	jne	invalid_operand
5589
	call	get_address
5590
	lods	byte [esi]
5591
	cmp	al,','
5592
	jne	invalid_operand
5593
	lods	byte [esi]
5594
	call	get_size_operator
5595
	cmp	al,10h
5596
	jne	invalid_operand
5597
	lods	byte [esi]
5598
	call	convert_mmx_register
5599
	cmp	ah,[mmx_size]
5600
	jne	invalid_operand_size
5601
	mov	[postbyte_register],al
5602
	jmp	instruction_ready
5603
5604
 
5605
	mov	[opcode_prefix],0F2h
5606
	mov	[mmx_size],8
5607
	jmp	movnts_instruction
5608
movntss_instruction:
5609
	mov	[opcode_prefix],0F3h
5610
	mov	[mmx_size],4
5611
      movnts_instruction:
5612
	mov	[extended_code],al
5613
	mov	[base_code],0Fh
5614
	lods	byte [esi]
5615
	call	get_size_operator
5616
	cmp	al,'['
5617
	jne	invalid_operand
5618
	call	get_address
5619
	mov	al,[operand_size]
5620
	cmp	al,[mmx_size]
5621
	je	movnts_size_ok
5622
	test	al,al
5623
	jnz	invalid_operand_size
5624
      movnts_size_ok:
5625
	lods	byte [esi]
5626
	cmp	al,','
5627
	jne	invalid_operand
5628
	mov	[operand_size],0
5629
	lods	byte [esi]
5630
	call	get_size_operator
5631
	cmp	al,10h
5632
	jne	invalid_operand
5633
	lods	byte [esi]
5634
	call	convert_xmm_register
5635
	mov	[postbyte_register],al
5636
	jmp	instruction_ready
5637
5638
 
5639
	mov	[supplemental_code],al
5640
	mov	al,38h
5641
movnti_instruction:
5642
	mov	[base_code],0Fh
5643
	mov	[extended_code],al
5644
	lods	byte [esi]
5645
	call	get_size_operator
5646
	cmp	al,'['
5647
	jne	invalid_operand
5648
	call	get_address
5649
	lods	byte [esi]
5650
	cmp	al,','
5651
	jne	invalid_operand
5652
	call	take_register
5653
	cmp	ah,4
5654
	je	movnti_store
5655
	cmp	ah,8
5656
	jne	invalid_operand_size
5657
	call	operand_64bit
5658
      movnti_store:
5659
	mov	[postbyte_register],al
5660
	jmp	instruction_ready
5661
monitor_instruction:
5662
	mov	[postbyte_register],al
5663
	cmp	byte [esi],0
5664
	je	monitor_instruction_store
5665
	cmp	byte [esi],0Fh
5666
	je	monitor_instruction_store
5667
	call	take_register
5668
	cmp	ax,0400h
5669
	jne	invalid_operand
5670
	lods	byte [esi]
5671
	cmp	al,','
5672
	jne	invalid_operand
5673
	call	take_register
5674
	cmp	ax,0401h
5675
	jne	invalid_operand
5676
	cmp	[postbyte_register],0C8h
5677
	jne	monitor_instruction_store
5678
	lods	byte [esi]
5679
	cmp	al,','
5680
	jne	invalid_operand
5681
	call	take_register
5682
	cmp	ax,0402h
5683
	jne	invalid_operand
5684
      monitor_instruction_store:
5685
	mov	ax,010Fh
5686
	stos	word [edi]
5687
	mov	al,[postbyte_register]
5688
	stos	byte [edi]
5689
	jmp	instruction_assembled
5690
pconfig_instruction:
5691
	mov	[postbyte_register],al
5692
	jmp	monitor_instruction_store
5693
movntdqa_instruction:
5694
	call	setup_66_0f_38
5695
	lods	byte [esi]
5696
	call	get_size_operator
5697
	cmp	al,10h
5698
	jne	invalid_operand
5699
	lods	byte [esi]
5700
	call	convert_xmm_register
5701
	mov	[postbyte_register],al
5702
	lods	byte [esi]
5703
	cmp	al,','
5704
	jne	invalid_operand
5705
	lods	byte [esi]
5706
	call	get_size_operator
5707
	cmp	al,'['
5708
	jne	invalid_operand
5709
	call	get_address
5710
	jmp	instruction_ready
5711
5712
 
5713
	mov	[opcode_prefix],66h
5714
	mov	[base_code],0Fh
5715
	mov	[extended_code],78h
5716
	lods	byte [esi]
5717
	call	get_size_operator
5718
	cmp	al,10h
5719
	jne	invalid_operand
5720
	lods	byte [esi]
5721
	call	convert_xmm_register
5722
	mov	[postbyte_register],al
5723
	mov	[operand_size],0
5724
	lods	byte [esi]
5725
	cmp	al,','
5726
	jne	invalid_operand
5727
	lods	byte [esi]
5728
	call	get_size_operator
5729
	cmp	al,10h
5730
	je	extrq_xmmreg_xmmreg
5731
	test	ah,not 1
5732
	jnz	invalid_operand_size
5733
	cmp	al,'('
5734
	jne	invalid_operand
5735
	xor	bl,bl
5736
	xchg	bl,[postbyte_register]
5737
	call	store_nomem_instruction
5738
	call	get_byte_value
5739
	stosb
5740
	call	append_imm8
5741
	jmp	instruction_assembled
5742
      extrq_xmmreg_xmmreg:
5743
	inc	[extended_code]
5744
	lods	byte [esi]
5745
	call	convert_xmm_register
5746
	mov	bl,al
5747
	jmp	nomem_instruction_ready
5748
insertq_instruction:
5749
	mov	[opcode_prefix],0F2h
5750
	mov	[base_code],0Fh
5751
	mov	[extended_code],78h
5752
	lods	byte [esi]
5753
	call	get_size_operator
5754
	cmp	al,10h
5755
	jne	invalid_operand
5756
	lods	byte [esi]
5757
	call	convert_xmm_register
5758
	mov	[postbyte_register],al
5759
	mov	[operand_size],0
5760
	lods	byte [esi]
5761
	cmp	al,','
5762
	jne	invalid_operand
5763
	lods	byte [esi]
5764
	call	get_size_operator
5765
	cmp	al,10h
5766
	jne	invalid_operand
5767
	lods	byte [esi]
5768
	call	convert_xmm_register
5769
	mov	bl,al
5770
	cmp	byte [esi],','
5771
	je	insertq_with_imm
5772
	inc	[extended_code]
5773
	jmp	nomem_instruction_ready
5774
      insertq_with_imm:
5775
	call	store_nomem_instruction
5776
	call	append_imm8
5777
	call	append_imm8
5778
	jmp	instruction_assembled
5779
5780
 
5781
	mov	[opcode_prefix],0F2h
5782
	mov	[base_code],0Fh
5783
	mov	[extended_code],38h
5784
	mov	[supplemental_code],0F0h
5785
	call	take_register
5786
	mov	[postbyte_register],al
5787
	cmp	ah,4
5788
	je	crc32_reg_size_ok
5789
	cmp	ah,8
5790
	jne	invalid_operand
5791
	cmp	[code_type],64
5792
	jne	illegal_instruction
5793
      crc32_reg_size_ok:
5794
	lods	byte [esi]
5795
	cmp	al,','
5796
	jne	invalid_operand
5797
	mov	[operand_size],0
5798
	lods	byte [esi]
5799
	call	get_size_operator
5800
	cmp	al,10h
5801
	je	crc32_reg_reg
5802
	cmp	al,'['
5803
	jne	invalid_operand
5804
	call	get_address
5805
	mov	al,[operand_size]
5806
	test	al,al
5807
	jz	crc32_unknown_size
5808
	cmp	al,1
5809
	je	crc32_reg_mem_store
5810
	inc	[supplemental_code]
5811
	call	operand_autodetect
5812
      crc32_reg_mem_store:
5813
	jmp	instruction_ready
5814
      crc32_unknown_size:
5815
	call	recoverable_unknown_size
5816
	jmp	crc32_reg_mem_store
5817
      crc32_reg_reg:
5818
	lods	byte [esi]
5819
	call	convert_register
5820
	mov	bl,al
5821
	mov	al,ah
5822
	cmp	al,1
5823
	je	crc32_reg_reg_store
5824
	inc	[supplemental_code]
5825
	call	operand_autodetect
5826
      crc32_reg_reg_store:
5827
	jmp	nomem_instruction_ready
5828
popcnt_instruction:
5829
	mov	[opcode_prefix],0F3h
5830
	jmp	bs_instruction
5831
movbe_instruction:
5832
	mov	[supplemental_code],al
5833
	mov	[extended_code],38h
5834
	mov	[base_code],0Fh
5835
	lods	byte [esi]
5836
	call	get_size_operator
5837
	cmp	al,'['
5838
	je	movbe_mem
5839
	cmp	al,10h
5840
	jne	invalid_operand
5841
	lods	byte [esi]
5842
	call	convert_register
5843
	mov	[postbyte_register],al
5844
	lods	byte [esi]
5845
	cmp	al,','
5846
	jne	invalid_operand
5847
	lods	byte [esi]
5848
	call	get_size_operator
5849
	cmp	al,'['
5850
	jne	invalid_argument
5851
	call	get_address
5852
	mov	al,[operand_size]
5853
	call	operand_autodetect
5854
	jmp	instruction_ready
5855
      movbe_mem:
5856
	inc	[supplemental_code]
5857
	call	get_address
5858
	push	edx ebx ecx
5859
	lods	byte [esi]
5860
	cmp	al,','
5861
	jne	invalid_operand
5862
	call	take_register
5863
	mov	[postbyte_register],al
5864
	pop	ecx ebx edx
5865
	mov	al,[operand_size]
5866
	call	operand_autodetect
5867
	jmp	instruction_ready
5868
adx_instruction:
5869
	mov	[base_code],0Fh
5870
	mov	[extended_code],38h
5871
	mov	[supplemental_code],0F6h
5872
	mov	[operand_prefix],al
5873
	call	get_reg_mem
5874
	jc	adx_reg_reg
5875
	mov	al,[operand_size]
5876
	cmp	al,4
5877
	je	instruction_ready
5878
	cmp	al,8
5879
	jne	invalid_operand_size
5880
	call	operand_64bit
5881
	jmp	instruction_ready
5882
      adx_reg_reg:
5883
	cmp	ah,4
5884
	je	nomem_instruction_ready
5885
	cmp	ah,8
5886
	jne	invalid_operand_size
5887
	call	operand_64bit
5888
	jmp	nomem_instruction_ready
5889
rdpid_instruction:
5890
	mov	[postbyte_register],al
5891
	mov	[extended_code],0C7h
5892
	mov	[base_code],0Fh
5893
	mov	[opcode_prefix],0F3h
5894
	call	take_register
5895
	cmp	[code_type],64
5896
	je	rdpid_64bit
5897
	cmp	ah,4
5898
	jne	invalid_operand_size
5899
	jmp	nomem_instruction_ready
5900
      rdpid_64bit:
5901
	cmp	ah,8
5902
	jne	invalid_operand_size
5903
	jmp	nomem_instruction_ready
5904
ptwrite_instruction:
5905
	mov	[base_code],0Fh
5906
	mov	[extended_code],0AEh
5907
	mov	[postbyte_register],al
5908
	mov	[opcode_prefix],0F3h
5909
	lods	byte [esi]
5910
	call	get_size_operator
5911
	cmp	al,10h
5912
	je	ptwrite_reg
5913
      ptwrite_mem:
5914
	cmp	al,'['
5915
	jne	invalid_operand
5916
	call	get_address
5917
	mov	al,[operand_size]
5918
	cmp	al,4
5919
	je	ptwrite_mem_store
5920
	cmp	al,8
5921
	je	ptwrite_mem_64bit
5922
	or	al,al
5923
	jnz	invalid_operand_size
5924
	call	recoverable_unknown_size
5925
	jmp	ptwrite_mem_store
5926
      ptwrite_mem_64bit:
5927
	call	operand_64bit
5928
      ptwrite_mem_store:
5929
	mov	al,[operand_size]
5930
	call	operand_autodetect
5931
	jmp	instruction_ready
5932
      ptwrite_reg:
5933
	lods	byte [esi]
5934
	call	convert_register
5935
	mov	bl,al
5936
	mov	al,ah
5937
	cmp	al,4
5938
	je	nomem_instruction_ready
5939
	cmp	al,8
5940
	jne	invalid_operand_size
5941
	call	operand_64bit
5942
	jmp	nomem_instruction_ready
5943
5944
 
5945
	mov	[opcode_prefix],66h
5946
	jmp	vmx_instruction
5947
vmxon_instruction:
5948
	mov	[opcode_prefix],0F3h
5949
vmx_instruction:
5950
	mov	[postbyte_register],al
5951
	mov	[extended_code],0C7h
5952
	lods	byte [esi]
5953
	call	get_size_operator
5954
	cmp	al,'['
5955
	jne	invalid_operand
5956
	call	get_address
5957
	mov	al,[operand_size]
5958
	or	al,al
5959
	jz	vmx_size_ok
5960
	cmp	al,8
5961
	jne	invalid_operand_size
5962
      vmx_size_ok:
5963
	mov	[base_code],0Fh
5964
	jmp	instruction_ready
5965
vmread_instruction:
5966
	mov	[extended_code],78h
5967
	lods	byte [esi]
5968
	call	get_size_operator
5969
	cmp	al,10h
5970
	je	vmread_nomem
5971
	cmp	al,'['
5972
	jne	invalid_operand
5973
	call	get_address
5974
	lods	byte [esi]
5975
	cmp	al,','
5976
	jne	invalid_operand
5977
	call	take_register
5978
	mov	[postbyte_register],al
5979
	call	vmread_check_size
5980
	jmp	vmx_size_ok
5981
      vmread_nomem:
5982
	lods	byte [esi]
5983
	call	convert_register
5984
	push	eax
5985
	call	vmread_check_size
5986
	lods	byte [esi]
5987
	cmp	al,','
5988
	jne	invalid_operand
5989
	call	take_register
5990
	mov	[postbyte_register],al
5991
	call	vmread_check_size
5992
	pop	ebx
5993
	mov	[base_code],0Fh
5994
	jmp	nomem_instruction_ready
5995
      vmread_check_size:
5996
	cmp	[code_type],64
5997
	je	vmread_long
5998
	cmp	[operand_size],4
5999
	jne	invalid_operand_size
6000
	ret
6001
      vmread_long:
6002
	cmp	[operand_size],8
6003
	jne	invalid_operand_size
6004
	ret
6005
vmwrite_instruction:
6006
	mov	[extended_code],79h
6007
	call	take_register
6008
	mov	[postbyte_register],al
6009
	lods	byte [esi]
6010
	cmp	al,','
6011
	jne	invalid_operand
6012
	lods	byte [esi]
6013
	call	get_size_operator
6014
	cmp	al,10h
6015
	je	vmwrite_nomem
6016
	cmp	al,'['
6017
	jne	invalid_operand
6018
	call	get_address
6019
	call	vmread_check_size
6020
	jmp	vmx_size_ok
6021
      vmwrite_nomem:
6022
	lods	byte [esi]
6023
	call	convert_register
6024
	mov	bl,al
6025
	mov	[base_code],0Fh
6026
	jmp	nomem_instruction_ready
6027
vmx_inv_instruction:
6028
	call	setup_66_0f_38
6029
	call	take_register
6030
	mov	[postbyte_register],al
6031
	call	vmread_check_size
6032
	mov	[operand_size],0
6033
	lods	byte [esi]
6034
	cmp	al,','
6035
	jne	invalid_operand
6036
	lods	byte [esi]
6037
	call	get_size_operator
6038
	cmp	al,'['
6039
	jne	invalid_operand
6040
	call	get_address
6041
	mov	al,[operand_size]
6042
	or	al,al
6043
	jz	vmx_size_ok
6044
	cmp	al,16
6045
	jne	invalid_operand_size
6046
	jmp	vmx_size_ok
6047
simple_svm_instruction:
6048
	push	eax
6049
	mov	[base_code],0Fh
6050
	mov	[extended_code],1
6051
	call	take_register
6052
	or	al,al
6053
	jnz	invalid_operand
6054
      simple_svm_detect_size:
6055
	cmp	ah,2
6056
	je	simple_svm_16bit
6057
	cmp	ah,4
6058
	je	simple_svm_32bit
6059
	cmp	[code_type],64
6060
	jne	invalid_operand_size
6061
	jmp	simple_svm_store
6062
      simple_svm_16bit:
6063
	cmp	[code_type],16
6064
	je	simple_svm_store
6065
	cmp	[code_type],64
6066
	je	invalid_operand_size
6067
	jmp	prefixed_svm_store
6068
      simple_svm_32bit:
6069
	cmp	[code_type],32
6070
	je	simple_svm_store
6071
      prefixed_svm_store:
6072
	mov	al,67h
6073
	stos	byte [edi]
6074
      simple_svm_store:
6075
	call	store_classic_instruction_code
6076
	pop	eax
6077
	stos	byte [edi]
6078
	jmp	instruction_assembled
6079
skinit_instruction:
6080
	call	take_register
6081
	cmp	ax,0400h
6082
	jne	invalid_operand
6083
	mov	al,0DEh
6084
	jmp	simple_instruction_0f_01
6085
clzero_instruction:
6086
	call	take_register
6087
	or	al,al
6088
	jnz	invalid_operand
6089
	mov	al,0FCh
6090
	cmp	[code_type],64
6091
	je	clzero_64bit
6092
	cmp	ah,4
6093
	jne	invalid_operand
6094
	jmp	simple_instruction_0f_01
6095
      clzero_64bit:
6096
	cmp	ah,8
6097
	jne	invalid_operand
6098
	jmp	simple_instruction_0f_01
6099
invlpga_instruction:
6100
	push	eax
6101
	mov	[base_code],0Fh
6102
	mov	[extended_code],1
6103
	call	take_register
6104
	or	al,al
6105
	jnz	invalid_operand
6106
	mov	bl,ah
6107
	mov	[operand_size],0
6108
	lods	byte [esi]
6109
	cmp	al,','
6110
	jne	invalid_operand
6111
	call	take_register
6112
	cmp	ax,0401h
6113
	jne	invalid_operand
6114
	mov	ah,bl
6115
	jmp	simple_svm_detect_size
6116
6117
 
6118
	mov	[base_code],0Fh
6119
	mov	[extended_code],0C7h
6120
	mov	[postbyte_register],al
6121
	call	take_register
6122
	mov	bl,al
6123
	mov	al,ah
6124
	call	operand_autodetect
6125
	jmp	nomem_instruction_ready
6126
rdfsbase_instruction:
6127
	cmp	[code_type],64
6128
	jne	illegal_instruction
6129
	mov	[opcode_prefix],0F3h
6130
	mov	[base_code],0Fh
6131
	mov	[extended_code],0AEh
6132
	mov	[postbyte_register],al
6133
	call	take_register
6134
	mov	bl,al
6135
	mov	al,ah
6136
	cmp	ah,2
6137
	je	invalid_operand_size
6138
	call	operand_autodetect
6139
	jmp	nomem_instruction_ready
6140
6141
 
6142
	lods	byte [esi]
6143
	call	get_size_operator
6144
	cmp	ah,1
6145
	ja	invalid_operand_size
6146
	cmp	al,'('
6147
	jne	invalid_operand
6148
	call	get_byte_value
6149
	mov	dl,al
6150
	mov	ax,0F8C6h
6151
	stos	word [edi]
6152
	mov	al,dl
6153
	stos	byte [edi]
6154
	jmp	instruction_assembled
6155
xbegin_instruction:
6156
	lods	byte [esi]
6157
	cmp	al,'('
6158
	jne	invalid_operand
6159
	mov	al,[code_type]
6160
	cmp	al,64
6161
	je	xbegin_64bit
6162
	cmp	al,32
6163
	je	xbegin_32bit
6164
      xbegin_16bit:
6165
	call	get_address_word_value
6166
	add	edi,4
6167
	mov	ebp,[addressing_space]
6168
	call	calculate_relative_offset
6169
	sub	edi,4
6170
	shl	eax,16
6171
	mov	ax,0F8C7h
6172
	stos	dword [edi]
6173
	jmp	instruction_assembled
6174
      xbegin_32bit:
6175
	call	get_address_dword_value
6176
	jmp	xbegin_address_ok
6177
      xbegin_64bit:
6178
	call	get_address_qword_value
6179
      xbegin_address_ok:
6180
	add	edi,5
6181
	mov	ebp,[addressing_space]
6182
	call	calculate_relative_offset
6183
	sub	edi,5
6184
	mov	edx,eax
6185
	cwde
6186
	cmp	eax,edx
6187
	jne	xbegin_rel32
6188
	mov	al,66h
6189
	stos	byte [edi]
6190
	mov	eax,edx
6191
	shl	eax,16
6192
	mov	ax,0F8C7h
6193
	stos	dword [edi]
6194
	jmp	instruction_assembled
6195
      xbegin_rel32:
6196
	sub	edx,1
6197
	jno	xbegin_rel32_ok
6198
	cmp	[code_type],64
6199
	je	jump_out_of_range
6200
      xbegin_rel32_ok:
6201
	mov	ax,0F8C7h
6202
	stos	word [edi]
6203
	mov	eax,edx
6204
	stos	dword [edi]
6205
	jmp	instruction_assembled
6206
6207
 
6208
	mov	ah,0F3h
6209
	jmp	bndc_instruction
6210
bndcu_instruction:
6211
	mov	ah,0F2h
6212
      bndc_instruction:
6213
	mov	[opcode_prefix],ah
6214
	mov	[base_code],0Fh
6215
	mov	[extended_code],al
6216
	call	take_bnd_register
6217
	mov	[postbyte_register],al
6218
	call	get_bnd_size
6219
	mov	[operand_size],al
6220
	lods	byte [esi]
6221
	cmp	al,','
6222
	jne	invalid_operand
6223
	lods	byte [esi]
6224
	call	get_size_operator
6225
	cmp	al,'['
6226
	je	bndc_mem
6227
	cmp	al,10h
6228
	jne	invalid_operand
6229
	lods	byte [esi]
6230
	call	convert_register
6231
	mov	bl,al
6232
	jmp	nomem_instruction_ready
6233
      bndc_mem:
6234
	call	get_address_of_required_size
6235
	jmp	instruction_ready
6236
bndmov_instruction:
6237
	mov	[opcode_prefix],66h
6238
	mov	[base_code],0Fh
6239
	mov	[extended_code],al
6240
	call	get_bnd_size
6241
	shl	al,1
6242
	mov	[operand_size],al
6243
	lods	byte [esi]
6244
	cmp	al,14h
6245
	je	bndmov_reg
6246
	call	get_size_operator
6247
	cmp	al,'['
6248
	jne	invalid_operand
6249
	inc	[extended_code]
6250
	call	get_address_of_required_size
6251
	lods	byte [esi]
6252
	cmp	al,','
6253
	jne	invalid_operand
6254
	call	take_bnd_register
6255
	mov	[postbyte_register],al
6256
	jmp	instruction_ready
6257
       bndmov_reg:
6258
	lods	byte [esi]
6259
	call	convert_bnd_register
6260
	mov	[postbyte_register],al
6261
	lods	byte [esi]
6262
	cmp	al,','
6263
	jne	invalid_operand
6264
	lods	byte [esi]
6265
	cmp	al,14h
6266
	je	bndmov_reg_reg
6267
	call	get_size_operator
6268
	cmp	al,'['
6269
	jne	invalid_operand
6270
	call	get_address_of_required_size
6271
	jmp	instruction_ready
6272
      bndmov_reg_reg:
6273
	lods	byte [esi]
6274
	call	convert_bnd_register
6275
	mov	bl,al
6276
	jmp	nomem_instruction_ready
6277
    take_bnd_register:
6278
	lods	byte [esi]
6279
	cmp	al,14h
6280
	jne	invalid_operand
6281
	lods	byte [esi]
6282
    convert_bnd_register:
6283
	mov	ah,al
6284
	shr	ah,4
6285
	cmp	ah,6
6286
	jne	invalid_operand
6287
	and	al,1111b
6288
	ret
6289
bndmk_instruction:
6290
	mov	[opcode_prefix],0F3h
6291
	mov	[base_code],0Fh
6292
	mov	[extended_code],al
6293
	call	take_bnd_register
6294
	mov	[postbyte_register],al
6295
	lods	byte [esi]
6296
	cmp	al,','
6297
	jne	invalid_operand
6298
	lods	byte [esi]
6299
	call	get_size_operator
6300
	cmp	al,'['
6301
	jne	invalid_operand
6302
	call	get_bnd_size
6303
	call	get_address_prefixes
6304
	call	get_address_component
6305
	cmp	byte [esi-1],']'
6306
	je	bndmk_ready
6307
	lods	byte [esi]
6308
	cmp	al,','
6309
	jne	invalid_operand
6310
	lods	byte [esi]
6311
	cmp	al,'('
6312
	jne	invalid_operand
6313
	or	dl,bl
6314
	or	dl,[address_sign]
6315
	or	edx,[address_high]
6316
	jnz	invalid_address
6317
	mov	[address_register],bh
6318
	call	get_address_component
6319
	lods	byte [esi]
6320
	cmp	al,']'
6321
	jne	invalid_operand
6322
	or	bh,bh
6323
	jz	bndmk_selected_base
6324
	cmp	bl,bh
6325
	je	bndmk_to_index
6326
	or	bl,bl
6327
	jnz	invalid_address
6328
	mov	bl,bh
6329
      bndmk_to_index:
6330
	inc	cl
6331
      bndmk_selected_base:
6332
	mov	bh,[address_register]
6333
      bndmk_ready:
6334
	or	bx,bx
6335
	jz	instruction_ready
6336
	cmp	[address_size_declared],0
6337
	jne	instruction_ready
6338
	and	ch,not 0Fh
6339
	jmp	instruction_ready
6340
    get_bnd_size:
6341
	mov	al,4
6342
	cmp	[code_type],64
6343
	jne	bnd_size_ok
6344
	add	al,4
6345
      bnd_size_ok:
6346
	mov	[address_size],al
6347
	ret
6348
    get_address_component:
6349
	mov	[free_address_range],0
6350
	call	calculate_address
6351
	mov	[address_high],edx
6352
	mov	edx,eax
6353
	or	bx,bx
6354
	jz	address_component_ok
6355
	mov	al,bl
6356
	or	al,bh
6357
	shr	al,4
6358
	cmp	al,[address_size]
6359
	jne	invalid_address
6360
      address_component_ok:
6361
	ret
6362
bndldx_instruction:
6363
	mov	[base_code],0Fh
6364
	mov	[extended_code],al
6365
	call	take_bnd_register
6366
	mov	[postbyte_register],al
6367
	lods	byte [esi]
6368
	cmp	al,','
6369
	jne	invalid_operand
6370
	call	take_bnd_mib
6371
	jmp	bndmk_ready
6372
bndstx_instruction:
6373
	mov	[base_code],0Fh
6374
	mov	[extended_code],al
6375
	call	take_bnd_mib
6376
	lods	byte [esi]
6377
	cmp	al,','
6378
	jne	invalid_operand
6379
	call	take_bnd_register
6380
	mov	[postbyte_register],al
6381
	jmp	bndmk_ready
6382
    take_bnd_mib:
6383
	lods	byte [esi]
6384
	cmp	al,'['
6385
	jne	invalid_operand
6386
	call	get_bnd_size
6387
	call	get_address_prefixes
6388
	call	get_address_component
6389
	cmp	byte [esi-1],']'
6390
	je	bnd_mib_ok
6391
	lods	byte [esi]
6392
	cmp	al,','
6393
	jne	invalid_operand
6394
	lods	byte [esi]
6395
	cmp	al,'('
6396
	jne	invalid_operand
6397
	mov	al,[address_sign]
6398
	push	eax ebx ecx edx [address_symbol]
6399
	call	get_address_component
6400
	lods	byte [esi]
6401
	cmp	al,']'
6402
	jne	invalid_operand
6403
	or	dl,bl
6404
	or	dl,[address_sign]
6405
	or	edx,[address_high]
6406
	jnz	invalid_address
6407
	mov	[address_register],bh
6408
	pop	[address_symbol] edx ecx ebx eax
6409
	mov	[address_sign],al
6410
	or	bl,bl
6411
	jz	mib_place_index
6412
	or	bh,bh
6413
	jnz	invalid_address
6414
	cmp	cl,1
6415
	jne	invalid_address
6416
	mov	bh,bl
6417
      mib_place_index:
6418
	mov	bl,[address_register]
6419
	xor	cl,cl
6420
	or	bl,bl
6421
	jz	bnd_mib_ok
6422
	inc	cl
6423
      bnd_mib_ok:
6424
	ret
6425
6426
 
6427
	mov	[postbyte_register],6
6428
	mov	[extended_code],0AEh
6429
	mov	[base_code],0Fh
6430
	mov	[opcode_prefix],al
6431
	call	take_register
6432
	cmp	ah,4
6433
	jne	invalid_operand_size
6434
	mov	bl,al
6435
	cmp	byte [esi],','
6436
	jne	nomem_instruction_ready
6437
	inc	esi
6438
	call	take_register
6439
	cmp	ax,0402h
6440
	jne	invalid_operand
6441
	lods	byte [esi]
6442
	cmp	al,','
6443
	jne	invalid_operand
6444
	call	take_register
6445
	cmp	ax,0400h
6446
	jne	invalid_operand
6447
	jmp	nomem_instruction_ready
6448
umonitor_instruction:
6449
	mov	[postbyte_register],6
6450
	mov	[extended_code],0AEh
6451
	mov	[base_code],0Fh
6452
	mov	[opcode_prefix],0F3h
6453
	call	take_register
6454
	mov	bl,al
6455
	mov	al,ah
6456
	call	operand_autodetect
6457
	jmp	nomem_instruction_ready
6458
movdir64b_instruction:
6459
	call	setup_66_0f_38
6460
	call	take_register
6461
	mov	[postbyte_register],al
6462
	xor	al,al
6463
	xchg	al,[operand_size]
6464
	push	eax
6465
	lods	byte [esi]
6466
	cmp	al,','
6467
	jne	invalid_operand
6468
	lods	byte [esi]
6469
	call	get_size_operator
6470
	cmp	al,'['
6471
	jne	invalid_operand
6472
	call	get_address
6473
	mov	al,[operand_size]
6474
	or	al,al
6475
	jz	movdir64b_ready
6476
	cmp	al,64
6477
	jne	invalid_operand_size
6478
      movdir64b_ready:
6479
	push	edi
6480
	call	store_instruction
6481
	pop	ebx eax
6482
	mov	cl,[code_type]
6483
	cmp	byte [ebx],67h
6484
	jne	movdir64b_size_check
6485
	shr	cl,1
6486
	cmp	cl,16
6487
	jae	movdir64b_size_check
6488
	mov	cl,32
6489
      movdir64b_size_check:
6490
	shl	al,3
6491
	cmp	al,cl
6492
	jne	invalid_operand_size
6493
	jmp	instruction_assembled
6494
6495
 
6496
	shl	eax,24
6497
	or	eax,010FF3h
6498
	stos	dword [edi]
6499
	jmp	instruction_assembled
6500
rstorssp_instruction:
6501
	mov	ah,1
6502
	jmp	setup_clrssbsy
6503
clrssbsy_instruction:
6504
	mov	ah,0AEh
6505
      setup_clrssbsy:
6506
	mov	[base_code],0Fh
6507
	mov	[extended_code],ah
6508
	mov	[postbyte_register],al
6509
	mov	[opcode_prefix],0F3h
6510
	lods	byte [esi]
6511
	call	get_size_operator
6512
	cmp	al,'['
6513
	jne	invalid_operand
6514
	call	get_address
6515
	test	[operand_size],not 8
6516
	jnz	invalid_operand_size
6517
	jmp	instruction_ready
6518
rdsspq_instruction:
6519
	mov	[rex_prefix],48h
6520
rdsspd_instruction:
6521
	mov	ah,1Eh
6522
	jmp	setup_incssp
6523
incsspq_instruction:
6524
	mov	[rex_prefix],48h
6525
incsspd_instruction:
6526
	mov	ah,0AEh
6527
      setup_incssp:
6528
	mov	[base_code],0Fh
6529
	mov	[extended_code],ah
6530
	mov	[postbyte_register],al
6531
	mov	[opcode_prefix],0F3h
6532
	lods	byte [esi]
6533
	call	get_size_operator
6534
	cmp	al,10h
6535
	jne	invalid_operand
6536
	lods	byte [esi]
6537
	call	convert_register
6538
	mov	bl,al
6539
	call	cet_size_check
6540
	jmp	nomem_instruction_ready
6541
      cet_size_check:
6542
	cmp	[rex_prefix],0
6543
	je	cet_dword
6544
	cmp	[code_type],64
6545
	jne	illegal_instruction
6546
	shr	ah,1
6547
      cet_dword:
6548
	cmp	ah,4
6549
	jne	invalid_operand_size
6550
	ret
6551
wrussq_instruction:
6552
	mov	[opcode_prefix],66h
6553
wrssq_instruction:
6554
	mov	[rex_prefix],48h
6555
	jmp	wrssd_instruction
6556
wrussd_instruction:
6557
	mov	[opcode_prefix],66h
6558
wrssd_instruction:
6559
	mov	[base_code],0Fh
6560
	mov	[extended_code],38h
6561
	mov	[supplemental_code],al
6562
	lods	byte [esi]
6563
	call	get_size_operator
6564
	cmp	al,10h
6565
	je	wrss_reg
6566
	cmp	al,'['
6567
	jne	invalid_operand
6568
	call	get_address
6569
	push	edx ebx ecx
6570
	lods	byte [esi]
6571
	cmp	al,','
6572
	jne	invalid_operand
6573
	call	take_register
6574
	mov	[postbyte_register],al
6575
	pop	ecx ebx edx
6576
	call	cet_size_check
6577
	jmp	instruction_ready
6578
      wrss_reg:
6579
	lods	byte [esi]
6580
	call	convert_register
6581
	mov	[postbyte_register],al
6582
	lods	byte [esi]
6583
	cmp	al,','
6584
	jne	invalid_operand
6585
	call	take_register
6586
	mov	bl,al
6587
	xchg	bl,[postbyte_register]
6588
	call	cet_size_check
6589
	jmp	nomem_instruction_ready
6590
endbr_instruction:
6591
	shl	eax,24
6592
	or	eax,1E0FF3h
6593
	stos	dword [edi]
6594
	jmp	instruction_assembled
6595
6596
 
6597
	lods	byte [esi]
6598
	call	get_size_operator
6599
	cmp	al,10h
6600
	jne	invalid_operand
6601
	lods	byte [esi]
6602
convert_register:
6603
	mov	ah,al
6604
	shr	ah,4
6605
	and	al,0Fh
6606
	cmp	ah,8
6607
	je	match_register_size
6608
	cmp	ah,4
6609
	ja	invalid_operand
6610
	cmp	ah,1
6611
	ja	match_register_size
6612
	cmp	al,4
6613
	jb	match_register_size
6614
	or	ah,ah
6615
	jz	high_byte_register
6616
	or	[rex_prefix],40h
6617
      match_register_size:
6618
	cmp	ah,[operand_size]
6619
	je	register_size_ok
6620
	cmp	[operand_size],0
6621
	jne	operand_sizes_do_not_match
6622
	mov	[operand_size],ah
6623
      register_size_ok:
6624
	ret
6625
      high_byte_register:
6626
	mov	ah,1
6627
	or	[rex_prefix],10h
6628
	jmp	match_register_size
6629
convert_fpu_register:
6630
	mov	ah,al
6631
	shr	ah,4
6632
	and	al,111b
6633
	cmp	ah,10
6634
	jne	invalid_operand
6635
	jmp	match_register_size
6636
convert_mmx_register:
6637
	mov	ah,al
6638
	shr	ah,4
6639
	cmp	ah,0Ch
6640
	je	xmm_register
6641
	ja	invalid_operand
6642
	and	al,111b
6643
	cmp	ah,0Bh
6644
	jne	invalid_operand
6645
	mov	ah,8
6646
	jmp	match_register_size
6647
      xmm_register:
6648
	and	al,0Fh
6649
	mov	ah,16
6650
	cmp	al,8
6651
	jb	match_register_size
6652
	cmp	[code_type],64
6653
	jne	invalid_operand
6654
	jmp	match_register_size
6655
convert_xmm_register:
6656
	mov	ah,al
6657
	shr	ah,4
6658
	cmp	ah,0Ch
6659
	je	xmm_register
6660
	jmp	invalid_operand
6661
get_size_operator:
6662
	xor	ah,ah
6663
	cmp	al,11h
6664
	jne	no_size_operator
6665
	mov	[size_declared],1
6666
	lods	word [esi]
6667
	xchg	al,ah
6668
	or	[operand_flags],1
6669
	cmp	ah,[operand_size]
6670
	je	size_operator_ok
6671
	cmp	[operand_size],0
6672
	jne	operand_sizes_do_not_match
6673
	mov	[operand_size],ah
6674
      size_operator_ok:
6675
	ret
6676
      no_size_operator:
6677
	mov	[size_declared],0
6678
	cmp	al,'['
6679
	jne	size_operator_ok
6680
	and	[operand_flags],not 1
6681
	ret
6682
get_jump_operator:
6683
	mov	[jump_type],0
6684
	cmp	al,12h
6685
	jne	jump_operator_ok
6686
	lods	word [esi]
6687
	mov	[jump_type],al
6688
	mov	al,ah
6689
      jump_operator_ok:
6690
	ret
6691
get_address:
6692
	and	[address_size],0
6693
    get_address_of_required_size:
6694
	call	get_address_prefixes
6695
	and	[free_address_range],0
6696
	call	calculate_address
6697
	cmp	byte [esi-1],']'
6698
	jne	invalid_address
6699
	mov	[address_high],edx
6700
	mov	edx,eax
6701
	cmp	[address_size_declared],0
6702
	jne	address_ok
6703
	cmp	[segment_register],4
6704
	ja	address_ok
6705
	or	bx,bx
6706
	jnz	clear_address_size
6707
	cmp	[code_type],64
6708
	jne	address_ok
6709
      calculate_relative_address:
6710
	mov	edx,[address_symbol]
6711
	mov	[symbol_identifier],edx
6712
	mov	edx,[address_high]
6713
	mov	ebp,[addressing_space]
6714
	call	calculate_relative_offset
6715
	mov	[address_high],edx
6716
	cdq
6717
	cmp	edx,[address_high]
6718
	je	address_high_ok
6719
	call	recoverable_overflow
6720
      address_high_ok:
6721
	mov	edx,eax
6722
	ror	ecx,16
6723
	mov	cl,[value_type]
6724
	rol	ecx,16
6725
	mov	bx,9900h
6726
      clear_address_size:
6727
	and	ch,not 0Fh
6728
      address_ok:
6729
	ret
6730
get_address_prefixes:
6731
	and	[segment_register],0
6732
	and	[address_size_declared],0
6733
	mov	al,[code_type]
6734
	shr	al,3
6735
	mov	[value_size],al
6736
	mov	al,[esi]
6737
	and	al,11110000b
6738
	cmp	al,60h
6739
	jne	get_address_size_prefix
6740
	lods	byte [esi]
6741
	sub	al,60h
6742
	mov	[segment_register],al
6743
	mov	al,[esi]
6744
	and	al,11110000b
6745
      get_address_size_prefix:
6746
	cmp	al,70h
6747
	jne	address_size_prefix_ok
6748
	lods	byte [esi]
6749
	sub	al,70h
6750
	cmp	al,2
6751
	jb	invalid_address_size
6752
	cmp	al,8
6753
	ja	invalid_address_size
6754
	mov	[value_size],al
6755
	or	[address_size_declared],1
6756
	or	[address_size],al
6757
	cmp	al,[address_size]
6758
	jne	invalid_address_size
6759
      address_size_prefix_ok:
6760
	ret
6761
operand_16bit:
6762
	cmp	[code_type],16
6763
	je	size_prefix_ok
6764
	mov	[operand_prefix],66h
6765
	ret
6766
operand_32bit:
6767
	cmp	[code_type],16
6768
	jne	size_prefix_ok
6769
	mov	[operand_prefix],66h
6770
      size_prefix_ok:
6771
	ret
6772
operand_64bit:
6773
	cmp	[code_type],64
6774
	jne	illegal_instruction
6775
	or	[rex_prefix],48h
6776
	ret
6777
operand_autodetect:
6778
	cmp	al,2
6779
	je	operand_16bit
6780
	cmp	al,4
6781
	je	operand_32bit
6782
	cmp	al,8
6783
	je	operand_64bit
6784
	jmp	invalid_operand_size
6785
store_segment_prefix_if_necessary:
6786
	mov	al,[segment_register]
6787
	or	al,al
6788
	jz	segment_prefix_ok
6789
	cmp	al,4
6790
	ja	segment_prefix_386
6791
	cmp	[code_type],64
6792
	je	segment_prefix_ok
6793
	cmp	al,3
6794
	je	ss_prefix
6795
	jb	segment_prefix_86
6796
	cmp	bl,25h
6797
	je	segment_prefix_86
6798
	cmp	bh,25h
6799
	je	segment_prefix_86
6800
	cmp	bh,45h
6801
	je	segment_prefix_86
6802
	cmp	bh,44h
6803
	je	segment_prefix_86
6804
	ret
6805
      ss_prefix:
6806
	cmp	bl,25h
6807
	je	segment_prefix_ok
6808
	cmp	bh,25h
6809
	je	segment_prefix_ok
6810
	cmp	bh,45h
6811
	je	segment_prefix_ok
6812
	cmp	bh,44h
6813
	je	segment_prefix_ok
6814
	jmp	segment_prefix_86
6815
store_segment_prefix:
6816
	mov	al,[segment_register]
6817
	or	al,al
6818
	jz	segment_prefix_ok
6819
	cmp	al,5
6820
	jae	segment_prefix_386
6821
      segment_prefix_86:
6822
	dec	al
6823
	shl	al,3
6824
	add	al,26h
6825
	stos	byte [edi]
6826
	jmp	segment_prefix_ok
6827
      segment_prefix_386:
6828
	add	al,64h-5
6829
	stos	byte [edi]
6830
      segment_prefix_ok:
6831
	ret
6832
store_instruction_code:
6833
	cmp	[vex_required],0
6834
	jne	store_vex_instruction_code
6835
store_classic_instruction_code:
6836
	mov	al,[operand_prefix]
6837
	or	al,al
6838
	jz	operand_prefix_ok
6839
	stos	byte [edi]
6840
      operand_prefix_ok:
6841
	mov	al,[opcode_prefix]
6842
	or	al,al
6843
	jz	opcode_prefix_ok
6844
	stos	byte [edi]
6845
      opcode_prefix_ok:
6846
	mov	al,[rex_prefix]
6847
	test	al,40h
6848
	jz	rex_prefix_ok
6849
	cmp	[code_type],64
6850
	jne	invalid_operand
6851
	test	al,0B0h
6852
	jnz	disallowed_combination_of_registers
6853
	stos	byte [edi]
6854
      rex_prefix_ok:
6855
	mov	al,[base_code]
6856
	stos	byte [edi]
6857
	cmp	al,0Fh
6858
	jne	instruction_code_ok
6859
      store_extended_code:
6860
	mov	al,[extended_code]
6861
	stos	byte [edi]
6862
	cmp	al,38h
6863
	je	store_supplemental_code
6864
	cmp	al,3Ah
6865
	je	store_supplemental_code
6866
      instruction_code_ok:
6867
	ret
6868
      store_supplemental_code:
6869
	mov	al,[supplemental_code]
6870
	stos	byte [edi]
6871
	ret
6872
store_nomem_instruction:
6873
	test	[postbyte_register],10000b
6874
	jz	nomem_reg_high_code_ok
6875
	or	[vex_required],10h
6876
	and	[postbyte_register],1111b
6877
      nomem_reg_high_code_ok:
6878
	test	[postbyte_register],1000b
6879
	jz	nomem_reg_code_ok
6880
	or	[rex_prefix],44h
6881
	and	[postbyte_register],111b
6882
      nomem_reg_code_ok:
6883
	test	bl,10000b
6884
	jz	nomem_rm_high_code_ok
6885
	or	[rex_prefix],42h
6886
	or	[vex_required],8
6887
	and	bl,1111b
6888
      nomem_rm_high_code_ok:
6889
	test	bl,1000b
6890
	jz	nomem_rm_code_ok
6891
	or	[rex_prefix],41h
6892
	and	bl,111b
6893
      nomem_rm_code_ok:
6894
	and	[displacement_compression],0
6895
	call	store_instruction_code
6896
	mov	al,[postbyte_register]
6897
	shl	al,3
6898
	or	al,bl
6899
	or	al,11000000b
6900
	stos	byte [edi]
6901
	ret
6902
store_instruction:
6903
	mov	[current_offset],edi
6904
	and	[displacement_compression],0
6905
	test	[postbyte_register],10000b
6906
	jz	reg_high_code_ok
6907
	or	[vex_required],10h
6908
	and	[postbyte_register],1111b
6909
      reg_high_code_ok:
6910
	test	[postbyte_register],1000b
6911
	jz	reg_code_ok
6912
	or	[rex_prefix],44h
6913
	and	[postbyte_register],111b
6914
      reg_code_ok:
6915
	cmp	[code_type],64
6916
	jne	address_value_ok
6917
	xor	eax,eax
6918
	bt	edx,31
6919
	sbb	eax,[address_high]
6920
	jz	address_value_ok
6921
	cmp	[address_high],0
6922
	jne	address_value_out_of_range
6923
	test	ch,44h
6924
	jnz	address_value_ok
6925
	test	bx,8080h
6926
	jz	address_value_ok
6927
      address_value_out_of_range:
6928
	call	recoverable_overflow
6929
      address_value_ok:
6930
	call	store_segment_prefix_if_necessary
6931
	test	[vex_required],4
6932
	jnz	address_vsib
6933
	or	bx,bx
6934
	jz	address_immediate
6935
	cmp	bx,9800h
6936
	je	address_rip_based
6937
	cmp	bx,9400h
6938
	je	address_eip_based
6939
	cmp	bx,9900h
6940
	je	address_relative
6941
	mov	al,bl
6942
	or	al,bh
6943
	and	al,11110000b
6944
	cmp	al,80h
6945
	je	postbyte_64bit
6946
	cmp	al,40h
6947
	je	postbyte_32bit
6948
	cmp	al,20h
6949
	jne	invalid_address
6950
	cmp	[code_type],64
6951
	je	invalid_address_size
6952
	call	address_16bit_prefix
6953
	test	ch,22h
6954
	setz	[displacement_compression]
6955
	call	store_instruction_code
6956
	cmp	bl,bh
6957
	jbe	determine_16bit_address
6958
	xchg	bl,bh
6959
      determine_16bit_address:
6960
	cmp	bx,2600h
6961
	je	address_si
6962
	cmp	bx,2700h
6963
	je	address_di
6964
	cmp	bx,2300h
6965
	je	address_bx
6966
	cmp	bx,2500h
6967
	je	address_bp
6968
	cmp	bx,2625h
6969
	je	address_bp_si
6970
	cmp	bx,2725h
6971
	je	address_bp_di
6972
	cmp	bx,2723h
6973
	je	address_bx_di
6974
	cmp	bx,2623h
6975
	jne	invalid_address
6976
      address_bx_si:
6977
	xor	al,al
6978
	jmp	postbyte_16bit
6979
      address_bx_di:
6980
	mov	al,1
6981
	jmp	postbyte_16bit
6982
      address_bp_si:
6983
	mov	al,10b
6984
	jmp	postbyte_16bit
6985
      address_bp_di:
6986
	mov	al,11b
6987
	jmp	postbyte_16bit
6988
      address_si:
6989
	mov	al,100b
6990
	jmp	postbyte_16bit
6991
      address_di:
6992
	mov	al,101b
6993
	jmp	postbyte_16bit
6994
      address_bx:
6995
	mov	al,111b
6996
	jmp	postbyte_16bit
6997
      address_bp:
6998
	mov	al,110b
6999
      postbyte_16bit:
7000
	test	ch,22h
7001
	jnz	address_16bit_value
7002
	or	ch,ch
7003
	jnz	address_sizes_do_not_agree
7004
	cmp	edx,10000h
7005
	jge	value_out_of_range
7006
	cmp	edx,-8000h
7007
	jl	value_out_of_range
7008
	or	dx,dx
7009
	jz	address
7010
	cmp	[displacement_compression],2
7011
	ja	address_8bit_value
7012
	je	address_16bit_value
7013
	cmp	dx,80h
7014
	jb	address_8bit_value
7015
	cmp	dx,-80h
7016
	jae	address_8bit_value
7017
      address_16bit_value:
7018
	or	al,10000000b
7019
	mov	cl,[postbyte_register]
7020
	shl	cl,3
7021
	or	al,cl
7022
	stos	byte [edi]
7023
	mov	eax,edx
7024
	stos	word [edi]
7025
	ret
7026
      address_8bit_value:
7027
	or	al,01000000b
7028
	mov	cl,[postbyte_register]
7029
	shl	cl,3
7030
	or	al,cl
7031
	stos	byte [edi]
7032
	mov	al,dl
7033
	stos	byte [edi]
7034
	ret
7035
      address:
7036
	cmp	al,110b
7037
	je	address_8bit_value
7038
	mov	cl,[postbyte_register]
7039
	shl	cl,3
7040
	or	al,cl
7041
	stos	byte [edi]
7042
	ret
7043
      address_vsib:
7044
	mov	al,bl
7045
	shr	al,4
7046
	test	al,1
7047
	jz	vsib_high_code_ok
7048
	or	[vex_register],10000b
7049
	or	[vex_required],8
7050
	xor	al,1
7051
      vsib_high_code_ok:
7052
	cmp	al,6
7053
	je	vsib_index_ok
7054
	cmp	al,0Ch
7055
	jb	invalid_address
7056
      vsib_index_ok:
7057
	mov	al,bh
7058
	shr	al,4
7059
	cmp	al,4
7060
	je	postbyte_32bit
7061
	cmp	[code_type],64
7062
	je	address_prefix_ok
7063
	test	al,al
7064
	jnz	invalid_address
7065
      postbyte_32bit:
7066
	call	address_32bit_prefix
7067
	jmp	address_prefix_ok
7068
      postbyte_64bit:
7069
	cmp	[code_type],64
7070
	jne	invalid_address_size
7071
      address_prefix_ok:
7072
	cmp	bl,44h
7073
	je	invalid_address
7074
	cmp	bl,84h
7075
	je	invalid_address
7076
	test	bh,1000b
7077
	jz	base_code_ok
7078
	or	[rex_prefix],41h
7079
      base_code_ok:
7080
	test	bl,1000b
7081
	jz	index_code_ok
7082
	or	[rex_prefix],42h
7083
      index_code_ok:
7084
	test	ch,44h or 88h
7085
	setz	[displacement_compression]
7086
	call	store_instruction_code
7087
	or	cl,cl
7088
	jz	only_base_register
7089
      base_and_index:
7090
	mov	al,100b
7091
	xor	ah,ah
7092
	cmp	cl,1
7093
	je	scale_ok
7094
	cmp	cl,2
7095
	je	scale_1
7096
	cmp	cl,4
7097
	je	scale_2
7098
	or	ah,11000000b
7099
	jmp	scale_ok
7100
      scale_2:
7101
	or	ah,10000000b
7102
	jmp	scale_ok
7103
      scale_1:
7104
	or	ah,01000000b
7105
      scale_ok:
7106
	or	bh,bh
7107
	jz	only_index_register
7108
	and	bl,111b
7109
	shl	bl,3
7110
	or	ah,bl
7111
	and	bh,111b
7112
	or	ah,bh
7113
      sib_ready:
7114
	test	ch,44h or 88h
7115
	jnz	sib_address_32bit_value
7116
	or	ch,ch
7117
	jnz	address_sizes_do_not_agree
7118
	cmp	bh,5
7119
	je	address_value
7120
	or	edx,edx
7121
	jz	sib_address
7122
      address_value:
7123
	cmp	[displacement_compression],2
7124
	ja	sib_address_8bit_value
7125
	je	sib_address_32bit_value
7126
	cmp	edx,80h
7127
	jb	sib_address_8bit_value
7128
	cmp	edx,-80h
7129
	jnb	sib_address_8bit_value
7130
      sib_address_32bit_value:
7131
	or	al,10000000b
7132
	mov	cl,[postbyte_register]
7133
	shl	cl,3
7134
	or	al,cl
7135
	stos	word [edi]
7136
	jmp	store_address_32bit_value
7137
      sib_address_8bit_value:
7138
	or	al,01000000b
7139
	mov	cl,[postbyte_register]
7140
	shl	cl,3
7141
	or	al,cl
7142
	stos	word [edi]
7143
	mov	al,dl
7144
	stos	byte [edi]
7145
	ret
7146
      sib_address:
7147
	mov	cl,[postbyte_register]
7148
	shl	cl,3
7149
	or	al,cl
7150
	stos	word [edi]
7151
	ret
7152
      only_index_register:
7153
	or	ah,101b
7154
	and	bl,111b
7155
	shl	bl,3
7156
	or	ah,bl
7157
	mov	cl,[postbyte_register]
7158
	shl	cl,3
7159
	or	al,cl
7160
	stos	word [edi]
7161
	test	ch,44h or 88h
7162
	jnz	store_address_32bit_value
7163
	or	ch,ch
7164
	jnz	invalid_address_size
7165
	cmp	[displacement_compression],2
7166
	jbe	store_address_32bit_value
7167
	mov	edx,[uncompressed_displacement]
7168
	jmp	store_address_32bit_value
7169
      zero_index_register:
7170
	mov	bl,4
7171
	mov	cl,1
7172
	jmp	base_and_index
7173
      only_base_register:
7174
	mov	al,bh
7175
	and	al,111b
7176
	cmp	al,4
7177
	je	zero_index_register
7178
	test	ch,44h or 88h
7179
	jnz	simple_address_32bit_value
7180
	or	ch,ch
7181
	jnz	address_sizes_do_not_agree
7182
	or	edx,edx
7183
	jz	simple_address
7184
	cmp	[displacement_compression],2
7185
	ja	simple_address_8bit_value
7186
	je	simple_address_32bit_value
7187
	cmp	edx,80h
7188
	jb	simple_address_8bit_value
7189
	cmp	edx,-80h
7190
	jnb	simple_address_8bit_value
7191
      simple_address_32bit_value:
7192
	or	al,10000000b
7193
	mov	cl,[postbyte_register]
7194
	shl	cl,3
7195
	or	al,cl
7196
	stos	byte [edi]
7197
	jmp	store_address_32bit_value
7198
      simple_address_8bit_value:
7199
	or	al,01000000b
7200
	mov	cl,[postbyte_register]
7201
	shl	cl,3
7202
	or	al,cl
7203
	stos	byte [edi]
7204
	mov	al,dl
7205
	stos	byte [edi]
7206
	ret
7207
      simple_address:
7208
	cmp	al,5
7209
	je	simple_address_8bit_value
7210
	mov	cl,[postbyte_register]
7211
	shl	cl,3
7212
	or	al,cl
7213
	stos	byte [edi]
7214
	ret
7215
      address_immediate:
7216
	cmp	[code_type],64
7217
	je	address_immediate_sib
7218
	test	ch,44h or 88h
7219
	jnz	address_immediate_32bit
7220
	test	ch,22h
7221
	jnz	address_immediate_16bit
7222
	or	ch,ch
7223
	jnz	invalid_address_size
7224
	cmp	[code_type],16
7225
	je	addressing_16bit
7226
      address_immediate_32bit:
7227
	call	address_32bit_prefix
7228
	call	store_instruction_code
7229
      store_immediate_address:
7230
	mov	al,101b
7231
	mov	cl,[postbyte_register]
7232
	shl	cl,3
7233
	or	al,cl
7234
	stos	byte [edi]
7235
      store_address_32bit_value:
7236
	test	ch,0F0h
7237
	jz	address_32bit_relocation_ok
7238
	mov	eax,ecx
7239
	shr	eax,16
7240
	cmp	al,4
7241
	jne	address_32bit_relocation
7242
	mov	al,2
7243
      address_32bit_relocation:
7244
	xchg	[value_type],al
7245
	mov	ebx,[address_symbol]
7246
	xchg	ebx,[symbol_identifier]
7247
	call	mark_relocation
7248
	mov	[value_type],al
7249
	mov	[symbol_identifier],ebx
7250
      address_32bit_relocation_ok:
7251
	mov	eax,edx
7252
	stos	dword [edi]
7253
	ret
7254
      store_address_64bit_value:
7255
	test	ch,0F0h
7256
	jz	address_64bit_relocation_ok
7257
	mov	eax,ecx
7258
	shr	eax,16
7259
	xchg	[value_type],al
7260
	mov	ebx,[address_symbol]
7261
	xchg	ebx,[symbol_identifier]
7262
	call	mark_relocation
7263
	mov	[value_type],al
7264
	mov	[symbol_identifier],ebx
7265
      address_64bit_relocation_ok:
7266
	mov	eax,edx
7267
	stos	dword [edi]
7268
	mov	eax,[address_high]
7269
	stos	dword [edi]
7270
	ret
7271
      address_immediate_sib:
7272
	test	ch,44h
7273
	jnz	address_immediate_sib_32bit
7274
	test	ch,not 88h
7275
	jnz	invalid_address_size
7276
	test	edx,80000000h
7277
	jz	address_immediate_sib_store
7278
	cmp	[address_high],0
7279
	je	address_immediate_sib_nosignextend
7280
      address_immediate_sib_store:
7281
	call	store_instruction_code
7282
	mov	al,100b
7283
	mov	ah,100101b
7284
	mov	cl,[postbyte_register]
7285
	shl	cl,3
7286
	or	al,cl
7287
	stos	word [edi]
7288
	jmp	store_address_32bit_value
7289
      address_immediate_sib_32bit:
7290
	test	ecx,0FF0000h
7291
	jnz	address_immediate_sib_nosignextend
7292
	test	edx,80000000h
7293
	jz	address_immediate_sib_store
7294
      address_immediate_sib_nosignextend:
7295
	call	address_32bit_prefix
7296
	jmp	address_immediate_sib_store
7297
      address_eip_based:
7298
	mov	al,67h
7299
	stos	byte [edi]
7300
      address_rip_based:
7301
	cmp	[code_type],64
7302
	jne	invalid_address
7303
	call	store_instruction_code
7304
	jmp	store_immediate_address
7305
      address_relative:
7306
	call	store_instruction_code
7307
	movzx	eax,[immediate_size]
7308
	add	eax,edi
7309
	sub	eax,[current_offset]
7310
	add	eax,5
7311
	sub	edx,eax
7312
	jno	@f
7313
	call	recoverable_overflow
7314
      @@:
7315
	mov	al,101b
7316
	mov	cl,[postbyte_register]
7317
	shl	cl,3
7318
	or	al,cl
7319
	stos	byte [edi]
7320
	shr	ecx,16
7321
	xchg	[value_type],cl
7322
	mov	ebx,[address_symbol]
7323
	xchg	ebx,[symbol_identifier]
7324
	mov	eax,edx
7325
	call	mark_relocation
7326
	mov	[value_type],cl
7327
	mov	[symbol_identifier],ebx
7328
	stos	dword [edi]
7329
	ret
7330
      addressing_16bit:
7331
	cmp	edx,10000h
7332
	jge	address_immediate_32bit
7333
	cmp	edx,-8000h
7334
	jl	address_immediate_32bit
7335
	movzx	edx,dx
7336
      address_immediate_16bit:
7337
	call	address_16bit_prefix
7338
	call	store_instruction_code
7339
	mov	al,110b
7340
	mov	cl,[postbyte_register]
7341
	shl	cl,3
7342
	or	al,cl
7343
	stos	byte [edi]
7344
	mov	eax,edx
7345
	stos	word [edi]
7346
	cmp	edx,10000h
7347
	jge	value_out_of_range
7348
	cmp	edx,-8000h
7349
	jl	value_out_of_range
7350
	ret
7351
      address_16bit_prefix:
7352
	cmp	[code_type],16
7353
	je	instruction_prefix_ok
7354
	mov	al,67h
7355
	stos	byte [edi]
7356
	ret
7357
      address_32bit_prefix:
7358
	cmp	[code_type],32
7359
	je	instruction_prefix_ok
7360
	mov	al,67h
7361
	stos	byte [edi]
7362
      instruction_prefix_ok:
7363
	ret
7364
store_instruction_with_imm8:
7365
	mov	[immediate_size],1
7366
	call	store_instruction
7367
	mov	al,byte [value]
7368
	stos	byte [edi]
7369
	ret
7370
store_instruction_with_imm16:
7371
	mov	[immediate_size],2
7372
	call	store_instruction
7373
	mov	ax,word [value]
7374
	call	mark_relocation
7375
	stos	word [edi]
7376
	ret
7377
store_instruction_with_imm32:
7378
	mov	[immediate_size],4
7379
	call	store_instruction
7380
	mov	eax,dword [value]
7381
	call	mark_relocation
7382
	stos	dword [edi]
7383
	ret
7384