Subversion Repositories Kolibri OS

Rev

Rev 4478 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
4478 dunkaist 1
 
2
; Copyright (c) 1999-2016, Tomasz Grysztar.
6467 dunkaist 3
; All rights reserved.
4478 dunkaist 4
5
 
6467 dunkaist 6
	or	[vex_required],8
7
avx_single_source_pd_instruction_er:
8
	or	[operand_flags],2+4+8
9
	jmp	avx_pd_instruction
4478 dunkaist 10
avx_single_source_pd_instruction_sae_evex:
6467 dunkaist 11
	or	[vex_required],8
12
	or	[operand_flags],2+4
13
	jmp	avx_pd_instruction
14
avx_pd_instruction_imm8:
4478 dunkaist 15
	mov	[immediate_size],1
16
	jmp	avx_pd_instruction
6467 dunkaist 17
avx_pd_instruction_er:
18
	or	[operand_flags],8
19
avx_pd_instruction_sae:
20
	or	[operand_flags],4
21
avx_pd_instruction:
4478 dunkaist 22
	mov	[opcode_prefix],66h
23
	or	[rex_prefix],80h
6467 dunkaist 24
	mov	cx,0800h
25
	jmp	avx_instruction_with_broadcast
26
avx_pd_instruction_38_evex:
27
	or	[vex_required],8
28
	mov	[supplemental_code],al
29
	mov	al,38h
30
	jmp	avx_pd_instruction
31
avx_cvtps2dq_instruction:
32
	mov	[opcode_prefix],66h
33
	jmp	avx_single_source_ps_instruction_er
34
avx_cvtudq2ps_instruction:
35
	mov	[opcode_prefix],0F2h
36
avx_single_source_ps_instruction_er_evex:
37
	or	[vex_required],8
38
avx_single_source_ps_instruction_er:
39
	or	[operand_flags],2+4+8
40
	jmp	avx_ps_instruction
41
avx_single_source_ps_instruction_noevex:
42
	or	[operand_flags],2
43
	or	[vex_required],2
4478 dunkaist 44
	jmp	avx_ps_instruction
45
avx_ps_instruction_imm8:
46
	mov	[immediate_size],1
47
	jmp	avx_ps_instruction
6467 dunkaist 48
avx_ps_instruction_er:
49
	or	[operand_flags],8
50
avx_ps_instruction_sae:
51
	or	[operand_flags],4
52
avx_ps_instruction:
4478 dunkaist 53
	mov	cx,0400h
6467 dunkaist 54
	jmp	avx_instruction_with_broadcast
55
avx_ps_instruction_66_38_evex:
56
	or	[vex_required],8
57
	mov	[opcode_prefix],66h
58
	mov	[supplemental_code],al
59
	mov	al,38h
60
	jmp	avx_ps_instruction
61
avx_sd_instruction_er:
62
	or	[operand_flags],8
63
avx_sd_instruction_sae:
64
	or	[operand_flags],4
65
avx_sd_instruction:
4478 dunkaist 66
	mov	[opcode_prefix],0F2h
67
	or	[rex_prefix],80h
6467 dunkaist 68
	mov	cl,8
69
	jmp	avx_instruction
4478 dunkaist 70
avx_ss_instruction_er:
6467 dunkaist 71
	or	[operand_flags],8
72
avx_ss_instruction_sae:
73
	or	[operand_flags],4
74
avx_ss_instruction:
4478 dunkaist 75
	mov	[opcode_prefix],0F3h
76
	mov	cl,4
6467 dunkaist 77
	jmp	avx_instruction
4478 dunkaist 78
avx_ss_instruction_noevex:
6467 dunkaist 79
	or	[vex_required],2
80
	jmp	avx_ss_instruction
81
avx_single_source_q_instruction_38_evex:
82
	or	[operand_flags],2
83
avx_q_instruction_38_evex:
84
	or	[vex_required],8
85
avx_q_instruction_38:
86
	mov	[supplemental_code],al
87
	mov	al,38h
88
	jmp	avx_q_instruction
89
avx_q_instruction_38_w1_evex:
90
	or	[vex_required],8
91
avx_q_instruction_38_w1:
92
	or	[rex_prefix],8
93
	jmp	avx_q_instruction_38
94
avx_q_instruction_3a_imm8_evex:
95
	mov	[immediate_size],1
96
	or	[vex_required],8
97
	mov	[supplemental_code],al
98
	mov	al,3Ah
99
	jmp	avx_q_instruction
100
avx_q_instruction_evex:
101
	or	[vex_required],8
102
avx_q_instruction:
103
	or	[rex_prefix],80h
104
	mov	ch,8
105
	jmp	avx_pi_instruction
106
avx_single_source_d_instruction_38_evex:
107
	or	[vex_required],8
108
avx_single_source_d_instruction_38:
109
	or	[operand_flags],2
110
	jmp	avx_d_instruction_38
111
avx_d_instruction_38_evex:
112
	or	[vex_required],8
113
avx_d_instruction_38:
114
	mov	[supplemental_code],al
115
	mov	al,38h
116
	jmp	avx_d_instruction
117
avx_d_instruction_3a_imm8_evex:
118
	mov	[immediate_size],1
119
	or	[vex_required],8
120
	mov	[supplemental_code],al
121
	mov	al,3Ah
122
	jmp	avx_d_instruction
123
avx_single_source_d_instruction_imm8:
124
	or	[operand_flags],2
125
	mov	[immediate_size],1
126
	jmp	avx_d_instruction
127
avx_d_instruction_evex:
128
	or	[vex_required],8
129
avx_d_instruction:
130
	mov	ch,4
131
	jmp	avx_pi_instruction
132
avx_single_source_bw_instruction_38:
133
	or	[operand_flags],2
134
avx_bw_instruction_38:
135
	mov	[supplemental_code],al
136
	mov	al,38h
137
avx_bw_instruction:
138
	xor	ch,ch
139
      avx_pi_instruction:
140
	mov	[opcode_prefix],66h
4478 dunkaist 141
	xor	cl,cl
6467 dunkaist 142
	jmp	avx_instruction_with_broadcast
143
avx_bw_instruction_38_w1_evex:
144
	or	[rex_prefix],8
145
avx_bw_instruction_38_evex:
146
	or	[vex_required],8
147
	jmp	avx_bw_instruction_38
148
avx_pd_instruction_noevex:
149
	xor	cl,cl
150
	or	[vex_required],2
4478 dunkaist 151
	mov	[opcode_prefix],66h
6467 dunkaist 152
	jmp	avx_instruction
4478 dunkaist 153
avx_ps_instruction_noevex:
6467 dunkaist 154
	or	[vex_required],2
4478 dunkaist 155
	mov	[opcode_prefix],0F2h
156
	xor	cl,cl
6467 dunkaist 157
	jmp	avx_instruction
4478 dunkaist 158
avx_instruction:
159
	xor	ch,ch
6467 dunkaist 160
      avx_instruction_with_broadcast:
161
	mov	[mmx_size],cl
162
	mov	[broadcast_size],ch
163
	mov	[base_code],0Fh
4478 dunkaist 164
	mov	[extended_code],al
165
      avx_xop_common:
6467 dunkaist 166
	or	[vex_required],1
4478 dunkaist 167
	lods	byte [esi]
168
	call	get_size_operator
169
	cmp	al,10h
170
	jne	invalid_operand
171
      avx_reg:
172
	lods	byte [esi]
173
	call	convert_avx_register
174
	mov	[postbyte_register],al
175
	call	take_avx512_mask
6467 dunkaist 176
      avx_vex_reg:
4478 dunkaist 177
	test	[operand_flags],2
6467 dunkaist 178
	jnz	avx_vex_reg_ok
4478 dunkaist 179
	lods	byte [esi]
180
	cmp	al,','
181
	jne	invalid_operand
182
	call	take_avx_register
183
	mov	[vex_register],al
184
      avx_vex_reg_ok:
185
	mov	al,[mmx_size]
6467 dunkaist 186
	or	al,al
187
	jz	avx_regs_size_ok
188
	mov	ah,[operand_size]
189
	or	ah,ah
190
	jz	avx_regs_size_ok
191
	cmp	al,ah
192
	je	avx_regs_size_ok
4478 dunkaist 193
	ja	invalid_operand_size
6467 dunkaist 194
	cmp	ah,16
4478 dunkaist 195
	jne	invalid_operand_size
6467 dunkaist 196
      avx_regs_size_ok:
4478 dunkaist 197
	lods	byte [esi]
198
	cmp	al,','
199
	jne	invalid_operand
200
      avx_regs_rm:
6467 dunkaist 201
	call	take_avx_rm
4478 dunkaist 202
	jc	avx_regs_reg
203
	mov	al,[immediate_size]
6467 dunkaist 204
	cmp	al,1
205
	je	mmx_imm8
206
	jb	instruction_ready
207
	cmp	al,-4
208
	je	sse_cmp_mem_ok
4478 dunkaist 209
	cmp	byte [esi],','
210
	jne	invalid_operand
211
	inc	esi
212
	call	take_avx_register
213
	shl	al,4
214
	jc	invalid_operand
6467 dunkaist 215
	or	byte [value],al
4478 dunkaist 216
	test	al,80h
217
	jz	avx_regs_mem_reg_store
218
	cmp	[code_type],64
219
	jne	invalid_operand
220
      avx_regs_mem_reg_store:
221
	call	take_imm4_if_needed
222
	call	store_instruction_with_imm8
223
	jmp	instruction_assembled
224
      avx_regs_reg:
225
	mov	bl,al
226
	call	take_avx512_rounding
6467 dunkaist 227
	mov	al,[immediate_size]
228
	cmp	al,1
229
	je	mmx_nomem_imm8
230
	jb	nomem_instruction_ready
231
	cmp	al,-4
232
	je	sse_cmp_nomem_ok
4478 dunkaist 233
	lods	byte [esi]
234
	cmp	al,','
235
	jne	invalid_operand
236
	mov	al,bl
237
	shl	al,4
238
	jc	invalid_operand
6467 dunkaist 239
	or	byte [value],al
4478 dunkaist 240
	test	al,80h
241
	jz	avx_regs_reg_
242
	cmp	[code_type],64
243
	jne	invalid_operand
244
      avx_regs_reg_:
245
	call	take_avx_rm
246
	jc	avx_regs_reg_reg
247
	cmp	[immediate_size],-2
248
	jg	invalid_operand
249
	or	[rex_prefix],8
250
	call	take_imm4_if_needed
251
	call	store_instruction_with_imm8
252
	jmp	instruction_assembled
253
      avx_regs_reg_reg:
254
	shl	al,4
255
	jc	invalid_operand
6467 dunkaist 256
	and	byte [value],1111b
4478 dunkaist 257
	or	byte [value],al
258
	call	take_imm4_if_needed
259
	call	store_nomem_instruction
260
	mov	al,byte [value]
261
	stos	byte [edi]
262
	jmp	instruction_assembled
263
      take_avx_rm:
264
	xor	cl,cl
265
	xchg	cl,[operand_size]
266
	lods	byte [esi]
267
	call	get_size_operator
268
	cmp	al,'['
269
	je	take_avx_mem
270
	cmp	al,10h
271
	jne	invalid_operand
272
	mov	[operand_size],cl
6467 dunkaist 273
	lods	byte [esi]
4478 dunkaist 274
	call	convert_avx_register
275
	or	cl,cl
6467 dunkaist 276
	jnz	avx_reg_ok
277
	or	cl,[mmx_size]
278
	jz	avx_reg_ok
279
	cmp	ah,cl
280
	je	avx_reg_ok
4478 dunkaist 281
	jb	invalid_operand_size
6467 dunkaist 282
	cmp	ah,16
4478 dunkaist 283
	jne	invalid_operand_size
6467 dunkaist 284
      avx_reg_ok:
4478 dunkaist 285
	stc
286
	ret
287
      take_avx_mem:
288
	push	ecx
289
	call	get_address
290
	cmp	byte [esi],'{'
6467 dunkaist 291
	jne	avx_mem_ok
292
	inc	esi
293
	lods	byte [esi]
294
	cmp	al,1Fh
295
	jne	invalid_operand
296
	mov	al,[esi]
297
	shr	al,4
298
	cmp	al,1
299
	jne	invalid_operand
300
	mov	al,[mmx_size]
301
	or	al,al
302
	jnz	avx_mem_broadcast_check
303
	mov	eax,[esp]
304
	or	al,al
305
	jnz	avx_mem_broadcast_check
306
	mov	al,[broadcast_size]
307
	mov	[mmx_size],al
308
	mov	ah,cl
309
	lods	byte [esi]
310
	and	al,1111b
311
	mov	cl,al
312
	mov	al,[broadcast_size]
313
	shl	al,cl
314
	mov	[esp],al
315
	mov	cl,ah
316
	jmp	avx_mem_broadcast_ok
317
      avx_mem_broadcast_check:
318
	bsf	eax,eax
319
	xchg	al,[broadcast_size]
320
	mov	[mmx_size],al
321
	bsf	eax,eax
322
	jz	invalid_operand
323
	mov	ah,[broadcast_size]
324
	sub	ah,al
325
	lods	byte [esi]
326
	and	al,1111b
327
	cmp	al,ah
328
	jne	invalid_operand_size
329
      avx_mem_broadcast_ok:
330
	or	[vex_required],40h
331
	lods	byte [esi]
332
	cmp	al,'}'
333
	jne	invalid_operand
334
      avx_mem_ok:
335
	pop	eax
4478 dunkaist 336
	or	al,al
6467 dunkaist 337
	jz	avx_mem_size_deciding
338
	xchg	al,[operand_size]
339
	cmp	[mmx_size],0
4478 dunkaist 340
	jne	avx_mem_size_enforced
6467 dunkaist 341
	or	al,al
4478 dunkaist 342
	jz	avx_mem_size_ok
6467 dunkaist 343
	cmp	al,[operand_size]
4478 dunkaist 344
	jne	operand_sizes_do_not_match
345
      avx_mem_size_ok:
6467 dunkaist 346
	clc
4478 dunkaist 347
	ret
348
      avx_mem_size_deciding:
6467 dunkaist 349
	mov	al,[operand_size]
350
	cmp	[mmx_size],0
351
	jne	avx_mem_size_enforced
352
	cmp	al,16
353
	je	avx_mem_size_ok
354
	cmp	al,32
355
	je	avx_mem_size_ok
356
	cmp	al,64
357
	je	avx_mem_size_ok
358
	or	al,al
4478 dunkaist 359
	jnz	invalid_operand_size
6467 dunkaist 360
	call	recoverable_unknown_size
361
      avx_mem_size_enforced:
362
	or	al,al
363
	jz	avx_mem_size_ok
364
	cmp	al,[mmx_size]
4478 dunkaist 365
	je	avx_mem_size_ok
6467 dunkaist 366
	jmp	invalid_operand_size
367
      take_imm4_if_needed:
4478 dunkaist 368
	cmp	[immediate_size],-3
369
	jne	imm4_ok
370
	push	ebx ecx edx
371
	lods	byte [esi]
372
	cmp	al,','
373
	jne	invalid_operand
374
	lods	byte [esi]
375
	cmp	al,'('
376
	jne	invalid_operand
377
	call	get_byte_value
378
	test	al,11110000b
379
	jnz	value_out_of_range
380
	or	byte [value],al
381
	pop	edx ecx ebx
382
      imm4_ok:
383
	ret
384
      take_avx512_mask:
6467 dunkaist 385
	cmp	byte [esi],'{'
386
	jne	avx512_masking_ok
387
	test	[operand_flags],10h
388
	jnz	invalid_operand
389
	inc	esi
390
	lods	byte [esi]
391
	cmp	al,14h
392
	jne	invalid_operand
393
	lods	byte [esi]
394
	mov	ah,al
395
	shr	ah,4
396
	cmp	ah,5
397
	jne	invalid_operand
398
	or	al,al
399
	jz	invalid_operand
400
	and	al,111b
401
	mov	[mask_register],al
402
	or	[vex_required],20h
403
	lods	byte [esi]
404
	cmp	al,'}'
405
	jne	invalid_operand
406
	cmp	byte [esi],'{'
407
	jne	avx512_masking_ok
408
	test	[operand_flags],20h
409
	jnz	invalid_operand
410
	inc	esi
411
	lods	byte [esi]
412
	cmp	al,1Fh
413
	jne	invalid_operand
414
	lods	byte [esi]
415
	or	al,al
416
	jnz	invalid_operand
417
	or	[mask_register],80h
418
	lods	byte [esi]
419
	cmp	al,'}'
420
	jne	invalid_operand
421
      avx512_masking_ok:
