balloon: Don't balloon roms
[qemu.git] / disas / i386.c
1 /* opcodes/i386-dis.c r1.126 */
2 /* Print i386 instructions for GDB, the GNU debugger.
3 Copyright 1988, 1989, 1991, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
4 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
5
6 This file is part of GDB.
7
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, see <http://www.gnu.org/licenses/>. */
20
21 /* 80386 instruction printer by Pace Willisson (pace@prep.ai.mit.edu)
22 July 1988
23 modified by John Hassey (hassey@dg-rtp.dg.com)
24 x86-64 support added by Jan Hubicka (jh@suse.cz)
25 VIA PadLock support by Michal Ludvig (mludvig@suse.cz). */
26
27 /* The main tables describing the instructions is essentially a copy
28 of the "Opcode Map" chapter (Appendix A) of the Intel 80386
29 Programmers Manual. Usually, there is a capital letter, followed
30 by a small letter. The capital letter tell the addressing mode,
31 and the small letter tells about the operand size. Refer to
32 the Intel manual for details. */
33
34 #include "qemu/osdep.h"
35 #include "disas/bfd.h"
36 #include "qemu/cutils.h"
37
38 /* include/opcode/i386.h r1.78 */
39
40 /* opcode/i386.h -- Intel 80386 opcode macros
41 Copyright 1989, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
42 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007
43 Free Software Foundation, Inc.
44
45 This file is part of GAS, the GNU Assembler, and GDB, the GNU Debugger.
46
47 This program is free software; you can redistribute it and/or modify
48 it under the terms of the GNU General Public License as published by
49 the Free Software Foundation; either version 2 of the License, or
50 (at your option) any later version.
51
52 This program is distributed in the hope that it will be useful,
53 but WITHOUT ANY WARRANTY; without even the implied warranty of
54 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
55 GNU General Public License for more details.
56
57 You should have received a copy of the GNU General Public License
58 along with this program; if not, see <http://www.gnu.org/licenses/>. */
59
60 /* The SystemV/386 SVR3.2 assembler, and probably all AT&T derived
61 ix86 Unix assemblers, generate floating point instructions with
62 reversed source and destination registers in certain cases.
63 Unfortunately, gcc and possibly many other programs use this
64 reversed syntax, so we're stuck with it.
65
66 eg. `fsub %st(3),%st' results in st = st - st(3) as expected, but
67 `fsub %st,%st(3)' results in st(3) = st - st(3), rather than
68 the expected st(3) = st(3) - st
69
70 This happens with all the non-commutative arithmetic floating point
71 operations with two register operands, where the source register is
72 %st, and destination register is %st(i).
73
74 The affected opcode map is dceX, dcfX, deeX, defX. */
75
76 #ifndef SYSV386_COMPAT
77 /* Set non-zero for broken, compatible instructions. Set to zero for
78 non-broken opcodes at your peril. gcc generates SystemV/386
79 compatible instructions. */
80 #define SYSV386_COMPAT 1
81 #endif
82 #ifndef OLDGCC_COMPAT
83 /* Set non-zero to cater for old (<= 2.8.1) versions of gcc that could
84 generate nonsense fsubp, fsubrp, fdivp and fdivrp with operands
85 reversed. */
86 #define OLDGCC_COMPAT SYSV386_COMPAT
87 #endif
88
89 #define MOV_AX_DISP32 0xa0
90 #define POP_SEG_SHORT 0x07
91 #define JUMP_PC_RELATIVE 0xeb
92 #define INT_OPCODE 0xcd
93 #define INT3_OPCODE 0xcc
94 /* The opcode for the fwait instruction, which disassembler treats as a
95 prefix when it can. */
96 #define FWAIT_OPCODE 0x9b
97 #define ADDR_PREFIX_OPCODE 0x67
98 #define DATA_PREFIX_OPCODE 0x66
99 #define LOCK_PREFIX_OPCODE 0xf0
100 #define CS_PREFIX_OPCODE 0x2e
101 #define DS_PREFIX_OPCODE 0x3e
102 #define ES_PREFIX_OPCODE 0x26
103 #define FS_PREFIX_OPCODE 0x64
104 #define GS_PREFIX_OPCODE 0x65
105 #define SS_PREFIX_OPCODE 0x36
106 #define REPNE_PREFIX_OPCODE 0xf2
107 #define REPE_PREFIX_OPCODE 0xf3
108
109 #define TWO_BYTE_OPCODE_ESCAPE 0x0f
110 #define NOP_OPCODE (char) 0x90
111
112 /* register numbers */
113 #define EBP_REG_NUM 5
114 #define ESP_REG_NUM 4
115
116 /* modrm_byte.regmem for twobyte escape */
117 #define ESCAPE_TO_TWO_BYTE_ADDRESSING ESP_REG_NUM
118 /* index_base_byte.index for no index register addressing */
119 #define NO_INDEX_REGISTER ESP_REG_NUM
120 /* index_base_byte.base for no base register addressing */
121 #define NO_BASE_REGISTER EBP_REG_NUM
122 #define NO_BASE_REGISTER_16 6
123
124 /* modrm.mode = REGMEM_FIELD_HAS_REG when a register is in there */
125 #define REGMEM_FIELD_HAS_REG 0x3/* always = 0x3 */
126 #define REGMEM_FIELD_HAS_MEM (~REGMEM_FIELD_HAS_REG)
127
128 /* x86-64 extension prefix. */
129 #define REX_OPCODE 0x40
130
131 /* Indicates 64 bit operand size. */
132 #define REX_W 8
133 /* High extension to reg field of modrm byte. */
134 #define REX_R 4
135 /* High extension to SIB index field. */
136 #define REX_X 2
137 /* High extension to base field of modrm or SIB, or reg field of opcode. */
138 #define REX_B 1
139
140 /* max operands per insn */
141 #define MAX_OPERANDS 4
142
143 /* max immediates per insn (lcall, ljmp, insertq, extrq) */
144 #define MAX_IMMEDIATE_OPERANDS 2
145
146 /* max memory refs per insn (string ops) */
147 #define MAX_MEMORY_OPERANDS 2
148
149 /* max size of insn mnemonics. */
150 #define MAX_MNEM_SIZE 16
151
152 /* max size of register name in insn mnemonics. */
153 #define MAX_REG_NAME_SIZE 8
154
155 /* opcodes/i386-dis.c r1.126 */
156 #include "qemu-common.h"
157
158 static int fetch_data2(struct disassemble_info *, bfd_byte *);
159 static int fetch_data(struct disassemble_info *, bfd_byte *);
160 static void ckprefix (void);
161 static const char *prefix_name (int, int);
162 static int print_insn (bfd_vma, disassemble_info *);
163 static void dofloat (int);
164 static void OP_ST (int, int);
165 static void OP_STi (int, int);
166 static int putop (const char *, int);
167 static void oappend (const char *);
168 static void append_seg (void);
169 static void OP_indirE (int, int);
170 static void print_operand_value (char *buf, size_t bufsize, int hex, bfd_vma disp);
171 static void print_displacement (char *, bfd_vma);
172 static void OP_E (int, int);
173 static void OP_G (int, int);
174 static void OP_vvvv (int, int);
175 static bfd_vma get64 (void);
176 static bfd_signed_vma get32 (void);
177 static bfd_signed_vma get32s (void);
178 static int get16 (void);
179 static void set_op (bfd_vma, int);
180 static void OP_REG (int, int);
181 static void OP_IMREG (int, int);
182 static void OP_I (int, int);
183 static void OP_I64 (int, int);
184 static void OP_sI (int, int);
185 static void OP_J (int, int);
186 static void OP_SEG (int, int);
187 static void OP_DIR (int, int);
188 static void OP_OFF (int, int);
189 static void OP_OFF64 (int, int);
190 static void ptr_reg (int, int);
191 static void OP_ESreg (int, int);
192 static void OP_DSreg (int, int);
193 static void OP_C (int, int);
194 static void OP_D (int, int);
195 static void OP_T (int, int);
196 static void OP_R (int, int);
197 static void OP_MMX (int, int);
198 static void OP_XMM (int, int);
199 static void OP_EM (int, int);
200 static void OP_EX (int, int);
201 static void OP_EMC (int,int);
202 static void OP_MXC (int,int);
203 static void OP_MS (int, int);
204 static void OP_XS (int, int);
205 static void OP_M (int, int);
206 static void OP_VMX (int, int);
207 static void OP_0fae (int, int);
208 static void OP_0f07 (int, int);
209 static void NOP_Fixup1 (int, int);
210 static void NOP_Fixup2 (int, int);
211 static void OP_3DNowSuffix (int, int);
212 static void OP_SIMD_Suffix (int, int);
213 static void SIMD_Fixup (int, int);
214 static void PNI_Fixup (int, int);
215 static void SVME_Fixup (int, int);
216 static void INVLPG_Fixup (int, int);
217 static void BadOp (void);
218 static void VMX_Fixup (int, int);
219 static void REP_Fixup (int, int);
220 static void CMPXCHG8B_Fixup (int, int);
221 static void XMM_Fixup (int, int);
222 static void CRC32_Fixup (int, int);
223
224 struct dis_private {
225 /* Points to first byte not fetched. */
226 bfd_byte *max_fetched;
227 bfd_byte the_buffer[MAX_MNEM_SIZE];
228 bfd_vma insn_start;
229 int orig_sizeflag;
230 sigjmp_buf bailout;
231 };
232
233 enum address_mode
234 {
235 mode_16bit,
236 mode_32bit,
237 mode_64bit
238 };
239
240 static enum address_mode address_mode;
241
242 /* Flags for the prefixes for the current instruction. See below. */
243 static int prefixes;
244
245 /* REX prefix the current instruction. See below. */
246 static int rex;
247 /* Bits of REX we've already used. */
248 static int rex_used;
249 /* Mark parts used in the REX prefix. When we are testing for
250 empty prefix (for 8bit register REX extension), just mask it
251 out. Otherwise test for REX bit is excuse for existence of REX
252 only in case value is nonzero. */
253 #define USED_REX(value) \
254 { \
255 if (value) \
256 { \
257 if ((rex & value)) \
258 rex_used |= (value) | REX_OPCODE; \
259 } \
260 else \
261 rex_used |= REX_OPCODE; \
262 }
263
264 /* Flags for prefixes which we somehow handled when printing the
265 current instruction. */
266 static int used_prefixes;
267
268 /* The VEX.vvvv register, unencoded. */
269 static int vex_reg;
270
271 /* Flags stored in PREFIXES. */
272 #define PREFIX_REPZ 1
273 #define PREFIX_REPNZ 2
274 #define PREFIX_LOCK 4
275 #define PREFIX_CS 8
276 #define PREFIX_SS 0x10
277 #define PREFIX_DS 0x20
278 #define PREFIX_ES 0x40
279 #define PREFIX_FS 0x80
280 #define PREFIX_GS 0x100
281 #define PREFIX_DATA 0x200
282 #define PREFIX_ADDR 0x400
283 #define PREFIX_FWAIT 0x800
284
285 #define PREFIX_VEX_0F 0x1000
286 #define PREFIX_VEX_0F38 0x2000
287 #define PREFIX_VEX_0F3A 0x4000
288
289 /* Make sure that bytes from INFO->PRIVATE_DATA->BUFFER (inclusive)
290 to ADDR (exclusive) are valid. Returns 1 for success, longjmps
291 on error. */
292 static int
293 fetch_data2(struct disassemble_info *info, bfd_byte *addr)
294 {
295 int status;
296 struct dis_private *priv = (struct dis_private *) info->private_data;
297 bfd_vma start = priv->insn_start + (priv->max_fetched - priv->the_buffer);
298
299 if (addr <= priv->the_buffer + MAX_MNEM_SIZE)
300 status = (*info->read_memory_func) (start,
301 priv->max_fetched,
302 addr - priv->max_fetched,
303 info);
304 else
305 status = -1;
306 if (status != 0)
307 {
308 /* If we did manage to read at least one byte, then
309 print_insn_i386 will do something sensible. Otherwise, print
310 an error. We do that here because this is where we know
311 STATUS. */
312 if (priv->max_fetched == priv->the_buffer)
313 (*info->memory_error_func) (status, start, info);
314 siglongjmp(priv->bailout, 1);
315 }
316 else
317 priv->max_fetched = addr;
318 return 1;
319 }
320
321 static int
322 fetch_data(struct disassemble_info *info, bfd_byte *addr)
323 {
324 if (addr <= ((struct dis_private *) (info->private_data))->max_fetched) {
325 return 1;
326 } else {
327 return fetch_data2(info, addr);
328 }
329 }
330
331
332 #define XX { NULL, 0 }
333
334 #define Bv { OP_vvvv, v_mode }
335 #define Eb { OP_E, b_mode }
336 #define Ev { OP_E, v_mode }
337 #define Ed { OP_E, d_mode }
338 #define Edq { OP_E, dq_mode }
339 #define Edqw { OP_E, dqw_mode }
340 #define Edqb { OP_E, dqb_mode }
341 #define Edqd { OP_E, dqd_mode }
342 #define indirEv { OP_indirE, stack_v_mode }
343 #define indirEp { OP_indirE, f_mode }
344 #define stackEv { OP_E, stack_v_mode }
345 #define Em { OP_E, m_mode }
346 #define Ew { OP_E, w_mode }
347 #define M { OP_M, 0 } /* lea, lgdt, etc. */
348 #define Ma { OP_M, v_mode }
349 #define Mp { OP_M, f_mode } /* 32 or 48 bit memory operand for LDS, LES etc */
350 #define Mq { OP_M, q_mode }
351 #define Gb { OP_G, b_mode }
352 #define Gv { OP_G, v_mode }
353 #define Gd { OP_G, d_mode }
354 #define Gdq { OP_G, dq_mode }
355 #define Gm { OP_G, m_mode }
356 #define Gw { OP_G, w_mode }
357 #define Rd { OP_R, d_mode }
358 #define Rm { OP_R, m_mode }
359 #define Ib { OP_I, b_mode }
360 #define sIb { OP_sI, b_mode } /* sign extended byte */
361 #define Iv { OP_I, v_mode }
362 #define Iq { OP_I, q_mode }
363 #define Iv64 { OP_I64, v_mode }
364 #define Iw { OP_I, w_mode }
365 #define I1 { OP_I, const_1_mode }
366 #define Jb { OP_J, b_mode }
367 #define Jv { OP_J, v_mode }
368 #define Cm { OP_C, m_mode }
369 #define Dm { OP_D, m_mode }
370 #define Td { OP_T, d_mode }
371
372 #define RMeAX { OP_REG, eAX_reg }
373 #define RMeBX { OP_REG, eBX_reg }
374 #define RMeCX { OP_REG, eCX_reg }
375 #define RMeDX { OP_REG, eDX_reg }
376 #define RMeSP { OP_REG, eSP_reg }
377 #define RMeBP { OP_REG, eBP_reg }
378 #define RMeSI { OP_REG, eSI_reg }
379 #define RMeDI { OP_REG, eDI_reg }
380 #define RMrAX { OP_REG, rAX_reg }
381 #define RMrBX { OP_REG, rBX_reg }
382 #define RMrCX { OP_REG, rCX_reg }
383 #define RMrDX { OP_REG, rDX_reg }
384 #define RMrSP { OP_REG, rSP_reg }
385 #define RMrBP { OP_REG, rBP_reg }
386 #define RMrSI { OP_REG, rSI_reg }
387 #define RMrDI { OP_REG, rDI_reg }
388 #define RMAL { OP_REG, al_reg }
389 #define RMAL { OP_REG, al_reg }
390 #define RMCL { OP_REG, cl_reg }
391 #define RMDL { OP_REG, dl_reg }
392 #define RMBL { OP_REG, bl_reg }
393 #define RMAH { OP_REG, ah_reg }
394 #define RMCH { OP_REG, ch_reg }
395 #define RMDH { OP_REG, dh_reg }
396 #define RMBH { OP_REG, bh_reg }
397 #define RMAX { OP_REG, ax_reg }
398 #define RMDX { OP_REG, dx_reg }
399
400 #define eAX { OP_IMREG, eAX_reg }
401 #define eBX { OP_IMREG, eBX_reg }
402 #define eCX { OP_IMREG, eCX_reg }
403 #define eDX { OP_IMREG, eDX_reg }
404 #define eSP { OP_IMREG, eSP_reg }
405 #define eBP { OP_IMREG, eBP_reg }
406 #define eSI { OP_IMREG, eSI_reg }
407 #define eDI { OP_IMREG, eDI_reg }
408 #define AL { OP_IMREG, al_reg }
409 #define CL { OP_IMREG, cl_reg }
410 #define DL { OP_IMREG, dl_reg }
411 #define BL { OP_IMREG, bl_reg }
412 #define AH { OP_IMREG, ah_reg }
413 #define CH { OP_IMREG, ch_reg }
414 #define DH { OP_IMREG, dh_reg }
415 #define BH { OP_IMREG, bh_reg }
416 #define AX { OP_IMREG, ax_reg }
417 #define DX { OP_IMREG, dx_reg }
418 #define zAX { OP_IMREG, z_mode_ax_reg }
419 #define indirDX { OP_IMREG, indir_dx_reg }
420
421 #define Sw { OP_SEG, w_mode }
422 #define Sv { OP_SEG, v_mode }
423 #define Ap { OP_DIR, 0 }
424 #define Ob { OP_OFF64, b_mode }
425 #define Ov { OP_OFF64, v_mode }
426 #define Xb { OP_DSreg, eSI_reg }
427 #define Xv { OP_DSreg, eSI_reg }
428 #define Xz { OP_DSreg, eSI_reg }
429 #define Yb { OP_ESreg, eDI_reg }
430 #define Yv { OP_ESreg, eDI_reg }
431 #define DSBX { OP_DSreg, eBX_reg }
432
433 #define es { OP_REG, es_reg }
434 #define ss { OP_REG, ss_reg }
435 #define cs { OP_REG, cs_reg }
436 #define ds { OP_REG, ds_reg }
437 #define fs { OP_REG, fs_reg }
438 #define gs { OP_REG, gs_reg }
439
440 #define MX { OP_MMX, 0 }
441 #define XM { OP_XMM, 0 }
442 #define EM { OP_EM, v_mode }
443 #define EMd { OP_EM, d_mode }
444 #define EMq { OP_EM, q_mode }
445 #define EXd { OP_EX, d_mode }
446 #define EXq { OP_EX, q_mode }
447 #define EXx { OP_EX, x_mode }
448 #define MS { OP_MS, v_mode }
449 #define XS { OP_XS, v_mode }
450 #define EMC { OP_EMC, v_mode }
451 #define MXC { OP_MXC, 0 }
452 #define VM { OP_VMX, q_mode }
453 #define OPSUF { OP_3DNowSuffix, 0 }
454 #define OPSIMD { OP_SIMD_Suffix, 0 }
455 #define XMM0 { XMM_Fixup, 0 }
456
457 /* Used handle "rep" prefix for string instructions. */
458 #define Xbr { REP_Fixup, eSI_reg }
459 #define Xvr { REP_Fixup, eSI_reg }
460 #define Ybr { REP_Fixup, eDI_reg }
461 #define Yvr { REP_Fixup, eDI_reg }
462 #define Yzr { REP_Fixup, eDI_reg }
463 #define indirDXr { REP_Fixup, indir_dx_reg }
464 #define ALr { REP_Fixup, al_reg }
465 #define eAXr { REP_Fixup, eAX_reg }
466
467 #define cond_jump_flag { NULL, cond_jump_mode }
468 #define loop_jcxz_flag { NULL, loop_jcxz_mode }
469
470 /* bits in sizeflag */
471 #define SUFFIX_ALWAYS 4
472 #define AFLAG 2
473 #define DFLAG 1
474
475 #define b_mode 1 /* byte operand */
476 #define v_mode 2 /* operand size depends on prefixes */
477 #define w_mode 3 /* word operand */
478 #define d_mode 4 /* double word operand */
479 #define q_mode 5 /* quad word operand */
480 #define t_mode 6 /* ten-byte operand */
481 #define x_mode 7 /* 16-byte XMM operand */
482 #define m_mode 8 /* d_mode in 32bit, q_mode in 64bit mode. */
483 #define cond_jump_mode 9
484 #define loop_jcxz_mode 10
485 #define dq_mode 11 /* operand size depends on REX prefixes. */
486 #define dqw_mode 12 /* registers like dq_mode, memory like w_mode. */
487 #define f_mode 13 /* 4- or 6-byte pointer operand */
488 #define const_1_mode 14
489 #define stack_v_mode 15 /* v_mode for stack-related opcodes. */
490 #define z_mode 16 /* non-quad operand size depends on prefixes */
491 #define o_mode 17 /* 16-byte operand */
492 #define dqb_mode 18 /* registers like dq_mode, memory like b_mode. */
493 #define dqd_mode 19 /* registers like dq_mode, memory like d_mode. */
494
495 #define es_reg 100
496 #define cs_reg 101
497 #define ss_reg 102
498 #define ds_reg 103
499 #define fs_reg 104
500 #define gs_reg 105
501
502 #define eAX_reg 108
503 #define eCX_reg 109
504 #define eDX_reg 110
505 #define eBX_reg 111
506 #define eSP_reg 112
507 #define eBP_reg 113
508 #define eSI_reg 114
509 #define eDI_reg 115
510
511 #define al_reg 116
512 #define cl_reg 117
513 #define dl_reg 118
514 #define bl_reg 119
515 #define ah_reg 120
516 #define ch_reg 121
517 #define dh_reg 122
518 #define bh_reg 123
519
520 #define ax_reg 124
521 #define cx_reg 125
522 #define dx_reg 126
523 #define bx_reg 127
524 #define sp_reg 128
525 #define bp_reg 129
526 #define si_reg 130
527 #define di_reg 131
528
529 #define rAX_reg 132
530 #define rCX_reg 133
531 #define rDX_reg 134
532 #define rBX_reg 135
533 #define rSP_reg 136
534 #define rBP_reg 137
535 #define rSI_reg 138
536 #define rDI_reg 139
537
538 #define z_mode_ax_reg 149
539 #define indir_dx_reg 150
540
541 #define FLOATCODE 1
542 #define USE_GROUPS 2
543 #define USE_PREFIX_USER_TABLE 3
544 #define X86_64_SPECIAL 4
545 #define IS_3BYTE_OPCODE 5
546
547 #define FLOAT NULL, { { NULL, FLOATCODE } }
548
549 #define GRP1a NULL, { { NULL, USE_GROUPS }, { NULL, 0 } }
550 #define GRP1b NULL, { { NULL, USE_GROUPS }, { NULL, 1 } }
551 #define GRP1S NULL, { { NULL, USE_GROUPS }, { NULL, 2 } }
552 #define GRP1Ss NULL, { { NULL, USE_GROUPS }, { NULL, 3 } }
553 #define GRP2b NULL, { { NULL, USE_GROUPS }, { NULL, 4 } }
554 #define GRP2S NULL, { { NULL, USE_GROUPS }, { NULL, 5 } }
555 #define GRP2b_one NULL, { { NULL, USE_GROUPS }, { NULL, 6 } }
556 #define GRP2S_one NULL, { { NULL, USE_GROUPS }, { NULL, 7 } }
557 #define GRP2b_cl NULL, { { NULL, USE_GROUPS }, { NULL, 8 } }
558 #define GRP2S_cl NULL, { { NULL, USE_GROUPS }, { NULL, 9 } }
559 #define GRP3b NULL, { { NULL, USE_GROUPS }, { NULL, 10 } }
560 #define GRP3S NULL, { { NULL, USE_GROUPS }, { NULL, 11 } }
561 #define GRP4 NULL, { { NULL, USE_GROUPS }, { NULL, 12 } }
562 #define GRP5 NULL, { { NULL, USE_GROUPS }, { NULL, 13 } }
563 #define GRP6 NULL, { { NULL, USE_GROUPS }, { NULL, 14 } }
564 #define GRP7 NULL, { { NULL, USE_GROUPS }, { NULL, 15 } }
565 #define GRP8 NULL, { { NULL, USE_GROUPS }, { NULL, 16 } }
566 #define GRP9 NULL, { { NULL, USE_GROUPS }, { NULL, 17 } }
567 #define GRP11_C6 NULL, { { NULL, USE_GROUPS }, { NULL, 18 } }
568 #define GRP11_C7 NULL, { { NULL, USE_GROUPS }, { NULL, 19 } }
569 #define GRP12 NULL, { { NULL, USE_GROUPS }, { NULL, 20 } }
570 #define GRP13 NULL, { { NULL, USE_GROUPS }, { NULL, 21 } }
571 #define GRP14 NULL, { { NULL, USE_GROUPS }, { NULL, 22 } }
572 #define GRP15 NULL, { { NULL, USE_GROUPS }, { NULL, 23 } }
573 #define GRP16 NULL, { { NULL, USE_GROUPS }, { NULL, 24 } }
574 #define GRPAMD NULL, { { NULL, USE_GROUPS }, { NULL, 25 } }
575 #define GRPPADLCK1 NULL, { { NULL, USE_GROUPS }, { NULL, 26 } }
576 #define GRPPADLCK2 NULL, { { NULL, USE_GROUPS }, { NULL, 27 } }
577
578 #define PREGRP0 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 0 } }
579 #define PREGRP1 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 1 } }
580 #define PREGRP2 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 2 } }
581 #define PREGRP3 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 3 } }
582 #define PREGRP4 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 4 } }
583 #define PREGRP5 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 5 } }
584 #define PREGRP6 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 6 } }
585 #define PREGRP7 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 7 } }
586 #define PREGRP8 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 8 } }
587 #define PREGRP9 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 9 } }
588 #define PREGRP10 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 10 } }
589 #define PREGRP11 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 11 } }
590 #define PREGRP12 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 12 } }
591 #define PREGRP13 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 13 } }
592 #define PREGRP14 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 14 } }
593 #define PREGRP15 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 15 } }
594 #define PREGRP16 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 16 } }
595 #define PREGRP17 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 17 } }
596 #define PREGRP18 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 18 } }
597 #define PREGRP19 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 19 } }
598 #define PREGRP20 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 20 } }
599 #define PREGRP21 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 21 } }
600 #define PREGRP22 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 22 } }
601 #define PREGRP23 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 23 } }
602 #define PREGRP24 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 24 } }
603 #define PREGRP25 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 25 } }
604 #define PREGRP26 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 26 } }
605 #define PREGRP27 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 27 } }
606 #define PREGRP28 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 28 } }
607 #define PREGRP29 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 29 } }
608 #define PREGRP30 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 30 } }
609 #define PREGRP31 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 31 } }
610 #define PREGRP32 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 32 } }
611 #define PREGRP33 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 33 } }
612 #define PREGRP34 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 34 } }
613 #define PREGRP35 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 35 } }
614 #define PREGRP36 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 36 } }
615 #define PREGRP37 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 37 } }
616 #define PREGRP38 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 38 } }
617 #define PREGRP39 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 39 } }
618 #define PREGRP40 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 40 } }
619 #define PREGRP41 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 41 } }
620 #define PREGRP42 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 42 } }
621 #define PREGRP43 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 43 } }
622 #define PREGRP44 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 44 } }
623 #define PREGRP45 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 45 } }
624 #define PREGRP46 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 46 } }
625 #define PREGRP47 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 47 } }
626 #define PREGRP48 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 48 } }
627 #define PREGRP49 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 49 } }
628 #define PREGRP50 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 50 } }
629 #define PREGRP51 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 51 } }
630 #define PREGRP52 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 52 } }
631 #define PREGRP53 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 53 } }
632 #define PREGRP54 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 54 } }
633 #define PREGRP55 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 55 } }
634 #define PREGRP56 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 56 } }
635 #define PREGRP57 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 57 } }
636 #define PREGRP58 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 58 } }
637 #define PREGRP59 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 59 } }
638 #define PREGRP60 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 60 } }
639 #define PREGRP61 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 61 } }
640 #define PREGRP62 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 62 } }
641 #define PREGRP63 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 63 } }
642 #define PREGRP64 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 64 } }
643 #define PREGRP65 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 65 } }
644 #define PREGRP66 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 66 } }
645 #define PREGRP67 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 67 } }
646 #define PREGRP68 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 68 } }
647 #define PREGRP69 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 69 } }
648 #define PREGRP70 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 70 } }
649 #define PREGRP71 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 71 } }
650 #define PREGRP72 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 72 } }
651 #define PREGRP73 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 73 } }
652 #define PREGRP74 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 74 } }
653 #define PREGRP75 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 75 } }
654 #define PREGRP76 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 76 } }
655 #define PREGRP77 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 77 } }
656 #define PREGRP78 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 78 } }
657 #define PREGRP79 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 79 } }
658 #define PREGRP80 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 80 } }
659 #define PREGRP81 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 81 } }
660 #define PREGRP82 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 82 } }
661 #define PREGRP83 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 83 } }
662 #define PREGRP84 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 84 } }
663 #define PREGRP85 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 85 } }
664 #define PREGRP86 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 86 } }
665 #define PREGRP87 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 87 } }
666 #define PREGRP88 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 88 } }
667 #define PREGRP89 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 89 } }
668 #define PREGRP90 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 90 } }
669 #define PREGRP91 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 91 } }
670 #define PREGRP92 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 92 } }
671 #define PREGRP93 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 93 } }
672 #define PREGRP94 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 94 } }
673 #define PREGRP95 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 95 } }
674 #define PREGRP96 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 96 } }
675 #define PREGRP97 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 97 } }
676 #define PREGRP98 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 98 } }
677 #define PREGRP99 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 99 } }
678 #define PREGRP100 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 100 } }
679 #define PREGRP101 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 101 } }
680 #define PREGRP102 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 102 } }
681 #define PREGRP103 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 103 } }
682 #define PREGRP104 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 104 } }
683 #define PREGRP105 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 105 } }
684 #define PREGRP106 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 106 } }
685
686 #define X86_64_0 NULL, { { NULL, X86_64_SPECIAL }, { NULL, 0 } }
687 #define X86_64_1 NULL, { { NULL, X86_64_SPECIAL }, { NULL, 1 } }
688 #define X86_64_2 NULL, { { NULL, X86_64_SPECIAL }, { NULL, 2 } }
689 #define X86_64_3 NULL, { { NULL, X86_64_SPECIAL }, { NULL, 3 } }
690
691 #define THREE_BYTE_0 NULL, { { NULL, IS_3BYTE_OPCODE }, { NULL, 0 } }
692 #define THREE_BYTE_1 NULL, { { NULL, IS_3BYTE_OPCODE }, { NULL, 1 } }
693
694 typedef void (*op_rtn) (int bytemode, int sizeflag);
695
696 struct dis386 {
697 const char *name;
698 struct
699 {
700 op_rtn rtn;
701 int bytemode;
702 } op[MAX_OPERANDS];
703 };
704
705 /* Upper case letters in the instruction names here are macros.
706 'A' => print 'b' if no register operands or suffix_always is true
707 'B' => print 'b' if suffix_always is true
708 'C' => print 's' or 'l' ('w' or 'd' in Intel mode) depending on operand
709 . size prefix
710 'D' => print 'w' if no register operands or 'w', 'l' or 'q', if
711 . suffix_always is true
712 'E' => print 'e' if 32-bit form of jcxz
713 'F' => print 'w' or 'l' depending on address size prefix (loop insns)
714 'G' => print 'w' or 'l' depending on operand size prefix (i/o insns)
715 'H' => print ",pt" or ",pn" branch hint
716 'I' => honor following macro letter even in Intel mode (implemented only
717 . for some of the macro letters)
718 'J' => print 'l'
719 'K' => print 'd' or 'q' if rex prefix is present.
720 'L' => print 'l' if suffix_always is true
721 'N' => print 'n' if instruction has no wait "prefix"
722 'O' => print 'd' or 'o' (or 'q' in Intel mode)
723 'P' => print 'w', 'l' or 'q' if instruction has an operand size prefix,
724 . or suffix_always is true. print 'q' if rex prefix is present.
725 'Q' => print 'w', 'l' or 'q' if no register operands or suffix_always
726 . is true
727 'R' => print 'w', 'l' or 'q' ('d' for 'l' and 'e' in Intel mode)
728 'S' => print 'w', 'l' or 'q' if suffix_always is true
729 'T' => print 'q' in 64bit mode and behave as 'P' otherwise
730 'U' => print 'q' in 64bit mode and behave as 'Q' otherwise
731 'V' => print 'q' in 64bit mode and behave as 'S' otherwise
732 'W' => print 'b', 'w' or 'l' ('d' in Intel mode)
733 'X' => print 's', 'd' depending on data16 prefix (for XMM)
734 'Y' => 'q' if instruction has an REX 64bit overwrite prefix
735 'Z' => print 'q' in 64bit mode and behave as 'L' otherwise
736
737 Many of the above letters print nothing in Intel mode. See "putop"
738 for the details.
739
740 Braces '{' and '}', and vertical bars '|', indicate alternative
741 mnemonic strings for AT&T, Intel, X86_64 AT&T, and X86_64 Intel
742 modes. In cases where there are only two alternatives, the X86_64
743 instruction is reserved, and "(bad)" is printed.
744 */
745
746 static const struct dis386 dis386[] = {
747 /* 00 */
748 { "addB", { Eb, Gb } },
749 { "addS", { Ev, Gv } },
750 { "addB", { Gb, Eb } },
751 { "addS", { Gv, Ev } },
752 { "addB", { AL, Ib } },
753 { "addS", { eAX, Iv } },
754 { "push{T|}", { es } },
755 { "pop{T|}", { es } },
756 /* 08 */
757 { "orB", { Eb, Gb } },
758 { "orS", { Ev, Gv } },
759 { "orB", { Gb, Eb } },
760 { "orS", { Gv, Ev } },
761 { "orB", { AL, Ib } },
762 { "orS", { eAX, Iv } },
763 { "push{T|}", { cs } },
764 { "(bad)", { XX } }, /* 0x0f extended opcode escape */
765 /* 10 */
766 { "adcB", { Eb, Gb } },
767 { "adcS", { Ev, Gv } },
768 { "adcB", { Gb, Eb } },
769 { "adcS", { Gv, Ev } },
770 { "adcB", { AL, Ib } },
771 { "adcS", { eAX, Iv } },
772 { "push{T|}", { ss } },
773 { "pop{T|}", { ss } },
774 /* 18 */
775 { "sbbB", { Eb, Gb } },
776 { "sbbS", { Ev, Gv } },
777 { "sbbB", { Gb, Eb } },
778 { "sbbS", { Gv, Ev } },
779 { "sbbB", { AL, Ib } },
780 { "sbbS", { eAX, Iv } },
781 { "push{T|}", { ds } },
782 { "pop{T|}", { ds } },
783 /* 20 */
784 { "andB", { Eb, Gb } },
785 { "andS", { Ev, Gv } },
786 { "andB", { Gb, Eb } },
787 { "andS", { Gv, Ev } },
788 { "andB", { AL, Ib } },
789 { "andS", { eAX, Iv } },
790 { "(bad)", { XX } }, /* SEG ES prefix */
791 { "daa{|}", { XX } },
792 /* 28 */
793 { "subB", { Eb, Gb } },
794 { "subS", { Ev, Gv } },
795 { "subB", { Gb, Eb } },
796 { "subS", { Gv, Ev } },
797 { "subB", { AL, Ib } },
798 { "subS", { eAX, Iv } },
799 { "(bad)", { XX } }, /* SEG CS prefix */
800 { "das{|}", { XX } },
801 /* 30 */
802 { "xorB", { Eb, Gb } },
803 { "xorS", { Ev, Gv } },
804 { "xorB", { Gb, Eb } },
805 { "xorS", { Gv, Ev } },
806 { "xorB", { AL, Ib } },
807 { "xorS", { eAX, Iv } },
808 { "(bad)", { XX } }, /* SEG SS prefix */
809 { "aaa{|}", { XX } },
810 /* 38 */
811 { "cmpB", { Eb, Gb } },
812 { "cmpS", { Ev, Gv } },
813 { "cmpB", { Gb, Eb } },
814 { "cmpS", { Gv, Ev } },
815 { "cmpB", { AL, Ib } },
816 { "cmpS", { eAX, Iv } },
817 { "(bad)", { XX } }, /* SEG DS prefix */
818 { "aas{|}", { XX } },
819 /* 40 */
820 { "inc{S|}", { RMeAX } },
821 { "inc{S|}", { RMeCX } },
822 { "inc{S|}", { RMeDX } },
823 { "inc{S|}", { RMeBX } },
824 { "inc{S|}", { RMeSP } },
825 { "inc{S|}", { RMeBP } },
826 { "inc{S|}", { RMeSI } },
827 { "inc{S|}", { RMeDI } },
828 /* 48 */
829 { "dec{S|}", { RMeAX } },
830 { "dec{S|}", { RMeCX } },
831 { "dec{S|}", { RMeDX } },
832 { "dec{S|}", { RMeBX } },
833 { "dec{S|}", { RMeSP } },
834 { "dec{S|}", { RMeBP } },
835 { "dec{S|}", { RMeSI } },
836 { "dec{S|}", { RMeDI } },
837 /* 50 */
838 { "pushV", { RMrAX } },
839 { "pushV", { RMrCX } },
840 { "pushV", { RMrDX } },
841 { "pushV", { RMrBX } },
842 { "pushV", { RMrSP } },
843 { "pushV", { RMrBP } },
844 { "pushV", { RMrSI } },
845 { "pushV", { RMrDI } },
846 /* 58 */
847 { "popV", { RMrAX } },
848 { "popV", { RMrCX } },
849 { "popV", { RMrDX } },
850 { "popV", { RMrBX } },
851 { "popV", { RMrSP } },
852 { "popV", { RMrBP } },
853 { "popV", { RMrSI } },
854 { "popV", { RMrDI } },
855 /* 60 */
856 { X86_64_0 },
857 { X86_64_1 },
858 { X86_64_2 },
859 { X86_64_3 },
860 { "(bad)", { XX } }, /* seg fs */
861 { "(bad)", { XX } }, /* seg gs */
862 { "(bad)", { XX } }, /* op size prefix */
863 { "(bad)", { XX } }, /* adr size prefix */
864 /* 68 */
865 { "pushT", { Iq } },
866 { "imulS", { Gv, Ev, Iv } },
867 { "pushT", { sIb } },
868 { "imulS", { Gv, Ev, sIb } },
869 { "ins{b||b|}", { Ybr, indirDX } },
870 { "ins{R||G|}", { Yzr, indirDX } },
871 { "outs{b||b|}", { indirDXr, Xb } },
872 { "outs{R||G|}", { indirDXr, Xz } },
873 /* 70 */
874 { "joH", { Jb, XX, cond_jump_flag } },
875 { "jnoH", { Jb, XX, cond_jump_flag } },
876 { "jbH", { Jb, XX, cond_jump_flag } },
877 { "jaeH", { Jb, XX, cond_jump_flag } },
878 { "jeH", { Jb, XX, cond_jump_flag } },
879 { "jneH", { Jb, XX, cond_jump_flag } },
880 { "jbeH", { Jb, XX, cond_jump_flag } },
881 { "jaH", { Jb, XX, cond_jump_flag } },
882 /* 78 */
883 { "jsH", { Jb, XX, cond_jump_flag } },
884 { "jnsH", { Jb, XX, cond_jump_flag } },
885 { "jpH", { Jb, XX, cond_jump_flag } },
886 { "jnpH", { Jb, XX, cond_jump_flag } },
887 { "jlH", { Jb, XX, cond_jump_flag } },
888 { "jgeH", { Jb, XX, cond_jump_flag } },
889 { "jleH", { Jb, XX, cond_jump_flag } },
890 { "jgH", { Jb, XX, cond_jump_flag } },
891 /* 80 */
892 { GRP1b },
893 { GRP1S },
894 { "(bad)", { XX } },
895 { GRP1Ss },
896 { "testB", { Eb, Gb } },
897 { "testS", { Ev, Gv } },
898 { "xchgB", { Eb, Gb } },
899 { "xchgS", { Ev, Gv } },
900 /* 88 */
901 { "movB", { Eb, Gb } },
902 { "movS", { Ev, Gv } },
903 { "movB", { Gb, Eb } },
904 { "movS", { Gv, Ev } },
905 { "movD", { Sv, Sw } },
906 { "leaS", { Gv, M } },
907 { "movD", { Sw, Sv } },
908 { GRP1a },
909 /* 90 */
910 { PREGRP38 },
911 { "xchgS", { RMeCX, eAX } },
912 { "xchgS", { RMeDX, eAX } },
913 { "xchgS", { RMeBX, eAX } },
914 { "xchgS", { RMeSP, eAX } },
915 { "xchgS", { RMeBP, eAX } },
916 { "xchgS", { RMeSI, eAX } },
917 { "xchgS", { RMeDI, eAX } },
918 /* 98 */
919 { "cW{t||t|}R", { XX } },
920 { "cR{t||t|}O", { XX } },
921 { "Jcall{T|}", { Ap } },
922 { "(bad)", { XX } }, /* fwait */
923 { "pushfT", { XX } },
924 { "popfT", { XX } },
925 { "sahf{|}", { XX } },
926 { "lahf{|}", { XX } },
927 /* a0 */
928 { "movB", { AL, Ob } },
929 { "movS", { eAX, Ov } },
930 { "movB", { Ob, AL } },
931 { "movS", { Ov, eAX } },
932 { "movs{b||b|}", { Ybr, Xb } },
933 { "movs{R||R|}", { Yvr, Xv } },
934 { "cmps{b||b|}", { Xb, Yb } },
935 { "cmps{R||R|}", { Xv, Yv } },
936 /* a8 */
937 { "testB", { AL, Ib } },
938 { "testS", { eAX, Iv } },
939 { "stosB", { Ybr, AL } },
940 { "stosS", { Yvr, eAX } },
941 { "lodsB", { ALr, Xb } },
942 { "lodsS", { eAXr, Xv } },
943 { "scasB", { AL, Yb } },
944 { "scasS", { eAX, Yv } },
945 /* b0 */
946 { "movB", { RMAL, Ib } },
947 { "movB", { RMCL, Ib } },
948 { "movB", { RMDL, Ib } },
949 { "movB", { RMBL, Ib } },
950 { "movB", { RMAH, Ib } },
951 { "movB", { RMCH, Ib } },
952 { "movB", { RMDH, Ib } },
953 { "movB", { RMBH, Ib } },
954 /* b8 */
955 { "movS", { RMeAX, Iv64 } },
956 { "movS", { RMeCX, Iv64 } },
957 { "movS", { RMeDX, Iv64 } },
958 { "movS", { RMeBX, Iv64 } },
959 { "movS", { RMeSP, Iv64 } },
960 { "movS", { RMeBP, Iv64 } },
961 { "movS", { RMeSI, Iv64 } },
962 { "movS", { RMeDI, Iv64 } },
963 /* c0 */
964 { GRP2b },
965 { GRP2S },
966 { "retT", { Iw } },
967 { "retT", { XX } },
968 { "les{S|}", { Gv, Mp } },
969 { "ldsS", { Gv, Mp } },
970 { GRP11_C6 },
971 { GRP11_C7 },
972 /* c8 */
973 { "enterT", { Iw, Ib } },
974 { "leaveT", { XX } },
975 { "lretP", { Iw } },
976 { "lretP", { XX } },
977 { "int3", { XX } },
978 { "int", { Ib } },
979 { "into{|}", { XX } },
980 { "iretP", { XX } },
981 /* d0 */
982 { GRP2b_one },
983 { GRP2S_one },
984 { GRP2b_cl },
985 { GRP2S_cl },
986 { "aam{|}", { sIb } },
987 { "aad{|}", { sIb } },
988 { "(bad)", { XX } },
989 { "xlat", { DSBX } },
990 /* d8 */
991 { FLOAT },
992 { FLOAT },
993 { FLOAT },
994 { FLOAT },
995 { FLOAT },
996 { FLOAT },
997 { FLOAT },
998 { FLOAT },
999 /* e0 */
1000 { "loopneFH", { Jb, XX, loop_jcxz_flag } },
1001 { "loopeFH", { Jb, XX, loop_jcxz_flag } },
1002 { "loopFH", { Jb, XX, loop_jcxz_flag } },
1003 { "jEcxzH", { Jb, XX, loop_jcxz_flag } },
1004 { "inB", { AL, Ib } },
1005 { "inG", { zAX, Ib } },
1006 { "outB", { Ib, AL } },
1007 { "outG", { Ib, zAX } },
1008 /* e8 */
1009 { "callT", { Jv } },
1010 { "jmpT", { Jv } },
1011 { "Jjmp{T|}", { Ap } },
1012 { "jmp", { Jb } },
1013 { "inB", { AL, indirDX } },
1014 { "inG", { zAX, indirDX } },
1015 { "outB", { indirDX, AL } },
1016 { "outG", { indirDX, zAX } },
1017 /* f0 */
1018 { "(bad)", { XX } }, /* lock prefix */
1019 { "icebp", { XX } },
1020 { "(bad)", { XX } }, /* repne */
1021 { "(bad)", { XX } }, /* repz */
1022 { "hlt", { XX } },
1023 { "cmc", { XX } },
1024 { GRP3b },
1025 { GRP3S },
1026 /* f8 */
1027 { "clc", { XX } },
1028 { "stc", { XX } },
1029 { "cli", { XX } },
1030 { "sti", { XX } },
1031 { "cld", { XX } },
1032 { "std", { XX } },
1033 { GRP4 },
1034 { GRP5 },
1035 };
1036
1037 static const struct dis386 dis386_twobyte[] = {
1038 /* 00 */
1039 { GRP6 },
1040 { GRP7 },
1041 { "larS", { Gv, Ew } },
1042 { "lslS", { Gv, Ew } },
1043 { "(bad)", { XX } },
1044 { "syscall", { XX } },
1045 { "clts", { XX } },
1046 { "sysretP", { XX } },
1047 /* 08 */
1048 { "invd", { XX } },
1049 { "wbinvd", { XX } },
1050 { "(bad)", { XX } },
1051 { "ud2a", { XX } },
1052 { "(bad)", { XX } },
1053 { GRPAMD },
1054 { "femms", { XX } },
1055 { "", { MX, EM, OPSUF } }, /* See OP_3DNowSuffix. */
1056 /* 10 */
1057 { PREGRP8 },
1058 { PREGRP9 },
1059 { PREGRP30 },
1060 { "movlpX", { EXq, XM, { SIMD_Fixup, 'h' } } },
1061 { "unpcklpX", { XM, EXq } },
1062 { "unpckhpX", { XM, EXq } },
1063 { PREGRP31 },
1064 { "movhpX", { EXq, XM, { SIMD_Fixup, 'l' } } },
1065 /* 18 */
1066 { GRP16 },
1067 { "(bad)", { XX } },
1068 { "(bad)", { XX } },
1069 { "(bad)", { XX } },
1070 { "(bad)", { XX } },
1071 { "(bad)", { XX } },
1072 { "(bad)", { XX } },
1073 { "nopQ", { Ev } },
1074 /* 20 */
1075 { "movZ", { Rm, Cm } },
1076 { "movZ", { Rm, Dm } },
1077 { "movZ", { Cm, Rm } },
1078 { "movZ", { Dm, Rm } },
1079 { "movL", { Rd, Td } },
1080 { "(bad)", { XX } },
1081 { "movL", { Td, Rd } },
1082 { "(bad)", { XX } },
1083 /* 28 */
1084 { "movapX", { XM, EXx } },
1085 { "movapX", { EXx, XM } },
1086 { PREGRP2 },
1087 { PREGRP33 },
1088 { PREGRP4 },
1089 { PREGRP3 },
1090 { PREGRP93 },
1091 { PREGRP94 },
1092 /* 30 */
1093 { "wrmsr", { XX } },
1094 { "rdtsc", { XX } },
1095 { "rdmsr", { XX } },
1096 { "rdpmc", { XX } },
1097 { "sysenter", { XX } },
1098 { "sysexit", { XX } },
1099 { "(bad)", { XX } },
1100 { "(bad)", { XX } },
1101 /* 38 */
1102 { THREE_BYTE_0 },
1103 { "(bad)", { XX } },
1104 { THREE_BYTE_1 },
1105 { "(bad)", { XX } },
1106 { "(bad)", { XX } },
1107 { "(bad)", { XX } },
1108 { "(bad)", { XX } },
1109 { "(bad)", { XX } },
1110 /* 40 */
1111 { "cmovo", { Gv, Ev } },
1112 { "cmovno", { Gv, Ev } },
1113 { "cmovb", { Gv, Ev } },
1114 { "cmovae", { Gv, Ev } },
1115 { "cmove", { Gv, Ev } },
1116 { "cmovne", { Gv, Ev } },
1117 { "cmovbe", { Gv, Ev } },
1118 { "cmova", { Gv, Ev } },
1119 /* 48 */
1120 { "cmovs", { Gv, Ev } },
1121 { "cmovns", { Gv, Ev } },
1122 { "cmovp", { Gv, Ev } },
1123 { "cmovnp", { Gv, Ev } },
1124 { "cmovl", { Gv, Ev } },
1125 { "cmovge", { Gv, Ev } },
1126 { "cmovle", { Gv, Ev } },
1127 { "cmovg", { Gv, Ev } },
1128 /* 50 */
1129 { "movmskpX", { Gdq, XS } },
1130 { PREGRP13 },
1131 { PREGRP12 },
1132 { PREGRP11 },
1133 { "andpX", { XM, EXx } },
1134 { "andnpX", { XM, EXx } },
1135 { "orpX", { XM, EXx } },
1136 { "xorpX", { XM, EXx } },
1137 /* 58 */
1138 { PREGRP0 },
1139 { PREGRP10 },
1140 { PREGRP17 },
1141 { PREGRP16 },
1142 { PREGRP14 },
1143 { PREGRP7 },
1144 { PREGRP5 },
1145 { PREGRP6 },
1146 /* 60 */
1147 { PREGRP95 },
1148 { PREGRP96 },
1149 { PREGRP97 },
1150 { "packsswb", { MX, EM } },
1151 { "pcmpgtb", { MX, EM } },
1152 { "pcmpgtw", { MX, EM } },
1153 { "pcmpgtd", { MX, EM } },
1154 { "packuswb", { MX, EM } },
1155 /* 68 */
1156 { "punpckhbw", { MX, EM } },
1157 { "punpckhwd", { MX, EM } },
1158 { "punpckhdq", { MX, EM } },
1159 { "packssdw", { MX, EM } },
1160 { PREGRP26 },
1161 { PREGRP24 },
1162 { "movd", { MX, Edq } },
1163 { PREGRP19 },
1164 /* 70 */
1165 { PREGRP22 },
1166 { GRP12 },
1167 { GRP13 },
1168 { GRP14 },
1169 { "pcmpeqb", { MX, EM } },
1170 { "pcmpeqw", { MX, EM } },
1171 { "pcmpeqd", { MX, EM } },
1172 { "emms", { XX } },
1173 /* 78 */
1174 { PREGRP34 },
1175 { PREGRP35 },
1176 { "(bad)", { XX } },
1177 { "(bad)", { XX } },
1178 { PREGRP28 },
1179 { PREGRP29 },
1180 { PREGRP23 },
1181 { PREGRP20 },
1182 /* 80 */
1183 { "joH", { Jv, XX, cond_jump_flag } },
1184 { "jnoH", { Jv, XX, cond_jump_flag } },
1185 { "jbH", { Jv, XX, cond_jump_flag } },
1186 { "jaeH", { Jv, XX, cond_jump_flag } },
1187 { "jeH", { Jv, XX, cond_jump_flag } },
1188 { "jneH", { Jv, XX, cond_jump_flag } },
1189 { "jbeH", { Jv, XX, cond_jump_flag } },
1190 { "jaH", { Jv, XX, cond_jump_flag } },
1191 /* 88 */
1192 { "jsH", { Jv, XX, cond_jump_flag } },
1193 { "jnsH", { Jv, XX, cond_jump_flag } },
1194 { "jpH", { Jv, XX, cond_jump_flag } },
1195 { "jnpH", { Jv, XX, cond_jump_flag } },
1196 { "jlH", { Jv, XX, cond_jump_flag } },
1197 { "jgeH", { Jv, XX, cond_jump_flag } },
1198 { "jleH", { Jv, XX, cond_jump_flag } },
1199 { "jgH", { Jv, XX, cond_jump_flag } },
1200 /* 90 */
1201 { "seto", { Eb } },
1202 { "setno", { Eb } },
1203 { "setb", { Eb } },
1204 { "setae", { Eb } },
1205 { "sete", { Eb } },
1206 { "setne", { Eb } },
1207 { "setbe", { Eb } },
1208 { "seta", { Eb } },
1209 /* 98 */
1210 { "sets", { Eb } },
1211 { "setns", { Eb } },
1212 { "setp", { Eb } },
1213 { "setnp", { Eb } },
1214 { "setl", { Eb } },
1215 { "setge", { Eb } },
1216 { "setle", { Eb } },
1217 { "setg", { Eb } },
1218 /* a0 */
1219 { "pushT", { fs } },
1220 { "popT", { fs } },
1221 { "cpuid", { XX } },
1222 { "btS", { Ev, Gv } },
1223 { "shldS", { Ev, Gv, Ib } },
1224 { "shldS", { Ev, Gv, CL } },
1225 { GRPPADLCK2 },
1226 { GRPPADLCK1 },
1227 /* a8 */
1228 { "pushT", { gs } },
1229 { "popT", { gs } },
1230 { "rsm", { XX } },
1231 { "btsS", { Ev, Gv } },
1232 { "shrdS", { Ev, Gv, Ib } },
1233 { "shrdS", { Ev, Gv, CL } },
1234 { GRP15 },
1235 { "imulS", { Gv, Ev } },
1236 /* b0 */
1237 { "cmpxchgB", { Eb, Gb } },
1238 { "cmpxchgS", { Ev, Gv } },
1239 { "lssS", { Gv, Mp } },
1240 { "btrS", { Ev, Gv } },
1241 { "lfsS", { Gv, Mp } },
1242 { "lgsS", { Gv, Mp } },
1243 { "movz{bR|x|bR|x}", { Gv, Eb } },
1244 { "movz{wR|x|wR|x}", { Gv, Ew } }, /* yes, there really is movzww ! */
1245 /* b8 */
1246 { PREGRP37 },
1247 { "ud2b", { XX } },
1248 { GRP8 },
1249 { "btcS", { Ev, Gv } },
1250 { "bsfS", { Gv, Ev } },
1251 { PREGRP36 },
1252 { "movs{bR|x|bR|x}", { Gv, Eb } },
1253 { "movs{wR|x|wR|x}", { Gv, Ew } }, /* yes, there really is movsww ! */
1254 /* c0 */
1255 { "xaddB", { Eb, Gb } },
1256 { "xaddS", { Ev, Gv } },
1257 { PREGRP1 },
1258 { "movntiS", { Ev, Gv } },
1259 { "pinsrw", { MX, Edqw, Ib } },
1260 { "pextrw", { Gdq, MS, Ib } },
1261 { "shufpX", { XM, EXx, Ib } },
1262 { GRP9 },
1263 /* c8 */
1264 { "bswap", { RMeAX } },
1265 { "bswap", { RMeCX } },
1266 { "bswap", { RMeDX } },
1267 { "bswap", { RMeBX } },
1268 { "bswap", { RMeSP } },
1269 { "bswap", { RMeBP } },
1270 { "bswap", { RMeSI } },
1271 { "bswap", { RMeDI } },
1272 /* d0 */
1273 { PREGRP27 },
1274 { "psrlw", { MX, EM } },
1275 { "psrld", { MX, EM } },
1276 { "psrlq", { MX, EM } },
1277 { "paddq", { MX, EM } },
1278 { "pmullw", { MX, EM } },
1279 { PREGRP21 },
1280 { "pmovmskb", { Gdq, MS } },
1281 /* d8 */
1282 { "psubusb", { MX, EM } },
1283 { "psubusw", { MX, EM } },
1284 { "pminub", { MX, EM } },
1285 { "pand", { MX, EM } },
1286 { "paddusb", { MX, EM } },
1287 { "paddusw", { MX, EM } },
1288 { "pmaxub", { MX, EM } },
1289 { "pandn", { MX, EM } },
1290 /* e0 */
1291 { "pavgb", { MX, EM } },
1292 { "psraw", { MX, EM } },
1293 { "psrad", { MX, EM } },
1294 { "pavgw", { MX, EM } },
1295 { "pmulhuw", { MX, EM } },
1296 { "pmulhw", { MX, EM } },
1297 { PREGRP15 },
1298 { PREGRP25 },
1299 /* e8 */
1300 { "psubsb", { MX, EM } },
1301 { "psubsw", { MX, EM } },
1302 { "pminsw", { MX, EM } },
1303 { "por", { MX, EM } },
1304 { "paddsb", { MX, EM } },
1305 { "paddsw", { MX, EM } },
1306 { "pmaxsw", { MX, EM } },
1307 { "pxor", { MX, EM } },
1308 /* f0 */
1309 { PREGRP32 },
1310 { "psllw", { MX, EM } },
1311 { "pslld", { MX, EM } },
1312 { "psllq", { MX, EM } },
1313 { "pmuludq", { MX, EM } },
1314 { "pmaddwd", { MX, EM } },
1315 { "psadbw", { MX, EM } },
1316 { PREGRP18 },
1317 /* f8 */
1318 { "psubb", { MX, EM } },
1319 { "psubw", { MX, EM } },
1320 { "psubd", { MX, EM } },
1321 { "psubq", { MX, EM } },
1322 { "paddb", { MX, EM } },
1323 { "paddw", { MX, EM } },
1324 { "paddd", { MX, EM } },
1325 { "(bad)", { XX } },
1326 };
1327
1328 static const unsigned char onebyte_has_modrm[256] = {
1329 /* 0 1 2 3 4 5 6 7 8 9 a b c d e f */
1330 /* ------------------------------- */
1331 /* 00 */ 1,1,1,1,0,0,0,0,1,1,1,1,0,0,0,0, /* 00 */
1332 /* 10 */ 1,1,1,1,0,0,0,0,1,1,1,1,0,0,0,0, /* 10 */
1333 /* 20 */ 1,1,1,1,0,0,0,0,1,1,1,1,0,0,0,0, /* 20 */
1334 /* 30 */ 1,1,1,1,0,0,0,0,1,1,1,1,0,0,0,0, /* 30 */
1335 /* 40 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 40 */
1336 /* 50 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 50 */
1337 /* 60 */ 0,0,1,1,0,0,0,0,0,1,0,1,0,0,0,0, /* 60 */
1338 /* 70 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 70 */
1339 /* 80 */ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, /* 80 */
1340 /* 90 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 90 */
1341 /* a0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* a0 */
1342 /* b0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* b0 */
1343 /* c0 */ 1,1,0,0,1,1,1,1,0,0,0,0,0,0,0,0, /* c0 */
1344 /* d0 */ 1,1,1,1,0,0,0,0,1,1,1,1,1,1,1,1, /* d0 */
1345 /* e0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* e0 */
1346 /* f0 */ 0,0,0,0,0,0,1,1,0,0,0,0,0,0,1,1 /* f0 */
1347 /* ------------------------------- */
1348 /* 0 1 2 3 4 5 6 7 8 9 a b c d e f */
1349 };
1350
1351 static const unsigned char twobyte_has_modrm[256] = {
1352 /* 0 1 2 3 4 5 6 7 8 9 a b c d e f */
1353 /* ------------------------------- */
1354 /* 00 */ 1,1,1,1,0,0,0,0,0,0,0,0,0,1,0,1, /* 0f */
1355 /* 10 */ 1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,1, /* 1f */
1356 /* 20 */ 1,1,1,1,1,0,1,0,1,1,1,1,1,1,1,1, /* 2f */
1357 /* 30 */ 0,0,0,0,0,0,0,0,1,0,1,0,0,0,0,0, /* 3f */
1358 /* 40 */ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, /* 4f */
1359 /* 50 */ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, /* 5f */
1360 /* 60 */ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, /* 6f */
1361 /* 70 */ 1,1,1,1,1,1,1,0,1,1,0,0,1,1,1,1, /* 7f */
1362 /* 80 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 8f */
1363 /* 90 */ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, /* 9f */
1364 /* a0 */ 0,0,0,1,1,1,1,1,0,0,0,1,1,1,1,1, /* af */
1365 /* b0 */ 1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1, /* bf */
1366 /* c0 */ 1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0, /* cf */
1367 /* d0 */ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, /* df */
1368 /* e0 */ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, /* ef */
1369 /* f0 */ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0 /* ff */
1370 /* ------------------------------- */
1371 /* 0 1 2 3 4 5 6 7 8 9 a b c d e f */
1372 };
1373
1374 static const unsigned char twobyte_uses_DATA_prefix[256] = {
1375 /* 0 1 2 3 4 5 6 7 8 9 a b c d e f */
1376 /* ------------------------------- */
1377 /* 00 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0f */
1378 /* 10 */ 1,1,1,0,0,0,1,0,0,0,0,0,0,0,0,0, /* 1f */
1379 /* 20 */ 0,0,0,0,0,0,0,0,0,0,1,1,1,1,0,0, /* 2f */
1380 /* 30 */ 0,0,0,0,0,0,0,0,1,0,1,0,0,0,0,0, /* 3f */
1381 /* 40 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 4f */
1382 /* 50 */ 0,1,1,1,0,0,0,0,1,1,1,1,1,1,1,1, /* 5f */
1383 /* 60 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1, /* 6f */
1384 /* 70 */ 1,0,0,0,0,0,0,0,1,1,0,0,1,1,1,1, /* 7f */
1385 /* 80 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 8f */
1386 /* 90 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 9f */
1387 /* a0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* af */
1388 /* b0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* bf */
1389 /* c0 */ 0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0, /* cf */
1390 /* d0 */ 1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0, /* df */
1391 /* e0 */ 0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0, /* ef */
1392 /* f0 */ 1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0 /* ff */
1393 /* ------------------------------- */
1394 /* 0 1 2 3 4 5 6 7 8 9 a b c d e f */
1395 };
1396
1397 static const unsigned char twobyte_uses_REPNZ_prefix[256] = {
1398 /* 0 1 2 3 4 5 6 7 8 9 a b c d e f */
1399 /* ------------------------------- */
1400 /* 00 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0f */
1401 /* 10 */ 1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 1f */
1402 /* 20 */ 0,0,0,0,0,0,0,0,0,0,1,1,1,1,0,0, /* 2f */
1403 /* 30 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 3f */
1404 /* 40 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 4f */
1405 /* 50 */ 0,1,0,0,0,0,0,0,1,1,1,0,1,1,1,1, /* 5f */
1406 /* 60 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 6f */
1407 /* 70 */ 1,0,0,0,0,0,0,0,1,1,0,0,1,1,0,0, /* 7f */
1408 /* 80 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 8f */
1409 /* 90 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 9f */
1410 /* a0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* af */
1411 /* b0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* bf */
1412 /* c0 */ 0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0, /* cf */
1413 /* d0 */ 1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0, /* df */
1414 /* e0 */ 0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0, /* ef */
1415 /* f0 */ 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* ff */
1416 /* ------------------------------- */
1417 /* 0 1 2 3 4 5 6 7 8 9 a b c d e f */
1418 };
1419
1420 static const unsigned char twobyte_uses_REPZ_prefix[256] = {
1421 /* 0 1 2 3 4 5 6 7 8 9 a b c d e f */
1422 /* ------------------------------- */
1423 /* 00 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0f */
1424 /* 10 */ 1,1,1,0,0,0,1,0,0,0,0,0,0,0,0,0, /* 1f */
1425 /* 20 */ 0,0,0,0,0,0,0,0,0,0,1,1,1,1,0,0, /* 2f */
1426 /* 30 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 3f */
1427 /* 40 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 4f */
1428 /* 50 */ 0,1,1,1,0,0,0,0,1,1,1,1,1,1,1,1, /* 5f */
1429 /* 60 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1, /* 6f */
1430 /* 70 */ 1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1, /* 7f */
1431 /* 80 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 8f */
1432 /* 90 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 9f */
1433 /* a0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* af */
1434 /* b0 */ 0,0,0,0,0,0,0,0,1,0,0,0,0,1,0,0, /* bf */
1435 /* c0 */ 0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0, /* cf */
1436 /* d0 */ 0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0, /* df */
1437 /* e0 */ 0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0, /* ef */
1438 /* f0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* ff */
1439 /* ------------------------------- */
1440 /* 0 1 2 3 4 5 6 7 8 9 a b c d e f */
1441 };
1442
1443 /* This is used to determine if opcode 0f 38 XX uses DATA prefix. */
1444 static const unsigned char threebyte_0x38_uses_DATA_prefix[256] = {
1445 /* 0 1 2 3 4 5 6 7 8 9 a b c d e f */
1446 /* ------------------------------- */
1447 /* 00 */ 1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0, /* 0f */
1448 /* 10 */ 1,0,0,0,1,1,0,1,0,0,0,0,1,1,1,0, /* 1f */
1449 /* 20 */ 1,1,1,1,1,1,0,0,1,1,1,1,0,0,0,0, /* 2f */
1450 /* 30 */ 1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1, /* 3f */
1451 /* 40 */ 1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 4f */
1452 /* 50 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 5f */
1453 /* 60 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 6f */
1454 /* 70 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 7f */
1455 /* 80 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 8f */
1456 /* 90 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 9f */
1457 /* a0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* af */
1458 /* b0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* bf */
1459 /* c0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* cf */
1460 /* d0 */ 0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1, /* df */
1461 /* e0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* ef */
1462 /* f0 */ 0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0, /* ff */
1463 /* ------------------------------- */
1464 /* 0 1 2 3 4 5 6 7 8 9 a b c d e f */
1465 };
1466
1467 /* This is used to determine if opcode 0f 38 XX uses REPNZ prefix. */
1468 static const unsigned char threebyte_0x38_uses_REPNZ_prefix[256] = {
1469 /* 0 1 2 3 4 5 6 7 8 9 a b c d e f */
1470 /* ------------------------------- */
1471 /* 00 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0f */
1472 /* 10 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 1f */
1473 /* 20 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 2f */
1474 /* 30 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 3f */
1475 /* 40 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 4f */
1476 /* 50 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 5f */
1477 /* 60 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 6f */
1478 /* 70 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 7f */
1479 /* 80 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 8f */
1480 /* 90 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 9f */
1481 /* a0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* af */
1482 /* b0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* bf */
1483 /* c0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* cf */
1484 /* d0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* df */
1485 /* e0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* ef */
1486 /* f0 */ 1,1,0,0,0,0,0,1,0,0,0,0,0,0,0,0, /* ff */
1487 /* ------------------------------- */
1488 /* 0 1 2 3 4 5 6 7 8 9 a b c d e f */
1489 };
1490
1491 /* This is used to determine if opcode 0f 38 XX uses REPZ prefix. */
1492 static const unsigned char threebyte_0x38_uses_REPZ_prefix[256] = {
1493 /* 0 1 2 3 4 5 6 7 8 9 a b c d e f */
1494 /* ------------------------------- */
1495 /* 00 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0f */
1496 /* 10 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 1f */
1497 /* 20 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 2f */
1498 /* 30 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 3f */
1499 /* 40 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 4f */
1500 /* 50 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 5f */
1501 /* 60 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 6f */
1502 /* 70 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 7f */
1503 /* 80 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 8f */
1504 /* 90 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 9f */
1505 /* a0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* af */
1506 /* b0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* bf */
1507 /* c0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* cf */
1508 /* d0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* df */
1509 /* e0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* ef */
1510 /* f0 */ 0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0, /* ff */
1511 /* ------------------------------- */
1512 /* 0 1 2 3 4 5 6 7 8 9 a b c d e f */
1513 };
1514
1515 /* This is used to determine if opcode 0f 3a XX uses DATA prefix. */
1516 static const unsigned char threebyte_0x3a_uses_DATA_prefix[256] = {
1517 /* 0 1 2 3 4 5 6 7 8 9 a b c d e f */
1518 /* ------------------------------- */
1519 /* 00 */ 0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1, /* 0f */
1520 /* 10 */ 0,0,0,0,1,1,1,1,0,0,0,0,0,0,0,0, /* 1f */
1521 /* 20 */ 1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 2f */
1522 /* 30 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 3f */
1523 /* 40 */ 1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0, /* 4f */
1524 /* 50 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 5f */
1525 /* 60 */ 1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0, /* 6f */
1526 /* 70 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 7f */
1527 /* 80 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 8f */
1528 /* 90 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 9f */
1529 /* a0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* af */
1530 /* b0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* bf */
1531 /* c0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* cf */
1532 /* d0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1, /* df */
1533 /* e0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* ef */
1534 /* f0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* ff */
1535 /* ------------------------------- */
1536 /* 0 1 2 3 4 5 6 7 8 9 a b c d e f */
1537 };
1538
1539 /* This is used to determine if opcode 0f 3a XX uses REPNZ prefix. */
1540 static const unsigned char threebyte_0x3a_uses_REPNZ_prefix[256] = {
1541 /* 0 1 2 3 4 5 6 7 8 9 a b c d e f */
1542 /* ------------------------------- */
1543 /* 00 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0f */
1544 /* 10 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 1f */
1545 /* 20 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 2f */
1546 /* 30 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 3f */
1547 /* 40 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 4f */
1548 /* 50 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 5f */
1549 /* 60 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 6f */
1550 /* 70 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 7f */
1551 /* 80 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 8f */
1552 /* 90 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 9f */
1553 /* a0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* af */
1554 /* b0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* bf */
1555 /* c0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* cf */
1556 /* d0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* df */
1557 /* e0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* ef */
1558 /* f0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* ff */
1559 /* ------------------------------- */
1560 /* 0 1 2 3 4 5 6 7 8 9 a b c d e f */
1561 };
1562
1563 /* This is used to determine if opcode 0f 3a XX uses REPZ prefix. */
1564 static const unsigned char threebyte_0x3a_uses_REPZ_prefix[256] = {
1565 /* 0 1 2 3 4 5 6 7 8 9 a b c d e f */
1566 /* ------------------------------- */
1567 /* 00 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0f */
1568 /* 10 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 1f */
1569 /* 20 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 2f */
1570 /* 30 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 3f */
1571 /* 40 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 4f */
1572 /* 50 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 5f */
1573 /* 60 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 6f */
1574 /* 70 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 7f */
1575 /* 80 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 8f */
1576 /* 90 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 9f */
1577 /* a0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* af */
1578 /* b0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* bf */
1579 /* c0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* cf */
1580 /* d0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* df */
1581 /* e0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* ef */
1582 /* f0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* ff */
1583 /* ------------------------------- */
1584 /* 0 1 2 3 4 5 6 7 8 9 a b c d e f */
1585 };
1586
1587 static char obuf[100];
1588 static char *obufp;
1589 static char scratchbuf[100];
1590 static unsigned char *start_codep;
1591 static unsigned char *insn_codep;
1592 static unsigned char *codep;
1593 static disassemble_info *the_info;
1594 static struct
1595 {
1596 int mod;
1597 int reg;
1598 int rm;
1599 }
1600 modrm;
1601 static unsigned char need_modrm;
1602
1603 /* If we are accessing mod/rm/reg without need_modrm set, then the
1604 values are stale. Hitting this abort likely indicates that you
1605 need to update onebyte_has_modrm or twobyte_has_modrm. */
1606 #define MODRM_CHECK if (!need_modrm) abort ()
1607
1608 static const char * const *names64;
1609 static const char * const *names32;
1610 static const char * const *names16;
1611 static const char * const *names8;
1612 static const char * const *names8rex;
1613 static const char * const *names_seg;
1614 static const char * const *index16;
1615
1616 static const char * const intel_names64[] = {
1617 "rax", "rcx", "rdx", "rbx", "rsp", "rbp", "rsi", "rdi",
1618 "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15"
1619 };
1620 static const char * const intel_names32[] = {
1621 "eax", "ecx", "edx", "ebx", "esp", "ebp", "esi", "edi",
1622 "r8d", "r9d", "r10d", "r11d", "r12d", "r13d", "r14d", "r15d"
1623 };
1624 static const char * const intel_names16[] = {
1625 "ax", "cx", "dx", "bx", "sp", "bp", "si", "di",
1626 "r8w", "r9w", "r10w", "r11w", "r12w", "r13w", "r14w", "r15w"
1627 };
1628 static const char * const intel_names8[] = {
1629 "al", "cl", "dl", "bl", "ah", "ch", "dh", "bh",
1630 };
1631 static const char * const intel_names8rex[] = {
1632 "al", "cl", "dl", "bl", "spl", "bpl", "sil", "dil",
1633 "r8b", "r9b", "r10b", "r11b", "r12b", "r13b", "r14b", "r15b"
1634 };
1635 static const char * const intel_names_seg[] = {
1636 "es", "cs", "ss", "ds", "fs", "gs", "?", "?",
1637 };
1638 static const char * const intel_index16[] = {
1639 "bx+si", "bx+di", "bp+si", "bp+di", "si", "di", "bp", "bx"
1640 };
1641
1642 static const char * const att_names64[] = {
1643 "%rax", "%rcx", "%rdx", "%rbx", "%rsp", "%rbp", "%rsi", "%rdi",
1644 "%r8", "%r9", "%r10", "%r11", "%r12", "%r13", "%r14", "%r15"
1645 };
1646 static const char * const att_names32[] = {
1647 "%eax", "%ecx", "%edx", "%ebx", "%esp", "%ebp", "%esi", "%edi",
1648 "%r8d", "%r9d", "%r10d", "%r11d", "%r12d", "%r13d", "%r14d", "%r15d"
1649 };
1650 static const char * const att_names16[] = {
1651 "%ax", "%cx", "%dx", "%bx", "%sp", "%bp", "%si", "%di",
1652 "%r8w", "%r9w", "%r10w", "%r11w", "%r12w", "%r13w", "%r14w", "%r15w"
1653 };
1654 static const char * const att_names8[] = {
1655 "%al", "%cl", "%dl", "%bl", "%ah", "%ch", "%dh", "%bh",
1656 };
1657 static const char * const att_names8rex[] = {
1658 "%al", "%cl", "%dl", "%bl", "%spl", "%bpl", "%sil", "%dil",
1659 "%r8b", "%r9b", "%r10b", "%r11b", "%r12b", "%r13b", "%r14b", "%r15b"
1660 };
1661 static const char * const att_names_seg[] = {
1662 "%es", "%cs", "%ss", "%ds", "%fs", "%gs", "%?", "%?",
1663 };
1664 static const char * const att_index16[] = {
1665 "%bx,%si", "%bx,%di", "%bp,%si", "%bp,%di", "%si", "%di", "%bp", "%bx"
1666 };
1667
1668 static const struct dis386 grps[][8] = {
1669 /* GRP1a */
1670 {
1671 { "popU", { stackEv } },
1672 { "(bad)", { XX } },
1673 { "(bad)", { XX } },
1674 { "(bad)", { XX } },
1675 { "(bad)", { XX } },
1676 { "(bad)", { XX } },
1677 { "(bad)", { XX } },
1678 { "(bad)", { XX } },
1679 },
1680 /* GRP1b */
1681 {
1682 { "addA", { Eb, Ib } },
1683 { "orA", { Eb, Ib } },
1684 { "adcA", { Eb, Ib } },
1685 { "sbbA", { Eb, Ib } },
1686 { "andA", { Eb, Ib } },
1687 { "subA", { Eb, Ib } },
1688 { "xorA", { Eb, Ib } },
1689 { "cmpA", { Eb, Ib } },
1690 },
1691 /* GRP1S */
1692 {
1693 { "addQ", { Ev, Iv } },
1694 { "orQ", { Ev, Iv } },
1695 { "adcQ", { Ev, Iv } },
1696 { "sbbQ", { Ev, Iv } },
1697 { "andQ", { Ev, Iv } },
1698 { "subQ", { Ev, Iv } },
1699 { "xorQ", { Ev, Iv } },
1700 { "cmpQ", { Ev, Iv } },
1701 },
1702 /* GRP1Ss */
1703 {
1704 { "addQ", { Ev, sIb } },
1705 { "orQ", { Ev, sIb } },
1706 { "adcQ", { Ev, sIb } },
1707 { "sbbQ", { Ev, sIb } },
1708 { "andQ", { Ev, sIb } },
1709 { "subQ", { Ev, sIb } },
1710 { "xorQ", { Ev, sIb } },
1711 { "cmpQ", { Ev, sIb } },
1712 },
1713 /* GRP2b */
1714 {
1715 { "rolA", { Eb, Ib } },
1716 { "rorA", { Eb, Ib } },
1717 { "rclA", { Eb, Ib } },
1718 { "rcrA", { Eb, Ib } },
1719 { "shlA", { Eb, Ib } },
1720 { "shrA", { Eb, Ib } },
1721 { "(bad)", { XX } },
1722 { "sarA", { Eb, Ib } },
1723 },
1724 /* GRP2S */
1725 {
1726 { "rolQ", { Ev, Ib } },
1727 { "rorQ", { Ev, Ib } },
1728 { "rclQ", { Ev, Ib } },
1729 { "rcrQ", { Ev, Ib } },
1730 { "shlQ", { Ev, Ib } },
1731 { "shrQ", { Ev, Ib } },
1732 { "(bad)", { XX } },
1733 { "sarQ", { Ev, Ib } },
1734 },
1735 /* GRP2b_one */
1736 {
1737 { "rolA", { Eb, I1 } },
1738 { "rorA", { Eb, I1 } },
1739 { "rclA", { Eb, I1 } },
1740 { "rcrA", { Eb, I1 } },
1741 { "shlA", { Eb, I1 } },
1742 { "shrA", { Eb, I1 } },
1743 { "(bad)", { XX } },
1744 { "sarA", { Eb, I1 } },
1745 },
1746 /* GRP2S_one */
1747 {
1748 { "rolQ", { Ev, I1 } },
1749 { "rorQ", { Ev, I1 } },
1750 { "rclQ", { Ev, I1 } },
1751 { "rcrQ", { Ev, I1 } },
1752 { "shlQ", { Ev, I1 } },
1753 { "shrQ", { Ev, I1 } },
1754 { "(bad)", { XX } },
1755 { "sarQ", { Ev, I1 } },
1756 },
1757 /* GRP2b_cl */
1758 {
1759 { "rolA", { Eb, CL } },
1760 { "rorA", { Eb, CL } },
1761 { "rclA", { Eb, CL } },
1762 { "rcrA", { Eb, CL } },
1763 { "shlA", { Eb, CL } },
1764 { "shrA", { Eb, CL } },
1765 { "(bad)", { XX } },
1766 { "sarA", { Eb, CL } },
1767 },
1768 /* GRP2S_cl */
1769 {
1770 { "rolQ", { Ev, CL } },
1771 { "rorQ", { Ev, CL } },
1772 { "rclQ", { Ev, CL } },
1773 { "rcrQ", { Ev, CL } },
1774 { "shlQ", { Ev, CL } },
1775 { "shrQ", { Ev, CL } },
1776 { "(bad)", { XX } },
1777 { "sarQ", { Ev, CL } },
1778 },
1779 /* GRP3b */
1780 {
1781 { "testA", { Eb, Ib } },
1782 { "(bad)", { Eb } },
1783 { "notA", { Eb } },
1784 { "negA", { Eb } },
1785 { "mulA", { Eb } }, /* Don't print the implicit %al register, */
1786 { "imulA", { Eb } }, /* to distinguish these opcodes from other */
1787 { "divA", { Eb } }, /* mul/imul opcodes. Do the same for div */
1788 { "idivA", { Eb } }, /* and idiv for consistency. */
1789 },
1790 /* GRP3S */
1791 {
1792 { "testQ", { Ev, Iv } },
1793 { "(bad)", { XX } },
1794 { "notQ", { Ev } },
1795 { "negQ", { Ev } },
1796 { "mulQ", { Ev } }, /* Don't print the implicit register. */
1797 { "imulQ", { Ev } },
1798 { "divQ", { Ev } },
1799 { "idivQ", { Ev } },
1800 },
1801 /* GRP4 */
1802 {
1803 { "incA", { Eb } },
1804 { "decA", { Eb } },
1805 { "(bad)", { XX } },
1806 { "(bad)", { XX } },
1807 { "(bad)", { XX } },
1808 { "(bad)", { XX } },
1809 { "(bad)", { XX } },
1810 { "(bad)", { XX } },
1811 },
1812 /* GRP5 */
1813 {
1814 { "incQ", { Ev } },
1815 { "decQ", { Ev } },
1816 { "callT", { indirEv } },
1817 { "JcallT", { indirEp } },
1818 { "jmpT", { indirEv } },
1819 { "JjmpT", { indirEp } },
1820 { "pushU", { stackEv } },
1821 { "(bad)", { XX } },
1822 },
1823 /* GRP6 */
1824 {
1825 { "sldtD", { Sv } },
1826 { "strD", { Sv } },
1827 { "lldt", { Ew } },
1828 { "ltr", { Ew } },
1829 { "verr", { Ew } },
1830 { "verw", { Ew } },
1831 { "(bad)", { XX } },
1832 { "(bad)", { XX } },
1833 },
1834 /* GRP7 */
1835 {
1836 { "sgdt{Q|IQ||}", { { VMX_Fixup, 0 } } },
1837 { "sidt{Q|IQ||}", { { PNI_Fixup, 0 } } },
1838 { "lgdt{Q|Q||}", { M } },
1839 { "lidt{Q|Q||}", { { SVME_Fixup, 0 } } },
1840 { "smswD", { Sv } },
1841 { "(bad)", { XX } },
1842 { "lmsw", { Ew } },
1843 { "invlpg", { { INVLPG_Fixup, w_mode } } },
1844 },
1845 /* GRP8 */
1846 {
1847 { "(bad)", { XX } },
1848 { "(bad)", { XX } },
1849 { "(bad)", { XX } },
1850 { "(bad)", { XX } },
1851 { "btQ", { Ev, Ib } },
1852 { "btsQ", { Ev, Ib } },
1853 { "btrQ", { Ev, Ib } },
1854 { "btcQ", { Ev, Ib } },
1855 },
1856 /* GRP9 */
1857 {
1858 { "(bad)", { XX } },
1859 { "cmpxchg8b", { { CMPXCHG8B_Fixup, q_mode } } },
1860 { "(bad)", { XX } },
1861 { "(bad)", { XX } },
1862 { "(bad)", { XX } },
1863 { "(bad)", { XX } },
1864 { "", { VM } }, /* See OP_VMX. */
1865 { "vmptrst", { Mq } },
1866 },
1867 /* GRP11_C6 */
1868 {
1869 { "movA", { Eb, Ib } },
1870 { "(bad)", { XX } },
1871 { "(bad)", { XX } },
1872 { "(bad)", { XX } },
1873 { "(bad)", { XX } },
1874 { "(bad)", { XX } },
1875 { "(bad)", { XX } },
1876 { "(bad)", { XX } },
1877 },
1878 /* GRP11_C7 */
1879 {
1880 { "movQ", { Ev, Iv } },
1881 { "(bad)", { XX } },
1882 { "(bad)", { XX } },
1883 { "(bad)", { XX } },
1884 { "(bad)", { XX } },
1885 { "(bad)", { XX } },
1886 { "(bad)", { XX } },
1887 { "(bad)", { XX } },
1888 },
1889 /* GRP12 */
1890 {
1891 { "(bad)", { XX } },
1892 { "(bad)", { XX } },
1893 { "psrlw", { MS, Ib } },
1894 { "(bad)", { XX } },
1895 { "psraw", { MS, Ib } },
1896 { "(bad)", { XX } },
1897 { "psllw", { MS, Ib } },
1898 { "(bad)", { XX } },
1899 },
1900 /* GRP13 */
1901 {
1902 { "(bad)", { XX } },
1903 { "(bad)", { XX } },
1904 { "psrld", { MS, Ib } },
1905 { "(bad)", { XX } },
1906 { "psrad", { MS, Ib } },
1907 { "(bad)", { XX } },
1908 { "pslld", { MS, Ib } },
1909 { "(bad)", { XX } },
1910 },
1911 /* GRP14 */
1912 {
1913 { "(bad)", { XX } },
1914 { "(bad)", { XX } },
1915 { "psrlq", { MS, Ib } },
1916 { "psrldq", { MS, Ib } },
1917 { "(bad)", { XX } },
1918 { "(bad)", { XX } },
1919 { "psllq", { MS, Ib } },
1920 { "pslldq", { MS, Ib } },
1921 },
1922 /* GRP15 */
1923 {
1924 { "fxsave", { Ev } },
1925 { "fxrstor", { Ev } },
1926 { "ldmxcsr", { Ev } },
1927 { "stmxcsr", { Ev } },
1928 { "(bad)", { XX } },
1929 { "lfence", { { OP_0fae, 0 } } },
1930 { "mfence", { { OP_0fae, 0 } } },
1931 { "clflush", { { OP_0fae, 0 } } },
1932 },
1933 /* GRP16 */
1934 {
1935 { "prefetchnta", { Ev } },
1936 { "prefetcht0", { Ev } },
1937 { "prefetcht1", { Ev } },
1938 { "prefetcht2", { Ev } },
1939 { "(bad)", { XX } },
1940 { "(bad)", { XX } },
1941 { "(bad)", { XX } },
1942 { "(bad)", { XX } },
1943 },
1944 /* GRPAMD */
1945 {
1946 { "prefetch", { Eb } },
1947 { "prefetchw", { Eb } },
1948 { "(bad)", { XX } },
1949 { "(bad)", { XX } },
1950 { "(bad)", { XX } },
1951 { "(bad)", { XX } },
1952 { "(bad)", { XX } },
1953 { "(bad)", { XX } },
1954 },
1955 /* GRPPADLCK1 */
1956 {
1957 { "xstore-rng", { { OP_0f07, 0 } } },
1958 { "xcrypt-ecb", { { OP_0f07, 0 } } },
1959 { "xcrypt-cbc", { { OP_0f07, 0 } } },
1960 { "xcrypt-ctr", { { OP_0f07, 0 } } },
1961 { "xcrypt-cfb", { { OP_0f07, 0 } } },
1962 { "xcrypt-ofb", { { OP_0f07, 0 } } },
1963 { "(bad)", { { OP_0f07, 0 } } },
1964 { "(bad)", { { OP_0f07, 0 } } },
1965 },
1966 /* GRPPADLCK2 */
1967 {
1968 { "montmul", { { OP_0f07, 0 } } },
1969 { "xsha1", { { OP_0f07, 0 } } },
1970 { "xsha256", { { OP_0f07, 0 } } },
1971 { "(bad)", { { OP_0f07, 0 } } },
1972 { "(bad)", { { OP_0f07, 0 } } },
1973 { "(bad)", { { OP_0f07, 0 } } },
1974 { "(bad)", { { OP_0f07, 0 } } },
1975 { "(bad)", { { OP_0f07, 0 } } },
1976 }
1977 };
1978
1979 static const struct dis386 prefix_user_table[][4] = {
1980 /* PREGRP0 */
1981 {
1982 { "addps", { XM, EXx } },
1983 { "addss", { XM, EXd } },
1984 { "addpd", { XM, EXx } },
1985 { "addsd", { XM, EXq } },
1986 },
1987 /* PREGRP1 */
1988 {
1989 { "", { XM, EXx, OPSIMD } }, /* See OP_SIMD_SUFFIX. */
1990 { "", { XM, EXx, OPSIMD } },
1991 { "", { XM, EXx, OPSIMD } },
1992 { "", { XM, EXx, OPSIMD } },
1993 },
1994 /* PREGRP2 */
1995 {
1996 { "cvtpi2ps", { XM, EMC } },
1997 { "cvtsi2ssY", { XM, Ev } },
1998 { "cvtpi2pd", { XM, EMC } },
1999 { "cvtsi2sdY", { XM, Ev } },
2000 },
2001 /* PREGRP3 */
2002 {
2003 { "cvtps2pi", { MXC, EXx } },
2004 { "cvtss2siY", { Gv, EXx } },
2005 { "cvtpd2pi", { MXC, EXx } },
2006 { "cvtsd2siY", { Gv, EXx } },
2007 },
2008 /* PREGRP4 */
2009 {
2010 { "cvttps2pi", { MXC, EXx } },
2011 { "cvttss2siY", { Gv, EXx } },
2012 { "cvttpd2pi", { MXC, EXx } },
2013 { "cvttsd2siY", { Gv, EXx } },
2014 },
2015 /* PREGRP5 */
2016 {
2017 { "divps", { XM, EXx } },
2018 { "divss", { XM, EXx } },
2019 { "divpd", { XM, EXx } },
2020 { "divsd", { XM, EXx } },
2021 },
2022 /* PREGRP6 */
2023 {
2024 { "maxps", { XM, EXx } },
2025 { "maxss", { XM, EXx } },
2026 { "maxpd", { XM, EXx } },
2027 { "maxsd", { XM, EXx } },
2028 },
2029 /* PREGRP7 */
2030 {
2031 { "minps", { XM, EXx } },
2032 { "minss", { XM, EXx } },
2033 { "minpd", { XM, EXx } },
2034 { "minsd", { XM, EXx } },
2035 },
2036 /* PREGRP8 */
2037 {
2038 { "movups", { XM, EXx } },
2039 { "movss", { XM, EXx } },
2040 { "movupd", { XM, EXx } },
2041 { "movsd", { XM, EXx } },
2042 },
2043 /* PREGRP9 */
2044 {
2045 { "movups", { EXx, XM } },
2046 { "movss", { EXx, XM } },
2047 { "movupd", { EXx, XM } },
2048 { "movsd", { EXx, XM } },
2049 },
2050 /* PREGRP10 */
2051 {
2052 { "mulps", { XM, EXx } },
2053 { "mulss", { XM, EXx } },
2054 { "mulpd", { XM, EXx } },
2055 { "mulsd", { XM, EXx } },
2056 },
2057 /* PREGRP11 */
2058 {
2059 { "rcpps", { XM, EXx } },
2060 { "rcpss", { XM, EXx } },
2061 { "(bad)", { XM, EXx } },
2062 { "(bad)", { XM, EXx } },
2063 },
2064 /* PREGRP12 */
2065 {
2066 { "rsqrtps",{ XM, EXx } },
2067 { "rsqrtss",{ XM, EXx } },
2068 { "(bad)", { XM, EXx } },
2069 { "(bad)", { XM, EXx } },
2070 },
2071 /* PREGRP13 */
2072 {
2073 { "sqrtps", { XM, EXx } },
2074 { "sqrtss", { XM, EXx } },
2075 { "sqrtpd", { XM, EXx } },
2076 { "sqrtsd", { XM, EXx } },
2077 },
2078 /* PREGRP14 */
2079 {
2080 { "subps", { XM, EXx } },
2081 { "subss", { XM, EXx } },
2082 { "subpd", { XM, EXx } },
2083 { "subsd", { XM, EXx } },
2084 },
2085 /* PREGRP15 */
2086 {
2087 { "(bad)", { XM, EXx } },
2088 { "cvtdq2pd", { XM, EXq } },
2089 { "cvttpd2dq", { XM, EXx } },
2090 { "cvtpd2dq", { XM, EXx } },
2091 },
2092 /* PREGRP16 */
2093 {
2094 { "cvtdq2ps", { XM, EXx } },
2095 { "cvttps2dq", { XM, EXx } },
2096 { "cvtps2dq", { XM, EXx } },
2097 { "(bad)", { XM, EXx } },
2098 },
2099 /* PREGRP17 */
2100 {
2101 { "cvtps2pd", { XM, EXq } },
2102 { "cvtss2sd", { XM, EXx } },
2103 { "cvtpd2ps", { XM, EXx } },
2104 { "cvtsd2ss", { XM, EXx } },
2105 },
2106 /* PREGRP18 */
2107 {
2108 { "maskmovq", { MX, MS } },
2109 { "(bad)", { XM, EXx } },
2110 { "maskmovdqu", { XM, XS } },
2111 { "(bad)", { XM, EXx } },
2112 },
2113 /* PREGRP19 */
2114 {
2115 { "movq", { MX, EM } },
2116 { "movdqu", { XM, EXx } },
2117 { "movdqa", { XM, EXx } },
2118 { "(bad)", { XM, EXx } },
2119 },
2120 /* PREGRP20 */
2121 {
2122 { "movq", { EM, MX } },
2123 { "movdqu", { EXx, XM } },
2124 { "movdqa", { EXx, XM } },
2125 { "(bad)", { EXx, XM } },
2126 },
2127 /* PREGRP21 */
2128 {
2129 { "(bad)", { EXx, XM } },
2130 { "movq2dq",{ XM, MS } },
2131 { "movq", { EXx, XM } },
2132 { "movdq2q",{ MX, XS } },
2133 },
2134 /* PREGRP22 */
2135 {
2136 { "pshufw", { MX, EM, Ib } },
2137 { "pshufhw",{ XM, EXx, Ib } },
2138 { "pshufd", { XM, EXx, Ib } },
2139 { "pshuflw",{ XM, EXx, Ib } },
2140 },
2141 /* PREGRP23 */
2142 {
2143 { "movd", { Edq, MX } },
2144 { "movq", { XM, EXx } },
2145 { "movd", { Edq, XM } },
2146 { "(bad)", { Ed, XM } },
2147 },
2148 /* PREGRP24 */
2149 {
2150 { "(bad)", { MX, EXx } },
2151 { "(bad)", { XM, EXx } },
2152 { "punpckhqdq", { XM, EXx } },
2153 { "(bad)", { XM, EXx } },
2154 },
2155 /* PREGRP25 */
2156 {
2157 { "movntq", { EM, MX } },
2158 { "(bad)", { EM, XM } },
2159 { "movntdq",{ EM, XM } },
2160 { "(bad)", { EM, XM } },
2161 },
2162 /* PREGRP26 */
2163 {
2164 { "(bad)", { MX, EXx } },
2165 { "(bad)", { XM, EXx } },
2166 { "punpcklqdq", { XM, EXx } },
2167 { "(bad)", { XM, EXx } },
2168 },
2169 /* PREGRP27 */
2170 {
2171 { "(bad)", { MX, EXx } },
2172 { "(bad)", { XM, EXx } },
2173 { "addsubpd", { XM, EXx } },
2174 { "addsubps", { XM, EXx } },
2175 },
2176 /* PREGRP28 */
2177 {
2178 { "(bad)", { MX, EXx } },
2179 { "(bad)", { XM, EXx } },
2180 { "haddpd", { XM, EXx } },
2181 { "haddps", { XM, EXx } },
2182 },
2183 /* PREGRP29 */
2184 {
2185 { "(bad)", { MX, EXx } },
2186 { "(bad)", { XM, EXx } },
2187 { "hsubpd", { XM, EXx } },
2188 { "hsubps", { XM, EXx } },
2189 },
2190 /* PREGRP30 */
2191 {
2192 { "movlpX", { XM, EXq, { SIMD_Fixup, 'h' } } }, /* really only 2 operands */
2193 { "movsldup", { XM, EXx } },
2194 { "movlpd", { XM, EXq } },
2195 { "movddup", { XM, EXq } },
2196 },
2197 /* PREGRP31 */
2198 {
2199 { "movhpX", { XM, EXq, { SIMD_Fixup, 'l' } } },
2200 { "movshdup", { XM, EXx } },
2201 { "movhpd", { XM, EXq } },
2202 { "(bad)", { XM, EXq } },
2203 },
2204 /* PREGRP32 */
2205 {
2206 { "(bad)", { XM, EXx } },
2207 { "(bad)", { XM, EXx } },
2208 { "(bad)", { XM, EXx } },
2209 { "lddqu", { XM, M } },
2210 },
2211 /* PREGRP33 */
2212 {
2213 {"movntps", { Ev, XM } },
2214 {"movntss", { Ev, XM } },
2215 {"movntpd", { Ev, XM } },
2216 {"movntsd", { Ev, XM } },
2217 },
2218
2219 /* PREGRP34 */
2220 {
2221 {"vmread", { Em, Gm } },
2222 {"(bad)", { XX } },
2223 {"extrq", { XS, Ib, Ib } },
2224 {"insertq", { XM, XS, Ib, Ib } },
2225 },
2226
2227 /* PREGRP35 */
2228 {
2229 {"vmwrite", { Gm, Em } },
2230 {"(bad)", { XX } },
2231 {"extrq", { XM, XS } },
2232 {"insertq", { XM, XS } },
2233 },
2234
2235 /* PREGRP36 */
2236 {
2237 { "bsrS", { Gv, Ev } },
2238 { "lzcntS", { Gv, Ev } },
2239 { "bsrS", { Gv, Ev } },
2240 { "(bad)", { XX } },
2241 },
2242
2243 /* PREGRP37 */
2244 {
2245 { "(bad)", { XX } },
2246 { "popcntS", { Gv, Ev } },
2247 { "(bad)", { XX } },
2248 { "(bad)", { XX } },
2249 },
2250
2251 /* PREGRP38 */
2252 {
2253 { "xchgS", { { NOP_Fixup1, eAX_reg }, { NOP_Fixup2, eAX_reg } } },
2254 { "pause", { XX } },
2255 { "xchgS", { { NOP_Fixup1, eAX_reg }, { NOP_Fixup2, eAX_reg } } },
2256 { "(bad)", { XX } },
2257 },
2258
2259 /* PREGRP39 */
2260 {
2261 { "(bad)", { XX } },
2262 { "(bad)", { XX } },
2263 { "pblendvb", {XM, EXx, XMM0 } },
2264 { "(bad)", { XX } },
2265 },
2266
2267 /* PREGRP40 */
2268 {
2269 { "(bad)", { XX } },
2270 { "(bad)", { XX } },
2271 { "blendvps", {XM, EXx, XMM0 } },
2272 { "(bad)", { XX } },
2273 },
2274
2275 /* PREGRP41 */
2276 {
2277 { "(bad)", { XX } },
2278 { "(bad)", { XX } },
2279 { "blendvpd", { XM, EXx, XMM0 } },
2280 { "(bad)", { XX } },
2281 },
2282
2283 /* PREGRP42 */
2284 {
2285 { "(bad)", { XX } },
2286 { "(bad)", { XX } },
2287 { "ptest", { XM, EXx } },
2288 { "(bad)", { XX } },
2289 },
2290
2291 /* PREGRP43 */
2292 {
2293 { "(bad)", { XX } },
2294 { "(bad)", { XX } },
2295 { "pmovsxbw", { XM, EXx } },
2296 { "(bad)", { XX } },
2297 },
2298
2299 /* PREGRP44 */
2300 {
2301 { "(bad)", { XX } },
2302 { "(bad)", { XX } },
2303 { "pmovsxbd", { XM, EXx } },
2304 { "(bad)", { XX } },
2305 },
2306
2307 /* PREGRP45 */
2308 {
2309 { "(bad)", { XX } },
2310 { "(bad)", { XX } },
2311 { "pmovsxbq", { XM, EXx } },
2312 { "(bad)", { XX } },
2313 },
2314
2315 /* PREGRP46 */
2316 {
2317 { "(bad)", { XX } },
2318 { "(bad)", { XX } },
2319 { "pmovsxwd", { XM, EXx } },
2320 { "(bad)", { XX } },
2321 },
2322
2323 /* PREGRP47 */
2324 {
2325 { "(bad)", { XX } },
2326 { "(bad)", { XX } },
2327 { "pmovsxwq", { XM, EXx } },
2328 { "(bad)", { XX } },
2329 },
2330
2331 /* PREGRP48 */
2332 {
2333 { "(bad)", { XX } },
2334 { "(bad)", { XX } },
2335 { "pmovsxdq", { XM, EXx } },
2336 { "(bad)", { XX } },
2337 },
2338
2339 /* PREGRP49 */
2340 {
2341 { "(bad)", { XX } },
2342 { "(bad)", { XX } },
2343 { "pmuldq", { XM, EXx } },
2344 { "(bad)", { XX } },
2345 },
2346
2347 /* PREGRP50 */
2348 {
2349 { "(bad)", { XX } },
2350 { "(bad)", { XX } },
2351 { "pcmpeqq", { XM, EXx } },
2352 { "(bad)", { XX } },
2353 },
2354
2355 /* PREGRP51 */
2356 {
2357 { "(bad)", { XX } },
2358 { "(bad)", { XX } },
2359 { "movntdqa", { XM, EM } },
2360 { "(bad)", { XX } },
2361 },
2362
2363 /* PREGRP52 */
2364 {
2365 { "(bad)", { XX } },
2366 { "(bad)", { XX } },
2367 { "packusdw", { XM, EXx } },
2368 { "(bad)", { XX } },
2369 },
2370
2371 /* PREGRP53 */
2372 {
2373 { "(bad)", { XX } },
2374 { "(bad)", { XX } },
2375 { "pmovzxbw", { XM, EXx } },
2376 { "(bad)", { XX } },
2377 },
2378
2379 /* PREGRP54 */
2380 {
2381 { "(bad)", { XX } },
2382 { "(bad)", { XX } },
2383 { "pmovzxbd", { XM, EXx } },
2384 { "(bad)", { XX } },
2385 },
2386
2387 /* PREGRP55 */
2388 {
2389 { "(bad)", { XX } },
2390 { "(bad)", { XX } },
2391 { "pmovzxbq", { XM, EXx } },
2392 { "(bad)", { XX } },
2393 },
2394
2395 /* PREGRP56 */
2396 {
2397 { "(bad)", { XX } },
2398 { "(bad)", { XX } },
2399 { "pmovzxwd", { XM, EXx } },
2400 { "(bad)", { XX } },
2401 },
2402
2403 /* PREGRP57 */
2404 {
2405 { "(bad)", { XX } },
2406 { "(bad)", { XX } },
2407 { "pmovzxwq", { XM, EXx } },
2408 { "(bad)", { XX } },
2409 },
2410
2411 /* PREGRP58 */
2412 {
2413 { "(bad)", { XX } },
2414 { "(bad)", { XX } },
2415 { "pmovzxdq", { XM, EXx } },
2416 { "(bad)", { XX } },
2417 },
2418
2419 /* PREGRP59 */
2420 {
2421 { "(bad)", { XX } },
2422 { "(bad)", { XX } },
2423 { "pminsb", { XM, EXx } },
2424 { "(bad)", { XX } },
2425 },
2426
2427 /* PREGRP60 */
2428 {
2429 { "(bad)", { XX } },
2430 { "(bad)", { XX } },
2431 { "pminsd", { XM, EXx } },
2432 { "(bad)", { XX } },
2433 },
2434
2435 /* PREGRP61 */
2436 {
2437 { "(bad)", { XX } },
2438 { "(bad)", { XX } },
2439 { "pminuw", { XM, EXx } },
2440 { "(bad)", { XX } },
2441 },
2442
2443 /* PREGRP62 */
2444 {
2445 { "(bad)", { XX } },
2446 { "(bad)", { XX } },
2447 { "pminud", { XM, EXx } },
2448 { "(bad)", { XX } },
2449 },
2450
2451 /* PREGRP63 */
2452 {
2453 { "(bad)", { XX } },
2454 { "(bad)", { XX } },
2455 { "pmaxsb", { XM, EXx } },
2456 { "(bad)", { XX } },
2457 },
2458
2459 /* PREGRP64 */
2460 {
2461 { "(bad)", { XX } },
2462 { "(bad)", { XX } },
2463 { "pmaxsd", { XM, EXx } },
2464 { "(bad)", { XX } },
2465 },
2466
2467 /* PREGRP65 */
2468 {
2469 { "(bad)", { XX } },
2470 { "(bad)", { XX } },
2471 { "pmaxuw", { XM, EXx } },
2472 { "(bad)", { XX } },
2473 },
2474
2475 /* PREGRP66 */
2476 {
2477 { "(bad)", { XX } },
2478 { "(bad)", { XX } },
2479 { "pmaxud", { XM, EXx } },
2480 { "(bad)", { XX } },
2481 },
2482
2483 /* PREGRP67 */
2484 {
2485 { "(bad)", { XX } },
2486 { "(bad)", { XX } },
2487 { "pmulld", { XM, EXx } },
2488 { "(bad)", { XX } },
2489 },
2490
2491 /* PREGRP68 */
2492 {
2493 { "(bad)", { XX } },
2494 { "(bad)", { XX } },
2495 { "phminposuw", { XM, EXx } },
2496 { "(bad)", { XX } },
2497 },
2498
2499 /* PREGRP69 */
2500 {
2501 { "(bad)", { XX } },
2502 { "(bad)", { XX } },
2503 { "roundps", { XM, EXx, Ib } },
2504 { "(bad)", { XX } },
2505 },
2506
2507 /* PREGRP70 */
2508 {
2509 { "(bad)", { XX } },
2510 { "(bad)", { XX } },
2511 { "roundpd", { XM, EXx, Ib } },
2512 { "(bad)", { XX } },
2513 },
2514
2515 /* PREGRP71 */
2516 {
2517 { "(bad)", { XX } },
2518 { "(bad)", { XX } },
2519 { "roundss", { XM, EXx, Ib } },
2520 { "(bad)", { XX } },
2521 },
2522
2523 /* PREGRP72 */
2524 {
2525 { "(bad)", { XX } },
2526 { "(bad)", { XX } },
2527 { "roundsd", { XM, EXx, Ib } },
2528 { "(bad)", { XX } },
2529 },
2530
2531 /* PREGRP73 */
2532 {
2533 { "(bad)", { XX } },
2534 { "(bad)", { XX } },
2535 { "blendps", { XM, EXx, Ib } },
2536 { "(bad)", { XX } },
2537 },
2538
2539 /* PREGRP74 */
2540 {
2541 { "(bad)", { XX } },
2542 { "(bad)", { XX } },
2543 { "blendpd", { XM, EXx, Ib } },
2544 { "(bad)", { XX } },
2545 },
2546
2547 /* PREGRP75 */
2548 {
2549 { "(bad)", { XX } },
2550 { "(bad)", { XX } },
2551 { "pblendw", { XM, EXx, Ib } },
2552 { "(bad)", { XX } },
2553 },
2554
2555 /* PREGRP76 */
2556 {
2557 { "(bad)", { XX } },
2558 { "(bad)", { XX } },
2559 { "pextrb", { Edqb, XM, Ib } },
2560 { "(bad)", { XX } },
2561 },
2562
2563 /* PREGRP77 */
2564 {
2565 { "(bad)", { XX } },
2566 { "(bad)", { XX } },
2567 { "pextrw", { Edqw, XM, Ib } },
2568 { "(bad)", { XX } },
2569 },
2570
2571 /* PREGRP78 */
2572 {
2573 { "(bad)", { XX } },
2574 { "(bad)", { XX } },
2575 { "pextrK", { Edq, XM, Ib } },
2576 { "(bad)", { XX } },
2577 },
2578
2579 /* PREGRP79 */
2580 {
2581 { "(bad)", { XX } },
2582 { "(bad)", { XX } },
2583 { "extractps", { Edqd, XM, Ib } },
2584 { "(bad)", { XX } },
2585 },
2586
2587 /* PREGRP80 */
2588 {
2589 { "(bad)", { XX } },
2590 { "(bad)", { XX } },
2591 { "pinsrb", { XM, Edqb, Ib } },
2592 { "(bad)", { XX } },
2593 },
2594
2595 /* PREGRP81 */
2596 {
2597 { "(bad)", { XX } },
2598 { "(bad)", { XX } },
2599 { "insertps", { XM, EXx, Ib } },
2600 { "(bad)", { XX } },
2601 },
2602
2603 /* PREGRP82 */
2604 {
2605 { "(bad)", { XX } },
2606 { "(bad)", { XX } },
2607 { "pinsrK", { XM, Edq, Ib } },
2608 { "(bad)", { XX } },
2609 },
2610
2611 /* PREGRP83 */
2612 {
2613 { "(bad)", { XX } },
2614 { "(bad)", { XX } },
2615 { "dpps", { XM, EXx, Ib } },
2616 { "(bad)", { XX } },
2617 },
2618
2619 /* PREGRP84 */
2620 {
2621 { "(bad)", { XX } },
2622 { "(bad)", { XX } },
2623 { "dppd", { XM, EXx, Ib } },
2624 { "(bad)", { XX } },
2625 },
2626
2627 /* PREGRP85 */
2628 {
2629 { "(bad)", { XX } },
2630 { "(bad)", { XX } },
2631 { "mpsadbw", { XM, EXx, Ib } },
2632 { "(bad)", { XX } },
2633 },
2634
2635 /* PREGRP86 */
2636 {
2637 { "(bad)", { XX } },
2638 { "(bad)", { XX } },
2639 { "pcmpgtq", { XM, EXx } },
2640 { "(bad)", { XX } },
2641 },
2642
2643 /* PREGRP87 */
2644 {
2645 { "movbe", { Gv, Ev } },
2646 { "(bad)", { XX } },
2647 { "movbe", { Gv, Ev } },
2648 { "crc32", { Gdq, { CRC32_Fixup, b_mode } } },
2649 },
2650
2651 /* PREGRP88 */
2652 {
2653 { "movbe", { Ev, Gv } },
2654 { "(bad)", { XX } },
2655 { "movbe", { Ev, Gv } },
2656 { "crc32", { Gdq, { CRC32_Fixup, v_mode } } },
2657 },
2658
2659 /* PREGRP89 */
2660 {
2661 { "(bad)", { XX } },
2662 { "(bad)", { XX } },
2663 { "pcmpestrm", { XM, EXx, Ib } },
2664 { "(bad)", { XX } },
2665 },
2666
2667 /* PREGRP90 */
2668 {
2669 { "(bad)", { XX } },
2670 { "(bad)", { XX } },
2671 { "pcmpestri", { XM, EXx, Ib } },
2672 { "(bad)", { XX } },
2673 },
2674
2675 /* PREGRP91 */
2676 {
2677 { "(bad)", { XX } },
2678 { "(bad)", { XX } },
2679 { "pcmpistrm", { XM, EXx, Ib } },
2680 { "(bad)", { XX } },
2681 },
2682
2683 /* PREGRP92 */
2684 {
2685 { "(bad)", { XX } },
2686 { "(bad)", { XX } },
2687 { "pcmpistri", { XM, EXx, Ib } },
2688 { "(bad)", { XX } },
2689 },
2690
2691 /* PREGRP93 */
2692 {
2693 { "ucomiss",{ XM, EXd } },
2694 { "(bad)", { XX } },
2695 { "ucomisd",{ XM, EXq } },
2696 { "(bad)", { XX } },
2697 },
2698
2699 /* PREGRP94 */
2700 {
2701 { "comiss", { XM, EXd } },
2702 { "(bad)", { XX } },
2703 { "comisd", { XM, EXq } },
2704 { "(bad)", { XX } },
2705 },
2706
2707 /* PREGRP95 */
2708 {
2709 { "punpcklbw",{ MX, EMd } },
2710 { "(bad)", { XX } },
2711 { "punpcklbw",{ MX, EMq } },
2712 { "(bad)", { XX } },
2713 },
2714
2715 /* PREGRP96 */
2716 {
2717 { "punpcklwd",{ MX, EMd } },
2718 { "(bad)", { XX } },
2719 { "punpcklwd",{ MX, EMq } },
2720 { "(bad)", { XX } },
2721 },
2722
2723 /* PREGRP97 */
2724 {
2725 { "punpckldq",{ MX, EMd } },
2726 { "(bad)", { XX } },
2727 { "punpckldq",{ MX, EMq } },
2728 { "(bad)", { XX } },
2729 },
2730
2731 /* PREGRP98 */
2732 {
2733 { "(bad)", { XX } },
2734 { "(bad)", { XX } },
2735 { "pclmulqdq", { XM, EXx, Ib } },
2736 { "(bad)", { XX } },
2737 },
2738
2739 /* PREGRP99 */
2740 {
2741 { "(bad)", { XX } },
2742 { "(bad)", { XX } },
2743 { "aesimc", { XM, EXx } },
2744 { "(bad)", { XX } },
2745 },
2746
2747 /* PREGRP100 */
2748 {
2749 { "(bad)", { XX } },
2750 { "(bad)", { XX } },
2751 { "aesenc", { XM, EXx } },
2752 { "(bad)", { XX } },
2753 },
2754
2755 /* PREGRP101 */
2756 {
2757 { "(bad)", { XX } },
2758 { "(bad)", { XX } },
2759 { "aesenclast", { XM, EXx } },
2760 { "(bad)", { XX } },
2761 },
2762
2763 /* PREGRP102 */
2764 {
2765 { "(bad)", { XX } },
2766 { "(bad)", { XX } },
2767 { "aesdec", { XM, EXx } },
2768 { "(bad)", { XX } },
2769 },
2770
2771 /* PREGRP103 */
2772 {
2773 { "(bad)", { XX } },
2774 { "(bad)", { XX } },
2775 { "aesdeclast", { XM, EXx } },
2776 { "(bad)", { XX } },
2777 },
2778
2779 /* PREGRP104 */
2780 {
2781 { "(bad)", { XX } },
2782 { "(bad)", { XX } },
2783 { "aeskeygenassist", { XM, EXx, Ib } },
2784 { "(bad)", { XX } },
2785 },
2786
2787 /* PREGRP105 */
2788 {
2789 { "andnS", { Gv, Bv, Ev } },
2790 { "(bad)", { XX } },
2791 { "(bad)", { XX } },
2792 { "(bad)", { XX } },
2793 },
2794
2795 /* PREGRP106 */
2796 {
2797 { "bextrS", { Gv, Ev, Bv } },
2798 { "sarxS", { Gv, Ev, Bv } },
2799 { "shlxS", { Gv, Ev, Bv } },
2800 { "shrxS", { Gv, Ev, Bv } },
2801 },
2802
2803 };
2804
2805 static const struct dis386 x86_64_table[][2] = {
2806 {
2807 { "pusha{P|}", { XX } },
2808 { "(bad)", { XX } },
2809 },
2810 {
2811 { "popa{P|}", { XX } },
2812 { "(bad)", { XX } },
2813 },
2814 {
2815 { "bound{S|}", { Gv, Ma } },
2816 { "(bad)", { XX } },
2817 },
2818 {
2819 { "arpl", { Ew, Gw } },
2820 { "movs{||lq|xd}", { Gv, Ed } },
2821 },
2822 };
2823
2824 static const struct dis386 three_byte_table[][256] = {
2825 /* THREE_BYTE_0 */
2826 {
2827 /* 00 */
2828 { "pshufb", { MX, EM } },
2829 { "phaddw", { MX, EM } },
2830 { "phaddd", { MX, EM } },
2831 { "phaddsw", { MX, EM } },
2832 { "pmaddubsw", { MX, EM } },
2833 { "phsubw", { MX, EM } },
2834 { "phsubd", { MX, EM } },
2835 { "phsubsw", { MX, EM } },
2836 /* 08 */
2837 { "psignb", { MX, EM } },
2838 { "psignw", { MX, EM } },
2839 { "psignd", { MX, EM } },
2840 { "pmulhrsw", { MX, EM } },
2841 { "(bad)", { XX } },
2842 { "(bad)", { XX } },
2843 { "(bad)", { XX } },
2844 { "(bad)", { XX } },
2845 /* 10 */
2846 { PREGRP39 },
2847 { "(bad)", { XX } },
2848 { "(bad)", { XX } },
2849 { "(bad)", { XX } },
2850 { PREGRP40 },
2851 { PREGRP41 },
2852 { "(bad)", { XX } },
2853 { PREGRP42 },
2854 /* 18 */
2855 { "(bad)", { XX } },
2856 { "(bad)", { XX } },
2857 { "(bad)", { XX } },
2858 { "(bad)", { XX } },
2859 { "pabsb", { MX, EM } },
2860 { "pabsw", { MX, EM } },
2861 { "pabsd", { MX, EM } },
2862 { "(bad)", { XX } },