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_0fae (int, int);
92 static void OP_0f07 (int, int);
93 static void NOP_Fixup (int, int);
94 static void OP_3DNowSuffix (int, int);
95 static void OP_SIMD_Suffix (int, int);
96 static void SIMD_Fixup (int, int);
97 static void PNI_Fixup (int, int);
98 static void SVME_Fixup (int, int);
99 static void INVLPG_Fixup (int, int);
100 static void BadOp (void);
101 static void SEG_Fixup (int, int);
104 /* Points to first byte not fetched. */
105 bfd_byte
*max_fetched
;
106 bfd_byte the_buffer
[MAXLEN
];
112 /* The opcode for the fwait instruction, which we treat as a prefix
114 #define FWAIT_OPCODE (0x9b)
116 /* Set to 1 for 64bit mode disassembly. */
117 static int mode_64bit
;
119 /* Flags for the prefixes for the current instruction. See below. */
122 /* REX prefix the current instruction. See below. */
124 /* Bits of REX we've already used. */
130 /* Mark parts used in the REX prefix. When we are testing for
131 empty prefix (for 8bit register REX extension), just mask it
132 out. Otherwise test for REX bit is excuse for existence of REX
133 only in case value is nonzero. */
134 #define USED_REX(value) \
137 rex_used |= (rex & value) ? (value) | 0x40 : 0; \
142 /* Flags for prefixes which we somehow handled when printing the
143 current instruction. */
144 static int used_prefixes
;
146 /* Flags stored in PREFIXES. */
147 #define PREFIX_REPZ 1
148 #define PREFIX_REPNZ 2
149 #define PREFIX_LOCK 4
151 #define PREFIX_SS 0x10
152 #define PREFIX_DS 0x20
153 #define PREFIX_ES 0x40
154 #define PREFIX_FS 0x80
155 #define PREFIX_GS 0x100
156 #define PREFIX_DATA 0x200
157 #define PREFIX_ADDR 0x400
158 #define PREFIX_FWAIT 0x800
160 /* Make sure that bytes from INFO->PRIVATE_DATA->BUFFER (inclusive)
161 to ADDR (exclusive) are valid. Returns 1 for success, longjmps
163 #define FETCH_DATA(info, addr) \
164 ((addr) <= ((struct dis_private *) (info->private_data))->max_fetched \
165 ? 1 : fetch_data ((info), (addr)))
168 fetch_data (struct disassemble_info
*info
, bfd_byte
*addr
)
171 struct dis_private
*priv
= (struct dis_private
*) info
->private_data
;
172 bfd_vma start
= priv
->insn_start
+ (priv
->max_fetched
- priv
->the_buffer
);
174 status
= (*info
->read_memory_func
) (start
,
176 addr
- priv
->max_fetched
,
180 /* If we did manage to read at least one byte, then
181 print_insn_i386 will do something sensible. Otherwise, print
182 an error. We do that here because this is where we know
184 if (priv
->max_fetched
== priv
->the_buffer
)
185 (*info
->memory_error_func
) (status
, start
, info
);
186 longjmp (priv
->bailout
, 1);
189 priv
->max_fetched
= addr
;
195 #define Eb OP_E, b_mode
196 #define Ev OP_E, v_mode
197 #define Ed OP_E, d_mode
198 #define Eq OP_E, q_mode
199 #define Edq OP_E, dq_mode
200 #define Edqw OP_E, dqw_mode
201 #define indirEv OP_indirE, branch_v_mode
202 #define indirEp OP_indirE, f_mode
203 #define Ew OP_E, w_mode
204 #define Ma OP_E, v_mode
205 #define M OP_M, 0 /* lea, lgdt, etc. */
206 #define Mp OP_M, f_mode /* 32 or 48 bit memory operand for LDS, LES etc */
207 #define Gb OP_G, b_mode
208 #define Gv OP_G, v_mode
209 #define Gd OP_G, d_mode
210 #define Gdq OP_G, dq_mode
211 #define Gw OP_G, w_mode
212 #define Rd OP_Rd, d_mode
213 #define Rm OP_Rd, m_mode
214 #define Ib OP_I, b_mode
215 #define sIb OP_sI, b_mode /* sign extened byte */
216 #define Iv OP_I, v_mode
217 #define Iq OP_I, q_mode
218 #define Iv64 OP_I64, v_mode
219 #define Iw OP_I, w_mode
220 #define I1 OP_I, const_1_mode
221 #define Jb OP_J, b_mode
222 #define Jv OP_J, v_mode
223 #define Cm OP_C, m_mode
224 #define Dm OP_D, m_mode
225 #define Td OP_T, d_mode
226 #define Sv SEG_Fixup, v_mode
228 #define RMeAX OP_REG, eAX_reg
229 #define RMeBX OP_REG, eBX_reg
230 #define RMeCX OP_REG, eCX_reg
231 #define RMeDX OP_REG, eDX_reg
232 #define RMeSP OP_REG, eSP_reg
233 #define RMeBP OP_REG, eBP_reg
234 #define RMeSI OP_REG, eSI_reg
235 #define RMeDI OP_REG, eDI_reg
236 #define RMrAX OP_REG, rAX_reg
237 #define RMrBX OP_REG, rBX_reg
238 #define RMrCX OP_REG, rCX_reg
239 #define RMrDX OP_REG, rDX_reg
240 #define RMrSP OP_REG, rSP_reg
241 #define RMrBP OP_REG, rBP_reg
242 #define RMrSI OP_REG, rSI_reg
243 #define RMrDI OP_REG, rDI_reg
244 #define RMAL OP_REG, al_reg
245 #define RMAL OP_REG, al_reg
246 #define RMCL OP_REG, cl_reg
247 #define RMDL OP_REG, dl_reg
248 #define RMBL OP_REG, bl_reg
249 #define RMAH OP_REG, ah_reg
250 #define RMCH OP_REG, ch_reg
251 #define RMDH OP_REG, dh_reg
252 #define RMBH OP_REG, bh_reg
253 #define RMAX OP_REG, ax_reg
254 #define RMDX OP_REG, dx_reg
256 #define eAX OP_IMREG, eAX_reg
257 #define eBX OP_IMREG, eBX_reg
258 #define eCX OP_IMREG, eCX_reg
259 #define eDX OP_IMREG, eDX_reg
260 #define eSP OP_IMREG, eSP_reg
261 #define eBP OP_IMREG, eBP_reg
262 #define eSI OP_IMREG, eSI_reg
263 #define eDI OP_IMREG, eDI_reg
264 #define AL OP_IMREG, al_reg
265 #define AL OP_IMREG, al_reg
266 #define CL OP_IMREG, cl_reg
267 #define DL OP_IMREG, dl_reg
268 #define BL OP_IMREG, bl_reg
269 #define AH OP_IMREG, ah_reg
270 #define CH OP_IMREG, ch_reg
271 #define DH OP_IMREG, dh_reg
272 #define BH OP_IMREG, bh_reg
273 #define AX OP_IMREG, ax_reg
274 #define DX OP_IMREG, dx_reg
275 #define indirDX OP_IMREG, indir_dx_reg
277 #define Sw OP_SEG, w_mode
279 #define Ob OP_OFF, b_mode
280 #define Ob64 OP_OFF64, b_mode
281 #define Ov OP_OFF, v_mode
282 #define Ov64 OP_OFF64, v_mode
283 #define Xb OP_DSreg, eSI_reg
284 #define Xv OP_DSreg, eSI_reg
285 #define Yb OP_ESreg, eDI_reg
286 #define Yv OP_ESreg, eDI_reg
287 #define DSBX OP_DSreg, eBX_reg
289 #define es OP_REG, es_reg
290 #define ss OP_REG, ss_reg
291 #define cs OP_REG, cs_reg
292 #define ds OP_REG, ds_reg
293 #define fs OP_REG, fs_reg
294 #define gs OP_REG, gs_reg
298 #define EM OP_EM, v_mode
299 #define EX OP_EX, v_mode
300 #define MS OP_MS, v_mode
301 #define XS OP_XS, v_mode
302 #define OPSUF OP_3DNowSuffix, 0
303 #define OPSIMD OP_SIMD_Suffix, 0
305 #define cond_jump_flag NULL, cond_jump_mode
306 #define loop_jcxz_flag NULL, loop_jcxz_mode
308 /* bits in sizeflag */
309 #define SUFFIX_ALWAYS 4
313 #define b_mode 1 /* byte operand */
314 #define v_mode 2 /* operand size depends on prefixes */
315 #define w_mode 3 /* word operand */
316 #define d_mode 4 /* double word operand */
317 #define q_mode 5 /* quad word operand */
318 #define t_mode 6 /* ten-byte operand */
319 #define x_mode 7 /* 16-byte XMM operand */
320 #define m_mode 8 /* d_mode in 32bit, q_mode in 64bit mode. */
321 #define cond_jump_mode 9
322 #define loop_jcxz_mode 10
323 #define dq_mode 11 /* operand size depends on REX prefixes. */
324 #define dqw_mode 12 /* registers like dq_mode, memory like w_mode. */
325 #define f_mode 13 /* 4- or 6-byte pointer operand */
326 #define const_1_mode 14
327 #define branch_v_mode 15 /* v_mode for branch. */
372 #define indir_dx_reg 150
376 #define USE_PREFIX_USER_TABLE 3
377 #define X86_64_SPECIAL 4
379 #define FLOAT NULL, NULL, FLOATCODE, NULL, 0, NULL, 0
381 #define GRP1b NULL, NULL, USE_GROUPS, NULL, 0, NULL, 0
382 #define GRP1S NULL, NULL, USE_GROUPS, NULL, 1, NULL, 0
383 #define GRP1Ss NULL, NULL, USE_GROUPS, NULL, 2, NULL, 0
384 #define GRP2b NULL, NULL, USE_GROUPS, NULL, 3, NULL, 0
385 #define GRP2S NULL, NULL, USE_GROUPS, NULL, 4, NULL, 0
386 #define GRP2b_one NULL, NULL, USE_GROUPS, NULL, 5, NULL, 0
387 #define GRP2S_one NULL, NULL, USE_GROUPS, NULL, 6, NULL, 0
388 #define GRP2b_cl NULL, NULL, USE_GROUPS, NULL, 7, NULL, 0
389 #define GRP2S_cl NULL, NULL, USE_GROUPS, NULL, 8, NULL, 0
390 #define GRP3b NULL, NULL, USE_GROUPS, NULL, 9, NULL, 0
391 #define GRP3S NULL, NULL, USE_GROUPS, NULL, 10, NULL, 0
392 #define GRP4 NULL, NULL, USE_GROUPS, NULL, 11, NULL, 0
393 #define GRP5 NULL, NULL, USE_GROUPS, NULL, 12, NULL, 0
394 #define GRP6 NULL, NULL, USE_GROUPS, NULL, 13, NULL, 0
395 #define GRP7 NULL, NULL, USE_GROUPS, NULL, 14, NULL, 0
396 #define GRP8 NULL, NULL, USE_GROUPS, NULL, 15, NULL, 0
397 #define GRP9 NULL, NULL, USE_GROUPS, NULL, 16, NULL, 0
398 #define GRP10 NULL, NULL, USE_GROUPS, NULL, 17, NULL, 0
399 #define GRP11 NULL, NULL, USE_GROUPS, NULL, 18, NULL, 0
400 #define GRP12 NULL, NULL, USE_GROUPS, NULL, 19, NULL, 0
401 #define GRP13 NULL, NULL, USE_GROUPS, NULL, 20, NULL, 0
402 #define GRP14 NULL, NULL, USE_GROUPS, NULL, 21, NULL, 0
403 #define GRPAMD NULL, NULL, USE_GROUPS, NULL, 22, NULL, 0
404 #define GRPPADLCK1 NULL, NULL, USE_GROUPS, NULL, 23, NULL, 0
405 #define GRPPADLCK2 NULL, NULL, USE_GROUPS, NULL, 24, NULL, 0
407 #define PREGRP0 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 0, NULL, 0
408 #define PREGRP1 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 1, NULL, 0
409 #define PREGRP2 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 2, NULL, 0
410 #define PREGRP3 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 3, NULL, 0
411 #define PREGRP4 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 4, NULL, 0
412 #define PREGRP5 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 5, NULL, 0
413 #define PREGRP6 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 6, NULL, 0
414 #define PREGRP7 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 7, NULL, 0
415 #define PREGRP8 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 8, NULL, 0
416 #define PREGRP9 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 9, NULL, 0
417 #define PREGRP10 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 10, NULL, 0
418 #define PREGRP11 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 11, NULL, 0
419 #define PREGRP12 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 12, NULL, 0
420 #define PREGRP13 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 13, NULL, 0
421 #define PREGRP14 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 14, NULL, 0
422 #define PREGRP15 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 15, NULL, 0
423 #define PREGRP16 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 16, NULL, 0
424 #define PREGRP17 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 17, NULL, 0
425 #define PREGRP18 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 18, NULL, 0
426 #define PREGRP19 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 19, NULL, 0
427 #define PREGRP20 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 20, NULL, 0
428 #define PREGRP21 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 21, NULL, 0
429 #define PREGRP22 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 22, NULL, 0
430 #define PREGRP23 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 23, NULL, 0
431 #define PREGRP24 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 24, NULL, 0
432 #define PREGRP25 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 25, NULL, 0
433 #define PREGRP26 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 26, NULL, 0
434 #define PREGRP27 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 27, NULL, 0
435 #define PREGRP28 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 28, NULL, 0
436 #define PREGRP29 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 29, NULL, 0
437 #define PREGRP30 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 30, NULL, 0
438 #define PREGRP31 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 31, NULL, 0
439 #define PREGRP32 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 32, NULL, 0
441 #define X86_64_0 NULL, NULL, X86_64_SPECIAL, NULL, 0, NULL, 0
443 typedef void (*op_rtn
) (int bytemode
, int sizeflag
);
455 /* Upper case letters in the instruction names here are macros.
456 'A' => print 'b' if no register operands or suffix_always is true
457 'B' => print 'b' if suffix_always is true
458 'C' => print 's' or 'l' ('w' or 'd' in Intel mode) depending on operand
460 'E' => print 'e' if 32-bit form of jcxz
461 'F' => print 'w' or 'l' depending on address size prefix (loop insns)
462 'H' => print ",pt" or ",pn" branch hint
463 'I' => honor following macro letter even in Intel mode (implemented only
464 . for some of the macro letters)
466 'L' => print 'l' if suffix_always is true
467 'N' => print 'n' if instruction has no wait "prefix"
468 'O' => print 'd', or 'o'
469 'P' => print 'w', 'l' or 'q' if instruction has an operand size prefix,
470 . or suffix_always is true. print 'q' if rex prefix is present.
471 'Q' => print 'w', 'l' or 'q' if no register operands or suffix_always
473 'R' => print 'w', 'l' or 'q' ("wd" or "dq" in intel mode)
474 'S' => print 'w', 'l' or 'q' if suffix_always is true
475 'T' => print 'q' in 64bit mode and behave as 'P' otherwise
476 'U' => print 'q' in 64bit mode and behave as 'Q' otherwise
477 'W' => print 'b' or 'w' ("w" or "de" in intel mode)
478 'X' => print 's', 'd' depending on data16 prefix (for XMM)
479 'Y' => 'q' if instruction has an REX 64bit overwrite prefix
481 Many of the above letters print nothing in Intel mode. See "putop"
484 Braces '{' and '}', and vertical bars '|', indicate alternative
485 mnemonic strings for AT&T, Intel, X86_64 AT&T, and X86_64 Intel
486 modes. In cases where there are only two alternatives, the X86_64
487 instruction is reserved, and "(bad)" is printed.
490 static const struct dis386 dis386
[] = {
492 { "addB", Eb
, Gb
, XX
},
493 { "addS", Ev
, Gv
, XX
},
494 { "addB", Gb
, Eb
, XX
},
495 { "addS", Gv
, Ev
, XX
},
496 { "addB", AL
, Ib
, XX
},
497 { "addS", eAX
, Iv
, XX
},
498 { "push{T|}", es
, XX
, XX
},
499 { "pop{T|}", es
, XX
, XX
},
501 { "orB", Eb
, Gb
, XX
},
502 { "orS", Ev
, Gv
, XX
},
503 { "orB", Gb
, Eb
, XX
},
504 { "orS", Gv
, Ev
, XX
},
505 { "orB", AL
, Ib
, XX
},
506 { "orS", eAX
, Iv
, XX
},
507 { "push{T|}", cs
, XX
, XX
},
508 { "(bad)", XX
, XX
, XX
}, /* 0x0f extended opcode escape */
510 { "adcB", Eb
, Gb
, XX
},
511 { "adcS", Ev
, Gv
, XX
},
512 { "adcB", Gb
, Eb
, XX
},
513 { "adcS", Gv
, Ev
, XX
},
514 { "adcB", AL
, Ib
, XX
},
515 { "adcS", eAX
, Iv
, XX
},
516 { "push{T|}", ss
, XX
, XX
},
517 { "popT|}", ss
, XX
, XX
},
519 { "sbbB", Eb
, Gb
, XX
},
520 { "sbbS", Ev
, Gv
, XX
},
521 { "sbbB", Gb
, Eb
, XX
},
522 { "sbbS", Gv
, Ev
, XX
},
523 { "sbbB", AL
, Ib
, XX
},
524 { "sbbS", eAX
, Iv
, XX
},
525 { "push{T|}", ds
, XX
, XX
},
526 { "pop{T|}", ds
, XX
, XX
},
528 { "andB", Eb
, Gb
, XX
},
529 { "andS", Ev
, Gv
, XX
},
530 { "andB", Gb
, Eb
, XX
},
531 { "andS", Gv
, Ev
, XX
},
532 { "andB", AL
, Ib
, XX
},
533 { "andS", eAX
, Iv
, XX
},
534 { "(bad)", XX
, XX
, XX
}, /* SEG ES prefix */
535 { "daa{|}", XX
, XX
, XX
},
537 { "subB", Eb
, Gb
, XX
},
538 { "subS", Ev
, Gv
, XX
},
539 { "subB", Gb
, Eb
, XX
},
540 { "subS", Gv
, Ev
, XX
},
541 { "subB", AL
, Ib
, XX
},
542 { "subS", eAX
, Iv
, XX
},
543 { "(bad)", XX
, XX
, XX
}, /* SEG CS prefix */
544 { "das{|}", XX
, XX
, XX
},
546 { "xorB", Eb
, Gb
, XX
},
547 { "xorS", Ev
, Gv
, XX
},
548 { "xorB", Gb
, Eb
, XX
},
549 { "xorS", Gv
, Ev
, XX
},
550 { "xorB", AL
, Ib
, XX
},
551 { "xorS", eAX
, Iv
, XX
},
552 { "(bad)", XX
, XX
, XX
}, /* SEG SS prefix */
553 { "aaa{|}", XX
, XX
, XX
},
555 { "cmpB", Eb
, Gb
, XX
},
556 { "cmpS", Ev
, Gv
, XX
},
557 { "cmpB", Gb
, Eb
, XX
},
558 { "cmpS", Gv
, Ev
, XX
},
559 { "cmpB", AL
, Ib
, XX
},
560 { "cmpS", eAX
, Iv
, XX
},
561 { "(bad)", XX
, XX
, XX
}, /* SEG DS prefix */
562 { "aas{|}", XX
, XX
, XX
},
564 { "inc{S|}", RMeAX
, XX
, XX
},
565 { "inc{S|}", RMeCX
, XX
, XX
},
566 { "inc{S|}", RMeDX
, XX
, XX
},
567 { "inc{S|}", RMeBX
, XX
, XX
},
568 { "inc{S|}", RMeSP
, XX
, XX
},
569 { "inc{S|}", RMeBP
, XX
, XX
},
570 { "inc{S|}", RMeSI
, XX
, XX
},
571 { "inc{S|}", RMeDI
, XX
, XX
},
573 { "dec{S|}", RMeAX
, XX
, XX
},
574 { "dec{S|}", RMeCX
, XX
, XX
},
575 { "dec{S|}", RMeDX
, XX
, XX
},
576 { "dec{S|}", RMeBX
, XX
, XX
},
577 { "dec{S|}", RMeSP
, XX
, XX
},
578 { "dec{S|}", RMeBP
, XX
, XX
},
579 { "dec{S|}", RMeSI
, XX
, XX
},
580 { "dec{S|}", RMeDI
, XX
, XX
},
582 { "pushS", RMrAX
, XX
, XX
},
583 { "pushS", RMrCX
, XX
, XX
},
584 { "pushS", RMrDX
, XX
, XX
},
585 { "pushS", RMrBX
, XX
, XX
},
586 { "pushS", RMrSP
, XX
, XX
},
587 { "pushS", RMrBP
, XX
, XX
},
588 { "pushS", RMrSI
, XX
, XX
},
589 { "pushS", RMrDI
, XX
, XX
},
591 { "popS", RMrAX
, XX
, XX
},
592 { "popS", RMrCX
, XX
, XX
},
593 { "popS", RMrDX
, XX
, XX
},
594 { "popS", RMrBX
, XX
, XX
},
595 { "popS", RMrSP
, XX
, XX
},
596 { "popS", RMrBP
, XX
, XX
},
597 { "popS", RMrSI
, XX
, XX
},
598 { "popS", RMrDI
, XX
, XX
},
600 { "pusha{P|}", XX
, XX
, XX
},
601 { "popa{P|}", XX
, XX
, XX
},
602 { "bound{S|}", Gv
, Ma
, XX
},
604 { "(bad)", XX
, XX
, XX
}, /* seg fs */
605 { "(bad)", XX
, XX
, XX
}, /* seg gs */
606 { "(bad)", XX
, XX
, XX
}, /* op size prefix */
607 { "(bad)", XX
, XX
, XX
}, /* adr size prefix */
609 { "pushT", Iq
, XX
, XX
},
610 { "imulS", Gv
, Ev
, Iv
},
611 { "pushT", sIb
, XX
, XX
},
612 { "imulS", Gv
, Ev
, sIb
},
613 { "ins{b||b|}", Yb
, indirDX
, XX
},
614 { "ins{R||R|}", Yv
, indirDX
, XX
},
615 { "outs{b||b|}", indirDX
, Xb
, XX
},
616 { "outs{R||R|}", indirDX
, Xv
, XX
},
618 { "joH", Jb
, XX
, cond_jump_flag
},
619 { "jnoH", Jb
, XX
, cond_jump_flag
},
620 { "jbH", Jb
, XX
, cond_jump_flag
},
621 { "jaeH", Jb
, XX
, cond_jump_flag
},
622 { "jeH", Jb
, XX
, cond_jump_flag
},
623 { "jneH", Jb
, XX
, cond_jump_flag
},
624 { "jbeH", Jb
, XX
, cond_jump_flag
},
625 { "jaH", Jb
, XX
, cond_jump_flag
},
627 { "jsH", Jb
, XX
, cond_jump_flag
},
628 { "jnsH", Jb
, XX
, cond_jump_flag
},
629 { "jpH", Jb
, XX
, cond_jump_flag
},
630 { "jnpH", Jb
, XX
, cond_jump_flag
},
631 { "jlH", Jb
, XX
, cond_jump_flag
},
632 { "jgeH", Jb
, XX
, cond_jump_flag
},
633 { "jleH", Jb
, XX
, cond_jump_flag
},
634 { "jgH", Jb
, XX
, cond_jump_flag
},
638 { "(bad)", XX
, XX
, XX
},
640 { "testB", Eb
, Gb
, XX
},
641 { "testS", Ev
, Gv
, XX
},
642 { "xchgB", Eb
, Gb
, XX
},
643 { "xchgS", Ev
, Gv
, XX
},
645 { "movB", Eb
, Gb
, XX
},
646 { "movS", Ev
, Gv
, XX
},
647 { "movB", Gb
, Eb
, XX
},
648 { "movS", Gv
, Ev
, XX
},
649 { "movQ", Sv
, Sw
, XX
},
650 { "leaS", Gv
, M
, XX
},
651 { "movQ", Sw
, Sv
, XX
},
652 { "popU", Ev
, XX
, XX
},
654 { "nop", NOP_Fixup
, 0, XX
, XX
},
655 { "xchgS", RMeCX
, eAX
, XX
},
656 { "xchgS", RMeDX
, eAX
, XX
},
657 { "xchgS", RMeBX
, eAX
, XX
},
658 { "xchgS", RMeSP
, eAX
, XX
},
659 { "xchgS", RMeBP
, eAX
, XX
},
660 { "xchgS", RMeSI
, eAX
, XX
},
661 { "xchgS", RMeDI
, eAX
, XX
},
663 { "cW{tR||tR|}", XX
, XX
, XX
},
664 { "cR{tO||tO|}", XX
, XX
, XX
},
665 { "Jcall{T|}", Ap
, XX
, XX
},
666 { "(bad)", XX
, XX
, XX
}, /* fwait */
667 { "pushfT", XX
, XX
, XX
},
668 { "popfT", XX
, XX
, XX
},
669 { "sahf{|}", XX
, XX
, XX
},
670 { "lahf{|}", XX
, XX
, XX
},
672 { "movB", AL
, Ob64
, XX
},
673 { "movS", eAX
, Ov64
, XX
},
674 { "movB", Ob64
, AL
, XX
},
675 { "movS", Ov64
, eAX
, XX
},
676 { "movs{b||b|}", Yb
, Xb
, XX
},
677 { "movs{R||R|}", Yv
, Xv
, XX
},
678 { "cmps{b||b|}", Xb
, Yb
, XX
},
679 { "cmps{R||R|}", Xv
, Yv
, XX
},
681 { "testB", AL
, Ib
, XX
},
682 { "testS", eAX
, Iv
, XX
},
683 { "stosB", Yb
, AL
, XX
},
684 { "stosS", Yv
, eAX
, XX
},
685 { "lodsB", AL
, Xb
, XX
},
686 { "lodsS", eAX
, Xv
, XX
},
687 { "scasB", AL
, Yb
, XX
},
688 { "scasS", eAX
, Yv
, XX
},
690 { "movB", RMAL
, Ib
, XX
},
691 { "movB", RMCL
, Ib
, XX
},
692 { "movB", RMDL
, Ib
, XX
},
693 { "movB", RMBL
, Ib
, XX
},
694 { "movB", RMAH
, Ib
, XX
},
695 { "movB", RMCH
, Ib
, XX
},
696 { "movB", RMDH
, Ib
, XX
},
697 { "movB", RMBH
, Ib
, XX
},
699 { "movS", RMeAX
, Iv64
, XX
},
700 { "movS", RMeCX
, Iv64
, XX
},
701 { "movS", RMeDX
, Iv64
, XX
},
702 { "movS", RMeBX
, Iv64
, XX
},
703 { "movS", RMeSP
, Iv64
, XX
},
704 { "movS", RMeBP
, Iv64
, XX
},
705 { "movS", RMeSI
, Iv64
, XX
},
706 { "movS", RMeDI
, Iv64
, XX
},
710 { "retT", Iw
, XX
, XX
},
711 { "retT", XX
, XX
, XX
},
712 { "les{S|}", Gv
, Mp
, XX
},
713 { "ldsS", Gv
, Mp
, XX
},
714 { "movA", Eb
, Ib
, XX
},
715 { "movQ", Ev
, Iv
, XX
},
717 { "enterT", Iw
, Ib
, XX
},
718 { "leaveT", XX
, XX
, XX
},
719 { "lretP", Iw
, XX
, XX
},
720 { "lretP", XX
, XX
, XX
},
721 { "int3", XX
, XX
, XX
},
722 { "int", Ib
, XX
, XX
},
723 { "into{|}", XX
, XX
, XX
},
724 { "iretP", XX
, XX
, XX
},
730 { "aam{|}", sIb
, XX
, XX
},
731 { "aad{|}", sIb
, XX
, XX
},
732 { "(bad)", XX
, XX
, XX
},
733 { "xlat", DSBX
, XX
, XX
},
744 { "loopneFH", Jb
, XX
, loop_jcxz_flag
},
745 { "loopeFH", Jb
, XX
, loop_jcxz_flag
},
746 { "loopFH", Jb
, XX
, loop_jcxz_flag
},
747 { "jEcxzH", Jb
, XX
, loop_jcxz_flag
},
748 { "inB", AL
, Ib
, XX
},
749 { "inS", eAX
, Ib
, XX
},
750 { "outB", Ib
, AL
, XX
},
751 { "outS", Ib
, eAX
, XX
},
753 { "callT", Jv
, XX
, XX
},
754 { "jmpT", Jv
, XX
, XX
},
755 { "Jjmp{T|}", Ap
, XX
, XX
},
756 { "jmp", Jb
, XX
, XX
},
757 { "inB", AL
, indirDX
, XX
},
758 { "inS", eAX
, indirDX
, XX
},
759 { "outB", indirDX
, AL
, XX
},
760 { "outS", indirDX
, eAX
, XX
},
762 { "(bad)", XX
, XX
, XX
}, /* lock prefix */
763 { "icebp", XX
, XX
, XX
},
764 { "(bad)", XX
, XX
, XX
}, /* repne */
765 { "(bad)", XX
, XX
, XX
}, /* repz */
766 { "hlt", XX
, XX
, XX
},
767 { "cmc", XX
, XX
, XX
},
771 { "clc", XX
, XX
, XX
},
772 { "stc", XX
, XX
, XX
},
773 { "cli", XX
, XX
, XX
},
774 { "sti", XX
, XX
, XX
},
775 { "cld", XX
, XX
, XX
},
776 { "std", XX
, XX
, XX
},
781 static const struct dis386 dis386_twobyte
[] = {
785 { "larS", Gv
, Ew
, XX
},
786 { "lslS", Gv
, Ew
, XX
},
787 { "(bad)", XX
, XX
, XX
},
788 { "syscall", XX
, XX
, XX
},
789 { "clts", XX
, XX
, XX
},
790 { "sysretP", XX
, XX
, XX
},
792 { "invd", XX
, XX
, XX
},
793 { "wbinvd", XX
, XX
, XX
},
794 { "(bad)", XX
, XX
, XX
},
795 { "ud2a", XX
, XX
, XX
},
796 { "(bad)", XX
, XX
, XX
},
798 { "femms", XX
, XX
, XX
},
799 { "", MX
, EM
, OPSUF
}, /* See OP_3DNowSuffix. */
804 { "movlpX", EX
, XM
, SIMD_Fixup
, 'h' },
805 { "unpcklpX", XM
, EX
, XX
},
806 { "unpckhpX", XM
, EX
, XX
},
808 { "movhpX", EX
, XM
, SIMD_Fixup
, 'l' },
811 { "(bad)", XX
, XX
, XX
},
812 { "(bad)", XX
, XX
, XX
},
813 { "(bad)", XX
, XX
, XX
},
814 { "(bad)", XX
, XX
, XX
},
815 { "(bad)", XX
, XX
, XX
},
816 { "(bad)", XX
, XX
, XX
},
817 { "(bad)", XX
, XX
, XX
},
819 { "movL", Rm
, Cm
, XX
},
820 { "movL", Rm
, Dm
, XX
},
821 { "movL", Cm
, Rm
, XX
},
822 { "movL", Dm
, Rm
, XX
},
823 { "movL", Rd
, Td
, XX
},
824 { "(bad)", XX
, XX
, XX
},
825 { "movL", Td
, Rd
, XX
},
826 { "(bad)", XX
, XX
, XX
},
828 { "movapX", XM
, EX
, XX
},
829 { "movapX", EX
, XM
, XX
},
831 { "movntpX", Ev
, XM
, XX
},
834 { "ucomisX", XM
,EX
, XX
},
835 { "comisX", XM
,EX
, XX
},
837 { "wrmsr", XX
, XX
, XX
},
838 { "rdtsc", XX
, XX
, XX
},
839 { "rdmsr", XX
, XX
, XX
},
840 { "rdpmc", XX
, XX
, XX
},
841 { "sysenter", XX
, XX
, XX
},
842 { "sysexit", XX
, XX
, XX
},
843 { "(bad)", XX
, XX
, XX
},
844 { "(bad)", XX
, XX
, XX
},
846 { "(bad)", XX
, XX
, XX
},
847 { "(bad)", XX
, XX
, XX
},
848 { "(bad)", XX
, XX
, XX
},
849 { "(bad)", XX
, XX
, XX
},
850 { "(bad)", XX
, XX
, XX
},
851 { "(bad)", XX
, XX
, XX
},
852 { "(bad)", XX
, XX
, XX
},
853 { "(bad)", XX
, XX
, XX
},
855 { "cmovo", Gv
, Ev
, XX
},
856 { "cmovno", Gv
, Ev
, XX
},
857 { "cmovb", Gv
, Ev
, XX
},
858 { "cmovae", Gv
, Ev
, XX
},
859 { "cmove", Gv
, Ev
, XX
},
860 { "cmovne", Gv
, Ev
, XX
},
861 { "cmovbe", Gv
, Ev
, XX
},
862 { "cmova", Gv
, Ev
, XX
},
864 { "cmovs", Gv
, Ev
, XX
},
865 { "cmovns", Gv
, Ev
, XX
},
866 { "cmovp", Gv
, Ev
, XX
},
867 { "cmovnp", Gv
, Ev
, XX
},
868 { "cmovl", Gv
, Ev
, XX
},
869 { "cmovge", Gv
, Ev
, XX
},
870 { "cmovle", Gv
, Ev
, XX
},
871 { "cmovg", Gv
, Ev
, XX
},
873 { "movmskpX", Gdq
, XS
, XX
},
877 { "andpX", XM
, EX
, XX
},
878 { "andnpX", XM
, EX
, XX
},
879 { "orpX", XM
, EX
, XX
},
880 { "xorpX", XM
, EX
, XX
},
891 { "punpcklbw", MX
, EM
, XX
},
892 { "punpcklwd", MX
, EM
, XX
},
893 { "punpckldq", MX
, EM
, XX
},
894 { "packsswb", MX
, EM
, XX
},
895 { "pcmpgtb", MX
, EM
, XX
},
896 { "pcmpgtw", MX
, EM
, XX
},
897 { "pcmpgtd", MX
, EM
, XX
},
898 { "packuswb", MX
, EM
, XX
},
900 { "punpckhbw", MX
, EM
, XX
},
901 { "punpckhwd", MX
, EM
, XX
},
902 { "punpckhdq", MX
, EM
, XX
},
903 { "packssdw", MX
, EM
, XX
},
906 { "movd", MX
, Edq
, XX
},
913 { "pcmpeqb", MX
, EM
, XX
},
914 { "pcmpeqw", MX
, EM
, XX
},
915 { "pcmpeqd", MX
, EM
, XX
},
916 { "emms", XX
, XX
, XX
},
918 { "(bad)", XX
, XX
, XX
},
919 { "(bad)", XX
, XX
, XX
},
920 { "(bad)", XX
, XX
, XX
},
921 { "(bad)", XX
, XX
, XX
},
927 { "joH", Jv
, XX
, cond_jump_flag
},
928 { "jnoH", Jv
, XX
, cond_jump_flag
},
929 { "jbH", Jv
, XX
, cond_jump_flag
},
930 { "jaeH", Jv
, XX
, cond_jump_flag
},
931 { "jeH", Jv
, XX
, cond_jump_flag
},
932 { "jneH", Jv
, XX
, cond_jump_flag
},
933 { "jbeH", Jv
, XX
, cond_jump_flag
},
934 { "jaH", Jv
, XX
, cond_jump_flag
},
936 { "jsH", Jv
, XX
, cond_jump_flag
},
937 { "jnsH", Jv
, XX
, cond_jump_flag
},
938 { "jpH", Jv
, XX
, cond_jump_flag
},
939 { "jnpH", Jv
, XX
, cond_jump_flag
},
940 { "jlH", Jv
, XX
, cond_jump_flag
},
941 { "jgeH", Jv
, XX
, cond_jump_flag
},
942 { "jleH", Jv
, XX
, cond_jump_flag
},
943 { "jgH", Jv
, XX
, cond_jump_flag
},
945 { "seto", Eb
, XX
, XX
},
946 { "setno", Eb
, XX
, XX
},
947 { "setb", Eb
, XX
, XX
},
948 { "setae", Eb
, XX
, XX
},
949 { "sete", Eb
, XX
, XX
},
950 { "setne", Eb
, XX
, XX
},
951 { "setbe", Eb
, XX
, XX
},
952 { "seta", Eb
, XX
, XX
},
954 { "sets", Eb
, XX
, XX
},
955 { "setns", Eb
, XX
, XX
},
956 { "setp", Eb
, XX
, XX
},
957 { "setnp", Eb
, XX
, XX
},
958 { "setl", Eb
, XX
, XX
},
959 { "setge", Eb
, XX
, XX
},
960 { "setle", Eb
, XX
, XX
},
961 { "setg", Eb
, XX
, XX
},
963 { "pushT", fs
, XX
, XX
},
964 { "popT", fs
, XX
, XX
},
965 { "cpuid", XX
, XX
, XX
},
966 { "btS", Ev
, Gv
, XX
},
967 { "shldS", Ev
, Gv
, Ib
},
968 { "shldS", Ev
, Gv
, CL
},
972 { "pushT", gs
, XX
, XX
},
973 { "popT", gs
, XX
, XX
},
974 { "rsm", XX
, XX
, XX
},
975 { "btsS", Ev
, Gv
, XX
},
976 { "shrdS", Ev
, Gv
, Ib
},
977 { "shrdS", Ev
, Gv
, CL
},
979 { "imulS", Gv
, Ev
, XX
},
981 { "cmpxchgB", Eb
, Gb
, XX
},
982 { "cmpxchgS", Ev
, Gv
, XX
},
983 { "lssS", Gv
, Mp
, XX
},
984 { "btrS", Ev
, Gv
, XX
},
985 { "lfsS", Gv
, Mp
, XX
},
986 { "lgsS", Gv
, Mp
, XX
},
987 { "movz{bR|x|bR|x}", Gv
, Eb
, XX
},
988 { "movz{wR|x|wR|x}", Gv
, Ew
, XX
}, /* yes, there really is movzww ! */
990 { "(bad)", XX
, XX
, XX
},
991 { "ud2b", XX
, XX
, XX
},
993 { "btcS", Ev
, Gv
, XX
},
994 { "bsfS", Gv
, Ev
, XX
},
995 { "bsrS", Gv
, Ev
, XX
},
996 { "movs{bR|x|bR|x}", Gv
, Eb
, XX
},
997 { "movs{wR|x|wR|x}", Gv
, Ew
, XX
}, /* yes, there really is movsww ! */
999 { "xaddB", Eb
, Gb
, XX
},
1000 { "xaddS", Ev
, Gv
, XX
},
1002 { "movntiS", Ev
, Gv
, XX
},
1003 { "pinsrw", MX
, Edqw
, Ib
},
1004 { "pextrw", Gdq
, MS
, Ib
},
1005 { "shufpX", XM
, EX
, Ib
},
1008 { "bswap", RMeAX
, XX
, XX
},
1009 { "bswap", RMeCX
, XX
, XX
},
1010 { "bswap", RMeDX
, XX
, XX
},
1011 { "bswap", RMeBX
, XX
, XX
},
1012 { "bswap", RMeSP
, XX
, XX
},
1013 { "bswap", RMeBP
, XX
, XX
},
1014 { "bswap", RMeSI
, XX
, XX
},
1015 { "bswap", RMeDI
, XX
, XX
},
1018 { "psrlw", MX
, EM
, XX
},
1019 { "psrld", MX
, EM
, XX
},
1020 { "psrlq", MX
, EM
, XX
},
1021 { "paddq", MX
, EM
, XX
},
1022 { "pmullw", MX
, EM
, XX
},
1024 { "pmovmskb", Gdq
, MS
, XX
},
1026 { "psubusb", MX
, EM
, XX
},
1027 { "psubusw", MX
, EM
, XX
},
1028 { "pminub", MX
, EM
, XX
},
1029 { "pand", MX
, EM
, XX
},
1030 { "paddusb", MX
, EM
, XX
},
1031 { "paddusw", MX
, EM
, XX
},
1032 { "pmaxub", MX
, EM
, XX
},
1033 { "pandn", MX
, EM
, XX
},
1035 { "pavgb", MX
, EM
, XX
},
1036 { "psraw", MX
, EM
, XX
},
1037 { "psrad", MX
, EM
, XX
},
1038 { "pavgw", MX
, EM
, XX
},
1039 { "pmulhuw", MX
, EM
, XX
},
1040 { "pmulhw", MX
, EM
, XX
},
1044 { "psubsb", MX
, EM
, XX
},
1045 { "psubsw", MX
, EM
, XX
},
1046 { "pminsw", MX
, EM
, XX
},
1047 { "por", MX
, EM
, XX
},
1048 { "paddsb", MX
, EM
, XX
},
1049 { "paddsw", MX
, EM
, XX
},
1050 { "pmaxsw", MX
, EM
, XX
},
1051 { "pxor", MX
, EM
, XX
},
1054 { "psllw", MX
, EM
, XX
},
1055 { "pslld", MX
, EM
, XX
},
1056 { "psllq", MX
, EM
, XX
},
1057 { "pmuludq", MX
, EM
, XX
},
1058 { "pmaddwd", MX
, EM
, XX
},
1059 { "psadbw", MX
, EM
, XX
},
1062 { "psubb", MX
, EM
, XX
},
1063 { "psubw", MX
, EM
, XX
},
1064 { "psubd", MX
, EM
, XX
},
1065 { "psubq", MX
, EM
, XX
},
1066 { "paddb", MX
, EM
, XX
},
1067 { "paddw", MX
, EM
, XX
},
1068 { "paddd", MX
, EM
, XX
},
1069 { "(bad)", XX
, XX
, XX
}
1072 static const unsigned char onebyte_has_modrm
[256] = {
1073 /* 0 1 2 3 4 5 6 7 8 9 a b c d e f */
1074 /* ------------------------------- */
1075 /* 00 */ 1,1,1,1,0,0,0,0,1,1,1,1,0,0,0,0, /* 00 */
1076 /* 10 */ 1,1,1,1,0,0,0,0,1,1,1,1,0,0,0,0, /* 10 */
1077 /* 20 */ 1,1,1,1,0,0,0,0,1,1,1,1,0,0,0,0, /* 20 */
1078 /* 30 */ 1,1,1,1,0,0,0,0,1,1,1,1,0,0,0,0, /* 30 */
1079 /* 40 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 40 */
1080 /* 50 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 50 */
1081 /* 60 */ 0,0,1,1,0,0,0,0,0,1,0,1,0,0,0,0, /* 60 */
1082 /* 70 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 70 */
1083 /* 80 */ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, /* 80 */
1084 /* 90 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 90 */
1085 /* a0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* a0 */
1086 /* b0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* b0 */
1087 /* c0 */ 1,1,0,0,1,1,1,1,0,0,0,0,0,0,0,0, /* c0 */
1088 /* d0 */ 1,1,1,1,0,0,0,0,1,1,1,1,1,1,1,1, /* d0 */
1089 /* e0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* e0 */
1090 /* f0 */ 0,0,0,0,0,0,1,1,0,0,0,0,0,0,1,1 /* f0 */
1091 /* ------------------------------- */
1092 /* 0 1 2 3 4 5 6 7 8 9 a b c d e f */
1095 static const unsigned char twobyte_has_modrm
[256] = {
1096 /* 0 1 2 3 4 5 6 7 8 9 a b c d e f */
1097 /* ------------------------------- */
1098 /* 00 */ 1,1,1,1,0,0,0,0,0,0,0,0,0,1,0,1, /* 0f */
1099 /* 10 */ 1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0, /* 1f */
1100 /* 20 */ 1,1,1,1,1,0,1,0,1,1,1,1,1,1,1,1, /* 2f */
1101 /* 30 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 3f */
1102 /* 40 */ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, /* 4f */
1103 /* 50 */ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, /* 5f */
1104 /* 60 */ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, /* 6f */
1105 /* 70 */ 1,1,1,1,1,1,1,0,0,0,0,0,1,1,1,1, /* 7f */
1106 /* 80 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 8f */
1107 /* 90 */ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, /* 9f */
1108 /* a0 */ 0,0,0,1,1,1,1,1,0,0,0,1,1,1,1,1, /* af */
1109 /* b0 */ 1,1,1,1,1,1,1,1,0,0,1,1,1,1,1,1, /* bf */
1110 /* c0 */ 1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0, /* cf */
1111 /* d0 */ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, /* df */
1112 /* e0 */ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, /* ef */
1113 /* f0 */ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0 /* ff */
1114 /* ------------------------------- */
1115 /* 0 1 2 3 4 5 6 7 8 9 a b c d e f */
1118 static const unsigned char twobyte_uses_SSE_prefix
[256] = {
1119 /* 0 1 2 3 4 5 6 7 8 9 a b c d e f */
1120 /* ------------------------------- */
1121 /* 00 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0f */
1122 /* 10 */ 1,1,1,0,0,0,1,0,0,0,0,0,0,0,0,0, /* 1f */
1123 /* 20 */ 0,0,0,0,0,0,0,0,0,0,1,0,1,1,0,0, /* 2f */
1124 /* 30 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 3f */
1125 /* 40 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 4f */
1126 /* 50 */ 0,1,1,1,0,0,0,0,1,1,1,1,1,1,1,1, /* 5f */
1127 /* 60 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1, /* 6f */
1128 /* 70 */ 1,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1, /* 7f */
1129 /* 80 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 8f */
1130 /* 90 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 9f */
1131 /* a0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* af */
1132 /* b0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* bf */
1133 /* c0 */ 0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0, /* cf */
1134 /* d0 */ 1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0, /* df */
1135 /* e0 */ 0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0, /* ef */
1136 /* f0 */ 1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0 /* ff */
1137 /* ------------------------------- */
1138 /* 0 1 2 3 4 5 6 7 8 9 a b c d e f */
1141 static char obuf
[100];
1143 static char scratchbuf
[100];
1144 static unsigned char *start_codep
;
1145 static unsigned char *insn_codep
;
1146 static unsigned char *codep
;
1147 static disassemble_info
*the_info
;
1151 static unsigned char need_modrm
;
1153 /* If we are accessing mod/rm/reg without need_modrm set, then the
1154 values are stale. Hitting this abort likely indicates that you
1155 need to update onebyte_has_modrm or twobyte_has_modrm. */
1156 #define MODRM_CHECK if (!need_modrm) abort ()
1158 static const char **names64
;
1159 static const char **names32
;
1160 static const char **names16
;
1161 static const char **names8
;
1162 static const char **names8rex
;
1163 static const char **names_seg
;
1164 static const char **index16
;
1166 static const char *intel_names64
[] = {
1167 "rax", "rcx", "rdx", "rbx", "rsp", "rbp", "rsi", "rdi",
1168 "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15"
1170 static const char *intel_names32
[] = {
1171 "eax", "ecx", "edx", "ebx", "esp", "ebp", "esi", "edi",
1172 "r8d", "r9d", "r10d", "r11d", "r12d", "r13d", "r14d", "r15d"
1174 static const char *intel_names16
[] = {
1175 "ax", "cx", "dx", "bx", "sp", "bp", "si", "di",
1176 "r8w", "r9w", "r10w", "r11w", "r12w", "r13w", "r14w", "r15w"
1178 static const char *intel_names8
[] = {
1179 "al", "cl", "dl", "bl", "ah", "ch", "dh", "bh",
1181 static const char *intel_names8rex
[] = {
1182 "al", "cl", "dl", "bl", "spl", "bpl", "sil", "dil",
1183 "r8b", "r9b", "r10b", "r11b", "r12b", "r13b", "r14b", "r15b"
1185 static const char *intel_names_seg
[] = {
1186 "es", "cs", "ss", "ds", "fs", "gs", "?", "?",
1188 static const char *intel_index16
[] = {
1189 "bx+si", "bx+di", "bp+si", "bp+di", "si", "di", "bp", "bx"
1192 static const char *att_names64
[] = {
1193 "%rax", "%rcx", "%rdx", "%rbx", "%rsp", "%rbp", "%rsi", "%rdi",
1194 "%r8", "%r9", "%r10", "%r11", "%r12", "%r13", "%r14", "%r15"
1196 static const char *att_names32
[] = {
1197 "%eax", "%ecx", "%edx", "%ebx", "%esp", "%ebp", "%esi", "%edi",
1198 "%r8d", "%r9d", "%r10d", "%r11d", "%r12d", "%r13d", "%r14d", "%r15d"
1200 static const char *att_names16
[] = {
1201 "%ax", "%cx", "%dx", "%bx", "%sp", "%bp", "%si", "%di",
1202 "%r8w", "%r9w", "%r10w", "%r11w", "%r12w", "%r13w", "%r14w", "%r15w"
1204 static const char *att_names8
[] = {
1205 "%al", "%cl", "%dl", "%bl", "%ah", "%ch", "%dh", "%bh",
1207 static const char *att_names8rex
[] = {
1208 "%al", "%cl", "%dl", "%bl", "%spl", "%bpl", "%sil", "%dil",
1209 "%r8b", "%r9b", "%r10b", "%r11b", "%r12b", "%r13b", "%r14b", "%r15b"
1211 static const char *att_names_seg
[] = {
1212 "%es", "%cs", "%ss", "%ds", "%fs", "%gs", "%?", "%?",
1214 static const char *att_index16
[] = {
1215 "%bx,%si", "%bx,%di", "%bp,%si", "%bp,%di", "%si", "%di", "%bp", "%bx"
1218 static const struct dis386 grps
[][8] = {
1221 { "addA", Eb
, Ib
, XX
},
1222 { "orA", Eb
, Ib
, XX
},
1223 { "adcA", Eb
, Ib
, XX
},
1224 { "sbbA", Eb
, Ib
, XX
},
1225 { "andA", Eb
, Ib
, XX
},
1226 { "subA", Eb
, Ib
, XX
},
1227 { "xorA", Eb
, Ib
, XX
},
1228 { "cmpA", Eb
, Ib
, XX
}
1232 { "addQ", Ev
, Iv
, XX
},
1233 { "orQ", Ev
, Iv
, XX
},
1234 { "adcQ", Ev
, Iv
, XX
},
1235 { "sbbQ", Ev
, Iv
, XX
},
1236 { "andQ", Ev
, Iv
, XX
},
1237 { "subQ", Ev
, Iv
, XX
},
1238 { "xorQ", Ev
, Iv
, XX
},
1239 { "cmpQ", Ev
, Iv
, XX
}
1243 { "addQ", Ev
, sIb
, XX
},
1244 { "orQ", Ev
, sIb
, XX
},
1245 { "adcQ", Ev
, sIb
, XX
},
1246 { "sbbQ", Ev
, sIb
, XX
},
1247 { "andQ", Ev
, sIb
, XX
},
1248 { "subQ", Ev
, sIb
, XX
},
1249 { "xorQ", Ev
, sIb
, XX
},
1250 { "cmpQ", Ev
, sIb
, XX
}
1254 { "rolA", Eb
, Ib
, XX
},
1255 { "rorA", Eb
, Ib
, XX
},
1256 { "rclA", Eb
, Ib
, XX
},
1257 { "rcrA", Eb
, Ib
, XX
},
1258 { "shlA", Eb
, Ib
, XX
},
1259 { "shrA", Eb
, Ib
, XX
},
1260 { "(bad)", XX
, XX
, XX
},
1261 { "sarA", Eb
, Ib
, XX
},
1265 { "rolQ", Ev
, Ib
, XX
},
1266 { "rorQ", Ev
, Ib
, XX
},
1267 { "rclQ", Ev
, Ib
, XX
},
1268 { "rcrQ", Ev
, Ib
, XX
},
1269 { "shlQ", Ev
, Ib
, XX
},
1270 { "shrQ", Ev
, Ib
, XX
},
1271 { "(bad)", XX
, XX
, XX
},
1272 { "sarQ", Ev
, Ib
, XX
},
1276 { "rolA", Eb
, I1
, XX
},
1277 { "rorA", Eb
, I1
, XX
},
1278 { "rclA", Eb
, I1
, XX
},
1279 { "rcrA", Eb
, I1
, XX
},
1280 { "shlA", Eb
, I1
, XX
},
1281 { "shrA", Eb
, I1
, XX
},
1282 { "(bad)", XX
, XX
, XX
},
1283 { "sarA", Eb
, I1
, XX
},
1287 { "rolQ", Ev
, I1
, XX
},
1288 { "rorQ", Ev
, I1
, XX
},
1289 { "rclQ", Ev
, I1
, XX
},
1290 { "rcrQ", Ev
, I1
, XX
},
1291 { "shlQ", Ev
, I1
, XX
},
1292 { "shrQ", Ev
, I1
, XX
},
1293 { "(bad)", XX
, XX
, XX
},
1294 { "sarQ", Ev
, I1
, XX
},
1298 { "rolA", Eb
, CL
, XX
},
1299 { "rorA", Eb
, CL
, XX
},
1300 { "rclA", Eb
, CL
, XX
},
1301 { "rcrA", Eb
, CL
, XX
},
1302 { "shlA", Eb
, CL
, XX
},
1303 { "shrA", Eb
, CL
, XX
},
1304 { "(bad)", XX
, XX
, XX
},
1305 { "sarA", Eb
, CL
, XX
},
1309 { "rolQ", Ev
, CL
, XX
},
1310 { "rorQ", Ev
, CL
, XX
},
1311 { "rclQ", Ev
, CL
, XX
},
1312 { "rcrQ", Ev
, CL
, XX
},
1313 { "shlQ", Ev
, CL
, XX
},
1314 { "shrQ", Ev
, CL
, XX
},
1315 { "(bad)", XX
, XX
, XX
},
1316 { "sarQ", Ev
, CL
, XX
}
1320 { "testA", Eb
, Ib
, XX
},
1321 { "(bad)", Eb
, XX
, XX
},
1322 { "notA", Eb
, XX
, XX
},
1323 { "negA", Eb
, XX
, XX
},
1324 { "mulA", Eb
, XX
, XX
}, /* Don't print the implicit %al register, */
1325 { "imulA", Eb
, XX
, XX
}, /* to distinguish these opcodes from other */
1326 { "divA", Eb
, XX
, XX
}, /* mul/imul opcodes. Do the same for div */
1327 { "idivA", Eb
, XX
, XX
} /* and idiv for consistency. */
1331 { "testQ", Ev
, Iv
, XX
},
1332 { "(bad)", XX
, XX
, XX
},
1333 { "notQ", Ev
, XX
, XX
},
1334 { "negQ", Ev
, XX
, XX
},
1335 { "mulQ", Ev
, XX
, XX
}, /* Don't print the implicit register. */
1336 { "imulQ", Ev
, XX
, XX
},
1337 { "divQ", Ev
, XX
, XX
},
1338 { "idivQ", Ev
, XX
, XX
},
1342 { "incA", Eb
, XX
, XX
},
1343 { "decA", Eb
, XX
, XX
},
1344 { "(bad)", XX
, XX
, XX
},
1345 { "(bad)", XX
, XX
, XX
},
1346 { "(bad)", XX
, XX
, XX
},
1347 { "(bad)", XX
, XX
, XX
},
1348 { "(bad)", XX
, XX
, XX
},
1349 { "(bad)", XX
, XX
, XX
},
1353 { "incQ", Ev
, XX
, XX
},
1354 { "decQ", Ev
, XX
, XX
},
1355 { "callT", indirEv
, XX
, XX
},
1356 { "JcallT", indirEp
, XX
, XX
},
1357 { "jmpT", indirEv
, XX
, XX
},
1358 { "JjmpT", indirEp
, XX
, XX
},
1359 { "pushU", Ev
, XX
, XX
},
1360 { "(bad)", XX
, XX
, XX
},
1364 { "sldtQ", Ev
, XX
, XX
},
1365 { "strQ", Ev
, XX
, XX
},
1366 { "lldt", Ew
, XX
, XX
},
1367 { "ltr", Ew
, XX
, XX
},
1368 { "verr", Ew
, XX
, XX
},
1369 { "verw", Ew
, XX
, XX
},
1370 { "(bad)", XX
, XX
, XX
},
1371 { "(bad)", XX
, XX
, XX
}
1375 { "sgdtIQ", M
, XX
, XX
},
1376 { "sidtIQ", PNI_Fixup
, 0, XX
, XX
},
1377 { "lgdt{Q|Q||}", M
, XX
, XX
},
1378 { "lidt{Q|Q||}", SVME_Fixup
, 0, XX
, XX
},
1379 { "smswQ", Ev
, XX
, XX
},
1380 { "(bad)", XX
, XX
, XX
},
1381 { "lmsw", Ew
, XX
, XX
},
1382 { "invlpg", INVLPG_Fixup
, w_mode
, XX
, XX
},
1386 { "(bad)", XX
, XX
, XX
},
1387 { "(bad)", XX
, XX
, XX
},
1388 { "(bad)", XX
, XX
, XX
},
1389 { "(bad)", XX
, XX
, XX
},
1390 { "btQ", Ev
, Ib
, XX
},
1391 { "btsQ", Ev
, Ib
, XX
},
1392 { "btrQ", Ev
, Ib
, XX
},
1393 { "btcQ", Ev
, Ib
, XX
},
1397 { "(bad)", XX
, XX
, XX
},
1398 { "cmpxchg8b", Eq
, XX
, XX
},
1399 { "(bad)", XX
, XX
, XX
},
1400 { "(bad)", XX
, XX
, XX
},
1401 { "(bad)", XX
, XX
, XX
},
1402 { "(bad)", XX
, XX
, XX
},
1403 { "(bad)", XX
, XX
, XX
},
1404 { "(bad)", XX
, XX
, XX
},
1408 { "(bad)", XX
, XX
, XX
},
1409 { "(bad)", XX
, XX
, XX
},
1410 { "psrlw", MS
, Ib
, XX
},
1411 { "(bad)", XX
, XX
, XX
},
1412 { "psraw", MS
, Ib
, XX
},
1413 { "(bad)", XX
, XX
, XX
},
1414 { "psllw", MS
, Ib
, XX
},
1415 { "(bad)", XX
, XX
, XX
},
1419 { "(bad)", XX
, XX
, XX
},
1420 { "(bad)", XX
, XX
, XX
},
1421 { "psrld", MS
, Ib
, XX
},
1422 { "(bad)", XX
, XX
, XX
},
1423 { "psrad", MS
, Ib
, XX
},
1424 { "(bad)", XX
, XX
, XX
},
1425 { "pslld", MS
, Ib
, XX
},
1426 { "(bad)", XX
, XX
, XX
},
1430 { "(bad)", XX
, XX
, XX
},
1431 { "(bad)", XX
, XX
, XX
},
1432 { "psrlq", MS
, Ib
, XX
},
1433 { "psrldq", MS
, Ib
, XX
},
1434 { "(bad)", XX
, XX
, XX
},
1435 { "(bad)", XX
, XX
, XX
},
1436 { "psllq", MS
, Ib
, XX
},
1437 { "pslldq", MS
, Ib
, XX
},
1441 { "fxsave", Ev
, XX
, XX
},
1442 { "fxrstor", Ev
, XX
, XX
},
1443 { "ldmxcsr", Ev
, XX
, XX
},
1444 { "stmxcsr", Ev
, XX
, XX
},
1445 { "(bad)", XX
, XX
, XX
},
1446 { "lfence", OP_0fae
, 0, XX
, XX
},
1447 { "mfence", OP_0fae
, 0, XX
, XX
},
1448 { "clflush", OP_0fae
, 0, XX
, XX
},
1452 { "prefetchnta", Ev
, XX
, XX
},
1453 { "prefetcht0", Ev
, XX
, XX
},
1454 { "prefetcht1", Ev
, XX
, XX
},
1455 { "prefetcht2", Ev
, XX
, XX
},
1456 { "(bad)", XX
, XX
, XX
},
1457 { "(bad)", XX
, XX
, XX
},
1458 { "(bad)", XX
, XX
, XX
},
1459 { "(bad)", XX
, XX
, XX
},
1463 { "prefetch", Eb
, XX
, XX
},
1464 { "prefetchw", Eb
, XX
, XX
},
1465 { "(bad)", XX
, XX
, XX
},
1466 { "(bad)", XX
, XX
, XX
},
1467 { "(bad)", XX
, XX
, XX
},
1468 { "(bad)", XX
, XX
, XX
},
1469 { "(bad)", XX
, XX
, XX
},
1470 { "(bad)", XX
, XX
, XX
},
1474 { "xstore-rng", OP_0f07
, 0, XX
, XX
},
1475 { "xcrypt-ecb", OP_0f07
, 0, XX
, XX
},
1476 { "xcrypt-cbc", OP_0f07
, 0, XX
, XX
},
1477 { "xcrypt-ctr", OP_0f07
, 0, XX
, XX
},
1478 { "xcrypt-cfb", OP_0f07
, 0, XX
, XX
},
1479 { "xcrypt-ofb", OP_0f07
, 0, XX
, XX
},
1480 { "(bad)", OP_0f07
, 0, XX
, XX
},
1481 { "(bad)", OP_0f07
, 0, XX
, XX
},
1485 { "montmul", OP_0f07
, 0, XX
, XX
},
1486 { "xsha1", OP_0f07
, 0, XX
, XX
},
1487 { "xsha256", OP_0f07
, 0, XX
, XX
},
1488 { "(bad)", OP_0f07
, 0, XX
, XX
},
1489 { "(bad)", OP_0f07
, 0, XX
, XX
},
1490 { "(bad)", OP_0f07
, 0, XX
, XX
},
1491 { "(bad)", OP_0f07
, 0, XX
, XX
},
1492 { "(bad)", OP_0f07
, 0, XX
, XX
},
1496 static const struct dis386 prefix_user_table
[][4] = {
1499 { "addps", XM
, EX
, XX
},
1500 { "addss", XM
, EX
, XX
},
1501 { "addpd", XM
, EX
, XX
},
1502 { "addsd", XM
, EX
, XX
},
1506 { "", XM
, EX
, OPSIMD
}, /* See OP_SIMD_SUFFIX. */
1507 { "", XM
, EX
, OPSIMD
},
1508 { "", XM
, EX
, OPSIMD
},
1509 { "", XM
, EX
, OPSIMD
},
1513 { "cvtpi2ps", XM
, EM
, XX
},
1514 { "cvtsi2ssY", XM
, Ev
, XX
},
1515 { "cvtpi2pd", XM
, EM
, XX
},
1516 { "cvtsi2sdY", XM
, Ev
, XX
},
1520 { "cvtps2pi", MX
, EX
, XX
},
1521 { "cvtss2siY", Gv
, EX
, XX
},
1522 { "cvtpd2pi", MX
, EX
, XX
},
1523 { "cvtsd2siY", Gv
, EX
, XX
},
1527 { "cvttps2pi", MX
, EX
, XX
},
1528 { "cvttss2siY", Gv
, EX
, XX
},
1529 { "cvttpd2pi", MX
, EX
, XX
},
1530 { "cvttsd2siY", Gv
, EX
, XX
},
1534 { "divps", XM
, EX
, XX
},
1535 { "divss", XM
, EX
, XX
},
1536 { "divpd", XM
, EX
, XX
},
1537 { "divsd", XM
, EX
, XX
},
1541 { "maxps", XM
, EX
, XX
},
1542 { "maxss", XM
, EX
, XX
},
1543 { "maxpd", XM
, EX
, XX
},
1544 { "maxsd", XM
, EX
, XX
},
1548 { "minps", XM
, EX
, XX
},
1549 { "minss", XM
, EX
, XX
},
1550 { "minpd", XM
, EX
, XX
},
1551 { "minsd", XM
, EX
, XX
},
1555 { "movups", XM
, EX
, XX
},
1556 { "movss", XM
, EX
, XX
},
1557 { "movupd", XM
, EX
, XX
},
1558 { "movsd", XM
, EX
, XX
},
1562 { "movups", EX
, XM
, XX
},
1563 { "movss", EX
, XM
, XX
},
1564 { "movupd", EX
, XM
, XX
},
1565 { "movsd", EX
, XM
, XX
},
1569 { "mulps", XM
, EX
, XX
},
1570 { "mulss", XM
, EX
, XX
},
1571 { "mulpd", XM
, EX
, XX
},
1572 { "mulsd", XM
, EX
, XX
},
1576 { "rcpps", XM
, EX
, XX
},
1577 { "rcpss", XM
, EX
, XX
},
1578 { "(bad)", XM
, EX
, XX
},
1579 { "(bad)", XM
, EX
, XX
},
1583 { "rsqrtps", XM
, EX
, XX
},
1584 { "rsqrtss", XM
, EX
, XX
},
1585 { "(bad)", XM
, EX
, XX
},
1586 { "(bad)", XM
, EX
, XX
},
1590 { "sqrtps", XM
, EX
, XX
},
1591 { "sqrtss", XM
, EX
, XX
},
1592 { "sqrtpd", XM
, EX
, XX
},
1593 { "sqrtsd", XM
, EX
, XX
},
1597 { "subps", XM
, EX
, XX
},
1598 { "subss", XM
, EX
, XX
},
1599 { "subpd", XM
, EX
, XX
},
1600 { "subsd", XM
, EX
, XX
},
1604 { "(bad)", XM
, EX
, XX
},
1605 { "cvtdq2pd", XM
, EX
, XX
},
1606 { "cvttpd2dq", XM
, EX
, XX
},
1607 { "cvtpd2dq", XM
, EX
, XX
},
1611 { "cvtdq2ps", XM
, EX
, XX
},
1612 { "cvttps2dq",XM
, EX
, XX
},
1613 { "cvtps2dq",XM
, EX
, XX
},
1614 { "(bad)", XM
, EX
, XX
},
1618 { "cvtps2pd", XM
, EX
, XX
},
1619 { "cvtss2sd", XM
, EX
, XX
},
1620 { "cvtpd2ps", XM
, EX
, XX
},
1621 { "cvtsd2ss", XM
, EX
, XX
},
1625 { "maskmovq", MX
, MS
, XX
},
1626 { "(bad)", XM
, EX
, XX
},
1627 { "maskmovdqu", XM
, EX
, XX
},
1628 { "(bad)", XM
, EX
, XX
},
1632 { "movq", MX
, EM
, XX
},
1633 { "movdqu", XM
, EX
, XX
},
1634 { "movdqa", XM
, EX
, XX
},
1635 { "(bad)", XM
, EX
, XX
},
1639 { "movq", EM
, MX
, XX
},
1640 { "movdqu", EX
, XM
, XX
},
1641 { "movdqa", EX
, XM
, XX
},
1642 { "(bad)", EX
, XM
, XX
},
1646 { "(bad)", EX
, XM
, XX
},
1647 { "movq2dq", XM
, MS
, XX
},
1648 { "movq", EX
, XM
, XX
},
1649 { "movdq2q", MX
, XS
, XX
},
1653 { "pshufw", MX
, EM
, Ib
},
1654 { "pshufhw", XM
, EX
, Ib
},
1655 { "pshufd", XM
, EX
, Ib
},
1656 { "pshuflw", XM
, EX
, Ib
},
1660 { "movd", Edq
, MX
, XX
},
1661 { "movq", XM
, EX
, XX
},
1662 { "movd", Edq
, XM
, XX
},
1663 { "(bad)", Ed
, XM
, XX
},
1667 { "(bad)", MX
, EX
, XX
},
1668 { "(bad)", XM
, EX
, XX
},
1669 { "punpckhqdq", XM
, EX
, XX
},
1670 { "(bad)", XM
, EX
, XX
},
1674 { "movntq", EM
, MX
, XX
},
1675 { "(bad)", EM
, XM
, XX
},
1676 { "movntdq", EM
, XM
, XX
},
1677 { "(bad)", EM
, XM
, XX
},
1681 { "(bad)", MX
, EX
, XX
},
1682 { "(bad)", XM
, EX
, XX
},
1683 { "punpcklqdq", XM
, EX
, XX
},
1684 { "(bad)", XM
, EX
, XX
},
1688 { "(bad)", MX
, EX
, XX
},
1689 { "(bad)", XM
, EX
, XX
},
1690 { "addsubpd", XM
, EX
, XX
},
1691 { "addsubps", XM
, EX
, XX
},
1695 { "(bad)", MX
, EX
, XX
},
1696 { "(bad)", XM
, EX
, XX
},
1697 { "haddpd", XM
, EX
, XX
},
1698 { "haddps", XM
, EX
, XX
},
1702 { "(bad)", MX
, EX
, XX
},
1703 { "(bad)", XM
, EX
, XX
},
1704 { "hsubpd", XM
, EX
, XX
},
1705 { "hsubps", XM
, EX
, XX
},
1709 { "movlpX", XM
, EX
, SIMD_Fixup
, 'h' }, /* really only 2 operands */
1710 { "movsldup", XM
, EX
, XX
},
1711 { "movlpd", XM
, EX
, XX
},
1712 { "movddup", XM
, EX
, XX
},
1716 { "movhpX", XM
, EX
, SIMD_Fixup
, 'l' },
1717 { "movshdup", XM
, EX
, XX
},
1718 { "movhpd", XM
, EX
, XX
},
1719 { "(bad)", XM
, EX
, XX
},
1723 { "(bad)", XM
, EX
, XX
},
1724 { "(bad)", XM
, EX
, XX
},
1725 { "(bad)", XM
, EX
, XX
},
1726 { "lddqu", XM
, M
, XX
},
1730 static const struct dis386 x86_64_table
[][2] = {
1732 { "arpl", Ew
, Gw
, XX
},
1733 { "movs{||lq|xd}", Gv
, Ed
, XX
},
1737 #define INTERNAL_DISASSEMBLER_ERROR _("<internal disassembler error>")
1749 FETCH_DATA (the_info
, codep
+ 1);
1753 /* REX prefixes family. */
1776 prefixes
|= PREFIX_REPZ
;
1779 prefixes
|= PREFIX_REPNZ
;
1782 prefixes
|= PREFIX_LOCK
;
1785 prefixes
|= PREFIX_CS
;
1788 prefixes
|= PREFIX_SS
;
1791 prefixes
|= PREFIX_DS
;
1794 prefixes
|= PREFIX_ES
;
1797 prefixes
|= PREFIX_FS
;
1800 prefixes
|= PREFIX_GS
;
1803 prefixes
|= PREFIX_DATA
;
1806 prefixes
|= PREFIX_ADDR
;
1809 /* fwait is really an instruction. If there are prefixes
1810 before the fwait, they belong to the fwait, *not* to the
1811 following instruction. */
1814 prefixes
|= PREFIX_FWAIT
;
1818 prefixes
= PREFIX_FWAIT
;
1823 /* Rex is ignored when followed by another prefix. */
1826 oappend (prefix_name (rex
, 0));
1834 /* Return the name of the prefix byte PREF, or NULL if PREF is not a
1838 prefix_name (int pref
, int sizeflag
)
1842 /* REX prefixes family. */
1894 return (sizeflag
& DFLAG
) ? "data16" : "data32";
1897 return (sizeflag
& AFLAG
) ? "addr32" : "addr64";
1899 return (sizeflag
& AFLAG
) ? "addr16" : "addr32";
1907 static char op1out
[100], op2out
[100], op3out
[100];
1908 static int op_ad
, op_index
[3];
1909 static int two_source_ops
;
1910 static bfd_vma op_address
[3];
1911 static bfd_vma op_riprel
[3];
1912 static bfd_vma start_pc
;
1915 * On the 386's of 1988, the maximum length of an instruction is 15 bytes.
1916 * (see topic "Redundant prefixes" in the "Differences from 8086"
1917 * section of the "Virtual 8086 Mode" chapter.)
1918 * 'pc' should be the address of this instruction, it will
1919 * be used to print the target address if this is a relative jump or call
1920 * The function returns the length of this instruction in bytes.
1923 static char intel_syntax
;
1924 static char open_char
;
1925 static char close_char
;
1926 static char separator_char
;
1927 static char scale_char
;
1929 /* Here for backwards compatibility. When gdb stops using
1930 print_insn_i386_att and print_insn_i386_intel these functions can
1931 disappear, and print_insn_i386 be merged into print_insn. */
1933 print_insn_i386_att (bfd_vma pc
, disassemble_info
*info
)
1937 return print_insn (pc
, info
);
1941 print_insn_i386_intel (bfd_vma pc
, disassemble_info
*info
)
1945 return print_insn (pc
, info
);
1949 print_insn_i386 (bfd_vma pc
, disassemble_info
*info
)
1953 return print_insn (pc
, info
);
1957 print_insn (bfd_vma pc
, disassemble_info
*info
)
1959 const struct dis386
*dp
;
1961 char *first
, *second
, *third
;
1963 unsigned char uses_SSE_prefix
, uses_LOCK_prefix
;
1966 struct dis_private priv
;
1968 mode_64bit
= (info
->mach
== bfd_mach_x86_64_intel_syntax
1969 || info
->mach
== bfd_mach_x86_64
);
1971 if (intel_syntax
== (char) -1)
1972 intel_syntax
= (info
->mach
== bfd_mach_i386_i386_intel_syntax
1973 || info
->mach
== bfd_mach_x86_64_intel_syntax
);
1975 if (info
->mach
== bfd_mach_i386_i386
1976 || info
->mach
== bfd_mach_x86_64
1977 || info
->mach
== bfd_mach_i386_i386_intel_syntax
1978 || info
->mach
== bfd_mach_x86_64_intel_syntax
)
1979 priv
.orig_sizeflag
= AFLAG
| DFLAG
;
1980 else if (info
->mach
== bfd_mach_i386_i8086
)
1981 priv
.orig_sizeflag
= 0;
1985 for (p
= info
->disassembler_options
; p
!= NULL
; )
1987 if (strncmp (p
, "x86-64", 6) == 0)
1990 priv
.orig_sizeflag
= AFLAG
| DFLAG
;
1992 else if (strncmp (p
, "i386", 4) == 0)
1995 priv
.orig_sizeflag
= AFLAG
| DFLAG
;
1997 else if (strncmp (p
, "i8086", 5) == 0)
2000 priv
.orig_sizeflag
= 0;
2002 else if (strncmp (p
, "intel", 5) == 0)
2006 else if (strncmp (p
, "att", 3) == 0)
2010 else if (strncmp (p
, "addr", 4) == 0)
2012 if (p
[4] == '1' && p
[5] == '6')
2013 priv
.orig_sizeflag
&= ~AFLAG
;
2014 else if (p
[4] == '3' && p
[5] == '2')
2015 priv
.orig_sizeflag
|= AFLAG
;
2017 else if (strncmp (p
, "data", 4) == 0)
2019 if (p
[4] == '1' && p
[5] == '6')
2020 priv
.orig_sizeflag
&= ~DFLAG
;
2021 else if (p
[4] == '3' && p
[5] == '2')
2022 priv
.orig_sizeflag
|= DFLAG
;
2024 else if (strncmp (p
, "suffix", 6) == 0)
2025 priv
.orig_sizeflag
|= SUFFIX_ALWAYS
;
2027 p
= strchr (p
, ',');
2034 names64
= intel_names64
;
2035 names32
= intel_names32
;
2036 names16
= intel_names16
;
2037 names8
= intel_names8
;
2038 names8rex
= intel_names8rex
;
2039 names_seg
= intel_names_seg
;
2040 index16
= intel_index16
;
2043 separator_char
= '+';
2048 names64
= att_names64
;
2049 names32
= att_names32
;
2050 names16
= att_names16
;
2051 names8
= att_names8
;
2052 names8rex
= att_names8rex
;
2053 names_seg
= att_names_seg
;
2054 index16
= att_index16
;
2057 separator_char
= ',';
2061 /* The output looks better if we put 7 bytes on a line, since that
2062 puts most long word instructions on a single line. */
2063 info
->bytes_per_line
= 7;
2065 info
->private_data
= &priv
;
2066 priv
.max_fetched
= priv
.the_buffer
;
2067 priv
.insn_start
= pc
;
2074 op_index
[0] = op_index
[1] = op_index
[2] = -1;
2078 start_codep
= priv
.the_buffer
;
2079 codep
= priv
.the_buffer
;
2081 if (setjmp (priv
.bailout
) != 0)
2085 /* Getting here means we tried for data but didn't get it. That
2086 means we have an incomplete instruction of some sort. Just
2087 print the first byte as a prefix or a .byte pseudo-op. */
2088 if (codep
> priv
.the_buffer
)
2090 name
= prefix_name (priv
.the_buffer
[0], priv
.orig_sizeflag
);
2092 (*info
->fprintf_func
) (info
->stream
, "%s", name
);
2095 /* Just print the first byte as a .byte instruction. */
2096 (*info
->fprintf_func
) (info
->stream
, ".byte 0x%x",
2097 (unsigned int) priv
.the_buffer
[0]);
2110 sizeflag
= priv
.orig_sizeflag
;
2112 FETCH_DATA (info
, codep
+ 1);
2113 two_source_ops
= (*codep
== 0x62) || (*codep
== 0xc8);
2115 if ((prefixes
& PREFIX_FWAIT
)
2116 && ((*codep
< 0xd8) || (*codep
> 0xdf)))
2120 /* fwait not followed by floating point instruction. Print the
2121 first prefix, which is probably fwait itself. */
2122 name
= prefix_name (priv
.the_buffer
[0], priv
.orig_sizeflag
);
2124 name
= INTERNAL_DISASSEMBLER_ERROR
;
2125 (*info
->fprintf_func
) (info
->stream
, "%s", name
);
2131 FETCH_DATA (info
, codep
+ 2);
2132 dp
= &dis386_twobyte
[*++codep
];
2133 need_modrm
= twobyte_has_modrm
[*codep
];
2134 uses_SSE_prefix
= twobyte_uses_SSE_prefix
[*codep
];
2135 uses_LOCK_prefix
= (*codep
& ~0x02) == 0x20;
2139 dp
= &dis386
[*codep
];
2140 need_modrm
= onebyte_has_modrm
[*codep
];
2141 uses_SSE_prefix
= 0;
2142 uses_LOCK_prefix
= 0;
2146 if (!uses_SSE_prefix
&& (prefixes
& PREFIX_REPZ
))
2149 used_prefixes
|= PREFIX_REPZ
;
2151 if (!uses_SSE_prefix
&& (prefixes
& PREFIX_REPNZ
))
2154 used_prefixes
|= PREFIX_REPNZ
;
2156 if (!uses_LOCK_prefix
&& (prefixes
& PREFIX_LOCK
))
2159 used_prefixes
|= PREFIX_LOCK
;
2162 if (prefixes
& PREFIX_ADDR
)
2165 if (dp
->bytemode3
!= loop_jcxz_mode
|| intel_syntax
)
2167 if ((sizeflag
& AFLAG
) || mode_64bit
)
2168 oappend ("addr32 ");
2170 oappend ("addr16 ");
2171 used_prefixes
|= PREFIX_ADDR
;
2175 if (!uses_SSE_prefix
&& (prefixes
& PREFIX_DATA
))
2178 if (dp
->bytemode3
== cond_jump_mode
2179 && dp
->bytemode1
== v_mode
2182 if (sizeflag
& DFLAG
)
2183 oappend ("data32 ");
2185 oappend ("data16 ");
2186 used_prefixes
|= PREFIX_DATA
;
2192 FETCH_DATA (info
, codep
+ 1);
2193 mod
= (*codep
>> 6) & 3;
2194 reg
= (*codep
>> 3) & 7;
2198 if (dp
->name
== NULL
&& dp
->bytemode1
== FLOATCODE
)
2205 if (dp
->name
== NULL
)
2207 switch (dp
->bytemode1
)
2210 dp
= &grps
[dp
->bytemode2
][reg
];
2213 case USE_PREFIX_USER_TABLE
:
2215 used_prefixes
|= (prefixes
& PREFIX_REPZ
);
2216 if (prefixes
& PREFIX_REPZ
)
2220 used_prefixes
|= (prefixes
& PREFIX_DATA
);
2221 if (prefixes
& PREFIX_DATA
)
2225 used_prefixes
|= (prefixes
& PREFIX_REPNZ
);
2226 if (prefixes
& PREFIX_REPNZ
)
2230 dp
= &prefix_user_table
[dp
->bytemode2
][index
];
2233 case X86_64_SPECIAL
:
2234 dp
= &x86_64_table
[dp
->bytemode2
][mode_64bit
];
2238 oappend (INTERNAL_DISASSEMBLER_ERROR
);
2243 if (putop (dp
->name
, sizeflag
) == 0)
2248 (*dp
->op1
) (dp
->bytemode1
, sizeflag
);
2253 (*dp
->op2
) (dp
->bytemode2
, sizeflag
);
2258 (*dp
->op3
) (dp
->bytemode3
, sizeflag
);
2262 /* See if any prefixes were not used. If so, print the first one
2263 separately. If we don't do this, we'll wind up printing an
2264 instruction stream which does not precisely correspond to the
2265 bytes we are disassembling. */
2266 if ((prefixes
& ~used_prefixes
) != 0)
2270 name
= prefix_name (priv
.the_buffer
[0], priv
.orig_sizeflag
);
2272 name
= INTERNAL_DISASSEMBLER_ERROR
;
2273 (*info
->fprintf_func
) (info
->stream
, "%s", name
);
2276 if (rex
& ~rex_used
)
2279 name
= prefix_name (rex
| 0x40, priv
.orig_sizeflag
);
2281 name
= INTERNAL_DISASSEMBLER_ERROR
;
2282 (*info
->fprintf_func
) (info
->stream
, "%s ", name
);
2285 obufp
= obuf
+ strlen (obuf
);
2286 for (i
= strlen (obuf
); i
< 6; i
++)
2289 (*info
->fprintf_func
) (info
->stream
, "%s", obuf
);
2291 /* The enter and bound instructions are printed with operands in the same
2292 order as the intel book; everything else is printed in reverse order. */
2293 if (intel_syntax
|| two_source_ops
)
2298 op_ad
= op_index
[0];
2299 op_index
[0] = op_index
[2];
2300 op_index
[2] = op_ad
;
2311 if (op_index
[0] != -1 && !op_riprel
[0])
2312 (*info
->print_address_func
) ((bfd_vma
) op_address
[op_index
[0]], info
);
2314 (*info
->fprintf_func
) (info
->stream
, "%s", first
);
2320 (*info
->fprintf_func
) (info
->stream
, ",");
2321 if (op_index
[1] != -1 && !op_riprel
[1])
2322 (*info
->print_address_func
) ((bfd_vma
) op_address
[op_index
[1]], info
);
2324 (*info
->fprintf_func
) (info
->stream
, "%s", second
);
2330 (*info
->fprintf_func
) (info
->stream
, ",");
2331 if (op_index
[2] != -1 && !op_riprel
[2])
2332 (*info
->print_address_func
) ((bfd_vma
) op_address
[op_index
[2]], info
);
2334 (*info
->fprintf_func
) (info
->stream
, "%s", third
);
2336 for (i
= 0; i
< 3; i
++)
2337 if (op_index
[i
] != -1 && op_riprel
[i
])
2339 (*info
->fprintf_func
) (info
->stream
, " # ");
2340 (*info
->print_address_func
) ((bfd_vma
) (start_pc
+ codep
- start_codep
2341 + op_address
[op_index
[i
]]), info
);
2343 return codep
- priv
.the_buffer
;
2346 static const char *float_mem
[] = {
2421 static const unsigned char float_mem_mode
[] = {
2497 #define STi OP_STi, 0
2499 #define FGRPd9_2 NULL, NULL, 0, NULL, 0, NULL, 0
2500 #define FGRPd9_4 NULL, NULL, 1, NULL, 0, NULL, 0
2501 #define FGRPd9_5 NULL, NULL, 2, NULL, 0, NULL, 0
2502 #define FGRPd9_6 NULL, NULL, 3, NULL, 0, NULL, 0
2503 #define FGRPd9_7 NULL, NULL, 4, NULL, 0, NULL, 0
2504 #define FGRPda_5 NULL, NULL, 5, NULL, 0, NULL, 0
2505 #define FGRPdb_4 NULL, NULL, 6, NULL, 0, NULL, 0
2506 #define FGRPde_3 NULL, NULL, 7, NULL, 0, NULL, 0
2507 #define FGRPdf_4 NULL, NULL, 8, NULL, 0, NULL, 0
2509 static const struct dis386 float_reg
[][8] = {
2512 { "fadd", ST
, STi
, XX
},
2513 { "fmul", ST
, STi
, XX
},
2514 { "fcom", STi
, XX
, XX
},
2515 { "fcomp", STi
, XX
, XX
},
2516 { "fsub", ST
, STi
, XX
},
2517 { "fsubr", ST
, STi
, XX
},
2518 { "fdiv", ST
, STi
, XX
},
2519 { "fdivr", ST
, STi
, XX
},
2523 { "fld", STi
, XX
, XX
},
2524 { "fxch", STi
, XX
, XX
},
2526 { "(bad)", XX
, XX
, XX
},
2534 { "fcmovb", ST
, STi
, XX
},
2535 { "fcmove", ST
, STi
, XX
},
2536 { "fcmovbe",ST
, STi
, XX
},
2537 { "fcmovu", ST
, STi
, XX
},
2538 { "(bad)", XX
, XX
, XX
},
2540 { "(bad)", XX
, XX
, XX
},
2541 { "(bad)", XX
, XX
, XX
},
2545 { "fcmovnb",ST
, STi
, XX
},
2546 { "fcmovne",ST
, STi
, XX
},
2547 { "fcmovnbe",ST
, STi
, XX
},
2548 { "fcmovnu",ST
, STi
, XX
},
2550 { "fucomi", ST
, STi
, XX
},
2551 { "fcomi", ST
, STi
, XX
},
2552 { "(bad)", XX
, XX
, XX
},
2556 { "fadd", STi
, ST
, XX
},
2557 { "fmul", STi
, ST
, XX
},
2558 { "(bad)", XX
, XX
, XX
},
2559 { "(bad)", XX
, XX
, XX
},
2561 { "fsub", STi
, ST
, XX
},
2562 { "fsubr", STi
, ST
, XX
},
2563 { "fdiv", STi
, ST
, XX
},
2564 { "fdivr", STi
, ST
, XX
},
2566 { "fsubr", STi
, ST
, XX
},
2567 { "fsub", STi
, ST
, XX
},
2568 { "fdivr", STi
, ST
, XX
},
2569 { "fdiv", STi
, ST
, XX
},
2574 { "ffree", STi
, XX
, XX
},
2575 { "(bad)", XX
, XX
, XX
},
2576 { "fst", STi
, XX
, XX
},
2577 { "fstp", STi
, XX
, XX
},
2578 { "fucom", STi
, XX
, XX
},
2579 { "fucomp", STi
, XX
, XX
},
2580 { "(bad)", XX
, XX
, XX
},
2581 { "(bad)", XX
, XX
, XX
},
2585 { "faddp", STi
, ST
, XX
},
2586 { "fmulp", STi
, ST
, XX
},
2587 { "(bad)", XX
, XX
, XX
},
2590 { "fsubp", STi
, ST
, XX
},
2591 { "fsubrp", STi
, ST
, XX
},
2592 { "fdivp", STi
, ST
, XX
},
2593 { "fdivrp", STi
, ST
, XX
},
2595 { "fsubrp", STi
, ST
, XX
},
2596 { "fsubp", STi
, ST
, XX
},
2597 { "fdivrp", STi
, ST
, XX
},
2598 { "fdivp", STi
, ST
, XX
},
2603 { "ffreep", STi
, XX
, XX
},
2604 { "(bad)", XX
, XX
, XX
},
2605 { "(bad)", XX
, XX
, XX
},
2606 { "(bad)", XX
, XX
, XX
},
2608 { "fucomip",ST
, STi
, XX
},
2609 { "fcomip", ST
, STi
, XX
},
2610 { "(bad)", XX
, XX
, XX
},
2614 static char *fgrps
[][8] = {
2617 "fnop","(bad)","(bad)","(bad)","(bad)","(bad)","(bad)","(bad)",
2622 "fchs","fabs","(bad)","(bad)","ftst","fxam","(bad)","(bad)",
2627 "fld1","fldl2t","fldl2e","fldpi","fldlg2","fldln2","fldz","(bad)",
2632 "f2xm1","fyl2x","fptan","fpatan","fxtract","fprem1","fdecstp","fincstp",
2637 "fprem","fyl2xp1","fsqrt","fsincos","frndint","fscale","fsin","fcos",
2642 "(bad)","fucompp","(bad)","(bad)","(bad)","(bad)","(bad)","(bad)",
2647 "feni(287 only)","fdisi(287 only)","fNclex","fNinit",
2648 "fNsetpm(287 only)","(bad)","(bad)","(bad)",
2653 "(bad)","fcompp","(bad)","(bad)","(bad)","(bad)","(bad)","(bad)",
2658 "fNstsw","(bad)","(bad)","(bad)","(bad)","(bad)","(bad)","(bad)",
2663 dofloat (int sizeflag
)
2665 const struct dis386
*dp
;
2666 unsigned char floatop
;
2668 floatop
= codep
[-1];
2672 int fp_indx
= (floatop
- 0xd8) * 8 + reg
;
2674 putop (float_mem
[fp_indx
], sizeflag
);
2676 OP_E (float_mem_mode
[fp_indx
], sizeflag
);
2679 /* Skip mod/rm byte. */
2683 dp
= &float_reg
[floatop
- 0xd8][reg
];
2684 if (dp
->name
== NULL
)
2686 putop (fgrps
[dp
->bytemode1
][rm
], sizeflag
);
2688 /* Instruction fnstsw is only one with strange arg. */
2689 if (floatop
== 0xdf && codep
[-1] == 0xe0)
2690 strcpy (op1out
, names16
[0]);
2694 putop (dp
->name
, sizeflag
);
2698 (*dp
->op1
) (dp
->bytemode1
, sizeflag
);
2701 (*dp
->op2
) (dp
->bytemode2
, sizeflag
);
2706 OP_ST (int bytemode ATTRIBUTE_UNUSED
, int sizeflag ATTRIBUTE_UNUSED
)
2712 OP_STi (int bytemode ATTRIBUTE_UNUSED
, int sizeflag ATTRIBUTE_UNUSED
)
2714 sprintf (scratchbuf
, "%%st(%d)", rm
);
2715 oappend (scratchbuf
+ intel_syntax
);
2718 /* Capital letters in template are macros. */
2720 putop (const char *template, int sizeflag
)
2725 for (p
= template; *p
; p
++)
2744 /* Alternative not valid. */
2745 strcpy (obuf
, "(bad)");
2749 else if (*p
== '\0')
2770 if (mod
!= 3 || (sizeflag
& SUFFIX_ALWAYS
))
2776 if (sizeflag
& SUFFIX_ALWAYS
)
2780 if (intel_syntax
&& !alt
)
2782 if ((prefixes
& PREFIX_DATA
) || (sizeflag
& SUFFIX_ALWAYS
))
2784 if (sizeflag
& DFLAG
)
2785 *obufp
++ = intel_syntax
? 'd' : 'l';
2787 *obufp
++ = intel_syntax
? 'w' : 's';
2788 used_prefixes
|= (prefixes
& PREFIX_DATA
);
2791 case 'E': /* For jcxz/jecxz */
2794 if (sizeflag
& AFLAG
)
2800 if (sizeflag
& AFLAG
)
2802 used_prefixes
|= (prefixes
& PREFIX_ADDR
);
2807 if ((prefixes
& PREFIX_ADDR
) || (sizeflag
& SUFFIX_ALWAYS
))
2809 if (sizeflag
& AFLAG
)
2810 *obufp
++ = mode_64bit
? 'q' : 'l';
2812 *obufp
++ = mode_64bit
? 'l' : 'w';
2813 used_prefixes
|= (prefixes
& PREFIX_ADDR
);
2819 if ((prefixes
& (PREFIX_CS
| PREFIX_DS
)) == PREFIX_CS
2820 || (prefixes
& (PREFIX_CS
| PREFIX_DS
)) == PREFIX_DS
)
2822 used_prefixes
|= prefixes
& (PREFIX_CS
| PREFIX_DS
);
2825 if (prefixes
& PREFIX_DS
)
2839 if (sizeflag
& SUFFIX_ALWAYS
)
2843 if ((prefixes
& PREFIX_FWAIT
) == 0)
2846 used_prefixes
|= PREFIX_FWAIT
;
2849 USED_REX (REX_MODE64
);
2850 if (rex
& REX_MODE64
)
2867 if ((prefixes
& PREFIX_DATA
)
2868 || (rex
& REX_MODE64
)
2869 || (sizeflag
& SUFFIX_ALWAYS
))
2871 USED_REX (REX_MODE64
);
2872 if (rex
& REX_MODE64
)
2876 if (sizeflag
& DFLAG
)
2880 used_prefixes
|= (prefixes
& PREFIX_DATA
);
2894 if (intel_syntax
&& !alt
)
2896 USED_REX (REX_MODE64
);
2897 if (mod
!= 3 || (sizeflag
& SUFFIX_ALWAYS
))
2899 if (rex
& REX_MODE64
)
2903 if (sizeflag
& DFLAG
)
2904 *obufp
++ = intel_syntax
? 'd' : 'l';
2907 used_prefixes
|= (prefixes
& PREFIX_DATA
);
2912 USED_REX (REX_MODE64
);
2915 if (rex
& REX_MODE64
)
2920 else if (sizeflag
& DFLAG
)
2933 if (rex
& REX_MODE64
)
2935 else if (sizeflag
& DFLAG
)
2940 if (!(rex
& REX_MODE64
))
2941 used_prefixes
|= (prefixes
& PREFIX_DATA
);
2946 if (sizeflag
& SUFFIX_ALWAYS
)
2948 if (rex
& REX_MODE64
)
2952 if (sizeflag
& DFLAG
)
2956 used_prefixes
|= (prefixes
& PREFIX_DATA
);
2961 if (prefixes
& PREFIX_DATA
)
2965 used_prefixes
|= (prefixes
& PREFIX_DATA
);
2970 if (rex
& REX_MODE64
)
2972 USED_REX (REX_MODE64
);
2976 /* implicit operand size 'l' for i386 or 'q' for x86-64 */
2978 /* operand size flag for cwtl, cbtw */
2982 else if (sizeflag
& DFLAG
)
2993 if (sizeflag
& DFLAG
)
3004 used_prefixes
|= (prefixes
& PREFIX_DATA
);
3014 oappend (const char *s
)
3017 obufp
+= strlen (s
);
3023 if (prefixes
& PREFIX_CS
)
3025 used_prefixes
|= PREFIX_CS
;
3026 oappend ("%cs:" + intel_syntax
);
3028 if (prefixes
& PREFIX_DS
)
3030 used_prefixes
|= PREFIX_DS
;
3031 oappend ("%ds:" + intel_syntax
);
3033 if (prefixes
& PREFIX_SS
)
3035 used_prefixes
|= PREFIX_SS
;
3036 oappend ("%ss:" + intel_syntax
);
3038 if (prefixes
& PREFIX_ES
)
3040 used_prefixes
|= PREFIX_ES
;
3041 oappend ("%es:" + intel_syntax
);
3043 if (prefixes
& PREFIX_FS
)
3045 used_prefixes
|= PREFIX_FS
;
3046 oappend ("%fs:" + intel_syntax
);
3048 if (prefixes
& PREFIX_GS
)
3050 used_prefixes
|= PREFIX_GS
;
3051 oappend ("%gs:" + intel_syntax
);
3056 OP_indirE (int bytemode
, int sizeflag
)
3060 OP_E (bytemode
, sizeflag
);
3064 print_operand_value (char *buf
, int hex
, bfd_vma disp
)
3074 sprintf_vma (tmp
, disp
);
3075 for (i
= 0; tmp
[i
] == '0' && tmp
[i
+ 1]; i
++);
3076 strcpy (buf
+ 2, tmp
+ i
);
3080 bfd_signed_vma v
= disp
;
3087 /* Check for possible overflow on 0x8000000000000000. */
3090 strcpy (buf
, "9223372036854775808");
3104 tmp
[28 - i
] = (v
% 10) + '0';
3108 strcpy (buf
, tmp
+ 29 - i
);
3114 sprintf (buf
, "0x%x", (unsigned int) disp
);
3116 sprintf (buf
, "%d", (int) disp
);
3121 OP_E (int bytemode
, int sizeflag
)
3126 USED_REX (REX_EXTZ
);
3130 /* Skip mod/rm byte. */
3141 oappend (names8rex
[rm
+ add
]);
3143 oappend (names8
[rm
+ add
]);
3146 oappend (names16
[rm
+ add
]);
3149 oappend (names32
[rm
+ add
]);
3152 oappend (names64
[rm
+ add
]);
3156 oappend (names64
[rm
+ add
]);
3158 oappend (names32
[rm
+ add
]);
3162 oappend (names64
[rm
+ add
]);
3165 if ((sizeflag
& DFLAG
) || bytemode
!= branch_v_mode
)
3166 oappend (names32
[rm
+ add
]);
3168 oappend (names16
[rm
+ add
]);
3169 used_prefixes
|= (prefixes
& PREFIX_DATA
);
3175 USED_REX (REX_MODE64
);
3176 if (rex
& REX_MODE64
)
3177 oappend (names64
[rm
+ add
]);
3178 else if ((sizeflag
& DFLAG
) || bytemode
!= v_mode
)
3179 oappend (names32
[rm
+ add
]);
3181 oappend (names16
[rm
+ add
]);
3182 used_prefixes
|= (prefixes
& PREFIX_DATA
);
3187 oappend (INTERNAL_DISASSEMBLER_ERROR
);
3196 if ((sizeflag
& AFLAG
) || mode_64bit
) /* 32 bit address mode */
3211 FETCH_DATA (the_info
, codep
+ 1);
3212 index
= (*codep
>> 3) & 7;
3213 if (mode_64bit
|| index
!= 0x4)
3214 /* When INDEX == 0x4 in 32 bit mode, SCALE is ignored. */
3215 scale
= (*codep
>> 6) & 3;
3217 USED_REX (REX_EXTY
);
3227 if ((base
& 7) == 5)
3230 if (mode_64bit
&& !havesib
)
3236 FETCH_DATA (the_info
, codep
+ 1);
3238 if ((disp
& 0x80) != 0)
3247 if (mod
!= 0 || (base
& 7) == 5)
3249 print_operand_value (scratchbuf
, !riprel
, disp
);
3250 oappend (scratchbuf
);
3258 if (havebase
|| (havesib
&& (index
!= 4 || scale
!= 0)))
3265 oappend ("BYTE PTR ");
3269 oappend ("WORD PTR ");
3274 USED_REX (REX_MODE64
);
3275 if (rex
& REX_MODE64
)
3276 oappend ("QWORD PTR ");
3277 else if ((sizeflag
& DFLAG
) || bytemode
== dq_mode
)
3278 oappend ("DWORD PTR ");
3280 oappend ("WORD PTR ");
3281 used_prefixes
|= (prefixes
& PREFIX_DATA
);
3284 oappend ("DWORD PTR ");
3287 oappend ("QWORD PTR ");
3291 oappend ("QWORD PTR ");
3293 oappend ("DWORD PTR ");
3296 if (sizeflag
& DFLAG
)
3298 used_prefixes
|= (prefixes
& PREFIX_DATA
);
3299 oappend ("FWORD PTR ");
3302 oappend ("DWORD PTR ");
3305 oappend ("TBYTE PTR ");
3308 oappend ("XMMWORD PTR ");
3314 *obufp
++ = open_char
;
3315 if (intel_syntax
&& riprel
)
3319 oappend (mode_64bit
&& (sizeflag
& AFLAG
)
3320 ? names64
[base
] : names32
[base
]);
3325 if (!intel_syntax
|| havebase
)
3327 *obufp
++ = separator_char
;
3330 oappend (mode_64bit
&& (sizeflag
& AFLAG
)
3331 ? names64
[index
] : names32
[index
]);
3333 if (scale
!= 0 || (!intel_syntax
&& index
!= 4))
3335 *obufp
++ = scale_char
;
3337 sprintf (scratchbuf
, "%d", 1 << scale
);
3338 oappend (scratchbuf
);
3341 if (intel_syntax
&& disp
)
3343 if ((bfd_signed_vma
) disp
> 0)
3352 disp
= - (bfd_signed_vma
) disp
;
3355 print_operand_value (scratchbuf
, mod
!= 1, disp
);
3356 oappend (scratchbuf
);
3359 *obufp
++ = close_char
;
3362 else if (intel_syntax
)
3364 if (mod
!= 0 || (base
& 7) == 5)
3366 if (prefixes
& (PREFIX_CS
| PREFIX_SS
| PREFIX_DS
3367 | PREFIX_ES
| PREFIX_FS
| PREFIX_GS
))
3371 oappend (names_seg
[ds_reg
- es_reg
]);
3374 print_operand_value (scratchbuf
, 1, disp
);
3375 oappend (scratchbuf
);
3380 { /* 16 bit address mode */
3387 if ((disp
& 0x8000) != 0)
3392 FETCH_DATA (the_info
, codep
+ 1);
3394 if ((disp
& 0x80) != 0)
3399 if ((disp
& 0x8000) != 0)
3405 if (mod
!= 0 || rm
== 6)
3407 print_operand_value (scratchbuf
, 0, disp
);
3408 oappend (scratchbuf
);
3411 if (mod
!= 0 || rm
!= 6)
3413 *obufp
++ = open_char
;
3415 oappend (index16
[rm
]);
3416 if (intel_syntax
&& disp
)
3418 if ((bfd_signed_vma
) disp
> 0)
3427 disp
= - (bfd_signed_vma
) disp
;
3430 print_operand_value (scratchbuf
, mod
!= 1, disp
);
3431 oappend (scratchbuf
);
3434 *obufp
++ = close_char
;
3437 else if (intel_syntax
)
3439 if (prefixes
& (PREFIX_CS
| PREFIX_SS
| PREFIX_DS
3440 | PREFIX_ES
| PREFIX_FS
| PREFIX_GS
))
3444 oappend (names_seg
[ds_reg
- es_reg
]);
3447 print_operand_value (scratchbuf
, 1, disp
& 0xffff);
3448 oappend (scratchbuf
);
3454 OP_G (int bytemode
, int sizeflag
)
3457 USED_REX (REX_EXTX
);
3465 oappend (names8rex
[reg
+ add
]);
3467 oappend (names8
[reg
+ add
]);
3470 oappend (names16
[reg
+ add
]);
3473 oappend (names32
[reg
+ add
]);
3476 oappend (names64
[reg
+ add
]);
3481 USED_REX (REX_MODE64
);
3482 if (rex
& REX_MODE64
)
3483 oappend (names64
[reg
+ add
]);
3484 else if ((sizeflag
& DFLAG
) || bytemode
!= v_mode
)
3485 oappend (names32
[reg
+ add
]);
3487 oappend (names16
[reg
+ add
]);
3488 used_prefixes
|= (prefixes
& PREFIX_DATA
);
3491 oappend (INTERNAL_DISASSEMBLER_ERROR
);
3504 FETCH_DATA (the_info
, codep
+ 8);
3505 a
= *codep
++ & 0xff;
3506 a
|= (*codep
++ & 0xff) << 8;
3507 a
|= (*codep
++ & 0xff) << 16;
3508 a
|= (*codep
++ & 0xff) << 24;
3509 b
= *codep
++ & 0xff;
3510 b
|= (*codep
++ & 0xff) << 8;
3511 b
|= (*codep
++ & 0xff) << 16;
3512 b
|= (*codep
++ & 0xff) << 24;
3513 x
= a
+ ((bfd_vma
) b
<< 32);
3521 static bfd_signed_vma
3524 bfd_signed_vma x
= 0;
3526 FETCH_DATA (the_info
, codep
+ 4);
3527 x
= *codep
++ & (bfd_signed_vma
) 0xff;
3528 x
|= (*codep
++ & (bfd_signed_vma
) 0xff) << 8;
3529 x
|= (*codep
++ & (bfd_signed_vma
) 0xff) << 16;
3530 x
|= (*codep
++ & (bfd_signed_vma
) 0xff) << 24;
3534 static bfd_signed_vma
3537 bfd_signed_vma x
= 0;
3539 FETCH_DATA (the_info
, codep
+ 4);
3540 x
= *codep
++ & (bfd_signed_vma
) 0xff;
3541 x
|= (*codep
++ & (bfd_signed_vma
) 0xff) << 8;
3542 x
|= (*codep
++ & (bfd_signed_vma
) 0xff) << 16;
3543 x
|= (*codep
++ & (bfd_signed_vma
) 0xff) << 24;
3545 x
= (x
^ ((bfd_signed_vma
) 1 << 31)) - ((bfd_signed_vma
) 1 << 31);
3555 FETCH_DATA (the_info
, codep
+ 2);
3556 x
= *codep
++ & 0xff;
3557 x
|= (*codep
++ & 0xff) << 8;
3562 set_op (bfd_vma op
, int riprel
)
3564 op_index
[op_ad
] = op_ad
;
3567 op_address
[op_ad
] = op
;
3568 op_riprel
[op_ad
] = riprel
;
3572 /* Mask to get a 32-bit address. */
3573 op_address
[op_ad
] = op
& 0xffffffff;
3574 op_riprel
[op_ad
] = riprel
& 0xffffffff;
3579 OP_REG (int code
, int sizeflag
)
3583 USED_REX (REX_EXTZ
);
3595 case ax_reg
: case cx_reg
: case dx_reg
: case bx_reg
:
3596 case sp_reg
: case bp_reg
: case si_reg
: case di_reg
:
3597 s
= names16
[code
- ax_reg
+ add
];
3599 case es_reg
: case ss_reg
: case cs_reg
:
3600 case ds_reg
: case fs_reg
: case gs_reg
:
3601 s
= names_seg
[code
- es_reg
+ add
];
3603 case al_reg
: case ah_reg
: case cl_reg
: case ch_reg
:
3604 case dl_reg
: case dh_reg
: case bl_reg
: case bh_reg
:
3607 s
= names8rex
[code
- al_reg
+ add
];
3609 s
= names8
[code
- al_reg
];
3611 case rAX_reg
: case rCX_reg
: case rDX_reg
: case rBX_reg
:
3612 case rSP_reg
: case rBP_reg
: case rSI_reg
: case rDI_reg
:
3615 s
= names64
[code
- rAX_reg
+ add
];
3618 code
+= eAX_reg
- rAX_reg
;
3620 case eAX_reg
: case eCX_reg
: case eDX_reg
: case eBX_reg
:
3621 case eSP_reg
: case eBP_reg
: case eSI_reg
: case eDI_reg
:
3622 USED_REX (REX_MODE64
);
3623 if (rex
& REX_MODE64
)
3624 s
= names64
[code
- eAX_reg
+ add
];
3625 else if (sizeflag
& DFLAG
)
3626 s
= names32
[code
- eAX_reg
+ add
];
3628 s
= names16
[code
- eAX_reg
+ add
];
3629 used_prefixes
|= (prefixes
& PREFIX_DATA
);
3632 s
= INTERNAL_DISASSEMBLER_ERROR
;
3639 OP_IMREG (int code
, int sizeflag
)
3651 case ax_reg
: case cx_reg
: case dx_reg
: case bx_reg
:
3652 case sp_reg
: case bp_reg
: case si_reg
: case di_reg
:
3653 s
= names16
[code
- ax_reg
];
3655 case es_reg
: case ss_reg
: case cs_reg
:
3656 case ds_reg
: case fs_reg
: case gs_reg
:
3657 s
= names_seg
[code
- es_reg
];
3659 case al_reg
: case ah_reg
: case cl_reg
: case ch_reg
:
3660 case dl_reg
: case dh_reg
: case bl_reg
: case bh_reg
:
3663 s
= names8rex
[code
- al_reg
];
3665 s
= names8
[code
- al_reg
];
3667 case eAX_reg
: case eCX_reg
: case eDX_reg
: case eBX_reg
:
3668 case eSP_reg
: case eBP_reg
: case eSI_reg
: case eDI_reg
:
3669 USED_REX (REX_MODE64
);
3670 if (rex
& REX_MODE64
)
3671 s
= names64
[code
- eAX_reg
];
3672 else if (sizeflag
& DFLAG
)
3673 s
= names32
[code
- eAX_reg
];
3675 s
= names16
[code
- eAX_reg
];
3676 used_prefixes
|= (prefixes
& PREFIX_DATA
);
3679 s
= INTERNAL_DISASSEMBLER_ERROR
;
3686 OP_I (int bytemode
, int sizeflag
)
3689 bfd_signed_vma mask
= -1;
3694 FETCH_DATA (the_info
, codep
+ 1);
3706 USED_REX (REX_MODE64
);
3707 if (rex
& REX_MODE64
)
3709 else if (sizeflag
& DFLAG
)
3719 used_prefixes
|= (prefixes
& PREFIX_DATA
);
3730 oappend (INTERNAL_DISASSEMBLER_ERROR
);
3735 scratchbuf
[0] = '$';
3736 print_operand_value (scratchbuf
+ 1, 1, op
);
3737 oappend (scratchbuf
+ intel_syntax
);
3738 scratchbuf
[0] = '\0';
3742 OP_I64 (int bytemode
, int sizeflag
)
3745 bfd_signed_vma mask
= -1;
3749 OP_I (bytemode
, sizeflag
);
3756 FETCH_DATA (the_info
, codep
+ 1);
3761 USED_REX (REX_MODE64
);
3762 if (rex
& REX_MODE64
)
3764 else if (sizeflag
& DFLAG
)
3774 used_prefixes
|= (prefixes
& PREFIX_DATA
);
3781 oappend (INTERNAL_DISASSEMBLER_ERROR
);
3786 scratchbuf
[0] = '$';
3787 print_operand_value (scratchbuf
+ 1, 1, op
);
3788 oappend (scratchbuf
+ intel_syntax
);
3789 scratchbuf
[0] = '\0';
3793 OP_sI (int bytemode
, int sizeflag
)
3796 bfd_signed_vma mask
= -1;
3801 FETCH_DATA (the_info
, codep
+ 1);
3803 if ((op
& 0x80) != 0)
3808 USED_REX (REX_MODE64
);
3809 if (rex
& REX_MODE64
)
3811 else if (sizeflag
& DFLAG
)
3820 if ((op
& 0x8000) != 0)
3823 used_prefixes
|= (prefixes
& PREFIX_DATA
);
3828 if ((op
& 0x8000) != 0)
3832 oappend (INTERNAL_DISASSEMBLER_ERROR
);
3836 scratchbuf
[0] = '$';
3837 print_operand_value (scratchbuf
+ 1, 1, op
);
3838 oappend (scratchbuf
+ intel_syntax
);
3842 OP_J (int bytemode
, int sizeflag
)
3850 FETCH_DATA (the_info
, codep
+ 1);
3852 if ((disp
& 0x80) != 0)
3856 if (sizeflag
& DFLAG
)
3861 /* For some reason, a data16 prefix on a jump instruction
3862 means that the pc is masked to 16 bits after the
3863 displacement is added! */
3868 oappend (INTERNAL_DISASSEMBLER_ERROR
);
3871 disp
= (start_pc
+ codep
- start_codep
+ disp
) & mask
;
3873 print_operand_value (scratchbuf
, 1, disp
);
3874 oappend (scratchbuf
);
3878 OP_SEG (int dummy ATTRIBUTE_UNUSED
, int sizeflag ATTRIBUTE_UNUSED
)
3880 oappend (names_seg
[reg
]);
3884 OP_DIR (int dummy ATTRIBUTE_UNUSED
, int sizeflag
)
3888 if (sizeflag
& DFLAG
)
3898 used_prefixes
|= (prefixes
& PREFIX_DATA
);
3900 sprintf (scratchbuf
, "0x%x,0x%x", seg
, offset
);
3902 sprintf (scratchbuf
, "$0x%x,$0x%x", seg
, offset
);
3903 oappend (scratchbuf
);
3907 OP_OFF (int bytemode ATTRIBUTE_UNUSED
, int sizeflag
)
3913 if ((sizeflag
& AFLAG
) || mode_64bit
)
3920 if (!(prefixes
& (PREFIX_CS
| PREFIX_SS
| PREFIX_DS
3921 | PREFIX_ES
| PREFIX_FS
| PREFIX_GS
)))
3923 oappend (names_seg
[ds_reg
- es_reg
]);
3927 print_operand_value (scratchbuf
, 1, off
);
3928 oappend (scratchbuf
);
3932 OP_OFF64 (int bytemode ATTRIBUTE_UNUSED
, int sizeflag ATTRIBUTE_UNUSED
)
3938 OP_OFF (bytemode
, sizeflag
);
3948 if (!(prefixes
& (PREFIX_CS
| PREFIX_SS
| PREFIX_DS
3949 | PREFIX_ES
| PREFIX_FS
| PREFIX_GS
)))
3951 oappend (names_seg
[ds_reg
- es_reg
]);
3955 print_operand_value (scratchbuf
, 1, off
);
3956 oappend (scratchbuf
);
3960 ptr_reg (int code
, int sizeflag
)
3964 *obufp
++ = open_char
;
3965 used_prefixes
|= (prefixes
& PREFIX_ADDR
);
3968 if (!(sizeflag
& AFLAG
))
3969 s
= names32
[code
- eAX_reg
];
3971 s
= names64
[code
- eAX_reg
];
3973 else if (sizeflag
& AFLAG
)
3974 s
= names32
[code
- eAX_reg
];
3976 s
= names16
[code
- eAX_reg
];
3978 *obufp
++ = close_char
;
3983 OP_ESreg (int code
, int sizeflag
)
3989 USED_REX (REX_MODE64
);
3990 used_prefixes
|= (prefixes
& PREFIX_DATA
);
3991 if (rex
& REX_MODE64
)
3992 oappend ("QWORD PTR ");
3993 else if ((sizeflag
& DFLAG
))
3994 oappend ("DWORD PTR ");
3996 oappend ("WORD PTR ");
3999 oappend ("BYTE PTR ");
4002 oappend ("%es:" + intel_syntax
);
4003 ptr_reg (code
, sizeflag
);
4007 OP_DSreg (int code
, int sizeflag
)
4011 if (codep
[-1] != 0xd7 && (codep
[-1] & 1))
4013 USED_REX (REX_MODE64
);
4014 used_prefixes
|= (prefixes
& PREFIX_DATA
);
4015 if (rex
& REX_MODE64
)
4016 oappend ("QWORD PTR ");
4017 else if ((sizeflag
& DFLAG
))
4018 oappend ("DWORD PTR ");
4020 oappend ("WORD PTR ");
4023 oappend ("BYTE PTR ");
4033 prefixes
|= PREFIX_DS
;
4035 ptr_reg (code
, sizeflag
);
4039 OP_C (int dummy ATTRIBUTE_UNUSED
, int sizeflag ATTRIBUTE_UNUSED
)
4044 USED_REX (REX_EXTX
);
4047 else if (!mode_64bit
&& (prefixes
& PREFIX_LOCK
))
4049 used_prefixes
|= PREFIX_LOCK
;
4052 sprintf (scratchbuf
, "%%cr%d", reg
+ add
);
4053 oappend (scratchbuf
+ intel_syntax
);
4057 OP_D (int dummy ATTRIBUTE_UNUSED
, int sizeflag ATTRIBUTE_UNUSED
)
4060 USED_REX (REX_EXTX
);
4064 sprintf (scratchbuf
, "db%d", reg
+ add
);
4066 sprintf (scratchbuf
, "%%db%d", reg
+ add
);
4067 oappend (scratchbuf
);
4071 OP_T (int dummy ATTRIBUTE_UNUSED
, int sizeflag ATTRIBUTE_UNUSED
)
4073 sprintf (scratchbuf
, "%%tr%d", reg
);
4074 oappend (scratchbuf
+ intel_syntax
);
4078 OP_Rd (int bytemode
, int sizeflag
)
4081 OP_E (bytemode
, sizeflag
);
4087 OP_MMX (int bytemode ATTRIBUTE_UNUSED
, int sizeflag ATTRIBUTE_UNUSED
)
4089 used_prefixes
|= (prefixes
& PREFIX_DATA
);
4090 if (prefixes
& PREFIX_DATA
)
4093 USED_REX (REX_EXTX
);
4096 sprintf (scratchbuf
, "%%xmm%d", reg
+ add
);
4099 sprintf (scratchbuf
, "%%mm%d", reg
);
4100 oappend (scratchbuf
+ intel_syntax
);
4104 OP_XMM (int bytemode ATTRIBUTE_UNUSED
, int sizeflag ATTRIBUTE_UNUSED
)
4107 USED_REX (REX_EXTX
);
4110 sprintf (scratchbuf
, "%%xmm%d", reg
+ add
);
4111 oappend (scratchbuf
+ intel_syntax
);
4115 OP_EM (int bytemode
, int sizeflag
)
4119 if (intel_syntax
&& bytemode
== v_mode
)
4121 bytemode
= (prefixes
& PREFIX_DATA
) ? x_mode
: q_mode
;
4122 used_prefixes
|= (prefixes
& PREFIX_DATA
);
4124 OP_E (bytemode
, sizeflag
);
4128 /* Skip mod/rm byte. */
4131 used_prefixes
|= (prefixes
& PREFIX_DATA
);
4132 if (prefixes
& PREFIX_DATA
)
4136 USED_REX (REX_EXTZ
);
4139 sprintf (scratchbuf
, "%%xmm%d", rm
+ add
);
4142 sprintf (scratchbuf
, "%%mm%d", rm
);
4143 oappend (scratchbuf
+ intel_syntax
);
4147 OP_EX (int bytemode
, int sizeflag
)
4152 if (intel_syntax
&& bytemode
== v_mode
)
4154 switch (prefixes
& (PREFIX_DATA
|PREFIX_REPZ
|PREFIX_REPNZ
))
4156 case 0: bytemode
= x_mode
; break;
4157 case PREFIX_REPZ
: bytemode
= d_mode
; used_prefixes
|= PREFIX_REPZ
; break;
4158 case PREFIX_DATA
: bytemode
= x_mode
; used_prefixes
|= PREFIX_DATA
; break;
4159 case PREFIX_REPNZ
: bytemode
= q_mode
; used_prefixes
|= PREFIX_REPNZ
; break;
4160 default: bytemode
= 0; break;
4163 OP_E (bytemode
, sizeflag
);
4166 USED_REX (REX_EXTZ
);
4170 /* Skip mod/rm byte. */
4173 sprintf (scratchbuf
, "%%xmm%d", rm
+ add
);
4174 oappend (scratchbuf
+ intel_syntax
);
4178 OP_MS (int bytemode
, int sizeflag
)
4181 OP_EM (bytemode
, sizeflag
);
4187 OP_XS (int bytemode
, int sizeflag
)
4190 OP_EX (bytemode
, sizeflag
);
4196 OP_M (int bytemode
, int sizeflag
)
4199 BadOp (); /* bad lea,lds,les,lfs,lgs,lss modrm */
4201 OP_E (bytemode
, sizeflag
);
4205 OP_0f07 (int bytemode
, int sizeflag
)
4207 if (mod
!= 3 || rm
!= 0)
4210 OP_E (bytemode
, sizeflag
);
4214 OP_0fae (int bytemode
, int sizeflag
)
4219 strcpy (obuf
+ strlen (obuf
) - sizeof ("clflush") + 1, "sfence");
4221 if (reg
< 5 || rm
!= 0)
4223 BadOp (); /* bad sfence, mfence, or lfence */
4229 BadOp (); /* bad clflush */
4233 OP_E (bytemode
, sizeflag
);
4237 NOP_Fixup (int bytemode ATTRIBUTE_UNUSED
, int sizeflag ATTRIBUTE_UNUSED
)
4239 /* NOP with REPZ prefix is called PAUSE. */
4240 if (prefixes
== PREFIX_REPZ
)
4241 strcpy (obuf
, "pause");
4244 static const char *const Suffix3DNow
[] = {
4245 /* 00 */ NULL
, NULL
, NULL
, NULL
,
4246 /* 04 */ NULL
, NULL
, NULL
, NULL
,
4247 /* 08 */ NULL
, NULL
, NULL
, NULL
,
4248 /* 0C */ "pi2fw", "pi2fd", NULL
, NULL
,
4249 /* 10 */ NULL
, NULL
, NULL
, NULL
,
4250 /* 14 */ NULL
, NULL
, NULL
, NULL
,
4251 /* 18 */ NULL
, NULL
, NULL
, NULL
,
4252 /* 1C */ "pf2iw", "pf2id", NULL
, NULL
,
4253 /* 20 */ NULL
, NULL
, NULL
, NULL
,
4254 /* 24 */ NULL
, NULL
, NULL
, NULL
,
4255 /* 28 */ NULL
, NULL
, NULL
, NULL
,
4256 /* 2C */ NULL
, NULL
, NULL
, NULL
,
4257 /* 30 */ NULL
, NULL
, NULL
, NULL
,
4258 /* 34 */ NULL
, NULL
, NULL
, NULL
,
4259 /* 38 */ NULL
, NULL
, NULL
, NULL
,
4260 /* 3C */ NULL
, NULL
, NULL
, NULL
,
4261 /* 40 */ NULL
, NULL
, NULL
, NULL
,
4262 /* 44 */ NULL
, NULL
, NULL
, NULL
,
4263 /* 48 */ NULL
, NULL
, NULL
, NULL
,
4264 /* 4C */ NULL
, NULL
, NULL
, NULL
,
4265 /* 50 */ NULL
, NULL
, NULL
, NULL
,
4266 /* 54 */ NULL
, NULL
, NULL
, NULL
,
4267 /* 58 */ NULL
, NULL
, NULL
, NULL
,
4268 /* 5C */ NULL
, NULL
, NULL
, NULL
,
4269 /* 60 */ NULL
, NULL
, NULL
, NULL
,
4270 /* 64 */ NULL
, NULL
, NULL
, NULL
,
4271 /* 68 */ NULL
, NULL
, NULL
, NULL
,
4272 /* 6C */ NULL
, NULL
, NULL
, NULL
,
4273 /* 70 */ NULL
, NULL
, NULL
, NULL
,
4274 /* 74 */ NULL
, NULL
, NULL
, NULL
,
4275 /* 78 */ NULL
, NULL
, NULL
, NULL
,
4276 /* 7C */ NULL
, NULL
, NULL
, NULL
,
4277 /* 80 */ NULL
, NULL
, NULL
, NULL
,
4278 /* 84 */ NULL
, NULL
, NULL
, NULL
,
4279 /* 88 */ NULL
, NULL
, "pfnacc", NULL
,
4280 /* 8C */ NULL
, NULL
, "pfpnacc", NULL
,
4281 /* 90 */ "pfcmpge", NULL
, NULL
, NULL
,
4282 /* 94 */ "pfmin", NULL
, "pfrcp", "pfrsqrt",
4283 /* 98 */ NULL
, NULL
, "pfsub", NULL
,
4284 /* 9C */ NULL
, NULL
, "pfadd", NULL
,
4285 /* A0 */ "pfcmpgt", NULL
, NULL
, NULL
,
4286 /* A4 */ "pfmax", NULL
, "pfrcpit1", "pfrsqit1",
4287 /* A8 */ NULL
, NULL
, "pfsubr", NULL
,
4288 /* AC */ NULL
, NULL
, "pfacc", NULL
,
4289 /* B0 */ "pfcmpeq", NULL
, NULL
, NULL
,
4290 /* B4 */ "pfmul", NULL
, "pfrcpit2", "pfmulhrw",
4291 /* B8 */ NULL
, NULL
, NULL
, "pswapd",
4292 /* BC */ NULL
, NULL
, NULL
, "pavgusb",
4293 /* C0 */ NULL
, NULL
, NULL
, NULL
,
4294 /* C4 */ NULL
, NULL
, NULL
, NULL
,
4295 /* C8 */ NULL
, NULL
, NULL
, NULL
,
4296 /* CC */ NULL
, NULL
, NULL
, NULL
,
4297 /* D0 */ NULL
, NULL
, NULL
, NULL
,
4298 /* D4 */ NULL
, NULL
, NULL
, NULL
,
4299 /* D8 */ NULL
, NULL
, NULL
, NULL
,
4300 /* DC */ NULL
, NULL
, NULL
, NULL
,
4301 /* E0 */ NULL
, NULL
, NULL
, NULL
,
4302 /* E4 */ NULL
, NULL
, NULL
, NULL
,
4303 /* E8 */ NULL
, NULL
, NULL
, NULL
,
4304 /* EC */ NULL
, NULL
, NULL
, NULL
,
4305 /* F0 */ NULL
, NULL
, NULL
, NULL
,
4306 /* F4 */ NULL
, NULL
, NULL
, NULL
,
4307 /* F8 */ NULL
, NULL
, NULL
, NULL
,
4308 /* FC */ NULL
, NULL
, NULL
, NULL
,
4312 OP_3DNowSuffix (int bytemode ATTRIBUTE_UNUSED
, int sizeflag ATTRIBUTE_UNUSED
)
4314 const char *mnemonic
;
4316 FETCH_DATA (the_info
, codep
+ 1);
4317 /* AMD 3DNow! instructions are specified by an opcode suffix in the
4318 place where an 8-bit immediate would normally go. ie. the last
4319 byte of the instruction. */
4320 obufp
= obuf
+ strlen (obuf
);
4321 mnemonic
= Suffix3DNow
[*codep
++ & 0xff];
4326 /* Since a variable sized modrm/sib chunk is between the start
4327 of the opcode (0x0f0f) and the opcode suffix, we need to do
4328 all the modrm processing first, and don't know until now that
4329 we have a bad opcode. This necessitates some cleaning up. */
4336 static const char *simd_cmp_op
[] = {
4348 OP_SIMD_Suffix (int bytemode ATTRIBUTE_UNUSED
, int sizeflag ATTRIBUTE_UNUSED
)
4350 unsigned int cmp_type
;
4352 FETCH_DATA (the_info
, codep
+ 1);
4353 obufp
= obuf
+ strlen (obuf
);
4354 cmp_type
= *codep
++ & 0xff;
4357 char suffix1
= 'p', suffix2
= 's';
4358 used_prefixes
|= (prefixes
& PREFIX_REPZ
);
4359 if (prefixes
& PREFIX_REPZ
)
4363 used_prefixes
|= (prefixes
& PREFIX_DATA
);
4364 if (prefixes
& PREFIX_DATA
)
4368 used_prefixes
|= (prefixes
& PREFIX_REPNZ
);
4369 if (prefixes
& PREFIX_REPNZ
)
4370 suffix1
= 's', suffix2
= 'd';
4373 sprintf (scratchbuf
, "cmp%s%c%c",
4374 simd_cmp_op
[cmp_type
], suffix1
, suffix2
);
4375 used_prefixes
|= (prefixes
& PREFIX_REPZ
);
4376 oappend (scratchbuf
);
4380 /* We have a bad extension byte. Clean up. */
4388 SIMD_Fixup (int extrachar
, int sizeflag ATTRIBUTE_UNUSED
)
4390 /* Change movlps/movhps to movhlps/movlhps for 2 register operand
4391 forms of these instructions. */
4394 char *p
= obuf
+ strlen (obuf
);
4397 *(p
- 1) = *(p
- 2);
4398 *(p
- 2) = *(p
- 3);
4399 *(p
- 3) = extrachar
;
4404 PNI_Fixup (int extrachar ATTRIBUTE_UNUSED
, int sizeflag
)
4406 if (mod
== 3 && reg
== 1 && rm
<= 1)
4408 /* Override "sidt". */
4409 char *p
= obuf
+ strlen (obuf
) - 4;
4411 /* We might have a suffix. */
4417 /* mwait %eax,%ecx */
4418 strcpy (p
, "mwait");
4420 strcpy (op1out
, names32
[0]);
4424 /* monitor %eax,%ecx,%edx" */
4425 strcpy (p
, "monitor");
4429 strcpy (op1out
, names32
[0]);
4430 else if (!(prefixes
& PREFIX_ADDR
))
4431 strcpy (op1out
, names64
[0]);
4434 strcpy (op1out
, names32
[0]);
4435 used_prefixes
|= PREFIX_ADDR
;
4437 strcpy (op3out
, names32
[2]);
4442 strcpy (op2out
, names32
[1]);
4453 SVME_Fixup (int bytemode
, int sizeflag
)
4485 OP_M (bytemode
, sizeflag
);
4488 /* Override "lidt". */
4489 p
= obuf
+ strlen (obuf
) - 4;
4490 /* We might have a suffix. */
4494 if (!(prefixes
& PREFIX_ADDR
))
4499 used_prefixes
|= PREFIX_ADDR
;
4503 strcpy (op2out
, names32
[1]);
4509 *obufp
++ = open_char
;
4510 if (mode_64bit
|| (sizeflag
& AFLAG
))
4514 strcpy (obufp
, alt
);
4515 obufp
+= strlen (alt
);
4516 *obufp
++ = close_char
;
4523 INVLPG_Fixup (int bytemode
, int sizeflag
)
4536 OP_M (bytemode
, sizeflag
);
4539 /* Override "invlpg". */
4540 strcpy (obuf
+ strlen (obuf
) - 6, alt
);
4547 /* Throw away prefixes and 1st. opcode byte. */
4548 codep
= insn_codep
+ 1;
4553 SEG_Fixup (int extrachar
, int sizeflag
)
4557 /* We need to add a proper suffix with
4568 if (prefixes
& PREFIX_DATA
)
4572 USED_REX (REX_MODE64
);
4573 if (rex
& REX_MODE64
)
4578 strcat (obuf
, suffix
);
4582 /* We need to fix the suffix for
4589 Override "mov[l|q]". */
4590 char *p
= obuf
+ strlen (obuf
) - 1;
4592 /* We might not have a suffix. */
4598 OP_E (extrachar
, sizeflag
);