422
	retn
423
      take_avx512_rounding:
424
	test	[operand_flags],4+8
425
	jz	avx512_rounding_done
426
	cmp	[mmx_size],0
427
	jne	avx512_rounding_allowed
428
	cmp	[operand_size],64
429
	jne	avx512_rounding_done
430
      avx512_rounding_allowed:
431
	cmp	byte [esi],','
432
	jne	avx512_rounding_done
433
	cmp	byte [esi+1],'{'
434
	jne	avx512_rounding_done
435
	add	esi,2
436
	mov	[rounding_mode],0
437
	or	[vex_required],40h+80h
438
	test	[operand_flags],8
439
	jz	take_sae
440
	lods	byte [esi]
441
	cmp	al,1Fh
442
	jne	invalid_operand
443
	lods	byte [esi]
444
	mov	ah,al
445
	shr	ah,4
446
	cmp	ah,2
447
	jne	invalid_operand
448
	and	al,11b
449
	mov	[rounding_mode],al
450
	lods	byte [esi]
451
	cmp	al,'-'
452
	jne	invalid_operand
453
      take_sae:
454
	lods	byte [esi]
455
	cmp	al,1Fh
456
	jne	invalid_operand
457
	lods	byte [esi]
458
	cmp	al,30h
459
	jne	invalid_operand
460
	lods	byte [esi]
461
	cmp	al,'}'
462
	jne	invalid_operand
463
      avx512_rounding_done:
464
	retn
465
4478 dunkaist 466
 
6467 dunkaist 467
	mov	ah,0F3h
468
	jmp	avx_movdq_instruction
469
avx_movdqa_instruction:
470
	mov	ah,66h
471
      avx_movdq_instruction:
472
	mov	[opcode_prefix],ah
473
	or	[vex_required],2
4478 dunkaist 474
	jmp	avx_movps_instruction
6467 dunkaist 475
avx512_movdqu16_instruction:
476
	or	[rex_prefix],8
4478 dunkaist 477
avx512_movdqu8_instruction:
6467 dunkaist 478
	mov	ah,0F2h
479
	jmp	avx_movdq_instruction_evex
480
avx512_movdqu64_instruction:
481
	or	[rex_prefix],8
4478 dunkaist 482
avx512_movdqu32_instruction:
6467 dunkaist 483
	mov	ah,0F3h
484
	jmp	avx_movdq_instruction_evex
485
avx512_movdqa64_instruction:
486
	or	[rex_prefix],8
487
avx512_movdqa32_instruction:
488
	mov	ah,66h
489
      avx_movdq_instruction_evex:
490
	mov	[opcode_prefix],ah
491
	or	[vex_required],8
492
	jmp	avx_movps_instruction
4478 dunkaist 493
avx_movpd_instruction:
494
	mov	[opcode_prefix],66h
495
	or	[rex_prefix],80h
6467 dunkaist 496
avx_movps_instruction:
4478 dunkaist 497
	or	[operand_flags],2
6467 dunkaist 498
	mov	[base_code],0Fh
4478 dunkaist 499
	mov	[extended_code],al
500
	or	[vex_required],1
6467 dunkaist 501
	xor	al,al
502
	mov	[mmx_size],al
503
	mov	[broadcast_size],al
504
	lods	byte [esi]
4478 dunkaist 505
	call	get_size_operator
506
	cmp	al,10h
507
	je	avx_reg
508
	inc	[extended_code]
509
	test	[extended_code],1
510
	jnz	avx_mem
511
	add	[extended_code],-1+10h
512
      avx_mem:
513
	cmp	al,'['
514
	jne	invalid_operand
515
	call	get_address
516
	or	[operand_flags],20h
6467 dunkaist 517
	call	take_avx512_mask
518
	lods	byte [esi]
4478 dunkaist 519
	cmp	al,','
520
	jne	invalid_operand
521
	call	take_avx_register
522
	mov	[postbyte_register],al
523
	jmp	instruction_ready
524
avx_movntpd_instruction:
525
	or	[rex_prefix],80h
6467 dunkaist 526
avx_movntdq_instruction:
527
	mov	[opcode_prefix],66h
4478 dunkaist 528
avx_movntps_instruction:
529
	mov	[base_code],0Fh
530
	mov	[extended_code],al
531
	or	[vex_required],1
6467 dunkaist 532
	or	[operand_flags],10h
533
	mov	[mmx_size],0
534
	lods	byte [esi]
4478 dunkaist 535
	call	get_size_operator
536
	jmp	avx_mem
537
avx_compress_q_instruction:
6467 dunkaist 538
	or	[rex_prefix],8
539
avx_compress_d_instruction:
540
	or	[vex_required],8
541
	mov	[mmx_size],0
542
	call	setup_66_0f_38
543
	lods	byte [esi]
544
	call	get_size_operator
545
	cmp	al,10h
546
	jne	avx_mem
547
	lods	byte [esi]
548
	call	convert_avx_register
549
	mov	bl,al
550
	call	take_avx512_mask
551
	lods	byte [esi]
552
	cmp	al,','
553
	jne	invalid_operand
554
	call	take_avx_register
555
	mov	[postbyte_register],al
556
	jmp	nomem_instruction_ready
557
avx_lddqu_instruction:
4478 dunkaist 558
	mov	ah,0F2h
6467 dunkaist 559
	or	[vex_required],2
560
      avx_load_instruction:
4478 dunkaist 561
	mov	[opcode_prefix],ah
6467 dunkaist 562
	mov	[base_code],0Fh
4478 dunkaist 563
	mov	[extended_code],al
564
	mov	[mmx_size],0
6467 dunkaist 565
	or	[vex_required],1
4478 dunkaist 566
	call	take_avx_register
567
	mov	[postbyte_register],al
6467 dunkaist 568
	lods	byte [esi]
4478 dunkaist 569
	cmp	al,','
570
	jne	invalid_operand
571
	lods	byte [esi]
572
	call	get_size_operator
573
	cmp	al,'['
6467 dunkaist 574
	jne	invalid_operand
575
	call	get_address
576
	jmp	instruction_ready
577
avx_movntdqa_instruction:
578
	mov	[supplemental_code],al
579
	mov	al,38h
580
	mov	ah,66h
581
	jmp	avx_load_instruction
582
avx_movq_instruction:
583
	or	[rex_prefix],8
584
	mov	[mmx_size],8
585
	jmp	avx_mov_instruction
586
avx_movd_instruction:
587
	mov	[mmx_size],4
588
      avx_mov_instruction:
589
	or	[vex_required],1
590
	mov	[opcode_prefix],66h
591
	mov	[base_code],0Fh
592
	mov	[extended_code],7Eh
593
	lods	byte [esi]
594
	call	get_size_operator
595
	cmp	al,10h
4478 dunkaist 596
	je	avx_movd_reg
6467 dunkaist 597
	cmp	al,'['
4478 dunkaist 598
	jne	invalid_operand
599
	call	get_address
600
	mov	al,[mmx_size]
601
	not	al
6467 dunkaist 602
	and	[operand_size],al
603
	jnz	invalid_operand_size
604
	lods	byte [esi]
605
	cmp	al,','
606
	jne	invalid_operand
607
	lods	byte [esi]
608
	call	get_size_operator
609
	cmp	al,10h
610
	jne	invalid_operand
611
	lods	byte [esi]
612
	call	convert_avx_register
613
	cmp	ah,16
614
	jne	invalid_operand_size
4478 dunkaist 615
	mov	[postbyte_register],al
6467 dunkaist 616
	cmp	[mmx_size],8
617
	jne	instruction_ready
618
	and	[rex_prefix],not 8
619
	or	[rex_prefix],80h
620
	mov	[extended_code],0D6h
621
	jmp	instruction_ready
4478 dunkaist 622
      avx_movd_reg:
6467 dunkaist 623
	lods	byte [esi]
4478 dunkaist 624
	cmp	al,0C0h
6467 dunkaist 625
	jae	avx_movd_xmmreg
626
	call	convert_register
627
	cmp	ah,[mmx_size]
628
	jne	invalid_operand_size
629
	mov	[operand_size],0
630
	mov	bl,al
631
	lods	byte [esi]
632
	cmp	al,','
633
	jne	invalid_operand
634
	lods	byte [esi]
635
	call	get_size_operator
636
	cmp	al,10h
637
	jne	invalid_operand
638
	lods	byte [esi]
639
	call	convert_avx_register
4478 dunkaist 640
	cmp	ah,16
6467 dunkaist 641
	jne	invalid_operand_size
642
	mov	[postbyte_register],al
643
	jmp	nomem_instruction_ready
644
      avx_movd_xmmreg:
645
	sub	[extended_code],10h
646
	call	convert_avx_register
647
	cmp	ah,16
648
	jne	invalid_operand_size
649
	mov	[postbyte_register],al
650
	mov	[operand_size],0
651
	lods	byte [esi]
652
	cmp	al,','
653
	jne	invalid_operand
4478 dunkaist 654
	lods	byte [esi]
6467 dunkaist 655
	call	get_size_operator
656
	cmp	al,10h
657
	je	avx_movd_xmmreg_reg
658
	cmp	al,'['
659
	jne	invalid_operand
660
	call	get_address
661
	mov	al,[mmx_size]
662
	cmp	al,8
663
	jne	avx_movd_xmmreg_mem_ready
664
	call	avx_movq_xmmreg_xmmreg_opcode
665
      avx_movd_xmmreg_mem_ready:
666
	not	al
667
	test	[operand_size],al
668
	jnz	invalid_operand_size
669
	jmp	instruction_ready
670
      avx_movd_xmmreg_reg:
671
	lods	byte [esi]
672
	cmp	al,0C0h
673
	jae	avx_movq_xmmreg_xmmreg
674
	call	convert_register
675
	cmp	ah,[mmx_size]
676
	jne	invalid_operand_size
677
	mov	bl,al
4478 dunkaist 678
	jmp	nomem_instruction_ready
6467 dunkaist 679
      avx_movq_xmmreg_xmmreg:
680
	cmp	[mmx_size],8
681
	jne	invalid_operand
682
	call	avx_movq_xmmreg_xmmreg_opcode
683
	call	convert_avx_register
684
	cmp	ah,16
685
	jne	invalid_operand_size
686
	mov	bl,al
687
	jmp	nomem_instruction_ready
688
      avx_movq_xmmreg_xmmreg_opcode:
689
	and	[rex_prefix],not 8
690
	or	[rex_prefix],80h
691
	add	[extended_code],10h
692
	mov	[opcode_prefix],0F3h
693
	ret
694
avx_movddup_instruction:
695
	or	[vex_required],1
696
	mov	[opcode_prefix],0F2h
697
	mov	[base_code],0Fh
698
	mov	[extended_code],al
699
	or	[rex_prefix],80h
700
	xor	al,al
701
	mov	[mmx_size],al
702
	mov	[broadcast_size],al
703
	lods	byte [esi]
704
	call	get_size_operator
705
	cmp	al,10h
706
	jne	invalid_operand
707
	lods	byte [esi]
708
	call	convert_avx_register
709
	mov	[postbyte_register],al
4478 dunkaist 710
	cmp	ah,16
6467 dunkaist 711
	ja	avx_movddup_size_ok
712
	mov	[mmx_size],8
4478 dunkaist 713
      avx_movddup_size_ok:
6467 dunkaist 714
	call	take_avx512_mask
715
	jmp	avx_vex_reg_ok
716
avx_movlpd_instruction:
4478 dunkaist 717
	mov	[opcode_prefix],66h
718
	or	[rex_prefix],80h
6467 dunkaist 719
avx_movlps_instruction:
4478 dunkaist 720
	mov	[base_code],0Fh
721
	mov	[extended_code],al
722
	mov	[mmx_size],8
723
	mov	[broadcast_size],0
6467 dunkaist 724
	or	[vex_required],1
4478 dunkaist 725
	lods	byte [esi]
726
	call	get_size_operator
727
	cmp	al,10h
728
	jne	avx_movlps_mem
729
	lods	byte [esi]
730
	call	convert_avx_register
731
	mov	[postbyte_register],al
732
	lods	byte [esi]
733
	cmp	al,','
734
	jne	invalid_operand
735
	call	take_avx_register
736
	mov	[vex_register],al
737
	cmp	[operand_size],16
738
	jne	invalid_operand
739
	mov	[operand_size],0
740
	lods	byte [esi]
741
	cmp	al,','
742
	jne	invalid_operand
743
	call	take_avx_rm
744
	jc	invalid_operand
745
	jmp	instruction_ready
746
      avx_movlps_mem:
747
	cmp	al,'['
748
	jne	invalid_operand
749
	call	get_address
750
      avx_movlps_mem_:
6467 dunkaist 751
	mov	al,[operand_size]
4478 dunkaist 752
	or	al,al
753
	jz	avx_movlps_mem_size_ok
754
	cmp	al,[mmx_size]
755
	jne	invalid_operand_size
756
	mov	[operand_size],0
757
      avx_movlps_mem_size_ok:
758
	lods	byte [esi]
759
	cmp	al,','
760
	jne	invalid_operand
761
	call	take_avx_register
762
	cmp	ah,16
763
	jne	invalid_operand
764
	mov	[postbyte_register],al
765
	inc	[extended_code]
766
	jmp	instruction_ready
767
avx_movhlps_instruction:
768
	mov	[base_code],0Fh
769
	mov	[extended_code],al
770
	or	[vex_required],1
771
	call	take_avx_register
772
	cmp	ah,16
773
	jne	invalid_operand
774
	mov	[postbyte_register],al
775
	lods	byte [esi]
776
	cmp	al,','
777
	jne	invalid_operand
778
	call	take_avx_register
779
	mov	[vex_register],al
780
	lods	byte [esi]
781
	cmp	al,','
782
	jne	invalid_operand
783
	call	take_avx_register
784
	mov	bl,al
785
	jmp	nomem_instruction_ready
786
avx_movsd_instruction:
6467 dunkaist 787
	mov	al,0F2h
788
	mov	cl,8
789
	or	[rex_prefix],80h
790
	jmp	avx_movs_instruction
791
avx_movss_instruction:
792
	mov	al,0F3h
793
	mov	cl,4
794
      avx_movs_instruction:
795
	mov	[opcode_prefix],al
796
	mov	[mmx_size],cl
797
	or	[vex_required],1
4478 dunkaist 798
	mov	[base_code],0Fh
6467 dunkaist 799
	mov	[extended_code],10h
800
	lods	byte [esi]
4478 dunkaist 801
	call	get_size_operator
802
	cmp	al,10h
803
	jne	avx_movs_mem
6467 dunkaist 804
	lods	byte [esi]
4478 dunkaist 805
	call	convert_avx_register
806
	cmp	ah,16
6467 dunkaist 807
	jne	invalid_operand
808
	mov	[postbyte_register],al
4478 dunkaist 809
	call	take_avx512_mask
6467 dunkaist 810
	xor	cl,cl
811
	xchg	cl,[operand_size]
812
	lods	byte [esi]
4478 dunkaist 813
	cmp	al,','
814
	jne	invalid_operand
815
	lods	byte [esi]
6467 dunkaist 816
	call	get_size_operator
817
	cmp	al,10h
818
	jne	avx_movs_reg_mem
819
	mov	[operand_size],cl
820
	lods	byte [esi]
821
	call	convert_avx_register
822
	mov	[vex_register],al
4478 dunkaist 823
	lods	byte [esi]
824
	cmp	al,','
825
	jne	invalid_operand
826
	call	take_avx_register
6467 dunkaist 827
	mov	bl,al
828
	cmp	bl,8
829
	jb	nomem_instruction_ready
830
	inc	[extended_code]
831
	xchg	bl,[postbyte_register]
832
	jmp	nomem_instruction_ready
833
      avx_movs_reg_mem:
834
	cmp	al,'['
835
	jne	invalid_operand
836
	call	get_address
837
	mov	al,[operand_size]
838
	or	al,al
839
	jz	avx_movs_reg_mem_ok
840
	cmp	al,[mmx_size]
841
	jne	invalid_operand_size
842
      avx_movs_reg_mem_ok:
843
	jmp	instruction_ready
4478 dunkaist 844
      avx_movs_mem:
6467 dunkaist 845
	cmp	al,'['
4478 dunkaist 846
	jne	invalid_operand
847
	call	get_address
848
	or	[operand_flags],20h
6467 dunkaist 849
	call	take_avx512_mask
850
	jmp	avx_movlps_mem_
851
852
 
853
	or	[operand_flags],2+4+10h
854
	mov	cl,4
855
	jmp	avx_instruction
856
avx_comisd_instruction:
857
	or	[operand_flags],2+4+10h
