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.
6 This file is part of GDB.
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.
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.
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/>. */
21 /* 80386 instruction printer by Pace Willisson (pace@prep.ai.mit.edu)
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). */
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. */
35 #include "disas/bfd.h"
36 /* include/opcode/i386.h r1.78 */
38 /* opcode/i386.h -- Intel 80386 opcode macros
39 Copyright 1989, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
40 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007
41 Free Software Foundation, Inc.
43 This file is part of GAS, the GNU Assembler, and GDB, the GNU Debugger.
45 This program is free software; you can redistribute it and/or modify
46 it under the terms of the GNU General Public License as published by
47 the Free Software Foundation; either version 2 of the License, or
48 (at your option) any later version.
50 This program is distributed in the hope that it will be useful,
51 but WITHOUT ANY WARRANTY; without even the implied warranty of
52 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
53 GNU General Public License for more details.
55 You should have received a copy of the GNU General Public License
56 along with this program; if not, see <http://www.gnu.org/licenses/>. */
58 /* The SystemV/386 SVR3.2 assembler, and probably all AT&T derived
59 ix86 Unix assemblers, generate floating point instructions with
60 reversed source and destination registers in certain cases.
61 Unfortunately, gcc and possibly many other programs use this
62 reversed syntax, so we're stuck with it.
64 eg. `fsub %st(3),%st' results in st = st - st(3) as expected, but
65 `fsub %st,%st(3)' results in st(3) = st - st(3), rather than
66 the expected st(3) = st(3) - st
68 This happens with all the non-commutative arithmetic floating point
69 operations with two register operands, where the source register is
70 %st, and destination register is %st(i).
72 The affected opcode map is dceX, dcfX, deeX, defX. */
74 #ifndef SYSV386_COMPAT
75 /* Set non-zero for broken, compatible instructions. Set to zero for
76 non-broken opcodes at your peril. gcc generates SystemV/386
77 compatible instructions. */
78 #define SYSV386_COMPAT 1
81 /* Set non-zero to cater for old (<= 2.8.1) versions of gcc that could
82 generate nonsense fsubp, fsubrp, fdivp and fdivrp with operands
84 #define OLDGCC_COMPAT SYSV386_COMPAT
87 #define MOV_AX_DISP32 0xa0
88 #define POP_SEG_SHORT 0x07
89 #define JUMP_PC_RELATIVE 0xeb
90 #define INT_OPCODE 0xcd
91 #define INT3_OPCODE 0xcc
92 /* The opcode for the fwait instruction, which disassembler treats as a
93 prefix when it can. */
94 #define FWAIT_OPCODE 0x9b
95 #define ADDR_PREFIX_OPCODE 0x67
96 #define DATA_PREFIX_OPCODE 0x66
97 #define LOCK_PREFIX_OPCODE 0xf0
98 #define CS_PREFIX_OPCODE 0x2e
99 #define DS_PREFIX_OPCODE 0x3e
100 #define ES_PREFIX_OPCODE 0x26
101 #define FS_PREFIX_OPCODE 0x64
102 #define GS_PREFIX_OPCODE 0x65
103 #define SS_PREFIX_OPCODE 0x36
104 #define REPNE_PREFIX_OPCODE 0xf2
105 #define REPE_PREFIX_OPCODE 0xf3
107 #define TWO_BYTE_OPCODE_ESCAPE 0x0f
108 #define NOP_OPCODE (char) 0x90
110 /* register numbers */
111 #define EBP_REG_NUM 5
112 #define ESP_REG_NUM 4
114 /* modrm_byte.regmem for twobyte escape */
115 #define ESCAPE_TO_TWO_BYTE_ADDRESSING ESP_REG_NUM
116 /* index_base_byte.index for no index register addressing */
117 #define NO_INDEX_REGISTER ESP_REG_NUM
118 /* index_base_byte.base for no base register addressing */
119 #define NO_BASE_REGISTER EBP_REG_NUM
120 #define NO_BASE_REGISTER_16 6
122 /* modrm.mode = REGMEM_FIELD_HAS_REG when a register is in there */
123 #define REGMEM_FIELD_HAS_REG 0x3/* always = 0x3 */
124 #define REGMEM_FIELD_HAS_MEM (~REGMEM_FIELD_HAS_REG)
126 /* x86-64 extension prefix. */
127 #define REX_OPCODE 0x40
129 /* Indicates 64 bit operand size. */
131 /* High extension to reg field of modrm byte. */
133 /* High extension to SIB index field. */
135 /* High extension to base field of modrm or SIB, or reg field of opcode. */
138 /* max operands per insn */
139 #define MAX_OPERANDS 4
141 /* max immediates per insn (lcall, ljmp, insertq, extrq) */
142 #define MAX_IMMEDIATE_OPERANDS 2
144 /* max memory refs per insn (string ops) */
145 #define MAX_MEMORY_OPERANDS 2
147 /* max size of insn mnemonics. */
148 #define MAX_MNEM_SIZE 16
150 /* max size of register name in insn mnemonics. */
151 #define MAX_REG_NAME_SIZE 8
153 /* opcodes/i386-dis.c r1.126 */
154 #include "qemu-common.h"
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 bfd_vma
get64 (void);
175 static bfd_signed_vma
get32 (void);
176 static bfd_signed_vma
get32s (void);
177 static int get16 (void);
178 static void set_op (bfd_vma
, int);
179 static void OP_REG (int, int);
180 static void OP_IMREG (int, int);
181 static void OP_I (int, int);
182 static void OP_I64 (int, int);
183 static void OP_sI (int, int);
184 static void OP_J (int, int);
185 static void OP_SEG (int, int);
186 static void OP_DIR (int, int);
187 static void OP_OFF (int, int);
188 static void OP_OFF64 (int, int);
189 static void ptr_reg (int, int);
190 static void OP_ESreg (int, int);
191 static void OP_DSreg (int, int);
192 static void OP_C (int, int);
193 static void OP_D (int, int);
194 static void OP_T (int, int);
195 static void OP_R (int, int);
196 static void OP_MMX (int, int);
197 static void OP_XMM (int, int);
198 static void OP_EM (int, int);
199 static void OP_EX (int, int);
200 static void OP_EMC (int,int);
201 static void OP_MXC (int,int);
202 static void OP_MS (int, int);
203 static void OP_XS (int, int);
204 static void OP_M (int, int);
205 static void OP_VMX (int, int);
206 static void OP_0fae (int, int);
207 static void OP_0f07 (int, int);
208 static void NOP_Fixup1 (int, int);
209 static void NOP_Fixup2 (int, int);
210 static void OP_3DNowSuffix (int, int);
211 static void OP_SIMD_Suffix (int, int);
212 static void SIMD_Fixup (int, int);
213 static void PNI_Fixup (int, int);
214 static void SVME_Fixup (int, int);
215 static void INVLPG_Fixup (int, int);
216 static void BadOp (void);
217 static void VMX_Fixup (int, int);
218 static void REP_Fixup (int, int);
219 static void CMPXCHG8B_Fixup (int, int);
220 static void XMM_Fixup (int, int);
221 static void CRC32_Fixup (int, int);
224 /* Points to first byte not fetched. */
225 bfd_byte
*max_fetched
;
226 bfd_byte the_buffer
[MAX_MNEM_SIZE
];
239 static enum address_mode address_mode
;
241 /* Flags for the prefixes for the current instruction. See below. */
244 /* REX prefix the current instruction. See below. */
246 /* Bits of REX we've already used. */
248 /* Mark parts used in the REX prefix. When we are testing for
249 empty prefix (for 8bit register REX extension), just mask it
250 out. Otherwise test for REX bit is excuse for existence of REX
251 only in case value is nonzero. */
252 #define USED_REX(value) \
257 rex_used |= (value) | REX_OPCODE; \
260 rex_used |= REX_OPCODE; \
263 /* Flags for prefixes which we somehow handled when printing the
264 current instruction. */
265 static int used_prefixes
;
267 /* Flags stored in PREFIXES. */
268 #define PREFIX_REPZ 1
269 #define PREFIX_REPNZ 2
270 #define PREFIX_LOCK 4
272 #define PREFIX_SS 0x10
273 #define PREFIX_DS 0x20
274 #define PREFIX_ES 0x40
275 #define PREFIX_FS 0x80
276 #define PREFIX_GS 0x100
277 #define PREFIX_DATA 0x200
278 #define PREFIX_ADDR 0x400
279 #define PREFIX_FWAIT 0x800
281 /* Make sure that bytes from INFO->PRIVATE_DATA->BUFFER (inclusive)
282 to ADDR (exclusive) are valid. Returns 1 for success, longjmps
285 fetch_data2(struct disassemble_info
*info
, bfd_byte
*addr
)
288 struct dis_private
*priv
= (struct dis_private
*) info
->private_data
;
289 bfd_vma start
= priv
->insn_start
+ (priv
->max_fetched
- priv
->the_buffer
);
291 if (addr
<= priv
->the_buffer
+ MAX_MNEM_SIZE
)
292 status
= (*info
->read_memory_func
) (start
,
294 addr
- priv
->max_fetched
,
300 /* If we did manage to read at least one byte, then
301 print_insn_i386 will do something sensible. Otherwise, print
302 an error. We do that here because this is where we know
304 if (priv
->max_fetched
== priv
->the_buffer
)
305 (*info
->memory_error_func
) (status
, start
, info
);
306 siglongjmp(priv
->bailout
, 1);
309 priv
->max_fetched
= addr
;
314 fetch_data(struct disassemble_info
*info
, bfd_byte
*addr
)
316 if (addr
<= ((struct dis_private
*) (info
->private_data
))->max_fetched
) {
319 return fetch_data2(info
, addr
);
324 #define XX { NULL, 0 }
326 #define Eb { OP_E, b_mode }
327 #define Ev { OP_E, v_mode }
328 #define Ed { OP_E, d_mode }
329 #define Edq { OP_E, dq_mode }
330 #define Edqw { OP_E, dqw_mode }
331 #define Edqb { OP_E, dqb_mode }
332 #define Edqd { OP_E, dqd_mode }
333 #define indirEv { OP_indirE, stack_v_mode }
334 #define indirEp { OP_indirE, f_mode }
335 #define stackEv { OP_E, stack_v_mode }
336 #define Em { OP_E, m_mode }
337 #define Ew { OP_E, w_mode }
338 #define M { OP_M, 0 } /* lea, lgdt, etc. */
339 #define Ma { OP_M, v_mode }
340 #define Mp { OP_M, f_mode } /* 32 or 48 bit memory operand for LDS, LES etc */
341 #define Mq { OP_M, q_mode }
342 #define Gb { OP_G, b_mode }
343 #define Gv { OP_G, v_mode }
344 #define Gd { OP_G, d_mode }
345 #define Gdq { OP_G, dq_mode }
346 #define Gm { OP_G, m_mode }
347 #define Gw { OP_G, w_mode }
348 #define Rd { OP_R, d_mode }
349 #define Rm { OP_R, m_mode }
350 #define Ib { OP_I, b_mode }
351 #define sIb { OP_sI, b_mode } /* sign extened byte */
352 #define Iv { OP_I, v_mode }
353 #define Iq { OP_I, q_mode }
354 #define Iv64 { OP_I64, v_mode }
355 #define Iw { OP_I, w_mode }
356 #define I1 { OP_I, const_1_mode }
357 #define Jb { OP_J, b_mode }
358 #define Jv { OP_J, v_mode }
359 #define Cm { OP_C, m_mode }
360 #define Dm { OP_D, m_mode }
361 #define Td { OP_T, d_mode }
363 #define RMeAX { OP_REG, eAX_reg }
364 #define RMeBX { OP_REG, eBX_reg }
365 #define RMeCX { OP_REG, eCX_reg }
366 #define RMeDX { OP_REG, eDX_reg }
367 #define RMeSP { OP_REG, eSP_reg }
368 #define RMeBP { OP_REG, eBP_reg }
369 #define RMeSI { OP_REG, eSI_reg }
370 #define RMeDI { OP_REG, eDI_reg }
371 #define RMrAX { OP_REG, rAX_reg }
372 #define RMrBX { OP_REG, rBX_reg }
373 #define RMrCX { OP_REG, rCX_reg }
374 #define RMrDX { OP_REG, rDX_reg }
375 #define RMrSP { OP_REG, rSP_reg }
376 #define RMrBP { OP_REG, rBP_reg }
377 #define RMrSI { OP_REG, rSI_reg }
378 #define RMrDI { OP_REG, rDI_reg }
379 #define RMAL { OP_REG, al_reg }
380 #define RMAL { OP_REG, al_reg }
381 #define RMCL { OP_REG, cl_reg }
382 #define RMDL { OP_REG, dl_reg }
383 #define RMBL { OP_REG, bl_reg }
384 #define RMAH { OP_REG, ah_reg }
385 #define RMCH { OP_REG, ch_reg }
386 #define RMDH { OP_REG, dh_reg }
387 #define RMBH { OP_REG, bh_reg }
388 #define RMAX { OP_REG, ax_reg }
389 #define RMDX { OP_REG, dx_reg }
391 #define eAX { OP_IMREG, eAX_reg }
392 #define eBX { OP_IMREG, eBX_reg }
393 #define eCX { OP_IMREG, eCX_reg }
394 #define eDX { OP_IMREG, eDX_reg }
395 #define eSP { OP_IMREG, eSP_reg }
396 #define eBP { OP_IMREG, eBP_reg }
397 #define eSI { OP_IMREG, eSI_reg }
398 #define eDI { OP_IMREG, eDI_reg }
399 #define AL { OP_IMREG, al_reg }
400 #define CL { OP_IMREG, cl_reg }
401 #define DL { OP_IMREG, dl_reg }
402 #define BL { OP_IMREG, bl_reg }
403 #define AH { OP_IMREG, ah_reg }
404 #define CH { OP_IMREG, ch_reg }
405 #define DH { OP_IMREG, dh_reg }
406 #define BH { OP_IMREG, bh_reg }
407 #define AX { OP_IMREG, ax_reg }
408 #define DX { OP_IMREG, dx_reg }
409 #define zAX { OP_IMREG, z_mode_ax_reg }
410 #define indirDX { OP_IMREG, indir_dx_reg }
412 #define Sw { OP_SEG, w_mode }
413 #define Sv { OP_SEG, v_mode }
414 #define Ap { OP_DIR, 0 }
415 #define Ob { OP_OFF64, b_mode }
416 #define Ov { OP_OFF64, v_mode }
417 #define Xb { OP_DSreg, eSI_reg }
418 #define Xv { OP_DSreg, eSI_reg }
419 #define Xz { OP_DSreg, eSI_reg }
420 #define Yb { OP_ESreg, eDI_reg }
421 #define Yv { OP_ESreg, eDI_reg }
422 #define DSBX { OP_DSreg, eBX_reg }
424 #define es { OP_REG, es_reg }
425 #define ss { OP_REG, ss_reg }
426 #define cs { OP_REG, cs_reg }
427 #define ds { OP_REG, ds_reg }
428 #define fs { OP_REG, fs_reg }
429 #define gs { OP_REG, gs_reg }
431 #define MX { OP_MMX, 0 }
432 #define XM { OP_XMM, 0 }
433 #define EM { OP_EM, v_mode }
434 #define EMd { OP_EM, d_mode }
435 #define EMq { OP_EM, q_mode }
436 #define EXd { OP_EX, d_mode }
437 #define EXq { OP_EX, q_mode }
438 #define EXx { OP_EX, x_mode }
439 #define MS { OP_MS, v_mode }
440 #define XS { OP_XS, v_mode }
441 #define EMC { OP_EMC, v_mode }
442 #define MXC { OP_MXC, 0 }
443 #define VM { OP_VMX, q_mode }
444 #define OPSUF { OP_3DNowSuffix, 0 }
445 #define OPSIMD { OP_SIMD_Suffix, 0 }
446 #define XMM0 { XMM_Fixup, 0 }
448 /* Used handle "rep" prefix for string instructions. */
449 #define Xbr { REP_Fixup, eSI_reg }
450 #define Xvr { REP_Fixup, eSI_reg }
451 #define Ybr { REP_Fixup, eDI_reg }
452 #define Yvr { REP_Fixup, eDI_reg }
453 #define Yzr { REP_Fixup, eDI_reg }
454 #define indirDXr { REP_Fixup, indir_dx_reg }
455 #define ALr { REP_Fixup, al_reg }
456 #define eAXr { REP_Fixup, eAX_reg }
458 #define cond_jump_flag { NULL, cond_jump_mode }
459 #define loop_jcxz_flag { NULL, loop_jcxz_mode }
461 /* bits in sizeflag */
462 #define SUFFIX_ALWAYS 4
466 #define b_mode 1 /* byte operand */
467 #define v_mode 2 /* operand size depends on prefixes */
468 #define w_mode 3 /* word operand */
469 #define d_mode 4 /* double word operand */
470 #define q_mode 5 /* quad word operand */
471 #define t_mode 6 /* ten-byte operand */
472 #define x_mode 7 /* 16-byte XMM operand */
473 #define m_mode 8 /* d_mode in 32bit, q_mode in 64bit mode. */
474 #define cond_jump_mode 9
475 #define loop_jcxz_mode 10
476 #define dq_mode 11 /* operand size depends on REX prefixes. */
477 #define dqw_mode 12 /* registers like dq_mode, memory like w_mode. */
478 #define f_mode 13 /* 4- or 6-byte pointer operand */
479 #define const_1_mode 14
480 #define stack_v_mode 15 /* v_mode for stack-related opcodes. */
481 #define z_mode 16 /* non-quad operand size depends on prefixes */
482 #define o_mode 17 /* 16-byte operand */
483 #define dqb_mode 18 /* registers like dq_mode, memory like b_mode. */
484 #define dqd_mode 19 /* registers like dq_mode, memory like d_mode. */
529 #define z_mode_ax_reg 149
530 #define indir_dx_reg 150
534 #define USE_PREFIX_USER_TABLE 3
535 #define X86_64_SPECIAL 4
536 #define IS_3BYTE_OPCODE 5
538 #define FLOAT NULL, { { NULL, FLOATCODE } }
540 #define GRP1a NULL, { { NULL, USE_GROUPS }, { NULL, 0 } }
541 #define GRP1b NULL, { { NULL, USE_GROUPS }, { NULL, 1 } }
542 #define GRP1S NULL, { { NULL, USE_GROUPS }, { NULL, 2 } }
543 #define GRP1Ss NULL, { { NULL, USE_GROUPS }, { NULL, 3 } }
544 #define GRP2b NULL, { { NULL, USE_GROUPS }, { NULL, 4 } }
545 #define GRP2S NULL, { { NULL, USE_GROUPS }, { NULL, 5 } }
546 #define GRP2b_one NULL, { { NULL, USE_GROUPS }, { NULL, 6 } }
547 #define GRP2S_one NULL, { { NULL, USE_GROUPS }, { NULL, 7 } }
548 #define GRP2b_cl NULL, { { NULL, USE_GROUPS }, { NULL, 8 } }
549 #define GRP2S_cl NULL, { { NULL, USE_GROUPS }, { NULL, 9 } }
550 #define GRP3b NULL, { { NULL, USE_GROUPS }, { NULL, 10 } }
551 #define GRP3S NULL, { { NULL, USE_GROUPS }, { NULL, 11 } }
552 #define GRP4 NULL, { { NULL, USE_GROUPS }, { NULL, 12 } }
553 #define GRP5 NULL, { { NULL, USE_GROUPS }, { NULL, 13 } }
554 #define GRP6 NULL, { { NULL, USE_GROUPS }, { NULL, 14 } }
555 #define GRP7 NULL, { { NULL, USE_GROUPS }, { NULL, 15 } }
556 #define GRP8 NULL, { { NULL, USE_GROUPS }, { NULL, 16 } }
557 #define GRP9 NULL, { { NULL, USE_GROUPS }, { NULL, 17 } }
558 #define GRP11_C6 NULL, { { NULL, USE_GROUPS }, { NULL, 18 } }
559 #define GRP11_C7 NULL, { { NULL, USE_GROUPS }, { NULL, 19 } }
560 #define GRP12 NULL, { { NULL, USE_GROUPS }, { NULL, 20 } }
561 #define GRP13 NULL, { { NULL, USE_GROUPS }, { NULL, 21 } }
562 #define GRP14 NULL, { { NULL, USE_GROUPS }, { NULL, 22 } }
563 #define GRP15 NULL, { { NULL, USE_GROUPS }, { NULL, 23 } }
564 #define GRP16 NULL, { { NULL, USE_GROUPS }, { NULL, 24 } }
565 #define GRPAMD NULL, { { NULL, USE_GROUPS }, { NULL, 25 } }
566 #define GRPPADLCK1 NULL, { { NULL, USE_GROUPS }, { NULL, 26 } }
567 #define GRPPADLCK2 NULL, { { NULL, USE_GROUPS }, { NULL, 27 } }
569 #define PREGRP0 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 0 } }
570 #define PREGRP1 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 1 } }
571 #define PREGRP2 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 2 } }
572 #define PREGRP3 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 3 } }
573 #define PREGRP4 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 4 } }
574 #define PREGRP5 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 5 } }
575 #define PREGRP6 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 6 } }
576 #define PREGRP7 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 7 } }
577 #define PREGRP8 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 8 } }
578 #define PREGRP9 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 9 } }
579 #define PREGRP10 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 10 } }
580 #define PREGRP11 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 11 } }
581 #define PREGRP12 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 12 } }
582 #define PREGRP13 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 13 } }
583 #define PREGRP14 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 14 } }
584 #define PREGRP15 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 15 } }
585 #define PREGRP16 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 16 } }
586 #define PREGRP17 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 17 } }
587 #define PREGRP18 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 18 } }
588 #define PREGRP19 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 19 } }
589 #define PREGRP20 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 20 } }
590 #define PREGRP21 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 21 } }
591 #define PREGRP22 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 22 } }
592 #define PREGRP23 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 23 } }
593 #define PREGRP24 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 24 } }
594 #define PREGRP25 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 25 } }
595 #define PREGRP26 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 26 } }
596 #define PREGRP27 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 27 } }
597 #define PREGRP28 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 28 } }
598 #define PREGRP29 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 29 } }
599 #define PREGRP30 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 30 } }
600 #define PREGRP31 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 31 } }
601 #define PREGRP32 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 32 } }
602 #define PREGRP33 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 33 } }
603 #define PREGRP34 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 34 } }
604 #define PREGRP35 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 35 } }
605 #define PREGRP36 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 36 } }
606 #define PREGRP37 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 37 } }
607 #define PREGRP38 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 38 } }
608 #define PREGRP39 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 39 } }
609 #define PREGRP40 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 40 } }
610 #define PREGRP41 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 41 } }
611 #define PREGRP42 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 42 } }
612 #define PREGRP43 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 43 } }
613 #define PREGRP44 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 44 } }
614 #define PREGRP45 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 45 } }
615 #define PREGRP46 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 46 } }
616 #define PREGRP47 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 47 } }
617 #define PREGRP48 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 48 } }
618 #define PREGRP49 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 49 } }
619 #define PREGRP50 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 50 } }
620 #define PREGRP51 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 51 } }
621 #define PREGRP52 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 52 } }
622 #define PREGRP53 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 53 } }
623 #define PREGRP54 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 54 } }
624 #define PREGRP55 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 55 } }
625 #define PREGRP56 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 56 } }
626 #define PREGRP57 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 57 } }
627 #define PREGRP58 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 58 } }
628 #define PREGRP59 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 59 } }
629 #define PREGRP60 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 60 } }
630 #define PREGRP61 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 61 } }
631 #define PREGRP62 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 62 } }
632 #define PREGRP63 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 63 } }
633 #define PREGRP64 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 64 } }
634 #define PREGRP65 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 65 } }
635 #define PREGRP66 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 66 } }
636 #define PREGRP67 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 67 } }
637 #define PREGRP68 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 68 } }
638 #define PREGRP69 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 69 } }
639 #define PREGRP70 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 70 } }
640 #define PREGRP71 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 71 } }
641 #define PREGRP72 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 72 } }
642 #define PREGRP73 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 73 } }
643 #define PREGRP74 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 74 } }
644 #define PREGRP75 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 75 } }
645 #define PREGRP76 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 76 } }
646 #define PREGRP77 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 77 } }
647 #define PREGRP78 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 78 } }
648 #define PREGRP79 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 79 } }
649 #define PREGRP80 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 80 } }
650 #define PREGRP81 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 81 } }
651 #define PREGRP82 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 82 } }
652 #define PREGRP83 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 83 } }
653 #define PREGRP84 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 84 } }
654 #define PREGRP85 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 85 } }
655 #define PREGRP86 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 86 } }
656 #define PREGRP87 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 87 } }
657 #define PREGRP88 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 88 } }
658 #define PREGRP89 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 89 } }
659 #define PREGRP90 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 90 } }
660 #define PREGRP91 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 91 } }
661 #define PREGRP92 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 92 } }
662 #define PREGRP93 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 93 } }
663 #define PREGRP94 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 94 } }
664 #define PREGRP95 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 95 } }
665 #define PREGRP96 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 96 } }
666 #define PREGRP97 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 97 } }
667 #define PREGRP98 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 98 } }
668 #define PREGRP99 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 99 } }
669 #define PREGRP100 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 100 } }
670 #define PREGRP101 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 101 } }
671 #define PREGRP102 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 102 } }
672 #define PREGRP103 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 103 } }
673 #define PREGRP104 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 104 } }
676 #define X86_64_0 NULL, { { NULL, X86_64_SPECIAL }, { NULL, 0 } }
677 #define X86_64_1 NULL, { { NULL, X86_64_SPECIAL }, { NULL, 1 } }
678 #define X86_64_2 NULL, { { NULL, X86_64_SPECIAL }, { NULL, 2 } }
679 #define X86_64_3 NULL, { { NULL, X86_64_SPECIAL }, { NULL, 3 } }
681 #define THREE_BYTE_0 NULL, { { NULL, IS_3BYTE_OPCODE }, { NULL, 0 } }
682 #define THREE_BYTE_1 NULL, { { NULL, IS_3BYTE_OPCODE }, { NULL, 1 } }
684 typedef void (*op_rtn
) (int bytemode
, int sizeflag
);
695 /* Upper case letters in the instruction names here are macros.
696 'A' => print 'b' if no register operands or suffix_always is true
697 'B' => print 'b' if suffix_always is true
698 'C' => print 's' or 'l' ('w' or 'd' in Intel mode) depending on operand
700 'D' => print 'w' if no register operands or 'w', 'l' or 'q', if
701 . suffix_always is true
702 'E' => print 'e' if 32-bit form of jcxz
703 'F' => print 'w' or 'l' depending on address size prefix (loop insns)
704 'G' => print 'w' or 'l' depending on operand size prefix (i/o insns)
705 'H' => print ",pt" or ",pn" branch hint
706 'I' => honor following macro letter even in Intel mode (implemented only
707 . for some of the macro letters)
709 'K' => print 'd' or 'q' if rex prefix is present.
710 'L' => print 'l' if suffix_always is true
711 'N' => print 'n' if instruction has no wait "prefix"
712 'O' => print 'd' or 'o' (or 'q' in Intel mode)
713 'P' => print 'w', 'l' or 'q' if instruction has an operand size prefix,
714 . or suffix_always is true. print 'q' if rex prefix is present.
715 'Q' => print 'w', 'l' or 'q' if no register operands or suffix_always
717 'R' => print 'w', 'l' or 'q' ('d' for 'l' and 'e' in Intel mode)
718 'S' => print 'w', 'l' or 'q' if suffix_always is true
719 'T' => print 'q' in 64bit mode and behave as 'P' otherwise
720 'U' => print 'q' in 64bit mode and behave as 'Q' otherwise
721 'V' => print 'q' in 64bit mode and behave as 'S' otherwise
722 'W' => print 'b', 'w' or 'l' ('d' in Intel mode)
723 'X' => print 's', 'd' depending on data16 prefix (for XMM)
724 'Y' => 'q' if instruction has an REX 64bit overwrite prefix
725 'Z' => print 'q' in 64bit mode and behave as 'L' otherwise
727 Many of the above letters print nothing in Intel mode. See "putop"
730 Braces '{' and '}', and vertical bars '|', indicate alternative
731 mnemonic strings for AT&T, Intel, X86_64 AT&T, and X86_64 Intel
732 modes. In cases where there are only two alternatives, the X86_64
733 instruction is reserved, and "(bad)" is printed.
736 static const struct dis386 dis386
[] = {
738 { "addB", { Eb
, Gb
} },
739 { "addS", { Ev
, Gv
} },
740 { "addB", { Gb
, Eb
} },
741 { "addS", { Gv
, Ev
} },
742 { "addB", { AL
, Ib
} },
743 { "addS", { eAX
, Iv
} },
744 { "push{T|}", { es
} },
745 { "pop{T|}", { es
} },
747 { "orB", { Eb
, Gb
} },
748 { "orS", { Ev
, Gv
} },
749 { "orB", { Gb
, Eb
} },
750 { "orS", { Gv
, Ev
} },
751 { "orB", { AL
, Ib
} },
752 { "orS", { eAX
, Iv
} },
753 { "push{T|}", { cs
} },
754 { "(bad)", { XX
} }, /* 0x0f extended opcode escape */
756 { "adcB", { Eb
, Gb
} },
757 { "adcS", { Ev
, Gv
} },
758 { "adcB", { Gb
, Eb
} },
759 { "adcS", { Gv
, Ev
} },
760 { "adcB", { AL
, Ib
} },
761 { "adcS", { eAX
, Iv
} },
762 { "push{T|}", { ss
} },
763 { "pop{T|}", { ss
} },
765 { "sbbB", { Eb
, Gb
} },
766 { "sbbS", { Ev
, Gv
} },
767 { "sbbB", { Gb
, Eb
} },
768 { "sbbS", { Gv
, Ev
} },
769 { "sbbB", { AL
, Ib
} },
770 { "sbbS", { eAX
, Iv
} },
771 { "push{T|}", { ds
} },
772 { "pop{T|}", { ds
} },
774 { "andB", { Eb
, Gb
} },
775 { "andS", { Ev
, Gv
} },
776 { "andB", { Gb
, Eb
} },
777 { "andS", { Gv
, Ev
} },
778 { "andB", { AL
, Ib
} },
779 { "andS", { eAX
, Iv
} },
780 { "(bad)", { XX
} }, /* SEG ES prefix */
781 { "daa{|}", { XX
} },
783 { "subB", { Eb
, Gb
} },
784 { "subS", { Ev
, Gv
} },
785 { "subB", { Gb
, Eb
} },
786 { "subS", { Gv
, Ev
} },
787 { "subB", { AL
, Ib
} },
788 { "subS", { eAX
, Iv
} },
789 { "(bad)", { XX
} }, /* SEG CS prefix */
790 { "das{|}", { XX
} },
792 { "xorB", { Eb
, Gb
} },
793 { "xorS", { Ev
, Gv
} },
794 { "xorB", { Gb
, Eb
} },
795 { "xorS", { Gv
, Ev
} },
796 { "xorB", { AL
, Ib
} },
797 { "xorS", { eAX
, Iv
} },
798 { "(bad)", { XX
} }, /* SEG SS prefix */
799 { "aaa{|}", { XX
} },
801 { "cmpB", { Eb
, Gb
} },
802 { "cmpS", { Ev
, Gv
} },
803 { "cmpB", { Gb
, Eb
} },
804 { "cmpS", { Gv
, Ev
} },
805 { "cmpB", { AL
, Ib
} },
806 { "cmpS", { eAX
, Iv
} },
807 { "(bad)", { XX
} }, /* SEG DS prefix */
808 { "aas{|}", { XX
} },
810 { "inc{S|}", { RMeAX
} },
811 { "inc{S|}", { RMeCX
} },
812 { "inc{S|}", { RMeDX
} },
813 { "inc{S|}", { RMeBX
} },
814 { "inc{S|}", { RMeSP
} },
815 { "inc{S|}", { RMeBP
} },
816 { "inc{S|}", { RMeSI
} },
817 { "inc{S|}", { RMeDI
} },
819 { "dec{S|}", { RMeAX
} },
820 { "dec{S|}", { RMeCX
} },
821 { "dec{S|}", { RMeDX
} },
822 { "dec{S|}", { RMeBX
} },
823 { "dec{S|}", { RMeSP
} },
824 { "dec{S|}", { RMeBP
} },
825 { "dec{S|}", { RMeSI
} },
826 { "dec{S|}", { RMeDI
} },
828 { "pushV", { RMrAX
} },
829 { "pushV", { RMrCX
} },
830 { "pushV", { RMrDX
} },
831 { "pushV", { RMrBX
} },
832 { "pushV", { RMrSP
} },
833 { "pushV", { RMrBP
} },
834 { "pushV", { RMrSI
} },
835 { "pushV", { RMrDI
} },
837 { "popV", { RMrAX
} },
838 { "popV", { RMrCX
} },
839 { "popV", { RMrDX
} },
840 { "popV", { RMrBX
} },
841 { "popV", { RMrSP
} },
842 { "popV", { RMrBP
} },
843 { "popV", { RMrSI
} },
844 { "popV", { RMrDI
} },
850 { "(bad)", { XX
} }, /* seg fs */
851 { "(bad)", { XX
} }, /* seg gs */
852 { "(bad)", { XX
} }, /* op size prefix */
853 { "(bad)", { XX
} }, /* adr size prefix */
856 { "imulS", { Gv
, Ev
, Iv
} },
857 { "pushT", { sIb
} },
858 { "imulS", { Gv
, Ev
, sIb
} },
859 { "ins{b||b|}", { Ybr
, indirDX
} },
860 { "ins{R||G|}", { Yzr
, indirDX
} },
861 { "outs{b||b|}", { indirDXr
, Xb
} },
862 { "outs{R||G|}", { indirDXr
, Xz
} },
864 { "joH", { Jb
, XX
, cond_jump_flag
} },
865 { "jnoH", { Jb
, XX
, cond_jump_flag
} },
866 { "jbH", { Jb
, XX
, cond_jump_flag
} },
867 { "jaeH", { Jb
, XX
, cond_jump_flag
} },
868 { "jeH", { Jb
, XX
, cond_jump_flag
} },
869 { "jneH", { Jb
, XX
, cond_jump_flag
} },
870 { "jbeH", { Jb
, XX
, cond_jump_flag
} },
871 { "jaH", { Jb
, XX
, cond_jump_flag
} },
873 { "jsH", { Jb
, XX
, cond_jump_flag
} },
874 { "jnsH", { Jb
, XX
, cond_jump_flag
} },
875 { "jpH", { Jb
, XX
, cond_jump_flag
} },
876 { "jnpH", { Jb
, XX
, cond_jump_flag
} },
877 { "jlH", { Jb
, XX
, cond_jump_flag
} },
878 { "jgeH", { Jb
, XX
, cond_jump_flag
} },
879 { "jleH", { Jb
, XX
, cond_jump_flag
} },
880 { "jgH", { Jb
, XX
, cond_jump_flag
} },
886 { "testB", { Eb
, Gb
} },
887 { "testS", { Ev
, Gv
} },
888 { "xchgB", { Eb
, Gb
} },
889 { "xchgS", { Ev
, Gv
} },
891 { "movB", { Eb
, Gb
} },
892 { "movS", { Ev
, Gv
} },
893 { "movB", { Gb
, Eb
} },
894 { "movS", { Gv
, Ev
} },
895 { "movD", { Sv
, Sw
} },
896 { "leaS", { Gv
, M
} },
897 { "movD", { Sw
, Sv
} },
901 { "xchgS", { RMeCX
, eAX
} },
902 { "xchgS", { RMeDX
, eAX
} },
903 { "xchgS", { RMeBX
, eAX
} },
904 { "xchgS", { RMeSP
, eAX
} },
905 { "xchgS", { RMeBP
, eAX
} },
906 { "xchgS", { RMeSI
, eAX
} },
907 { "xchgS", { RMeDI
, eAX
} },
909 { "cW{t||t|}R", { XX
} },
910 { "cR{t||t|}O", { XX
} },
911 { "Jcall{T|}", { Ap
} },
912 { "(bad)", { XX
} }, /* fwait */
913 { "pushfT", { XX
} },
915 { "sahf{|}", { XX
} },
916 { "lahf{|}", { XX
} },
918 { "movB", { AL
, Ob
} },
919 { "movS", { eAX
, Ov
} },
920 { "movB", { Ob
, AL
} },
921 { "movS", { Ov
, eAX
} },
922 { "movs{b||b|}", { Ybr
, Xb
} },
923 { "movs{R||R|}", { Yvr
, Xv
} },
924 { "cmps{b||b|}", { Xb
, Yb
} },
925 { "cmps{R||R|}", { Xv
, Yv
} },
927 { "testB", { AL
, Ib
} },
928 { "testS", { eAX
, Iv
} },
929 { "stosB", { Ybr
, AL
} },
930 { "stosS", { Yvr
, eAX
} },
931 { "lodsB", { ALr
, Xb
} },
932 { "lodsS", { eAXr
, Xv
} },
933 { "scasB", { AL
, Yb
} },
934 { "scasS", { eAX
, Yv
} },
936 { "movB", { RMAL
, Ib
} },
937 { "movB", { RMCL
, Ib
} },
938 { "movB", { RMDL
, Ib
} },
939 { "movB", { RMBL
, Ib
} },
940 { "movB", { RMAH
, Ib
} },
941 { "movB", { RMCH
, Ib
} },
942 { "movB", { RMDH
, Ib
} },
943 { "movB", { RMBH
, Ib
} },
945 { "movS", { RMeAX
, Iv64
} },
946 { "movS", { RMeCX
, Iv64
} },
947 { "movS", { RMeDX
, Iv64
} },
948 { "movS", { RMeBX
, Iv64
} },
949 { "movS", { RMeSP
, Iv64
} },
950 { "movS", { RMeBP
, Iv64
} },
951 { "movS", { RMeSI
, Iv64
} },
952 { "movS", { RMeDI
, Iv64
} },
958 { "les{S|}", { Gv
, Mp
} },
959 { "ldsS", { Gv
, Mp
} },
963 { "enterT", { Iw
, Ib
} },
964 { "leaveT", { XX
} },
969 { "into{|}", { XX
} },
976 { "aam{|}", { sIb
} },
977 { "aad{|}", { sIb
} },
979 { "xlat", { DSBX
} },
990 { "loopneFH", { Jb
, XX
, loop_jcxz_flag
} },
991 { "loopeFH", { Jb
, XX
, loop_jcxz_flag
} },
992 { "loopFH", { Jb
, XX
, loop_jcxz_flag
} },
993 { "jEcxzH", { Jb
, XX
, loop_jcxz_flag
} },
994 { "inB", { AL
, Ib
} },
995 { "inG", { zAX
, Ib
} },
996 { "outB", { Ib
, AL
} },
997 { "outG", { Ib
, zAX
} },
1001 { "Jjmp{T|}", { Ap
} },
1003 { "inB", { AL
, indirDX
} },
1004 { "inG", { zAX
, indirDX
} },
1005 { "outB", { indirDX
, AL
} },
1006 { "outG", { indirDX
, zAX
} },
1008 { "(bad)", { XX
} }, /* lock prefix */
1009 { "icebp", { XX
} },
1010 { "(bad)", { XX
} }, /* repne */
1011 { "(bad)", { XX
} }, /* repz */
1027 static const struct dis386 dis386_twobyte
[] = {
1031 { "larS", { Gv
, Ew
} },
1032 { "lslS", { Gv
, Ew
} },
1033 { "(bad)", { XX
} },
1034 { "syscall", { XX
} },
1036 { "sysretP", { XX
} },
1039 { "wbinvd", { XX
} },
1040 { "(bad)", { XX
} },
1042 { "(bad)", { XX
} },
1044 { "femms", { XX
} },
1045 { "", { MX
, EM
, OPSUF
} }, /* See OP_3DNowSuffix. */
1050 { "movlpX", { EXq
, XM
, { SIMD_Fixup
, 'h' } } },
1051 { "unpcklpX", { XM
, EXq
} },
1052 { "unpckhpX", { XM
, EXq
} },
1054 { "movhpX", { EXq
, XM
, { SIMD_Fixup
, 'l' } } },
1057 { "(bad)", { XX
} },
1058 { "(bad)", { XX
} },
1059 { "(bad)", { XX
} },
1060 { "(bad)", { XX
} },
1061 { "(bad)", { XX
} },
1062 { "(bad)", { XX
} },
1065 { "movZ", { Rm
, Cm
} },
1066 { "movZ", { Rm
, Dm
} },
1067 { "movZ", { Cm
, Rm
} },
1068 { "movZ", { Dm
, Rm
} },
1069 { "movL", { Rd
, Td
} },
1070 { "(bad)", { XX
} },
1071 { "movL", { Td
, Rd
} },
1072 { "(bad)", { XX
} },
1074 { "movapX", { XM
, EXx
} },
1075 { "movapX", { EXx
, XM
} },
1083 { "wrmsr", { XX
} },
1084 { "rdtsc", { XX
} },
1085 { "rdmsr", { XX
} },
1086 { "rdpmc", { XX
} },
1087 { "sysenter", { XX
} },
1088 { "sysexit", { XX
} },
1089 { "(bad)", { XX
} },
1090 { "(bad)", { XX
} },
1093 { "(bad)", { XX
} },
1095 { "(bad)", { XX
} },
1096 { "(bad)", { XX
} },
1097 { "(bad)", { XX
} },
1098 { "(bad)", { XX
} },
1099 { "(bad)", { XX
} },
1101 { "cmovo", { Gv
, Ev
} },
1102 { "cmovno", { Gv
, Ev
} },
1103 { "cmovb", { Gv
, Ev
} },
1104 { "cmovae", { Gv
, Ev
} },
1105 { "cmove", { Gv
, Ev
} },
1106 { "cmovne", { Gv
, Ev
} },
1107 { "cmovbe", { Gv
, Ev
} },
1108 { "cmova", { Gv
, Ev
} },
1110 { "cmovs", { Gv
, Ev
} },
1111 { "cmovns", { Gv
, Ev
} },
1112 { "cmovp", { Gv
, Ev
} },
1113 { "cmovnp", { Gv
, Ev
} },
1114 { "cmovl", { Gv
, Ev
} },
1115 { "cmovge", { Gv
, Ev
} },
1116 { "cmovle", { Gv
, Ev
} },
1117 { "cmovg", { Gv
, Ev
} },
1119 { "movmskpX", { Gdq
, XS
} },
1123 { "andpX", { XM
, EXx
} },
1124 { "andnpX", { XM
, EXx
} },
1125 { "orpX", { XM
, EXx
} },
1126 { "xorpX", { XM
, EXx
} },
1140 { "packsswb", { MX
, EM
} },
1141 { "pcmpgtb", { MX
, EM
} },
1142 { "pcmpgtw", { MX
, EM
} },
1143 { "pcmpgtd", { MX
, EM
} },
1144 { "packuswb", { MX
, EM
} },
1146 { "punpckhbw", { MX
, EM
} },
1147 { "punpckhwd", { MX
, EM
} },
1148 { "punpckhdq", { MX
, EM
} },
1149 { "packssdw", { MX
, EM
} },
1152 { "movd", { MX
, Edq
} },
1159 { "pcmpeqb", { MX
, EM
} },
1160 { "pcmpeqw", { MX
, EM
} },
1161 { "pcmpeqd", { MX
, EM
} },
1166 { "(bad)", { XX
} },
1167 { "(bad)", { XX
} },
1173 { "joH", { Jv
, XX
, cond_jump_flag
} },
1174 { "jnoH", { Jv
, XX
, cond_jump_flag
} },
1175 { "jbH", { Jv
, XX
, cond_jump_flag
} },
1176 { "jaeH", { Jv
, XX
, cond_jump_flag
} },
1177 { "jeH", { Jv
, XX
, cond_jump_flag
} },
1178 { "jneH", { Jv
, XX
, cond_jump_flag
} },
1179 { "jbeH", { Jv
, XX
, cond_jump_flag
} },
1180 { "jaH", { Jv
, XX
, cond_jump_flag
} },
1182 { "jsH", { Jv
, XX
, cond_jump_flag
} },
1183 { "jnsH", { Jv
, XX
, cond_jump_flag
} },
1184 { "jpH", { Jv
, XX
, cond_jump_flag
} },
1185 { "jnpH", { Jv
, XX
, cond_jump_flag
} },
1186 { "jlH", { Jv
, XX
, cond_jump_flag
} },
1187 { "jgeH", { Jv
, XX
, cond_jump_flag
} },
1188 { "jleH", { Jv
, XX
, cond_jump_flag
} },
1189 { "jgH", { Jv
, XX
, cond_jump_flag
} },
1192 { "setno", { Eb
} },
1194 { "setae", { Eb
} },
1196 { "setne", { Eb
} },
1197 { "setbe", { Eb
} },
1201 { "setns", { Eb
} },
1203 { "setnp", { Eb
} },
1205 { "setge", { Eb
} },
1206 { "setle", { Eb
} },
1209 { "pushT", { fs
} },
1211 { "cpuid", { XX
} },
1212 { "btS", { Ev
, Gv
} },
1213 { "shldS", { Ev
, Gv
, Ib
} },
1214 { "shldS", { Ev
, Gv
, CL
} },
1218 { "pushT", { gs
} },
1221 { "btsS", { Ev
, Gv
} },
1222 { "shrdS", { Ev
, Gv
, Ib
} },
1223 { "shrdS", { Ev
, Gv
, CL
} },
1225 { "imulS", { Gv
, Ev
} },
1227 { "cmpxchgB", { Eb
, Gb
} },
1228 { "cmpxchgS", { Ev
, Gv
} },
1229 { "lssS", { Gv
, Mp
} },
1230 { "btrS", { Ev
, Gv
} },
1231 { "lfsS", { Gv
, Mp
} },
1232 { "lgsS", { Gv
, Mp
} },
1233 { "movz{bR|x|bR|x}", { Gv
, Eb
} },
1234 { "movz{wR|x|wR|x}", { Gv
, Ew
} }, /* yes, there really is movzww ! */
1239 { "btcS", { Ev
, Gv
} },
1240 { "bsfS", { Gv
, Ev
} },
1242 { "movs{bR|x|bR|x}", { Gv
, Eb
} },
1243 { "movs{wR|x|wR|x}", { Gv
, Ew
} }, /* yes, there really is movsww ! */
1245 { "xaddB", { Eb
, Gb
} },
1246 { "xaddS", { Ev
, Gv
} },
1248 { "movntiS", { Ev
, Gv
} },
1249 { "pinsrw", { MX
, Edqw
, Ib
} },
1250 { "pextrw", { Gdq
, MS
, Ib
} },
1251 { "shufpX", { XM
, EXx
, Ib
} },
1254 { "bswap", { RMeAX
} },
1255 { "bswap", { RMeCX
} },
1256 { "bswap", { RMeDX
} },
1257 { "bswap", { RMeBX
} },
1258 { "bswap", { RMeSP
} },
1259 { "bswap", { RMeBP
} },
1260 { "bswap", { RMeSI
} },
1261 { "bswap", { RMeDI
} },
1264 { "psrlw", { MX
, EM
} },
1265 { "psrld", { MX
, EM
} },
1266 { "psrlq", { MX
, EM
} },
1267 { "paddq", { MX
, EM
} },
1268 { "pmullw", { MX
, EM
} },
1270 { "pmovmskb", { Gdq
, MS
} },
1272 { "psubusb", { MX
, EM
} },
1273 { "psubusw", { MX
, EM
} },
1274 { "pminub", { MX
, EM
} },
1275 { "pand", { MX
, EM
} },
1276 { "paddusb", { MX
, EM
} },
1277 { "paddusw", { MX
, EM
} },
1278 { "pmaxub", { MX
, EM
} },
1279 { "pandn", { MX
, EM
} },
1281 { "pavgb", { MX
, EM
} },
1282 { "psraw", { MX
, EM
} },
1283 { "psrad", { MX
, EM
} },
1284 { "pavgw", { MX
, EM
} },
1285 { "pmulhuw", { MX
, EM
} },
1286 { "pmulhw", { MX
, EM
} },
1290 { "psubsb", { MX
, EM
} },
1291 { "psubsw", { MX
, EM
} },
1292 { "pminsw", { MX
, EM
} },
1293 { "por", { MX
, EM
} },
1294 { "paddsb", { MX
, EM
} },
1295 { "paddsw", { MX
, EM
} },
1296 { "pmaxsw", { MX
, EM
} },
1297 { "pxor", { MX
, EM
} },
1300 { "psllw", { MX
, EM
} },
1301 { "pslld", { MX
, EM
} },
1302 { "psllq", { MX
, EM
} },
1303 { "pmuludq", { MX
, EM
} },
1304 { "pmaddwd", { MX
, EM
} },
1305 { "psadbw", { MX
, EM
} },
1308 { "psubb", { MX
, EM
} },
1309 { "psubw", { MX
, EM
} },
1310 { "psubd", { MX
, EM
} },
1311 { "psubq", { MX
, EM
} },
1312 { "paddb", { MX
, EM
} },
1313 { "paddw", { MX
, EM
} },
1314 { "paddd", { MX
, EM
} },
1315 { "(bad)", { XX
} },
1318 static const unsigned char onebyte_has_modrm
[256] = {
1319 /* 0 1 2 3 4 5 6 7 8 9 a b c d e f */
1320 /* ------------------------------- */
1321 /* 00 */ 1,1,1,1,0,0,0,0,1,1,1,1,0,0,0,0, /* 00 */
1322 /* 10 */ 1,1,1,1,0,0,0,0,1,1,1,1,0,0,0,0, /* 10 */
1323 /* 20 */ 1,1,1,1,0,0,0,0,1,1,1,1,0,0,0,0, /* 20 */
1324 /* 30 */ 1,1,1,1,0,0,0,0,1,1,1,1,0,0,0,0, /* 30 */
1325 /* 40 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 40 */
1326 /* 50 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 50 */
1327 /* 60 */ 0,0,1,1,0,0,0,0,0,1,0,1,0,0,0,0, /* 60 */
1328 /* 70 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 70 */
1329 /* 80 */ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, /* 80 */
1330 /* 90 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 90 */
1331 /* a0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* a0 */
1332 /* b0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* b0 */
1333 /* c0 */ 1,1,0,0,1,1,1,1,0,0,0,0,0,0,0,0, /* c0 */
1334 /* d0 */ 1,1,1,1,0,0,0,0,1,1,1,1,1,1,1,1, /* d0 */
1335 /* e0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* e0 */
1336 /* f0 */ 0,0,0,0,0,0,1,1,0,0,0,0,0,0,1,1 /* f0 */
1337 /* ------------------------------- */
1338 /* 0 1 2 3 4 5 6 7 8 9 a b c d e f */
1341 static const unsigned char twobyte_has_modrm
[256] = {
1342 /* 0 1 2 3 4 5 6 7 8 9 a b c d e f */
1343 /* ------------------------------- */
1344 /* 00 */ 1,1,1,1,0,0,0,0,0,0,0,0,0,1,0,1, /* 0f */
1345 /* 10 */ 1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,1, /* 1f */
1346 /* 20 */ 1,1,1,1,1,0,1,0,1,1,1,1,1,1,1,1, /* 2f */
1347 /* 30 */ 0,0,0,0,0,0,0,0,1,0,1,0,0,0,0,0, /* 3f */
1348 /* 40 */ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, /* 4f */
1349 /* 50 */ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, /* 5f */
1350 /* 60 */ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, /* 6f */
1351 /* 70 */ 1,1,1,1,1,1,1,0,1,1,0,0,1,1,1,1, /* 7f */
1352 /* 80 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 8f */
1353 /* 90 */ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, /* 9f */
1354 /* a0 */ 0,0,0,1,1,1,1,1,0,0,0,1,1,1,1,1, /* af */
1355 /* b0 */ 1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1, /* bf */
1356 /* c0 */ 1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0, /* cf */
1357 /* d0 */ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, /* df */
1358 /* e0 */ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, /* ef */
1359 /* f0 */ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0 /* ff */
1360 /* ------------------------------- */
1361 /* 0 1 2 3 4 5 6 7 8 9 a b c d e f */
1364 static const unsigned char twobyte_uses_DATA_prefix
[256] = {
1365 /* 0 1 2 3 4 5 6 7 8 9 a b c d e f */
1366 /* ------------------------------- */
1367 /* 00 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0f */
1368 /* 10 */ 1,1,1,0,0,0,1,0,0,0,0,0,0,0,0,0, /* 1f */
1369 /* 20 */ 0,0,0,0,0,0,0,0,0,0,1,1,1,1,0,0, /* 2f */
1370 /* 30 */ 0,0,0,0,0,0,0,0,1,0,1,0,0,0,0,0, /* 3f */
1371 /* 40 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 4f */
1372 /* 50 */ 0,1,1,1,0,0,0,0,1,1,1,1,1,1,1,1, /* 5f */
1373 /* 60 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1, /* 6f */
1374 /* 70 */ 1,0,0,0,0,0,0,0,1,1,0,0,1,1,1,1, /* 7f */
1375 /* 80 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 8f */
1376 /* 90 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 9f */
1377 /* a0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* af */
1378 /* b0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* bf */
1379 /* c0 */ 0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0, /* cf */
1380 /* d0 */ 1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0, /* df */
1381 /* e0 */ 0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0, /* ef */
1382 /* f0 */ 1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0 /* ff */
1383 /* ------------------------------- */
1384 /* 0 1 2 3 4 5 6 7 8 9 a b c d e f */
1387 static const unsigned char twobyte_uses_REPNZ_prefix
[256] = {
1388 /* 0 1 2 3 4 5 6 7 8 9 a b c d e f */
1389 /* ------------------------------- */
1390 /* 00 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0f */
1391 /* 10 */ 1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 1f */
1392 /* 20 */ 0,0,0,0,0,0,0,0,0,0,1,1,1,1,0,0, /* 2f */
1393 /* 30 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 3f */
1394 /* 40 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 4f */
1395 /* 50 */ 0,1,0,0,0,0,0,0,1,1,1,0,1,1,1,1, /* 5f */
1396 /* 60 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 6f */
1397 /* 70 */ 1,0,0,0,0,0,0,0,1,1,0,0,1,1,0,0, /* 7f */
1398 /* 80 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 8f */
1399 /* 90 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 9f */
1400 /* a0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* af */
1401 /* b0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* bf */
1402 /* c0 */ 0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0, /* cf */
1403 /* d0 */ 1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0, /* df */
1404 /* e0 */ 0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0, /* ef */
1405 /* f0 */ 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* ff */
1406 /* ------------------------------- */
1407 /* 0 1 2 3 4 5 6 7 8 9 a b c d e f */
1410 static const unsigned char twobyte_uses_REPZ_prefix
[256] = {
1411 /* 0 1 2 3 4 5 6 7 8 9 a b c d e f */
1412 /* ------------------------------- */
1413 /* 00 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0f */
1414 /* 10 */ 1,1,1,0,0,0,1,0,0,0,0,0,0,0,0,0, /* 1f */
1415 /* 20 */ 0,0,0,0,0,0,0,0,0,0,1,1,1,1,0,0, /* 2f */
1416 /* 30 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 3f */
1417 /* 40 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 4f */
1418 /* 50 */ 0,1,1,1,0,0,0,0,1,1,1,1,1,1,1,1, /* 5f */
1419 /* 60 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1, /* 6f */
1420 /* 70 */ 1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1, /* 7f */
1421 /* 80 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 8f */
1422 /* 90 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 9f */
1423 /* a0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* af */
1424 /* b0 */ 0,0,0,0,0,0,0,0,1,0,0,0,0,1,0,0, /* bf */
1425 /* c0 */ 0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0, /* cf */
1426 /* d0 */ 0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0, /* df */
1427 /* e0 */ 0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0, /* ef */
1428 /* f0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* ff */
1429 /* ------------------------------- */
1430 /* 0 1 2 3 4 5 6 7 8 9 a b c d e f */
1433 /* This is used to determine if opcode 0f 38 XX uses DATA prefix. */
1434 static const unsigned char threebyte_0x38_uses_DATA_prefix
[256] = {
1435 /* 0 1 2 3 4 5 6 7 8 9 a b c d e f */
1436 /* ------------------------------- */
1437 /* 00 */ 1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0, /* 0f */
1438 /* 10 */ 1,0,0,0,1,1,0,1,0,0,0,0,1,1,1,0, /* 1f */
1439 /* 20 */ 1,1,1,1,1,1,0,0,1,1,1,1,0,0,0,0, /* 2f */
1440 /* 30 */ 1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1, /* 3f */
1441 /* 40 */ 1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 4f */
1442 /* 50 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 5f */
1443 /* 60 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 6f */
1444 /* 70 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 7f */
1445 /* 80 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 8f */
1446 /* 90 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 9f */
1447 /* a0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* af */
1448 /* b0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* bf */
1449 /* c0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* cf */
1450 /* d0 */ 0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1, /* df */
1451 /* e0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* ef */
1452 /* f0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* ff */
1453 /* ------------------------------- */
1454 /* 0 1 2 3 4 5 6 7 8 9 a b c d e f */
1457 /* This is used to determine if opcode 0f 38 XX uses REPNZ prefix. */
1458 static const unsigned char threebyte_0x38_uses_REPNZ_prefix
[256] = {
1459 /* 0 1 2 3 4 5 6 7 8 9 a b c d e f */
1460 /* ------------------------------- */
1461 /* 00 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0f */
1462 /* 10 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 1f */
1463 /* 20 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 2f */
1464 /* 30 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 3f */
1465 /* 40 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 4f */
1466 /* 50 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 5f */
1467 /* 60 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 6f */
1468 /* 70 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 7f */
1469 /* 80 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 8f */
1470 /* 90 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 9f */
1471 /* a0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* af */
1472 /* b0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* bf */
1473 /* c0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* cf */
1474 /* d0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* df */
1475 /* e0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* ef */
1476 /* f0 */ 1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* ff */
1477 /* ------------------------------- */
1478 /* 0 1 2 3 4 5 6 7 8 9 a b c d e f */
1481 /* This is used to determine if opcode 0f 38 XX uses REPZ prefix. */
1482 static const unsigned char threebyte_0x38_uses_REPZ_prefix
[256] = {
1483 /* 0 1 2 3 4 5 6 7 8 9 a b c d e f */
1484 /* ------------------------------- */
1485 /* 00 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0f */
1486 /* 10 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 1f */
1487 /* 20 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 2f */
1488 /* 30 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 3f */
1489 /* 40 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 4f */
1490 /* 50 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 5f */
1491 /* 60 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 6f */
1492 /* 70 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 7f */
1493 /* 80 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 8f */
1494 /* 90 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 9f */
1495 /* a0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* af */
1496 /* b0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* bf */
1497 /* c0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* cf */
1498 /* d0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* df */
1499 /* e0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* ef */
1500 /* f0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* ff */
1501 /* ------------------------------- */
1502 /* 0 1 2 3 4 5 6 7 8 9 a b c d e f */
1505 /* This is used to determine if opcode 0f 3a XX uses DATA prefix. */
1506 static const unsigned char threebyte_0x3a_uses_DATA_prefix
[256] = {
1507 /* 0 1 2 3 4 5 6 7 8 9 a b c d e f */
1508 /* ------------------------------- */
1509 /* 00 */ 0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1, /* 0f */
1510 /* 10 */ 0,0,0,0,1,1,1,1,0,0,0,0,0,0,0,0, /* 1f */
1511 /* 20 */ 1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 2f */
1512 /* 30 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 3f */
1513 /* 40 */ 1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0, /* 4f */
1514 /* 50 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 5f */
1515 /* 60 */ 1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0, /* 6f */
1516 /* 70 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 7f */
1517 /* 80 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 8f */
1518 /* 90 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 9f */
1519 /* a0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* af */
1520 /* b0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* bf */
1521 /* c0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* cf */
1522 /* d0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1, /* df */
1523 /* e0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* ef */
1524 /* f0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* ff */
1525 /* ------------------------------- */
1526 /* 0 1 2 3 4 5 6 7 8 9 a b c d e f */
1529 /* This is used to determine if opcode 0f 3a XX uses REPNZ prefix. */
1530 static const unsigned char threebyte_0x3a_uses_REPNZ_prefix
[256] = {
1531 /* 0 1 2 3 4 5 6 7 8 9 a b c d e f */
1532 /* ------------------------------- */
1533 /* 00 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0f */
1534 /* 10 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 1f */
1535 /* 20 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 2f */
1536 /* 30 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 3f */
1537 /* 40 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 4f */
1538 /* 50 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 5f */
1539 /* 60 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 6f */
1540 /* 70 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 7f */
1541 /* 80 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 8f */
1542 /* 90 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 9f */
1543 /* a0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* af */
1544 /* b0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* bf */
1545 /* c0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* cf */
1546 /* d0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* df */
1547 /* e0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* ef */
1548 /* f0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* ff */
1549 /* ------------------------------- */
1550 /* 0 1 2 3 4 5 6 7 8 9 a b c d e f */
1553 /* This is used to determine if opcode 0f 3a XX uses REPZ prefix. */
1554 static const unsigned char threebyte_0x3a_uses_REPZ_prefix
[256] = {
1555 /* 0 1 2 3 4 5 6 7 8 9 a b c d e f */
1556 /* ------------------------------- */
1557 /* 00 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0f */
1558 /* 10 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 1f */
1559 /* 20 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 2f */
1560 /* 30 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 3f */
1561 /* 40 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 4f */
1562 /* 50 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 5f */
1563 /* 60 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 6f */
1564 /* 70 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 7f */
1565 /* 80 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 8f */
1566 /* 90 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 9f */
1567 /* a0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* af */
1568 /* b0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* bf */
1569 /* c0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* cf */
1570 /* d0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* df */
1571 /* e0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* ef */
1572 /* f0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* ff */
1573 /* ------------------------------- */
1574 /* 0 1 2 3 4 5 6 7 8 9 a b c d e f */
1577 static char obuf
[100];
1579 static char scratchbuf
[100];
1580 static unsigned char *start_codep
;
1581 static unsigned char *insn_codep
;
1582 static unsigned char *codep
;
1583 static disassemble_info
*the_info
;
1591 static unsigned char need_modrm
;
1593 /* If we are accessing mod/rm/reg without need_modrm set, then the
1594 values are stale. Hitting this abort likely indicates that you
1595 need to update onebyte_has_modrm or twobyte_has_modrm. */
1596 #define MODRM_CHECK if (!need_modrm) abort ()
1598 static const char * const *names64
;
1599 static const char * const *names32
;
1600 static const char * const *names16
;
1601 static const char * const *names8
;
1602 static const char * const *names8rex
;
1603 static const char * const *names_seg
;
1604 static const char * const *index16
;
1606 static const char * const intel_names64
[] = {
1607 "rax", "rcx", "rdx", "rbx", "rsp", "rbp", "rsi", "rdi",
1608 "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15"
1610 static const char * const intel_names32
[] = {
1611 "eax", "ecx", "edx", "ebx", "esp", "ebp", "esi", "edi",
1612 "r8d", "r9d", "r10d", "r11d", "r12d", "r13d", "r14d", "r15d"
1614 static const char * const intel_names16
[] = {
1615 "ax", "cx", "dx", "bx", "sp", "bp", "si", "di",
1616 "r8w", "r9w", "r10w", "r11w", "r12w", "r13w", "r14w", "r15w"
1618 static const char * const intel_names8
[] = {
1619 "al", "cl", "dl", "bl", "ah", "ch", "dh", "bh",
1621 static const char * const intel_names8rex
[] = {
1622 "al", "cl", "dl", "bl", "spl", "bpl", "sil", "dil",
1623 "r8b", "r9b", "r10b", "r11b", "r12b", "r13b", "r14b", "r15b"
1625 static const char * const intel_names_seg
[] = {
1626 "es", "cs", "ss", "ds", "fs", "gs", "?", "?",
1628 static const char * const intel_index16
[] = {
1629 "bx+si", "bx+di", "bp+si", "bp+di", "si", "di", "bp", "bx"
1632 static const char * const att_names64
[] = {
1633 "%rax", "%rcx", "%rdx", "%rbx", "%rsp", "%rbp", "%rsi", "%rdi",
1634 "%r8", "%r9", "%r10", "%r11", "%r12", "%r13", "%r14", "%r15"
1636 static const char * const att_names32
[] = {
1637 "%eax", "%ecx", "%edx", "%ebx", "%esp", "%ebp", "%esi", "%edi",
1638 "%r8d", "%r9d", "%r10d", "%r11d", "%r12d", "%r13d", "%r14d", "%r15d"
1640 static const char * const att_names16
[] = {
1641 "%ax", "%cx", "%dx", "%bx", "%sp", "%bp", "%si", "%di",
1642 "%r8w", "%r9w", "%r10w", "%r11w", "%r12w", "%r13w", "%r14w", "%r15w"
1644 static const char * const att_names8
[] = {
1645 "%al", "%cl", "%dl", "%bl", "%ah", "%ch", "%dh", "%bh",
1647 static const char * const att_names8rex
[] = {
1648 "%al", "%cl", "%dl", "%bl", "%spl", "%bpl", "%sil", "%dil",
1649 "%r8b", "%r9b", "%r10b", "%r11b", "%r12b", "%r13b", "%r14b", "%r15b"
1651 static const char * const att_names_seg
[] = {
1652 "%es", "%cs", "%ss", "%ds", "%fs", "%gs", "%?", "%?",
1654 static const char * const att_index16
[] = {
1655 "%bx,%si", "%bx,%di", "%bp,%si", "%bp,%di", "%si", "%di", "%bp", "%bx"
1658 static const struct dis386 grps
[][8] = {
1661 { "popU", { stackEv
} },
1662 { "(bad)", { XX
} },
1663 { "(bad)", { XX
} },
1664 { "(bad)", { XX
} },
1665 { "(bad)", { XX
} },
1666 { "(bad)", { XX
} },
1667 { "(bad)", { XX
} },
1668 { "(bad)", { XX
} },
1672 { "addA", { Eb
, Ib
} },
1673 { "orA", { Eb
, Ib
} },
1674 { "adcA", { Eb
, Ib
} },
1675 { "sbbA", { Eb
, Ib
} },
1676 { "andA", { Eb
, Ib
} },
1677 { "subA", { Eb
, Ib
} },
1678 { "xorA", { Eb
, Ib
} },
1679 { "cmpA", { Eb
, Ib
} },
1683 { "addQ", { Ev
, Iv
} },
1684 { "orQ", { Ev
, Iv
} },
1685 { "adcQ", { Ev
, Iv
} },
1686 { "sbbQ", { Ev
, Iv
} },
1687 { "andQ", { Ev
, Iv
} },
1688 { "subQ", { Ev
, Iv
} },
1689 { "xorQ", { Ev
, Iv
} },
1690 { "cmpQ", { Ev
, Iv
} },
1694 { "addQ", { Ev
, sIb
} },
1695 { "orQ", { Ev
, sIb
} },
1696 { "adcQ", { Ev
, sIb
} },
1697 { "sbbQ", { Ev
, sIb
} },
1698 { "andQ", { Ev
, sIb
} },
1699 { "subQ", { Ev
, sIb
} },
1700 { "xorQ", { Ev
, sIb
} },
1701 { "cmpQ", { Ev
, sIb
} },
1705 { "rolA", { Eb
, Ib
} },
1706 { "rorA", { Eb
, Ib
} },
1707 { "rclA", { Eb
, Ib
} },
1708 { "rcrA", { Eb
, Ib
} },
1709 { "shlA", { Eb
, Ib
} },
1710 { "shrA", { Eb
, Ib
} },
1711 { "(bad)", { XX
} },
1712 { "sarA", { Eb
, Ib
} },
1716 { "rolQ", { Ev
, Ib
} },
1717 { "rorQ", { Ev
, Ib
} },
1718 { "rclQ", { Ev
, Ib
} },
1719 { "rcrQ", { Ev
, Ib
} },
1720 { "shlQ", { Ev
, Ib
} },
1721 { "shrQ", { Ev
, Ib
} },
1722 { "(bad)", { XX
} },
1723 { "sarQ", { Ev
, Ib
} },
1727 { "rolA", { Eb
, I1
} },
1728 { "rorA", { Eb
, I1
} },
1729 { "rclA", { Eb
, I1
} },
1730 { "rcrA", { Eb
, I1
} },
1731 { "shlA", { Eb
, I1
} },
1732 { "shrA", { Eb
, I1
} },
1733 { "(bad)", { XX
} },
1734 { "sarA", { Eb
, I1
} },
1738 { "rolQ", { Ev
, I1
} },
1739 { "rorQ", { Ev
, I1
} },
1740 { "rclQ", { Ev
, I1
} },
1741 { "rcrQ", { Ev
, I1
} },
1742 { "shlQ", { Ev
, I1
} },
1743 { "shrQ", { Ev
, I1
} },
1744 { "(bad)", { XX
} },
1745 { "sarQ", { Ev
, I1
} },
1749 { "rolA", { Eb
, CL
} },
1750 { "rorA", { Eb
, CL
} },
1751 { "rclA", { Eb
, CL
} },
1752 { "rcrA", { Eb
, CL
} },
1753 { "shlA", { Eb
, CL
} },
1754 { "shrA", { Eb
, CL
} },
1755 { "(bad)", { XX
} },
1756 { "sarA", { Eb
, CL
} },
1760 { "rolQ", { Ev
, CL
} },
1761 { "rorQ", { Ev
, CL
} },
1762 { "rclQ", { Ev
, CL
} },
1763 { "rcrQ", { Ev
, CL
} },
1764 { "shlQ", { Ev
, CL
} },
1765 { "shrQ", { Ev
, CL
} },
1766 { "(bad)", { XX
} },
1767 { "sarQ", { Ev
, CL
} },
1771 { "testA", { Eb
, Ib
} },
1772 { "(bad)", { Eb
} },
1775 { "mulA", { Eb
} }, /* Don't print the implicit %al register, */
1776 { "imulA", { Eb
} }, /* to distinguish these opcodes from other */
1777 { "divA", { Eb
} }, /* mul/imul opcodes. Do the same for div */
1778 { "idivA", { Eb
} }, /* and idiv for consistency. */
1782 { "testQ", { Ev
, Iv
} },
1783 { "(bad)", { XX
} },
1786 { "mulQ", { Ev
} }, /* Don't print the implicit register. */
1787 { "imulQ", { Ev
} },
1789 { "idivQ", { Ev
} },
1795 { "(bad)", { XX
} },
1796 { "(bad)", { XX
} },
1797 { "(bad)", { XX
} },
1798 { "(bad)", { XX
} },
1799 { "(bad)", { XX
} },
1800 { "(bad)", { XX
} },
1806 { "callT", { indirEv
} },
1807 { "JcallT", { indirEp
} },
1808 { "jmpT", { indirEv
} },
1809 { "JjmpT", { indirEp
} },
1810 { "pushU", { stackEv
} },
1811 { "(bad)", { XX
} },
1815 { "sldtD", { Sv
} },
1821 { "(bad)", { XX
} },
1822 { "(bad)", { XX
} },
1826 { "sgdt{Q|IQ||}", { { VMX_Fixup
, 0 } } },
1827 { "sidt{Q|IQ||}", { { PNI_Fixup
, 0 } } },
1828 { "lgdt{Q|Q||}", { M
} },
1829 { "lidt{Q|Q||}", { { SVME_Fixup
, 0 } } },
1830 { "smswD", { Sv
} },
1831 { "(bad)", { XX
} },
1833 { "invlpg", { { INVLPG_Fixup
, w_mode
} } },
1837 { "(bad)", { XX
} },
1838 { "(bad)", { XX
} },
1839 { "(bad)", { XX
} },
1840 { "(bad)", { XX
} },
1841 { "btQ", { Ev
, Ib
} },
1842 { "btsQ", { Ev
, Ib
} },
1843 { "btrQ", { Ev
, Ib
} },
1844 { "btcQ", { Ev
, Ib
} },
1848 { "(bad)", { XX
} },
1849 { "cmpxchg8b", { { CMPXCHG8B_Fixup
, q_mode
} } },
1850 { "(bad)", { XX
} },
1851 { "(bad)", { XX
} },
1852 { "(bad)", { XX
} },
1853 { "(bad)", { XX
} },
1854 { "", { VM
} }, /* See OP_VMX. */
1855 { "vmptrst", { Mq
} },
1859 { "movA", { Eb
, Ib
} },
1860 { "(bad)", { XX
} },
1861 { "(bad)", { XX
} },
1862 { "(bad)", { XX
} },
1863 { "(bad)", { XX
} },
1864 { "(bad)", { XX
} },
1865 { "(bad)", { XX
} },
1866 { "(bad)", { XX
} },
1870 { "movQ", { Ev
, Iv
} },
1871 { "(bad)", { XX
} },
1872 { "(bad)", { XX
} },
1873 { "(bad)", { XX
} },
1874 { "(bad)", { XX
} },
1875 { "(bad)", { XX
} },
1876 { "(bad)", { XX
} },
1877 { "(bad)", { XX
} },
1881 { "(bad)", { XX
} },
1882 { "(bad)", { XX
} },
1883 { "psrlw", { MS
, Ib
} },
1884 { "(bad)", { XX
} },
1885 { "psraw", { MS
, Ib
} },
1886 { "(bad)", { XX
} },
1887 { "psllw", { MS
, Ib
} },
1888 { "(bad)", { XX
} },
1892 { "(bad)", { XX
} },
1893 { "(bad)", { XX
} },
1894 { "psrld", { MS
, Ib
} },
1895 { "(bad)", { XX
} },
1896 { "psrad", { MS
, Ib
} },
1897 { "(bad)", { XX
} },
1898 { "pslld", { MS
, Ib
} },
1899 { "(bad)", { XX
} },
1903 { "(bad)", { XX
} },
1904 { "(bad)", { XX
} },
1905 { "psrlq", { MS
, Ib
} },
1906 { "psrldq", { MS
, Ib
} },
1907 { "(bad)", { XX
} },
1908 { "(bad)", { XX
} },
1909 { "psllq", { MS
, Ib
} },
1910 { "pslldq", { MS
, Ib
} },
1914 { "fxsave", { Ev
} },
1915 { "fxrstor", { Ev
} },
1916 { "ldmxcsr", { Ev
} },
1917 { "stmxcsr", { Ev
} },
1918 { "(bad)", { XX
} },
1919 { "lfence", { { OP_0fae
, 0 } } },
1920 { "mfence", { { OP_0fae
, 0 } } },
1921 { "clflush", { { OP_0fae
, 0 } } },
1925 { "prefetchnta", { Ev
} },
1926 { "prefetcht0", { Ev
} },
1927 { "prefetcht1", { Ev
} },
1928 { "prefetcht2", { Ev
} },
1929 { "(bad)", { XX
} },
1930 { "(bad)", { XX
} },
1931 { "(bad)", { XX
} },
1932 { "(bad)", { XX
} },
1936 { "prefetch", { Eb
} },
1937 { "prefetchw", { Eb
} },
1938 { "(bad)", { XX
} },
1939 { "(bad)", { XX
} },
1940 { "(bad)", { XX
} },
1941 { "(bad)", { XX
} },
1942 { "(bad)", { XX
} },
1943 { "(bad)", { XX
} },
1947 { "xstore-rng", { { OP_0f07
, 0 } } },
1948 { "xcrypt-ecb", { { OP_0f07
, 0 } } },
1949 { "xcrypt-cbc", { { OP_0f07
, 0 } } },
1950 { "xcrypt-ctr", { { OP_0f07
, 0 } } },
1951 { "xcrypt-cfb", { { OP_0f07
, 0 } } },
1952 { "xcrypt-ofb", { { OP_0f07
, 0 } } },
1953 { "(bad)", { { OP_0f07
, 0 } } },
1954 { "(bad)", { { OP_0f07
, 0 } } },
1958 { "montmul", { { OP_0f07
, 0 } } },
1959 { "xsha1", { { OP_0f07
, 0 } } },
1960 { "xsha256", { { OP_0f07
, 0 } } },
1961 { "(bad)", { { OP_0f07
, 0 } } },
1962 { "(bad)", { { OP_0f07
, 0 } } },
1963 { "(bad)", { { OP_0f07
, 0 } } },
1964 { "(bad)", { { OP_0f07
, 0 } } },
1965 { "(bad)", { { OP_0f07
, 0 } } },
1969 static const struct dis386 prefix_user_table
[][4] = {
1972 { "addps", { XM
, EXx
} },
1973 { "addss", { XM
, EXd
} },
1974 { "addpd", { XM
, EXx
} },
1975 { "addsd", { XM
, EXq
} },
1979 { "", { XM
, EXx
, OPSIMD
} }, /* See OP_SIMD_SUFFIX. */
1980 { "", { XM
, EXx
, OPSIMD
} },
1981 { "", { XM
, EXx
, OPSIMD
} },
1982 { "", { XM
, EXx
, OPSIMD
} },
1986 { "cvtpi2ps", { XM
, EMC
} },
1987 { "cvtsi2ssY", { XM
, Ev
} },
1988 { "cvtpi2pd", { XM
, EMC
} },
1989 { "cvtsi2sdY", { XM
, Ev
} },
1993 { "cvtps2pi", { MXC
, EXx
} },
1994 { "cvtss2siY", { Gv
, EXx
} },
1995 { "cvtpd2pi", { MXC
, EXx
} },
1996 { "cvtsd2siY", { Gv
, EXx
} },
2000 { "cvttps2pi", { MXC
, EXx
} },
2001 { "cvttss2siY", { Gv
, EXx
} },
2002 { "cvttpd2pi", { MXC
, EXx
} },
2003 { "cvttsd2siY", { Gv
, EXx
} },
2007 { "divps", { XM
, EXx
} },
2008 { "divss", { XM
, EXx
} },
2009 { "divpd", { XM
, EXx
} },
2010 { "divsd", { XM
, EXx
} },
2014 { "maxps", { XM
, EXx
} },
2015 { "maxss", { XM
, EXx
} },
2016 { "maxpd", { XM
, EXx
} },
2017 { "maxsd", { XM
, EXx
} },
2021 { "minps", { XM
, EXx
} },
2022 { "minss", { XM
, EXx
} },
2023 { "minpd", { XM
, EXx
} },
2024 { "minsd", { XM
, EXx
} },
2028 { "movups", { XM
, EXx
} },
2029 { "movss", { XM
, EXx
} },
2030 { "movupd", { XM
, EXx
} },
2031 { "movsd", { XM
, EXx
} },
2035 { "movups", { EXx
, XM
} },
2036 { "movss", { EXx
, XM
} },
2037 { "movupd", { EXx
, XM
} },
2038 { "movsd", { EXx
, XM
} },
2042 { "mulps", { XM
, EXx
} },
2043 { "mulss", { XM
, EXx
} },
2044 { "mulpd", { XM
, EXx
} },
2045 { "mulsd", { XM
, EXx
} },
2049 { "rcpps", { XM
, EXx
} },
2050 { "rcpss", { XM
, EXx
} },
2051 { "(bad)", { XM
, EXx
} },
2052 { "(bad)", { XM
, EXx
} },
2056 { "rsqrtps",{ XM
, EXx
} },
2057 { "rsqrtss",{ XM
, EXx
} },
2058 { "(bad)", { XM
, EXx
} },
2059 { "(bad)", { XM
, EXx
} },
2063 { "sqrtps", { XM
, EXx
} },
2064 { "sqrtss", { XM
, EXx
} },
2065 { "sqrtpd", { XM
, EXx
} },
2066 { "sqrtsd", { XM
, EXx
} },
2070 { "subps", { XM
, EXx
} },
2071 { "subss", { XM
, EXx
} },
2072 { "subpd", { XM
, EXx
} },
2073 { "subsd", { XM
, EXx
} },
2077 { "(bad)", { XM
, EXx
} },
2078 { "cvtdq2pd", { XM
, EXq
} },
2079 { "cvttpd2dq", { XM
, EXx
} },
2080 { "cvtpd2dq", { XM
, EXx
} },
2084 { "cvtdq2ps", { XM
, EXx
} },
2085 { "cvttps2dq", { XM
, EXx
} },
2086 { "cvtps2dq", { XM
, EXx
} },
2087 { "(bad)", { XM
, EXx
} },
2091 { "cvtps2pd", { XM
, EXq
} },
2092 { "cvtss2sd", { XM
, EXx
} },
2093 { "cvtpd2ps", { XM
, EXx
} },
2094 { "cvtsd2ss", { XM
, EXx
} },
2098 { "maskmovq", { MX
, MS
} },
2099 { "(bad)", { XM
, EXx
} },
2100 { "maskmovdqu", { XM
, XS
} },
2101 { "(bad)", { XM
, EXx
} },
2105 { "movq", { MX
, EM
} },
2106 { "movdqu", { XM
, EXx
} },
2107 { "movdqa", { XM
, EXx
} },
2108 { "(bad)", { XM
, EXx
} },
2112 { "movq", { EM
, MX
} },
2113 { "movdqu", { EXx
, XM
} },
2114 { "movdqa", { EXx
, XM
} },
2115 { "(bad)", { EXx
, XM
} },
2119 { "(bad)", { EXx
, XM
} },
2120 { "movq2dq",{ XM
, MS
} },
2121 { "movq", { EXx
, XM
} },
2122 { "movdq2q",{ MX
, XS
} },
2126 { "pshufw", { MX
, EM
, Ib
} },
2127 { "pshufhw",{ XM
, EXx
, Ib
} },
2128 { "pshufd", { XM
, EXx
, Ib
} },
2129 { "pshuflw",{ XM
, EXx
, Ib
} },
2133 { "movd", { Edq
, MX
} },
2134 { "movq", { XM
, EXx
} },
2135 { "movd", { Edq
, XM
} },
2136 { "(bad)", { Ed
, XM
} },
2140 { "(bad)", { MX
, EXx
} },
2141 { "(bad)", { XM
, EXx
} },
2142 { "punpckhqdq", { XM
, EXx
} },
2143 { "(bad)", { XM
, EXx
} },
2147 { "movntq", { EM
, MX
} },
2148 { "(bad)", { EM
, XM
} },
2149 { "movntdq",{ EM
, XM
} },
2150 { "(bad)", { EM
, XM
} },
2154 { "(bad)", { MX
, EXx
} },
2155 { "(bad)", { XM
, EXx
} },
2156 { "punpcklqdq", { XM
, EXx
} },
2157 { "(bad)", { XM
, EXx
} },
2161 { "(bad)", { MX
, EXx
} },
2162 { "(bad)", { XM
, EXx
} },
2163 { "addsubpd", { XM
, EXx
} },
2164 { "addsubps", { XM
, EXx
} },
2168 { "(bad)", { MX
, EXx
} },
2169 { "(bad)", { XM
, EXx
} },
2170 { "haddpd", { XM
, EXx
} },
2171 { "haddps", { XM
, EXx
} },
2175 { "(bad)", { MX
, EXx
} },
2176 { "(bad)", { XM
, EXx
} },
2177 { "hsubpd", { XM
, EXx
} },
2178 { "hsubps", { XM
, EXx
} },
2182 { "movlpX", { XM
, EXq
, { SIMD_Fixup
, 'h' } } }, /* really only 2 operands */
2183 { "movsldup", { XM
, EXx
} },
2184 { "movlpd", { XM
, EXq
} },
2185 { "movddup", { XM
, EXq
} },
2189 { "movhpX", { XM
, EXq
, { SIMD_Fixup
, 'l' } } },
2190 { "movshdup", { XM
, EXx
} },
2191 { "movhpd", { XM
, EXq
} },
2192 { "(bad)", { XM
, EXq
} },
2196 { "(bad)", { XM
, EXx
} },
2197 { "(bad)", { XM
, EXx
} },
2198 { "(bad)", { XM
, EXx
} },
2199 { "lddqu", { XM
, M
} },
2203 {"movntps", { Ev
, XM
} },
2204 {"movntss", { Ev
, XM
} },
2205 {"movntpd", { Ev
, XM
} },
2206 {"movntsd", { Ev
, XM
} },
2211 {"vmread", { Em
, Gm
} },
2213 {"extrq", { XS
, Ib
, Ib
} },
2214 {"insertq", { XM
, XS
, Ib
, Ib
} },
2219 {"vmwrite", { Gm
, Em
} },
2221 {"extrq", { XM
, XS
} },
2222 {"insertq", { XM
, XS
} },
2227 { "bsrS", { Gv
, Ev
} },
2228 { "lzcntS", { Gv
, Ev
} },
2229 { "bsrS", { Gv
, Ev
} },
2230 { "(bad)", { XX
} },
2235 { "(bad)", { XX
} },
2236 { "popcntS", { Gv
, Ev
} },
2237 { "(bad)", { XX
} },
2238 { "(bad)", { XX
} },
2243 { "xchgS", { { NOP_Fixup1
, eAX_reg
}, { NOP_Fixup2
, eAX_reg
} } },
2244 { "pause", { XX
} },
2245 { "xchgS", { { NOP_Fixup1
, eAX_reg
}, { NOP_Fixup2
, eAX_reg
} } },
2246 { "(bad)", { XX
} },
2251 { "(bad)", { XX
} },
2252 { "(bad)", { XX
} },
2253 { "pblendvb", {XM
, EXx
, XMM0
} },
2254 { "(bad)", { XX
} },
2259 { "(bad)", { XX
} },
2260 { "(bad)", { XX
} },
2261 { "blendvps", {XM
, EXx
, XMM0
} },
2262 { "(bad)", { XX
} },
2267 { "(bad)", { XX
} },
2268 { "(bad)", { XX
} },
2269 { "blendvpd", { XM
, EXx
, XMM0
} },
2270 { "(bad)", { XX
} },
2275 { "(bad)", { XX
} },
2276 { "(bad)", { XX
} },
2277 { "ptest", { XM
, EXx
} },
2278 { "(bad)", { XX
} },
2283 { "(bad)", { XX
} },
2284 { "(bad)", { XX
} },
2285 { "pmovsxbw", { XM
, EXx
} },
2286 { "(bad)", { XX
} },
2291 { "(bad)", { XX
} },
2292 { "(bad)", { XX
} },
2293 { "pmovsxbd", { XM
, EXx
} },
2294 { "(bad)", { XX
} },
2299 { "(bad)", { XX
} },
2300 { "(bad)", { XX
} },
2301 { "pmovsxbq", { XM
, EXx
} },
2302 { "(bad)", { XX
} },
2307 { "(bad)", { XX
} },
2308 { "(bad)", { XX
} },
2309 { "pmovsxwd", { XM
, EXx
} },
2310 { "(bad)", { XX
} },
2315 { "(bad)", { XX
} },
2316 { "(bad)", { XX
} },
2317 { "pmovsxwq", { XM
, EXx
} },
2318 { "(bad)", { XX
} },
2323 { "(bad)", { XX
} },
2324 { "(bad)", { XX
} },
2325 { "pmovsxdq", { XM
, EXx
} },
2326 { "(bad)", { XX
} },
2331 { "(bad)", { XX
} },
2332 { "(bad)", { XX
} },
2333 { "pmuldq", { XM
, EXx
} },
2334 { "(bad)", { XX
} },
2339 { "(bad)", { XX
} },
2340 { "(bad)", { XX
} },
2341 { "pcmpeqq", { XM
, EXx
} },
2342 { "(bad)", { XX
} },
2347 { "(bad)", { XX
} },
2348 { "(bad)", { XX
} },
2349 { "movntdqa", { XM
, EM
} },
2350 { "(bad)", { XX
} },
2355 { "(bad)", { XX
} },
2356 { "(bad)", { XX
} },
2357 { "packusdw", { XM
, EXx
} },
2358 { "(bad)", { XX
} },
2363 { "(bad)", { XX
} },
2364 { "(bad)", { XX
} },
2365 { "pmovzxbw", { XM
, EXx
} },
2366 { "(bad)", { XX
} },
2371 { "(bad)", { XX
} },
2372 { "(bad)", { XX
} },
2373 { "pmovzxbd", { XM
, EXx
} },
2374 { "(bad)", { XX
} },
2379 { "(bad)", { XX
} },
2380 { "(bad)", { XX
} },
2381 { "pmovzxbq", { XM
, EXx
} },
2382 { "(bad)", { XX
} },
2387 { "(bad)", { XX
} },
2388 { "(bad)", { XX
} },
2389 { "pmovzxwd", { XM
, EXx
} },
2390 { "(bad)", { XX
} },
2395 { "(bad)", { XX
} },
2396 { "(bad)", { XX
} },
2397 { "pmovzxwq", { XM
, EXx
} },
2398 { "(bad)", { XX
} },
2403 { "(bad)", { XX
} },
2404 { "(bad)", { XX
} },
2405 { "pmovzxdq", { XM
, EXx
} },
2406 { "(bad)", { XX
} },
2411 { "(bad)", { XX
} },
2412 { "(bad)", { XX
} },
2413 { "pminsb", { XM
, EXx
} },
2414 { "(bad)", { XX
} },
2419 { "(bad)", { XX
} },
2420 { "(bad)", { XX
} },
2421 { "pminsd", { XM
, EXx
} },
2422 { "(bad)", { XX
} },
2427 { "(bad)", { XX
} },
2428 { "(bad)", { XX
} },
2429 { "pminuw", { XM
, EXx
} },
2430 { "(bad)", { XX
} },
2435 { "(bad)", { XX
} },
2436 { "(bad)", { XX
} },
2437 { "pminud", { XM
, EXx
} },
2438 { "(bad)", { XX
} },
2443 { "(bad)", { XX
} },
2444 { "(bad)", { XX
} },
2445 { "pmaxsb", { XM
, EXx
} },
2446 { "(bad)", { XX
} },
2451 { "(bad)", { XX
} },
2452 { "(bad)", { XX
} },
2453 { "pmaxsd", { XM
, EXx
} },
2454 { "(bad)", { XX
} },
2459 { "(bad)", { XX
} },
2460 { "(bad)", { XX
} },
2461 { "pmaxuw", { XM
, EXx
} },
2462 { "(bad)", { XX
} },
2467 { "(bad)", { XX
} },
2468 { "(bad)", { XX
} },
2469 { "pmaxud", { XM
, EXx
} },
2470 { "(bad)", { XX
} },
2475 { "(bad)", { XX
} },
2476 { "(bad)", { XX
} },
2477 { "pmulld", { XM
, EXx
} },
2478 { "(bad)", { XX
} },
2483 { "(bad)", { XX
} },
2484 { "(bad)", { XX
} },
2485 { "phminposuw", { XM
, EXx
} },
2486 { "(bad)", { XX
} },
2491 { "(bad)", { XX
} },
2492 { "(bad)", { XX
} },
2493 { "roundps", { XM
, EXx
, Ib
} },
2494 { "(bad)", { XX
} },
2499 { "(bad)", { XX
} },
2500 { "(bad)", { XX
} },
2501 { "roundpd", { XM
, EXx
, Ib
} },
2502 { "(bad)", { XX
} },
2507 { "(bad)", { XX
} },
2508 { "(bad)", { XX
} },
2509 { "roundss", { XM
, EXx
, Ib
} },
2510 { "(bad)", { XX
} },
2515 { "(bad)", { XX
} },
2516 { "(bad)", { XX
} },
2517 { "roundsd", { XM
, EXx
, Ib
} },
2518 { "(bad)", { XX
} },
2523 { "(bad)", { XX
} },
2524 { "(bad)", { XX
} },
2525 { "blendps", { XM
, EXx
, Ib
} },
2526 { "(bad)", { XX
} },
2531 { "(bad)", { XX
} },
2532 { "(bad)", { XX
} },
2533 { "blendpd", { XM
, EXx
, Ib
} },
2534 { "(bad)", { XX
} },
2539 { "(bad)", { XX
} },
2540 { "(bad)", { XX
} },
2541 { "pblendw", { XM
, EXx
, Ib
} },
2542 { "(bad)", { XX
} },
2547 { "(bad)", { XX
} },
2548 { "(bad)", { XX
} },
2549 { "pextrb", { Edqb
, XM
, Ib
} },
2550 { "(bad)", { XX
} },
2555 { "(bad)", { XX
} },
2556 { "(bad)", { XX
} },
2557 { "pextrw", { Edqw
, XM
, Ib
} },
2558 { "(bad)", { XX
} },
2563 { "(bad)", { XX
} },
2564 { "(bad)", { XX
} },
2565 { "pextrK", { Edq
, XM
, Ib
} },
2566 { "(bad)", { XX
} },
2571 { "(bad)", { XX
} },
2572 { "(bad)", { XX
} },
2573 { "extractps", { Edqd
, XM
, Ib
} },
2574 { "(bad)", { XX
} },
2579 { "(bad)", { XX
} },
2580 { "(bad)", { XX
} },
2581 { "pinsrb", { XM
, Edqb
, Ib
} },
2582 { "(bad)", { XX
} },
2587 { "(bad)", { XX
} },
2588 { "(bad)", { XX
} },
2589 { "insertps", { XM
, EXx
, Ib
} },
2590 { "(bad)", { XX
} },
2595 { "(bad)", { XX
} },
2596 { "(bad)", { XX
} },
2597 { "pinsrK", { XM
, Edq
, Ib
} },
2598 { "(bad)", { XX
} },
2603 { "(bad)", { XX
} },
2604 { "(bad)", { XX
} },
2605 { "dpps", { XM
, EXx
, Ib
} },
2606 { "(bad)", { XX
} },
2611 { "(bad)", { XX
} },
2612 { "(bad)", { XX
} },
2613 { "dppd", { XM
, EXx
, Ib
} },
2614 { "(bad)", { XX
} },
2619 { "(bad)", { XX
} },
2620 { "(bad)", { XX
} },
2621 { "mpsadbw", { XM
, EXx
, Ib
} },
2622 { "(bad)", { XX
} },
2627 { "(bad)", { XX
} },
2628 { "(bad)", { XX
} },
2629 { "pcmpgtq", { XM
, EXx
} },
2630 { "(bad)", { XX
} },
2635 { "movbe", { Gv
, Ev
} },
2636 { "(bad)", { XX
} },
2637 { "movbe", { Gv
, Ev
} },
2638 { "crc32", { Gdq
, { CRC32_Fixup
, b_mode
} } },
2643 { "movbe", { Ev
, Gv
} },
2644 { "(bad)", { XX
} },
2645 { "movbe", { Ev
, Gv
} },
2646 { "crc32", { Gdq
, { CRC32_Fixup
, v_mode
} } },
2651 { "(bad)", { XX
} },
2652 { "(bad)", { XX
} },
2653 { "pcmpestrm", { XM
, EXx
, Ib
} },
2654 { "(bad)", { XX
} },
2659 { "(bad)", { XX
} },
2660 { "(bad)", { XX
} },
2661 { "pcmpestri", { XM
, EXx
, Ib
} },
2662 { "(bad)", { XX
} },
2667 { "(bad)", { XX
} },
2668 { "(bad)", { XX
} },
2669 { "pcmpistrm", { XM
, EXx
, Ib
} },
2670 { "(bad)", { XX
} },
2675 { "(bad)", { XX
} },
2676 { "(bad)", { XX
} },
2677 { "pcmpistri", { XM
, EXx
, Ib
} },
2678 { "(bad)", { XX
} },
2683 { "ucomiss",{ XM
, EXd
} },
2684 { "(bad)", { XX
} },
2685 { "ucomisd",{ XM
, EXq
} },
2686 { "(bad)", { XX
} },
2691 { "comiss", { XM
, EXd
} },
2692 { "(bad)", { XX
} },
2693 { "comisd", { XM
, EXq
} },
2694 { "(bad)", { XX
} },
2699 { "punpcklbw",{ MX
, EMd
} },
2700 { "(bad)", { XX
} },
2701 { "punpcklbw",{ MX
, EMq
} },
2702 { "(bad)", { XX
} },
2707 { "punpcklwd",{ MX
, EMd
} },
2708 { "(bad)", { XX
} },
2709 { "punpcklwd",{ MX
, EMq
} },
2710 { "(bad)", { XX
} },
2715 { "punpckldq",{ MX
, EMd
} },
2716 { "(bad)", { XX
} },
2717 { "punpckldq",{ MX
, EMq
} },
2718 { "(bad)", { XX
} },
2723 { "(bad)", { XX
} },
2724 { "(bad)", { XX
} },
2725 { "pclmulqdq", { XM
, EXx
, Ib
} },
2726 { "(bad)", { XX
} },
2731 { "(bad)", { XX
} },
2732 { "(bad)", { XX
} },
2733 { "aesimc", { XM
, EXx
} },
2734 { "(bad)", { XX
} },
2739 { "(bad)", { XX
} },
2740 { "(bad)", { XX
} },
2741 { "aesenc", { XM
, EXx
} },
2742 { "(bad)", { XX
} },
2747 { "(bad)", { XX
} },
2748 { "(bad)", { XX
} },
2749 { "aesenclast", { XM
, EXx
} },
2750 { "(bad)", { XX
} },
2755 { "(bad)", { XX
} },
2756 { "(bad)", { XX
} },
2757 { "aesdec", { XM
, EXx
} },
2758 { "(bad)", { XX
} },
2763 { "(bad)", { XX
} },
2764 { "(bad)", { XX
} },
2765 { "aesdeclast", { XM
, EXx
} },
2766 { "(bad)", { XX
} },
2771 { "(bad)", { XX
} },
2772 { "(bad)", { XX
} },
2773 { "aeskeygenassist", { XM
, EXx
, Ib
} },
2774 { "(bad)", { XX
} },
2779 static const struct dis386 x86_64_table
[][2] = {
2781 { "pusha{P|}", { XX
} },
2782 { "(bad)", { XX
} },
2785 { "popa{P|}", { XX
} },
2786 { "(bad)", { XX
} },
2789 { "bound{S|}", { Gv
, Ma
} },
2790 { "(bad)", { XX
} },
2793 { "arpl", { Ew
, Gw
} },
2794 { "movs{||lq|xd}", { Gv
, Ed
} },
2798 static const struct dis386 three_byte_table
[][256] = {
2802 { "pshufb", { MX
, EM
} },
2803 { "phaddw", { MX
, EM
} },
2804 { "phaddd", { MX
, EM
} },
2805 { "phaddsw", { MX
, EM
} },
2806 { "pmaddubsw", { MX
, EM
} },
2807 { "phsubw", { MX
, EM
} },
2808 { "phsubd", { MX
, EM
} },
2809 { "phsubsw", { MX
, EM
} },
2811 { "psignb", { MX
, EM
} },
2812 { "psignw", { MX
, EM
} },
2813 { "psignd", { MX
, EM
} },
2814 { "pmulhrsw", { MX
, EM
} },
2815 { "(bad)", { XX
} },
2816 { "(bad)", { XX
} },
2817 { "(bad)", { XX
} },
2818 { "(bad)", { XX
} },
2821 { "(bad)", { XX
} },
2822 { "(bad)", { XX
} },
2823 { "(bad)", { XX
} },
2826 { "(bad)", { XX
} },
2829 { "(bad)", { XX
} },
2830 { "(bad)", { XX
} },
2831 { "(bad)", { XX
} },
2832 { "(bad)", { XX
} },
2833 { "pabsb", { MX
, EM
} },
2834 { "pabsw", { MX
, EM
} },
2835 { "pabsd", { MX
, EM
} },
2836 { "(bad)", { XX
} },
2844 { "(bad)", { XX
} },
2845 { "(bad)", { XX
} },
2851 { "(bad)", { XX
} },
2852 { "(bad)", { XX
} },
2853 { "(bad)", { XX
} },
2854 { "(bad)", { XX
} },
2862 { "(bad)", { XX
} },
2876 { "(bad)", { XX
} },
2877 { "(bad)", { XX
} },
2878 { "(bad)", { XX
} },
2879 { "(bad)", { XX
} },
2880 { "(bad)", { XX
} },
2881 { "(bad)", { XX
} },
2883 { "(bad)", { XX
} },
2884 { "(bad)", { XX
} },
2885 { "(bad)", { XX
} },
2886 { "(bad)", { XX
} },
2887 { "(bad)", { XX
} },
2888 { "(bad)", { XX
} },
2889 { "(bad)", { XX
} },
2890 { "(bad)", { XX
} },
2892 { "(bad)", { XX
} },
2893 { "(bad)", { XX
} },
2894 { "(bad)", { XX
} },
2895 { "(bad)", { XX
} },
2896 { "(bad)", { XX
} },
2897 { "(bad)", { XX
} },
2898 { "(bad)", { XX
} },
2899 { "(bad)", { XX
} },
2901 { "(bad)", { XX
} },
2902 { "(bad)", { XX
} },
2903 { "(bad)", { XX
} },
2904 { "(bad)", { XX
} },
2905 { "(bad)", { XX
} },
2906 { "(bad)", { XX
} },
2907 { "(bad)", { XX
} },
2908 { "(bad)", { XX
} },
2910 { "(bad)", { XX
} },
2911 { "(bad)", { XX
} },
2912 { "(bad)", { XX
} },
2913 { "(bad)", { XX
} },
2914 { "(bad)", { XX
} },
2915 { "(bad)", { XX
} },
2916 { "(bad)", { XX
} },
2917 { "(bad)", { XX
} },
2919 { "(bad)", { XX
} },
2920 { "(bad)", { XX
} },
2921 { "(bad)", { XX
} },
2922 { "(bad)", { XX
} },
2923 { "(bad)", { XX
} },
2924 { "(bad)", { XX
} },
2925 { "(bad)", { XX
} },
2926 { "(bad)", { XX
} },
2928 { "(bad)", { XX
} },
2929 { "(bad)", { XX
} },
2930 { "(bad)", { XX
} },
2931 { "(bad)", { XX
} },
2932 { "(bad)", { XX
} },
2933 { "(bad)", { XX
} },
2934 { "(bad)", { XX
} },
2935 { "(bad)", { XX
} },
2937 { "(bad)", { XX
} },
2938 { "(bad)", { XX
} },
2939 { "(bad)", { XX
} },
2940 { "(bad)", { XX
} },
2941 { "(bad)", { XX
} },
2942 { "(bad)", { XX
} },
2943 { "(bad)", { XX
} },
2944 { "(bad)", { XX
} },
2946 { "(bad)", { XX
} },
2947 { "(bad)", { XX
} },
2948 { "(bad)", { XX
} },
2949 { "(bad)", { XX
} },
2950 { "(bad)", { XX
} },
2951 { "(bad)", { XX
} },
2952 { "(bad)", { XX
} },
2953 { "(bad)", { XX
} },
2955 { "(bad)", { XX
} },
2956 { "(bad)", { XX
} },
2957 { "(bad)", { XX
} },
2958 { "(bad)", { XX
} },
2959 { "(bad)", { XX
} },
2960 { "(bad)", { XX
} },
2961 { "(bad)", { XX
} },
2962 { "(bad)", { XX
} },
2964 { "(bad)", { XX
} },
2965 { "(bad)", { XX
} },
2966 { "(bad)", { XX
} },
2967 { "(bad)", { XX
} },
2968 { "(bad)", { XX
} },
2969 { "(bad)", { XX
} },
2970 { "(bad)", { XX
} },
2971 { "(bad)", { XX
} },
2973 { "(bad)", { XX
} },
2974 { "(bad)", { XX
} },
2975 { "(bad)", { XX
} },
2976 { "(bad)", { XX
} },
2977 { "(bad)", { XX
} },
2978 { "(bad)", { XX
} },
2979 { "(bad)", { XX
} },
2980 { "(bad)", { XX
} },
2982 { "(bad)", { XX
} },
2983 { "(bad)", { XX
} },
2984 { "(bad)", { XX
} },
2985 { "(bad)", { XX
} },
2986 { "(bad)", { XX
} },
2987 { "(bad)", { XX
} },
2988 { "(bad)", { XX
} },
2989 { "(bad)", { XX
} },
2991 { "(bad)", { XX
} },
2992 { "(bad)", { XX
} },
2993 { "(bad)", { XX
} },
2994 { "(bad)", { XX
} },
2995 { "(bad)", { XX
} },
2996 { "(bad)", { XX
} },
2997 { "(bad)", { XX
} },
2998 { "(bad)", { XX
} },
3000 { "(bad)", { XX
} },
3001 { "(bad)", { XX
} },
3002 { "(bad)", { XX
} },
3003 { "(bad)", { XX
} },
3004 { "(bad)", { XX
} },
3005 { "(bad)", { XX
} },
3006 { "(bad)", { XX
} },
3007 { "(bad)", { XX
} },
3009 { "(bad)", { XX
} },
3010 { "(bad)", { XX
} },
3011 { "(bad)", { XX
} },
3012 { "(bad)", { XX
} },
3013 { "(bad)", { XX
} },
3014 { "(bad)", { XX
} },
3015 { "(bad)", { XX
} },
3016 { "(bad)", { XX
} },
3018 { "(bad)", { XX
} },
3019 { "(bad)", { XX
} },
3020 { "(bad)", { XX
} },
3021 { "(bad)", { XX
} },
3022 { "(bad)", { XX
} },
3023 { "(bad)", { XX
} },
3024 { "(bad)", { XX
} },
3025 { "(bad)", { XX
} },
3027 { "(bad)", { XX
} },
3028 { "(bad)", { XX
} },
3029 { "(bad)", { XX
} },
3030 { "(bad)", { XX
} },
3031 { "(bad)", { XX
} },
3032 { "(bad)", { XX
} },
3033 { "(bad)", { XX
} },
3034 { "(bad)", { XX
} },
3036 { "(bad)", { XX
} },
3037 { "(bad)", { XX
} },
3038 { "(bad)", { XX
} },
3039 { "(bad)", { XX
} },
3040 { "(bad)", { XX
} },
3041 { "(bad)", { XX
} },
3042 { "(bad)", { XX
} },
3043 { "(bad)", { XX
} },
3045 { "(bad)", { XX
} },
3046 { "(bad)", { XX
} },
3047 { "(bad)", { XX
} },
3054 { "(bad)", { XX
} },
3055 { "(bad)", { XX
} },
3056 { "(bad)", { XX
} },
3057 { "(bad)", { XX
} },
3058 { "(bad)", { XX
} },
3059 { "(bad)", { XX
} },
3060 { "(bad)", { XX
} },
3061 { "(bad)", { XX
} },
3063 { "(bad)", { XX
} },
3064 { "(bad)", { XX
} },
3065 { "(bad)", { XX
} },
3066 { "(bad)", { XX
} },
3067 { "(bad)", { XX
} },
3068 { "(bad)", { XX
} },
3069 { "(bad)", { XX
} },
3070 { "(bad)", { XX
} },
3074 { "(bad)", { XX
} },
3075 { "(bad)", { XX
} },
3076 { "(bad)", { XX
} },
3077 { "(bad)", { XX
} },
3078 { "(bad)", { XX
} },
3079 { "(bad)", { XX
} },
3081 { "(bad)", { XX
} },
3082 { "(bad)", { XX
} },
3083 { "(bad)", { XX
} },
3084 { "(bad)", { XX
} },
3085 { "(bad)", { XX
} },
3086 { "(bad)", { XX
} },
3087 { "(bad)", { XX
} },
3088 { "(bad)", { XX
} },
3093 { "(bad)", { XX
} },
3094 { "(bad)", { XX
} },
3095 { "(bad)", { XX
} },
3096 { "(bad)", { XX
} },
3097 { "(bad)", { XX
} },
3098 { "(bad)", { XX
} },
3099 { "(bad)", { XX
} },
3100 { "(bad)", { XX
} },
3109 { "palignr", { MX
, EM
, Ib
} },
3111 { "(bad)", { XX
} },
3112 { "(bad)", { XX
} },
3113 { "(bad)", { XX
} },
3114 { "(bad)", { XX
} },
3120 { "(bad)", { XX
} },
3121 { "(bad)", { XX
} },
3122 { "(bad)", { XX
} },
3123 { "(bad)", { XX
} },
3124 { "(bad)", { XX
} },
3125 { "(bad)", { XX
} },
3126 { "(bad)", { XX
} },
3127 { "(bad)", { XX
} },
3132 { "(bad)", { XX
} },
3133 { "(bad)", { XX
} },
3134 { "(bad)", { XX
} },
3135 { "(bad)", { XX
} },
3136 { "(bad)", { XX
} },
3138 { "(bad)", { XX
} },
3139 { "(bad)", { XX
} },
3140 { "(bad)", { XX
} },
3141 { "(bad)", { XX
} },
3142 { "(bad)", { XX
} },
3143 { "(bad)", { XX
} },
3144 { "(bad)", { XX
} },
3145 { "(bad)", { XX
} },
3147 { "(bad)", { XX
} },
3148 { "(bad)", { XX
} },
3149 { "(bad)", { XX
} },
3150 { "(bad)", { XX
} },
3151 { "(bad)", { XX
} },
3152 { "(bad)", { XX
} },
3153 { "(bad)", { XX
} },
3154 { "(bad)", { XX
} },
3156 { "(bad)", { XX
} },
3157 { "(bad)", { XX
} },
3158 { "(bad)", { XX
} },
3159 { "(bad)", { XX
} },
3160 { "(bad)", { XX
} },
3161 { "(bad)", { XX
} },
3162 { "(bad)", { XX
} },
3163 { "(bad)", { XX
} },
3168 { "(bad)", { XX
} },
3170 { "(bad)", { XX
} },
3171 { "(bad)", { XX
} },
3172 { "(bad)", { XX
} },
3174 { "(bad)", { XX
} },
3175 { "(bad)", { XX
} },
3176 { "(bad)", { XX
} },
3177 { "(bad)", { XX
} },
3178 { "(bad)", { XX
} },
3179 { "(bad)", { XX
} },
3180 { "(bad)", { XX
} },
3181 { "(bad)", { XX
} },
3183 { "(bad)", { XX
} },
3184 { "(bad)", { XX
} },
3185 { "(bad)", { XX
} },
3186 { "(bad)", { XX
} },
3187 { "(bad)", { XX
} },
3188 { "(bad)", { XX
} },
3189 { "(bad)", { XX
} },
3190 { "(bad)", { XX
} },
3192 { "(bad)", { XX
} },
3193 { "(bad)", { XX
} },
3194 { "(bad)", { XX
} },
3195 { "(bad)", { XX
} },
3196 { "(bad)", { XX
} },
3197 { "(bad)", { XX
} },
3198 { "(bad)", { XX
} },
3199 { "(bad)", { XX
} },
3205 { "(bad)", { XX
} },
3206 { "(bad)", { XX
} },
3207 { "(bad)", { XX
} },
3208 { "(bad)", { XX
} },
3210 { "(bad)", { XX
} },
3211 { "(bad)", { XX
} },
3212 { "(bad)", { XX
} },
3213 { "(bad)", { XX
} },
3214 { "(bad)", { XX
} },
3215 { "(bad)", { XX
} },
3216 { "(bad)", { XX
} },
3217 { "(bad)", { XX
} },
3219 { "(bad)", { XX
} },
3220 { "(bad)", { XX
} },
3221 { "(bad)", { XX
} },
3222 { "(bad)", { XX
} },
3223 { "(bad)", { XX
} },
3224 { "(bad)", { XX
} },
3225 { "(bad)", { XX
} },
3226 { "(bad)", { XX
} },
3228 { "(bad)", { XX
} },
3229 { "(bad)", { XX
} },
3230 { "(bad)", { XX
} },
3231 { "(bad)", { XX
} },
3232 { "(bad)", { XX
} },
3233 { "(bad)", { XX
} },
3234 { "(bad)", { XX
} },
3235 { "(bad)", { XX
} },
3237 { "(bad)", { XX
} },
3238 { "(bad)", { XX
} },
3239 { "(bad)", { XX
} },
3240 { "(bad)", { XX
} },
3241 { "(bad)", { XX
} },
3242 { "(bad)", { XX
} },
3243 { "(bad)", { XX
} },
3244 { "(bad)", { XX
} },
3246 { "(bad)", { XX
} },
3247 { "(bad)", { XX
} },
3248 { "(bad)", { XX
} },
3249 { "(bad)", { XX
} },
3250 { "(bad)", { XX
} },
3251 { "(bad)", { XX
} },
3252 { "(bad)", { XX
} },
3253 { "(bad)", { XX
} },
3255 { "(bad)", { XX
} },
3256 { "(bad)", { XX
} },
3257 { "(bad)", { XX
} },
3258 { "(bad)", { XX
} },
3259 { "(bad)", { XX
} },
3260 { "(bad)", { XX
} },
3261 { "(bad)", { XX
} },
3262 { "(bad)", { XX
} },
3264 { "(bad)", { XX
} },
3265 { "(bad)", { XX
} },
3266 { "(bad)", { XX
} },
3267 { "(bad)", { XX
} },
3268 { "(bad)", { XX
} },
3269 { "(bad)", { XX
} },
3270 { "(bad)", { XX
} },
3271 { "(bad)", { XX
} },
3273 { "(bad)", { XX
} },
3274 { "(bad)", { XX
} },
3275 { "(bad)", { XX
} },
3276 { "(bad)", { XX
} },
3277 { "(bad)", { XX
} },
3278 { "(bad)", { XX
} },
3279 { "(bad)", { XX
} },
3280 { "(bad)", { XX
} },
3282 { "(bad)", { XX
} },
3283 { "(bad)", { XX
} },
3284 { "(bad)", { XX
} },
3285 { "(bad)", { XX
} },
3286 { "(bad)", { XX
} },
3287 { "(bad)", { XX
} },
3288 { "(bad)", { XX
} },
3289 { "(bad)", { XX
} },
3291 { "(bad)", { XX
} },
3292 { "(bad)", { XX
} },
3293 { "(bad)", { XX
} },
3294 { "(bad)", { XX
} },
3295 { "(bad)", { XX
} },
3296 { "(bad)", { XX
} },
3297 { "(bad)", { XX
} },
3298 { "(bad)", { XX
} },
3300 { "(bad)", { XX
} },
3301 { "(bad)", { XX
} },
3302 { "(bad)", { XX
} },
3303 { "(bad)", { XX
} },
3304 { "(bad)", { XX
} },
3305 { "(bad)", { XX
} },
3306 { "(bad)", { XX
} },
3307 { "(bad)", { XX
} },
3309 { "(bad)", { XX
} },
3310 { "(bad)", { XX
} },
3311 { "(bad)", { XX
} },
3312 { "(bad)", { XX
} },
3313 { "(bad)", { XX
} },
3314 { "(bad)", { XX
} },
3315 { "(bad)", { XX
} },
3316 { "(bad)", { XX
} },
3318 { "(bad)", { XX
} },
3319 { "(bad)", { XX
} },
3320 { "(bad)", { XX
} },
3321 { "(bad)", { XX
} },
3322 { "(bad)", { XX
} },
3323 { "(bad)", { XX
} },
3324 { "(bad)", { XX
} },
3325 { "(bad)", { XX
} },
3327 { "(bad)", { XX
} },
3328 { "(bad)", { XX
} },
3329 { "(bad)", { XX
} },
3330 { "(bad)", { XX
} },
3331 { "(bad)", { XX
} },
3332 { "(bad)", { XX
} },
3333 { "(bad)", { XX
} },
3334 { "(bad)", { XX
} },
3336 { "(bad)", { XX
} },
3337 { "(bad)", { XX
} },
3338 { "(bad)", { XX
} },
3339 { "(bad)", { XX
} },
3340 { "(bad)", { XX
} },
3341 { "(bad)", { XX
} },
3342 { "(bad)", { XX
} },
3345 { "(bad)", { XX
} },
3346 { "(bad)", { XX
} },
3347 { "(bad)", { XX
} },
3348 { "(bad)", { XX
} },
3349 { "(bad)", { XX
} },
3350 { "(bad)", { XX
} },
3351 { "(bad)", { XX
} },
3352 { "(bad)", { XX
} },
3354 { "(bad)", { XX
} },
3355 { "(bad)", { XX
} },
3356 { "(bad)", { XX
} },
3357 { "(bad)", { XX
} },
3358 { "(bad)", { XX
} },
3359 { "(bad)", { XX
} },
3360 { "(bad)", { XX
} },
3361 { "(bad)", { XX
} },
3363 { "(bad)", { XX
} },
3364 { "(bad)", { XX
} },
3365 { "(bad)", { XX
} },
3366 { "(bad)", { XX
} },
3367 { "(bad)", { XX
} },
3368 { "(bad)", { XX
} },
3369 { "(bad)", { XX
} },
3370 { "(bad)", { XX
} },
3372 { "(bad)", { XX
} },
3373 { "(bad)", { XX
} },
3374 { "(bad)", { XX
} },
3375 { "(bad)", { XX
} },
3376 { "(bad)", { XX
} },
3377 { "(bad)", { XX
} },
3378 { "(bad)", { XX
} },
3379 { "(bad)", { XX
} },
3383 #define INTERNAL_DISASSEMBLER_ERROR _("<internal disassembler error>")
3395 fetch_data(the_info
, codep
+ 1);
3399 /* REX prefixes family. */
3416 if (address_mode
== mode_64bit
)
3422 prefixes
|= PREFIX_REPZ
;
3425 prefixes
|= PREFIX_REPNZ
;
3428 prefixes
|= PREFIX_LOCK
;
3431 prefixes
|= PREFIX_CS
;
3434 prefixes
|= PREFIX_SS
;
3437 prefixes
|= PREFIX_DS
;
3440 prefixes
|= PREFIX_ES
;
3443 prefixes
|= PREFIX_FS
;
3446 prefixes
|= PREFIX_GS
;
3449 prefixes
|= PREFIX_DATA
;
3452 prefixes
|= PREFIX_ADDR
;
3455 /* fwait is really an instruction. If there are prefixes
3456 before the fwait, they belong to the fwait, *not* to the
3457 following instruction. */
3458 if (prefixes
|| rex
)
3460 prefixes
|= PREFIX_FWAIT
;
3464 prefixes
= PREFIX_FWAIT
;
3469 /* Rex is ignored when followed by another prefix. */
3480 /* Return the name of the prefix byte PREF, or NULL if PREF is not a
3484 prefix_name (int pref
, int sizeflag
)
3486 static const char * const rexes
[16] =
3491 "rex.XB", /* 0x43 */
3493 "rex.RB", /* 0x45 */
3494 "rex.RX", /* 0x46 */
3495 "rex.RXB", /* 0x47 */
3497 "rex.WB", /* 0x49 */
3498 "rex.WX", /* 0x4a */
3499 "rex.WXB", /* 0x4b */
3500 "rex.WR", /* 0x4c */
3501 "rex.WRB", /* 0x4d */
3502 "rex.WRX", /* 0x4e */
3503 "rex.WRXB", /* 0x4f */
3508 /* REX prefixes family. */
3525 return rexes
[pref
- 0x40];
3545 return (sizeflag
& DFLAG
) ? "data16" : "data32";
3547 if (address_mode
== mode_64bit
)
3548 return (sizeflag
& AFLAG
) ? "addr32" : "addr64";
3550 return (sizeflag
& AFLAG
) ? "addr16" : "addr32";
3558 static char op_out
[MAX_OPERANDS
][100];
3559 static int op_ad
, op_index
[MAX_OPERANDS
];
3560 static int two_source_ops
;
3561 static bfd_vma op_address
[MAX_OPERANDS
];
3562 static bfd_vma op_riprel
[MAX_OPERANDS
];
3563 static bfd_vma start_pc
;
3566 * On the 386's of 1988, the maximum length of an instruction is 15 bytes.
3567 * (see topic "Redundant prefixes" in the "Differences from 8086"
3568 * section of the "Virtual 8086 Mode" chapter.)
3569 * 'pc' should be the address of this instruction, it will
3570 * be used to print the target address if this is a relative jump or call
3571 * The function returns the length of this instruction in bytes.
3574 static char intel_syntax
;
3575 static char open_char
;
3576 static char close_char
;
3577 static char separator_char
;
3578 static char scale_char
;
3581 print_insn_i386 (bfd_vma pc
, disassemble_info
*info
)
3585 return print_insn (pc
, info
);
3589 print_insn (bfd_vma pc
, disassemble_info
*info
)
3591 const struct dis386
*dp
;
3593 char *op_txt
[MAX_OPERANDS
];
3595 unsigned char uses_DATA_prefix
, uses_LOCK_prefix
;
3596 unsigned char uses_REPNZ_prefix
, uses_REPZ_prefix
;
3599 struct dis_private priv
;
3602 if (info
->mach
== bfd_mach_x86_64_intel_syntax
3603 || info
->mach
== bfd_mach_x86_64
)
3604 address_mode
= mode_64bit
;
3606 address_mode
= mode_32bit
;
3608 if (intel_syntax
== (char) -1)
3609 intel_syntax
= (info
->mach
== bfd_mach_i386_i386_intel_syntax
3610 || info
->mach
== bfd_mach_x86_64_intel_syntax
);
3612 if (info
->mach
== bfd_mach_i386_i386
3613 || info
->mach
== bfd_mach_x86_64
3614 || info
->mach
== bfd_mach_i386_i386_intel_syntax
3615 || info
->mach
== bfd_mach_x86_64_intel_syntax
)
3616 priv
.orig_sizeflag
= AFLAG
| DFLAG
;
3617 else if (info
->mach
== bfd_mach_i386_i8086
)
3618 priv
.orig_sizeflag
= 0;
3622 for (p
= info
->disassembler_options
; p
!= NULL
; )
3624 if (strncmp (p
, "x86-64", 6) == 0)
3626 address_mode
= mode_64bit
;
3627 priv
.orig_sizeflag
= AFLAG
| DFLAG
;
3629 else if (strncmp (p
, "i386", 4) == 0)
3631 address_mode
= mode_32bit
;
3632 priv
.orig_sizeflag
= AFLAG
| DFLAG
;
3634 else if (strncmp (p
, "i8086", 5) == 0)
3636 address_mode
= mode_16bit
;
3637 priv
.orig_sizeflag
= 0;
3639 else if (strncmp (p
, "intel", 5) == 0)
3643 else if (strncmp (p
, "att", 3) == 0)
3647 else if (strncmp (p
, "addr", 4) == 0)
3649 if (address_mode
== mode_64bit
)
3651 if (p
[4] == '3' && p
[5] == '2')
3652 priv
.orig_sizeflag
&= ~AFLAG
;
3653 else if (p
[4] == '6' && p
[5] == '4')
3654 priv
.orig_sizeflag
|= AFLAG
;
3658 if (p
[4] == '1' && p
[5] == '6')
3659 priv
.orig_sizeflag
&= ~AFLAG
;
3660 else if (p
[4] == '3' && p
[5] == '2')
3661 priv
.orig_sizeflag
|= AFLAG
;
3664 else if (strncmp (p
, "data", 4) == 0)
3666 if (p
[4] == '1' && p
[5] == '6')
3667 priv
.orig_sizeflag
&= ~DFLAG
;
3668 else if (p
[4] == '3' && p
[5] == '2')
3669 priv
.orig_sizeflag
|= DFLAG
;
3671 else if (strncmp (p
, "suffix", 6) == 0)
3672 priv
.orig_sizeflag
|= SUFFIX_ALWAYS
;
3674 p
= strchr (p
, ',');
3681 names64
= intel_names64
;
3682 names32
= intel_names32
;
3683 names16
= intel_names16
;
3684 names8
= intel_names8
;
3685 names8rex
= intel_names8rex
;
3686 names_seg
= intel_names_seg
;
3687 index16
= intel_index16
;
3690 separator_char
= '+';
3695 names64
= att_names64
;
3696 names32
= att_names32
;
3697 names16
= att_names16
;
3698 names8
= att_names8
;
3699 names8rex
= att_names8rex
;
3700 names_seg
= att_names_seg
;
3701 index16
= att_index16
;
3704 separator_char
= ',';
3708 /* The output looks better if we put 7 bytes on a line, since that
3709 puts most long word instructions on a single line. */
3710 info
->bytes_per_line
= 7;
3712 info
->private_data
= &priv
;
3713 priv
.max_fetched
= priv
.the_buffer
;
3714 priv
.insn_start
= pc
;
3717 for (i
= 0; i
< MAX_OPERANDS
; ++i
)
3725 start_codep
= priv
.the_buffer
;
3726 codep
= priv
.the_buffer
;
3728 if (sigsetjmp(priv
.bailout
, 0) != 0)
3732 /* Getting here means we tried for data but didn't get it. That
3733 means we have an incomplete instruction of some sort. Just
3734 print the first byte as a prefix or a .byte pseudo-op. */
3735 if (codep
> priv
.the_buffer
)
3737 name
= prefix_name (priv
.the_buffer
[0], priv
.orig_sizeflag
);
3739 (*info
->fprintf_func
) (info
->stream
, "%s", name
);
3742 /* Just print the first byte as a .byte instruction. */
3743 (*info
->fprintf_func
) (info
->stream
, ".byte 0x%x",
3744 (unsigned int) priv
.the_buffer
[0]);
3757 sizeflag
= priv
.orig_sizeflag
;
3759 fetch_data(info
, codep
+ 1);
3760 two_source_ops
= (*codep
== 0x62) || (*codep
== 0xc8);
3762 if (((prefixes
& PREFIX_FWAIT
)
3763 && ((*codep
< 0xd8) || (*codep
> 0xdf)))
3764 || (rex
&& rex_used
))
3768 /* fwait not followed by floating point instruction, or rex followed
3769 by other prefixes. Print the first prefix. */
3770 name
= prefix_name (priv
.the_buffer
[0], priv
.orig_sizeflag
);
3772 name
= INTERNAL_DISASSEMBLER_ERROR
;
3773 (*info
->fprintf_func
) (info
->stream
, "%s", name
);
3780 unsigned char threebyte
;
3781 fetch_data(info
, codep
+ 2);
3782 threebyte
= *++codep
;
3783 dp
= &dis386_twobyte
[threebyte
];
3784 need_modrm
= twobyte_has_modrm
[*codep
];
3785 uses_DATA_prefix
= twobyte_uses_DATA_prefix
[*codep
];
3786 uses_REPNZ_prefix
= twobyte_uses_REPNZ_prefix
[*codep
];
3787 uses_REPZ_prefix
= twobyte_uses_REPZ_prefix
[*codep
];
3788 uses_LOCK_prefix
= (*codep
& ~0x02) == 0x20;
3790 if (dp
->name
== NULL
&& dp
->op
[0].bytemode
== IS_3BYTE_OPCODE
)
3792 fetch_data(info
, codep
+ 2);
3797 uses_DATA_prefix
= threebyte_0x38_uses_DATA_prefix
[op
];
3798 uses_REPNZ_prefix
= threebyte_0x38_uses_REPNZ_prefix
[op
];
3799 uses_REPZ_prefix
= threebyte_0x38_uses_REPZ_prefix
[op
];
3802 uses_DATA_prefix
= threebyte_0x3a_uses_DATA_prefix
[op
];
3803 uses_REPNZ_prefix
= threebyte_0x3a_uses_REPNZ_prefix
[op
];
3804 uses_REPZ_prefix
= threebyte_0x3a_uses_REPZ_prefix
[op
];
3813 dp
= &dis386
[*codep
];
3814 need_modrm
= onebyte_has_modrm
[*codep
];
3815 uses_DATA_prefix
= 0;
3816 uses_REPNZ_prefix
= 0;
3817 /* pause is 0xf3 0x90. */
3818 uses_REPZ_prefix
= *codep
== 0x90;
3819 uses_LOCK_prefix
= 0;
3823 if (!uses_REPZ_prefix
&& (prefixes
& PREFIX_REPZ
))
3826 used_prefixes
|= PREFIX_REPZ
;
3828 if (!uses_REPNZ_prefix
&& (prefixes
& PREFIX_REPNZ
))
3831 used_prefixes
|= PREFIX_REPNZ
;
3834 if (!uses_LOCK_prefix
&& (prefixes
& PREFIX_LOCK
))
3837 used_prefixes
|= PREFIX_LOCK
;
3840 if (prefixes
& PREFIX_ADDR
)
3843 if (dp
->op
[2].bytemode
!= loop_jcxz_mode
|| intel_syntax
)
3845 if ((sizeflag
& AFLAG
) || address_mode
== mode_64bit
)
3846 oappend ("addr32 ");
3848 oappend ("addr16 ");
3849 used_prefixes
|= PREFIX_ADDR
;
3853 if (!uses_DATA_prefix
&& (prefixes
& PREFIX_DATA
))
3856 if (dp
->op
[2].bytemode
== cond_jump_mode
3857 && dp
->op
[0].bytemode
== v_mode
3860 if (sizeflag
& DFLAG
)
3861 oappend ("data32 ");
3863 oappend ("data16 ");
3864 used_prefixes
|= PREFIX_DATA
;
3868 if (dp
->name
== NULL
&& dp
->op
[0].bytemode
== IS_3BYTE_OPCODE
)
3870 dp
= &three_byte_table
[dp
->op
[1].bytemode
][op
];
3871 modrm
.mod
= (*codep
>> 6) & 3;
3872 modrm
.reg
= (*codep
>> 3) & 7;
3873 modrm
.rm
= *codep
& 7;
3875 else if (need_modrm
)
3877 fetch_data(info
, codep
+ 1);
3878 modrm
.mod
= (*codep
>> 6) & 3;
3879 modrm
.reg
= (*codep
>> 3) & 7;
3880 modrm
.rm
= *codep
& 7;
3883 if (dp
->name
== NULL
&& dp
->op
[0].bytemode
== FLOATCODE
)
3890 if (dp
->name
== NULL
)
3892 switch (dp
->op
[0].bytemode
)
3895 dp
= &grps
[dp
->op
[1].bytemode
][modrm
.reg
];
3898 case USE_PREFIX_USER_TABLE
:
3900 used_prefixes
|= (prefixes
& PREFIX_REPZ
);
3901 if (prefixes
& PREFIX_REPZ
)
3905 /* We should check PREFIX_REPNZ and PREFIX_REPZ
3906 before PREFIX_DATA. */
3907 used_prefixes
|= (prefixes
& PREFIX_REPNZ
);
3908 if (prefixes
& PREFIX_REPNZ
)
3912 used_prefixes
|= (prefixes
& PREFIX_DATA
);
3913 if (prefixes
& PREFIX_DATA
)
3917 dp
= &prefix_user_table
[dp
->op
[1].bytemode
][index
];
3920 case X86_64_SPECIAL
:
3921 index
= address_mode
== mode_64bit
? 1 : 0;
3922 dp
= &x86_64_table
[dp
->op
[1].bytemode
][index
];
3926 oappend (INTERNAL_DISASSEMBLER_ERROR
);
3931 if (putop (dp
->name
, sizeflag
) == 0)
3933 for (i
= 0; i
< MAX_OPERANDS
; ++i
)
3936 op_ad
= MAX_OPERANDS
- 1 - i
;
3938 (*dp
->op
[i
].rtn
) (dp
->op
[i
].bytemode
, sizeflag
);
3943 /* See if any prefixes were not used. If so, print the first one
3944 separately. If we don't do this, we'll wind up printing an
3945 instruction stream which does not precisely correspond to the
3946 bytes we are disassembling. */
3947 if ((prefixes
& ~used_prefixes
) != 0)
3951 name
= prefix_name (priv
.the_buffer
[0], priv
.orig_sizeflag
);
3953 name
= INTERNAL_DISASSEMBLER_ERROR
;
3954 (*info
->fprintf_func
) (info
->stream
, "%s", name
);
3957 if (rex
& ~rex_used
)
3960 name
= prefix_name (rex
| 0x40, priv
.orig_sizeflag
);
3962 name
= INTERNAL_DISASSEMBLER_ERROR
;
3963 (*info
->fprintf_func
) (info
->stream
, "%s ", name
);
3966 obufp
= obuf
+ strlen (obuf
);
3967 for (i
= strlen (obuf
); i
< 6; i
++)
3970 (*info
->fprintf_func
) (info
->stream
, "%s", obuf
);
3972 /* The enter and bound instructions are printed with operands in the same
3973 order as the intel book; everything else is printed in reverse order. */
3974 if (intel_syntax
|| two_source_ops
)
3978 for (i
= 0; i
< MAX_OPERANDS
; ++i
)
3979 op_txt
[i
] = op_out
[i
];
3981 for (i
= 0; i
< (MAX_OPERANDS
>> 1); ++i
)
3983 op_ad
= op_index
[i
];
3984 op_index
[i
] = op_index
[MAX_OPERANDS
- 1 - i
];
3985 op_index
[MAX_OPERANDS
- 1 - i
] = op_ad
;
3986 riprel
= op_riprel
[i
];
3987 op_riprel
[i
] = op_riprel
[MAX_OPERANDS
- 1 - i
];
3988 op_riprel
[MAX_OPERANDS
- 1 - i
] = riprel
;
3993 for (i
= 0; i
< MAX_OPERANDS
; ++i
)
3994 op_txt
[MAX_OPERANDS
- 1 - i
] = op_out
[i
];
3998 for (i
= 0; i
< MAX_OPERANDS
; ++i
)
4002 (*info
->fprintf_func
) (info
->stream
, ",");
4003 if (op_index
[i
] != -1 && !op_riprel
[i
])
4004 (*info
->print_address_func
) ((bfd_vma
) op_address
[op_index
[i
]], info
);
4006 (*info
->fprintf_func
) (info
->stream
, "%s", op_txt
[i
]);
4010 for (i
= 0; i
< MAX_OPERANDS
; i
++)
4011 if (op_index
[i
] != -1 && op_riprel
[i
])
4013 (*info
->fprintf_func
) (info
->stream
, " # ");
4014 (*info
->print_address_func
) ((bfd_vma
) (start_pc
+ codep
- start_codep
4015 + op_address
[op_index
[i
]]), info
);
4018 return codep
- priv
.the_buffer
;
4021 static const char *float_mem
[] = {
4096 static const unsigned char float_mem_mode
[] = {
4171 #define ST { OP_ST, 0 }
4172 #define STi { OP_STi, 0 }
4174 #define FGRPd9_2 NULL, { { NULL, 0 } }
4175 #define FGRPd9_4 NULL, { { NULL, 1 } }
4176 #define FGRPd9_5 NULL, { { NULL, 2 } }
4177 #define FGRPd9_6 NULL, { { NULL, 3 } }
4178 #define FGRPd9_7 NULL, { { NULL, 4 } }
4179 #define FGRPda_5 NULL, { { NULL, 5 } }
4180 #define FGRPdb_4 NULL, { { NULL, 6 } }
4181 #define FGRPde_3 NULL, { { NULL, 7 } }
4182 #define FGRPdf_4 NULL, { { NULL, 8 } }
4184 static const struct dis386 float_reg
[][8] = {
4187 { "fadd", { ST
, STi
} },
4188 { "fmul", { ST
, STi
} },
4189 { "fcom", { STi
} },
4190 { "fcomp", { STi
} },
4191 { "fsub", { ST
, STi
} },
4192 { "fsubr", { ST
, STi
} },
4193 { "fdiv", { ST
, STi
} },
4194 { "fdivr", { ST
, STi
} },
4199 { "fxch", { STi
} },
4201 { "(bad)", { XX
} },
4209 { "fcmovb", { ST
, STi
} },
4210 { "fcmove", { ST
, STi
} },
4211 { "fcmovbe",{ ST
, STi
} },
4212 { "fcmovu", { ST
, STi
} },
4213 { "(bad)", { XX
} },
4215 { "(bad)", { XX
} },
4216 { "(bad)", { XX
} },
4220 { "fcmovnb",{ ST
, STi
} },
4221 { "fcmovne",{ ST
, STi
} },
4222 { "fcmovnbe",{ ST
, STi
} },
4223 { "fcmovnu",{ ST
, STi
} },
4225 { "fucomi", { ST
, STi
} },
4226 { "fcomi", { ST
, STi
} },
4227 { "(bad)", { XX
} },
4231 { "fadd", { STi
, ST
} },
4232 { "fmul", { STi
, ST
} },
4233 { "(bad)", { XX
} },
4234 { "(bad)", { XX
} },
4236 { "fsub", { STi
, ST
} },
4237 { "fsubr", { STi
, ST
} },
4238 { "fdiv", { STi
, ST
} },
4239 { "fdivr", { STi
, ST
} },
4241 { "fsubr", { STi
, ST
} },
4242 { "fsub", { STi
, ST
} },
4243 { "fdivr", { STi
, ST
} },
4244 { "fdiv", { STi
, ST
} },
4249 { "ffree", { STi
} },
4250 { "(bad)", { XX
} },
4252 { "fstp", { STi
} },
4253 { "fucom", { STi
} },
4254 { "fucomp", { STi
} },
4255 { "(bad)", { XX
} },
4256 { "(bad)", { XX
} },
4260 { "faddp", { STi
, ST
} },
4261 { "fmulp", { STi
, ST
} },
4262 { "(bad)", { XX
} },
4265 { "fsubp", { STi
, ST
} },
4266 { "fsubrp", { STi
, ST
} },
4267 { "fdivp", { STi
, ST
} },
4268 { "fdivrp", { STi
, ST
} },
4270 { "fsubrp", { STi
, ST
} },
4271 { "fsubp", { STi
, ST
} },
4272 { "fdivrp", { STi
, ST
} },
4273 { "fdivp", { STi
, ST
} },
4278 { "ffreep", { STi
} },
4279 { "(bad)", { XX
} },
4280 { "(bad)", { XX
} },
4281 { "(bad)", { XX
} },
4283 { "fucomip", { ST
, STi
} },
4284 { "fcomip", { ST
, STi
} },
4285 { "(bad)", { XX
} },
4289 static const char *fgrps
[][8] = {
4292 "fnop","(bad)","(bad)","(bad)","(bad)","(bad)","(bad)","(bad)",
4297 "fchs","fabs","(bad)","(bad)","ftst","fxam","(bad)","(bad)",
4302 "fld1","fldl2t","fldl2e","fldpi","fldlg2","fldln2","fldz","(bad)",
4307 "f2xm1","fyl2x","fptan","fpatan","fxtract","fprem1","fdecstp","fincstp",
4312 "fprem","fyl2xp1","fsqrt","fsincos","frndint","fscale","fsin","fcos",
4317 "(bad)","fucompp","(bad)","(bad)","(bad)","(bad)","(bad)","(bad)",
4322 "feni(287 only)","fdisi(287 only)","fNclex","fNinit",
4323 "fNsetpm(287 only)","(bad)","(bad)","(bad)",
4328 "(bad)","fcompp","(bad)","(bad)","(bad)","(bad)","(bad)","(bad)",
4333 "fNstsw","(bad)","(bad)","(bad)","(bad)","(bad)","(bad)","(bad)",
4338 dofloat (int sizeflag
)
4340 const struct dis386
*dp
;
4341 unsigned char floatop
;
4343 floatop
= codep
[-1];
4347 int fp_indx
= (floatop
- 0xd8) * 8 + modrm
.reg
;
4349 putop (float_mem
[fp_indx
], sizeflag
);
4352 OP_E (float_mem_mode
[fp_indx
], sizeflag
);
4355 /* Skip mod/rm byte. */
4359 dp
= &float_reg
[floatop
- 0xd8][modrm
.reg
];
4360 if (dp
->name
== NULL
)
4362 putop (fgrps
[dp
->op
[0].bytemode
][modrm
.rm
], sizeflag
);
4364 /* Instruction fnstsw is only one with strange arg. */
4365 if (floatop
== 0xdf && codep
[-1] == 0xe0)
4366 pstrcpy (op_out
[0], sizeof(op_out
[0]), names16
[0]);
4370 putop (dp
->name
, sizeflag
);
4375 (*dp
->op
[0].rtn
) (dp
->op
[0].bytemode
, sizeflag
);
4380 (*dp
->op
[1].rtn
) (dp
->op
[1].bytemode
, sizeflag
);
4385 OP_ST (int bytemode ATTRIBUTE_UNUSED
, int sizeflag ATTRIBUTE_UNUSED
)
4387 oappend ("%st" + intel_syntax
);
4391 OP_STi (int bytemode ATTRIBUTE_UNUSED
, int sizeflag ATTRIBUTE_UNUSED
)
4393 snprintf (scratchbuf
, sizeof(scratchbuf
), "%%st(%d)", modrm
.rm
);
4394 oappend (scratchbuf
+ intel_syntax
);
4397 /* Capital letters in template are macros. */
4399 putop (const char *template, int sizeflag
)
4404 for (p
= template; *p
; p
++)
4415 if (address_mode
== mode_64bit
)
4423 /* Alternative not valid. */
4424 pstrcpy (obuf
, sizeof(obuf
), "(bad)");
4428 else if (*p
== '\0')
4449 if (modrm
.mod
!= 3 || (sizeflag
& SUFFIX_ALWAYS
))
4455 if (sizeflag
& SUFFIX_ALWAYS
)
4459 if (intel_syntax
&& !alt
)
4461 if ((prefixes
& PREFIX_DATA
) || (sizeflag
& SUFFIX_ALWAYS
))
4463 if (sizeflag
& DFLAG
)
4464 *obufp
++ = intel_syntax
? 'd' : 'l';
4466 *obufp
++ = intel_syntax
? 'w' : 's';
4467 used_prefixes
|= (prefixes
& PREFIX_DATA
);
4471 if (intel_syntax
|| !(sizeflag
& SUFFIX_ALWAYS
))
4478 else if (sizeflag
& DFLAG
)
4479 *obufp
++ = intel_syntax
? 'd' : 'l';
4482 used_prefixes
|= (prefixes
& PREFIX_DATA
);
4487 case 'E': /* For jcxz/jecxz */
4488 if (address_mode
== mode_64bit
)
4490 if (sizeflag
& AFLAG
)
4496 if (sizeflag
& AFLAG
)
4498 used_prefixes
|= (prefixes
& PREFIX_ADDR
);
4503 if ((prefixes
& PREFIX_ADDR
) || (sizeflag
& SUFFIX_ALWAYS
))
4505 if (sizeflag
& AFLAG
)
4506 *obufp
++ = address_mode
== mode_64bit
? 'q' : 'l';
4508 *obufp
++ = address_mode
== mode_64bit
? 'l' : 'w';
4509 used_prefixes
|= (prefixes
& PREFIX_ADDR
);
4513 if (intel_syntax
|| (obufp
[-1] != 's' && !(sizeflag
& SUFFIX_ALWAYS
)))
4515 if ((rex
& REX_W
) || (sizeflag
& DFLAG
))
4520 used_prefixes
|= (prefixes
& PREFIX_DATA
);
4525 if ((prefixes
& (PREFIX_CS
| PREFIX_DS
)) == PREFIX_CS
4526 || (prefixes
& (PREFIX_CS
| PREFIX_DS
)) == PREFIX_DS
)
4528 used_prefixes
|= prefixes
& (PREFIX_CS
| PREFIX_DS
);
4531 if (prefixes
& PREFIX_DS
)
4552 if (address_mode
== mode_64bit
&& (sizeflag
& SUFFIX_ALWAYS
))
4561 if (sizeflag
& SUFFIX_ALWAYS
)
4565 if ((prefixes
& PREFIX_FWAIT
) == 0)
4568 used_prefixes
|= PREFIX_FWAIT
;
4574 else if (intel_syntax
&& (sizeflag
& DFLAG
))
4579 used_prefixes
|= (prefixes
& PREFIX_DATA
);
4584 if (address_mode
== mode_64bit
&& (sizeflag
& DFLAG
))
4593 if ((prefixes
& PREFIX_DATA
)
4595 || (sizeflag
& SUFFIX_ALWAYS
))
4602 if (sizeflag
& DFLAG
)
4607 used_prefixes
|= (prefixes
& PREFIX_DATA
);
4613 if (address_mode
== mode_64bit
&& (sizeflag
& DFLAG
))
4615 if (modrm
.mod
!= 3 || (sizeflag
& SUFFIX_ALWAYS
))
4621 if (intel_syntax
&& !alt
)
4624 if (modrm
.mod
!= 3 || (sizeflag
& SUFFIX_ALWAYS
))
4630 if (sizeflag
& DFLAG
)
4631 *obufp
++ = intel_syntax
? 'd' : 'l';
4635 used_prefixes
|= (prefixes
& PREFIX_DATA
);
4642 else if (sizeflag
& DFLAG
)
4651 if (intel_syntax
&& !p
[1]
4652 && ((rex
& REX_W
) || (sizeflag
& DFLAG
)))
4655 used_prefixes
|= (prefixes
& PREFIX_DATA
);
4660 if (address_mode
== mode_64bit
&& (sizeflag
& DFLAG
))
4662 if (sizeflag
& SUFFIX_ALWAYS
)
4670 if (sizeflag
& SUFFIX_ALWAYS
)
4676 if (sizeflag
& DFLAG
)
4680 used_prefixes
|= (prefixes
& PREFIX_DATA
);
4685 if (prefixes
& PREFIX_DATA
)
4689 used_prefixes
|= (prefixes
& PREFIX_DATA
);
4700 /* implicit operand size 'l' for i386 or 'q' for x86-64 */
4702 /* operand size flag for cwtl, cbtw */
4711 else if (sizeflag
& DFLAG
)
4716 used_prefixes
|= (prefixes
& PREFIX_DATA
);
4726 oappend (const char *s
)
4729 obufp
+= strlen (s
);
4735 if (prefixes
& PREFIX_CS
)
4737 used_prefixes
|= PREFIX_CS
;
4738 oappend ("%cs:" + intel_syntax
);
4740 if (prefixes
& PREFIX_DS
)
4742 used_prefixes
|= PREFIX_DS
;
4743 oappend ("%ds:" + intel_syntax
);
4745 if (prefixes
& PREFIX_SS
)
4747 used_prefixes
|= PREFIX_SS
;
4748 oappend ("%ss:" + intel_syntax
);
4750 if (prefixes
& PREFIX_ES
)
4752 used_prefixes
|= PREFIX_ES
;
4753 oappend ("%es:" + intel_syntax
);
4755 if (prefixes
& PREFIX_FS
)
4757 used_prefixes
|= PREFIX_FS
;
4758 oappend ("%fs:" + intel_syntax
);
4760 if (prefixes
& PREFIX_GS
)
4762 used_prefixes
|= PREFIX_GS
;
4763 oappend ("%gs:" + intel_syntax
);
4768 OP_indirE (int bytemode
, int sizeflag
)
4772 OP_E (bytemode
, sizeflag
);
4776 print_operand_value (char *buf
, size_t bufsize
, int hex
, bfd_vma disp
)
4778 if (address_mode
== mode_64bit
)
4786 snprintf_vma (tmp
, sizeof(tmp
), disp
);
4787 for (i
= 0; tmp
[i
] == '0' && tmp
[i
+ 1]; i
++) {
4789 pstrcpy (buf
+ 2, bufsize
- 2, tmp
+ i
);
4793 bfd_signed_vma v
= disp
;
4800 /* Check for possible overflow on 0x8000000000000000. */
4803 pstrcpy (buf
, bufsize
, "9223372036854775808");
4809 pstrcpy (buf
, bufsize
, "0");
4817 tmp
[28 - i
] = (v
% 10) + '0';
4821 pstrcpy (buf
, bufsize
, tmp
+ 29 - i
);
4827 snprintf (buf
, bufsize
, "0x%x", (unsigned int) disp
);
4829 snprintf (buf
, bufsize
, "%d", (int) disp
);
4833 /* Put DISP in BUF as signed hex number. */
4836 print_displacement (char *buf
, bfd_vma disp
)
4838 bfd_signed_vma val
= disp
;
4847 /* Check for possible overflow. */
4850 switch (address_mode
)
4853 strcpy (buf
+ j
, "0x8000000000000000");
4856 strcpy (buf
+ j
, "0x80000000");
4859 strcpy (buf
+ j
, "0x8000");
4869 snprintf_vma (tmp
, sizeof(tmp
), val
);
4870 for (i
= 0; tmp
[i
] == '0'; i
++)
4874 strcpy (buf
+ j
, tmp
+ i
);
4878 intel_operand_size (int bytemode
, int sizeflag
)
4884 oappend ("BYTE PTR ");
4888 oappend ("WORD PTR ");
4891 if (address_mode
== mode_64bit
&& (sizeflag
& DFLAG
))
4893 oappend ("QWORD PTR ");
4894 used_prefixes
|= (prefixes
& PREFIX_DATA
);
4902 oappend ("QWORD PTR ");
4903 else if ((sizeflag
& DFLAG
) || bytemode
== dq_mode
)
4904 oappend ("DWORD PTR ");
4906 oappend ("WORD PTR ");
4907 used_prefixes
|= (prefixes
& PREFIX_DATA
);
4910 if ((rex
& REX_W
) || (sizeflag
& DFLAG
))
4912 oappend ("WORD PTR ");
4914 used_prefixes
|= (prefixes
& PREFIX_DATA
);
4918 oappend ("DWORD PTR ");
4921 oappend ("QWORD PTR ");
4924 if (address_mode
== mode_64bit
)
4925 oappend ("QWORD PTR ");
4927 oappend ("DWORD PTR ");
4930 if (sizeflag
& DFLAG
)
4931 oappend ("FWORD PTR ");
4933 oappend ("DWORD PTR ");
4934 used_prefixes
|= (prefixes
& PREFIX_DATA
);
4937 oappend ("TBYTE PTR ");
4940 oappend ("XMMWORD PTR ");
4943 oappend ("OWORD PTR ");
4951 OP_E (int bytemode
, int sizeflag
)
4960 /* Skip mod/rm byte. */
4971 oappend (names8rex
[modrm
.rm
+ add
]);
4973 oappend (names8
[modrm
.rm
+ add
]);
4976 oappend (names16
[modrm
.rm
+ add
]);
4979 oappend (names32
[modrm
.rm
+ add
]);
4982 oappend (names64
[modrm
.rm
+ add
]);
4985 if (address_mode
== mode_64bit
)
4986 oappend (names64
[modrm
.rm
+ add
]);
4988 oappend (names32
[modrm
.rm
+ add
]);
4991 if (address_mode
== mode_64bit
&& (sizeflag
& DFLAG
))
4993 oappend (names64
[modrm
.rm
+ add
]);
4994 used_prefixes
|= (prefixes
& PREFIX_DATA
);
5006 oappend (names64
[modrm
.rm
+ add
]);
5007 else if ((sizeflag
& DFLAG
) || bytemode
!= v_mode
)
5008 oappend (names32
[modrm
.rm
+ add
]);
5010 oappend (names16
[modrm
.rm
+ add
]);
5011 used_prefixes
|= (prefixes
& PREFIX_DATA
);
5016 oappend (INTERNAL_DISASSEMBLER_ERROR
);
5024 intel_operand_size (bytemode
, sizeflag
);
5027 if ((sizeflag
& AFLAG
) || address_mode
== mode_64bit
)
5029 /* 32/64 bit address mode */
5044 fetch_data(the_info
, codep
+ 1);
5045 index
= (*codep
>> 3) & 7;
5046 if (address_mode
== mode_64bit
|| index
!= 0x4)
5047 /* When INDEX == 0x4 in 32 bit mode, SCALE is ignored. */
5048 scale
= (*codep
>> 6) & 3;
5060 if ((base
& 7) == 5)
5063 if (address_mode
== mode_64bit
&& !havesib
)
5069 fetch_data (the_info
, codep
+ 1);
5071 if ((disp
& 0x80) != 0)
5079 havedisp
= havebase
|| (havesib
&& (index
!= 4 || scale
!= 0));
5082 if (modrm
.mod
!= 0 || (base
& 7) == 5)
5084 if (havedisp
|| riprel
)
5085 print_displacement (scratchbuf
, disp
);
5087 print_operand_value (scratchbuf
, sizeof(scratchbuf
), 1, disp
);
5088 oappend (scratchbuf
);
5096 if (havedisp
|| (intel_syntax
&& riprel
))
5098 *obufp
++ = open_char
;
5099 if (intel_syntax
&& riprel
)
5106 oappend (address_mode
== mode_64bit
&& (sizeflag
& AFLAG
)
5107 ? names64
[base
] : names32
[base
]);
5112 if (!intel_syntax
|| havebase
)
5114 *obufp
++ = separator_char
;
5117 oappend (address_mode
== mode_64bit
&& (sizeflag
& AFLAG
)
5118 ? names64
[index
] : names32
[index
]);
5120 if (scale
!= 0 || (!intel_syntax
&& index
!= 4))
5122 *obufp
++ = scale_char
;
5124 snprintf (scratchbuf
, sizeof(scratchbuf
), "%d", 1 << scale
);
5125 oappend (scratchbuf
);
5129 && (disp
|| modrm
.mod
!= 0 || (base
& 7) == 5))
5131 if ((bfd_signed_vma
) disp
>= 0)
5136 else if (modrm
.mod
!= 1)
5140 disp
= - (bfd_signed_vma
) disp
;
5143 print_displacement (scratchbuf
, disp
);
5144 oappend (scratchbuf
);
5147 *obufp
++ = close_char
;
5150 else if (intel_syntax
)
5152 if (modrm
.mod
!= 0 || (base
& 7) == 5)
5154 if (prefixes
& (PREFIX_CS
| PREFIX_SS
| PREFIX_DS
5155 | PREFIX_ES
| PREFIX_FS
| PREFIX_GS
))
5159 oappend (names_seg
[ds_reg
- es_reg
]);
5162 print_operand_value (scratchbuf
, sizeof(scratchbuf
), 1, disp
);
5163 oappend (scratchbuf
);
5168 { /* 16 bit address mode */
5175 if ((disp
& 0x8000) != 0)
5180 fetch_data(the_info
, codep
+ 1);
5182 if ((disp
& 0x80) != 0)
5187 if ((disp
& 0x8000) != 0)
5193 if (modrm
.mod
!= 0 || modrm
.rm
== 6)
5195 print_displacement (scratchbuf
, disp
);
5196 oappend (scratchbuf
);
5199 if (modrm
.mod
!= 0 || modrm
.rm
!= 6)
5201 *obufp
++ = open_char
;
5203 oappend (index16
[modrm
.rm
]);
5205 && (disp
|| modrm
.mod
!= 0 || modrm
.rm
== 6))
5207 if ((bfd_signed_vma
) disp
>= 0)
5212 else if (modrm
.mod
!= 1)
5216 disp
= - (bfd_signed_vma
) disp
;
5219 print_displacement (scratchbuf
, disp
);
5220 oappend (scratchbuf
);
5223 *obufp
++ = close_char
;
5226 else if (intel_syntax
)
5228 if (prefixes
& (PREFIX_CS
| PREFIX_SS
| PREFIX_DS
5229 | PREFIX_ES
| PREFIX_FS
| PREFIX_GS
))
5233 oappend (names_seg
[ds_reg
- es_reg
]);
5236 print_operand_value (scratchbuf
, sizeof(scratchbuf
), 1,
5238 oappend (scratchbuf
);
5244 OP_G (int bytemode
, int sizeflag
)
5255 oappend (names8rex
[modrm
.reg
+ add
]);
5257 oappend (names8
[modrm
.reg
+ add
]);
5260 oappend (names16
[modrm
.reg
+ add
]);
5263 oappend (names32
[modrm
.reg
+ add
]);
5266 oappend (names64
[modrm
.reg
+ add
]);
5275 oappend (names64
[modrm
.reg
+ add
]);
5276 else if ((sizeflag
& DFLAG
) || bytemode
!= v_mode
)
5277 oappend (names32
[modrm
.reg
+ add
]);
5279 oappend (names16
[modrm
.reg
+ add
]);
5280 used_prefixes
|= (prefixes
& PREFIX_DATA
);
5283 if (address_mode
== mode_64bit
)
5284 oappend (names64
[modrm
.reg
+ add
]);
5286 oappend (names32
[modrm
.reg
+ add
]);
5289 oappend (INTERNAL_DISASSEMBLER_ERROR
);
5302 fetch_data(the_info
, codep
+ 8);
5303 a
= *codep
++ & 0xff;
5304 a
|= (*codep
++ & 0xff) << 8;
5305 a
|= (*codep
++ & 0xff) << 16;
5306 a
|= (*codep
++ & 0xff) << 24;
5307 b
= *codep
++ & 0xff;
5308 b
|= (*codep
++ & 0xff) << 8;
5309 b
|= (*codep
++ & 0xff) << 16;
5310 b
|= (*codep
++ & 0xff) << 24;
5311 x
= a
+ ((bfd_vma
) b
<< 32);
5319 static bfd_signed_vma
5322 bfd_signed_vma x
= 0;
5324 fetch_data(the_info
, codep
+ 4);
5325 x
= *codep
++ & (bfd_signed_vma
) 0xff;
5326 x
|= (*codep
++ & (bfd_signed_vma
) 0xff) << 8;
5327 x
|= (*codep
++ & (bfd_signed_vma
) 0xff) << 16;
5328 x
|= (*codep
++ & (bfd_signed_vma
) 0xff) << 24;
5332 static bfd_signed_vma
5335 bfd_signed_vma x
= 0;
5337 fetch_data(the_info
, codep
+ 4);
5338 x
= *codep
++ & (bfd_signed_vma
) 0xff;
5339 x
|= (*codep
++ & (bfd_signed_vma
) 0xff) << 8;
5340 x
|= (*codep
++ & (bfd_signed_vma
) 0xff) << 16;
5341 x
|= (*codep
++ & (bfd_signed_vma
) 0xff) << 24;
5343 x
= (x
^ ((bfd_signed_vma
) 1 << 31)) - ((bfd_signed_vma
) 1 << 31);
5353 fetch_data(the_info
, codep
+ 2);
5354 x
= *codep
++ & 0xff;
5355 x
|= (*codep
++ & 0xff) << 8;
5360 set_op (bfd_vma op
, int riprel
)
5362 op_index
[op_ad
] = op_ad
;
5363 if (address_mode
== mode_64bit
)
5365 op_address
[op_ad
] = op
;
5366 op_riprel
[op_ad
] = riprel
;
5370 /* Mask to get a 32-bit address. */
5371 op_address
[op_ad
] = op
& 0xffffffff;
5372 op_riprel
[op_ad
] = riprel
& 0xffffffff;
5377 OP_REG (int code
, int sizeflag
)
5387 case ax_reg
: case cx_reg
: case dx_reg
: case bx_reg
:
5388 case sp_reg
: case bp_reg
: case si_reg
: case di_reg
:
5389 s
= names16
[code
- ax_reg
+ add
];
5391 case es_reg
: case ss_reg
: case cs_reg
:
5392 case ds_reg
: case fs_reg
: case gs_reg
:
5393 s
= names_seg
[code
- es_reg
+ add
];
5395 case al_reg
: case ah_reg
: case cl_reg
: case ch_reg
:
5396 case dl_reg
: case dh_reg
: case bl_reg
: case bh_reg
:
5399 s
= names8rex
[code
- al_reg
+ add
];
5401 s
= names8
[code
- al_reg
];
5403 case rAX_reg
: case rCX_reg
: case rDX_reg
: case rBX_reg
:
5404 case rSP_reg
: case rBP_reg
: case rSI_reg
: case rDI_reg
:
5405 if (address_mode
== mode_64bit
&& (sizeflag
& DFLAG
))
5407 s
= names64
[code
- rAX_reg
+ add
];
5410 code
+= eAX_reg
- rAX_reg
;
5412 case eAX_reg
: case eCX_reg
: case eDX_reg
: case eBX_reg
:
5413 case eSP_reg
: case eBP_reg
: case eSI_reg
: case eDI_reg
:
5416 s
= names64
[code
- eAX_reg
+ add
];
5417 else if (sizeflag
& DFLAG
)
5418 s
= names32
[code
- eAX_reg
+ add
];
5420 s
= names16
[code
- eAX_reg
+ add
];
5421 used_prefixes
|= (prefixes
& PREFIX_DATA
);
5424 s
= INTERNAL_DISASSEMBLER_ERROR
;
5431 OP_IMREG (int code
, int sizeflag
)
5443 case ax_reg
: case cx_reg
: case dx_reg
: case bx_reg
:
5444 case sp_reg
: case bp_reg
: case si_reg
: case di_reg
:
5445 s
= names16
[code
- ax_reg
];
5447 case es_reg
: case ss_reg
: case cs_reg
:
5448 case ds_reg
: case fs_reg
: case gs_reg
:
5449 s
= names_seg
[code
- es_reg
];
5451 case al_reg
: case ah_reg
: case cl_reg
: case ch_reg
:
5452 case dl_reg
: case dh_reg
: case bl_reg
: case bh_reg
:
5455 s
= names8rex
[code
- al_reg
];
5457 s
= names8
[code
- al_reg
];
5459 case eAX_reg
: case eCX_reg
: case eDX_reg
: case eBX_reg
:
5460 case eSP_reg
: case eBP_reg
: case eSI_reg
: case eDI_reg
:
5463 s
= names64
[code
- eAX_reg
];
5464 else if (sizeflag
& DFLAG
)
5465 s
= names32
[code
- eAX_reg
];
5467 s
= names16
[code
- eAX_reg
];
5468 used_prefixes
|= (prefixes
& PREFIX_DATA
);
5471 if ((rex
& REX_W
) || (sizeflag
& DFLAG
))
5476 used_prefixes
|= (prefixes
& PREFIX_DATA
);
5479 s
= INTERNAL_DISASSEMBLER_ERROR
;
5486 OP_I (int bytemode
, int sizeflag
)
5489 bfd_signed_vma mask
= -1;
5494 fetch_data(the_info
, codep
+ 1);
5499 if (address_mode
== mode_64bit
)
5509 else if (sizeflag
& DFLAG
)
5519 used_prefixes
|= (prefixes
& PREFIX_DATA
);
5530 oappend (INTERNAL_DISASSEMBLER_ERROR
);
5535 scratchbuf
[0] = '$';
5536 print_operand_value (scratchbuf
+ 1, sizeof(scratchbuf
) - 1, 1, op
);
5537 oappend (scratchbuf
+ intel_syntax
);
5538 scratchbuf
[0] = '\0';
5542 OP_I64 (int bytemode
, int sizeflag
)
5545 bfd_signed_vma mask
= -1;
5547 if (address_mode
!= mode_64bit
)
5549 OP_I (bytemode
, sizeflag
);
5556 fetch_data(the_info
, codep
+ 1);
5564 else if (sizeflag
& DFLAG
)
5574 used_prefixes
|= (prefixes
& PREFIX_DATA
);
5581 oappend (INTERNAL_DISASSEMBLER_ERROR
);
5586 scratchbuf
[0] = '$';
5587 print_operand_value (scratchbuf
+ 1, sizeof(scratchbuf
) - 1, 1, op
);
5588 oappend (scratchbuf
+ intel_syntax
);
5589 scratchbuf
[0] = '\0';
5593 OP_sI (int bytemode
, int sizeflag
)
5600 fetch_data(the_info
, codep
+ 1);
5602 if ((op
& 0x80) != 0)
5609 else if (sizeflag
& DFLAG
)
5616 if ((op
& 0x8000) != 0)
5619 used_prefixes
|= (prefixes
& PREFIX_DATA
);
5623 if ((op
& 0x8000) != 0)
5627 oappend (INTERNAL_DISASSEMBLER_ERROR
);
5631 scratchbuf
[0] = '$';
5632 print_operand_value (scratchbuf
+ 1, sizeof(scratchbuf
) - 1, 1, op
);
5633 oappend (scratchbuf
+ intel_syntax
);
5637 OP_J (int bytemode
, int sizeflag
)
5641 bfd_vma segment
= 0;
5646 fetch_data(the_info
, codep
+ 1);
5648 if ((disp
& 0x80) != 0)
5652 if ((sizeflag
& DFLAG
) || (rex
& REX_W
))
5657 if ((disp
& 0x8000) != 0)
5659 /* In 16bit mode, address is wrapped around at 64k within
5660 the same segment. Otherwise, a data16 prefix on a jump
5661 instruction means that the pc is masked to 16 bits after
5662 the displacement is added! */
5664 if ((prefixes
& PREFIX_DATA
) == 0)
5665 segment
= ((start_pc
+ codep
- start_codep
)
5666 & ~((bfd_vma
) 0xffff));
5668 used_prefixes
|= (prefixes
& PREFIX_DATA
);
5671 oappend (INTERNAL_DISASSEMBLER_ERROR
);
5674 disp
= ((start_pc
+ codep
- start_codep
+ disp
) & mask
) | segment
;
5676 print_operand_value (scratchbuf
, sizeof(scratchbuf
), 1, disp
);
5677 oappend (scratchbuf
);
5681 OP_SEG (int bytemode
, int sizeflag
)
5683 if (bytemode
== w_mode
)
5684 oappend (names_seg
[modrm
.reg
]);
5686 OP_E (modrm
.mod
== 3 ? bytemode
: w_mode
, sizeflag
);
5690 OP_DIR (int dummy ATTRIBUTE_UNUSED
, int sizeflag
)
5694 if (sizeflag
& DFLAG
)
5704 used_prefixes
|= (prefixes
& PREFIX_DATA
);
5706 snprintf (scratchbuf
, sizeof(scratchbuf
), "0x%x:0x%x", seg
, offset
);
5708 snprintf (scratchbuf
, sizeof(scratchbuf
), "$0x%x,$0x%x", seg
, offset
);
5709 oappend (scratchbuf
);
5713 OP_OFF (int bytemode
, int sizeflag
)
5717 if (intel_syntax
&& (sizeflag
& SUFFIX_ALWAYS
))
5718 intel_operand_size (bytemode
, sizeflag
);
5721 if ((sizeflag
& AFLAG
) || address_mode
== mode_64bit
)
5728 if (!(prefixes
& (PREFIX_CS
| PREFIX_SS
| PREFIX_DS
5729 | PREFIX_ES
| PREFIX_FS
| PREFIX_GS
)))
5731 oappend (names_seg
[ds_reg
- es_reg
]);
5735 print_operand_value (scratchbuf
, sizeof(scratchbuf
), 1, off
);
5736 oappend (scratchbuf
);
5740 OP_OFF64 (int bytemode
, int sizeflag
)
5744 if (address_mode
!= mode_64bit
5745 || (prefixes
& PREFIX_ADDR
))
5747 OP_OFF (bytemode
, sizeflag
);
5751 if (intel_syntax
&& (sizeflag
& SUFFIX_ALWAYS
))
5752 intel_operand_size (bytemode
, sizeflag
);
5759 if (!(prefixes
& (PREFIX_CS
| PREFIX_SS
| PREFIX_DS
5760 | PREFIX_ES
| PREFIX_FS
| PREFIX_GS
)))
5762 oappend (names_seg
[ds_reg
- es_reg
]);
5766 print_operand_value (scratchbuf
, sizeof(scratchbuf
), 1, off
);
5767 oappend (scratchbuf
);
5771 ptr_reg (int code
, int sizeflag
)
5775 *obufp
++ = open_char
;
5776 used_prefixes
|= (prefixes
& PREFIX_ADDR
);
5777 if (address_mode
== mode_64bit
)
5779 if (!(sizeflag
& AFLAG
))
5780 s
= names32
[code
- eAX_reg
];
5782 s
= names64
[code
- eAX_reg
];
5784 else if (sizeflag
& AFLAG
)
5785 s
= names32
[code
- eAX_reg
];
5787 s
= names16
[code
- eAX_reg
];
5789 *obufp
++ = close_char
;
5794 OP_ESreg (int code
, int sizeflag
)
5800 case 0x6d: /* insw/insl */
5801 intel_operand_size (z_mode
, sizeflag
);
5803 case 0xa5: /* movsw/movsl/movsq */
5804 case 0xa7: /* cmpsw/cmpsl/cmpsq */
5805 case 0xab: /* stosw/stosl */
5806 case 0xaf: /* scasw/scasl */
5807 intel_operand_size (v_mode
, sizeflag
);
5810 intel_operand_size (b_mode
, sizeflag
);
5813 oappend ("%es:" + intel_syntax
);
5814 ptr_reg (code
, sizeflag
);
5818 OP_DSreg (int code
, int sizeflag
)
5824 case 0x6f: /* outsw/outsl */
5825 intel_operand_size (z_mode
, sizeflag
);
5827 case 0xa5: /* movsw/movsl/movsq */
5828 case 0xa7: /* cmpsw/cmpsl/cmpsq */
5829 case 0xad: /* lodsw/lodsl/lodsq */
5830 intel_operand_size (v_mode
, sizeflag
);
5833 intel_operand_size (b_mode
, sizeflag
);
5843 prefixes
|= PREFIX_DS
;
5845 ptr_reg (code
, sizeflag
);
5849 OP_C (int dummy ATTRIBUTE_UNUSED
, int sizeflag ATTRIBUTE_UNUSED
)
5857 else if (address_mode
!= mode_64bit
&& (prefixes
& PREFIX_LOCK
))
5859 used_prefixes
|= PREFIX_LOCK
;
5862 snprintf (scratchbuf
, sizeof(scratchbuf
), "%%cr%d", modrm
.reg
+ add
);
5863 oappend (scratchbuf
+ intel_syntax
);
5867 OP_D (int dummy ATTRIBUTE_UNUSED
, int sizeflag ATTRIBUTE_UNUSED
)
5874 snprintf (scratchbuf
, sizeof(scratchbuf
), "db%d", modrm
.reg
+ add
);
5876 snprintf (scratchbuf
, sizeof(scratchbuf
), "%%db%d", modrm
.reg
+ add
);
5877 oappend (scratchbuf
);
5881 OP_T (int dummy ATTRIBUTE_UNUSED
, int sizeflag ATTRIBUTE_UNUSED
)
5883 snprintf (scratchbuf
, sizeof(scratchbuf
), "%%tr%d", modrm
.reg
);
5884 oappend (scratchbuf
+ intel_syntax
);
5888 OP_R (int bytemode
, int sizeflag
)
5891 OP_E (bytemode
, sizeflag
);
5897 OP_MMX (int bytemode ATTRIBUTE_UNUSED
, int sizeflag ATTRIBUTE_UNUSED
)
5899 used_prefixes
|= (prefixes
& PREFIX_DATA
);
5900 if (prefixes
& PREFIX_DATA
)
5906 snprintf (scratchbuf
, sizeof(scratchbuf
), "%%xmm%d", modrm
.reg
+ add
);
5909 snprintf (scratchbuf
, sizeof(scratchbuf
), "%%mm%d", modrm
.reg
);
5910 oappend (scratchbuf
+ intel_syntax
);
5914 OP_XMM (int bytemode ATTRIBUTE_UNUSED
, int sizeflag ATTRIBUTE_UNUSED
)
5920 snprintf (scratchbuf
, sizeof(scratchbuf
), "%%xmm%d", modrm
.reg
+ add
);
5921 oappend (scratchbuf
+ intel_syntax
);
5925 OP_EM (int bytemode
, int sizeflag
)
5929 if (intel_syntax
&& bytemode
== v_mode
)
5931 bytemode
= (prefixes
& PREFIX_DATA
) ? x_mode
: q_mode
;
5932 used_prefixes
|= (prefixes
& PREFIX_DATA
);
5934 OP_E (bytemode
, sizeflag
);
5938 /* Skip mod/rm byte. */
5941 used_prefixes
|= (prefixes
& PREFIX_DATA
);
5942 if (prefixes
& PREFIX_DATA
)
5949 snprintf (scratchbuf
, sizeof(scratchbuf
), "%%xmm%d", modrm
.rm
+ add
);
5952 snprintf (scratchbuf
, sizeof(scratchbuf
), "%%mm%d", modrm
.rm
);
5953 oappend (scratchbuf
+ intel_syntax
);
5956 /* cvt* are the only instructions in sse2 which have
5957 both SSE and MMX operands and also have 0x66 prefix
5958 in their opcode. 0x66 was originally used to differentiate
5959 between SSE and MMX instruction(operands). So we have to handle the
5960 cvt* separately using OP_EMC and OP_MXC */
5962 OP_EMC (int bytemode
, int sizeflag
)
5966 if (intel_syntax
&& bytemode
== v_mode
)
5968 bytemode
= (prefixes
& PREFIX_DATA
) ? x_mode
: q_mode
;
5969 used_prefixes
|= (prefixes
& PREFIX_DATA
);
5971 OP_E (bytemode
, sizeflag
);
5975 /* Skip mod/rm byte. */
5978 used_prefixes
|= (prefixes
& PREFIX_DATA
);
5979 snprintf (scratchbuf
, sizeof(scratchbuf
), "%%mm%d", modrm
.rm
);
5980 oappend (scratchbuf
+ intel_syntax
);
5984 OP_MXC (int bytemode ATTRIBUTE_UNUSED
, int sizeflag ATTRIBUTE_UNUSED
)
5986 used_prefixes
|= (prefixes
& PREFIX_DATA
);
5987 snprintf (scratchbuf
, sizeof(scratchbuf
), "%%mm%d", modrm
.reg
);
5988 oappend (scratchbuf
+ intel_syntax
);
5992 OP_EX (int bytemode
, int sizeflag
)
5997 OP_E (bytemode
, sizeflag
);
6004 /* Skip mod/rm byte. */
6007 snprintf (scratchbuf
, sizeof(scratchbuf
), "%%xmm%d", modrm
.rm
+ add
);
6008 oappend (scratchbuf
+ intel_syntax
);
6012 OP_MS (int bytemode
, int sizeflag
)
6015 OP_EM (bytemode
, sizeflag
);
6021 OP_XS (int bytemode
, int sizeflag
)
6024 OP_EX (bytemode
, sizeflag
);
6030 OP_M (int bytemode
, int sizeflag
)
6033 /* bad bound,lea,lds,les,lfs,lgs,lss,cmpxchg8b,vmptrst modrm */
6036 OP_E (bytemode
, sizeflag
);
6040 OP_0f07 (int bytemode
, int sizeflag
)
6042 if (modrm
.mod
!= 3 || modrm
.rm
!= 0)
6045 OP_E (bytemode
, sizeflag
);
6049 OP_0fae (int bytemode
, int sizeflag
)
6054 strcpy (obuf
+ strlen (obuf
) - sizeof ("clflush") + 1, "sfence");
6056 if (modrm
.reg
< 5 || modrm
.rm
!= 0)
6058 BadOp (); /* bad sfence, mfence, or lfence */
6062 else if (modrm
.reg
!= 7)
6064 BadOp (); /* bad clflush */
6068 OP_E (bytemode
, sizeflag
);
6071 /* NOP is an alias of "xchg %ax,%ax" in 16bit mode, "xchg %eax,%eax" in
6072 32bit mode and "xchg %rax,%rax" in 64bit mode. */
6075 NOP_Fixup1 (int bytemode
, int sizeflag
)
6077 if ((prefixes
& PREFIX_DATA
) != 0
6080 && address_mode
== mode_64bit
))
6081 OP_REG (bytemode
, sizeflag
);
6083 strcpy (obuf
, "nop");
6087 NOP_Fixup2 (int bytemode
, int sizeflag
)
6089 if ((prefixes
& PREFIX_DATA
) != 0
6092 && address_mode
== mode_64bit
))
6093 OP_IMREG (bytemode
, sizeflag
);
6096 static const char *Suffix3DNow
[] = {
6097 /* 00 */ NULL
, NULL
, NULL
, NULL
,
6098 /* 04 */ NULL
, NULL
, NULL
, NULL
,
6099 /* 08 */ NULL
, NULL
, NULL
, NULL
,
6100 /* 0C */ "pi2fw", "pi2fd", NULL
, NULL
,
6101 /* 10 */ NULL
, NULL
, NULL
, NULL
,
6102 /* 14 */ NULL
, NULL
, NULL
, NULL
,
6103 /* 18 */ NULL
, NULL
, NULL
, NULL
,
6104 /* 1C */ "pf2iw", "pf2id", NULL
, NULL
,
6105 /* 20 */ NULL
, NULL
, NULL
, NULL
,
6106 /* 24 */ NULL
, NULL
, NULL
, NULL
,
6107 /* 28 */ NULL
, NULL
, NULL
, NULL
,
6108 /* 2C */ NULL
, NULL
, NULL
, NULL
,
6109 /* 30 */ NULL
, NULL
, NULL
, NULL
,
6110 /* 34 */ NULL
, NULL
, NULL
, NULL
,
6111 /* 38 */ NULL
, NULL
, NULL
, NULL
,
6112 /* 3C */ NULL
, NULL
, NULL
, NULL
,
6113 /* 40 */ NULL
, NULL
, NULL
, NULL
,
6114 /* 44 */ NULL
, NULL
, NULL
, NULL
,
6115 /* 48 */ NULL
, NULL
, NULL
, NULL
,
6116 /* 4C */ NULL
, NULL
, NULL
, NULL
,
6117 /* 50 */ NULL
, NULL
, NULL
, NULL
,
6118 /* 54 */ NULL
, NULL
, NULL
, NULL
,
6119 /* 58 */ NULL
, NULL
, NULL
, NULL
,
6120 /* 5C */ NULL
, NULL
, NULL
, NULL
,
6121 /* 60 */ NULL
, NULL
, NULL
, NULL
,
6122 /* 64 */ NULL
, NULL
, NULL
, NULL
,
6123 /* 68 */ NULL
, NULL
, NULL
, NULL
,
6124 /* 6C */ NULL
, NULL
, NULL
, NULL
,
6125 /* 70 */ NULL
, NULL
, NULL
, NULL
,
6126 /* 74 */ NULL
, NULL
, NULL
, NULL
,
6127 /* 78 */ NULL
, NULL
, NULL
, NULL
,
6128 /* 7C */ NULL
, NULL
, NULL
, NULL
,
6129 /* 80 */ NULL
, NULL
, NULL
, NULL
,
6130 /* 84 */ NULL
, NULL
, NULL
, NULL
,
6131 /* 88 */ NULL
, NULL
, "pfnacc", NULL
,
6132 /* 8C */ NULL
, NULL
, "pfpnacc", NULL
,
6133 /* 90 */ "pfcmpge", NULL
, NULL
, NULL
,
6134 /* 94 */ "pfmin", NULL
, "pfrcp", "pfrsqrt",
6135 /* 98 */ NULL
, NULL
, "pfsub", NULL
,
6136 /* 9C */ NULL
, NULL
, "pfadd", NULL
,
6137 /* A0 */ "pfcmpgt", NULL
, NULL
, NULL
,
6138 /* A4 */ "pfmax", NULL
, "pfrcpit1", "pfrsqit1",
6139 /* A8 */ NULL
, NULL
, "pfsubr", NULL
,
6140 /* AC */ NULL
, NULL
, "pfacc", NULL
,
6141 /* B0 */ "pfcmpeq", NULL
, NULL
, NULL
,
6142 /* B4 */ "pfmul", NULL
, "pfrcpit2", "pmulhrw",
6143 /* B8 */ NULL
, NULL
, NULL
, "pswapd",
6144 /* BC */ NULL
, NULL
, NULL
, "pavgusb",
6145 /* C0 */ NULL
, NULL
, NULL
, NULL
,
6146 /* C4 */ NULL
, NULL
, NULL
, NULL
,
6147 /* C8 */ NULL
, NULL
, NULL
, NULL
,
6148 /* CC */ NULL
, NULL
, NULL
, NULL
,
6149 /* D0 */ NULL
, NULL
, NULL
, NULL
,
6150 /* D4 */ NULL
, NULL
, NULL
, NULL
,
6151 /* D8 */ NULL
, NULL
, NULL
, NULL
,
6152 /* DC */ NULL
, NULL
, NULL
, NULL
,
6153 /* E0 */ NULL
, NULL
, NULL
, NULL
,
6154 /* E4 */ NULL
, NULL
, NULL
, NULL
,
6155 /* E8 */ NULL
, NULL
, NULL
, NULL
,
6156 /* EC */ NULL
, NULL
, NULL
, NULL
,
6157 /* F0 */ NULL
, NULL
, NULL
, NULL
,
6158 /* F4 */ NULL
, NULL
, NULL
, NULL
,
6159 /* F8 */ NULL
, NULL
, NULL
, NULL
,
6160 /* FC */ NULL
, NULL
, NULL
, NULL
,
6164 OP_3DNowSuffix (int bytemode ATTRIBUTE_UNUSED
, int sizeflag ATTRIBUTE_UNUSED
)
6166 const char *mnemonic
;
6168 fetch_data(the_info
, codep
+ 1);
6169 /* AMD 3DNow! instructions are specified by an opcode suffix in the
6170 place where an 8-bit immediate would normally go. ie. the last
6171 byte of the instruction. */
6172 obufp
= obuf
+ strlen (obuf
);
6173 mnemonic
= Suffix3DNow
[*codep
++ & 0xff];
6178 /* Since a variable sized modrm/sib chunk is between the start
6179 of the opcode (0x0f0f) and the opcode suffix, we need to do
6180 all the modrm processing first, and don't know until now that
6181 we have a bad opcode. This necessitates some cleaning up. */
6182 op_out
[0][0] = '\0';
6183 op_out
[1][0] = '\0';
6188 static const char *simd_cmp_op
[] = {
6200 OP_SIMD_Suffix (int bytemode ATTRIBUTE_UNUSED
, int sizeflag ATTRIBUTE_UNUSED
)
6202 unsigned int cmp_type
;
6204 fetch_data(the_info
, codep
+ 1);
6205 obufp
= obuf
+ strlen (obuf
);
6206 cmp_type
= *codep
++ & 0xff;
6209 char suffix1
= 'p', suffix2
= 's';
6210 used_prefixes
|= (prefixes
& PREFIX_REPZ
);
6211 if (prefixes
& PREFIX_REPZ
)
6215 used_prefixes
|= (prefixes
& PREFIX_DATA
);
6216 if (prefixes
& PREFIX_DATA
)
6220 used_prefixes
|= (prefixes
& PREFIX_REPNZ
);
6221 if (prefixes
& PREFIX_REPNZ
)
6222 suffix1
= 's', suffix2
= 'd';
6225 snprintf (scratchbuf
, sizeof(scratchbuf
), "cmp%s%c%c",
6226 simd_cmp_op
[cmp_type
], suffix1
, suffix2
);
6227 used_prefixes
|= (prefixes
& PREFIX_REPZ
);
6228 oappend (scratchbuf
);
6232 /* We have a bad extension byte. Clean up. */
6233 op_out
[0][0] = '\0';
6234 op_out
[1][0] = '\0';
6240 SIMD_Fixup (int extrachar
, int sizeflag ATTRIBUTE_UNUSED
)
6242 /* Change movlps/movhps to movhlps/movlhps for 2 register operand
6243 forms of these instructions. */
6246 char *p
= obuf
+ strlen (obuf
);
6249 *(p
- 1) = *(p
- 2);
6250 *(p
- 2) = *(p
- 3);
6251 *(p
- 3) = extrachar
;
6256 PNI_Fixup (int extrachar ATTRIBUTE_UNUSED
, int sizeflag
)
6258 if (modrm
.mod
== 3 && modrm
.reg
== 1 && modrm
.rm
<= 1)
6260 /* Override "sidt". */
6261 size_t olen
= strlen (obuf
);
6262 char *p
= obuf
+ olen
- 4;
6263 const char * const *names
= (address_mode
== mode_64bit
6264 ? names64
: names32
);
6266 /* We might have a suffix when disassembling with -Msuffix. */
6270 /* Remove "addr16/addr32" if we aren't in Intel mode. */
6272 && (prefixes
& PREFIX_ADDR
)
6275 && strncmp (p
- 7, "addr", 4) == 0
6276 && (strncmp (p
- 3, "16", 2) == 0
6277 || strncmp (p
- 3, "32", 2) == 0))
6282 /* mwait %eax,%ecx */
6283 strcpy (p
, "mwait");
6285 strcpy (op_out
[0], names
[0]);
6289 /* monitor %eax,%ecx,%edx" */
6290 strcpy (p
, "monitor");
6293 const char * const *op1_names
;
6294 if (!(prefixes
& PREFIX_ADDR
))
6295 op1_names
= (address_mode
== mode_16bit
6299 op1_names
= (address_mode
!= mode_32bit
6300 ? names32
: names16
);
6301 used_prefixes
|= PREFIX_ADDR
;
6303 strcpy (op_out
[0], op1_names
[0]);
6304 strcpy (op_out
[2], names
[2]);
6309 strcpy (op_out
[1], names
[1]);
6320 SVME_Fixup (int bytemode
, int sizeflag
)
6352 OP_M (bytemode
, sizeflag
);
6355 /* Override "lidt". */
6356 p
= obuf
+ strlen (obuf
) - 4;
6357 /* We might have a suffix. */
6361 if (!(prefixes
& PREFIX_ADDR
))
6366 used_prefixes
|= PREFIX_ADDR
;
6370 strcpy (op_out
[1], names32
[1]);
6376 *obufp
++ = open_char
;
6377 if (address_mode
== mode_64bit
|| (sizeflag
& AFLAG
))
6381 strcpy (obufp
, alt
);
6382 obufp
+= strlen (alt
);
6383 *obufp
++ = close_char
;
6390 INVLPG_Fixup (int bytemode
, int sizeflag
)
6403 OP_M (bytemode
, sizeflag
);
6406 /* Override "invlpg". */
6407 strcpy (obuf
+ strlen (obuf
) - 6, alt
);
6414 /* Throw away prefixes and 1st. opcode byte. */
6415 codep
= insn_codep
+ 1;
6420 VMX_Fixup (int extrachar ATTRIBUTE_UNUSED
, int sizeflag
)
6427 /* Override "sgdt". */
6428 char *p
= obuf
+ strlen (obuf
) - 4;
6430 /* We might have a suffix when disassembling with -Msuffix. */
6437 strcpy (p
, "vmcall");
6440 strcpy (p
, "vmlaunch");
6443 strcpy (p
, "vmresume");
6446 strcpy (p
, "vmxoff");
6457 OP_VMX (int bytemode
, int sizeflag
)
6459 used_prefixes
|= (prefixes
& (PREFIX_DATA
| PREFIX_REPZ
));
6460 if (prefixes
& PREFIX_DATA
)
6461 strcpy (obuf
, "vmclear");
6462 else if (prefixes
& PREFIX_REPZ
)
6463 strcpy (obuf
, "vmxon");
6465 strcpy (obuf
, "vmptrld");
6466 OP_E (bytemode
, sizeflag
);
6470 REP_Fixup (int bytemode
, int sizeflag
)
6472 /* The 0xf3 prefix should be displayed as "rep" for ins, outs, movs,
6476 if (prefixes
& PREFIX_REPZ
)
6477 switch (*insn_codep
)
6479 case 0x6e: /* outsb */
6480 case 0x6f: /* outsw/outsl */
6481 case 0xa4: /* movsb */
6482 case 0xa5: /* movsw/movsl/movsq */
6488 case 0xaa: /* stosb */
6489 case 0xab: /* stosw/stosl/stosq */
6490 case 0xac: /* lodsb */
6491 case 0xad: /* lodsw/lodsl/lodsq */
6492 if (!intel_syntax
&& (sizeflag
& SUFFIX_ALWAYS
))
6497 case 0x6c: /* insb */
6498 case 0x6d: /* insl/insw */
6514 olen
= strlen (obuf
);
6515 p
= obuf
+ olen
- ilen
- 1 - 4;
6516 /* Handle "repz [addr16|addr32]". */
6517 if ((prefixes
& PREFIX_ADDR
))
6520 memmove (p
+ 3, p
+ 4, olen
- (p
+ 3 - obuf
));
6528 OP_IMREG (bytemode
, sizeflag
);
6531 OP_ESreg (bytemode
, sizeflag
);
6534 OP_DSreg (bytemode
, sizeflag
);
6543 CMPXCHG8B_Fixup (int bytemode
, int sizeflag
)
6548 /* Change cmpxchg8b to cmpxchg16b. */
6549 char *p
= obuf
+ strlen (obuf
) - 2;
6553 OP_M (bytemode
, sizeflag
);
6557 XMM_Fixup (int reg
, int sizeflag ATTRIBUTE_UNUSED
)
6559 snprintf (scratchbuf
, sizeof(scratchbuf
), "%%xmm%d", reg
);
6560 oappend (scratchbuf
+ intel_syntax
);
6564 CRC32_Fixup (int bytemode
, int sizeflag
)
6566 /* Add proper suffix to "crc32". */
6567 char *p
= obuf
+ strlen (obuf
);
6584 else if (sizeflag
& DFLAG
)
6588 used_prefixes
|= (prefixes
& PREFIX_DATA
);
6591 oappend (INTERNAL_DISASSEMBLER_ERROR
);
6600 /* Skip mod/rm byte. */
6605 add
= (rex
& REX_B
) ? 8 : 0;
6606 if (bytemode
== b_mode
)
6610 oappend (names8rex
[modrm
.rm
+ add
]);
6612 oappend (names8
[modrm
.rm
+ add
]);
6618 oappend (names64
[modrm
.rm
+ add
]);
6619 else if ((prefixes
& PREFIX_DATA
))
6620 oappend (names16
[modrm
.rm
+ add
]);
6622 oappend (names32
[modrm
.rm
+ add
]);
6626 OP_E (bytemode
, sizeflag
);