1 /* Print i386 instructions for GDB, the GNU debugger.
2 Copyright 1988, 1989, 1991, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
3 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
5 This file is part of GDB.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */
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. */
42 #ifndef UNIXWARE_COMPAT
43 /* Set non-zero for broken, compatible instructions. Set to zero for
44 non-broken opcodes. */
45 #define UNIXWARE_COMPAT 1
48 static int fetch_data (struct disassemble_info
*, bfd_byte
*);
49 static void ckprefix (void);
50 static const char *prefix_name (int, int);
51 static int print_insn (bfd_vma
, disassemble_info
*);
52 static void dofloat (int);
53 static void OP_ST (int, int);
54 static void OP_STi (int, int);
55 static int putop (const char *, int);
56 static void oappend (const char *);
57 static void append_seg (void);
58 static void OP_indirE (int, int);
59 static void print_operand_value (char *, int, bfd_vma
);
60 static void OP_E (int, int);
61 static void OP_G (int, int);
62 static bfd_vma
get64 (void);
63 static bfd_signed_vma
get32 (void);
64 static bfd_signed_vma
get32s (void);
65 static int get16 (void);
66 static void set_op (bfd_vma
, int);
67 static void OP_REG (int, int);
68 static void OP_IMREG (int, int);
69 static void OP_I (int, int);
70 static void OP_I64 (int, int);
71 static void OP_sI (int, int);
72 static void OP_J (int, int);
73 static void OP_SEG (int, int);
74 static void OP_DIR (int, int);
75 static void OP_OFF (int, int);
76 static void OP_OFF64 (int, int);
77 static void ptr_reg (int, int);
78 static void OP_ESreg (int, int);
79 static void OP_DSreg (int, int);
80 static void OP_C (int, int);
81 static void OP_D (int, int);
82 static void OP_T (int, int);
83 static void OP_Rd (int, int);
84 static void OP_MMX (int, int);
85 static void OP_XMM (int, int);
86 static void OP_EM (int, int);
87 static void OP_EX (int, int);
88 static void OP_MS (int, int);
89 static void OP_XS (int, int);
90 static void OP_M (int, int);
91 static void OP_VMX (int, int);
92 static void OP_0fae (int, int);
93 static void OP_0f07 (int, int);
94 static void NOP_Fixup1 (int, int);
95 static void NOP_Fixup2 (int, int);
96 static void OP_3DNowSuffix (int, int);
97 static void OP_SIMD_Suffix (int, int);
98 static void SIMD_Fixup (int, int);
99 static void PNI_Fixup (int, int);
100 static void SVME_Fixup (int, int);
101 static void INVLPG_Fixup (int, int);
102 static void BadOp (void);
103 static void SEG_Fixup (int, int);
104 static void VMX_Fixup (int, int);
105 static void REP_Fixup (int, int);
108 /* Points to first byte not fetched. */
109 bfd_byte
*max_fetched
;
110 bfd_byte the_buffer
[MAXLEN
];
116 /* The opcode for the fwait instruction, which we treat as a prefix
118 #define FWAIT_OPCODE (0x9b)
127 enum address_mode address_mode
;
129 /* Flags for the prefixes for the current instruction. See below. */
132 /* REX prefix the current instruction. See below. */
134 /* Bits of REX we've already used. */
140 /* Mark parts used in the REX prefix. When we are testing for
141 empty prefix (for 8bit register REX extension), just mask it
142 out. Otherwise test for REX bit is excuse for existence of REX
143 only in case value is nonzero. */
144 #define USED_REX(value) \
147 rex_used |= (rex & value) ? (value) | 0x40 : 0; \
152 /* Flags for prefixes which we somehow handled when printing the
153 current instruction. */
154 static int used_prefixes
;
156 /* Flags stored in PREFIXES. */
157 #define PREFIX_REPZ 1
158 #define PREFIX_REPNZ 2
159 #define PREFIX_LOCK 4
161 #define PREFIX_SS 0x10
162 #define PREFIX_DS 0x20
163 #define PREFIX_ES 0x40
164 #define PREFIX_FS 0x80
165 #define PREFIX_GS 0x100
166 #define PREFIX_DATA 0x200
167 #define PREFIX_ADDR 0x400
168 #define PREFIX_FWAIT 0x800
170 /* Make sure that bytes from INFO->PRIVATE_DATA->BUFFER (inclusive)
171 to ADDR (exclusive) are valid. Returns 1 for success, longjmps
173 #define FETCH_DATA(info, addr) \
174 ((addr) <= ((struct dis_private *) (info->private_data))->max_fetched \
175 ? 1 : fetch_data ((info), (addr)))
178 fetch_data (struct disassemble_info
*info
, bfd_byte
*addr
)
181 struct dis_private
*priv
= (struct dis_private
*) info
->private_data
;
182 bfd_vma start
= priv
->insn_start
+ (priv
->max_fetched
- priv
->the_buffer
);
184 if (addr
<= priv
->the_buffer
+ MAXLEN
)
185 status
= (*info
->read_memory_func
) (start
,
187 addr
- priv
->max_fetched
,
193 /* If we did manage to read at least one byte, then
194 print_insn_i386 will do something sensible. Otherwise, print
195 an error. We do that here because this is where we know
197 if (priv
->max_fetched
== priv
->the_buffer
)
198 (*info
->memory_error_func
) (status
, start
, info
);
199 longjmp (priv
->bailout
, 1);
202 priv
->max_fetched
= addr
;
208 #define Eb OP_E, b_mode
209 #define Ev OP_E, v_mode
210 #define Ed OP_E, d_mode
211 #define Eq OP_E, q_mode
212 #define Edq OP_E, dq_mode
213 #define Edqw OP_E, dqw_mode
214 #define indirEv OP_indirE, stack_v_mode
215 #define indirEp OP_indirE, f_mode
216 #define stackEv OP_E, stack_v_mode
217 #define Em OP_E, m_mode
218 #define Ew OP_E, w_mode
219 #define Ma OP_E, v_mode
220 #define M OP_M, 0 /* lea, lgdt, etc. */
221 #define Mp OP_M, f_mode /* 32 or 48 bit memory operand for LDS, LES etc */
222 #define Gb OP_G, b_mode
223 #define Gv OP_G, v_mode
224 #define Gd OP_G, d_mode
225 #define Gdq OP_G, dq_mode
226 #define Gm OP_G, m_mode
227 #define Gw OP_G, w_mode
228 #define Rd OP_Rd, d_mode
229 #define Rm OP_Rd, m_mode
230 #define Ib OP_I, b_mode
231 #define sIb OP_sI, b_mode /* sign extened byte */
232 #define Iv OP_I, v_mode
233 #define Iq OP_I, q_mode
234 #define Iv64 OP_I64, v_mode
235 #define Iw OP_I, w_mode
236 #define I1 OP_I, const_1_mode
237 #define Jb OP_J, b_mode
238 #define Jv OP_J, v_mode
239 #define Cm OP_C, m_mode
240 #define Dm OP_D, m_mode
241 #define Td OP_T, d_mode
242 #define Sv SEG_Fixup, v_mode
244 #define RMeAX OP_REG, eAX_reg
245 #define RMeBX OP_REG, eBX_reg
246 #define RMeCX OP_REG, eCX_reg
247 #define RMeDX OP_REG, eDX_reg
248 #define RMeSP OP_REG, eSP_reg
249 #define RMeBP OP_REG, eBP_reg
250 #define RMeSI OP_REG, eSI_reg
251 #define RMeDI OP_REG, eDI_reg
252 #define RMrAX OP_REG, rAX_reg
253 #define RMrBX OP_REG, rBX_reg
254 #define RMrCX OP_REG, rCX_reg
255 #define RMrDX OP_REG, rDX_reg
256 #define RMrSP OP_REG, rSP_reg
257 #define RMrBP OP_REG, rBP_reg
258 #define RMrSI OP_REG, rSI_reg
259 #define RMrDI OP_REG, rDI_reg
260 #define RMAL OP_REG, al_reg
261 #define RMAL OP_REG, al_reg
262 #define RMCL OP_REG, cl_reg
263 #define RMDL OP_REG, dl_reg
264 #define RMBL OP_REG, bl_reg
265 #define RMAH OP_REG, ah_reg
266 #define RMCH OP_REG, ch_reg
267 #define RMDH OP_REG, dh_reg
268 #define RMBH OP_REG, bh_reg
269 #define RMAX OP_REG, ax_reg
270 #define RMDX OP_REG, dx_reg
272 #define eAX OP_IMREG, eAX_reg
273 #define eBX OP_IMREG, eBX_reg
274 #define eCX OP_IMREG, eCX_reg
275 #define eDX OP_IMREG, eDX_reg
276 #define eSP OP_IMREG, eSP_reg
277 #define eBP OP_IMREG, eBP_reg
278 #define eSI OP_IMREG, eSI_reg
279 #define eDI OP_IMREG, eDI_reg
280 #define AL OP_IMREG, al_reg
281 #define CL OP_IMREG, cl_reg
282 #define DL OP_IMREG, dl_reg
283 #define BL OP_IMREG, bl_reg
284 #define AH OP_IMREG, ah_reg
285 #define CH OP_IMREG, ch_reg
286 #define DH OP_IMREG, dh_reg
287 #define BH OP_IMREG, bh_reg
288 #define AX OP_IMREG, ax_reg
289 #define DX OP_IMREG, dx_reg
290 #define indirDX OP_IMREG, indir_dx_reg
292 #define Sw OP_SEG, w_mode
294 #define Ob OP_OFF64, b_mode
295 #define Ov OP_OFF64, v_mode
296 #define Xb OP_DSreg, eSI_reg
297 #define Xv OP_DSreg, eSI_reg
298 #define Yb OP_ESreg, eDI_reg
299 #define Yv OP_ESreg, eDI_reg
300 #define DSBX OP_DSreg, eBX_reg
302 #define es OP_REG, es_reg
303 #define ss OP_REG, ss_reg
304 #define cs OP_REG, cs_reg
305 #define ds OP_REG, ds_reg
306 #define fs OP_REG, fs_reg
307 #define gs OP_REG, gs_reg
311 #define EM OP_EM, v_mode
312 #define EX OP_EX, v_mode
313 #define MS OP_MS, v_mode
314 #define XS OP_XS, v_mode
315 #define VM OP_VMX, q_mode
316 #define OPSUF OP_3DNowSuffix, 0
317 #define OPSIMD OP_SIMD_Suffix, 0
319 /* Used handle "rep" prefix for string instructions. */
320 #define Xbr REP_Fixup, eSI_reg
321 #define Xvr REP_Fixup, eSI_reg
322 #define Ybr REP_Fixup, eDI_reg
323 #define Yvr REP_Fixup, eDI_reg
324 #define indirDXr REP_Fixup, indir_dx_reg
325 #define ALr REP_Fixup, al_reg
326 #define eAXr REP_Fixup, eAX_reg
328 #define cond_jump_flag NULL, cond_jump_mode
329 #define loop_jcxz_flag NULL, loop_jcxz_mode
331 /* bits in sizeflag */
332 #define SUFFIX_ALWAYS 4
336 #define b_mode 1 /* byte operand */
337 #define v_mode 2 /* operand size depends on prefixes */
338 #define w_mode 3 /* word operand */
339 #define d_mode 4 /* double word operand */
340 #define q_mode 5 /* quad word operand */
341 #define t_mode 6 /* ten-byte operand */
342 #define x_mode 7 /* 16-byte XMM operand */
343 #define m_mode 8 /* d_mode in 32bit, q_mode in 64bit mode. */
344 #define cond_jump_mode 9
345 #define loop_jcxz_mode 10
346 #define dq_mode 11 /* operand size depends on REX prefixes. */
347 #define dqw_mode 12 /* registers like dq_mode, memory like w_mode. */
348 #define f_mode 13 /* 4- or 6-byte pointer operand */
349 #define const_1_mode 14
350 #define stack_v_mode 15 /* v_mode for stack-related opcodes. */
395 #define indir_dx_reg 150
399 #define USE_PREFIX_USER_TABLE 3
400 #define X86_64_SPECIAL 4
401 #define IS_3BYTE_OPCODE 5
403 #define FLOAT NULL, NULL, FLOATCODE, NULL, 0, NULL, 0
405 #define GRP1b NULL, NULL, USE_GROUPS, NULL, 0, NULL, 0
406 #define GRP1S NULL, NULL, USE_GROUPS, NULL, 1, NULL, 0
407 #define GRP1Ss NULL, NULL, USE_GROUPS, NULL, 2, NULL, 0
408 #define GRP2b NULL, NULL, USE_GROUPS, NULL, 3, NULL, 0
409 #define GRP2S NULL, NULL, USE_GROUPS, NULL, 4, NULL, 0
410 #define GRP2b_one NULL, NULL, USE_GROUPS, NULL, 5, NULL, 0
411 #define GRP2S_one NULL, NULL, USE_GROUPS, NULL, 6, NULL, 0
412 #define GRP2b_cl NULL, NULL, USE_GROUPS, NULL, 7, NULL, 0
413 #define GRP2S_cl NULL, NULL, USE_GROUPS, NULL, 8, NULL, 0
414 #define GRP3b NULL, NULL, USE_GROUPS, NULL, 9, NULL, 0
415 #define GRP3S NULL, NULL, USE_GROUPS, NULL, 10, NULL, 0
416 #define GRP4 NULL, NULL, USE_GROUPS, NULL, 11, NULL, 0
417 #define GRP5 NULL, NULL, USE_GROUPS, NULL, 12, NULL, 0
418 #define GRP6 NULL, NULL, USE_GROUPS, NULL, 13, NULL, 0
419 #define GRP7 NULL, NULL, USE_GROUPS, NULL, 14, NULL, 0
420 #define GRP8 NULL, NULL, USE_GROUPS, NULL, 15, NULL, 0
421 #define GRP9 NULL, NULL, USE_GROUPS, NULL, 16, NULL, 0
422 #define GRP12 NULL, NULL, USE_GROUPS, NULL, 17, NULL, 0
423 #define GRP13 NULL, NULL, USE_GROUPS, NULL, 18, NULL, 0
424 #define GRP14 NULL, NULL, USE_GROUPS, NULL, 19, NULL, 0
425 #define GRP15 NULL, NULL, USE_GROUPS, NULL, 20, NULL, 0
426 #define GRP16 NULL, NULL, USE_GROUPS, NULL, 21, NULL, 0
427 #define GRPAMD NULL, NULL, USE_GROUPS, NULL, 22, NULL, 0
428 #define GRPPADLCK1 NULL, NULL, USE_GROUPS, NULL, 23, NULL, 0
429 #define GRPPADLCK2 NULL, NULL, USE_GROUPS, NULL, 24, NULL, 0
431 #define PREGRP0 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 0, NULL, 0
432 #define PREGRP1 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 1, NULL, 0
433 #define PREGRP2 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 2, NULL, 0
434 #define PREGRP3 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 3, NULL, 0
435 #define PREGRP4 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 4, NULL, 0
436 #define PREGRP5 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 5, NULL, 0
437 #define PREGRP6 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 6, NULL, 0
438 #define PREGRP7 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 7, NULL, 0
439 #define PREGRP8 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 8, NULL, 0
440 #define PREGRP9 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 9, NULL, 0
441 #define PREGRP10 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 10, NULL, 0
442 #define PREGRP11 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 11, NULL, 0
443 #define PREGRP12 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 12, NULL, 0
444 #define PREGRP13 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 13, NULL, 0
445 #define PREGRP14 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 14, NULL, 0
446 #define PREGRP15 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 15, NULL, 0
447 #define PREGRP16 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 16, NULL, 0
448 #define PREGRP17 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 17, NULL, 0
449 #define PREGRP18 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 18, NULL, 0
450 #define PREGRP19 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 19, NULL, 0
451 #define PREGRP20 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 20, NULL, 0
452 #define PREGRP21 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 21, NULL, 0
453 #define PREGRP22 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 22, NULL, 0
454 #define PREGRP23 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 23, NULL, 0
455 #define PREGRP24 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 24, NULL, 0
456 #define PREGRP25 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 25, NULL, 0
457 #define PREGRP26 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 26, NULL, 0
458 #define PREGRP27 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 27, NULL, 0
459 #define PREGRP28 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 28, NULL, 0
460 #define PREGRP29 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 29, NULL, 0
461 #define PREGRP30 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 30, NULL, 0
462 #define PREGRP31 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 31, NULL, 0
463 #define PREGRP32 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 32, NULL, 0
465 #define X86_64_0 NULL, NULL, X86_64_SPECIAL, NULL, 0, NULL, 0
467 #define THREE_BYTE_0 NULL, NULL, IS_3BYTE_OPCODE, NULL, 0, NULL, 0
468 #define THREE_BYTE_1 NULL, NULL, IS_3BYTE_OPCODE, NULL, 1, NULL, 0
470 typedef void (*op_rtn
) (int bytemode
, int sizeflag
);
482 /* Upper case letters in the instruction names here are macros.
483 'A' => print 'b' if no register operands or suffix_always is true
484 'B' => print 'b' if suffix_always is true
485 'C' => print 's' or 'l' ('w' or 'd' in Intel mode) depending on operand
487 'E' => print 'e' if 32-bit form of jcxz
488 'F' => print 'w' or 'l' depending on address size prefix (loop insns)
489 'H' => print ",pt" or ",pn" branch hint
490 'I' => honor following macro letter even in Intel mode (implemented only
491 . for some of the macro letters)
493 'L' => print 'l' if suffix_always is true
494 'N' => print 'n' if instruction has no wait "prefix"
495 'O' => print 'd', or 'o'
496 'P' => print 'w', 'l' or 'q' if instruction has an operand size prefix,
497 . or suffix_always is true. print 'q' if rex prefix is present.
498 'Q' => print 'w', 'l' or 'q' if no register operands or suffix_always
500 'R' => print 'w', 'l' or 'q' ("wd" or "dq" in intel mode)
501 'S' => print 'w', 'l' or 'q' if suffix_always is true
502 'T' => print 'q' in 64bit mode and behave as 'P' otherwise
503 'U' => print 'q' in 64bit mode and behave as 'Q' otherwise
504 'V' => print 'q' in 64bit mode and behave as 'S' otherwise
505 'W' => print 'b' or 'w' ("w" or "de" in intel mode)
506 'X' => print 's', 'd' depending on data16 prefix (for XMM)
507 'Y' => 'q' if instruction has an REX 64bit overwrite prefix
508 'Z' => print 'q' in 64bit mode and behave as 'L' otherwise
510 Many of the above letters print nothing in Intel mode. See "putop"
513 Braces '{' and '}', and vertical bars '|', indicate alternative
514 mnemonic strings for AT&T, Intel, X86_64 AT&T, and X86_64 Intel
515 modes. In cases where there are only two alternatives, the X86_64
516 instruction is reserved, and "(bad)" is printed.
519 static const struct dis386 dis386
[] = {
521 { "addB", Eb
, Gb
, XX
},
522 { "addS", Ev
, Gv
, XX
},
523 { "addB", Gb
, Eb
, XX
},
524 { "addS", Gv
, Ev
, XX
},
525 { "addB", AL
, Ib
, XX
},
526 { "addS", eAX
, Iv
, XX
},
527 { "push{T|}", es
, XX
, XX
},
528 { "pop{T|}", es
, XX
, XX
},
530 { "orB", Eb
, Gb
, XX
},
531 { "orS", Ev
, Gv
, XX
},
532 { "orB", Gb
, Eb
, XX
},
533 { "orS", Gv
, Ev
, XX
},
534 { "orB", AL
, Ib
, XX
},
535 { "orS", eAX
, Iv
, XX
},
536 { "push{T|}", cs
, XX
, XX
},
537 { "(bad)", XX
, XX
, XX
}, /* 0x0f extended opcode escape */
539 { "adcB", Eb
, Gb
, XX
},
540 { "adcS", Ev
, Gv
, XX
},
541 { "adcB", Gb
, Eb
, XX
},
542 { "adcS", Gv
, Ev
, XX
},
543 { "adcB", AL
, Ib
, XX
},
544 { "adcS", eAX
, Iv
, XX
},
545 { "push{T|}", ss
, XX
, XX
},
546 { "pop{T|}", ss
, XX
, XX
},
548 { "sbbB", Eb
, Gb
, XX
},
549 { "sbbS", Ev
, Gv
, XX
},
550 { "sbbB", Gb
, Eb
, XX
},
551 { "sbbS", Gv
, Ev
, XX
},
552 { "sbbB", AL
, Ib
, XX
},
553 { "sbbS", eAX
, Iv
, XX
},
554 { "push{T|}", ds
, XX
, XX
},
555 { "pop{T|}", ds
, XX
, XX
},
557 { "andB", Eb
, Gb
, XX
},
558 { "andS", Ev
, Gv
, XX
},
559 { "andB", Gb
, Eb
, XX
},
560 { "andS", Gv
, Ev
, XX
},
561 { "andB", AL
, Ib
, XX
},
562 { "andS", eAX
, Iv
, XX
},
563 { "(bad)", XX
, XX
, XX
}, /* SEG ES prefix */
564 { "daa{|}", XX
, XX
, XX
},
566 { "subB", Eb
, Gb
, XX
},
567 { "subS", Ev
, Gv
, XX
},
568 { "subB", Gb
, Eb
, XX
},
569 { "subS", Gv
, Ev
, XX
},
570 { "subB", AL
, Ib
, XX
},
571 { "subS", eAX
, Iv
, XX
},
572 { "(bad)", XX
, XX
, XX
}, /* SEG CS prefix */
573 { "das{|}", XX
, XX
, XX
},
575 { "xorB", Eb
, Gb
, XX
},
576 { "xorS", Ev
, Gv
, XX
},
577 { "xorB", Gb
, Eb
, XX
},
578 { "xorS", Gv
, Ev
, XX
},
579 { "xorB", AL
, Ib
, XX
},
580 { "xorS", eAX
, Iv
, XX
},
581 { "(bad)", XX
, XX
, XX
}, /* SEG SS prefix */
582 { "aaa{|}", XX
, XX
, XX
},
584 { "cmpB", Eb
, Gb
, XX
},
585 { "cmpS", Ev
, Gv
, XX
},
586 { "cmpB", Gb
, Eb
, XX
},
587 { "cmpS", Gv
, Ev
, XX
},
588 { "cmpB", AL
, Ib
, XX
},
589 { "cmpS", eAX
, Iv
, XX
},
590 { "(bad)", XX
, XX
, XX
}, /* SEG DS prefix */
591 { "aas{|}", XX
, XX
, XX
},
593 { "inc{S|}", RMeAX
, XX
, XX
},
594 { "inc{S|}", RMeCX
, XX
, XX
},
595 { "inc{S|}", RMeDX
, XX
, XX
},
596 { "inc{S|}", RMeBX
, XX
, XX
},
597 { "inc{S|}", RMeSP
, XX
, XX
},
598 { "inc{S|}", RMeBP
, XX
, XX
},
599 { "inc{S|}", RMeSI
, XX
, XX
},
600 { "inc{S|}", RMeDI
, XX
, XX
},
602 { "dec{S|}", RMeAX
, XX
, XX
},
603 { "dec{S|}", RMeCX
, XX
, XX
},
604 { "dec{S|}", RMeDX
, XX
, XX
},
605 { "dec{S|}", RMeBX
, XX
, XX
},
606 { "dec{S|}", RMeSP
, XX
, XX
},
607 { "dec{S|}", RMeBP
, XX
, XX
},
608 { "dec{S|}", RMeSI
, XX
, XX
},
609 { "dec{S|}", RMeDI
, XX
, XX
},
611 { "pushV", RMrAX
, XX
, XX
},
612 { "pushV", RMrCX
, XX
, XX
},
613 { "pushV", RMrDX
, XX
, XX
},
614 { "pushV", RMrBX
, XX
, XX
},
615 { "pushV", RMrSP
, XX
, XX
},
616 { "pushV", RMrBP
, XX
, XX
},
617 { "pushV", RMrSI
, XX
, XX
},
618 { "pushV", RMrDI
, XX
, XX
},
620 { "popV", RMrAX
, XX
, XX
},
621 { "popV", RMrCX
, XX
, XX
},
622 { "popV", RMrDX
, XX
, XX
},
623 { "popV", RMrBX
, XX
, XX
},
624 { "popV", RMrSP
, XX
, XX
},
625 { "popV", RMrBP
, XX
, XX
},
626 { "popV", RMrSI
, XX
, XX
},
627 { "popV", RMrDI
, XX
, XX
},
629 { "pusha{P|}", XX
, XX
, XX
},
630 { "popa{P|}", XX
, XX
, XX
},
631 { "bound{S|}", Gv
, Ma
, XX
},
633 { "(bad)", XX
, XX
, XX
}, /* seg fs */
634 { "(bad)", XX
, XX
, XX
}, /* seg gs */
635 { "(bad)", XX
, XX
, XX
}, /* op size prefix */
636 { "(bad)", XX
, XX
, XX
}, /* adr size prefix */
638 { "pushT", Iq
, XX
, XX
},
639 { "imulS", Gv
, Ev
, Iv
},
640 { "pushT", sIb
, XX
, XX
},
641 { "imulS", Gv
, Ev
, sIb
},
642 { "ins{b||b|}", Ybr
, indirDX
, XX
},
643 { "ins{R||R|}", Yvr
, indirDX
, XX
},
644 { "outs{b||b|}", indirDXr
, Xb
, XX
},
645 { "outs{R||R|}", indirDXr
, Xv
, XX
},
647 { "joH", Jb
, XX
, cond_jump_flag
},
648 { "jnoH", Jb
, XX
, cond_jump_flag
},
649 { "jbH", Jb
, XX
, cond_jump_flag
},
650 { "jaeH", Jb
, XX
, cond_jump_flag
},
651 { "jeH", Jb
, XX
, cond_jump_flag
},
652 { "jneH", Jb
, XX
, cond_jump_flag
},
653 { "jbeH", Jb
, XX
, cond_jump_flag
},
654 { "jaH", Jb
, XX
, cond_jump_flag
},
656 { "jsH", Jb
, XX
, cond_jump_flag
},
657 { "jnsH", Jb
, XX
, cond_jump_flag
},
658 { "jpH", Jb
, XX
, cond_jump_flag
},
659 { "jnpH", Jb
, XX
, cond_jump_flag
},
660 { "jlH", Jb
, XX
, cond_jump_flag
},
661 { "jgeH", Jb
, XX
, cond_jump_flag
},
662 { "jleH", Jb
, XX
, cond_jump_flag
},
663 { "jgH", Jb
, XX
, cond_jump_flag
},
667 { "(bad)", XX
, XX
, XX
},
669 { "testB", Eb
, Gb
, XX
},
670 { "testS", Ev
, Gv
, XX
},
671 { "xchgB", Eb
, Gb
, XX
},
672 { "xchgS", Ev
, Gv
, XX
},
674 { "movB", Eb
, Gb
, XX
},
675 { "movS", Ev
, Gv
, XX
},
676 { "movB", Gb
, Eb
, XX
},
677 { "movS", Gv
, Ev
, XX
},
678 { "movQ", Sv
, Sw
, XX
},
679 { "leaS", Gv
, M
, XX
},
680 { "movQ", Sw
, Sv
, XX
},
681 { "popU", stackEv
, XX
, XX
},
683 { "xchgS", NOP_Fixup1
, eAX_reg
, NOP_Fixup2
, eAX_reg
, XX
},
684 { "xchgS", RMeCX
, eAX
, XX
},
685 { "xchgS", RMeDX
, eAX
, XX
},
686 { "xchgS", RMeBX
, eAX
, XX
},
687 { "xchgS", RMeSP
, eAX
, XX
},
688 { "xchgS", RMeBP
, eAX
, XX
},
689 { "xchgS", RMeSI
, eAX
, XX
},
690 { "xchgS", RMeDI
, eAX
, XX
},
692 { "cW{tR||tR|}", XX
, XX
, XX
},
693 { "cR{tO||tO|}", XX
, XX
, XX
},
694 { "Jcall{T|}", Ap
, XX
, XX
},
695 { "(bad)", XX
, XX
, XX
}, /* fwait */
696 { "pushfT", XX
, XX
, XX
},
697 { "popfT", XX
, XX
, XX
},
698 { "sahf{|}", XX
, XX
, XX
},
699 { "lahf{|}", XX
, XX
, XX
},
701 { "movB", AL
, Ob
, XX
},
702 { "movS", eAX
, Ov
, XX
},
703 { "movB", Ob
, AL
, XX
},
704 { "movS", Ov
, eAX
, XX
},
705 { "movs{b||b|}", Ybr
, Xb
, XX
},
706 { "movs{R||R|}", Yvr
, Xv
, XX
},
707 { "cmps{b||b|}", Xb
, Yb
, XX
},
708 { "cmps{R||R|}", Xv
, Yv
, XX
},
710 { "testB", AL
, Ib
, XX
},
711 { "testS", eAX
, Iv
, XX
},
712 { "stosB", Ybr
, AL
, XX
},
713 { "stosS", Yvr
, eAX
, XX
},
714 { "lodsB", ALr
, Xb
, XX
},
715 { "lodsS", eAXr
, Xv
, XX
},
716 { "scasB", AL
, Yb
, XX
},
717 { "scasS", eAX
, Yv
, XX
},
719 { "movB", RMAL
, Ib
, XX
},
720 { "movB", RMCL
, Ib
, XX
},
721 { "movB", RMDL
, Ib
, XX
},
722 { "movB", RMBL
, Ib
, XX
},
723 { "movB", RMAH
, Ib
, XX
},
724 { "movB", RMCH
, Ib
, XX
},
725 { "movB", RMDH
, Ib
, XX
},
726 { "movB", RMBH
, Ib
, XX
},
728 { "movS", RMeAX
, Iv64
, XX
},
729 { "movS", RMeCX
, Iv64
, XX
},
730 { "movS", RMeDX
, Iv64
, XX
},
731 { "movS", RMeBX
, Iv64
, XX
},
732 { "movS", RMeSP
, Iv64
, XX
},
733 { "movS", RMeBP
, Iv64
, XX
},
734 { "movS", RMeSI
, Iv64
, XX
},
735 { "movS", RMeDI
, Iv64
, XX
},
739 { "retT", Iw
, XX
, XX
},
740 { "retT", XX
, XX
, XX
},
741 { "les{S|}", Gv
, Mp
, XX
},
742 { "ldsS", Gv
, Mp
, XX
},
743 { "movA", Eb
, Ib
, XX
},
744 { "movQ", Ev
, Iv
, XX
},
746 { "enterT", Iw
, Ib
, XX
},
747 { "leaveT", XX
, XX
, XX
},
748 { "lretP", Iw
, XX
, XX
},
749 { "lretP", XX
, XX
, XX
},
750 { "int3", XX
, XX
, XX
},
751 { "int", Ib
, XX
, XX
},
752 { "into{|}", XX
, XX
, XX
},
753 { "iretP", XX
, XX
, XX
},
759 { "aam{|}", sIb
, XX
, XX
},
760 { "aad{|}", sIb
, XX
, XX
},
761 { "(bad)", XX
, XX
, XX
},
762 { "xlat", DSBX
, XX
, XX
},
773 { "loopneFH", Jb
, XX
, loop_jcxz_flag
},
774 { "loopeFH", Jb
, XX
, loop_jcxz_flag
},
775 { "loopFH", Jb
, XX
, loop_jcxz_flag
},
776 { "jEcxzH", Jb
, XX
, loop_jcxz_flag
},
777 { "inB", AL
, Ib
, XX
},
778 { "inS", eAX
, Ib
, XX
},
779 { "outB", Ib
, AL
, XX
},
780 { "outS", Ib
, eAX
, XX
},
782 { "callT", Jv
, XX
, XX
},
783 { "jmpT", Jv
, XX
, XX
},
784 { "Jjmp{T|}", Ap
, XX
, XX
},
785 { "jmp", Jb
, XX
, XX
},
786 { "inB", AL
, indirDX
, XX
},
787 { "inS", eAX
, indirDX
, XX
},
788 { "outB", indirDX
, AL
, XX
},
789 { "outS", indirDX
, eAX
, XX
},
791 { "(bad)", XX
, XX
, XX
}, /* lock prefix */
792 { "icebp", XX
, XX
, XX
},
793 { "(bad)", XX
, XX
, XX
}, /* repne */
794 { "(bad)", XX
, XX
, XX
}, /* repz */
795 { "hlt", XX
, XX
, XX
},
796 { "cmc", XX
, XX
, XX
},
800 { "clc", XX
, XX
, XX
},
801 { "stc", XX
, XX
, XX
},
802 { "cli", XX
, XX
, XX
},
803 { "sti", XX
, XX
, XX
},
804 { "cld", XX
, XX
, XX
},
805 { "std", XX
, XX
, XX
},
810 static const struct dis386 dis386_twobyte
[] = {
814 { "larS", Gv
, Ew
, XX
},
815 { "lslS", Gv
, Ew
, XX
},
816 { "(bad)", XX
, XX
, XX
},
817 { "syscall", XX
, XX
, XX
},
818 { "clts", XX
, XX
, XX
},
819 { "sysretP", XX
, XX
, XX
},
821 { "invd", XX
, XX
, XX
},
822 { "wbinvd", XX
, XX
, XX
},
823 { "(bad)", XX
, XX
, XX
},
824 { "ud2a", XX
, XX
, XX
},
825 { "(bad)", XX
, XX
, XX
},
827 { "femms", XX
, XX
, XX
},
828 { "", MX
, EM
, OPSUF
}, /* See OP_3DNowSuffix. */
833 { "movlpX", EX
, XM
, SIMD_Fixup
, 'h' },
834 { "unpcklpX", XM
, EX
, XX
},
835 { "unpckhpX", XM
, EX
, XX
},
837 { "movhpX", EX
, XM
, SIMD_Fixup
, 'l' },
840 { "(bad)", XX
, XX
, XX
},
841 { "(bad)", XX
, XX
, XX
},
842 { "(bad)", XX
, XX
, XX
},
843 { "(bad)", XX
, XX
, XX
},
844 { "(bad)", XX
, XX
, XX
},
845 { "(bad)", XX
, XX
, XX
},
846 { "nopQ", Ev
, XX
, XX
},
848 { "movZ", Rm
, Cm
, XX
},
849 { "movZ", Rm
, Dm
, XX
},
850 { "movZ", Cm
, Rm
, XX
},
851 { "movZ", Dm
, Rm
, XX
},
852 { "movL", Rd
, Td
, XX
},
853 { "(bad)", XX
, XX
, XX
},
854 { "movL", Td
, Rd
, XX
},
855 { "(bad)", XX
, XX
, XX
},
857 { "movapX", XM
, EX
, XX
},
858 { "movapX", EX
, XM
, XX
},
860 { "movntpX", Ev
, XM
, XX
},
863 { "ucomisX", XM
,EX
, XX
},
864 { "comisX", XM
,EX
, XX
},
866 { "wrmsr", XX
, XX
, XX
},
867 { "rdtsc", XX
, XX
, XX
},
868 { "rdmsr", XX
, XX
, XX
},
869 { "rdpmc", XX
, XX
, XX
},
870 { "sysenter", XX
, XX
, XX
},
871 { "sysexit", XX
, XX
, XX
},
872 { "(bad)", XX
, XX
, XX
},
873 { "(bad)", XX
, XX
, XX
},
876 { "(bad)", XX
, XX
, XX
},
878 { "(bad)", XX
, XX
, XX
},
879 { "(bad)", XX
, XX
, XX
},
880 { "(bad)", XX
, XX
, XX
},
881 { "(bad)", XX
, XX
, XX
},
882 { "(bad)", XX
, XX
, XX
},
884 { "cmovo", Gv
, Ev
, XX
},
885 { "cmovno", Gv
, Ev
, XX
},
886 { "cmovb", Gv
, Ev
, XX
},
887 { "cmovae", Gv
, Ev
, XX
},
888 { "cmove", Gv
, Ev
, XX
},
889 { "cmovne", Gv
, Ev
, XX
},
890 { "cmovbe", Gv
, Ev
, XX
},
891 { "cmova", Gv
, Ev
, XX
},
893 { "cmovs", Gv
, Ev
, XX
},
894 { "cmovns", Gv
, Ev
, XX
},
895 { "cmovp", Gv
, Ev
, XX
},
896 { "cmovnp", Gv
, Ev
, XX
},
897 { "cmovl", Gv
, Ev
, XX
},
898 { "cmovge", Gv
, Ev
, XX
},
899 { "cmovle", Gv
, Ev
, XX
},
900 { "cmovg", Gv
, Ev
, XX
},
902 { "movmskpX", Gdq
, XS
, XX
},
906 { "andpX", XM
, EX
, XX
},
907 { "andnpX", XM
, EX
, XX
},
908 { "orpX", XM
, EX
, XX
},
909 { "xorpX", XM
, EX
, XX
},
920 { "punpcklbw", MX
, EM
, XX
},
921 { "punpcklwd", MX
, EM
, XX
},
922 { "punpckldq", MX
, EM
, XX
},
923 { "packsswb", MX
, EM
, XX
},
924 { "pcmpgtb", MX
, EM
, XX
},
925 { "pcmpgtw", MX
, EM
, XX
},
926 { "pcmpgtd", MX
, EM
, XX
},
927 { "packuswb", MX
, EM
, XX
},
929 { "punpckhbw", MX
, EM
, XX
},
930 { "punpckhwd", MX
, EM
, XX
},
931 { "punpckhdq", MX
, EM
, XX
},
932 { "packssdw", MX
, EM
, XX
},
935 { "movd", MX
, Edq
, XX
},
942 { "pcmpeqb", MX
, EM
, XX
},
943 { "pcmpeqw", MX
, EM
, XX
},
944 { "pcmpeqd", MX
, EM
, XX
},
945 { "emms", XX
, XX
, XX
},
947 { "vmread", Em
, Gm
, XX
},
948 { "vmwrite", Gm
, Em
, XX
},
949 { "(bad)", XX
, XX
, XX
},
950 { "(bad)", XX
, XX
, XX
},
956 { "joH", Jv
, XX
, cond_jump_flag
},
957 { "jnoH", Jv
, XX
, cond_jump_flag
},
958 { "jbH", Jv
, XX
, cond_jump_flag
},
959 { "jaeH", Jv
, XX
, cond_jump_flag
},
960 { "jeH", Jv
, XX
, cond_jump_flag
},
961 { "jneH", Jv
, XX
, cond_jump_flag
},
962 { "jbeH", Jv
, XX
, cond_jump_flag
},
963 { "jaH", Jv
, XX
, cond_jump_flag
},
965 { "jsH", Jv
, XX
, cond_jump_flag
},
966 { "jnsH", Jv
, XX
, cond_jump_flag
},
967 { "jpH", Jv
, XX
, cond_jump_flag
},
968 { "jnpH", Jv
, XX
, cond_jump_flag
},
969 { "jlH", Jv
, XX
, cond_jump_flag
},
970 { "jgeH", Jv
, XX
, cond_jump_flag
},
971 { "jleH", Jv
, XX
, cond_jump_flag
},
972 { "jgH", Jv
, XX
, cond_jump_flag
},
974 { "seto", Eb
, XX
, XX
},
975 { "setno", Eb
, XX
, XX
},
976 { "setb", Eb
, XX
, XX
},
977 { "setae", Eb
, XX
, XX
},
978 { "sete", Eb
, XX
, XX
},
979 { "setne", Eb
, XX
, XX
},
980 { "setbe", Eb
, XX
, XX
},
981 { "seta", Eb
, XX
, XX
},
983 { "sets", Eb
, XX
, XX
},
984 { "setns", Eb
, XX
, XX
},
985 { "setp", Eb
, XX
, XX
},
986 { "setnp", Eb
, XX
, XX
},
987 { "setl", Eb
, XX
, XX
},
988 { "setge", Eb
, XX
, XX
},
989 { "setle", Eb
, XX
, XX
},
990 { "setg", Eb
, XX
, XX
},
992 { "pushT", fs
, XX
, XX
},
993 { "popT", fs
, XX
, XX
},
994 { "cpuid", XX
, XX
, XX
},
995 { "btS", Ev
, Gv
, XX
},
996 { "shldS", Ev
, Gv
, Ib
},
997 { "shldS", Ev
, Gv
, CL
},
1001 { "pushT", gs
, XX
, XX
},
1002 { "popT", gs
, XX
, XX
},
1003 { "rsm", XX
, XX
, XX
},
1004 { "btsS", Ev
, Gv
, XX
},
1005 { "shrdS", Ev
, Gv
, Ib
},
1006 { "shrdS", Ev
, Gv
, CL
},
1008 { "imulS", Gv
, Ev
, XX
},
1010 { "cmpxchgB", Eb
, Gb
, XX
},
1011 { "cmpxchgS", Ev
, Gv
, XX
},
1012 { "lssS", Gv
, Mp
, XX
},
1013 { "btrS", Ev
, Gv
, XX
},
1014 { "lfsS", Gv
, Mp
, XX
},
1015 { "lgsS", Gv
, Mp
, XX
},
1016 { "movz{bR|x|bR|x}", Gv
, Eb
, XX
},
1017 { "movz{wR|x|wR|x}", Gv
, Ew
, XX
}, /* yes, there really is movzww ! */
1019 { "(bad)", XX
, XX
, XX
},
1020 { "ud2b", XX
, XX
, XX
},
1022 { "btcS", Ev
, Gv
, XX
},
1023 { "bsfS", Gv
, Ev
, XX
},
1024 { "bsrS", Gv
, Ev
, XX
},
1025 { "movs{bR|x|bR|x}", Gv
, Eb
, XX
},
1026 { "movs{wR|x|wR|x}", Gv
, Ew
, XX
}, /* yes, there really is movsww ! */
1028 { "xaddB", Eb
, Gb
, XX
},
1029 { "xaddS", Ev
, Gv
, XX
},
1031 { "movntiS", Ev
, Gv
, XX
},
1032 { "pinsrw", MX
, Edqw
, Ib
},
1033 { "pextrw", Gdq
, MS
, Ib
},
1034 { "shufpX", XM
, EX
, Ib
},
1037 { "bswap", RMeAX
, XX
, XX
},
1038 { "bswap", RMeCX
, XX
, XX
},
1039 { "bswap", RMeDX
, XX
, XX
},
1040 { "bswap", RMeBX
, XX
, XX
},
1041 { "bswap", RMeSP
, XX
, XX
},
1042 { "bswap", RMeBP
, XX
, XX
},
1043 { "bswap", RMeSI
, XX
, XX
},
1044 { "bswap", RMeDI
, XX
, XX
},
1047 { "psrlw", MX
, EM
, XX
},
1048 { "psrld", MX
, EM
, XX
},
1049 { "psrlq", MX
, EM
, XX
},
1050 { "paddq", MX
, EM
, XX
},
1051 { "pmullw", MX
, EM
, XX
},
1053 { "pmovmskb", Gdq
, MS
, XX
},
1055 { "psubusb", MX
, EM
, XX
},
1056 { "psubusw", MX
, EM
, XX
},
1057 { "pminub", MX
, EM
, XX
},
1058 { "pand", MX
, EM
, XX
},
1059 { "paddusb", MX
, EM
, XX
},
1060 { "paddusw", MX
, EM
, XX
},
1061 { "pmaxub", MX
, EM
, XX
},
1062 { "pandn", MX
, EM
, XX
},
1064 { "pavgb", MX
, EM
, XX
},
1065 { "psraw", MX
, EM
, XX
},
1066 { "psrad", MX
, EM
, XX
},
1067 { "pavgw", MX
, EM
, XX
},
1068 { "pmulhuw", MX
, EM
, XX
},
1069 { "pmulhw", MX
, EM
, XX
},
1073 { "psubsb", MX
, EM
, XX
},
1074 { "psubsw", MX
, EM
, XX
},
1075 { "pminsw", MX
, EM
, XX
},
1076 { "por", MX
, EM
, XX
},
1077 { "paddsb", MX
, EM
, XX
},
1078 { "paddsw", MX
, EM
, XX
},
1079 { "pmaxsw", MX
, EM
, XX
},
1080 { "pxor", MX
, EM
, XX
},
1083 { "psllw", MX
, EM
, XX
},
1084 { "pslld", MX
, EM
, XX
},
1085 { "psllq", MX
, EM
, XX
},
1086 { "pmuludq", MX
, EM
, XX
},
1087 { "pmaddwd", MX
, EM
, XX
},
1088 { "psadbw", MX
, EM
, XX
},
1091 { "psubb", MX
, EM
, XX
},
1092 { "psubw", MX
, EM
, XX
},
1093 { "psubd", MX
, EM
, XX
},
1094 { "psubq", MX
, EM
, XX
},
1095 { "paddb", MX
, EM
, XX
},
1096 { "paddw", MX
, EM
, XX
},
1097 { "paddd", MX
, EM
, XX
},
1098 { "(bad)", XX
, XX
, XX
}
1101 static const unsigned char onebyte_has_modrm
[256] = {
1102 /* 0 1 2 3 4 5 6 7 8 9 a b c d e f */
1103 /* ------------------------------- */
1104 /* 00 */ 1,1,1,1,0,0,0,0,1,1,1,1,0,0,0,0, /* 00 */
1105 /* 10 */ 1,1,1,1,0,0,0,0,1,1,1,1,0,0,0,0, /* 10 */
1106 /* 20 */ 1,1,1,1,0,0,0,0,1,1,1,1,0,0,0,0, /* 20 */
1107 /* 30 */ 1,1,1,1,0,0,0,0,1,1,1,1,0,0,0,0, /* 30 */
1108 /* 40 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 40 */
1109 /* 50 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 50 */
1110 /* 60 */ 0,0,1,1,0,0,0,0,0,1,0,1,0,0,0,0, /* 60 */
1111 /* 70 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 70 */
1112 /* 80 */ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, /* 80 */
1113 /* 90 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 90 */
1114 /* a0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* a0 */
1115 /* b0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* b0 */
1116 /* c0 */ 1,1,0,0,1,1,1,1,0,0,0,0,0,0,0,0, /* c0 */
1117 /* d0 */ 1,1,1,1,0,0,0,0,1,1,1,1,1,1,1,1, /* d0 */
1118 /* e0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* e0 */
1119 /* f0 */ 0,0,0,0,0,0,1,1,0,0,0,0,0,0,1,1 /* f0 */
1120 /* ------------------------------- */
1121 /* 0 1 2 3 4 5 6 7 8 9 a b c d e f */
1124 static const unsigned char twobyte_has_modrm
[256] = {
1125 /* 0 1 2 3 4 5 6 7 8 9 a b c d e f */
1126 /* ------------------------------- */
1127 /* 00 */ 1,1,1,1,0,0,0,0,0,0,0,0,0,1,0,1, /* 0f */
1128 /* 10 */ 1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,1, /* 1f */
1129 /* 20 */ 1,1,1,1,1,0,1,0,1,1,1,1,1,1,1,1, /* 2f */
1130 /* 30 */ 0,0,0,0,0,0,0,0,1,0,1,0,0,0,0,0, /* 3f */
1131 /* 40 */ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, /* 4f */
1132 /* 50 */ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, /* 5f */
1133 /* 60 */ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, /* 6f */
1134 /* 70 */ 1,1,1,1,1,1,1,0,1,1,0,0,1,1,1,1, /* 7f */
1135 /* 80 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 8f */
1136 /* 90 */ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, /* 9f */
1137 /* a0 */ 0,0,0,1,1,1,1,1,0,0,0,1,1,1,1,1, /* af */
1138 /* b0 */ 1,1,1,1,1,1,1,1,0,0,1,1,1,1,1,1, /* bf */
1139 /* c0 */ 1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0, /* cf */
1140 /* d0 */ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, /* df */
1141 /* e0 */ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, /* ef */
1142 /* f0 */ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0 /* ff */
1143 /* ------------------------------- */
1144 /* 0 1 2 3 4 5 6 7 8 9 a b c d e f */
1147 static const unsigned char twobyte_uses_SSE_prefix
[256] = {
1148 /* 0 1 2 3 4 5 6 7 8 9 a b c d e f */
1149 /* ------------------------------- */
1150 /* 00 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0f */
1151 /* 10 */ 1,1,1,0,0,0,1,0,0,0,0,0,0,0,0,0, /* 1f */
1152 /* 20 */ 0,0,0,0,0,0,0,0,0,0,1,0,1,1,0,0, /* 2f */
1153 /* 30 */ 0,0,0,0,0,0,0,0,1,0,1,0,0,0,0,0, /* 3f */
1154 /* 40 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 4f */
1155 /* 50 */ 0,1,1,1,0,0,0,0,1,1,1,1,1,1,1,1, /* 5f */
1156 /* 60 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1, /* 6f */
1157 /* 70 */ 1,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1, /* 7f */
1158 /* 80 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 8f */
1159 /* 90 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 9f */
1160 /* a0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* af */
1161 /* b0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* bf */
1162 /* c0 */ 0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0, /* cf */
1163 /* d0 */ 1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0, /* df */
1164 /* e0 */ 0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0, /* ef */
1165 /* f0 */ 1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0 /* ff */
1166 /* ------------------------------- */
1167 /* 0 1 2 3 4 5 6 7 8 9 a b c d e f */
1170 static char obuf
[100];
1172 static char scratchbuf
[100];
1173 static unsigned char *start_codep
;
1174 static unsigned char *insn_codep
;
1175 static unsigned char *codep
;
1176 static disassemble_info
*the_info
;
1180 static unsigned char need_modrm
;
1182 /* If we are accessing mod/rm/reg without need_modrm set, then the
1183 values are stale. Hitting this abort likely indicates that you
1184 need to update onebyte_has_modrm or twobyte_has_modrm. */
1185 #define MODRM_CHECK if (!need_modrm) abort ()
1187 static const char **names64
;
1188 static const char **names32
;
1189 static const char **names16
;
1190 static const char **names8
;
1191 static const char **names8rex
;
1192 static const char **names_seg
;
1193 static const char **index16
;
1195 static const char *intel_names64
[] = {
1196 "rax", "rcx", "rdx", "rbx", "rsp", "rbp", "rsi", "rdi",
1197 "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15"
1199 static const char *intel_names32
[] = {
1200 "eax", "ecx", "edx", "ebx", "esp", "ebp", "esi", "edi",
1201 "r8d", "r9d", "r10d", "r11d", "r12d", "r13d", "r14d", "r15d"
1203 static const char *intel_names16
[] = {
1204 "ax", "cx", "dx", "bx", "sp", "bp", "si", "di",
1205 "r8w", "r9w", "r10w", "r11w", "r12w", "r13w", "r14w", "r15w"
1207 static const char *intel_names8
[] = {
1208 "al", "cl", "dl", "bl", "ah", "ch", "dh", "bh",
1210 static const char *intel_names8rex
[] = {
1211 "al", "cl", "dl", "bl", "spl", "bpl", "sil", "dil",
1212 "r8b", "r9b", "r10b", "r11b", "r12b", "r13b", "r14b", "r15b"
1214 static const char *intel_names_seg
[] = {
1215 "es", "cs", "ss", "ds", "fs", "gs", "?", "?",
1217 static const char *intel_index16
[] = {
1218 "bx+si", "bx+di", "bp+si", "bp+di", "si", "di", "bp", "bx"
1221 static const char *att_names64
[] = {
1222 "%rax", "%rcx", "%rdx", "%rbx", "%rsp", "%rbp", "%rsi", "%rdi",
1223 "%r8", "%r9", "%r10", "%r11", "%r12", "%r13", "%r14", "%r15"
1225 static const char *att_names32
[] = {
1226 "%eax", "%ecx", "%edx", "%ebx", "%esp", "%ebp", "%esi", "%edi",
1227 "%r8d", "%r9d", "%r10d", "%r11d", "%r12d", "%r13d", "%r14d", "%r15d"
1229 static const char *att_names16
[] = {
1230 "%ax", "%cx", "%dx", "%bx", "%sp", "%bp", "%si", "%di",
1231 "%r8w", "%r9w", "%r10w", "%r11w", "%r12w", "%r13w", "%r14w", "%r15w"
1233 static const char *att_names8
[] = {
1234 "%al", "%cl", "%dl", "%bl", "%ah", "%ch", "%dh", "%bh",
1236 static const char *att_names8rex
[] = {
1237 "%al", "%cl", "%dl", "%bl", "%spl", "%bpl", "%sil", "%dil",
1238 "%r8b", "%r9b", "%r10b", "%r11b", "%r12b", "%r13b", "%r14b", "%r15b"
1240 static const char *att_names_seg
[] = {
1241 "%es", "%cs", "%ss", "%ds", "%fs", "%gs", "%?", "%?",
1243 static const char *att_index16
[] = {
1244 "%bx,%si", "%bx,%di", "%bp,%si", "%bp,%di", "%si", "%di", "%bp", "%bx"
1247 static const struct dis386 grps
[][8] = {
1250 { "addA", Eb
, Ib
, XX
},
1251 { "orA", Eb
, Ib
, XX
},
1252 { "adcA", Eb
, Ib
, XX
},
1253 { "sbbA", Eb
, Ib
, XX
},
1254 { "andA", Eb
, Ib
, XX
},
1255 { "subA", Eb
, Ib
, XX
},
1256 { "xorA", Eb
, Ib
, XX
},
1257 { "cmpA", Eb
, Ib
, XX
}
1261 { "addQ", Ev
, Iv
, XX
},
1262 { "orQ", Ev
, Iv
, XX
},
1263 { "adcQ", Ev
, Iv
, XX
},
1264 { "sbbQ", Ev
, Iv
, XX
},
1265 { "andQ", Ev
, Iv
, XX
},
1266 { "subQ", Ev
, Iv
, XX
},
1267 { "xorQ", Ev
, Iv
, XX
},
1268 { "cmpQ", Ev
, Iv
, XX
}
1272 { "addQ", Ev
, sIb
, XX
},
1273 { "orQ", Ev
, sIb
, XX
},
1274 { "adcQ", Ev
, sIb
, XX
},
1275 { "sbbQ", Ev
, sIb
, XX
},
1276 { "andQ", Ev
, sIb
, XX
},
1277 { "subQ", Ev
, sIb
, XX
},
1278 { "xorQ", Ev
, sIb
, XX
},
1279 { "cmpQ", Ev
, sIb
, XX
}
1283 { "rolA", Eb
, Ib
, XX
},
1284 { "rorA", Eb
, Ib
, XX
},
1285 { "rclA", Eb
, Ib
, XX
},
1286 { "rcrA", Eb
, Ib
, XX
},
1287 { "shlA", Eb
, Ib
, XX
},
1288 { "shrA", Eb
, Ib
, XX
},
1289 { "(bad)", XX
, XX
, XX
},
1290 { "sarA", Eb
, Ib
, XX
},
1294 { "rolQ", Ev
, Ib
, XX
},
1295 { "rorQ", Ev
, Ib
, XX
},
1296 { "rclQ", Ev
, Ib
, XX
},
1297 { "rcrQ", Ev
, Ib
, XX
},
1298 { "shlQ", Ev
, Ib
, XX
},
1299 { "shrQ", Ev
, Ib
, XX
},
1300 { "(bad)", XX
, XX
, XX
},
1301 { "sarQ", Ev
, Ib
, XX
},
1305 { "rolA", Eb
, I1
, XX
},
1306 { "rorA", Eb
, I1
, XX
},
1307 { "rclA", Eb
, I1
, XX
},
1308 { "rcrA", Eb
, I1
, XX
},
1309 { "shlA", Eb
, I1
, XX
},
1310 { "shrA", Eb
, I1
, XX
},
1311 { "(bad)", XX
, XX
, XX
},
1312 { "sarA", Eb
, I1
, XX
},
1316 { "rolQ", Ev
, I1
, XX
},
1317 { "rorQ", Ev
, I1
, XX
},
1318 { "rclQ", Ev
, I1
, XX
},
1319 { "rcrQ", Ev
, I1
, XX
},
1320 { "shlQ", Ev
, I1
, XX
},
1321 { "shrQ", Ev
, I1
, XX
},
1322 { "(bad)", XX
, XX
, XX
},
1323 { "sarQ", Ev
, I1
, XX
},
1327 { "rolA", Eb
, CL
, XX
},
1328 { "rorA", Eb
, CL
, XX
},
1329 { "rclA", Eb
, CL
, XX
},
1330 { "rcrA", Eb
, CL
, XX
},
1331 { "shlA", Eb
, CL
, XX
},
1332 { "shrA", Eb
, CL
, XX
},
1333 { "(bad)", XX
, XX
, XX
},
1334 { "sarA", Eb
, CL
, XX
},
1338 { "rolQ", Ev
, CL
, XX
},
1339 { "rorQ", Ev
, CL
, XX
},
1340 { "rclQ", Ev
, CL
, XX
},
1341 { "rcrQ", Ev
, CL
, XX
},
1342 { "shlQ", Ev
, CL
, XX
},
1343 { "shrQ", Ev
, CL
, XX
},
1344 { "(bad)", XX
, XX
, XX
},
1345 { "sarQ", Ev
, CL
, XX
}
1349 { "testA", Eb
, Ib
, XX
},
1350 { "(bad)", Eb
, XX
, XX
},
1351 { "notA", Eb
, XX
, XX
},
1352 { "negA", Eb
, XX
, XX
},
1353 { "mulA", Eb
, XX
, XX
}, /* Don't print the implicit %al register, */
1354 { "imulA", Eb
, XX
, XX
}, /* to distinguish these opcodes from other */
1355 { "divA", Eb
, XX
, XX
}, /* mul/imul opcodes. Do the same for div */
1356 { "idivA", Eb
, XX
, XX
} /* and idiv for consistency. */
1360 { "testQ", Ev
, Iv
, XX
},
1361 { "(bad)", XX
, XX
, XX
},
1362 { "notQ", Ev
, XX
, XX
},
1363 { "negQ", Ev
, XX
, XX
},
1364 { "mulQ", Ev
, XX
, XX
}, /* Don't print the implicit register. */
1365 { "imulQ", Ev
, XX
, XX
},
1366 { "divQ", Ev
, XX
, XX
},
1367 { "idivQ", Ev
, XX
, XX
},
1371 { "incA", Eb
, XX
, XX
},
1372 { "decA", Eb
, XX
, XX
},
1373 { "(bad)", XX
, XX
, XX
},
1374 { "(bad)", XX
, XX
, XX
},
1375 { "(bad)", XX
, XX
, XX
},
1376 { "(bad)", XX
, XX
, XX
},
1377 { "(bad)", XX
, XX
, XX
},
1378 { "(bad)", XX
, XX
, XX
},
1382 { "incQ", Ev
, XX
, XX
},
1383 { "decQ", Ev
, XX
, XX
},
1384 { "callT", indirEv
, XX
, XX
},
1385 { "JcallT", indirEp
, XX
, XX
},
1386 { "jmpT", indirEv
, XX
, XX
},
1387 { "JjmpT", indirEp
, XX
, XX
},
1388 { "pushU", stackEv
, XX
, XX
},
1389 { "(bad)", XX
, XX
, XX
},
1393 { "sldtQ", Ev
, XX
, XX
},
1394 { "strQ", Ev
, XX
, XX
},
1395 { "lldt", Ew
, XX
, XX
},
1396 { "ltr", Ew
, XX
, XX
},
1397 { "verr", Ew
, XX
, XX
},
1398 { "verw", Ew
, XX
, XX
},
1399 { "(bad)", XX
, XX
, XX
},
1400 { "(bad)", XX
, XX
, XX
}
1404 { "sgdt{Q|IQ||}", VMX_Fixup
, 0, XX
, XX
},
1405 { "sidt{Q|IQ||}", PNI_Fixup
, 0, XX
, XX
},
1406 { "lgdt{Q|Q||}", M
, XX
, XX
},
1407 { "lidt{Q|Q||}", SVME_Fixup
, 0, XX
, XX
},
1408 { "smswQ", Ev
, XX
, XX
},
1409 { "(bad)", XX
, XX
, XX
},
1410 { "lmsw", Ew
, XX
, XX
},
1411 { "invlpg", INVLPG_Fixup
, w_mode
, XX
, XX
},
1415 { "(bad)", XX
, XX
, XX
},
1416 { "(bad)", XX
, XX
, XX
},
1417 { "(bad)", XX
, XX
, XX
},
1418 { "(bad)", XX
, XX
, XX
},
1419 { "btQ", Ev
, Ib
, XX
},
1420 { "btsQ", Ev
, Ib
, XX
},
1421 { "btrQ", Ev
, Ib
, XX
},
1422 { "btcQ", Ev
, Ib
, XX
},
1426 { "(bad)", XX
, XX
, XX
},
1427 { "cmpxchg8b", Eq
, XX
, XX
},
1428 { "(bad)", XX
, XX
, XX
},
1429 { "(bad)", XX
, XX
, XX
},
1430 { "(bad)", XX
, XX
, XX
},
1431 { "(bad)", XX
, XX
, XX
},
1432 { "", VM
, XX
, XX
}, /* See OP_VMX. */
1433 { "vmptrst", Eq
, XX
, XX
},
1437 { "(bad)", XX
, XX
, XX
},
1438 { "(bad)", XX
, XX
, XX
},
1439 { "psrlw", MS
, Ib
, XX
},
1440 { "(bad)", XX
, XX
, XX
},
1441 { "psraw", MS
, Ib
, XX
},
1442 { "(bad)", XX
, XX
, XX
},
1443 { "psllw", MS
, Ib
, XX
},
1444 { "(bad)", XX
, XX
, XX
},
1448 { "(bad)", XX
, XX
, XX
},
1449 { "(bad)", XX
, XX
, XX
},
1450 { "psrld", MS
, Ib
, XX
},
1451 { "(bad)", XX
, XX
, XX
},
1452 { "psrad", MS
, Ib
, XX
},
1453 { "(bad)", XX
, XX
, XX
},
1454 { "pslld", MS
, Ib
, XX
},
1455 { "(bad)", XX
, XX
, XX
},
1459 { "(bad)", XX
, XX
, XX
},
1460 { "(bad)", XX
, XX
, XX
},
1461 { "psrlq", MS
, Ib
, XX
},
1462 { "psrldq", MS
, Ib
, XX
},
1463 { "(bad)", XX
, XX
, XX
},
1464 { "(bad)", XX
, XX
, XX
},
1465 { "psllq", MS
, Ib
, XX
},
1466 { "pslldq", MS
, Ib
, XX
},
1470 { "fxsave", Ev
, XX
, XX
},
1471 { "fxrstor", Ev
, XX
, XX
},
1472 { "ldmxcsr", Ev
, XX
, XX
},
1473 { "stmxcsr", Ev
, XX
, XX
},
1474 { "(bad)", XX
, XX
, XX
},
1475 { "lfence", OP_0fae
, 0, XX
, XX
},
1476 { "mfence", OP_0fae
, 0, XX
, XX
},
1477 { "clflush", OP_0fae
, 0, XX
, XX
},
1481 { "prefetchnta", Ev
, XX
, XX
},
1482 { "prefetcht0", Ev
, XX
, XX
},
1483 { "prefetcht1", Ev
, XX
, XX
},
1484 { "prefetcht2", Ev
, XX
, XX
},
1485 { "(bad)", XX
, XX
, XX
},
1486 { "(bad)", XX
, XX
, XX
},
1487 { "(bad)", XX
, XX
, XX
},
1488 { "(bad)", XX
, XX
, XX
},
1492 { "prefetch", Eb
, XX
, XX
},
1493 { "prefetchw", Eb
, XX
, XX
},
1494 { "(bad)", XX
, XX
, XX
},
1495 { "(bad)", XX
, XX
, XX
},
1496 { "(bad)", XX
, XX
, XX
},
1497 { "(bad)", XX
, XX
, XX
},
1498 { "(bad)", XX
, XX
, XX
},
1499 { "(bad)", XX
, XX
, XX
},
1503 { "xstore-rng", OP_0f07
, 0, XX
, XX
},
1504 { "xcrypt-ecb", OP_0f07
, 0, XX
, XX
},
1505 { "xcrypt-cbc", OP_0f07
, 0, XX
, XX
},
1506 { "xcrypt-ctr", OP_0f07
, 0, XX
, XX
},
1507 { "xcrypt-cfb", OP_0f07
, 0, XX
, XX
},
1508 { "xcrypt-ofb", OP_0f07
, 0, XX
, XX
},
1509 { "(bad)", OP_0f07
, 0, XX
, XX
},
1510 { "(bad)", OP_0f07
, 0, XX
, XX
},
1514 { "montmul", OP_0f07
, 0, XX
, XX
},
1515 { "xsha1", OP_0f07
, 0, XX
, XX
},
1516 { "xsha256", OP_0f07
, 0, XX
, XX
},
1517 { "(bad)", OP_0f07
, 0, XX
, XX
},
1518 { "(bad)", OP_0f07
, 0, XX
, XX
},
1519 { "(bad)", OP_0f07
, 0, XX
, XX
},
1520 { "(bad)", OP_0f07
, 0, XX
, XX
},
1521 { "(bad)", OP_0f07
, 0, XX
, XX
},
1525 static const struct dis386 prefix_user_table
[][4] = {
1528 { "addps", XM
, EX
, XX
},
1529 { "addss", XM
, EX
, XX
},
1530 { "addpd", XM
, EX
, XX
},
1531 { "addsd", XM
, EX
, XX
},
1535 { "", XM
, EX
, OPSIMD
}, /* See OP_SIMD_SUFFIX. */
1536 { "", XM
, EX
, OPSIMD
},
1537 { "", XM
, EX
, OPSIMD
},
1538 { "", XM
, EX
, OPSIMD
},
1542 { "cvtpi2ps", XM
, EM
, XX
},
1543 { "cvtsi2ssY", XM
, Ev
, XX
},
1544 { "cvtpi2pd", XM
, EM
, XX
},
1545 { "cvtsi2sdY", XM
, Ev
, XX
},
1549 { "cvtps2pi", MX
, EX
, XX
},
1550 { "cvtss2siY", Gv
, EX
, XX
},
1551 { "cvtpd2pi", MX
, EX
, XX
},
1552 { "cvtsd2siY", Gv
, EX
, XX
},
1556 { "cvttps2pi", MX
, EX
, XX
},
1557 { "cvttss2siY", Gv
, EX
, XX
},
1558 { "cvttpd2pi", MX
, EX
, XX
},
1559 { "cvttsd2siY", Gv
, EX
, XX
},
1563 { "divps", XM
, EX
, XX
},
1564 { "divss", XM
, EX
, XX
},
1565 { "divpd", XM
, EX
, XX
},
1566 { "divsd", XM
, EX
, XX
},
1570 { "maxps", XM
, EX
, XX
},
1571 { "maxss", XM
, EX
, XX
},
1572 { "maxpd", XM
, EX
, XX
},
1573 { "maxsd", XM
, EX
, XX
},
1577 { "minps", XM
, EX
, XX
},
1578 { "minss", XM
, EX
, XX
},
1579 { "minpd", XM
, EX
, XX
},
1580 { "minsd", XM
, EX
, XX
},
1584 { "movups", XM
, EX
, XX
},
1585 { "movss", XM
, EX
, XX
},
1586 { "movupd", XM
, EX
, XX
},
1587 { "movsd", XM
, EX
, XX
},
1591 { "movups", EX
, XM
, XX
},
1592 { "movss", EX
, XM
, XX
},
1593 { "movupd", EX
, XM
, XX
},
1594 { "movsd", EX
, XM
, XX
},
1598 { "mulps", XM
, EX
, XX
},
1599 { "mulss", XM
, EX
, XX
},
1600 { "mulpd", XM
, EX
, XX
},
1601 { "mulsd", XM
, EX
, XX
},
1605 { "rcpps", XM
, EX
, XX
},
1606 { "rcpss", XM
, EX
, XX
},
1607 { "(bad)", XM
, EX
, XX
},
1608 { "(bad)", XM
, EX
, XX
},
1612 { "rsqrtps", XM
, EX
, XX
},
1613 { "rsqrtss", XM
, EX
, XX
},
1614 { "(bad)", XM
, EX
, XX
},
1615 { "(bad)", XM
, EX
, XX
},
1619 { "sqrtps", XM
, EX
, XX
},
1620 { "sqrtss", XM
, EX
, XX
},
1621 { "sqrtpd", XM
, EX
, XX
},
1622 { "sqrtsd", XM
, EX
, XX
},
1626 { "subps", XM
, EX
, XX
},
1627 { "subss", XM
, EX
, XX
},
1628 { "subpd", XM
, EX
, XX
},
1629 { "subsd", XM
, EX
, XX
},
1633 { "(bad)", XM
, EX
, XX
},
1634 { "cvtdq2pd", XM
, EX
, XX
},
1635 { "cvttpd2dq", XM
, EX
, XX
},
1636 { "cvtpd2dq", XM
, EX
, XX
},
1640 { "cvtdq2ps", XM
, EX
, XX
},
1641 { "cvttps2dq",XM
, EX
, XX
},
1642 { "cvtps2dq",XM
, EX
, XX
},
1643 { "(bad)", XM
, EX
, XX
},
1647 { "cvtps2pd", XM
, EX
, XX
},
1648 { "cvtss2sd", XM
, EX
, XX
},
1649 { "cvtpd2ps", XM
, EX
, XX
},
1650 { "cvtsd2ss", XM
, EX
, XX
},
1654 { "maskmovq", MX
, MS
, XX
},
1655 { "(bad)", XM
, EX
, XX
},
1656 { "maskmovdqu", XM
, EX
, XX
},
1657 { "(bad)", XM
, EX
, XX
},
1661 { "movq", MX
, EM
, XX
},
1662 { "movdqu", XM
, EX
, XX
},
1663 { "movdqa", XM
, EX
, XX
},
1664 { "(bad)", XM
, EX
, XX
},
1668 { "movq", EM
, MX
, XX
},
1669 { "movdqu", EX
, XM
, XX
},
1670 { "movdqa", EX
, XM
, XX
},
1671 { "(bad)", EX
, XM
, XX
},
1675 { "(bad)", EX
, XM
, XX
},
1676 { "movq2dq", XM
, MS
, XX
},
1677 { "movq", EX
, XM
, XX
},
1678 { "movdq2q", MX
, XS
, XX
},
1682 { "pshufw", MX
, EM
, Ib
},
1683 { "pshufhw", XM
, EX
, Ib
},
1684 { "pshufd", XM
, EX
, Ib
},
1685 { "pshuflw", XM
, EX
, Ib
},
1689 { "movd", Edq
, MX
, XX
},
1690 { "movq", XM
, EX
, XX
},
1691 { "movd", Edq
, XM
, XX
},
1692 { "(bad)", Ed
, XM
, XX
},
1696 { "(bad)", MX
, EX
, XX
},
1697 { "(bad)", XM
, EX
, XX
},
1698 { "punpckhqdq", XM
, EX
, XX
},
1699 { "(bad)", XM
, EX
, XX
},
1703 { "movntq", EM
, MX
, XX
},
1704 { "(bad)", EM
, XM
, XX
},
1705 { "movntdq", EM
, XM
, XX
},
1706 { "(bad)", EM
, XM
, XX
},
1710 { "(bad)", MX
, EX
, XX
},
1711 { "(bad)", XM
, EX
, XX
},
1712 { "punpcklqdq", XM
, EX
, XX
},
1713 { "(bad)", XM
, EX
, XX
},
1717 { "(bad)", MX
, EX
, XX
},
1718 { "(bad)", XM
, EX
, XX
},
1719 { "addsubpd", XM
, EX
, XX
},
1720 { "addsubps", XM
, EX
, XX
},
1724 { "(bad)", MX
, EX
, XX
},
1725 { "(bad)", XM
, EX
, XX
},
1726 { "haddpd", XM
, EX
, XX
},
1727 { "haddps", XM
, EX
, XX
},
1731 { "(bad)", MX
, EX
, XX
},
1732 { "(bad)", XM
, EX
, XX
},
1733 { "hsubpd", XM
, EX
, XX
},
1734 { "hsubps", XM
, EX
, XX
},
1738 { "movlpX", XM
, EX
, SIMD_Fixup
, 'h' }, /* really only 2 operands */
1739 { "movsldup", XM
, EX
, XX
},
1740 { "movlpd", XM
, EX
, XX
},
1741 { "movddup", XM
, EX
, XX
},
1745 { "movhpX", XM
, EX
, SIMD_Fixup
, 'l' },
1746 { "movshdup", XM
, EX
, XX
},
1747 { "movhpd", XM
, EX
, XX
},
1748 { "(bad)", XM
, EX
, XX
},
1752 { "(bad)", XM
, EX
, XX
},
1753 { "(bad)", XM
, EX
, XX
},
1754 { "(bad)", XM
, EX
, XX
},
1755 { "lddqu", XM
, M
, XX
},
1759 static const struct dis386 x86_64_table
[][2] = {
1761 { "arpl", Ew
, Gw
, XX
},
1762 { "movs{||lq|xd}", Gv
, Ed
, XX
},
1766 static const struct dis386 three_byte_table
[][32] = {
1769 { "pshufb", MX
, EM
, XX
},
1770 { "phaddw", MX
, EM
, XX
},
1771 { "phaddd", MX
, EM
, XX
},
1772 { "phaddsw", MX
, EM
, XX
},
1773 { "pmaddubsw", MX
, EM
, XX
},
1774 { "phsubw", MX
, EM
, XX
},
1775 { "phsubd", MX
, EM
, XX
},
1776 { "phsubsw", MX
, EM
, XX
},
1777 { "psignb", MX
, EM
, XX
},
1778 { "psignw", MX
, EM
, XX
},
1779 { "psignd", MX
, EM
, XX
},
1780 { "pmulhrsw", MX
, EM
, XX
},
1781 { "(bad)", XX
, XX
, XX
},
1782 { "(bad)", XX
, XX
, XX
},
1783 { "(bad)", XX
, XX
, XX
},
1784 { "(bad)", XX
, XX
, XX
},
1785 { "(bad)", XX
, XX
, XX
},
1786 { "(bad)", XX
, XX
, XX
},
1787 { "(bad)", XX
, XX
, XX
},
1788 { "(bad)", XX
, XX
, XX
},
1789 { "(bad)", XX
, XX
, XX
},
1790 { "(bad)", XX
, XX
, XX
},
1791 { "(bad)", XX
, XX
, XX
},
1792 { "(bad)", XX
, XX
, XX
},
1793 { "(bad)", XX
, XX
, XX
},
1794 { "(bad)", XX
, XX
, XX
},
1795 { "(bad)", XX
, XX
, XX
},
1796 { "(bad)", XX
, XX
, XX
},
1797 { "pabsb", MX
, EM
, XX
},
1798 { "pabsw", MX
, EM
, XX
},
1799 { "pabsd", MX
, EM
, XX
},
1800 { "(bad)", XX
, XX
, XX
}
1804 { "(bad)", XX
, XX
, XX
},
1805 { "(bad)", XX
, XX
, XX
},
1806 { "(bad)", XX
, XX
, XX
},
1807 { "(bad)", XX
, XX
, XX
},
1808 { "(bad)", XX
, XX
, XX
},
1809 { "(bad)", XX
, XX
, XX
},
1810 { "(bad)", XX
, XX
, XX
},
1811 { "(bad)", XX
, XX
, XX
},
1812 { "(bad)", XX
, XX
, XX
},
1813 { "(bad)", XX
, XX
, XX
},
1814 { "(bad)", XX
, XX
, XX
},
1815 { "(bad)", XX
, XX
, XX
},
1816 { "(bad)", XX
, XX
, XX
},
1817 { "(bad)", XX
, XX
, XX
},
1818 { "(bad)", XX
, XX
, XX
},
1819 { "palignr", MX
, EM
, Ib
},
1820 { "(bad)", XX
, XX
, XX
},
1821 { "(bad)", XX
, XX
, XX
},
1822 { "(bad)", XX
, XX
, XX
},
1823 { "(bad)", XX
, XX
, XX
},
1824 { "(bad)", XX
, XX
, XX
},
1825 { "(bad)", XX
, XX
, XX
},
1826 { "(bad)", XX
, XX
, XX
},
1827 { "(bad)", XX
, XX
, XX
},
1828 { "(bad)", XX
, XX
, XX
},
1829 { "(bad)", XX
, XX
, XX
},
1830 { "(bad)", XX
, XX
, XX
},
1831 { "(bad)", XX
, XX
, XX
},
1832 { "(bad)", XX
, XX
, XX
},
1833 { "(bad)", XX
, XX
, XX
},
1834 { "(bad)", XX
, XX
, XX
},
1835 { "(bad)", XX
, XX
, XX
}
1839 #define INTERNAL_DISASSEMBLER_ERROR _("<internal disassembler error>")
1851 FETCH_DATA (the_info
, codep
+ 1);
1855 /* REX prefixes family. */
1872 if (address_mode
== mode_64bit
)
1878 prefixes
|= PREFIX_REPZ
;
1881 prefixes
|= PREFIX_REPNZ
;
1884 prefixes
|= PREFIX_LOCK
;
1887 prefixes
|= PREFIX_CS
;
1890 prefixes
|= PREFIX_SS
;
1893 prefixes
|= PREFIX_DS
;
1896 prefixes
|= PREFIX_ES
;
1899 prefixes
|= PREFIX_FS
;
1902 prefixes
|= PREFIX_GS
;
1905 prefixes
|= PREFIX_DATA
;
1908 prefixes
|= PREFIX_ADDR
;
1911 /* fwait is really an instruction. If there are prefixes
1912 before the fwait, they belong to the fwait, *not* to the
1913 following instruction. */
1914 if (prefixes
|| rex
)
1916 prefixes
|= PREFIX_FWAIT
;
1920 prefixes
= PREFIX_FWAIT
;
1925 /* Rex is ignored when followed by another prefix. */
1936 /* Return the name of the prefix byte PREF, or NULL if PREF is not a
1940 prefix_name (int pref
, int sizeflag
)
1944 /* REX prefixes family. */
1996 return (sizeflag
& DFLAG
) ? "data16" : "data32";
1998 if (address_mode
== mode_64bit
)
1999 return (sizeflag
& AFLAG
) ? "addr32" : "addr64";
2001 return (sizeflag
& AFLAG
) ? "addr16" : "addr32";
2009 static char op1out
[100], op2out
[100], op3out
[100];
2010 static int op_ad
, op_index
[3];
2011 static int two_source_ops
;
2012 static bfd_vma op_address
[3];
2013 static bfd_vma op_riprel
[3];
2014 static bfd_vma start_pc
;
2017 * On the 386's of 1988, the maximum length of an instruction is 15 bytes.
2018 * (see topic "Redundant prefixes" in the "Differences from 8086"
2019 * section of the "Virtual 8086 Mode" chapter.)
2020 * 'pc' should be the address of this instruction, it will
2021 * be used to print the target address if this is a relative jump or call
2022 * The function returns the length of this instruction in bytes.
2025 static char intel_syntax
;
2026 static char open_char
;
2027 static char close_char
;
2028 static char separator_char
;
2029 static char scale_char
;
2031 /* Here for backwards compatibility. When gdb stops using
2032 print_insn_i386_att and print_insn_i386_intel these functions can
2033 disappear, and print_insn_i386 be merged into print_insn. */
2035 print_insn_i386_att (bfd_vma pc
, disassemble_info
*info
)
2039 return print_insn (pc
, info
);
2043 print_insn_i386_intel (bfd_vma pc
, disassemble_info
*info
)
2047 return print_insn (pc
, info
);
2051 print_insn_i386 (bfd_vma pc
, disassemble_info
*info
)
2055 return print_insn (pc
, info
);
2059 print_insn (bfd_vma pc
, disassemble_info
*info
)
2061 const struct dis386
*dp
;
2063 char *first
, *second
, *third
;
2065 unsigned char uses_SSE_prefix
, uses_LOCK_prefix
;
2068 struct dis_private priv
;
2070 if (info
->mach
== bfd_mach_x86_64_intel_syntax
2071 || info
->mach
== bfd_mach_x86_64
)
2072 address_mode
= mode_64bit
;
2074 address_mode
= mode_32bit
;
2076 if (intel_syntax
== (char) -1)
2077 intel_syntax
= (info
->mach
== bfd_mach_i386_i386_intel_syntax
2078 || info
->mach
== bfd_mach_x86_64_intel_syntax
);
2080 if (info
->mach
== bfd_mach_i386_i386
2081 || info
->mach
== bfd_mach_x86_64
2082 || info
->mach
== bfd_mach_i386_i386_intel_syntax
2083 || info
->mach
== bfd_mach_x86_64_intel_syntax
)
2084 priv
.orig_sizeflag
= AFLAG
| DFLAG
;
2085 else if (info
->mach
== bfd_mach_i386_i8086
)
2086 priv
.orig_sizeflag
= 0;
2090 for (p
= info
->disassembler_options
; p
!= NULL
; )
2092 if (strncmp (p
, "x86-64", 6) == 0)
2094 address_mode
= mode_64bit
;
2095 priv
.orig_sizeflag
= AFLAG
| DFLAG
;
2097 else if (strncmp (p
, "i386", 4) == 0)
2099 address_mode
= mode_32bit
;
2100 priv
.orig_sizeflag
= AFLAG
| DFLAG
;
2102 else if (strncmp (p
, "i8086", 5) == 0)
2104 address_mode
= mode_16bit
;
2105 priv
.orig_sizeflag
= 0;
2107 else if (strncmp (p
, "intel", 5) == 0)
2111 else if (strncmp (p
, "att", 3) == 0)
2115 else if (strncmp (p
, "addr", 4) == 0)
2117 if (p
[4] == '1' && p
[5] == '6')
2118 priv
.orig_sizeflag
&= ~AFLAG
;
2119 else if (p
[4] == '3' && p
[5] == '2')
2120 priv
.orig_sizeflag
|= AFLAG
;
2122 else if (strncmp (p
, "data", 4) == 0)
2124 if (p
[4] == '1' && p
[5] == '6')
2125 priv
.orig_sizeflag
&= ~DFLAG
;
2126 else if (p
[4] == '3' && p
[5] == '2')
2127 priv
.orig_sizeflag
|= DFLAG
;
2129 else if (strncmp (p
, "suffix", 6) == 0)
2130 priv
.orig_sizeflag
|= SUFFIX_ALWAYS
;
2132 p
= strchr (p
, ',');
2139 names64
= intel_names64
;
2140 names32
= intel_names32
;
2141 names16
= intel_names16
;
2142 names8
= intel_names8
;
2143 names8rex
= intel_names8rex
;
2144 names_seg
= intel_names_seg
;
2145 index16
= intel_index16
;
2148 separator_char
= '+';
2153 names64
= att_names64
;
2154 names32
= att_names32
;
2155 names16
= att_names16
;
2156 names8
= att_names8
;
2157 names8rex
= att_names8rex
;
2158 names_seg
= att_names_seg
;
2159 index16
= att_index16
;
2162 separator_char
= ',';
2166 /* The output looks better if we put 7 bytes on a line, since that
2167 puts most long word instructions on a single line. */
2168 info
->bytes_per_line
= 7;
2170 info
->private_data
= &priv
;
2171 priv
.max_fetched
= priv
.the_buffer
;
2172 priv
.insn_start
= pc
;
2179 op_index
[0] = op_index
[1] = op_index
[2] = -1;
2183 start_codep
= priv
.the_buffer
;
2184 codep
= priv
.the_buffer
;
2186 if (setjmp (priv
.bailout
) != 0)
2190 /* Getting here means we tried for data but didn't get it. That
2191 means we have an incomplete instruction of some sort. Just
2192 print the first byte as a prefix or a .byte pseudo-op. */
2193 if (codep
> priv
.the_buffer
)
2195 name
= prefix_name (priv
.the_buffer
[0], priv
.orig_sizeflag
);
2197 (*info
->fprintf_func
) (info
->stream
, "%s", name
);
2200 /* Just print the first byte as a .byte instruction. */
2201 (*info
->fprintf_func
) (info
->stream
, ".byte 0x%x",
2202 (unsigned int) priv
.the_buffer
[0]);
2215 sizeflag
= priv
.orig_sizeflag
;
2217 FETCH_DATA (info
, codep
+ 1);
2218 two_source_ops
= (*codep
== 0x62) || (*codep
== 0xc8);
2220 if (((prefixes
& PREFIX_FWAIT
)
2221 && ((*codep
< 0xd8) || (*codep
> 0xdf)))
2222 || (rex
&& rex_used
))
2226 /* fwait not followed by floating point instruction, or rex followed
2227 by other prefixes. Print the first prefix. */
2228 name
= prefix_name (priv
.the_buffer
[0], priv
.orig_sizeflag
);
2230 name
= INTERNAL_DISASSEMBLER_ERROR
;
2231 (*info
->fprintf_func
) (info
->stream
, "%s", name
);
2237 FETCH_DATA (info
, codep
+ 2);
2238 dp
= &dis386_twobyte
[*++codep
];
2239 need_modrm
= twobyte_has_modrm
[*codep
];
2240 uses_SSE_prefix
= twobyte_uses_SSE_prefix
[*codep
];
2241 uses_LOCK_prefix
= (*codep
& ~0x02) == 0x20;
2245 dp
= &dis386
[*codep
];
2246 need_modrm
= onebyte_has_modrm
[*codep
];
2247 uses_SSE_prefix
= 0;
2248 uses_LOCK_prefix
= 0;
2252 if (!uses_SSE_prefix
&& (prefixes
& PREFIX_REPZ
))
2255 used_prefixes
|= PREFIX_REPZ
;
2257 if (!uses_SSE_prefix
&& (prefixes
& PREFIX_REPNZ
))
2260 used_prefixes
|= PREFIX_REPNZ
;
2262 if (!uses_LOCK_prefix
&& (prefixes
& PREFIX_LOCK
))
2265 used_prefixes
|= PREFIX_LOCK
;
2268 if (prefixes
& PREFIX_ADDR
)
2271 if (dp
->bytemode3
!= loop_jcxz_mode
|| intel_syntax
)
2273 if ((sizeflag
& AFLAG
) || address_mode
== mode_64bit
)
2274 oappend ("addr32 ");
2276 oappend ("addr16 ");
2277 used_prefixes
|= PREFIX_ADDR
;
2281 if (!uses_SSE_prefix
&& (prefixes
& PREFIX_DATA
))
2284 if (dp
->bytemode3
== cond_jump_mode
2285 && dp
->bytemode1
== v_mode
2288 if (sizeflag
& DFLAG
)
2289 oappend ("data32 ");
2291 oappend ("data16 ");
2292 used_prefixes
|= PREFIX_DATA
;
2296 if (dp
->name
== NULL
&& dp
->bytemode1
== IS_3BYTE_OPCODE
)
2298 FETCH_DATA (info
, codep
+ 2);
2299 dp
= &three_byte_table
[dp
->bytemode2
][*codep
++];
2300 mod
= (*codep
>> 6) & 3;
2301 reg
= (*codep
>> 3) & 7;
2304 else if (need_modrm
)
2306 FETCH_DATA (info
, codep
+ 1);
2307 mod
= (*codep
>> 6) & 3;
2308 reg
= (*codep
>> 3) & 7;
2312 if (dp
->name
== NULL
&& dp
->bytemode1
== FLOATCODE
)
2319 if (dp
->name
== NULL
)
2321 switch (dp
->bytemode1
)
2324 dp
= &grps
[dp
->bytemode2
][reg
];
2327 case USE_PREFIX_USER_TABLE
:
2329 used_prefixes
|= (prefixes
& PREFIX_REPZ
);
2330 if (prefixes
& PREFIX_REPZ
)
2334 used_prefixes
|= (prefixes
& PREFIX_DATA
);
2335 if (prefixes
& PREFIX_DATA
)
2339 used_prefixes
|= (prefixes
& PREFIX_REPNZ
);
2340 if (prefixes
& PREFIX_REPNZ
)
2344 dp
= &prefix_user_table
[dp
->bytemode2
][index
];
2347 case X86_64_SPECIAL
:
2348 index
= address_mode
== mode_64bit
? 1 : 0;
2349 dp
= &x86_64_table
[dp
->bytemode2
][index
];
2353 oappend (INTERNAL_DISASSEMBLER_ERROR
);
2358 if (putop (dp
->name
, sizeflag
) == 0)
2363 (*dp
->op1
) (dp
->bytemode1
, sizeflag
);
2368 (*dp
->op2
) (dp
->bytemode2
, sizeflag
);
2373 (*dp
->op3
) (dp
->bytemode3
, sizeflag
);
2377 /* See if any prefixes were not used. If so, print the first one
2378 separately. If we don't do this, we'll wind up printing an
2379 instruction stream which does not precisely correspond to the
2380 bytes we are disassembling. */
2381 if ((prefixes
& ~used_prefixes
) != 0)
2385 name
= prefix_name (priv
.the_buffer
[0], priv
.orig_sizeflag
);
2387 name
= INTERNAL_DISASSEMBLER_ERROR
;
2388 (*info
->fprintf_func
) (info
->stream
, "%s", name
);
2391 if (rex
& ~rex_used
)
2394 name
= prefix_name (rex
| 0x40, priv
.orig_sizeflag
);
2396 name
= INTERNAL_DISASSEMBLER_ERROR
;
2397 (*info
->fprintf_func
) (info
->stream
, "%s ", name
);
2400 obufp
= obuf
+ strlen (obuf
);
2401 for (i
= strlen (obuf
); i
< 6; i
++)
2404 (*info
->fprintf_func
) (info
->stream
, "%s", obuf
);
2406 /* The enter and bound instructions are printed with operands in the same
2407 order as the intel book; everything else is printed in reverse order. */
2408 if (intel_syntax
|| two_source_ops
)
2413 op_ad
= op_index
[0];
2414 op_index
[0] = op_index
[2];
2415 op_index
[2] = op_ad
;
2426 if (op_index
[0] != -1 && !op_riprel
[0])
2427 (*info
->print_address_func
) ((bfd_vma
) op_address
[op_index
[0]], info
);
2429 (*info
->fprintf_func
) (info
->stream
, "%s", first
);
2435 (*info
->fprintf_func
) (info
->stream
, ",");
2436 if (op_index
[1] != -1 && !op_riprel
[1])
2437 (*info
->print_address_func
) ((bfd_vma
) op_address
[op_index
[1]], info
);
2439 (*info
->fprintf_func
) (info
->stream
, "%s", second
);
2445 (*info
->fprintf_func
) (info
->stream
, ",");
2446 if (op_index
[2] != -1 && !op_riprel
[2])
2447 (*info
->print_address_func
) ((bfd_vma
) op_address
[op_index
[2]], info
);
2449 (*info
->fprintf_func
) (info
->stream
, "%s", third
);
2451 for (i
= 0; i
< 3; i
++)
2452 if (op_index
[i
] != -1 && op_riprel
[i
])
2454 (*info
->fprintf_func
) (info
->stream
, " # ");
2455 (*info
->print_address_func
) ((bfd_vma
) (start_pc
+ codep
- start_codep
2456 + op_address
[op_index
[i
]]), info
);
2458 return codep
- priv
.the_buffer
;
2461 static const char *float_mem
[] = {
2536 static const unsigned char float_mem_mode
[] = {
2612 #define STi OP_STi, 0
2614 #define FGRPd9_2 NULL, NULL, 0, NULL, 0, NULL, 0
2615 #define FGRPd9_4 NULL, NULL, 1, NULL, 0, NULL, 0
2616 #define FGRPd9_5 NULL, NULL, 2, NULL, 0, NULL, 0
2617 #define FGRPd9_6 NULL, NULL, 3, NULL, 0, NULL, 0
2618 #define FGRPd9_7 NULL, NULL, 4, NULL, 0, NULL, 0
2619 #define FGRPda_5 NULL, NULL, 5, NULL, 0, NULL, 0
2620 #define FGRPdb_4 NULL, NULL, 6, NULL, 0, NULL, 0
2621 #define FGRPde_3 NULL, NULL, 7, NULL, 0, NULL, 0
2622 #define FGRPdf_4 NULL, NULL, 8, NULL, 0, NULL, 0
2624 static const struct dis386 float_reg
[][8] = {
2627 { "fadd", ST
, STi
, XX
},
2628 { "fmul", ST
, STi
, XX
},
2629 { "fcom", STi
, XX
, XX
},
2630 { "fcomp", STi
, XX
, XX
},
2631 { "fsub", ST
, STi
, XX
},
2632 { "fsubr", ST
, STi
, XX
},
2633 { "fdiv", ST
, STi
, XX
},
2634 { "fdivr", ST
, STi
, XX
},
2638 { "fld", STi
, XX
, XX
},
2639 { "fxch", STi
, XX
, XX
},
2641 { "(bad)", XX
, XX
, XX
},
2649 { "fcmovb", ST
, STi
, XX
},
2650 { "fcmove", ST
, STi
, XX
},
2651 { "fcmovbe",ST
, STi
, XX
},
2652 { "fcmovu", ST
, STi
, XX
},
2653 { "(bad)", XX
, XX
, XX
},
2655 { "(bad)", XX
, XX
, XX
},
2656 { "(bad)", XX
, XX
, XX
},
2660 { "fcmovnb",ST
, STi
, XX
},
2661 { "fcmovne",ST
, STi
, XX
},
2662 { "fcmovnbe",ST
, STi
, XX
},
2663 { "fcmovnu",ST
, STi
, XX
},
2665 { "fucomi", ST
, STi
, XX
},
2666 { "fcomi", ST
, STi
, XX
},
2667 { "(bad)", XX
, XX
, XX
},
2671 { "fadd", STi
, ST
, XX
},
2672 { "fmul", STi
, ST
, XX
},
2673 { "(bad)", XX
, XX
, XX
},
2674 { "(bad)", XX
, XX
, XX
},
2676 { "fsub", STi
, ST
, XX
},
2677 { "fsubr", STi
, ST
, XX
},
2678 { "fdiv", STi
, ST
, XX
},
2679 { "fdivr", STi
, ST
, XX
},
2681 { "fsubr", STi
, ST
, XX
},
2682 { "fsub", STi
, ST
, XX
},
2683 { "fdivr", STi
, ST
, XX
},
2684 { "fdiv", STi
, ST
, XX
},
2689 { "ffree", STi
, XX
, XX
},
2690 { "(bad)", XX
, XX
, XX
},
2691 { "fst", STi
, XX
, XX
},
2692 { "fstp", STi
, XX
, XX
},
2693 { "fucom", STi
, XX
, XX
},
2694 { "fucomp", STi
, XX
, XX
},
2695 { "(bad)", XX
, XX
, XX
},
2696 { "(bad)", XX
, XX
, XX
},
2700 { "faddp", STi
, ST
, XX
},
2701 { "fmulp", STi
, ST
, XX
},
2702 { "(bad)", XX
, XX
, XX
},
2705 { "fsubp", STi
, ST
, XX
},
2706 { "fsubrp", STi
, ST
, XX
},
2707 { "fdivp", STi
, ST
, XX
},
2708 { "fdivrp", STi
, ST
, XX
},
2710 { "fsubrp", STi
, ST
, XX
},
2711 { "fsubp", STi
, ST
, XX
},
2712 { "fdivrp", STi
, ST
, XX
},
2713 { "fdivp", STi
, ST
, XX
},
2718 { "ffreep", STi
, XX
, XX
},
2719 { "(bad)", XX
, XX
, XX
},
2720 { "(bad)", XX
, XX
, XX
},
2721 { "(bad)", XX
, XX
, XX
},
2723 { "fucomip",ST
, STi
, XX
},
2724 { "fcomip", ST
, STi
, XX
},
2725 { "(bad)", XX
, XX
, XX
},
2729 static char *fgrps
[][8] = {
2732 "fnop","(bad)","(bad)","(bad)","(bad)","(bad)","(bad)","(bad)",
2737 "fchs","fabs","(bad)","(bad)","ftst","fxam","(bad)","(bad)",
2742 "fld1","fldl2t","fldl2e","fldpi","fldlg2","fldln2","fldz","(bad)",
2747 "f2xm1","fyl2x","fptan","fpatan","fxtract","fprem1","fdecstp","fincstp",
2752 "fprem","fyl2xp1","fsqrt","fsincos","frndint","fscale","fsin","fcos",
2757 "(bad)","fucompp","(bad)","(bad)","(bad)","(bad)","(bad)","(bad)",
2762 "feni(287 only)","fdisi(287 only)","fNclex","fNinit",
2763 "fNsetpm(287 only)","(bad)","(bad)","(bad)",
2768 "(bad)","fcompp","(bad)","(bad)","(bad)","(bad)","(bad)","(bad)",
2773 "fNstsw","(bad)","(bad)","(bad)","(bad)","(bad)","(bad)","(bad)",
2778 dofloat (int sizeflag
)
2780 const struct dis386
*dp
;
2781 unsigned char floatop
;
2783 floatop
= codep
[-1];
2787 int fp_indx
= (floatop
- 0xd8) * 8 + reg
;
2789 putop (float_mem
[fp_indx
], sizeflag
);
2792 OP_E (float_mem_mode
[fp_indx
], sizeflag
);
2795 /* Skip mod/rm byte. */
2799 dp
= &float_reg
[floatop
- 0xd8][reg
];
2800 if (dp
->name
== NULL
)
2802 putop (fgrps
[dp
->bytemode1
][rm
], sizeflag
);
2804 /* Instruction fnstsw is only one with strange arg. */
2805 if (floatop
== 0xdf && codep
[-1] == 0xe0)
2806 strcpy (op1out
, names16
[0]);
2810 putop (dp
->name
, sizeflag
);
2815 (*dp
->op1
) (dp
->bytemode1
, sizeflag
);
2820 (*dp
->op2
) (dp
->bytemode2
, sizeflag
);
2825 OP_ST (int bytemode ATTRIBUTE_UNUSED
, int sizeflag ATTRIBUTE_UNUSED
)
2827 oappend ("%st" + intel_syntax
);
2831 OP_STi (int bytemode ATTRIBUTE_UNUSED
, int sizeflag ATTRIBUTE_UNUSED
)
2833 sprintf (scratchbuf
, "%%st(%d)", rm
);
2834 oappend (scratchbuf
+ intel_syntax
);
2837 /* Capital letters in template are macros. */
2839 putop (const char *template, int sizeflag
)
2844 for (p
= template; *p
; p
++)
2855 if (address_mode
== mode_64bit
)
2863 /* Alternative not valid. */
2864 strcpy (obuf
, "(bad)");
2868 else if (*p
== '\0')
2889 if (mod
!= 3 || (sizeflag
& SUFFIX_ALWAYS
))
2895 if (sizeflag
& SUFFIX_ALWAYS
)
2899 if (intel_syntax
&& !alt
)
2901 if ((prefixes
& PREFIX_DATA
) || (sizeflag
& SUFFIX_ALWAYS
))
2903 if (sizeflag
& DFLAG
)
2904 *obufp
++ = intel_syntax
? 'd' : 'l';
2906 *obufp
++ = intel_syntax
? 'w' : 's';
2907 used_prefixes
|= (prefixes
& PREFIX_DATA
);
2910 case 'E': /* For jcxz/jecxz */
2911 if (address_mode
== mode_64bit
)
2913 if (sizeflag
& AFLAG
)
2919 if (sizeflag
& AFLAG
)
2921 used_prefixes
|= (prefixes
& PREFIX_ADDR
);
2926 if ((prefixes
& PREFIX_ADDR
) || (sizeflag
& SUFFIX_ALWAYS
))
2928 if (sizeflag
& AFLAG
)
2929 *obufp
++ = address_mode
== mode_64bit
? 'q' : 'l';
2931 *obufp
++ = address_mode
== mode_64bit
? 'l' : 'w';
2932 used_prefixes
|= (prefixes
& PREFIX_ADDR
);
2938 if ((prefixes
& (PREFIX_CS
| PREFIX_DS
)) == PREFIX_CS
2939 || (prefixes
& (PREFIX_CS
| PREFIX_DS
)) == PREFIX_DS
)
2941 used_prefixes
|= prefixes
& (PREFIX_CS
| PREFIX_DS
);
2944 if (prefixes
& PREFIX_DS
)
2958 if (address_mode
== mode_64bit
&& (sizeflag
& SUFFIX_ALWAYS
))
2967 if (sizeflag
& SUFFIX_ALWAYS
)
2971 if ((prefixes
& PREFIX_FWAIT
) == 0)
2974 used_prefixes
|= PREFIX_FWAIT
;
2977 USED_REX (REX_MODE64
);
2978 if (rex
& REX_MODE64
)
2986 if (address_mode
== mode_64bit
&& (sizeflag
& DFLAG
))
2995 if ((prefixes
& PREFIX_DATA
)
2996 || (rex
& REX_MODE64
)
2997 || (sizeflag
& SUFFIX_ALWAYS
))
2999 USED_REX (REX_MODE64
);
3000 if (rex
& REX_MODE64
)
3004 if (sizeflag
& DFLAG
)
3009 used_prefixes
|= (prefixes
& PREFIX_DATA
);
3015 if (address_mode
== mode_64bit
&& (sizeflag
& DFLAG
))
3017 if (mod
!= 3 || (sizeflag
& SUFFIX_ALWAYS
))
3023 if (intel_syntax
&& !alt
)
3025 USED_REX (REX_MODE64
);
3026 if (mod
!= 3 || (sizeflag
& SUFFIX_ALWAYS
))
3028 if (rex
& REX_MODE64
)
3032 if (sizeflag
& DFLAG
)
3033 *obufp
++ = intel_syntax
? 'd' : 'l';
3037 used_prefixes
|= (prefixes
& PREFIX_DATA
);
3041 USED_REX (REX_MODE64
);
3044 if (rex
& REX_MODE64
)
3049 else if (sizeflag
& DFLAG
)
3062 if (rex
& REX_MODE64
)
3064 else if (sizeflag
& DFLAG
)
3069 if (!(rex
& REX_MODE64
))
3070 used_prefixes
|= (prefixes
& PREFIX_DATA
);
3075 if (address_mode
== mode_64bit
&& (sizeflag
& DFLAG
))
3077 if (sizeflag
& SUFFIX_ALWAYS
)
3085 if (sizeflag
& SUFFIX_ALWAYS
)
3087 if (rex
& REX_MODE64
)
3091 if (sizeflag
& DFLAG
)
3095 used_prefixes
|= (prefixes
& PREFIX_DATA
);
3100 if (prefixes
& PREFIX_DATA
)
3104 used_prefixes
|= (prefixes
& PREFIX_DATA
);
3109 if (rex
& REX_MODE64
)
3111 USED_REX (REX_MODE64
);
3115 /* implicit operand size 'l' for i386 or 'q' for x86-64 */
3117 /* operand size flag for cwtl, cbtw */
3121 else if (sizeflag
& DFLAG
)
3132 if (sizeflag
& DFLAG
)
3143 used_prefixes
|= (prefixes
& PREFIX_DATA
);
3153 oappend (const char *s
)
3156 obufp
+= strlen (s
);
3162 if (prefixes
& PREFIX_CS
)
3164 used_prefixes
|= PREFIX_CS
;
3165 oappend ("%cs:" + intel_syntax
);
3167 if (prefixes
& PREFIX_DS
)
3169 used_prefixes
|= PREFIX_DS
;
3170 oappend ("%ds:" + intel_syntax
);
3172 if (prefixes
& PREFIX_SS
)
3174 used_prefixes
|= PREFIX_SS
;
3175 oappend ("%ss:" + intel_syntax
);
3177 if (prefixes
& PREFIX_ES
)
3179 used_prefixes
|= PREFIX_ES
;
3180 oappend ("%es:" + intel_syntax
);
3182 if (prefixes
& PREFIX_FS
)
3184 used_prefixes
|= PREFIX_FS
;
3185 oappend ("%fs:" + intel_syntax
);
3187 if (prefixes
& PREFIX_GS
)
3189 used_prefixes
|= PREFIX_GS
;
3190 oappend ("%gs:" + intel_syntax
);
3195 OP_indirE (int bytemode
, int sizeflag
)
3199 OP_E (bytemode
, sizeflag
);
3203 print_operand_value (char *buf
, int hex
, bfd_vma disp
)
3205 if (address_mode
== mode_64bit
)
3213 sprintf_vma (tmp
, disp
);
3214 for (i
= 0; tmp
[i
] == '0' && tmp
[i
+ 1]; i
++);
3215 strcpy (buf
+ 2, tmp
+ i
);
3219 bfd_signed_vma v
= disp
;
3226 /* Check for possible overflow on 0x8000000000000000. */
3229 strcpy (buf
, "9223372036854775808");
3243 tmp
[28 - i
] = (v
% 10) + '0';
3247 strcpy (buf
, tmp
+ 29 - i
);
3253 sprintf (buf
, "0x%x", (unsigned int) disp
);
3255 sprintf (buf
, "%d", (int) disp
);
3260 intel_operand_size (int bytemode
, int sizeflag
)
3265 oappend ("BYTE PTR ");
3269 oappend ("WORD PTR ");
3272 if (address_mode
== mode_64bit
&& (sizeflag
& DFLAG
))
3274 oappend ("QWORD PTR ");
3275 used_prefixes
|= (prefixes
& PREFIX_DATA
);
3281 USED_REX (REX_MODE64
);
3282 if (rex
& REX_MODE64
)
3283 oappend ("QWORD PTR ");
3284 else if ((sizeflag
& DFLAG
) || bytemode
== dq_mode
)
3285 oappend ("DWORD PTR ");
3287 oappend ("WORD PTR ");
3288 used_prefixes
|= (prefixes
& PREFIX_DATA
);
3291 oappend ("DWORD PTR ");
3294 oappend ("QWORD PTR ");
3297 if (address_mode
== mode_64bit
)
3298 oappend ("QWORD PTR ");
3300 oappend ("DWORD PTR ");
3303 if (sizeflag
& DFLAG
)
3304 oappend ("FWORD PTR ");
3306 oappend ("DWORD PTR ");
3307 used_prefixes
|= (prefixes
& PREFIX_DATA
);
3310 oappend ("TBYTE PTR ");
3313 oappend ("XMMWORD PTR ");
3321 OP_E (int bytemode
, int sizeflag
)
3326 USED_REX (REX_EXTZ
);
3330 /* Skip mod/rm byte. */
3341 oappend (names8rex
[rm
+ add
]);
3343 oappend (names8
[rm
+ add
]);
3346 oappend (names16
[rm
+ add
]);
3349 oappend (names32
[rm
+ add
]);
3352 oappend (names64
[rm
+ add
]);
3355 if (address_mode
== mode_64bit
)
3356 oappend (names64
[rm
+ add
]);
3358 oappend (names32
[rm
+ add
]);
3361 if (address_mode
== mode_64bit
&& (sizeflag
& DFLAG
))
3363 oappend (names64
[rm
+ add
]);
3364 used_prefixes
|= (prefixes
& PREFIX_DATA
);
3372 USED_REX (REX_MODE64
);
3373 if (rex
& REX_MODE64
)
3374 oappend (names64
[rm
+ add
]);
3375 else if ((sizeflag
& DFLAG
) || bytemode
!= v_mode
)
3376 oappend (names32
[rm
+ add
]);
3378 oappend (names16
[rm
+ add
]);
3379 used_prefixes
|= (prefixes
& PREFIX_DATA
);
3384 oappend (INTERNAL_DISASSEMBLER_ERROR
);
3392 intel_operand_size (bytemode
, sizeflag
);
3395 if ((sizeflag
& AFLAG
) || address_mode
== mode_64bit
) /* 32 bit address mode */
3410 FETCH_DATA (the_info
, codep
+ 1);
3411 index
= (*codep
>> 3) & 7;
3412 if (address_mode
== mode_64bit
|| index
!= 0x4)
3413 /* When INDEX == 0x4 in 32 bit mode, SCALE is ignored. */
3414 scale
= (*codep
>> 6) & 3;
3416 USED_REX (REX_EXTY
);
3426 if ((base
& 7) == 5)
3429 if (address_mode
== mode_64bit
&& !havesib
)
3435 FETCH_DATA (the_info
, codep
+ 1);
3437 if ((disp
& 0x80) != 0)
3446 if (mod
!= 0 || (base
& 7) == 5)
3448 print_operand_value (scratchbuf
, !riprel
, disp
);
3449 oappend (scratchbuf
);
3457 if (havebase
|| (havesib
&& (index
!= 4 || scale
!= 0)))
3459 *obufp
++ = open_char
;
3460 if (intel_syntax
&& riprel
)
3464 oappend (address_mode
== mode_64bit
&& (sizeflag
& AFLAG
)
3465 ? names64
[base
] : names32
[base
]);
3470 if (!intel_syntax
|| havebase
)
3472 *obufp
++ = separator_char
;
3475 oappend (address_mode
== mode_64bit
&& (sizeflag
& AFLAG
)
3476 ? names64
[index
] : names32
[index
]);
3478 if (scale
!= 0 || (!intel_syntax
&& index
!= 4))
3480 *obufp
++ = scale_char
;
3482 sprintf (scratchbuf
, "%d", 1 << scale
);
3483 oappend (scratchbuf
);
3486 if (intel_syntax
&& disp
)
3488 if ((bfd_signed_vma
) disp
> 0)
3497 disp
= - (bfd_signed_vma
) disp
;
3500 print_operand_value (scratchbuf
, mod
!= 1, disp
);
3501 oappend (scratchbuf
);
3504 *obufp
++ = close_char
;
3507 else if (intel_syntax
)
3509 if (mod
!= 0 || (base
& 7) == 5)
3511 if (prefixes
& (PREFIX_CS
| PREFIX_SS
| PREFIX_DS
3512 | PREFIX_ES
| PREFIX_FS
| PREFIX_GS
))
3516 oappend (names_seg
[ds_reg
- es_reg
]);
3519 print_operand_value (scratchbuf
, 1, disp
);
3520 oappend (scratchbuf
);
3525 { /* 16 bit address mode */
3532 if ((disp
& 0x8000) != 0)
3537 FETCH_DATA (the_info
, codep
+ 1);
3539 if ((disp
& 0x80) != 0)
3544 if ((disp
& 0x8000) != 0)
3550 if (mod
!= 0 || rm
== 6)
3552 print_operand_value (scratchbuf
, 0, disp
);
3553 oappend (scratchbuf
);
3556 if (mod
!= 0 || rm
!= 6)
3558 *obufp
++ = open_char
;
3560 oappend (index16
[rm
]);
3561 if (intel_syntax
&& disp
)
3563 if ((bfd_signed_vma
) disp
> 0)
3572 disp
= - (bfd_signed_vma
) disp
;
3575 print_operand_value (scratchbuf
, mod
!= 1, disp
);
3576 oappend (scratchbuf
);
3579 *obufp
++ = close_char
;
3582 else if (intel_syntax
)
3584 if (prefixes
& (PREFIX_CS
| PREFIX_SS
| PREFIX_DS
3585 | PREFIX_ES
| PREFIX_FS
| PREFIX_GS
))
3589 oappend (names_seg
[ds_reg
- es_reg
]);
3592 print_operand_value (scratchbuf
, 1, disp
& 0xffff);
3593 oappend (scratchbuf
);
3599 OP_G (int bytemode
, int sizeflag
)
3602 USED_REX (REX_EXTX
);
3610 oappend (names8rex
[reg
+ add
]);
3612 oappend (names8
[reg
+ add
]);
3615 oappend (names16
[reg
+ add
]);
3618 oappend (names32
[reg
+ add
]);
3621 oappend (names64
[reg
+ add
]);
3626 USED_REX (REX_MODE64
);
3627 if (rex
& REX_MODE64
)
3628 oappend (names64
[reg
+ add
]);
3629 else if ((sizeflag
& DFLAG
) || bytemode
!= v_mode
)
3630 oappend (names32
[reg
+ add
]);
3632 oappend (names16
[reg
+ add
]);
3633 used_prefixes
|= (prefixes
& PREFIX_DATA
);
3636 if (address_mode
== mode_64bit
)
3637 oappend (names64
[reg
+ add
]);
3639 oappend (names32
[reg
+ add
]);
3642 oappend (INTERNAL_DISASSEMBLER_ERROR
);
3655 FETCH_DATA (the_info
, codep
+ 8);
3656 a
= *codep
++ & 0xff;
3657 a
|= (*codep
++ & 0xff) << 8;
3658 a
|= (*codep
++ & 0xff) << 16;
3659 a
|= (*codep
++ & 0xff) << 24;
3660 b
= *codep
++ & 0xff;
3661 b
|= (*codep
++ & 0xff) << 8;
3662 b
|= (*codep
++ & 0xff) << 16;
3663 b
|= (*codep
++ & 0xff) << 24;
3664 x
= a
+ ((bfd_vma
) b
<< 32);
3672 static bfd_signed_vma
3675 bfd_signed_vma x
= 0;
3677 FETCH_DATA (the_info
, codep
+ 4);
3678 x
= *codep
++ & (bfd_signed_vma
) 0xff;
3679 x
|= (*codep
++ & (bfd_signed_vma
) 0xff) << 8;
3680 x
|= (*codep
++ & (bfd_signed_vma
) 0xff) << 16;
3681 x
|= (*codep
++ & (bfd_signed_vma
) 0xff) << 24;
3685 static bfd_signed_vma
3688 bfd_signed_vma x
= 0;
3690 FETCH_DATA (the_info
, codep
+ 4);
3691 x
= *codep
++ & (bfd_signed_vma
) 0xff;
3692 x
|= (*codep
++ & (bfd_signed_vma
) 0xff) << 8;
3693 x
|= (*codep
++ & (bfd_signed_vma
) 0xff) << 16;
3694 x
|= (*codep
++ & (bfd_signed_vma
) 0xff) << 24;
3696 x
= (x
^ ((bfd_signed_vma
) 1 << 31)) - ((bfd_signed_vma
) 1 << 31);
3706 FETCH_DATA (the_info
, codep
+ 2);
3707 x
= *codep
++ & 0xff;
3708 x
|= (*codep
++ & 0xff) << 8;
3713 set_op (bfd_vma op
, int riprel
)
3715 op_index
[op_ad
] = op_ad
;
3716 if (address_mode
== mode_64bit
)
3718 op_address
[op_ad
] = op
;
3719 op_riprel
[op_ad
] = riprel
;
3723 /* Mask to get a 32-bit address. */
3724 op_address
[op_ad
] = op
& 0xffffffff;
3725 op_riprel
[op_ad
] = riprel
& 0xffffffff;
3730 OP_REG (int code
, int sizeflag
)
3734 USED_REX (REX_EXTZ
);
3746 case ax_reg
: case cx_reg
: case dx_reg
: case bx_reg
:
3747 case sp_reg
: case bp_reg
: case si_reg
: case di_reg
:
3748 s
= names16
[code
- ax_reg
+ add
];
3750 case es_reg
: case ss_reg
: case cs_reg
:
3751 case ds_reg
: case fs_reg
: case gs_reg
:
3752 s
= names_seg
[code
- es_reg
+ add
];
3754 case al_reg
: case ah_reg
: case cl_reg
: case ch_reg
:
3755 case dl_reg
: case dh_reg
: case bl_reg
: case bh_reg
:
3758 s
= names8rex
[code
- al_reg
+ add
];
3760 s
= names8
[code
- al_reg
];
3762 case rAX_reg
: case rCX_reg
: case rDX_reg
: case rBX_reg
:
3763 case rSP_reg
: case rBP_reg
: case rSI_reg
: case rDI_reg
:
3764 if (address_mode
== mode_64bit
&& (sizeflag
& DFLAG
))
3766 s
= names64
[code
- rAX_reg
+ add
];
3769 code
+= eAX_reg
- rAX_reg
;
3771 case eAX_reg
: case eCX_reg
: case eDX_reg
: case eBX_reg
:
3772 case eSP_reg
: case eBP_reg
: case eSI_reg
: case eDI_reg
:
3773 USED_REX (REX_MODE64
);
3774 if (rex
& REX_MODE64
)
3775 s
= names64
[code
- eAX_reg
+ add
];
3776 else if (sizeflag
& DFLAG
)
3777 s
= names32
[code
- eAX_reg
+ add
];
3779 s
= names16
[code
- eAX_reg
+ add
];
3780 used_prefixes
|= (prefixes
& PREFIX_DATA
);
3783 s
= INTERNAL_DISASSEMBLER_ERROR
;
3790 OP_IMREG (int code
, int sizeflag
)
3802 case ax_reg
: case cx_reg
: case dx_reg
: case bx_reg
:
3803 case sp_reg
: case bp_reg
: case si_reg
: case di_reg
:
3804 s
= names16
[code
- ax_reg
];
3806 case es_reg
: case ss_reg
: case cs_reg
:
3807 case ds_reg
: case fs_reg
: case gs_reg
:
3808 s
= names_seg
[code
- es_reg
];
3810 case al_reg
: case ah_reg
: case cl_reg
: case ch_reg
:
3811 case dl_reg
: case dh_reg
: case bl_reg
: case bh_reg
:
3814 s
= names8rex
[code
- al_reg
];
3816 s
= names8
[code
- al_reg
];
3818 case eAX_reg
: case eCX_reg
: case eDX_reg
: case eBX_reg
:
3819 case eSP_reg
: case eBP_reg
: case eSI_reg
: case eDI_reg
:
3820 USED_REX (REX_MODE64
);
3821 if (rex
& REX_MODE64
)
3822 s
= names64
[code
- eAX_reg
];
3823 else if (sizeflag
& DFLAG
)
3824 s
= names32
[code
- eAX_reg
];
3826 s
= names16
[code
- eAX_reg
];
3827 used_prefixes
|= (prefixes
& PREFIX_DATA
);
3830 s
= INTERNAL_DISASSEMBLER_ERROR
;
3837 OP_I (int bytemode
, int sizeflag
)
3840 bfd_signed_vma mask
= -1;
3845 FETCH_DATA (the_info
, codep
+ 1);
3850 if (address_mode
== mode_64bit
)
3857 USED_REX (REX_MODE64
);
3858 if (rex
& REX_MODE64
)
3860 else if (sizeflag
& DFLAG
)
3870 used_prefixes
|= (prefixes
& PREFIX_DATA
);
3881 oappend (INTERNAL_DISASSEMBLER_ERROR
);
3886 scratchbuf
[0] = '$';
3887 print_operand_value (scratchbuf
+ 1, 1, op
);
3888 oappend (scratchbuf
+ intel_syntax
);
3889 scratchbuf
[0] = '\0';
3893 OP_I64 (int bytemode
, int sizeflag
)
3896 bfd_signed_vma mask
= -1;
3898 if (address_mode
!= mode_64bit
)
3900 OP_I (bytemode
, sizeflag
);
3907 FETCH_DATA (the_info
, codep
+ 1);
3912 USED_REX (REX_MODE64
);
3913 if (rex
& REX_MODE64
)
3915 else if (sizeflag
& DFLAG
)
3925 used_prefixes
|= (prefixes
& PREFIX_DATA
);
3932 oappend (INTERNAL_DISASSEMBLER_ERROR
);
3937 scratchbuf
[0] = '$';
3938 print_operand_value (scratchbuf
+ 1, 1, op
);
3939 oappend (scratchbuf
+ intel_syntax
);
3940 scratchbuf
[0] = '\0';
3944 OP_sI (int bytemode
, int sizeflag
)
3947 bfd_signed_vma mask
= -1;
3952 FETCH_DATA (the_info
, codep
+ 1);
3954 if ((op
& 0x80) != 0)
3959 USED_REX (REX_MODE64
);
3960 if (rex
& REX_MODE64
)
3962 else if (sizeflag
& DFLAG
)
3971 if ((op
& 0x8000) != 0)
3974 used_prefixes
|= (prefixes
& PREFIX_DATA
);
3979 if ((op
& 0x8000) != 0)
3983 oappend (INTERNAL_DISASSEMBLER_ERROR
);
3987 scratchbuf
[0] = '$';
3988 print_operand_value (scratchbuf
+ 1, 1, op
);
3989 oappend (scratchbuf
+ intel_syntax
);
3993 OP_J (int bytemode
, int sizeflag
)
4001 FETCH_DATA (the_info
, codep
+ 1);
4003 if ((disp
& 0x80) != 0)
4007 if ((sizeflag
& DFLAG
) || (rex
& REX_MODE64
))
4012 /* For some reason, a data16 prefix on a jump instruction
4013 means that the pc is masked to 16 bits after the
4014 displacement is added! */
4019 oappend (INTERNAL_DISASSEMBLER_ERROR
);
4022 disp
= (start_pc
+ codep
- start_codep
+ disp
) & mask
;
4024 print_operand_value (scratchbuf
, 1, disp
);
4025 oappend (scratchbuf
);
4029 OP_SEG (int dummy ATTRIBUTE_UNUSED
, int sizeflag ATTRIBUTE_UNUSED
)
4031 oappend (names_seg
[reg
]);
4035 OP_DIR (int dummy ATTRIBUTE_UNUSED
, int sizeflag
)
4039 if (sizeflag
& DFLAG
)
4049 used_prefixes
|= (prefixes
& PREFIX_DATA
);
4051 sprintf (scratchbuf
, "0x%x:0x%x", seg
, offset
);
4053 sprintf (scratchbuf
, "$0x%x,$0x%x", seg
, offset
);
4054 oappend (scratchbuf
);
4058 OP_OFF (int bytemode
, int sizeflag
)
4062 if (intel_syntax
&& (sizeflag
& SUFFIX_ALWAYS
))
4063 intel_operand_size (bytemode
, sizeflag
);
4066 if ((sizeflag
& AFLAG
) || address_mode
== mode_64bit
)
4073 if (!(prefixes
& (PREFIX_CS
| PREFIX_SS
| PREFIX_DS
4074 | PREFIX_ES
| PREFIX_FS
| PREFIX_GS
)))
4076 oappend (names_seg
[ds_reg
- es_reg
]);
4080 print_operand_value (scratchbuf
, 1, off
);
4081 oappend (scratchbuf
);
4085 OP_OFF64 (int bytemode
, int sizeflag
)
4089 if (address_mode
!= mode_64bit
)
4091 OP_OFF (bytemode
, sizeflag
);
4095 if (intel_syntax
&& (sizeflag
& SUFFIX_ALWAYS
))
4096 intel_operand_size (bytemode
, sizeflag
);
4103 if (!(prefixes
& (PREFIX_CS
| PREFIX_SS
| PREFIX_DS
4104 | PREFIX_ES
| PREFIX_FS
| PREFIX_GS
)))
4106 oappend (names_seg
[ds_reg
- es_reg
]);
4110 print_operand_value (scratchbuf
, 1, off
);
4111 oappend (scratchbuf
);
4115 ptr_reg (int code
, int sizeflag
)
4119 *obufp
++ = open_char
;
4120 used_prefixes
|= (prefixes
& PREFIX_ADDR
);
4121 if (address_mode
== mode_64bit
)
4123 if (!(sizeflag
& AFLAG
))
4124 s
= names32
[code
- eAX_reg
];
4126 s
= names64
[code
- eAX_reg
];
4128 else if (sizeflag
& AFLAG
)
4129 s
= names32
[code
- eAX_reg
];
4131 s
= names16
[code
- eAX_reg
];
4133 *obufp
++ = close_char
;
4138 OP_ESreg (int code
, int sizeflag
)
4141 intel_operand_size (codep
[-1] & 1 ? v_mode
: b_mode
, sizeflag
);
4142 oappend ("%es:" + intel_syntax
);
4143 ptr_reg (code
, sizeflag
);
4147 OP_DSreg (int code
, int sizeflag
)
4150 intel_operand_size (codep
[-1] != 0xd7 && (codep
[-1] & 1)
4161 prefixes
|= PREFIX_DS
;
4163 ptr_reg (code
, sizeflag
);
4167 OP_C (int dummy ATTRIBUTE_UNUSED
, int sizeflag ATTRIBUTE_UNUSED
)
4172 USED_REX (REX_EXTX
);
4175 else if (address_mode
!= mode_64bit
&& (prefixes
& PREFIX_LOCK
))
4177 used_prefixes
|= PREFIX_LOCK
;
4180 sprintf (scratchbuf
, "%%cr%d", reg
+ add
);
4181 oappend (scratchbuf
+ intel_syntax
);
4185 OP_D (int dummy ATTRIBUTE_UNUSED
, int sizeflag ATTRIBUTE_UNUSED
)
4188 USED_REX (REX_EXTX
);
4192 sprintf (scratchbuf
, "db%d", reg
+ add
);
4194 sprintf (scratchbuf
, "%%db%d", reg
+ add
);
4195 oappend (scratchbuf
);
4199 OP_T (int dummy ATTRIBUTE_UNUSED
, int sizeflag ATTRIBUTE_UNUSED
)
4201 sprintf (scratchbuf
, "%%tr%d", reg
);
4202 oappend (scratchbuf
+ intel_syntax
);
4206 OP_Rd (int bytemode
, int sizeflag
)
4209 OP_E (bytemode
, sizeflag
);
4215 OP_MMX (int bytemode ATTRIBUTE_UNUSED
, int sizeflag ATTRIBUTE_UNUSED
)
4217 used_prefixes
|= (prefixes
& PREFIX_DATA
);
4218 if (prefixes
& PREFIX_DATA
)
4221 USED_REX (REX_EXTX
);
4224 sprintf (scratchbuf
, "%%xmm%d", reg
+ add
);
4227 sprintf (scratchbuf
, "%%mm%d", reg
);
4228 oappend (scratchbuf
+ intel_syntax
);
4232 OP_XMM (int bytemode ATTRIBUTE_UNUSED
, int sizeflag ATTRIBUTE_UNUSED
)
4235 USED_REX (REX_EXTX
);
4238 sprintf (scratchbuf
, "%%xmm%d", reg
+ add
);
4239 oappend (scratchbuf
+ intel_syntax
);
4243 OP_EM (int bytemode
, int sizeflag
)
4247 if (intel_syntax
&& bytemode
== v_mode
)
4249 bytemode
= (prefixes
& PREFIX_DATA
) ? x_mode
: q_mode
;
4250 used_prefixes
|= (prefixes
& PREFIX_DATA
);
4252 OP_E (bytemode
, sizeflag
);
4256 /* Skip mod/rm byte. */
4259 used_prefixes
|= (prefixes
& PREFIX_DATA
);
4260 if (prefixes
& PREFIX_DATA
)
4264 USED_REX (REX_EXTZ
);
4267 sprintf (scratchbuf
, "%%xmm%d", rm
+ add
);
4270 sprintf (scratchbuf
, "%%mm%d", rm
);
4271 oappend (scratchbuf
+ intel_syntax
);
4275 OP_EX (int bytemode
, int sizeflag
)
4280 if (intel_syntax
&& bytemode
== v_mode
)
4282 switch (prefixes
& (PREFIX_DATA
|PREFIX_REPZ
|PREFIX_REPNZ
))
4284 case 0: bytemode
= x_mode
; break;
4285 case PREFIX_REPZ
: bytemode
= d_mode
; used_prefixes
|= PREFIX_REPZ
; break;
4286 case PREFIX_DATA
: bytemode
= x_mode
; used_prefixes
|= PREFIX_DATA
; break;
4287 case PREFIX_REPNZ
: bytemode
= q_mode
; used_prefixes
|= PREFIX_REPNZ
; break;
4288 default: bytemode
= 0; break;
4291 OP_E (bytemode
, sizeflag
);
4294 USED_REX (REX_EXTZ
);
4298 /* Skip mod/rm byte. */
4301 sprintf (scratchbuf
, "%%xmm%d", rm
+ add
);
4302 oappend (scratchbuf
+ intel_syntax
);
4306 OP_MS (int bytemode
, int sizeflag
)
4309 OP_EM (bytemode
, sizeflag
);
4315 OP_XS (int bytemode
, int sizeflag
)
4318 OP_EX (bytemode
, sizeflag
);
4324 OP_M (int bytemode
, int sizeflag
)
4327 BadOp (); /* bad lea,lds,les,lfs,lgs,lss modrm */
4329 OP_E (bytemode
, sizeflag
);
4333 OP_0f07 (int bytemode
, int sizeflag
)
4335 if (mod
!= 3 || rm
!= 0)
4338 OP_E (bytemode
, sizeflag
);
4342 OP_0fae (int bytemode
, int sizeflag
)
4347 strcpy (obuf
+ strlen (obuf
) - sizeof ("clflush") + 1, "sfence");
4349 if (reg
< 5 || rm
!= 0)
4351 BadOp (); /* bad sfence, mfence, or lfence */
4357 BadOp (); /* bad clflush */
4361 OP_E (bytemode
, sizeflag
);
4364 /* NOP is an alias of "xchg %ax,%ax" in 16bit mode, "xchg %eax,%eax" in
4365 32bit mode and "xchg %rax,%rax" in 64bit mode. NOP with REPZ prefix
4366 is called PAUSE. We display "xchg %ax,%ax" instead of "data16 nop".
4370 NOP_Fixup1 (int bytemode
, int sizeflag
)
4372 if (prefixes
== PREFIX_REPZ
)
4373 strcpy (obuf
, "pause");
4374 else if (prefixes
== PREFIX_DATA
4375 || ((rex
& REX_MODE64
) && rex
!= 0x48))
4376 OP_REG (bytemode
, sizeflag
);
4378 strcpy (obuf
, "nop");
4382 NOP_Fixup2 (int bytemode
, int sizeflag
)
4384 if (prefixes
== PREFIX_DATA
4385 || ((rex
& REX_MODE64
) && rex
!= 0x48))
4386 OP_IMREG (bytemode
, sizeflag
);
4389 static const char *const Suffix3DNow
[] = {
4390 /* 00 */ NULL
, NULL
, NULL
, NULL
,
4391 /* 04 */ NULL
, NULL
, NULL
, NULL
,
4392 /* 08 */ NULL
, NULL
, NULL
, NULL
,
4393 /* 0C */ "pi2fw", "pi2fd", NULL
, NULL
,
4394 /* 10 */ NULL
, NULL
, NULL
, NULL
,
4395 /* 14 */ NULL
, NULL
, NULL
, NULL
,
4396 /* 18 */ NULL
, NULL
, NULL
, NULL
,
4397 /* 1C */ "pf2iw", "pf2id", NULL
, NULL
,
4398 /* 20 */ NULL
, NULL
, NULL
, NULL
,
4399 /* 24 */ NULL
, NULL
, NULL
, NULL
,
4400 /* 28 */ NULL
, NULL
, NULL
, NULL
,
4401 /* 2C */ NULL
, NULL
, NULL
, NULL
,
4402 /* 30 */ NULL
, NULL
, NULL
, NULL
,
4403 /* 34 */ NULL
, NULL
, NULL
, NULL
,
4404 /* 38 */ NULL
, NULL
, NULL
, NULL
,
4405 /* 3C */ NULL
, NULL
, NULL
, NULL
,
4406 /* 40 */ NULL
, NULL
, NULL
, NULL
,
4407 /* 44 */ NULL
, NULL
, NULL
, NULL
,
4408 /* 48 */ NULL
, NULL
, NULL
, NULL
,
4409 /* 4C */ NULL
, NULL
, NULL
, NULL
,
4410 /* 50 */ NULL
, NULL
, NULL
, NULL
,
4411 /* 54 */ NULL
, NULL
, NULL
, NULL
,
4412 /* 58 */ NULL
, NULL
, NULL
, NULL
,
4413 /* 5C */ NULL
, NULL
, NULL
, NULL
,
4414 /* 60 */ NULL
, NULL
, NULL
, NULL
,
4415 /* 64 */ NULL
, NULL
, NULL
, NULL
,
4416 /* 68 */ NULL
, NULL
, NULL
, NULL
,
4417 /* 6C */ NULL
, NULL
, NULL
, NULL
,
4418 /* 70 */ NULL
, NULL
, NULL
, NULL
,
4419 /* 74 */ NULL
, NULL
, NULL
, NULL
,
4420 /* 78 */ NULL
, NULL
, NULL
, NULL
,
4421 /* 7C */ NULL
, NULL
, NULL
, NULL
,
4422 /* 80 */ NULL
, NULL
, NULL
, NULL
,
4423 /* 84 */ NULL
, NULL
, NULL
, NULL
,
4424 /* 88 */ NULL
, NULL
, "pfnacc", NULL
,
4425 /* 8C */ NULL
, NULL
, "pfpnacc", NULL
,
4426 /* 90 */ "pfcmpge", NULL
, NULL
, NULL
,
4427 /* 94 */ "pfmin", NULL
, "pfrcp", "pfrsqrt",
4428 /* 98 */ NULL
, NULL
, "pfsub", NULL
,
4429 /* 9C */ NULL
, NULL
, "pfadd", NULL
,
4430 /* A0 */ "pfcmpgt", NULL
, NULL
, NULL
,
4431 /* A4 */ "pfmax", NULL
, "pfrcpit1", "pfrsqit1",
4432 /* A8 */ NULL
, NULL
, "pfsubr", NULL
,
4433 /* AC */ NULL
, NULL
, "pfacc", NULL
,
4434 /* B0 */ "pfcmpeq", NULL
, NULL
, NULL
,
4435 /* B4 */ "pfmul", NULL
, "pfrcpit2", "pfmulhrw",
4436 /* B8 */ NULL
, NULL
, NULL
, "pswapd",
4437 /* BC */ NULL
, NULL
, NULL
, "pavgusb",
4438 /* C0 */ NULL
, NULL
, NULL
, NULL
,
4439 /* C4 */ NULL
, NULL
, NULL
, NULL
,
4440 /* C8 */ NULL
, NULL
, NULL
, NULL
,
4441 /* CC */ NULL
, NULL
, NULL
, NULL
,
4442 /* D0 */ NULL
, NULL
, NULL
, NULL
,
4443 /* D4 */ NULL
, NULL
, NULL
, NULL
,
4444 /* D8 */ NULL
, NULL
, NULL
, NULL
,
4445 /* DC */ NULL
, NULL
, NULL
, NULL
,
4446 /* E0 */ NULL
, NULL
, NULL
, NULL
,
4447 /* E4 */ NULL
, NULL
, NULL
, NULL
,
4448 /* E8 */ NULL
, NULL
, NULL
, NULL
,
4449 /* EC */ NULL
, NULL
, NULL
, NULL
,
4450 /* F0 */ NULL
, NULL
, NULL
, NULL
,
4451 /* F4 */ NULL
, NULL
, NULL
, NULL
,
4452 /* F8 */ NULL
, NULL
, NULL
, NULL
,
4453 /* FC */ NULL
, NULL
, NULL
, NULL
,
4457 OP_3DNowSuffix (int bytemode ATTRIBUTE_UNUSED
, int sizeflag ATTRIBUTE_UNUSED
)
4459 const char *mnemonic
;
4461 FETCH_DATA (the_info
, codep
+ 1);
4462 /* AMD 3DNow! instructions are specified by an opcode suffix in the
4463 place where an 8-bit immediate would normally go. ie. the last
4464 byte of the instruction. */
4465 obufp
= obuf
+ strlen (obuf
);
4466 mnemonic
= Suffix3DNow
[*codep
++ & 0xff];
4471 /* Since a variable sized modrm/sib chunk is between the start
4472 of the opcode (0x0f0f) and the opcode suffix, we need to do
4473 all the modrm processing first, and don't know until now that
4474 we have a bad opcode. This necessitates some cleaning up. */
4481 static const char *simd_cmp_op
[] = {
4493 OP_SIMD_Suffix (int bytemode ATTRIBUTE_UNUSED
, int sizeflag ATTRIBUTE_UNUSED
)
4495 unsigned int cmp_type
;
4497 FETCH_DATA (the_info
, codep
+ 1);
4498 obufp
= obuf
+ strlen (obuf
);
4499 cmp_type
= *codep
++ & 0xff;
4502 char suffix1
= 'p', suffix2
= 's';
4503 used_prefixes
|= (prefixes
& PREFIX_REPZ
);
4504 if (prefixes
& PREFIX_REPZ
)
4508 used_prefixes
|= (prefixes
& PREFIX_DATA
);
4509 if (prefixes
& PREFIX_DATA
)
4513 used_prefixes
|= (prefixes
& PREFIX_REPNZ
);
4514 if (prefixes
& PREFIX_REPNZ
)
4515 suffix1
= 's', suffix2
= 'd';
4518 sprintf (scratchbuf
, "cmp%s%c%c",
4519 simd_cmp_op
[cmp_type
], suffix1
, suffix2
);
4520 used_prefixes
|= (prefixes
& PREFIX_REPZ
);
4521 oappend (scratchbuf
);
4525 /* We have a bad extension byte. Clean up. */
4533 SIMD_Fixup (int extrachar
, int sizeflag ATTRIBUTE_UNUSED
)
4535 /* Change movlps/movhps to movhlps/movlhps for 2 register operand
4536 forms of these instructions. */
4539 char *p
= obuf
+ strlen (obuf
);
4542 *(p
- 1) = *(p
- 2);
4543 *(p
- 2) = *(p
- 3);
4544 *(p
- 3) = extrachar
;
4549 PNI_Fixup (int extrachar ATTRIBUTE_UNUSED
, int sizeflag
)
4551 if (mod
== 3 && reg
== 1 && rm
<= 1)
4553 /* Override "sidt". */
4554 size_t olen
= strlen (obuf
);
4555 char *p
= obuf
+ olen
- 4;
4556 const char **names
= (address_mode
== mode_64bit
4557 ? names64
: names32
);
4559 /* We might have a suffix when disassembling with -Msuffix. */
4563 /* Remove "addr16/addr32" if we aren't in Intel mode. */
4565 && (prefixes
& PREFIX_ADDR
)
4568 && strncmp (p
- 7, "addr", 4) == 0
4569 && (strncmp (p
- 3, "16", 2) == 0
4570 || strncmp (p
- 3, "32", 2) == 0))
4575 /* mwait %eax,%ecx */
4576 strcpy (p
, "mwait");
4578 strcpy (op1out
, names
[0]);
4582 /* monitor %eax,%ecx,%edx" */
4583 strcpy (p
, "monitor");
4586 const char **op1_names
;
4587 if (!(prefixes
& PREFIX_ADDR
))
4588 op1_names
= (address_mode
== mode_16bit
4592 op1_names
= (address_mode
!= mode_32bit
4593 ? names32
: names16
);
4594 used_prefixes
|= PREFIX_ADDR
;
4596 strcpy (op1out
, op1_names
[0]);
4597 strcpy (op3out
, names
[2]);
4602 strcpy (op2out
, names
[1]);
4613 SVME_Fixup (int bytemode
, int sizeflag
)
4645 OP_M (bytemode
, sizeflag
);
4648 /* Override "lidt". */
4649 p
= obuf
+ strlen (obuf
) - 4;
4650 /* We might have a suffix. */
4654 if (!(prefixes
& PREFIX_ADDR
))
4659 used_prefixes
|= PREFIX_ADDR
;
4663 strcpy (op2out
, names32
[1]);
4669 *obufp
++ = open_char
;
4670 if (address_mode
== mode_64bit
|| (sizeflag
& AFLAG
))
4674 strcpy (obufp
, alt
);
4675 obufp
+= strlen (alt
);
4676 *obufp
++ = close_char
;
4683 INVLPG_Fixup (int bytemode
, int sizeflag
)
4696 OP_M (bytemode
, sizeflag
);
4699 /* Override "invlpg". */
4700 strcpy (obuf
+ strlen (obuf
) - 6, alt
);
4707 /* Throw away prefixes and 1st. opcode byte. */
4708 codep
= insn_codep
+ 1;
4713 SEG_Fixup (int extrachar
, int sizeflag
)
4717 /* We need to add a proper suffix with
4728 if (prefixes
& PREFIX_DATA
)
4732 USED_REX (REX_MODE64
);
4733 if (rex
& REX_MODE64
)
4738 strcat (obuf
, suffix
);
4742 /* We need to fix the suffix for
4749 Override "mov[l|q]". */
4750 char *p
= obuf
+ strlen (obuf
) - 1;
4752 /* We might not have a suffix. */
4758 OP_E (extrachar
, sizeflag
);
4762 VMX_Fixup (int extrachar ATTRIBUTE_UNUSED
, int sizeflag
)
4764 if (mod
== 3 && reg
== 0 && rm
>=1 && rm
<= 4)
4766 /* Override "sgdt". */
4767 char *p
= obuf
+ strlen (obuf
) - 4;
4769 /* We might have a suffix when disassembling with -Msuffix. */
4776 strcpy (p
, "vmcall");
4779 strcpy (p
, "vmlaunch");
4782 strcpy (p
, "vmresume");
4785 strcpy (p
, "vmxoff");
4796 OP_VMX (int bytemode
, int sizeflag
)
4798 used_prefixes
|= (prefixes
& (PREFIX_DATA
| PREFIX_REPZ
));
4799 if (prefixes
& PREFIX_DATA
)
4800 strcpy (obuf
, "vmclear");
4801 else if (prefixes
& PREFIX_REPZ
)
4802 strcpy (obuf
, "vmxon");
4804 strcpy (obuf
, "vmptrld");
4805 OP_E (bytemode
, sizeflag
);
4809 REP_Fixup (int bytemode
, int sizeflag
)
4811 /* The 0xf3 prefix should be displayed as "rep" for ins, outs, movs,
4815 if (prefixes
& PREFIX_REPZ
)
4816 switch (*insn_codep
)
4818 case 0x6e: /* outsb */
4819 case 0x6f: /* outsw/outsl */
4820 case 0xa4: /* movsb */
4821 case 0xa5: /* movsw/movsl/movsq */
4827 case 0xaa: /* stosb */
4828 case 0xab: /* stosw/stosl/stosq */
4829 case 0xac: /* lodsb */
4830 case 0xad: /* lodsw/lodsl/lodsq */
4831 if (!intel_syntax
&& (sizeflag
& SUFFIX_ALWAYS
))
4836 case 0x6c: /* insb */
4837 case 0x6d: /* insl/insw */
4853 olen
= strlen (obuf
);
4854 p
= obuf
+ olen
- ilen
- 1 - 4;
4855 /* Handle "repz [addr16|addr32]". */
4856 if ((prefixes
& PREFIX_ADDR
))
4859 memmove (p
+ 3, p
+ 4, olen
- (p
+ 3 - obuf
));
4867 OP_IMREG (bytemode
, sizeflag
);
4870 OP_ESreg (bytemode
, sizeflag
);
4873 OP_DSreg (bytemode
, sizeflag
);