858
	mov	[opcode_prefix],66h
859
	or	[rex_prefix],80h
860
	mov	cl,8
861
	jmp	avx_instruction
862
avx_movshdup_instruction:
863
	or	[operand_flags],2
864
	mov	[opcode_prefix],0F3h
865
	xor	cl,cl
866
	jmp	avx_instruction
867
avx_cvtqq2pd_instruction:
868
	mov	[opcode_prefix],0F3h
869
	or	[vex_required],8
870
	or	[operand_flags],2+4+8
871
	or	[rex_prefix],8
872
	mov	cx,0800h
873
	jmp	avx_instruction_with_broadcast
874
avx_pshuf_w_instruction:
875
	mov	[opcode_prefix],al
876
	or	[operand_flags],2
877
	mov	[immediate_size],1
878
	mov	al,70h
879
	xor	cl,cl
880
	jmp	avx_instruction
881
avx_single_source_128bit_instruction_38_noevex:
882
	or	[operand_flags],2
883
avx_128bit_instruction_38_noevex:
884
	mov	cl,16
885
	jmp	avx_instruction_38_noevex
886
avx_single_source_instruction_38_noevex:
887
	or	[operand_flags],2
888
	jmp	avx_pi_instruction_38_noevex
889
avx_pi_instruction_38_noevex:
890
	xor	cl,cl
891
      avx_instruction_38_noevex:
892
	or	[vex_required],2
893
      avx_instruction_38:
894
	mov	[opcode_prefix],66h
895
	mov	[supplemental_code],al
4478 dunkaist 896
	mov	al,38h
6467 dunkaist 897
	jmp	avx_instruction
898
avx_ss_instruction_3a_imm8_noevex:
899
	mov	cl,4
900
	jmp	avx_instruction_3a_imm8_noevex
901
avx_sd_instruction_3a_imm8_noevex:
902
	mov	cl,8
903
	jmp	avx_instruction_3a_imm8_noevex
904
avx_single_source_128bit_instruction_3a_imm8_noevex:
905
	or	[operand_flags],2
906
avx_128bit_instruction_3a_imm8_noevex:
907
	mov	cl,16
908
	jmp	avx_instruction_3a_imm8_noevex
909
avx_triple_source_instruction_3a_noevex:
910
	xor	cl,cl
911
	mov	[immediate_size],-1
912
	mov	byte [value],0
913
	jmp	avx_instruction_3a_noevex
914
avx_single_source_instruction_3a_imm8_noevex:
915
	or	[operand_flags],2
916
avx_pi_instruction_3a_imm8_noevex:
917
	xor	cl,cl
918
      avx_instruction_3a_imm8_noevex:
919
	mov	[immediate_size],1
920
      avx_instruction_3a_noevex:
921
	or	[vex_required],2
922
      avx_instruction_3a:
923
	mov	[opcode_prefix],66h
4478 dunkaist 924
	mov	[supplemental_code],al
6467 dunkaist 925
	mov	al,3Ah
926
	jmp	avx_instruction
927
avx_pi_instruction_3a_imm8:
928
	xor	cl,cl
929
	mov	[immediate_size],1
930
	jmp	avx_instruction_3a
931
avx_pclmulqdq_instruction:
932
	mov	byte [value],al
933
	mov	[immediate_size],-4
934
	or	[vex_required],2
935
	mov	cl,16
936
	mov	al,44h
937
	jmp	avx_instruction_3a
938
939
 
940
	or	[operand_flags],2
941
avx512_pd_instruction_sae_imm8:
942
	or	[rex_prefix],8
943
	mov	cx,0800h
944
	jmp	avx512_instruction_sae_imm8
945
avx512_single_source_ps_instruction_sae_imm8:
946
	or	[operand_flags],2
947
avx512_ps_instruction_sae_imm8:
948
	mov	cx,0400h
949
	jmp	avx512_instruction_sae_imm8
950
avx512_sd_instruction_sae_imm8:
951
	or	[rex_prefix],8
952
	mov	cx,0008h
953
	jmp	avx512_instruction_sae_imm8
954
avx512_ss_instruction_sae_imm8:
955
	mov	cx,0004h
956
      avx512_instruction_sae_imm8:
957
	or	[operand_flags],4
958
      avx512_instruction_imm8:
959
	or	[vex_required],8
960
	mov	[opcode_prefix],66h
961
	mov	[immediate_size],1
962
	mov	[supplemental_code],al
963
	mov	al,3Ah
964
	jmp	avx_instruction_with_broadcast
965
avx512_pd_instruction_er:
966
	or	[operand_flags],4+8
967
	jmp	avx512_pd_instruction
968
avx512_single_source_pd_instruction_sae:
969
	or	[operand_flags],4
970
avx512_single_source_pd_instruction:
971
	or	[operand_flags],2
972
avx512_pd_instruction:
973
	or	[rex_prefix],8
974
	mov	cx,0800h
975
	jmp	avx512_instruction
976
avx512_ps_instruction_er:
977
	or	[operand_flags],4+8
978
	jmp	avx512_ps_instruction
979
avx512_single_source_ps_instruction_sae:
980
	or	[operand_flags],4
981
avx512_single_source_ps_instruction:
982
	or	[operand_flags],2
983
avx512_ps_instruction:
984
	mov	cx,0400h
985
	jmp	avx512_instruction
986
avx512_sd_instruction_er:
987
	or	[operand_flags],8
988
avx512_sd_instruction_sae:
989
	or	[operand_flags],4
990
avx512_sd_instruction:
991
	or	[rex_prefix],8
992
	mov	cx,0008h
993
	jmp	avx512_instruction
994
avx512_ss_instruction_er:
995
	or	[operand_flags],8
996
avx512_ss_instruction_sae:
997
	or	[operand_flags],4
998
avx512_ss_instruction:
999
	mov	cx,0004h
1000
      avx512_instruction:
1001
	or	[vex_required],8
1002
	mov	[opcode_prefix],66h
1003
	mov	[supplemental_code],al
1004
	mov	al,38h
1005
	jmp	avx_instruction_with_broadcast
1006
avx512_exp2pd_instruction:
1007
	or	[rex_prefix],8
1008
	or	[operand_flags],2+4
1009
	mov	cx,0840h
1010
	jmp	avx512_instruction
1011
avx512_exp2ps_instruction:
1012
	or	[operand_flags],2+4
1013
	mov	cx,0440h
1014
	jmp	avx512_instruction
1015
1016
 
1017
	or	[rex_prefix],8
1018
	mov	cx,0800h
1019
	jmp	fma_instruction
1020
fma_instruction_ps:
1021
	mov	cx,0400h
1022
	jmp	fma_instruction
1023
fma_instruction_sd:
1024
	or	[rex_prefix],8
1025
	mov	cx,0008h
1026
	jmp	fma_instruction
1027
fma_instruction_ss:
1028
	mov	cx,0004h
1029
      fma_instruction:
1030
	or	[operand_flags],4+8
1031
	mov	[opcode_prefix],66h
1032
	mov	[supplemental_code],al
1033
	mov	al,38h
1034
	jmp	avx_instruction_with_broadcast
1035
1036
 
1037
	xor	cl,cl
1038
	jmp	fma4_instruction
1039
fma4_instruction_sd:
1040
	mov	cl,8
1041
	jmp	fma4_instruction
1042
fma4_instruction_ss:
1043
	mov	cl,4
1044
      fma4_instruction:
1045
	mov	[immediate_size],-2
1046
	mov	byte [value],0
1047
	jmp	avx_instruction_3a_noevex
1048
1049
 
1050
	mov	[opcode_prefix],66h
1051
	or	[rex_prefix],80h
1052
	mov	cx,0800h
1053
	jmp	avx_cmp_instruction
1054
avx_cmp_ps_instruction:
1055
	mov	cx,0400h
1056
	jmp	avx_cmp_instruction
1057
avx_cmp_sd_instruction:
1058
	mov	[opcode_prefix],0F2h
4478 dunkaist 1059
	or	[rex_prefix],80h
6467 dunkaist 1060
	mov	cx,0008h
1061
	jmp	avx_cmp_instruction
1062
avx_cmp_ss_instruction:
1063
	mov	[opcode_prefix],0F3h
1064
	mov	cx,0004h
1065
      avx_cmp_instruction:
1066
	mov	byte [value],al
1067
	mov	[immediate_size],-4
1068
	or	[operand_flags],4+20h
1069
	mov	al,0C2h
1070
	jmp	avx_cmp_common
1071
avx_cmpeqq_instruction:
1072
	or	[rex_prefix],80h
1073
	mov	ch,8
1074
	mov	[supplemental_code],al
1075
	mov	al,38h
1076
	jmp	avx_cmp_pi_instruction
1077
avx_cmpeqd_instruction:
1078
	mov	ch,4
1079
	jmp	avx_cmp_pi_instruction
1080
avx_cmpeqb_instruction:
1081
	xor	ch,ch
1082
	jmp	avx_cmp_pi_instruction
1083
avx512_cmp_uq_instruction:
1084
	or	[rex_prefix],8
1085
	mov	ch,8
1086
	mov	ah,1Eh
1087
	jmp	avx_cmp_pi_instruction_evex
1088
avx512_cmp_ud_instruction:
1089
	mov	ch,4
1090
	mov	ah,1Eh
1091
	jmp	avx_cmp_pi_instruction_evex
1092
avx512_cmp_q_instruction:
1093
	or	[rex_prefix],8
1094
	mov	ch,8
1095
	mov	ah,1Fh
1096
	jmp	avx_cmp_pi_instruction_evex
1097
avx512_cmp_d_instruction:
1098
	mov	ch,4
1099
	mov	ah,1Fh
1100
	jmp	avx_cmp_pi_instruction_evex
1101
avx512_cmp_uw_instruction:
1102
	or	[rex_prefix],8
1103
avx512_cmp_ub_instruction:
1104
	xor	ch,ch
1105
	mov	ah,3Eh
1106
	jmp	avx_cmp_pi_instruction_evex
1107
avx512_cmp_w_instruction:
1108
	or	[rex_prefix],8
1109
avx512_cmp_b_instruction:
1110
	xor	ch,ch
1111
	mov	ah,3Fh
1112
      avx_cmp_pi_instruction_evex:
1113
	mov	byte [value],al
1114
	mov	[immediate_size],-4
1115
	mov	[supplemental_code],ah
1116
	mov	al,3Ah
1117
	or	[vex_required],8
1118
      avx_cmp_pi_instruction:
1119
	xor	cl,cl
1120
	or	[operand_flags],20h
1121
	mov	[opcode_prefix],66h
1122
      avx_cmp_common:
1123
	mov	[mmx_size],cl
1124
	mov	[broadcast_size],ch
1125
	mov	[extended_code],al
1126
	mov	[base_code],0Fh
4478 dunkaist 1127
	lods	byte [esi]
1128
	call	get_size_operator
1129
	cmp	al,14h
6467 dunkaist 1130
	je	avx_maskreg
1131
	cmp	al,10h
4478 dunkaist 1132
	jne	invalid_operand
1133
	or	[vex_required],2
6467 dunkaist 1134
	jmp	avx_reg
1135
      avx_maskreg:
1136
	cmp	[operand_size],0
1137
	jne	invalid_operand_size
1138
	or	[vex_required],8
1139
	lods	byte [esi]
4478 dunkaist 1140
	call	convert_mask_register
6467 dunkaist 1141
	mov	[postbyte_register],al
4478 dunkaist 1142
	call	take_avx512_mask
6467 dunkaist 1143
	jmp	avx_vex_reg
1144
avx512_fpclasspd_instruction:
1145
	or	[rex_prefix],8
1146
	mov	cx,0800h
1147
	jmp	avx_fpclass_instruction
1148
avx512_fpclassps_instruction:
1149
	mov	cx,0400h
1150
	jmp	avx_fpclass_instruction
1151
avx512_fpclasssd_instruction:
1152
	or	[rex_prefix],8
1153
	mov	cx,0008h
1154
	jmp	avx_fpclass_instruction
1155
avx512_fpclassss_instruction:
1156
	mov	cx,0004h
1157
      avx_fpclass_instruction:
1158
	mov	[broadcast_size],ch
1159
	mov	[mmx_size],cl
1160
	or	[operand_flags],2
1161
	call	setup_66_0f_3a
1162
	mov	[immediate_size],1
1163
	lods	byte [esi]
1164
	cmp	al,14h
1165
	je	avx_maskreg
1166
	jmp	invalid_operand
1167
avx512_ptestnmd_instruction:
1168
	mov	ch,4
1169
	jmp	avx512_ptestnm_instruction
1170
avx512_ptestnmq_instruction:
1171
	or	[rex_prefix],8
1172
	mov	ch,8
1173
	jmp	avx512_ptestnm_instruction
1174
avx512_ptestnmw_instruction:
1175
	or	[rex_prefix],8
1176
avx512_ptestnmb_instruction:
1177
	xor	ch,ch
1178
      avx512_ptestnm_instruction:
1179
	mov	ah,0F3h
1180
	jmp	avx512_ptest_instruction
1181
avx512_ptestmd_instruction:
1182
	mov	ch,4
1183
	jmp	avx512_ptestm_instruction
1184
avx512_ptestmq_instruction:
1185
	or	[rex_prefix],8
1186
	mov	ch,8
1187
	jmp	avx512_ptestm_instruction
1188
avx512_ptestmw_instruction:
1189
	or	[rex_prefix],8
1190
avx512_ptestmb_instruction:
1191
	xor	ch,ch
1192
      avx512_ptestm_instruction:
1193
	mov	ah,66h
1194
      avx512_ptest_instruction:
1195
	xor	cl,cl
1196
	mov	[opcode_prefix],ah
1197
	mov	[supplemental_code],al
1198
	mov	al,38h
1199
	or	[vex_required],8
1200
	jmp	avx_cmp_common
1201
1202
 
1203
	or	[rex_prefix],8
1204
mask_shift_instruction_d:
1205
	or	[operand_flags],2
1206
	or	[immediate_size],1
1207
	mov	[opcode_prefix],66h
4478 dunkaist 1208
	mov	[supplemental_code],al
6467 dunkaist 1209
	mov	al,3Ah
1210
	jmp	mask_instruction
1211
mask_instruction_single_source_b:
1212
	mov	[opcode_prefix],66h
1213
	jmp	mask_instruction_single_source_w
1214
mask_instruction_single_source_d:
1215
	mov	[opcode_prefix],66h
1216
mask_instruction_single_source_q:
1217
	or	[rex_prefix],8
1218
mask_instruction_single_source_w:
1219
	or	[operand_flags],2
1220
	jmp	mask_instruction
1221
mask_instruction_b:
1222
	mov	[opcode_prefix],66h
1223
	jmp	mask_instruction_w
1224
mask_instruction_d:
1225
	mov	[opcode_prefix],66h
1226
mask_instruction_q:
1227
	or	[rex_prefix],8
1228
mask_instruction_w:
1229
	mov	[operand_size],32
1230
mask_instruction:
1231
	or	[vex_required],1
1232
	mov	[base_code],0Fh
4478 dunkaist 1233
	mov	[extended_code],al
6467 dunkaist 1234
	call	take_mask_register
1235
	mov	[postbyte_register],al
1236
	test	[operand_flags],2
1237
	jnz	mask_instruction_nds_ok
1238
	lods	byte [esi]
4478 dunkaist 1239
	cmp	al,','
6467 dunkaist 1240
	jne	invalid_operand
4478 dunkaist 1241
	call	take_mask_register
6467 dunkaist 1242
	mov	[vex_register],al
1243
      mask_instruction_nds_ok:
1244
	lods	byte [esi]
4478 dunkaist 1245
	cmp	al,','
1246
	jne	invalid_operand
1247
	call	take_mask_register
6467 dunkaist 1248
	mov	bl,al
4478 dunkaist 1249
	cmp	[immediate_size],0
6467 dunkaist 1250
	jne	mmx_nomem_imm8
1251
	jmp	nomem_instruction_ready
4478 dunkaist 1252
take_mask_register:
6467 dunkaist 1253
	lods	byte [esi]
1254
	cmp	al,14h
1255
	jne	invalid_operand
1256
	lods	byte [esi]
1257
convert_mask_register:
1258
	mov	ah,al
1259
	shr	ah,4
1260
	cmp	ah,5
1261
	jne	invalid_operand
1262
	and	al,1111b
1263
	ret
1264
kmov_instruction:
1265
	mov	[mmx_size],al
1266
	or	[vex_required],1
4478 dunkaist 1267
	mov	[base_code],0Fh
1268
	mov	[extended_code],90h
6467 dunkaist 1269
	lods	byte [esi]
4478 dunkaist 1270
	cmp	al,14h
6467 dunkaist 1271
	je	kmov_maskreg
1272
	cmp	al,10h
1273
	je	kmov_reg
1274
	call	get_size_operator
4478 dunkaist 1275
	inc	[extended_code]
6467 dunkaist 1276
	cmp	al,'['
1277
	jne	invalid_argument
1278
	call	get_address
1279
	lods	byte [esi]
4478 dunkaist 1280
	cmp	al,','
6467 dunkaist 1281
	jne	invalid_operand
1282
	call	take_mask_register
1283
	mov	[postbyte_register],al
4478 dunkaist 1284
      kmov_with_mem:
6467 dunkaist 1285
	mov	ah,[mmx_size]
1286
	mov	al,[operand_size]
1287
	or	al,al
1288
	jz	kmov_mem_size_ok
1289
	cmp	al,ah
1290
	jne	invalid_operand_size
1291
      kmov_mem_size_ok:
1292
	call	setup_kmov_prefix
1293
	jmp	instruction_ready
1294
      setup_kmov_prefix:
1295
	cmp	ah,4
1296
	jb	kmov_w_ok
1297
	or	[rex_prefix],8
1298
      kmov_w_ok:
1299
	test	ah,1 or 4
1300
	jz	kmov_prefix_ok
1301
	mov	[opcode_prefix],66h
1302
      kmov_prefix_ok:
1303
	ret
1304
      kmov_maskreg:
1305
	lods	byte [esi]
4478 dunkaist 1306
	call	convert_mask_register
6467 dunkaist 1307
	mov	[postbyte_register],al
1308
	lods	byte [esi]
1309
	cmp	al,','
4478 dunkaist 1310
	jne	invalid_operand
1311
	lods	byte [esi]
1312
	cmp	al,14h
6467 dunkaist 1313
	je	kmov_maskreg_maskreg
1314
	cmp	al,10h
1315
	je	kmov_maskreg_reg
1316
	call	get_size_operator
4478 dunkaist 1317
	cmp	al,'['
6467 dunkaist 1318
	jne	invalid_argument
1319
	call	get_address
1320
	jmp	kmov_with_mem
1321
      kmov_maskreg_maskreg:
1322
	lods	byte [esi]
4478 dunkaist 1323
	call	convert_mask_register
6467 dunkaist 1324
	mov	bl,al
1325
	mov	ah,[mmx_size]
1326
	call	setup_kmov_prefix
1327
	jmp	nomem_instruction_ready
1328
      kmov_maskreg_reg:
1329
	add	[extended_code],2
1330
	lods	byte [esi]
4478 dunkaist 1331
	call	convert_register
6467 dunkaist 1332
      kmov_with_reg:
1333
	mov	bl,al
1334
	mov	al,[mmx_size]
1335
	mov	ah,4
1336
	cmp	al,ah
1337
	jbe	kmov_reg_size_check
1338
	mov	ah,al
1339
      kmov_reg_size_check:
1340
	cmp	ah,[operand_size]
1341
	jne	invalid_operand_size
1342
	cmp	al,8
1343
	je	kmov_f2_w1
1344
	cmp	al,2
1345
	ja	kmov_f2
1346
	je	nomem_instruction_ready
1347
	mov	[opcode_prefix],66h
1348
	jmp	nomem_instruction_ready
1349
      kmov_f2_w1:
1350
	or	[rex_prefix],8
1351
      kmov_f2:
1352
	mov	[opcode_prefix],0F2h
1353
	jmp	nomem_instruction_ready
1354
      kmov_reg:
1355
	add	[extended_code],3
1356
	lods	byte [esi]
1357
	call	convert_register
1358
	mov	[postbyte_register],al
1359
	lods	byte [esi]
1360
	cmp	al,','
4478 dunkaist 1361
	jne	invalid_operand
1362
	call	take_mask_register
6467 dunkaist 1363
	jmp	kmov_with_reg
1364
avx512_pmov_m2_instruction_w1:
1365
	or	[rex_prefix],8
1366
avx512_pmov_m2_instruction:
1367
	or	[vex_required],8
1368
	call	setup_f3_0f_38
1369
	call	take_avx_register
4478 dunkaist 1370
	mov	[postbyte_register],al
6467 dunkaist 1371
	lods	byte [esi]
1372
	cmp	al,','
1373
	jne	invalid_operand
1374
	call	take_mask_register
1375
	mov	bl,al
4478 dunkaist 1376
	jmp	nomem_instruction_ready
1377
avx512_pmov_2m_instruction_w1:
6467 dunkaist 1378
	or	[rex_prefix],8
1379
avx512_pmov_2m_instruction:
1380
	or	[vex_required],8
1381
	call	setup_f3_0f_38
1382
	call	take_mask_register
1383
	mov	[postbyte_register],al
1384
	lods	byte [esi]
1385
	cmp	al,','
1386
	jne	invalid_operand
4478 dunkaist 1387
	call	take_avx_register
6467 dunkaist 1388
	mov	bl,al
1389
	jmp	nomem_instruction_ready
1390
      setup_f3_0f_38:
1391
	mov	[extended_code],38h
1392
	mov	[supplemental_code],al
1393
	mov	[base_code],0Fh
1394
	mov	[opcode_prefix],0F3h
1395
	ret
1396
4478 dunkaist 1397
 
6467 dunkaist 1398
	mov	[operand_size],32
1399
vzeroupper_instruction:
1400
	mov	[base_code],0Fh
4478 dunkaist 1401
	mov	[extended_code],al
1402
	and	[displacement_compression],0
6467 dunkaist 1403
	call	store_vex_instruction_code
1404
	jmp	instruction_assembled
1405
vldmxcsr_instruction:
1406
	or	[vex_required],2
1407
	jmp	fxsave_instruction
1408
1409
 
1410
	or	[vex_required],2
1411
	xor	ch,ch
1412
      avx_instruction_imm8_without_128bit:
1413
	mov	[immediate_size],1
1414
	mov	ah,3Ah
1415
	jmp	avx_instruction_without_128bit
1416
avx512_shuf_q_instruction:
1417
	or	[rex_prefix],8
1418
	or	[vex_required],8
1419
	mov	ch,8
1420
	jmp	avx_instruction_imm8_without_128bit
1421
avx512_shuf_d_instruction:
1422
	or	[vex_required],8
1423
	mov	ch,4
1424
	jmp	avx_instruction_imm8_without_128bit
1425
avx_permd_instruction:
1426
	mov	ah,38h
1427
	mov	ch,4
1428
      avx_instruction_without_128bit:
1429
	xor	cl,cl
1430
	call	setup_avx_66_supplemental
1431
	call	take_avx_register
1432
	cmp	ah,32
1433
	jb	invalid_operand_size
1434
	mov	[postbyte_register],al
1435
	call	take_avx512_mask
1436
	jmp	avx_vex_reg
1437
      setup_avx_66_supplemental:
1438
	mov	[opcode_prefix],66h
1439
	mov	[broadcast_size],ch
1440
	mov	[mmx_size],cl
1441
	mov	[base_code],0Fh
1442
	mov	[extended_code],ah
1443
	mov	[supplemental_code],al
1444
	or	[vex_required],1
4478 dunkaist 1445
	ret
6467 dunkaist 1446
avx_permq_instruction:
1447
	or	[rex_prefix],8
1448
	mov	ch,8
1449
	jmp	avx_permil_instruction
1450
avx_permilpd_instruction:
1451
	or	[rex_prefix],80h
1452
	mov	ch,8
1453
	jmp	avx_permil_instruction
1454
avx_permilps_instruction:
1455
	mov	ch,4
1456
      avx_permil_instruction:
1457
	or	[operand_flags],2
1458
	xor	cl,cl
1459
	mov	ah,3Ah
1460
	call	setup_avx_66_supplemental
1461
	call	take_avx_register
4478 dunkaist 1462
	cmp	[supplemental_code],4
6467 dunkaist 1463
	jae	avx_permil_size_ok
1464
	cmp	ah,32
1465
	jb	invalid_operand_size
1466
      avx_permil_size_ok:
1467
	mov	[postbyte_register],al
4478 dunkaist 1468
	call	take_avx512_mask
6467 dunkaist 1469
	lods	byte [esi]
4478 dunkaist 1470
	cmp	al,','
1471
	jne	invalid_operand
1472
	call	take_avx_rm
6467 dunkaist 1473
	jnc	mmx_imm8
1474
	mov	bl,al
1475
	cmp	byte [esi],','
1476
	jne	invalid_operand
1477
	mov	al,[esi+1]
1478
	cmp	al,11h
1479
	jne	avx_permil_rm_or_imm8
1480
	mov	al,[esi+3]
1481
      avx_permil_rm_or_imm8:
1482
	cmp	al,'('
1483
	je	mmx_nomem_imm8
1484
	mov	[vex_register],bl
1485
	inc	esi
1486
	mov	[extended_code],38h
1487
	mov	al,[supplemental_code]
1488
	cmp	al,4
1489
	jb	avx_permq_rm
1490
	add	[supplemental_code],8
1491
	jmp	avx_regs_rm
1492
      avx_permq_rm:
1493
	or	[vex_required],8
1494
	shl	al,5
1495
	neg	al
1496
	add	al,36h
1497
	mov	[supplemental_code],al
1498
	jmp	avx_regs_rm
1499
vpermil_2pd_instruction:
1500
	mov	[immediate_size],-2
1501
	mov	byte [value],al
1502
	mov	al,49h
1503
	jmp	vpermil2_instruction_setup
1504
vpermil_2ps_instruction:
1505
	mov	[immediate_size],-2
1506
	mov	byte [value],al
1507
	mov	al,48h
1508
	jmp	vpermil2_instruction_setup
1509
vpermil2_instruction:
1510
	mov	[immediate_size],-3
1511
	mov	byte [value],0
1512
      vpermil2_instruction_setup:
1513
	or	[vex_required],2
1514
	mov	[base_code],0Fh
1515
	mov	[supplemental_code],al
1516
	mov	al,3Ah
1517
	xor	cl,cl
4478 dunkaist 1518
	jmp	avx_instruction
6467 dunkaist 1519
1520
 
1521
	or	[vex_required],8
1522
avx_shift_q_instruction:
1523
	or	[rex_prefix],80h
1524
	mov	cl,8
1525
	jmp	avx_shift_instruction
1526
avx_shift_d_instruction:
1527
	mov	cl,4
1528
	jmp	avx_shift_instruction
1529
avx_shift_bw_instruction:
1530
	xor	cl,cl
1531
       avx_shift_instruction:
1532
	mov	[broadcast_size],cl
1533
	mov	[mmx_size],0
1534
	mov	[opcode_prefix],66h
1535
	mov	[base_code],0Fh
1536
	mov	[extended_code],al
1537
	or	[vex_required],1
1538
	call	take_avx_register
1539
	mov	[postbyte_register],al
1540
	call	take_avx512_mask
1541
	lods	byte [esi]
1542
	cmp	al,','
1543
	jne	invalid_operand
1544
	xor	cl,cl
1545
	xchg	cl,[operand_size]
4478 dunkaist 1546
	lods	byte [esi]
1547
	call	get_size_operator
1548
	cmp	al,'['
6467 dunkaist 1549
	je	avx_shift_reg_mem
1550
	mov	[operand_size],cl
1551
	cmp	al,10h
4478 dunkaist 1552
	jne	invalid_operand
6467 dunkaist 1553
	lods	byte [esi]
4478 dunkaist 1554
	call	convert_avx_register
6467 dunkaist 1555
	mov	[vex_register],al
1556
	lods	byte [esi]
1557
	cmp	al,','
1558
	jne	invalid_operand
1559
	push	esi
1560
	xor	cl,cl
1561
	xchg	cl,[operand_size]
1562
	lods	byte [esi]
1563
	call	get_size_operator
1564
	cmp	al,10h
1565
	je	avx_shift_reg_reg_reg
1566
	pop	esi
1567
	cmp	al,'['
1568
	je	avx_shift_reg_reg_mem
1569
	xchg	cl,[operand_size]
1570
	test	cl,not 1
1571
	jnz	invalid_operand_size
1572
	dec	esi
1573
	call	convert_avx_shift_opcode
1574
	mov	bl,al
1575
	jmp	mmx_nomem_imm8
1576
      convert_avx_shift_opcode:
1577
	mov	al,[extended_code]
1578
	mov	ah,al
1579
	and	ah,1111b
1580
	add	ah,70h
1581
	mov	[extended_code],ah
1582
	shr	al,4
1583
	sub	al,0Ch
1584
	shl	al,1
1585
	xchg	al,[postbyte_register]
1586
	xchg	al,[vex_register]
1587
	ret
1588
      avx_shift_reg_reg_reg:
1589
	pop	eax
1590
	lods	byte [esi]
1591
	call	convert_xmm_register
4478 dunkaist 1592
	xchg	cl,[operand_size]
6467 dunkaist 1593
	mov	bl,al
4478 dunkaist 1594
	jmp	nomem_instruction_ready
1595
      avx_shift_reg_reg_mem:
6467 dunkaist 1596
	mov	[mmx_size],16
1597
	push	ecx
1598
	lods	byte [esi]
1599
	call	get_size_operator
1600
	call	get_address
4478 dunkaist 1601
	pop	eax
6467 dunkaist 1602
	xchg	al,[operand_size]
4478 dunkaist 1603
	test	al,al
6467 dunkaist 1604
	jz	instruction_ready
4478 dunkaist 1605
	cmp	al,16
6467 dunkaist 1606
	jne	invalid_operand_size
4478 dunkaist 1607
	jmp	instruction_ready
1608
      avx_shift_reg_mem:
6467 dunkaist 1609
	or	[vex_required],8
1610
	call	take_avx_mem
1611
	call	convert_avx_shift_opcode
1612
	jmp	mmx_imm8
1613
avx_shift_dq_instruction:
1614
	mov	[postbyte_register],al
1615
	mov	[opcode_prefix],66h
4478 dunkaist 1616
	mov	[base_code],0Fh
1617
	mov	[extended_code],73h
6467 dunkaist 1618
	or	[vex_required],1
4478 dunkaist 1619
	mov	[mmx_size],0
6467 dunkaist 1620
	call	take_avx_register
4478 dunkaist 1621
	mov	[vex_register],al
6467 dunkaist 1622
	lods	byte [esi]
1623
	cmp	al,','
1624
	jne	invalid_operand
4478 dunkaist 1625
	lods	byte [esi]
1626
	call	get_size_operator
6467 dunkaist 1627
	cmp	al,'['
1628
	je	avx_shift_dq_reg_mem
1629
	cmp	al,10h
1630
	jne	invalid_operand
1631
	lods	byte [esi]
1632
	call	convert_avx_register
1633
	mov	bl,al
1634
	jmp	mmx_nomem_imm8
1635
      avx_shift_dq_reg_mem:
1636
	or	[vex_required],8
1637
	call	get_address
1638
	jmp	mmx_imm8
1639
avx512_rotate_q_instruction:
1640
	mov	cl,8
1641
	or	[rex_prefix],cl
1642
	jmp	avx512_rotate_instruction
1643
avx512_rotate_d_instruction:
1644
	mov	cl,4
1645
      avx512_rotate_instruction:
1646
	mov	[broadcast_size],cl
1647
	mov	[postbyte_register],al
1648
	mov	[opcode_prefix],66h
1649
	mov	[base_code],0Fh
1650
	mov	[extended_code],72h
1651
	or	[vex_required],8
1652
	mov	[mmx_size],0
1653
	mov	[immediate_size],1
1654
	call	take_avx_register
1655
	mov	[vex_register],al
1656
	call	take_avx512_mask
1657
	jmp	avx_vex_reg_ok
1658
1659
 
1660
	mov	cl,2
1661
	jmp	avx_pmovsx_instruction
1662
avx_pmovsxbd_instruction:
1663
	mov	cl,4
1664
	jmp	avx_pmovsx_instruction
1665
avx_pmovsxbw_instruction:
1666
	mov	cl,8
1667
      avx_pmovsx_instruction:
1668
	mov	[mmx_size],cl
1669
	or	[vex_required],1
1670
	call	setup_66_0f_38
1671
	call	take_avx_register
1672
	mov	[postbyte_register],al
1673
	call	take_avx512_mask
1674
	lods	byte [esi]
1675
	cmp	al,','
4478 dunkaist 1676
	jne	invalid_operand
1677
	xor	al,al
6467 dunkaist 1678
	xchg	al,[operand_size]
1679
	bsf	ecx,eax
1680
	sub	cl,4
1681
	shl	[mmx_size],cl
1682
	push	eax
1683
	lods	byte [esi]
4478 dunkaist 1684
	call	get_size_operator
1685
	cmp	al,10h
1686
	je	avx_pmovsx_reg_reg
6467 dunkaist 1687
	cmp	al,'['
1688
	jne	invalid_operand
1689
	call	get_address
1690
	pop	eax
1691
	xchg	al,[operand_size]
1692
	or	al,al
1693
	jz	instruction_ready
1694
	cmp	al,[mmx_size]
1695
	jne	invalid_operand_size
1696
	jmp	instruction_ready
1697
      avx_pmovsx_reg_reg:
1698
	lods	byte [esi]
4478 dunkaist 1699
	call	convert_avx_register
1700
	mov	bl,al
1701
	cmp	ah,[mmx_size]
6467 dunkaist 1702
	je	avx_pmovsx_xmmreg_reg_size_ok
1703
	jb	invalid_operand_size
1704
	cmp	ah,16
1705
	jne	invalid_operand_size
1706
      avx_pmovsx_xmmreg_reg_size_ok:
1707
	pop	eax
1708
	mov	[operand_size],al
1709
	jmp	nomem_instruction_ready
4478 dunkaist 1710
avx512_pmovqb_instruction:
6467 dunkaist 1711
	mov	cl,2
1712
	jmp	avx512_pmov_instruction
1713
avx512_pmovdb_instruction:
1714
	mov	cl,4
1715
	jmp	avx512_pmov_instruction
1716
avx512_pmovwb_instruction:
1717
	mov	cl,8
1718
      avx512_pmov_instruction:
1719
	mov	[mmx_size],cl
1720
	or	[vex_required],8
1721
	mov	[extended_code],38h
1722
	mov	[supplemental_code],al
1723
	mov	[base_code],0Fh
1724
	mov	[opcode_prefix],0F3h
1725
	lods	byte [esi]
1726
	call	get_size_operator
1727
	cmp	al,10h
1728
	je	avx512_pmov_reg
1729
	cmp	al,'['
4478 dunkaist 1730
	jne	invalid_operand
1731
	call	get_address
1732
	or	[operand_flags],20h
6467 dunkaist 1733
	call	avx512_pmov_common
1734
	or	al,al
4478 dunkaist 1735
	jz	instruction_ready
6467 dunkaist 1736
	cmp	al,[mmx_size]
1737
	jne	invalid_operand_size
1738
	jmp	instruction_ready
1739
      avx512_pmov_common:
1740
	call	take_avx512_mask
1741
	xor	al,al
1742
	xchg	al,[operand_size]
1743
	push	eax
1744
	lods	byte [esi]
1745
	cmp	al,','
1746
	jne	invalid_operand
1747
	call	take_avx_register
1748
	mov	[postbyte_register],al
1749
	mov	al,ah
1750
	mov	ah,cl
1751
	bsf	ecx,eax
1752
	sub	cl,4
1753
	shl	[mmx_size],cl
1754
	mov	cl,ah
1755
	pop	eax
1756
	ret
1757
      avx512_pmov_reg:
1758
	lods	byte [esi]
1759
	call	convert_avx_register
1760
	mov	bl,al
1761
	call	avx512_pmov_common
1762
	cmp	al,[mmx_size]
1763
	je	nomem_instruction_ready
1764
	jb	invalid_operand_size
1765
	cmp	al,16
4478 dunkaist 1766
	jne	invalid_operand_size
1767
	jmp	nomem_instruction_ready
6467 dunkaist 1768
1769
 
1770
	or	[vex_required],2
4478 dunkaist 1771
	mov	cl,10h
6467 dunkaist 1772
	jmp	avx_broadcast_instruction
1773
avx512_broadcast_32x2_instruction:
1774
	mov	cl,08h
1775
	jmp	avx_broadcast_instruction_evex
1776
avx512_broadcast_32x4_instruction:
1777
	mov	cl,10h
1778
	jmp	avx_broadcast_instruction_evex
1779
avx512_broadcast_32x8_instruction:
1780
	mov	cl,20h
1781
	jmp	avx_broadcast_instruction_evex
1782
avx512_broadcast_64x2_instruction:
1783
	mov	cl,10h
1784
	jmp	avx_broadcast_instruction_w1_evex
1785
avx512_broadcast_64x4_instruction:
1786
	mov	cl,20h
1787
      avx_broadcast_instruction_w1_evex:
1788
	or	[rex_prefix],8
1789
      avx_broadcast_instruction_evex:
1790
	or	[vex_required],8
1791
	jmp	avx_broadcast_instruction
1792
avx_broadcastss_instruction:
1793
	mov	cl,4
1794
	jmp	avx_broadcast_instruction
1795
avx_broadcastsd_instruction:
1796
	or	[rex_prefix],80h
1797
	mov	cl,8
1798
	jmp	avx_broadcast_instruction
1799
avx_pbroadcastb_instruction:
1800
	mov	cl,1
1801
	jmp	avx_broadcast_pi_instruction
1802
avx_pbroadcastw_instruction:
1803
	mov	cl,2
1804
	jmp	avx_broadcast_pi_instruction
1805
avx_pbroadcastd_instruction:
1806
	mov	cl,4
1807
	jmp	avx_broadcast_pi_instruction
1808
avx_pbroadcastq_instruction:
1809
	mov	cl,8
1810
	or	[rex_prefix],80h
1811
      avx_broadcast_pi_instruction:
1812
	or	[operand_flags],40h
1813
      avx_broadcast_instruction:
1814
	mov	[opcode_prefix],66h
1815
	mov	[supplemental_code],al
1816
	mov	al,38h
1817
	mov	[mmx_size],cl
1818
	mov	[base_code],0Fh
4478 dunkaist 1819
	mov	[extended_code],al
1820
	or	[vex_required],1
1821
	call	take_avx_register
1822
	cmp	ah,[mmx_size]
6467 dunkaist 1823
	je	invalid_operand_size
1824
	test	[operand_flags],40h
1825
	jnz	avx_broadcast_destination_size_ok
1826
	cmp	[mmx_size],4
1827
	je	avx_broadcast_destination_size_ok
1828
	cmp	[supplemental_code],59h
1829
	je	avx_broadcast_destination_size_ok
1830
	cmp	ah,16
4478 dunkaist 1831
	je	invalid_operand_size
6467 dunkaist 1832
      avx_broadcast_destination_size_ok:
1833
	xor	ah,ah
1834
	xchg	ah,[operand_size]
1835
	push	eax
1836
	call	take_avx512_mask
1837
	lods	byte [esi]
4478 dunkaist 1838
	cmp	al,','
1839
	jne	invalid_operand
1840
	lods	byte [esi]
6467 dunkaist 1841
	call	get_size_operator
1842
	cmp	al,10h
1843
	je	avx_broadcast_reg_reg
1844
	cmp	al,'['
1845
	jne	invalid_operand
1846
	call	get_address
1847
	pop	eax
1848
	xchg	ah,[operand_size]
1849
	mov	[postbyte_register],al
1850
	mov	al,[broadcast_size]
1851
	mov	al,[mmx_size]
1852
	cmp	al,ah
1853
	je	instruction_ready
1854
	or	al,al
1855
	jz	instruction_ready
1856
	or	ah,ah
1857
	jz	instruction_ready
1858
	jmp	invalid_operand_size
1859
      avx_broadcast_reg_reg:
1860
	lods	byte [esi]
1861
	test	[operand_flags],40h
1862
	jz	avx_broadcast_reg_avx_reg
1863
	cmp	al,60h
1864
	jb	avx_broadcast_reg_general_reg
1865
	cmp	al,80h
1866
	jb	avx_broadcast_reg_avx_reg
1867
	cmp	al,0C0h
1868
	jb	avx_broadcast_reg_general_reg
1869
      avx_broadcast_reg_avx_reg:
1870
	call	convert_avx_register
1871
	mov	bl,al
1872
	mov	al,[mmx_size]
1873
	or	al,al
1874
	jz	avx_broadcast_reg_avx_reg_size_ok
1875
	cmp	ah,16
1876
	jne	invalid_operand_size
1877
	cmp	al,ah
1878
	jae	invalid_operand
1879
      avx_broadcast_reg_avx_reg_size_ok:
1880
	pop	eax
1881
	xchg	ah,[operand_size]
1882
	mov	[postbyte_register],al
1883
	test	[vex_required],2
1884
	jnz	invalid_operand
1885
	jmp	nomem_instruction_ready
1886
      avx_broadcast_reg_general_reg:
1887
	call	convert_register
1888
	mov	bl,al
1889
	mov	al,[mmx_size]
1890
	or	al,al
1891
	jz	avx_broadcast_reg_general_reg_size_ok
1892
	cmp	al,ah
1893
	jne	invalid_operand_size
1894
      avx_broadcast_reg_general_reg_size_ok:
1895
	cmp	al,4
1896
	jb	avx_broadcast_reg_general_reg_ready
1897
	cmp	al,8
1898
	mov	al,3
1899
	jne	avx_broadcast_reg_general_reg_ready
1900
	or	[rex_prefix],8
1901
      avx_broadcast_reg_general_reg_ready:
1902
	add	al,7Ah-1
1903
	mov	[supplemental_code],al
1904
	or	[vex_required],8
1905
	pop	eax
1906
	xchg	ah,[operand_size]
1907
	mov	[postbyte_register],al
1908
	jmp	nomem_instruction_ready
1909
4478 dunkaist 1910
 
6467 dunkaist 1911
	or	[rex_prefix],8
1912
avx512_extract_32x8_instruction:
1913
	or	[vex_required],8
1914
	mov	cl,32
1915
	jmp	avx_extractf_instruction
1916
avx512_extract_64x2_instruction:
1917
	or	[rex_prefix],8
1918
avx512_extract_32x4_instruction:
1919
	or	[vex_required],8
1920
	mov	cl,16
1921
	jmp	avx_extractf_instruction
1922
avx_extractf128_instruction:
4478 dunkaist 1923
	or	[vex_required],2
6467 dunkaist 1924
	mov	cl,16
1925
      avx_extractf_instruction:
1926
	mov	[mmx_size],cl
1927
	call	setup_66_0f_3a
4478 dunkaist 1928
	lods	byte [esi]
1929
	call	get_size_operator
1930
	cmp	al,10h
1931
	je	avx_extractf_reg
6467 dunkaist 1932
	cmp	al,'['
4478 dunkaist 1933
	jne	invalid_operand
1934
	call	get_address
1935
	xor	al,al
1936
	xchg	al,[operand_size]
1937
	or	al,al
1938
	jz	avx_extractf_mem_size_ok
6467 dunkaist 1939
	cmp	al,[mmx_size]
1940
	jne	invalid_operand_size
4478 dunkaist 1941
      avx_extractf_mem_size_ok:
6467 dunkaist 1942
	call	take_avx512_mask
1943
	lods	byte [esi]
4478 dunkaist 1944
	cmp	al,','
1945
	jne	invalid_operand
1946
	call	take_avx_register
1947
	cmp	ah,[mmx_size]
6467 dunkaist 1948
	jbe	invalid_operand_size
1949
	mov	[postbyte_register],al
4478 dunkaist 1950
	jmp	mmx_imm8
1951
      avx_extractf_reg:
6467 dunkaist 1952
	lods	byte [esi]
4478 dunkaist 1953
	call	convert_avx_register
6467 dunkaist 1954
	cmp	ah,[mmx_size]
1955
	jne	invalid_operand_size
1956
	push	eax
1957
	call	take_avx512_mask
1958
	mov	[operand_size],0
4478 dunkaist 1959
	lods	byte [esi]
1960
	cmp	al,','
1961
	jne	invalid_operand
1962
	call	take_avx_register
1963
	cmp	ah,[mmx_size]
6467 dunkaist 1964
	jbe	invalid_operand_size
1965
	mov	[postbyte_register],al
4478 dunkaist 1966
	pop	ebx
1967
	jmp	mmx_nomem_imm8
1968
avx512_insert_64x4_instruction:
6467 dunkaist 1969
	or	[rex_prefix],8
1970
avx512_insert_32x8_instruction:
1971
	or	[vex_required],8
1972
	mov	cl,32
1973
	jmp	avx_insertf_instruction
1974
avx512_insert_64x2_instruction:
1975
	or	[rex_prefix],8
1976
avx512_insert_32x4_instruction:
1977
	or	[vex_required],8
1978
	mov	cl,16
1979
	jmp	avx_insertf_instruction
1980
avx_insertf128_instruction:
4478 dunkaist 1981
	or	[vex_required],2
6467 dunkaist 1982
	mov	cl,16
1983
      avx_insertf_instruction:
1984
	mov	[mmx_size],cl
1985
	mov	[broadcast_size],0
1986
	call	setup_66_0f_3a
4478 dunkaist 1987
	call	take_avx_register
1988
	cmp	ah,[mmx_size]
6467 dunkaist 1989
	jbe	invalid_operand
1990
	mov	[postbyte_register],al
4478 dunkaist 1991
	call	take_avx512_mask
6467 dunkaist 1992
	lods	byte [esi]
4478 dunkaist 1993
	cmp	al,','
1994
	jne	invalid_operand
1995
	call	take_avx_register
1996
	mov	[vex_register],al
1997
	mov	al,[mmx_size]
6467 dunkaist 1998
	xchg	al,[operand_size]
1999
	push	eax
2000
	lods	byte [esi]
4478 dunkaist 2001
	cmp	al,','
2002
	jne	invalid_operand
2003
	lods	byte [esi]
6467 dunkaist 2004
	call	get_size_operator
2005
	cmp	al,10h
2006
	je	avx_insertf_reg_reg_reg
2007
	cmp	al,'['
2008
	jne	invalid_operand
2009
	call	get_address
2010
	pop	eax
2011
	mov	[operand_size],al
2012
	jmp	mmx_imm8
2013
      avx_insertf_reg_reg_reg:
2014
	lods	byte [esi]
2015
	call	convert_avx_register
2016
	mov	bl,al
4478 dunkaist 2017
	pop	eax
6467 dunkaist 2018
	mov	[operand_size],al
2019
	jmp	mmx_nomem_imm8
4478 dunkaist 2020
avx_extract_b_instruction:
6467 dunkaist 2021
	mov	cl,1
2022
	jmp	avx_extract_instruction
2023
avx_extract_w_instruction:
2024
	mov	cl,2
2025
	jmp	avx_extract_instruction
2026
avx_extract_q_instruction:
2027
	or	[rex_prefix],8
2028
	mov	cl,8
2029
	jmp	avx_extract_instruction
2030
avx_extract_d_instruction:
2031
	mov	cl,4
2032
      avx_extract_instruction:
2033
	mov	[mmx_size],cl
2034
	call	setup_66_0f_3a
2035
	or	[vex_required],1
4478 dunkaist 2036
	lods	byte [esi]
6467 dunkaist 2037
	call	get_size_operator
2038
	cmp	al,10h
2039
	je	avx_extractps_reg
2040
	cmp	al,'['
2041
	jne	invalid_operand
2042
	call	get_address
2043
	mov	al,[mmx_size]
2044
	not	al
2045
	and	[operand_size],al
2046
	jnz	invalid_operand_size
2047
	lods	byte [esi]
2048
	cmp	al,','
2049
	jne	invalid_operand
2050
	lods	byte [esi]
2051
	call	get_size_operator
2052
	cmp	al,10h
2053
	jne	invalid_operand
2054
	lods	byte [esi]
2055
	call	convert_avx_register
2056
	cmp	ah,16
4478 dunkaist 2057
	jne	invalid_operand_size
2058
	mov	[postbyte_register],al
2059
	jmp	mmx_imm8
6467 dunkaist 2060
      avx_extractps_reg:
2061
	lods	byte [esi]
4478 dunkaist 2062
	call	convert_register
6467 dunkaist 2063
	mov	bl,al
2064
	mov	al,[mmx_size]
2065
	cmp	ah,al
2066
	jb	invalid_operand_size
2067
	cmp	ah,4
2068
	je	avx_extractps_reg_size_ok
2069
	cmp	ah,8
2070
	jne	invalid_operand_size
2071
	cmp	[code_type],64
2072
	jne	invalid_operand
2073
	cmp	al,4
2074
	jae	avx_extractps_reg_size_ok
2075
	or	[rex_prefix],8
2076
      avx_extractps_reg_size_ok:
2077
	mov	[operand_size],0
2078
	lods	byte [esi]
2079
	cmp	al,','
4478 dunkaist 2080
	jne	invalid_operand
2081
	lods	byte [esi]
6467 dunkaist 2082
	call	get_size_operator
2083
	cmp	al,10h
2084
	jne	invalid_operand
2085
	lods	byte [esi]
2086
	call	convert_avx_register
2087
	cmp	ah,16
2088
	jne	invalid_operand_size
2089
	mov	[postbyte_register],al
2090
	cmp	[supplemental_code],15h
2091
	jne	mmx_nomem_imm8
2092
	mov	[extended_code],0C5h
2093
	xchg	bl,[postbyte_register]
2094
	jmp	mmx_nomem_imm8
2095
avx_insertps_instruction:
2096
	mov	[immediate_size],1
2097
	or	[operand_flags],10h
2098
	mov	[opcode_prefix],66h
2099
	mov	[supplemental_code],al
2100
	mov	al,3Ah
2101
	mov	cl,4
2102
	jmp	avx_instruction
2103
avx_pinsrb_instruction:
4478 dunkaist 2104
	mov	cl,1
6467 dunkaist 2105
	jmp	avx_pinsr_instruction_3a
4478 dunkaist 2106
avx_pinsrw_instruction:
2107
	mov	cl,2
6467 dunkaist 2108
	jmp	avx_pinsr_instruction
4478 dunkaist 2109
avx_pinsrd_instruction:
2110
	mov	cl,4
6467 dunkaist 2111
	jmp	avx_pinsr_instruction_3a
4478 dunkaist 2112
avx_pinsrq_instruction:
2113
	mov	cl,8
6467 dunkaist 2114
	or	[rex_prefix],8
2115
      avx_pinsr_instruction_3a:
4478 dunkaist 2116
	mov	[supplemental_code],al
2117
	mov	al,3Ah
2118
      avx_pinsr_instruction:
2119
	mov	[opcode_prefix],66h
2120
	mov	[base_code],0Fh
2121
	mov	[extended_code],al
2122
	mov	[mmx_size],cl
6467 dunkaist 2123
	or	[vex_required],1
2124
	call	take_avx_register
4478 dunkaist 2125
	cmp	ah,16
2126
	jne	invalid_operand_size
2127
	mov	[postbyte_register],al
2128
	lods	byte [esi]
2129
	cmp	al,','
2130
	jne	invalid_operand
2131
	call	take_avx_register
2132
	mov	[vex_register],al
2133
	jmp	pinsr_xmmreg
2134
6467 dunkaist 2135
 
2136
	or	[vex_required],8
2137
avx_cvtdq2pd_instruction:
2138
	mov	[opcode_prefix],0F3h
2139
	mov	cl,4
2140
	jmp	avx_cvt_d_instruction
2141
avx_cvtps2qq_instruction:
2142
	or	[operand_flags],8
2143
avx_cvttps2qq_instruction:
2144
	or	[operand_flags],4
2145
	or	[vex_required],8
2146
	mov	[opcode_prefix],66h
4478 dunkaist 2147
	mov	cl,4
6467 dunkaist 2148
	jmp	avx_cvt_d_instruction
2149
avx_cvtps2pd_instruction:
2150
	or	[operand_flags],4
2151
	mov	cl,4
2152
      avx_cvt_d_instruction:
2153
	mov	[base_code],0Fh
4478 dunkaist 2154
	mov	[extended_code],al
2155
	or	[vex_required],1
6467 dunkaist 2156
	mov	[broadcast_size],cl
2157
	call	take_avx_register
2158
	mov	[postbyte_register],al
2159
	call	take_avx512_mask
2160
	lods	byte [esi]
4478 dunkaist 2161
	cmp	al,','
6467 dunkaist 2162
	jne	invalid_operand
2163
	xor	ecx,ecx
2164
	xchg	cl,[operand_size]
2165
	mov	al,cl
2166
	shr	al,1
2167
	mov	[mmx_size],al
2168
	lods	byte [esi]
2169
	call	get_size_operator
4478 dunkaist 2170
	cmp	al,'['
6467 dunkaist 2171
	je	avx_cvt_d_reg_mem
2172
	cmp	al,10h
4478 dunkaist 2173
	jne	invalid_operand
2174
	mov	[operand_size],0
6467 dunkaist 2175
	lods	byte [esi]
4478 dunkaist 2176
	call	convert_avx_register
6467 dunkaist 2177
	cmp	ah,[mmx_size]
2178
	je	avx_cvt_d_reg_reg_size_ok
2179
	jb	invalid_operand_size
2180
	cmp	ah,16
2181
	jne	invalid_operand_size
4478 dunkaist 2182
      avx_cvt_d_reg_reg_size_ok:
6467 dunkaist 2183
	mov	bl,al
4478 dunkaist 2184
	mov	[operand_size],cl
6467 dunkaist 2185
	call	take_avx512_rounding
2186
	jmp	nomem_instruction_ready
4478 dunkaist 2187
      avx_cvt_d_reg_mem:
6467 dunkaist 2188
	call	take_avx_mem
2189
	jmp	instruction_ready
2190
avx_cvtpd2dq_instruction:
2191
	or	[operand_flags],4+8
2192
	mov	[opcode_prefix],0F2h
2193
	jmp	avx_cvt_q_instruction
2194
avx_cvtuqq2ps_instruction:
2195
	mov	[opcode_prefix],0F2h
2196
avx_cvtpd2udq_instruction:
2197
	or	[operand_flags],8
2198
avx_cvttpd2udq_instruction:
2199
	or	[operand_flags],4
2200
	or	[vex_required],8
2201
	jmp	avx_cvt_q_instruction
2202
avx_cvtpd2ps_instruction:
2203
	or	[operand_flags],8
2204
avx_cvttpd2dq_instruction:
2205
	or	[operand_flags],4
2206
	mov	[opcode_prefix],66h
2207
      avx_cvt_q_instruction:
2208
	mov	[broadcast_size],8
2209
	mov	[base_code],0Fh
2210
	mov	[extended_code],al
2211
	or	[vex_required],1
4478 dunkaist 2212
	or	[rex_prefix],80h
6467 dunkaist 2213
	call	take_avx_register
4478 dunkaist 2214
	mov	[postbyte_register],al
2215
	push	eax
6467 dunkaist 2216
	call	take_avx512_mask
2217
	lods	byte [esi]
4478 dunkaist 2218
	cmp	al,','
2219
	jne	invalid_operand
2220
	xor	al,al
6467 dunkaist 2221
	mov	[operand_size],al
2222
	mov	[mmx_size],al
2223
	call	take_avx_rm
4478 dunkaist 2224
	jnc	avx_cvt_q_reg_mem
6467 dunkaist 2225
	mov	bl,al
4478 dunkaist 2226
	pop	eax
6467 dunkaist 2227
	call	avx_cvt_q_check_size
2228
	call	take_avx512_rounding
2229
	jmp	nomem_instruction_ready
2230
      avx_cvt_q_reg_mem:
2231
	pop	eax
2232
	call	avx_cvt_q_check_size
2233
	jmp	instruction_ready
2234
      avx_cvt_q_check_size:
2235
	mov	al,[operand_size]
2236
	or	al,al
2237
	jz	avx_cvt_q_size_not_specified
2238
	shr	al,1
2239
	cmp	al,ah
2240
	je	avx_cvt_q_size_ok
2241
	ja	invalid_operand_size
2242
	cmp	ah,16
2243
	jne	invalid_operand_size
2244
      avx_cvt_q_size_ok:
2245
	ret
2246
      avx_cvt_q_size_not_specified:
2247
	cmp	ah,64 shr 1
2248
	jne	recoverable_unknown_size
2249
	mov	[operand_size],64
2250
	ret
2251
avx_cvttps2udq_instruction:
2252
	or	[vex_required],8
2253
	or	[operand_flags],2+4
2254
	mov	cx,0400h
2255
	jmp	avx_instruction_with_broadcast
2256
avx_cvttps2dq_instruction:
2257
	mov	[opcode_prefix],0F3h
2258
	or	[operand_flags],2+4
2259
	mov	cx,0400h
2260
	jmp	avx_instruction_with_broadcast
2261
avx_cvtph2ps_instruction:
2262
	mov	[opcode_prefix],66h
2263
	mov	[supplemental_code],al
2264
	or	[operand_flags],4
2265
	mov	al,38h
2266
	xor	cl,cl
2267
	jmp	avx_cvt_d_instruction
2268
avx_cvtps2ph_instruction:
2269
	call	setup_66_0f_3a
2270
	or	[vex_required],1
4478 dunkaist 2271
	or	[operand_flags],4
6467 dunkaist 2272
	lods	byte [esi]
2273
	call	get_size_operator
2274
	cmp	al,10h
2275
	je	vcvtps2ph_reg
2276
	cmp	al,'['
2277
	jne	invalid_operand
2278
	call	get_address
2279
	call	take_avx512_mask
2280
	lods	byte [esi]
2281
	cmp	al,','
2282
	jne	invalid_operand
2283
	shl	[operand_size],1
2284
	call	take_avx_register
4478 dunkaist 2285
	mov	[postbyte_register],al
2286
	shr	ah,1
6467 dunkaist 2287
	mov	[mmx_size],ah
2288
	jmp	mmx_imm8
2289
      vcvtps2ph_reg:
2290
	lods	byte [esi]
4478 dunkaist 2291
	call	convert_avx_register
6467 dunkaist 2292
	mov	bl,al
2293
	call	take_avx512_mask
2294
	xor	cl,cl
2295
	xchg	cl,[operand_size]
2296
	shl	cl,1
2297
	lods	byte [esi]
2298
	cmp	al,','
4478 dunkaist 2299
	jne	invalid_operand
2300
	call	take_avx_register
6467 dunkaist 2301
	mov	[postbyte_register],al
2302
	or	cl,cl
2303
	jz	vcvtps2ph_reg_size_ok
2304
	cmp	cl,ah
2305
	je	vcvtps2ph_reg_size_ok
2306
	jb	invalid_operand_size
2307
	cmp	ah,16
2308
	jne	invalid_operand_size
2309
      vcvtps2ph_reg_size_ok:
2310
	call	take_avx512_rounding
2311
	jmp	mmx_nomem_imm8
2312
2313
 
2314
	or	[operand_flags],8
2315
avx_cvttsd2usi_instruction:
2316
	or	[vex_required],8
2317
	jmp	avx_cvttsd2si_instruction
2318
avx_cvtsd2si_instruction:
2319
	or	[operand_flags],8
2320
avx_cvttsd2si_instruction:
2321
	mov	ah,0F2h
2322
	mov	cl,8
2323
	jmp	avx_cvt_2si_instruction
2324
avx_cvtss2usi_instruction:
2325
	or	[operand_flags],8
2326
avx_cvttss2usi_instruction:
2327
	or	[vex_required],8
2328
	jmp	avx_cvttss2si_instruction
2329
avx_cvtss2si_instruction:
2330
	or	[operand_flags],8
2331
avx_cvttss2si_instruction:
2332
	mov	ah,0F3h
2333
	mov	cl,4
2334
      avx_cvt_2si_instruction:
2335
	or	[operand_flags],2+4
2336
	mov	[mmx_size],cl
2337
	mov	[broadcast_size],0
2338
	mov	[opcode_prefix],ah
2339
	mov	[base_code],0Fh
2340
	mov	[extended_code],al
2341
	or	[vex_required],1
2342
	lods	byte [esi]
4478 dunkaist 2343
	call	get_size_operator
2344
	cmp	al,10h
2345
	jne	invalid_operand
2346
	lods	byte [esi]
6467 dunkaist 2347
	call	convert_register
2348
	mov	[postbyte_register],al
2349
	mov	[operand_size],0
2350
	cmp	ah,4
2351
	je	avx_cvt_2si_reg
2352
	cmp	ah,8
2353
	jne	invalid_operand_size
4478 dunkaist 2354
	call	operand_64bit
6467 dunkaist 2355
      avx_cvt_2si_reg:
2356
	lods	byte [esi]
4478 dunkaist 2357
	cmp	al,','
6467 dunkaist 2358
	jne	invalid_operand
2359
	call	take_avx_rm
2360
	jnc	instruction_ready
2361
	mov	bl,al
4478 dunkaist 2362
	call	take_avx512_rounding
6467 dunkaist 2363
	jmp	nomem_instruction_ready
4478 dunkaist 2364
avx_cvtusi2sd_instruction:
6467 dunkaist 2365
	or	[vex_required],8
2366
avx_cvtsi2sd_instruction:
2367
	mov	ah,0F2h
2368
	mov	cl,8
2369
	jmp	avx_cvtsi_instruction
2370
avx_cvtusi2ss_instruction:
2371
	or	[vex_required],8
2372
avx_cvtsi2ss_instruction:
2373
	mov	ah,0F3h
2374
	mov	cl,4
2375
      avx_cvtsi_instruction:
2376
	or	[operand_flags],2+4+8
2377
	mov	[mmx_size],cl
2378
	mov	[opcode_prefix],ah
2379
	mov	[base_code],0Fh
2380
	mov	[extended_code],al
2381
	or	[vex_required],1
4478 dunkaist 2382
	call	take_avx_register
2383
	cmp	ah,16
6467 dunkaist 2384
	jne	invalid_operand_size
2385
	mov	[postbyte_register],al
4478 dunkaist 2386
	lods	byte [esi]
2387
	cmp	al,','
2388
	jne	invalid_operand
2389
	call	take_avx_register
6467 dunkaist 2390
	mov	[vex_register],al
2391
	lods	byte [esi]
4478 dunkaist 2392
	cmp	al,','
6467 dunkaist 2393
	jne	invalid_operand
2394
	mov	[operand_size],0
2395
	lods	byte [esi]
2396
	call	get_size_operator
4478 dunkaist 2397
	cmp	al,'['
2398
	je	avx_cvtsi_reg_reg_mem
6467 dunkaist 2399
	cmp	al,10h
4478 dunkaist 2400
	jne	invalid_operand
2401
	lods	byte [esi]
2402
	call	convert_register
6467 dunkaist 2403
	mov	bl,al
2404
	cmp	ah,4
2405
	je	avx_cvtsi_reg_reg_reg32
2406
	cmp	ah,8
2407
	jne	invalid_operand_size
2408
	call	operand_64bit
2409
      avx_cvtsi_rounding:
2410
	call	take_avx512_rounding
2411
	jmp	nomem_instruction_ready
2412
      avx_cvtsi_reg_reg_reg32:
2413
	cmp	[mmx_size],8
2414
	jne	avx_cvtsi_rounding
2415
	jmp	nomem_instruction_ready
2416
      avx_cvtsi_reg_reg_mem:
2417
	call	get_address
2418
	mov	al,[operand_size]
2419
	mov	[mmx_size],al
2420
	or	al,al
2421
	jz	single_mem_nosize
2422
	cmp	al,4
2423
	je	instruction_ready
2424
	cmp	al,8
2425
	jne	invalid_operand_size
2426
	call	operand_64bit
2427
	jmp	instruction_ready
2428
2429
 
2430
	or	[rex_prefix],8
2431
avx_maskmov_instruction:
2432
	call	setup_66_0f_38
2433
	mov	[mmx_size],0
2434
	or	[vex_required],2
2435
	lods	byte [esi]
2436
	call	get_size_operator
2437
	cmp	al,10h
2438
	jne	avx_maskmov_mem
2439
	lods	byte [esi]
2440
	call	convert_avx_register
4478 dunkaist 2441
	mov	[postbyte_register],al
6467 dunkaist 2442
	lods	byte [esi]
2443
	cmp	al,','
2444
	jne	invalid_operand
2445
	call	take_avx_register
2446
	mov	[vex_register],al
4478 dunkaist 2447
	lods	byte [esi]
2448
	cmp	al,','
2449
	jne	invalid_operand
2450
	lods	byte [esi]
2451
	cmp	al,'['
2452
	jne	invalid_operand
6467 dunkaist 2453
	call	get_address
4478 dunkaist 2454
	jmp	instruction_ready
2455
      avx_maskmov_mem:
6467 dunkaist 2456
	cmp	al,'['
2457
	jne	invalid_operand
2458
	call	get_address
4478 dunkaist 2459
	lods	byte [esi]
2460
	cmp	al,','
2461
	jne	invalid_operand
2462
	call	take_avx_register
2463
	mov	[vex_register],al
2464
	lods	byte [esi]
2465
	cmp	al,','
2466
	jne	invalid_operand
2467
	call	take_avx_register
6467 dunkaist 2468
	mov	[postbyte_register],al
2469
	add	[supplemental_code],2
2470
	jmp	instruction_ready
2471
avx_movmskpd_instruction:
2472
	mov	[opcode_prefix],66h
2473
avx_movmskps_instruction:
2474
	mov	[base_code],0Fh
2475
	mov	[extended_code],50h
2476
	or	[vex_required],2
2477
	lods	byte [esi]
4478 dunkaist 2478
	call	get_size_operator
2479
	cmp	al,10h
2480
	jne	invalid_operand
6467 dunkaist 2481
	lods	byte [esi]
2482
	call	convert_register
2483
	mov	[postbyte_register],al
2484
	cmp	ah,4
2485
	je	avx_movmskps_reg_ok
2486
	cmp	ah,8
2487
	jne	invalid_operand_size
2488
	cmp	[code_type],64
2489
	jne	invalid_operand
2490
      avx_movmskps_reg_ok:
2491
	mov	[operand_size],0
2492
	lods	byte [esi]
2493
	cmp	al,','
2494
	jne	invalid_operand
2495
	call	take_avx_register
2496
	mov	bl,al
2497
	jmp	nomem_instruction_ready
2498
avx_maskmovdqu_instruction:
2499
	or	[vex_required],2
2500
	jmp	maskmovdqu_instruction
2501
avx_pmovmskb_instruction:
2502
	or	[vex_required],2
2503
	mov	[opcode_prefix],66h
2504
	mov	[base_code],0Fh
2505
	mov	[extended_code],al
4478 dunkaist 2506
	lods	byte [esi]
2507
	call	get_size_operator
6467 dunkaist 2508
	cmp	al,10h
2509
	jne	invalid_operand
2510
	lods	byte [esi]
2511
	call	convert_register
2512
	cmp	ah,4
2513
	je	avx_pmovmskb_reg_size_ok
2514
	cmp	[code_type],64
2515
	jne	invalid_operand_size
2516
	cmp	ah,8
2517
	jnz	invalid_operand_size
2518
      avx_pmovmskb_reg_size_ok:
2519
	mov	[postbyte_register],al
2520
	mov	[operand_size],0
2521
	lods	byte [esi]
2522
	cmp	al,','
2523
	jne	invalid_operand
2524
	call	take_avx_register
2525
	mov	bl,al
4478 dunkaist 2526
	jmp	nomem_instruction_ready
2527
6467 dunkaist 2528
 
2529
	or	[rex_prefix],8
2530
gather_ps_instruction:
2531
	call	setup_66_0f_38
2532
	or	[vex_required],4
2533
	or	[operand_flags],20h
2534
	call	take_avx_register
2535
	mov	[postbyte_register],al
2536
	call	take_avx512_mask
2537
	lods	byte [esi]
2538
	cmp	al,','
2539
	jne	invalid_operand
2540
	xor	cl,cl
2541
	xchg	cl,[operand_size]
2542
	push	ecx
4478 dunkaist 2543
	lods	byte [esi]
2544
	call	get_size_operator
2545
	cmp	al,'['
6467 dunkaist 2546
	jne	invalid_argument
2547
	call	get_address
4478 dunkaist 2548
	pop	eax
2549
	xchg	al,[operand_size]
2550
      gather_mem_size_check:
6467 dunkaist 2551
	mov	ah,4
2552
	test	[rex_prefix],8
2553
	jz	gather_elements_size_ok
2554
	add	ah,ah
2555
      gather_elements_size_ok:
2556
	mov	[mmx_size],ah
2557
	test	al,al
4478 dunkaist 2558
	jz	gather_mem_size_ok
6467 dunkaist 2559
	cmp	al,ah
2560
	jne	invalid_operand_size
4478 dunkaist 2561
      gather_mem_size_ok:
6467 dunkaist 2562
	cmp	byte [esi],','
2563
	je	gather_reg_mem_reg
2564
	test	[vex_required],20h
2565
	jz	invalid_operand
2566
	mov	ah,[operand_size]
2567
	mov	al,80h
2568
	jmp	gather_arguments_ok
2569
      gather_reg_mem_reg:
2570
	or	[vex_required],2
2571
	inc	esi
2572
	call	take_avx_register
4478 dunkaist 2573
      gather_arguments_ok:
6467 dunkaist 2574
	mov	[vex_register],al
4478 dunkaist 2575
	cmp	al,[postbyte_register]
6467 dunkaist 2576
	je	disallowed_combination_of_registers
2577
	mov	al,bl
2578
	and	al,11111b
2579
	cmp	al,[postbyte_register]
2580
	je	disallowed_combination_of_registers
2581
	cmp	al,[vex_register]
2582
	je	disallowed_combination_of_registers
2583
	mov	al,bl
2584
	shr	al,5
2585
	cmp	al,0Ch shr 1
2586
	je	gather_vr128
2587
	mov	ah,32
2588
	cmp	al,6 shr 1
2589
	jne	gather_regular
2590
	add	ah,ah
2591
      gather_regular:
2592
	mov	al,[rex_prefix]
2593
	shr	al,3
2594
	xor	al,[supplemental_code]
2595
	test	al,1
2596
	jz	gather_uniform
2597
	test	[supplemental_code],1
2598
	jz	gather_double
2599
	mov	al,ah
2600
	xchg	al,[operand_size]
2601
	add	al,al
2602
	cmp	al,ah
2603
	jne	invalid_operand_size
2604
	jmp	instruction_ready
2605
      gather_double:
2606
	add	ah,ah
2607
      gather_uniform:
2608
	cmp	ah,[operand_size]
2609
	jne	invalid_operand_size
2610
	jmp	instruction_ready
2611
      gather_vr128:
2612
	cmp	ah,16
2613
	je	instruction_ready
2614
	cmp	ah,32
2615
	jne	invalid_operand_size
2616
	test	[supplemental_code],1
2617
	jnz	invalid_operand_size
2618
	test	[rex_prefix],8
2619
	jz	invalid_operand_size
2620
	jmp	instruction_ready
2621
scatter_pd_instruction:
2622
	or	[rex_prefix],8
2623
scatter_ps_instruction:
2624
	call	setup_66_0f_38
2625
	or	[vex_required],4+8
2626
	or	[operand_flags],20h
2627
	lods	byte [esi]
4478 dunkaist 2628
	call	get_size_operator
2629
	cmp	al,'['
2630
	jne	invalid_argument
6467 dunkaist 2631
	call	get_address
4478 dunkaist 2632
	call	take_avx512_mask
6467 dunkaist 2633
	lods	byte [esi]
4478 dunkaist 2634
	cmp	al,','
2635
	jne	invalid_operand
2636
	xor	al,al
6467 dunkaist 2637
	xchg	al,[operand_size]
2638
	push	eax
2639
	call	take_avx_register
4478 dunkaist 2640
	mov	[postbyte_register],al
2641
	pop	eax
6467 dunkaist 2642
	jmp	gather_mem_size_check
2643
gatherpf_qpd_instruction:
2644
	mov	ah,0C7h
2645
	jmp	gatherpf_pd_instruction
2646
gatherpf_dpd_instruction:
2647
	mov	ah,0C6h
2648
      gatherpf_pd_instruction:
2649
	or	[rex_prefix],8
2650
	mov	cl,8
2651
	jmp	gatherpf_instruction
2652
gatherpf_qps_instruction:
2653
	mov	ah,0C7h
2654
	jmp	gatherpf_ps_instruction
2655
gatherpf_dps_instruction:
2656
	mov	ah,0C6h
2657
      gatherpf_ps_instruction:
2658
	mov	cl,4
2659
      gatherpf_instruction:
2660
	mov	[mmx_size],cl
2661
	mov	[postbyte_register],al
2662
	mov	al,ah
2663
	call	setup_66_0f_38
2664
	or	[vex_required],4+8
2665
	or	[operand_flags],20h
2666
	lods	byte [esi]
4478 dunkaist 2667
	call	get_size_operator
6467 dunkaist 2668
	cmp	al,'['
2669
	jne	invalid_argument
2670
	call	get_address
2671
	call	take_avx512_mask
2672
	mov	ah,[mmx_size]
2673
	mov	al,[operand_size]
2674
	or	al,al
2675
	jz	gatherpf_mem_size_ok
2676
	cmp	al,ah
2677
	jne	invalid_operand_size
2678
      gatherpf_mem_size_ok:
2679
	mov	[operand_size],64
2680
	mov	al,6 shr 1
2681
	cmp	ah,4
2682
	je	gatherpf_check_vsib
2683
	cmp	[supplemental_code],0C6h
2684
	jne	gatherpf_check_vsib
2685
	mov	al,0Eh shr 1
2686
      gatherpf_check_vsib:
2687
	mov	ah,bl
2688
	shr	ah,5
2689
	cmp	al,ah
2690
	jne	invalid_operand
4478 dunkaist 2691
	jmp	instruction_ready
6467 dunkaist 2692
4478 dunkaist 2693
 
2694
	mov	[base_code],0Fh
2695
	mov	[extended_code],38h
2696
	mov	[supplemental_code],0F3h
2697
	mov	[postbyte_register],al
2698
      bmi_reg:
2699
	or	[vex_required],2
6467 dunkaist 2700
	lods	byte [esi]
4478 dunkaist 2701
	call	get_size_operator
2702
	cmp	al,10h
2703
	jne	invalid_operand
2704
	lods	byte [esi]
2705
	call	convert_register
2706
	mov	[vex_register],al
2707
	lods	byte [esi]
2708
	cmp	al,','
2709
	jne	invalid_operand
2710
	lods	byte [esi]
2711
	call	get_size_operator
2712
	cmp	al,10h
2713
	je	bmi_reg_reg
2714
	cmp	al,'['
2715
	jne	invalid_argument
2716
	call	get_address
2717
	call	operand_32or64
2718
	jmp	instruction_ready
2719
      bmi_reg_reg:
2720
	lods	byte [esi]
2721
	call	convert_register
2722
	mov	bl,al
2723
	call	operand_32or64
2724
	jmp	nomem_instruction_ready
2725
      operand_32or64:
2726
	mov	al,[operand_size]
2727
	cmp	al,4
2728
	je	operand_32or64_ok
2729
	cmp	al,8
2730
	jne	invalid_operand_size
2731
	cmp	[code_type],64
2732
	jne	invalid_operand
2733
	or	[rex_prefix],8
2734
      operand_32or64_ok:
2735
	ret
2736
pdep_instruction:
2737
	mov	[opcode_prefix],0F2h
2738
	jmp	andn_instruction
2739
pext_instruction:
2740
	mov	[opcode_prefix],0F3h
2741
andn_instruction:
2742
	mov	[base_code],0Fh
2743
	mov	[extended_code],38h
2744
	mov	[supplemental_code],al
2745
	or	[vex_required],2
6467 dunkaist 2746
	lods	byte [esi]
4478 dunkaist 2747
	call	get_size_operator
2748
	cmp	al,10h
2749
	jne	invalid_operand
2750
	lods	byte [esi]
2751
	call	convert_register
2752
	mov	[postbyte_register],al
2753
	lods	byte [esi]
2754
	cmp	al,','
2755
	jne	invalid_operand
2756
	jmp	bmi_reg
2757
sarx_instruction:
2758
	mov	[opcode_prefix],0F3h
2759
	jmp	bzhi_instruction
2760
shrx_instruction:
2761
	mov	[opcode_prefix],0F2h
2762
	jmp	bzhi_instruction
2763
shlx_instruction:
2764
	mov	[opcode_prefix],66h
2765
bzhi_instruction:
2766
	mov	[base_code],0Fh
2767
	mov	[extended_code],38h
2768
	mov	[supplemental_code],al
2769
	or	[vex_required],2
6467 dunkaist 2770
	call	get_reg_mem
4478 dunkaist 2771
	jc	bzhi_reg_reg
2772
	call	get_vex_source_register
2773
	jc	invalid_operand
2774
	call	operand_32or64
2775
	jmp	instruction_ready
2776
      bzhi_reg_reg:
2777
	call	get_vex_source_register
2778
	jc	invalid_operand
2779
	call	operand_32or64
2780
	jmp	nomem_instruction_ready
2781
      get_vex_source_register:
2782
	lods	byte [esi]
2783
	cmp	al,','
2784
	jne	invalid_operand
2785
	lods	byte [esi]
2786
	call	get_size_operator
2787
	cmp	al,10h
2788
	jne	no_vex_source_register
2789
	lods	byte [esi]
2790
	call	convert_register
2791
	mov	[vex_register],al
2792
	clc
2793
	ret
2794
      no_vex_source_register:
2795
	stc
2796
	ret
2797
bextr_instruction:
2798
	mov	[base_code],0Fh
2799
	mov	[extended_code],38h
2800
	mov	[supplemental_code],al
2801
	or	[vex_required],2
6467 dunkaist 2802
	call	get_reg_mem
4478 dunkaist 2803
	jc	bextr_reg_reg
2804
	call	get_vex_source_register
2805
	jc	bextr_reg_mem_imm32
2806
	call	operand_32or64
2807
	jmp	instruction_ready
2808
      bextr_reg_reg:
2809
	call	get_vex_source_register
2810
	jc	bextr_reg_reg_imm32
2811
	call	operand_32or64
2812
	jmp	nomem_instruction_ready
2813
      setup_bextr_imm_opcode:
2814
	mov	[xop_opcode_map],0Ah
2815
	mov	[base_code],10h
2816
	call	operand_32or64
2817
	ret
2818
      bextr_reg_mem_imm32:
2819
	call	get_imm32
2820
	call	setup_bextr_imm_opcode
2821
	jmp	store_instruction_with_imm32
2822
      bextr_reg_reg_imm32:
2823
	call	get_imm32
2824
	call	setup_bextr_imm_opcode
2825
      store_nomem_instruction_with_imm32:
2826
	call	store_nomem_instruction
2827
	mov	eax,dword [value]
2828
	call	mark_relocation
2829
	stos	dword [edi]
2830
	jmp	instruction_assembled
2831
      get_imm32:
2832
	cmp	al,'('
2833
	jne	invalid_operand
2834
	push	edx ebx ecx
2835
	call	get_dword_value
2836
	mov	dword [value],eax
2837
	pop	ecx ebx edx
2838
	ret
2839
rorx_instruction:
2840
	mov	[opcode_prefix],0F2h
2841
	mov	[base_code],0Fh
2842
	mov	[extended_code],3Ah
2843
	mov	[supplemental_code],al
2844
	or	[vex_required],2
6467 dunkaist 2845
	call	get_reg_mem
4478 dunkaist 2846
	jc	rorx_reg_reg
2847
	call	operand_32or64
2848
	jmp	mmx_imm8
2849
      rorx_reg_reg:
2850
	call	operand_32or64
2851
	jmp	mmx_nomem_imm8
2852
2853
 
6467 dunkaist 2854
	mov	[xop_opcode_map],9
2855
	mov	ah,al
2856
	shr	ah,4
2857
	and	al,111b
2858
	mov	[base_code],ah
2859
	mov	[postbyte_register],al
2860
	jmp	bmi_reg
2861
4478 dunkaist 2862
 
6467 dunkaist 2863
	or	[vex_required],2
2864
	mov	[xop_opcode_map],9
2865
	mov	[base_code],12h
2866
	mov	[postbyte_register],al
2867
	lods	byte [esi]
2868
	call	get_size_operator
2869
	cmp	al,10h
2870
	jne	invalid_operand
2871
	lods	byte [esi]
2872
	call	convert_register
2873
	mov	bl,al
2874
	call	operand_32or64
2875
	jmp	nomem_instruction_ready
2876
lwpins_instruction:
2877
	or	[vex_required],2
2878
	mov	[xop_opcode_map],0Ah
2879
	mov	[base_code],12h
2880
	mov	[vex_register],al
2881
	lods	byte [esi]
2882
	call	get_size_operator
2883
	cmp	al,10h
2884
	jne	invalid_operand
2885
	lods	byte [esi]
2886
	call	convert_register
2887
	mov	[postbyte_register],al
2888
	lods	byte [esi]
2889
	cmp	al,','
2890
	jne	invalid_operand
2891
	xor	cl,cl
2892
	xchg	cl,[operand_size]
2893
	lods	byte [esi]
2894
	call	get_size_operator
2895
	cmp	al,10h
2896
	je	lwpins_reg_reg
2897
	cmp	al,'['
2898
	jne	invalid_argument
2899
	push	ecx
2900
	call	get_address
2901
	pop	eax
2902
	xchg	al,[operand_size]
2903
	test	al,al
2904
	jz	lwpins_reg_mem_size_ok
2905
	cmp	al,4
2906
	jne	invalid_operand_size
2907
      lwpins_reg_mem_size_ok:
2908
	call	prepare_lwpins
2909
	jmp	store_instruction_with_imm32
2910
      lwpins_reg_reg:
2911
	lods	byte [esi]
2912
	call	convert_register
2913
	cmp	ah,4
2914
	jne	invalid_operand_size
2915
	mov	[operand_size],cl
2916
	mov	bl,al
2917
	call	prepare_lwpins
2918
	jmp	store_nomem_instruction_with_imm32
2919
      prepare_lwpins:
2920
	lods	byte [esi]
2921
	cmp	al,','
2922
	jne	invalid_operand
2923
	lods	byte [esi]
2924
	call	get_imm32
2925
	call	operand_32or64
2926
	mov	al,[vex_register]
2927
	xchg	al,[postbyte_register]
2928
	mov	[vex_register],al
2929
	ret
2930
4478 dunkaist 2931
 
2932
	or	[operand_flags],2
6467 dunkaist 2933
	mov	[mmx_size],8
4478 dunkaist 2934
	jmp	xop_instruction_9
2935
xop_single_source_ss_instruction:
2936
	or	[operand_flags],2
6467 dunkaist 2937
	mov	[mmx_size],4
4478 dunkaist 2938
	jmp	xop_instruction_9
2939
xop_single_source_instruction:
2940
	or	[operand_flags],2
6467 dunkaist 2941
	mov	[mmx_size],0
4478 dunkaist 2942
      xop_instruction_9:
2943
	mov	[base_code],al
2944
	mov	[xop_opcode_map],9
2945
	jmp	avx_xop_common
6467 dunkaist 2946
xop_single_source_128bit_instruction:
4478 dunkaist 2947
	or	[operand_flags],2
6467 dunkaist 2948
	mov	[mmx_size],16
4478 dunkaist 2949
	jmp	xop_instruction_9
2950
xop_triple_source_128bit_instruction:
2951
	mov	[immediate_size],-1
2952
	mov	byte [value],0
2953
	mov	[mmx_size],16
2954
	jmp	xop_instruction_8
2955
xop_128bit_instruction:
2956
	mov	[immediate_size],-2
2957
	mov	byte [value],0
2958
	mov	[mmx_size],16
2959
      xop_instruction_8:
2960
	mov	[base_code],al
2961
	mov	[xop_opcode_map],8
2962
	jmp	avx_xop_common
6467 dunkaist 2963
xop_pcom_b_instruction:
4478 dunkaist 2964
	mov	ah,0CCh
2965
	jmp	xop_pcom_instruction
2966
xop_pcom_d_instruction:
2967
	mov	ah,0CEh
2968
	jmp	xop_pcom_instruction
2969
xop_pcom_q_instruction:
2970
	mov	ah,0CFh
2971
	jmp	xop_pcom_instruction
2972
xop_pcom_w_instruction:
2973
	mov	ah,0CDh
2974
	jmp	xop_pcom_instruction
2975
xop_pcom_ub_instruction:
2976
	mov	ah,0ECh
2977
	jmp	xop_pcom_instruction
2978
xop_pcom_ud_instruction:
2979
	mov	ah,0EEh
2980
	jmp	xop_pcom_instruction
2981
xop_pcom_uq_instruction:
2982
	mov	ah,0EFh
2983
	jmp	xop_pcom_instruction
2984
xop_pcom_uw_instruction:
2985
	mov	ah,0EDh
2986
      xop_pcom_instruction:
2987
	mov	byte [value],al
2988
	mov	[immediate_size],-4
6467 dunkaist 2989
	mov	[mmx_size],16
4478 dunkaist 2990
	mov	[base_code],ah
2991
	mov	[xop_opcode_map],8
2992
	jmp	avx_xop_common
6467 dunkaist 2993
vpcmov_instruction:
4478 dunkaist 2994
	or	[vex_required],2
6467 dunkaist 2995
	mov	[immediate_size],-2
4478 dunkaist 2996
	mov	byte [value],0
2997
	mov	[mmx_size],0
2998
	mov	[base_code],al
2999
	mov	[xop_opcode_map],8
3000
	jmp	avx_xop_common
6467 dunkaist 3001
xop_shift_instruction:
4478 dunkaist 3002
	mov	[base_code],al
3003
	or	[vex_required],2
6467 dunkaist 3004
	mov	[xop_opcode_map],9
4478 dunkaist 3005
	call	take_avx_register
3006
	cmp	ah,16
3007
	jne	invalid_operand
3008
	mov	[postbyte_register],al
3009
	lods	byte [esi]
3010
	cmp	al,','
3011
	jne	invalid_operand
3012
	lods	byte [esi]
3013
	call	get_size_operator
3014
	cmp	al,'['
3015
	je	xop_shift_reg_mem
3016
	cmp	al,10h
3017
	jne	invalid_operand
3018
	lods	byte [esi]
3019
	call	convert_xmm_register
3020
	mov	[vex_register],al
3021
	lods	byte [esi]
3022
	cmp	al,','
3023
	jne	invalid_operand
3024
	push	esi
3025
	xor	cl,cl
3026
	xchg	cl,[operand_size]
3027
	lods	byte [esi]
3028
	call	get_size_operator
3029
	pop	esi
3030
	xchg	cl,[operand_size]
3031
	cmp	al,'['
3032
	je	xop_shift_reg_reg_mem
3033
	cmp	al,10h
3034
	jne	xop_shift_reg_reg_imm
3035
	call	take_avx_register
3036
	mov	bl,al
3037
	xchg	bl,[vex_register]
3038
	jmp	nomem_instruction_ready
3039
      xop_shift_reg_reg_mem:
3040
	or	[rex_prefix],8
3041
	lods	byte [esi]
3042
	call	get_size_operator
3043
	call	get_address
3044
	jmp	instruction_ready
3045
      xop_shift_reg_reg_imm:
3046
	xor	bl,bl
3047
	xchg	bl,[vex_register]
3048
	cmp	[base_code],94h
3049
	jae	invalid_operand
3050
	add	[base_code],30h
3051
	mov	[xop_opcode_map],8
3052
	dec	esi
3053
	jmp	mmx_nomem_imm8
3054
      xop_shift_reg_mem:
3055
	call	get_address
3056
	lods	byte [esi]
3057
	cmp	al,','
3058
	jne	invalid_operand
3059
	push	esi
3060
	xor	cl,cl
3061
	xchg	cl,[operand_size]
3062
	lods	byte [esi]
3063
	call	get_size_operator
3064
	pop	esi
3065
	xchg	cl,[operand_size]
3066
	cmp	al,10h
3067
	jne	xop_shift_reg_mem_imm
3068
	call	take_avx_register
3069
	mov	[vex_register],al
3070
	jmp	instruction_ready
3071
      xop_shift_reg_mem_imm:
3072
	cmp	[base_code],94h
3073
	jae	invalid_operand
3074
	add	[base_code],30h
3075
	mov	[xop_opcode_map],8
3076
	dec	esi
3077
	jmp	mmx_imm8
3078
3079
 
6467 dunkaist 3080
	mov	[evex_mode],al
3081
	jmp	instruction_assembled
3082
4478 dunkaist 3083
 
3084
	lods	byte [esi]
3085
	call	get_size_operator
3086
	cmp	al,10h
3087
	jne	invalid_operand
3088
	lods	byte [esi]
3089
convert_avx_register:
3090
	mov	ah,al
3091
	and	al,1Fh
6467 dunkaist 3092
	and	ah,0E0h
3093
	sub	ah,60h
3094
	jb	invalid_operand
3095
	jz	avx512_register_size
3096
	sub	ah,60h
3097
	jb	invalid_operand
3098
	jnz	avx_register_size_ok
3099
	mov	ah,16
3100
	jmp	avx_register_size_ok
3101
      avx512_register_size:
3102
	mov	ah,64
3103
      avx_register_size_ok:
3104
	cmp	al,8
4478 dunkaist 3105
	jb	match_register_size
3106
	cmp	[code_type],64
3107
	jne	invalid_operand
3108
	jmp	match_register_size
3109
store_vex_instruction_code:
3110
	test	[rex_prefix],10h
6467 dunkaist 3111
	jnz	invalid_operand
3112
	test	[vex_required],0F8h
3113
	jnz	store_evex_instruction_code
3114
	test	[vex_register],10000b
3115
	jnz	store_evex_instruction_code
3116
	cmp	[operand_size],64
3117
	je	store_evex_instruction_code
3118
	mov	al,[base_code]
4478 dunkaist 3119
	cmp	al,0Fh
3120
	jne	store_xop_instruction_code
3121
	test	[vex_required],2
6467 dunkaist 3122
	jnz	prepare_vex
3123
	cmp	[evex_mode],0
3124
	je	prepare_vex
3125
	cmp	[displacement_compression],1
3126
	jne	prepare_vex
3127
	cmp	edx,80h
3128
	jb	prepare_vex
3129
	cmp	edx,-80h
3130
	jae	prepare_vex
3131
	mov	al,bl
3132
	or	al,bh
3133
	shr	al,4
3134
	cmp	al,2
3135
	je	prepare_vex
3136
	call	compress_displacement
3137
	cmp	[displacement_compression],2
3138
	ja	prepare_evex
3139
	jb	prepare_vex
3140
	dec	[displacement_compression]
3141
	mov	edx,[uncompressed_displacement]
3142
      prepare_vex:
3143
	mov	ah,[extended_code]
4478 dunkaist 3144
	cmp	ah,38h
3145
	je	store_vex_0f38_instruction_code
3146
	cmp	ah,3Ah
3147
	je	store_vex_0f3a_instruction_code
3148
	test	[rex_prefix],1011b
3149
	jnz	store_vex_0f_instruction_code
3150
	mov	[edi+2],ah
3151
	mov	byte [edi],0C5h
3152
	mov	al,[vex_register]
3153
	not	al
3154
	shl	al,3
3155
	mov	ah,[rex_prefix]
3156
	shl	ah,5
3157
	and	ah,80h
3158
	xor	al,ah
3159
	call	get_vex_lpp_bits
3160
	mov	[edi+1],al
3161
	call	check_vex
3162
	add	edi,3
3163
	ret
3164
      get_vex_lpp_bits:
3165
	cmp	[operand_size],32
3166
	jne	get_vex_pp_bits
6467 dunkaist 3167
	or	al,100b
4478 dunkaist 3168
      get_vex_pp_bits:
6467 dunkaist 3169
	mov	ah,[opcode_prefix]
4478 dunkaist 3170
	cmp	ah,66h
3171
	je	vex_66
3172
	cmp	ah,0F3h
3173
	je	vex_f3
3174
	cmp	ah,0F2h
3175
	je	vex_f2
3176
	test	ah,ah
3177
	jnz	disallowed_combination_of_registers
3178
	ret
3179
      vex_f2:
3180
	or	al,11b
3181
	ret
3182
      vex_f3:
3183
	or	al,10b
3184
	ret
3185
      vex_66:
3186
	or	al,1
3187
	ret
3188
      store_vex_0f38_instruction_code:
3189
	mov	al,11100010b
3190
	mov	ah,[supplemental_code]
3191
	jmp	make_c4_vex
3192
      store_vex_0f3a_instruction_code:
3193
	mov	al,11100011b
3194
	mov	ah,[supplemental_code]
3195
	jmp	make_c4_vex
3196
      store_vex_0f_instruction_code:
3197
	mov	al,11100001b
3198
      make_c4_vex:
3199
	mov	[edi+3],ah
3200
	mov	byte [edi],0C4h
3201
	mov	ah,[rex_prefix]
3202
	shl	ah,5
3203
	xor	al,ah
3204
	mov	[edi+1],al
3205
	call	check_vex
3206
	mov	al,[vex_register]
3207
	xor	al,1111b
3208
	shl	al,3
3209
	mov	ah,[rex_prefix]
3210
	shl	ah,4
3211
	and	ah,80h
3212
	or	al,ah
3213
	call	get_vex_lpp_bits
3214
	mov	[edi+2],al
3215
	add	edi,4
3216
	ret
3217
      check_vex:
3218
	cmp	[code_type],64
3219
	je	vex_ok
3220
	not	al
3221
	test	al,11000000b
3222
	jnz	invalid_operand
3223
	test	[rex_prefix],40h
3224
	jnz	invalid_operand
3225
      vex_ok:
3226
	ret
3227
store_xop_instruction_code:
3228
	mov	[edi+3],al
3229
	mov	byte [edi],8Fh
3230
	mov	al,[xop_opcode_map]
3231
	mov	ah,[rex_prefix]
3232
	test	ah,40h
3233
	jz	xop_ok
3234
	cmp	[code_type],64
3235
	jne	invalid_operand
3236
      xop_ok:
3237
	not	ah
3238
	shl	ah,5
3239
	xor	al,ah
3240
	mov	[edi+1],al
3241
	mov	al,[vex_register]
3242
	xor	al,1111b
3243
	shl	al,3
3244
	mov	ah,[rex_prefix]
3245
	shl	ah,4
3246
	and	ah,80h
3247
	or	al,ah
3248
	call	get_vex_lpp_bits
3249
	mov	[edi+2],al
3250
	add	edi,4
3251
	ret
3252
store_evex_instruction_code:
6467 dunkaist 3253
	test	[vex_required],2
3254
	jnz	invalid_operand
3255
	cmp	[base_code],0Fh
3256
	jne	invalid_operand
3257
	cmp	[displacement_compression],1
3258
	jne	prepare_evex
3259
	call	compress_displacement
3260
      prepare_evex:
3261
	mov	ah,[extended_code]
3262
	cmp	ah,38h
3263
	je	store_evex_0f38_instruction_code
3264
	cmp	ah,3Ah
3265
	je	store_evex_0f3a_instruction_code
3266
	mov	al,11110001b
3267
      make_evex:
3268
	mov	[edi+4],ah
3269
	mov	byte [edi],62h
3270
	mov	ah,[rex_prefix]
3271
	shl	ah,5
3272
	xor	al,ah
3273
	mov	ah,[vex_required]
3274
	and	ah,10h
3275
	xor	al,ah
3276
	mov	[edi+1],al
3277
	call	check_vex
3278
	mov	al,[vex_register]
3279
	not	al
3280
	and	al,1111b
3281
	shl	al,3
3282
	mov	ah,[rex_prefix]
3283
	shl	ah,4
3284
	or	ah,[rex_prefix]
3285
	and	ah,80h
3286
	or	al,ah
3287
	or	al,100b
3288
	call	get_vex_pp_bits
3289
	mov	[edi+2],al
3290
	mov	al,[vex_register]
3291
	not	al
3292
	shr	al,1
3293
	and	al,1000b
3294
	test	[vex_required],80h
3295
	jne	evex_rounding
3296
	mov	ah,[operand_size]
3297
	cmp	ah,16
3298
	jbe	evex_l_ok
3299
	or	al,ah
3300
	jmp	evex_l_ok
3301
      evex_rounding:
3302
	mov	ah,[rounding_mode]
3303
	shl	ah,5
3304
	or	al,ah
3305
      evex_l_ok:
3306
	test	[vex_required],20h
3307
	jz	evex_zaaa_ok
3308
	or	al,[mask_register]
3309
      evex_zaaa_ok:
3310
	test	[vex_required],40h
3311
	jz	evex_b_ok
3312
	or	al,10h
3313
      evex_b_ok:
3314
	mov	[edi+3],al
3315
	add	edi,5
3316
	ret
3317
      store_evex_0f38_instruction_code:
3318
	mov	al,11110010b
3319
	mov	ah,[supplemental_code]
3320
	jmp	make_evex
3321
      store_evex_0f3a_instruction_code:
3322
	mov	al,11110011b
3323
	mov	ah,[supplemental_code]
3324
	jmp	make_evex
3325
compress_displacement:
3326
	mov	ebp,ecx
3327
	mov	[uncompressed_displacement],edx
3328
	or	edx,edx
3329
	jz	displacement_compressed
3330
	xor	ecx,ecx
3331
	mov	cl,[mmx_size]
3332
	test	cl,cl
3333
	jnz	calculate_displacement_scale
3334
	mov	cl,[operand_size]
3335
      calculate_displacement_scale:
3336
	bsf	ecx,ecx
3337
	jz	displacement_compression_ok
3338
	xor	eax,eax
3339
	shrd	eax,edx,cl
3340
	jnz	displacement_not_compressed
3341
	sar	edx,cl
3342
	cmp	edx,80h
3343
	jb	displacement_compressed
3344
	cmp	edx,-80h
3345
	jnb	displacement_compressed
3346
	shl	edx,cl
3347
      displacement_not_compressed:
3348
	inc	[displacement_compression]
3349
	jmp	displacement_compression_ok
3350
      displacement_compressed:
3351
	add	[displacement_compression],2
3352
      displacement_compression_ok:
3353
	mov	ecx,ebp
3354
	ret
3355