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_Fixup (int, int);
95 static void OP_3DNowSuffix (int, int);
96 static void OP_SIMD_Suffix (int, int);
97 static void SIMD_Fixup (int, int);
98 static void PNI_Fixup (int, int);
99 static void SVME_Fixup (int, int);
100 static void INVLPG_Fixup (int, int);
101 static void BadOp (void);
102 static void SEG_Fixup (int, int);
103 static void VMX_Fixup (int, int);
106 /* Points to first byte not fetched. */
107 bfd_byte
*max_fetched
;
108 bfd_byte the_buffer
[MAXLEN
];
114 /* The opcode for the fwait instruction, which we treat as a prefix
116 #define FWAIT_OPCODE (0x9b)
125 enum address_mode address_mode
;
127 /* Flags for the prefixes for the current instruction. See below. */
130 /* REX prefix the current instruction. See below. */
132 /* Bits of REX we've already used. */
138 /* Mark parts used in the REX prefix. When we are testing for
139 empty prefix (for 8bit register REX extension), just mask it
140 out. Otherwise test for REX bit is excuse for existence of REX
141 only in case value is nonzero. */
142 #define USED_REX(value) \
145 rex_used |= (rex & value) ? (value) | 0x40 : 0; \
150 /* Flags for prefixes which we somehow handled when printing the
151 current instruction. */
152 static int used_prefixes
;
154 /* Flags stored in PREFIXES. */
155 #define PREFIX_REPZ 1
156 #define PREFIX_REPNZ 2
157 #define PREFIX_LOCK 4
159 #define PREFIX_SS 0x10
160 #define PREFIX_DS 0x20
161 #define PREFIX_ES 0x40
162 #define PREFIX_FS 0x80
163 #define PREFIX_GS 0x100
164 #define PREFIX_DATA 0x200
165 #define PREFIX_ADDR 0x400
166 #define PREFIX_FWAIT 0x800
168 /* Make sure that bytes from INFO->PRIVATE_DATA->BUFFER (inclusive)
169 to ADDR (exclusive) are valid. Returns 1 for success, longjmps
171 #define FETCH_DATA(info, addr) \
172 ((addr) <= ((struct dis_private *) (info->private_data))->max_fetched \
173 ? 1 : fetch_data ((info), (addr)))
176 fetch_data (struct disassemble_info
*info
, bfd_byte
*addr
)
179 struct dis_private
*priv
= (struct dis_private
*) info
->private_data
;
180 bfd_vma start
= priv
->insn_start
+ (priv
->max_fetched
- priv
->the_buffer
);
182 if (addr
<= priv
->the_buffer
+ MAXLEN
)
183 status
= (*info
->read_memory_func
) (start
,
185 addr
- priv
->max_fetched
,
191 /* If we did manage to read at least one byte, then
192 print_insn_i386 will do something sensible. Otherwise, print
193 an error. We do that here because this is where we know
195 if (priv
->max_fetched
== priv
->the_buffer
)
196 (*info
->memory_error_func
) (status
, start
, info
);
197 longjmp (priv
->bailout
, 1);
200 priv
->max_fetched
= addr
;
206 #define Eb OP_E, b_mode
207 #define Ev OP_E, v_mode
208 #define Ed OP_E, d_mode
209 #define Eq OP_E, q_mode
210 #define Edq OP_E, dq_mode
211 #define Edqw OP_E, dqw_mode
212 #define indirEv OP_indirE, stack_v_mode
213 #define indirEp OP_indirE, f_mode
214 #define stackEv OP_E, stack_v_mode
215 #define Em OP_E, m_mode
216 #define Ew OP_E, w_mode
217 #define Ma OP_E, v_mode
218 #define M OP_M, 0 /* lea, lgdt, etc. */
219 #define Mp OP_M, f_mode /* 32 or 48 bit memory operand for LDS, LES etc */
220 #define Gb OP_G, b_mode
221 #define Gv OP_G, v_mode
222 #define Gd OP_G, d_mode
223 #define Gdq OP_G, dq_mode
224 #define Gm OP_G, m_mode
225 #define Gw OP_G, w_mode
226 #define Rd OP_Rd, d_mode
227 #define Rm OP_Rd, m_mode
228 #define Ib OP_I, b_mode
229 #define sIb OP_sI, b_mode /* sign extened byte */
230 #define Iv OP_I, v_mode
231 #define Iq OP_I, q_mode
232 #define Iv64 OP_I64, v_mode
233 #define Iw OP_I, w_mode
234 #define I1 OP_I, const_1_mode
235 #define Jb OP_J, b_mode
236 #define Jv OP_J, v_mode
237 #define Cm OP_C, m_mode
238 #define Dm OP_D, m_mode
239 #define Td OP_T, d_mode
240 #define Sv SEG_Fixup, v_mode
242 #define RMeAX OP_REG, eAX_reg
243 #define RMeBX OP_REG, eBX_reg
244 #define RMeCX OP_REG, eCX_reg
245 #define RMeDX OP_REG, eDX_reg
246 #define RMeSP OP_REG, eSP_reg
247 #define RMeBP OP_REG, eBP_reg
248 #define RMeSI OP_REG, eSI_reg
249 #define RMeDI OP_REG, eDI_reg
250 #define RMrAX OP_REG, rAX_reg
251 #define RMrBX OP_REG, rBX_reg
252 #define RMrCX OP_REG, rCX_reg
253 #define RMrDX OP_REG, rDX_reg
254 #define RMrSP OP_REG, rSP_reg
255 #define RMrBP OP_REG, rBP_reg
256 #define RMrSI OP_REG, rSI_reg
257 #define RMrDI OP_REG, rDI_reg
258 #define RMAL OP_REG, al_reg
259 #define RMAL OP_REG, al_reg
260 #define RMCL OP_REG, cl_reg
261 #define RMDL OP_REG, dl_reg
262 #define RMBL OP_REG, bl_reg
263 #define RMAH OP_REG, ah_reg
264 #define RMCH OP_REG, ch_reg
265 #define RMDH OP_REG, dh_reg
266 #define RMBH OP_REG, bh_reg
267 #define RMAX OP_REG, ax_reg
268 #define RMDX OP_REG, dx_reg
270 #define eAX OP_IMREG, eAX_reg
271 #define eBX OP_IMREG, eBX_reg
272 #define eCX OP_IMREG, eCX_reg
273 #define eDX OP_IMREG, eDX_reg
274 #define eSP OP_IMREG, eSP_reg
275 #define eBP OP_IMREG, eBP_reg
276 #define eSI OP_IMREG, eSI_reg
277 #define eDI OP_IMREG, eDI_reg
278 #define AL OP_IMREG, al_reg
279 #define AL OP_IMREG, al_reg
280 #define CL OP_IMREG, cl_reg
281 #define DL OP_IMREG, dl_reg
282 #define BL OP_IMREG, bl_reg
283 #define AH OP_IMREG, ah_reg
284 #define CH OP_IMREG, ch_reg
285 #define DH OP_IMREG, dh_reg
286 #define BH OP_IMREG, bh_reg
287 #define AX OP_IMREG, ax_reg
288 #define DX OP_IMREG, dx_reg
289 #define indirDX OP_IMREG, indir_dx_reg
291 #define Sw OP_SEG, w_mode
293 #define Ob OP_OFF64, b_mode
294 #define Ov OP_OFF64, v_mode
295 #define Xb OP_DSreg, eSI_reg
296 #define Xv OP_DSreg, eSI_reg
297 #define Yb OP_ESreg, eDI_reg
298 #define Yv OP_ESreg, eDI_reg
299 #define DSBX OP_DSreg, eBX_reg
301 #define es OP_REG, es_reg
302 #define ss OP_REG, ss_reg
303 #define cs OP_REG, cs_reg
304 #define ds OP_REG, ds_reg
305 #define fs OP_REG, fs_reg
306 #define gs OP_REG, gs_reg
310 #define EM OP_EM, v_mode
311 #define EX OP_EX, v_mode
312 #define MS OP_MS, v_mode
313 #define XS OP_XS, v_mode
314 #define VM OP_VMX, q_mode
315 #define OPSUF OP_3DNowSuffix, 0
316 #define OPSIMD OP_SIMD_Suffix, 0
318 #define cond_jump_flag NULL, cond_jump_mode
319 #define loop_jcxz_flag NULL, loop_jcxz_mode
321 /* bits in sizeflag */
322 #define SUFFIX_ALWAYS 4
326 #define b_mode 1 /* byte operand */
327 #define v_mode 2 /* operand size depends on prefixes */
328 #define w_mode 3 /* word operand */
329 #define d_mode 4 /* double word operand */
330 #define q_mode 5 /* quad word operand */
331 #define t_mode 6 /* ten-byte operand */
332 #define x_mode 7 /* 16-byte XMM operand */
333 #define m_mode 8 /* d_mode in 32bit, q_mode in 64bit mode. */
334 #define cond_jump_mode 9
335 #define loop_jcxz_mode 10
336 #define dq_mode 11 /* operand size depends on REX prefixes. */
337 #define dqw_mode 12 /* registers like dq_mode, memory like w_mode. */
338 #define f_mode 13 /* 4- or 6-byte pointer operand */
339 #define const_1_mode 14
340 #define stack_v_mode 15 /* v_mode for stack-related opcodes. */
385 #define indir_dx_reg 150
389 #define USE_PREFIX_USER_TABLE 3
390 #define X86_64_SPECIAL 4
392 #define FLOAT NULL, NULL, FLOATCODE, NULL, 0, NULL, 0
394 #define GRP1b NULL, NULL, USE_GROUPS, NULL, 0, NULL, 0
395 #define GRP1S NULL, NULL, USE_GROUPS, NULL, 1, NULL, 0
396 #define GRP1Ss NULL, NULL, USE_GROUPS, NULL, 2, NULL, 0
397 #define GRP2b NULL, NULL, USE_GROUPS, NULL, 3, NULL, 0
398 #define GRP2S NULL, NULL, USE_GROUPS, NULL, 4, NULL, 0
399 #define GRP2b_one NULL, NULL, USE_GROUPS, NULL, 5, NULL, 0
400 #define GRP2S_one NULL, NULL, USE_GROUPS, NULL, 6, NULL, 0
401 #define GRP2b_cl NULL, NULL, USE_GROUPS, NULL, 7, NULL, 0
402 #define GRP2S_cl NULL, NULL, USE_GROUPS, NULL, 8, NULL, 0
403 #define GRP3b NULL, NULL, USE_GROUPS, NULL, 9, NULL, 0
404 #define GRP3S NULL, NULL, USE_GROUPS, NULL, 10, NULL, 0
405 #define GRP4 NULL, NULL, USE_GROUPS, NULL, 11, NULL, 0
406 #define GRP5 NULL, NULL, USE_GROUPS, NULL, 12, NULL, 0
407 #define GRP6 NULL, NULL, USE_GROUPS, NULL, 13, NULL, 0
408 #define GRP7 NULL, NULL, USE_GROUPS, NULL, 14, NULL, 0
409 #define GRP8 NULL, NULL, USE_GROUPS, NULL, 15, NULL, 0
410 #define GRP9 NULL, NULL, USE_GROUPS, NULL, 16, NULL, 0
411 #define GRP10 NULL, NULL, USE_GROUPS, NULL, 17, NULL, 0
412 #define GRP11 NULL, NULL, USE_GROUPS, NULL, 18, NULL, 0
413 #define GRP12 NULL, NULL, USE_GROUPS, NULL, 19, NULL, 0
414 #define GRP13 NULL, NULL, USE_GROUPS, NULL, 20, NULL, 0
415 #define GRP14 NULL, NULL, USE_GROUPS, NULL, 21, NULL, 0
416 #define GRPAMD NULL, NULL, USE_GROUPS, NULL, 22, NULL, 0
417 #define GRPPADLCK1 NULL, NULL, USE_GROUPS, NULL, 23, NULL, 0
418 #define GRPPADLCK2 NULL, NULL, USE_GROUPS, NULL, 24, NULL, 0
420 #define PREGRP0 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 0, NULL, 0
421 #define PREGRP1 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 1, NULL, 0
422 #define PREGRP2 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 2, NULL, 0
423 #define PREGRP3 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 3, NULL, 0
424 #define PREGRP4 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 4, NULL, 0
425 #define PREGRP5 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 5, NULL, 0
426 #define PREGRP6 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 6, NULL, 0
427 #define PREGRP7 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 7, NULL, 0
428 #define PREGRP8 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 8, NULL, 0
429 #define PREGRP9 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 9, NULL, 0
430 #define PREGRP10 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 10, NULL, 0
431 #define PREGRP11 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 11, NULL, 0
432 #define PREGRP12 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 12, NULL, 0
433 #define PREGRP13 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 13, NULL, 0
434 #define PREGRP14 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 14, NULL, 0
435 #define PREGRP15 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 15, NULL, 0
436 #define PREGRP16 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 16, NULL, 0
437 #define PREGRP17 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 17, NULL, 0
438 #define PREGRP18 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 18, NULL, 0
439 #define PREGRP19 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 19, NULL, 0
440 #define PREGRP20 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 20, NULL, 0
441 #define PREGRP21 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 21, NULL, 0
442 #define PREGRP22 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 22, NULL, 0
443 #define PREGRP23 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 23, NULL, 0
444 #define PREGRP24 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 24, NULL, 0
445 #define PREGRP25 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 25, NULL, 0
446 #define PREGRP26 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 26, NULL, 0
447 #define PREGRP27 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 27, NULL, 0
448 #define PREGRP28 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 28, NULL, 0
449 #define PREGRP29 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 29, NULL, 0
450 #define PREGRP30 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 30, NULL, 0
451 #define PREGRP31 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 31, NULL, 0
452 #define PREGRP32 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 32, NULL, 0
454 #define X86_64_0 NULL, NULL, X86_64_SPECIAL, NULL, 0, NULL, 0
456 typedef void (*op_rtn
) (int bytemode
, int sizeflag
);
468 /* Upper case letters in the instruction names here are macros.
469 'A' => print 'b' if no register operands or suffix_always is true
470 'B' => print 'b' if suffix_always is true
471 'C' => print 's' or 'l' ('w' or 'd' in Intel mode) depending on operand
473 'E' => print 'e' if 32-bit form of jcxz
474 'F' => print 'w' or 'l' depending on address size prefix (loop insns)
475 'H' => print ",pt" or ",pn" branch hint
476 'I' => honor following macro letter even in Intel mode (implemented only
477 . for some of the macro letters)
479 'L' => print 'l' if suffix_always is true
480 'N' => print 'n' if instruction has no wait "prefix"
481 'O' => print 'd', or 'o'
482 'P' => print 'w', 'l' or 'q' if instruction has an operand size prefix,
483 . or suffix_always is true. print 'q' if rex prefix is present.
484 'Q' => print 'w', 'l' or 'q' if no register operands or suffix_always
486 'R' => print 'w', 'l' or 'q' ("wd" or "dq" in intel mode)
487 'S' => print 'w', 'l' or 'q' if suffix_always is true
488 'T' => print 'q' in 64bit mode and behave as 'P' otherwise
489 'U' => print 'q' in 64bit mode and behave as 'Q' otherwise
490 'V' => print 'q' in 64bit mode and behave as 'S' otherwise
491 'W' => print 'b' or 'w' ("w" or "de" in intel mode)
492 'X' => print 's', 'd' depending on data16 prefix (for XMM)
493 'Y' => 'q' if instruction has an REX 64bit overwrite prefix
495 Many of the above letters print nothing in Intel mode. See "putop"
498 Braces '{' and '}', and vertical bars '|', indicate alternative
499 mnemonic strings for AT&T, Intel, X86_64 AT&T, and X86_64 Intel
500 modes. In cases where there are only two alternatives, the X86_64
501 instruction is reserved, and "(bad)" is printed.
504 static const struct dis386 dis386
[] = {
506 { "addB", Eb
, Gb
, XX
},
507 { "addS", Ev
, Gv
, XX
},
508 { "addB", Gb
, Eb
, XX
},
509 { "addS", Gv
, Ev
, XX
},
510 { "addB", AL
, Ib
, XX
},
511 { "addS", eAX
, Iv
, XX
},
512 { "push{T|}", es
, XX
, XX
},
513 { "pop{T|}", es
, XX
, XX
},
515 { "orB", Eb
, Gb
, XX
},
516 { "orS", Ev
, Gv
, XX
},
517 { "orB", Gb
, Eb
, XX
},
518 { "orS", Gv
, Ev
, XX
},
519 { "orB", AL
, Ib
, XX
},
520 { "orS", eAX
, Iv
, XX
},
521 { "push{T|}", cs
, XX
, XX
},
522 { "(bad)", XX
, XX
, XX
}, /* 0x0f extended opcode escape */
524 { "adcB", Eb
, Gb
, XX
},
525 { "adcS", Ev
, Gv
, XX
},
526 { "adcB", Gb
, Eb
, XX
},
527 { "adcS", Gv
, Ev
, XX
},
528 { "adcB", AL
, Ib
, XX
},
529 { "adcS", eAX
, Iv
, XX
},
530 { "push{T|}", ss
, XX
, XX
},
531 { "pop{T|}", ss
, XX
, XX
},
533 { "sbbB", Eb
, Gb
, XX
},
534 { "sbbS", Ev
, Gv
, XX
},
535 { "sbbB", Gb
, Eb
, XX
},
536 { "sbbS", Gv
, Ev
, XX
},
537 { "sbbB", AL
, Ib
, XX
},
538 { "sbbS", eAX
, Iv
, XX
},
539 { "push{T|}", ds
, XX
, XX
},
540 { "pop{T|}", ds
, XX
, XX
},
542 { "andB", Eb
, Gb
, XX
},
543 { "andS", Ev
, Gv
, XX
},
544 { "andB", Gb
, Eb
, XX
},
545 { "andS", Gv
, Ev
, XX
},
546 { "andB", AL
, Ib
, XX
},
547 { "andS", eAX
, Iv
, XX
},
548 { "(bad)", XX
, XX
, XX
}, /* SEG ES prefix */
549 { "daa{|}", XX
, XX
, XX
},
551 { "subB", Eb
, Gb
, XX
},
552 { "subS", Ev
, Gv
, XX
},
553 { "subB", Gb
, Eb
, XX
},
554 { "subS", Gv
, Ev
, XX
},
555 { "subB", AL
, Ib
, XX
},
556 { "subS", eAX
, Iv
, XX
},
557 { "(bad)", XX
, XX
, XX
}, /* SEG CS prefix */
558 { "das{|}", XX
, XX
, XX
},
560 { "xorB", Eb
, Gb
, XX
},
561 { "xorS", Ev
, Gv
, XX
},
562 { "xorB", Gb
, Eb
, XX
},
563 { "xorS", Gv
, Ev
, XX
},
564 { "xorB", AL
, Ib
, XX
},
565 { "xorS", eAX
, Iv
, XX
},
566 { "(bad)", XX
, XX
, XX
}, /* SEG SS prefix */
567 { "aaa{|}", XX
, XX
, XX
},
569 { "cmpB", Eb
, Gb
, XX
},
570 { "cmpS", Ev
, Gv
, XX
},
571 { "cmpB", Gb
, Eb
, XX
},
572 { "cmpS", Gv
, Ev
, XX
},
573 { "cmpB", AL
, Ib
, XX
},
574 { "cmpS", eAX
, Iv
, XX
},
575 { "(bad)", XX
, XX
, XX
}, /* SEG DS prefix */
576 { "aas{|}", XX
, XX
, XX
},
578 { "inc{S|}", RMeAX
, XX
, XX
},
579 { "inc{S|}", RMeCX
, XX
, XX
},
580 { "inc{S|}", RMeDX
, XX
, XX
},
581 { "inc{S|}", RMeBX
, XX
, XX
},
582 { "inc{S|}", RMeSP
, XX
, XX
},
583 { "inc{S|}", RMeBP
, XX
, XX
},
584 { "inc{S|}", RMeSI
, XX
, XX
},
585 { "inc{S|}", RMeDI
, XX
, XX
},
587 { "dec{S|}", RMeAX
, XX
, XX
},
588 { "dec{S|}", RMeCX
, XX
, XX
},
589 { "dec{S|}", RMeDX
, XX
, XX
},
590 { "dec{S|}", RMeBX
, XX
, XX
},
591 { "dec{S|}", RMeSP
, XX
, XX
},
592 { "dec{S|}", RMeBP
, XX
, XX
},
593 { "dec{S|}", RMeSI
, XX
, XX
},
594 { "dec{S|}", RMeDI
, XX
, XX
},
596 { "pushV", RMrAX
, XX
, XX
},
597 { "pushV", RMrCX
, XX
, XX
},
598 { "pushV", RMrDX
, XX
, XX
},
599 { "pushV", RMrBX
, XX
, XX
},
600 { "pushV", RMrSP
, XX
, XX
},
601 { "pushV", RMrBP
, XX
, XX
},
602 { "pushV", RMrSI
, XX
, XX
},
603 { "pushV", RMrDI
, XX
, XX
},
605 { "popV", RMrAX
, XX
, XX
},
606 { "popV", RMrCX
, XX
, XX
},
607 { "popV", RMrDX
, XX
, XX
},
608 { "popV", RMrBX
, XX
, XX
},
609 { "popV", RMrSP
, XX
, XX
},
610 { "popV", RMrBP
, XX
, XX
},
611 { "popV", RMrSI
, XX
, XX
},
612 { "popV", RMrDI
, XX
, XX
},
614 { "pusha{P|}", XX
, XX
, XX
},
615 { "popa{P|}", XX
, XX
, XX
},
616 { "bound{S|}", Gv
, Ma
, XX
},
618 { "(bad)", XX
, XX
, XX
}, /* seg fs */
619 { "(bad)", XX
, XX
, XX
}, /* seg gs */
620 { "(bad)", XX
, XX
, XX
}, /* op size prefix */
621 { "(bad)", XX
, XX
, XX
}, /* adr size prefix */
623 { "pushT", Iq
, XX
, XX
},
624 { "imulS", Gv
, Ev
, Iv
},
625 { "pushT", sIb
, XX
, XX
},
626 { "imulS", Gv
, Ev
, sIb
},
627 { "ins{b||b|}", Yb
, indirDX
, XX
},
628 { "ins{R||R|}", Yv
, indirDX
, XX
},
629 { "outs{b||b|}", indirDX
, Xb
, XX
},
630 { "outs{R||R|}", indirDX
, Xv
, XX
},
632 { "joH", Jb
, XX
, cond_jump_flag
},
633 { "jnoH", Jb
, XX
, cond_jump_flag
},
634 { "jbH", Jb
, XX
, cond_jump_flag
},
635 { "jaeH", Jb
, XX
, cond_jump_flag
},
636 { "jeH", Jb
, XX
, cond_jump_flag
},
637 { "jneH", Jb
, XX
, cond_jump_flag
},
638 { "jbeH", Jb
, XX
, cond_jump_flag
},
639 { "jaH", Jb
, XX
, cond_jump_flag
},
641 { "jsH", Jb
, XX
, cond_jump_flag
},
642 { "jnsH", Jb
, XX
, cond_jump_flag
},
643 { "jpH", Jb
, XX
, cond_jump_flag
},
644 { "jnpH", Jb
, XX
, cond_jump_flag
},
645 { "jlH", Jb
, XX
, cond_jump_flag
},
646 { "jgeH", Jb
, XX
, cond_jump_flag
},
647 { "jleH", Jb
, XX
, cond_jump_flag
},
648 { "jgH", Jb
, XX
, cond_jump_flag
},
652 { "(bad)", XX
, XX
, XX
},
654 { "testB", Eb
, Gb
, XX
},
655 { "testS", Ev
, Gv
, XX
},
656 { "xchgB", Eb
, Gb
, XX
},
657 { "xchgS", Ev
, Gv
, XX
},
659 { "movB", Eb
, Gb
, XX
},
660 { "movS", Ev
, Gv
, XX
},
661 { "movB", Gb
, Eb
, XX
},
662 { "movS", Gv
, Ev
, XX
},
663 { "movQ", Sv
, Sw
, XX
},
664 { "leaS", Gv
, M
, XX
},
665 { "movQ", Sw
, Sv
, XX
},
666 { "popU", stackEv
, XX
, XX
},
668 { "nop", NOP_Fixup
, 0, XX
, XX
},
669 { "xchgS", RMeCX
, eAX
, XX
},
670 { "xchgS", RMeDX
, eAX
, XX
},
671 { "xchgS", RMeBX
, eAX
, XX
},
672 { "xchgS", RMeSP
, eAX
, XX
},
673 { "xchgS", RMeBP
, eAX
, XX
},
674 { "xchgS", RMeSI
, eAX
, XX
},
675 { "xchgS", RMeDI
, eAX
, XX
},
677 { "cW{tR||tR|}", XX
, XX
, XX
},
678 { "cR{tO||tO|}", XX
, XX
, XX
},
679 { "Jcall{T|}", Ap
, XX
, XX
},
680 { "(bad)", XX
, XX
, XX
}, /* fwait */
681 { "pushfT", XX
, XX
, XX
},
682 { "popfT", XX
, XX
, XX
},
683 { "sahf{|}", XX
, XX
, XX
},
684 { "lahf{|}", XX
, XX
, XX
},
686 { "movB", AL
, Ob
, XX
},
687 { "movS", eAX
, Ov
, XX
},
688 { "movB", Ob
, AL
, XX
},
689 { "movS", Ov
, eAX
, XX
},
690 { "movs{b||b|}", Yb
, Xb
, XX
},
691 { "movs{R||R|}", Yv
, Xv
, XX
},
692 { "cmps{b||b|}", Xb
, Yb
, XX
},
693 { "cmps{R||R|}", Xv
, Yv
, XX
},
695 { "testB", AL
, Ib
, XX
},
696 { "testS", eAX
, Iv
, XX
},
697 { "stosB", Yb
, AL
, XX
},
698 { "stosS", Yv
, eAX
, XX
},
699 { "lodsB", AL
, Xb
, XX
},
700 { "lodsS", eAX
, Xv
, XX
},
701 { "scasB", AL
, Yb
, XX
},
702 { "scasS", eAX
, Yv
, XX
},
704 { "movB", RMAL
, Ib
, XX
},
705 { "movB", RMCL
, Ib
, XX
},
706 { "movB", RMDL
, Ib
, XX
},
707 { "movB", RMBL
, Ib
, XX
},
708 { "movB", RMAH
, Ib
, XX
},
709 { "movB", RMCH
, Ib
, XX
},
710 { "movB", RMDH
, Ib
, XX
},
711 { "movB", RMBH
, Ib
, XX
},
713 { "movS", RMeAX
, Iv64
, XX
},
714 { "movS", RMeCX
, Iv64
, XX
},
715 { "movS", RMeDX
, Iv64
, XX
},
716 { "movS", RMeBX
, Iv64
, XX
},
717 { "movS", RMeSP
, Iv64
, XX
},
718 { "movS", RMeBP
, Iv64
, XX
},
719 { "movS", RMeSI
, Iv64
, XX
},
720 { "movS", RMeDI
, Iv64
, XX
},
724 { "retT", Iw
, XX
, XX
},
725 { "retT", XX
, XX
, XX
},
726 { "les{S|}", Gv
, Mp
, XX
},
727 { "ldsS", Gv
, Mp
, XX
},
728 { "movA", Eb
, Ib
, XX
},
729 { "movQ", Ev
, Iv
, XX
},
731 { "enterT", Iw
, Ib
, XX
},
732 { "leaveT", XX
, XX
, XX
},
733 { "lretP", Iw
, XX
, XX
},
734 { "lretP", XX
, XX
, XX
},
735 { "int3", XX
, XX
, XX
},
736 { "int", Ib
, XX
, XX
},
737 { "into{|}", XX
, XX
, XX
},
738 { "iretP", XX
, XX
, XX
},
744 { "aam{|}", sIb
, XX
, XX
},
745 { "aad{|}", sIb
, XX
, XX
},
746 { "(bad)", XX
, XX
, XX
},
747 { "xlat", DSBX
, XX
, XX
},
758 { "loopneFH", Jb
, XX
, loop_jcxz_flag
},
759 { "loopeFH", Jb
, XX
, loop_jcxz_flag
},
760 { "loopFH", Jb
, XX
, loop_jcxz_flag
},
761 { "jEcxzH", Jb
, XX
, loop_jcxz_flag
},
762 { "inB", AL
, Ib
, XX
},
763 { "inS", eAX
, Ib
, XX
},
764 { "outB", Ib
, AL
, XX
},
765 { "outS", Ib
, eAX
, XX
},
767 { "callT", Jv
, XX
, XX
},
768 { "jmpT", Jv
, XX
, XX
},
769 { "Jjmp{T|}", Ap
, XX
, XX
},
770 { "jmp", Jb
, XX
, XX
},
771 { "inB", AL
, indirDX
, XX
},
772 { "inS", eAX
, indirDX
, XX
},
773 { "outB", indirDX
, AL
, XX
},
774 { "outS", indirDX
, eAX
, XX
},
776 { "(bad)", XX
, XX
, XX
}, /* lock prefix */
777 { "icebp", XX
, XX
, XX
},
778 { "(bad)", XX
, XX
, XX
}, /* repne */
779 { "(bad)", XX
, XX
, XX
}, /* repz */
780 { "hlt", XX
, XX
, XX
},
781 { "cmc", XX
, XX
, XX
},
785 { "clc", XX
, XX
, XX
},
786 { "stc", XX
, XX
, XX
},
787 { "cli", XX
, XX
, XX
},
788 { "sti", XX
, XX
, XX
},
789 { "cld", XX
, XX
, XX
},
790 { "std", XX
, XX
, XX
},
795 static const struct dis386 dis386_twobyte
[] = {
799 { "larS", Gv
, Ew
, XX
},
800 { "lslS", Gv
, Ew
, XX
},
801 { "(bad)", XX
, XX
, XX
},
802 { "syscall", XX
, XX
, XX
},
803 { "clts", XX
, XX
, XX
},
804 { "sysretP", XX
, XX
, XX
},
806 { "invd", XX
, XX
, XX
},
807 { "wbinvd", XX
, XX
, XX
},
808 { "(bad)", XX
, XX
, XX
},
809 { "ud2a", XX
, XX
, XX
},
810 { "(bad)", XX
, XX
, XX
},
812 { "femms", XX
, XX
, XX
},
813 { "", MX
, EM
, OPSUF
}, /* See OP_3DNowSuffix. */
818 { "movlpX", EX
, XM
, SIMD_Fixup
, 'h' },
819 { "unpcklpX", XM
, EX
, XX
},
820 { "unpckhpX", XM
, EX
, XX
},
822 { "movhpX", EX
, XM
, SIMD_Fixup
, 'l' },
825 { "(bad)", XX
, XX
, XX
},
826 { "(bad)", XX
, XX
, XX
},
827 { "(bad)", XX
, XX
, XX
},
828 { "(bad)", XX
, XX
, XX
},
829 { "(bad)", XX
, XX
, XX
},
830 { "(bad)", XX
, XX
, XX
},
831 { "(bad)", XX
, XX
, XX
},
833 { "movL", Rm
, Cm
, XX
},
834 { "movL", Rm
, Dm
, XX
},
835 { "movL", Cm
, Rm
, XX
},
836 { "movL", Dm
, Rm
, XX
},
837 { "movL", Rd
, Td
, XX
},
838 { "(bad)", XX
, XX
, XX
},
839 { "movL", Td
, Rd
, XX
},
840 { "(bad)", XX
, XX
, XX
},
842 { "movapX", XM
, EX
, XX
},
843 { "movapX", EX
, XM
, XX
},
845 { "movntpX", Ev
, XM
, XX
},
848 { "ucomisX", XM
,EX
, XX
},
849 { "comisX", XM
,EX
, XX
},
851 { "wrmsr", XX
, XX
, XX
},
852 { "rdtsc", XX
, XX
, XX
},
853 { "rdmsr", XX
, XX
, XX
},
854 { "rdpmc", XX
, XX
, XX
},
855 { "sysenter", XX
, XX
, XX
},
856 { "sysexit", XX
, XX
, XX
},
857 { "(bad)", XX
, XX
, XX
},
858 { "(bad)", XX
, XX
, XX
},
860 { "(bad)", XX
, XX
, XX
},
861 { "(bad)", XX
, XX
, XX
},
862 { "(bad)", XX
, XX
, XX
},
863 { "(bad)", XX
, XX
, XX
},
864 { "(bad)", XX
, XX
, XX
},
865 { "(bad)", XX
, XX
, XX
},
866 { "(bad)", XX
, XX
, XX
},
867 { "(bad)", XX
, XX
, XX
},
869 { "cmovo", Gv
, Ev
, XX
},
870 { "cmovno", Gv
, Ev
, XX
},
871 { "cmovb", Gv
, Ev
, XX
},
872 { "cmovae", Gv
, Ev
, XX
},
873 { "cmove", Gv
, Ev
, XX
},
874 { "cmovne", Gv
, Ev
, XX
},
875 { "cmovbe", Gv
, Ev
, XX
},
876 { "cmova", Gv
, Ev
, XX
},
878 { "cmovs", Gv
, Ev
, XX
},
879 { "cmovns", Gv
, Ev
, XX
},
880 { "cmovp", Gv
, Ev
, XX
},
881 { "cmovnp", Gv
, Ev
, XX
},
882 { "cmovl", Gv
, Ev
, XX
},
883 { "cmovge", Gv
, Ev
, XX
},
884 { "cmovle", Gv
, Ev
, XX
},
885 { "cmovg", Gv
, Ev
, XX
},
887 { "movmskpX", Gdq
, XS
, XX
},
891 { "andpX", XM
, EX
, XX
},
892 { "andnpX", XM
, EX
, XX
},
893 { "orpX", XM
, EX
, XX
},
894 { "xorpX", XM
, EX
, XX
},
905 { "punpcklbw", MX
, EM
, XX
},
906 { "punpcklwd", MX
, EM
, XX
},
907 { "punpckldq", MX
, EM
, XX
},
908 { "packsswb", MX
, EM
, XX
},
909 { "pcmpgtb", MX
, EM
, XX
},
910 { "pcmpgtw", MX
, EM
, XX
},
911 { "pcmpgtd", MX
, EM
, XX
},
912 { "packuswb", MX
, EM
, XX
},
914 { "punpckhbw", MX
, EM
, XX
},
915 { "punpckhwd", MX
, EM
, XX
},
916 { "punpckhdq", MX
, EM
, XX
},
917 { "packssdw", MX
, EM
, XX
},
920 { "movd", MX
, Edq
, XX
},
927 { "pcmpeqb", MX
, EM
, XX
},
928 { "pcmpeqw", MX
, EM
, XX
},
929 { "pcmpeqd", MX
, EM
, XX
},
930 { "emms", XX
, XX
, XX
},
932 { "vmread", Em
, Gm
, XX
},
933 { "vmwrite", Gm
, Em
, XX
},
934 { "(bad)", XX
, XX
, XX
},
935 { "(bad)", XX
, XX
, XX
},
941 { "joH", Jv
, XX
, cond_jump_flag
},
942 { "jnoH", Jv
, XX
, cond_jump_flag
},
943 { "jbH", Jv
, XX
, cond_jump_flag
},
944 { "jaeH", Jv
, XX
, cond_jump_flag
},
945 { "jeH", Jv
, XX
, cond_jump_flag
},
946 { "jneH", Jv
, XX
, cond_jump_flag
},
947 { "jbeH", Jv
, XX
, cond_jump_flag
},
948 { "jaH", Jv
, XX
, cond_jump_flag
},
950 { "jsH", Jv
, XX
, cond_jump_flag
},
951 { "jnsH", Jv
, XX
, cond_jump_flag
},
952 { "jpH", Jv
, XX
, cond_jump_flag
},
953 { "jnpH", Jv
, XX
, cond_jump_flag
},
954 { "jlH", Jv
, XX
, cond_jump_flag
},
955 { "jgeH", Jv
, XX
, cond_jump_flag
},
956 { "jleH", Jv
, XX
, cond_jump_flag
},
957 { "jgH", Jv
, XX
, cond_jump_flag
},
959 { "seto", Eb
, XX
, XX
},
960 { "setno", Eb
, XX
, XX
},
961 { "setb", Eb
, XX
, XX
},
962 { "setae", Eb
, XX
, XX
},
963 { "sete", Eb
, XX
, XX
},
964 { "setne", Eb
, XX
, XX
},
965 { "setbe", Eb
, XX
, XX
},
966 { "seta", Eb
, XX
, XX
},
968 { "sets", Eb
, XX
, XX
},
969 { "setns", Eb
, XX
, XX
},
970 { "setp", Eb
, XX
, XX
},
971 { "setnp", Eb
, XX
, XX
},
972 { "setl", Eb
, XX
, XX
},
973 { "setge", Eb
, XX
, XX
},
974 { "setle", Eb
, XX
, XX
},
975 { "setg", Eb
, XX
, XX
},
977 { "pushT", fs
, XX
, XX
},
978 { "popT", fs
, XX
, XX
},
979 { "cpuid", XX
, XX
, XX
},
980 { "btS", Ev
, Gv
, XX
},
981 { "shldS", Ev
, Gv
, Ib
},
982 { "shldS", Ev
, Gv
, CL
},
986 { "pushT", gs
, XX
, XX
},
987 { "popT", gs
, XX
, XX
},
988 { "rsm", XX
, XX
, XX
},
989 { "btsS", Ev
, Gv
, XX
},
990 { "shrdS", Ev
, Gv
, Ib
},
991 { "shrdS", Ev
, Gv
, CL
},
993 { "imulS", Gv
, Ev
, XX
},
995 { "cmpxchgB", Eb
, Gb
, XX
},
996 { "cmpxchgS", Ev
, Gv
, XX
},
997 { "lssS", Gv
, Mp
, XX
},
998 { "btrS", Ev
, Gv
, XX
},
999 { "lfsS", Gv
, Mp
, XX
},
1000 { "lgsS", Gv
, Mp
, XX
},
1001 { "movz{bR|x|bR|x}", Gv
, Eb
, XX
},
1002 { "movz{wR|x|wR|x}", Gv
, Ew
, XX
}, /* yes, there really is movzww ! */
1004 { "(bad)", XX
, XX
, XX
},
1005 { "ud2b", XX
, XX
, XX
},
1007 { "btcS", Ev
, Gv
, XX
},
1008 { "bsfS", Gv
, Ev
, XX
},
1009 { "bsrS", Gv
, Ev
, XX
},
1010 { "movs{bR|x|bR|x}", Gv
, Eb
, XX
},
1011 { "movs{wR|x|wR|x}", Gv
, Ew
, XX
}, /* yes, there really is movsww ! */
1013 { "xaddB", Eb
, Gb
, XX
},
1014 { "xaddS", Ev
, Gv
, XX
},
1016 { "movntiS", Ev
, Gv
, XX
},
1017 { "pinsrw", MX
, Edqw
, Ib
},
1018 { "pextrw", Gdq
, MS
, Ib
},
1019 { "shufpX", XM
, EX
, Ib
},
1022 { "bswap", RMeAX
, XX
, XX
},
1023 { "bswap", RMeCX
, XX
, XX
},
1024 { "bswap", RMeDX
, XX
, XX
},
1025 { "bswap", RMeBX
, XX
, XX
},
1026 { "bswap", RMeSP
, XX
, XX
},
1027 { "bswap", RMeBP
, XX
, XX
},
1028 { "bswap", RMeSI
, XX
, XX
},
1029 { "bswap", RMeDI
, XX
, XX
},
1032 { "psrlw", MX
, EM
, XX
},
1033 { "psrld", MX
, EM
, XX
},
1034 { "psrlq", MX
, EM
, XX
},
1035 { "paddq", MX
, EM
, XX
},
1036 { "pmullw", MX
, EM
, XX
},
1038 { "pmovmskb", Gdq
, MS
, XX
},
1040 { "psubusb", MX
, EM
, XX
},
1041 { "psubusw", MX
, EM
, XX
},
1042 { "pminub", MX
, EM
, XX
},
1043 { "pand", MX
, EM
, XX
},
1044 { "paddusb", MX
, EM
, XX
},
1045 { "paddusw", MX
, EM
, XX
},
1046 { "pmaxub", MX
, EM
, XX
},
1047 { "pandn", MX
, EM
, XX
},
1049 { "pavgb", MX
, EM
, XX
},
1050 { "psraw", MX
, EM
, XX
},
1051 { "psrad", MX
, EM
, XX
},
1052 { "pavgw", MX
, EM
, XX
},
1053 { "pmulhuw", MX
, EM
, XX
},
1054 { "pmulhw", MX
, EM
, XX
},
1058 { "psubsb", MX
, EM
, XX
},
1059 { "psubsw", MX
, EM
, XX
},
1060 { "pminsw", MX
, EM
, XX
},
1061 { "por", MX
, EM
, XX
},
1062 { "paddsb", MX
, EM
, XX
},
1063 { "paddsw", MX
, EM
, XX
},
1064 { "pmaxsw", MX
, EM
, XX
},
1065 { "pxor", MX
, EM
, XX
},
1068 { "psllw", MX
, EM
, XX
},
1069 { "pslld", MX
, EM
, XX
},
1070 { "psllq", MX
, EM
, XX
},
1071 { "pmuludq", MX
, EM
, XX
},
1072 { "pmaddwd", MX
, EM
, XX
},
1073 { "psadbw", MX
, EM
, XX
},
1076 { "psubb", MX
, EM
, XX
},
1077 { "psubw", MX
, EM
, XX
},
1078 { "psubd", MX
, EM
, XX
},
1079 { "psubq", MX
, EM
, XX
},
1080 { "paddb", MX
, EM
, XX
},
1081 { "paddw", MX
, EM
, XX
},
1082 { "paddd", MX
, EM
, XX
},
1083 { "(bad)", XX
, XX
, XX
}
1086 static const unsigned char onebyte_has_modrm
[256] = {
1087 /* 0 1 2 3 4 5 6 7 8 9 a b c d e f */
1088 /* ------------------------------- */
1089 /* 00 */ 1,1,1,1,0,0,0,0,1,1,1,1,0,0,0,0, /* 00 */
1090 /* 10 */ 1,1,1,1,0,0,0,0,1,1,1,1,0,0,0,0, /* 10 */
1091 /* 20 */ 1,1,1,1,0,0,0,0,1,1,1,1,0,0,0,0, /* 20 */
1092 /* 30 */ 1,1,1,1,0,0,0,0,1,1,1,1,0,0,0,0, /* 30 */
1093 /* 40 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 40 */
1094 /* 50 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 50 */
1095 /* 60 */ 0,0,1,1,0,0,0,0,0,1,0,1,0,0,0,0, /* 60 */
1096 /* 70 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 70 */
1097 /* 80 */ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, /* 80 */
1098 /* 90 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 90 */
1099 /* a0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* a0 */
1100 /* b0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* b0 */
1101 /* c0 */ 1,1,0,0,1,1,1,1,0,0,0,0,0,0,0,0, /* c0 */
1102 /* d0 */ 1,1,1,1,0,0,0,0,1,1,1,1,1,1,1,1, /* d0 */
1103 /* e0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* e0 */
1104 /* f0 */ 0,0,0,0,0,0,1,1,0,0,0,0,0,0,1,1 /* f0 */
1105 /* ------------------------------- */
1106 /* 0 1 2 3 4 5 6 7 8 9 a b c d e f */
1109 static const unsigned char twobyte_has_modrm
[256] = {
1110 /* 0 1 2 3 4 5 6 7 8 9 a b c d e f */
1111 /* ------------------------------- */
1112 /* 00 */ 1,1,1,1,0,0,0,0,0,0,0,0,0,1,0,1, /* 0f */
1113 /* 10 */ 1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0, /* 1f */
1114 /* 20 */ 1,1,1,1,1,0,1,0,1,1,1,1,1,1,1,1, /* 2f */
1115 /* 30 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 3f */
1116 /* 40 */ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, /* 4f */
1117 /* 50 */ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, /* 5f */
1118 /* 60 */ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, /* 6f */
1119 /* 70 */ 1,1,1,1,1,1,1,0,1,1,0,0,1,1,1,1, /* 7f */
1120 /* 80 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 8f */
1121 /* 90 */ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, /* 9f */
1122 /* a0 */ 0,0,0,1,1,1,1,1,0,0,0,1,1,1,1,1, /* af */
1123 /* b0 */ 1,1,1,1,1,1,1,1,0,0,1,1,1,1,1,1, /* bf */
1124 /* c0 */ 1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0, /* cf */
1125 /* d0 */ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, /* df */
1126 /* e0 */ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, /* ef */
1127 /* f0 */ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0 /* ff */
1128 /* ------------------------------- */
1129 /* 0 1 2 3 4 5 6 7 8 9 a b c d e f */
1132 static const unsigned char twobyte_uses_SSE_prefix
[256] = {
1133 /* 0 1 2 3 4 5 6 7 8 9 a b c d e f */
1134 /* ------------------------------- */
1135 /* 00 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0f */
1136 /* 10 */ 1,1,1,0,0,0,1,0,0,0,0,0,0,0,0,0, /* 1f */
1137 /* 20 */ 0,0,0,0,0,0,0,0,0,0,1,0,1,1,0,0, /* 2f */
1138 /* 30 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 3f */
1139 /* 40 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 4f */
1140 /* 50 */ 0,1,1,1,0,0,0,0,1,1,1,1,1,1,1,1, /* 5f */
1141 /* 60 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1, /* 6f */
1142 /* 70 */ 1,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1, /* 7f */
1143 /* 80 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 8f */
1144 /* 90 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 9f */
1145 /* a0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* af */
1146 /* b0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* bf */
1147 /* c0 */ 0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0, /* cf */
1148 /* d0 */ 1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0, /* df */
1149 /* e0 */ 0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0, /* ef */
1150 /* f0 */ 1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0 /* ff */
1151 /* ------------------------------- */
1152 /* 0 1 2 3 4 5 6 7 8 9 a b c d e f */
1155 static char obuf
[100];
1157 static char scratchbuf
[100];
1158 static unsigned char *start_codep
;
1159 static unsigned char *insn_codep
;
1160 static unsigned char *codep
;
1161 static disassemble_info
*the_info
;
1165 static unsigned char need_modrm
;
1167 /* If we are accessing mod/rm/reg without need_modrm set, then the
1168 values are stale. Hitting this abort likely indicates that you
1169 need to update onebyte_has_modrm or twobyte_has_modrm. */
1170 #define MODRM_CHECK if (!need_modrm) abort ()
1172 static const char **names64
;
1173 static const char **names32
;
1174 static const char **names16
;
1175 static const char **names8
;
1176 static const char **names8rex
;
1177 static const char **names_seg
;
1178 static const char **index16
;
1180 static const char *intel_names64
[] = {
1181 "rax", "rcx", "rdx", "rbx", "rsp", "rbp", "rsi", "rdi",
1182 "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15"
1184 static const char *intel_names32
[] = {
1185 "eax", "ecx", "edx", "ebx", "esp", "ebp", "esi", "edi",
1186 "r8d", "r9d", "r10d", "r11d", "r12d", "r13d", "r14d", "r15d"
1188 static const char *intel_names16
[] = {
1189 "ax", "cx", "dx", "bx", "sp", "bp", "si", "di",
1190 "r8w", "r9w", "r10w", "r11w", "r12w", "r13w", "r14w", "r15w"
1192 static const char *intel_names8
[] = {
1193 "al", "cl", "dl", "bl", "ah", "ch", "dh", "bh",
1195 static const char *intel_names8rex
[] = {
1196 "al", "cl", "dl", "bl", "spl", "bpl", "sil", "dil",
1197 "r8b", "r9b", "r10b", "r11b", "r12b", "r13b", "r14b", "r15b"
1199 static const char *intel_names_seg
[] = {
1200 "es", "cs", "ss", "ds", "fs", "gs", "?", "?",
1202 static const char *intel_index16
[] = {
1203 "bx+si", "bx+di", "bp+si", "bp+di", "si", "di", "bp", "bx"
1206 static const char *att_names64
[] = {
1207 "%rax", "%rcx", "%rdx", "%rbx", "%rsp", "%rbp", "%rsi", "%rdi",
1208 "%r8", "%r9", "%r10", "%r11", "%r12", "%r13", "%r14", "%r15"
1210 static const char *att_names32
[] = {
1211 "%eax", "%ecx", "%edx", "%ebx", "%esp", "%ebp", "%esi", "%edi",
1212 "%r8d", "%r9d", "%r10d", "%r11d", "%r12d", "%r13d", "%r14d", "%r15d"
1214 static const char *att_names16
[] = {
1215 "%ax", "%cx", "%dx", "%bx", "%sp", "%bp", "%si", "%di",
1216 "%r8w", "%r9w", "%r10w", "%r11w", "%r12w", "%r13w", "%r14w", "%r15w"
1218 static const char *att_names8
[] = {
1219 "%al", "%cl", "%dl", "%bl", "%ah", "%ch", "%dh", "%bh",
1221 static const char *att_names8rex
[] = {
1222 "%al", "%cl", "%dl", "%bl", "%spl", "%bpl", "%sil", "%dil",
1223 "%r8b", "%r9b", "%r10b", "%r11b", "%r12b", "%r13b", "%r14b", "%r15b"
1225 static const char *att_names_seg
[] = {
1226 "%es", "%cs", "%ss", "%ds", "%fs", "%gs", "%?", "%?",
1228 static const char *att_index16
[] = {
1229 "%bx,%si", "%bx,%di", "%bp,%si", "%bp,%di", "%si", "%di", "%bp", "%bx"
1232 static const struct dis386 grps
[][8] = {
1235 { "addA", Eb
, Ib
, XX
},
1236 { "orA", Eb
, Ib
, XX
},
1237 { "adcA", Eb
, Ib
, XX
},
1238 { "sbbA", Eb
, Ib
, XX
},
1239 { "andA", Eb
, Ib
, XX
},
1240 { "subA", Eb
, Ib
, XX
},
1241 { "xorA", Eb
, Ib
, XX
},
1242 { "cmpA", Eb
, Ib
, XX
}
1246 { "addQ", Ev
, Iv
, XX
},
1247 { "orQ", Ev
, Iv
, XX
},
1248 { "adcQ", Ev
, Iv
, XX
},
1249 { "sbbQ", Ev
, Iv
, XX
},
1250 { "andQ", Ev
, Iv
, XX
},
1251 { "subQ", Ev
, Iv
, XX
},
1252 { "xorQ", Ev
, Iv
, XX
},
1253 { "cmpQ", Ev
, Iv
, XX
}
1257 { "addQ", Ev
, sIb
, XX
},
1258 { "orQ", Ev
, sIb
, XX
},
1259 { "adcQ", Ev
, sIb
, XX
},
1260 { "sbbQ", Ev
, sIb
, XX
},
1261 { "andQ", Ev
, sIb
, XX
},
1262 { "subQ", Ev
, sIb
, XX
},
1263 { "xorQ", Ev
, sIb
, XX
},
1264 { "cmpQ", Ev
, sIb
, XX
}
1268 { "rolA", Eb
, Ib
, XX
},
1269 { "rorA", Eb
, Ib
, XX
},
1270 { "rclA", Eb
, Ib
, XX
},
1271 { "rcrA", Eb
, Ib
, XX
},
1272 { "shlA", Eb
, Ib
, XX
},
1273 { "shrA", Eb
, Ib
, XX
},
1274 { "(bad)", XX
, XX
, XX
},
1275 { "sarA", Eb
, Ib
, XX
},
1279 { "rolQ", Ev
, Ib
, XX
},
1280 { "rorQ", Ev
, Ib
, XX
},
1281 { "rclQ", Ev
, Ib
, XX
},
1282 { "rcrQ", Ev
, Ib
, XX
},
1283 { "shlQ", Ev
, Ib
, XX
},
1284 { "shrQ", Ev
, Ib
, XX
},
1285 { "(bad)", XX
, XX
, XX
},
1286 { "sarQ", Ev
, Ib
, XX
},
1290 { "rolA", Eb
, I1
, XX
},
1291 { "rorA", Eb
, I1
, XX
},
1292 { "rclA", Eb
, I1
, XX
},
1293 { "rcrA", Eb
, I1
, XX
},
1294 { "shlA", Eb
, I1
, XX
},
1295 { "shrA", Eb
, I1
, XX
},
1296 { "(bad)", XX
, XX
, XX
},
1297 { "sarA", Eb
, I1
, XX
},
1301 { "rolQ", Ev
, I1
, XX
},
1302 { "rorQ", Ev
, I1
, XX
},
1303 { "rclQ", Ev
, I1
, XX
},
1304 { "rcrQ", Ev
, I1
, XX
},
1305 { "shlQ", Ev
, I1
, XX
},
1306 { "shrQ", Ev
, I1
, XX
},
1307 { "(bad)", XX
, XX
, XX
},
1308 { "sarQ", Ev
, I1
, XX
},
1312 { "rolA", Eb
, CL
, XX
},
1313 { "rorA", Eb
, CL
, XX
},
1314 { "rclA", Eb
, CL
, XX
},
1315 { "rcrA", Eb
, CL
, XX
},
1316 { "shlA", Eb
, CL
, XX
},
1317 { "shrA", Eb
, CL
, XX
},
1318 { "(bad)", XX
, XX
, XX
},
1319 { "sarA", Eb
, CL
, XX
},
1323 { "rolQ", Ev
, CL
, XX
},
1324 { "rorQ", Ev
, CL
, XX
},
1325 { "rclQ", Ev
, CL
, XX
},
1326 { "rcrQ", Ev
, CL
, XX
},
1327 { "shlQ", Ev
, CL
, XX
},
1328 { "shrQ", Ev
, CL
, XX
},
1329 { "(bad)", XX
, XX
, XX
},
1330 { "sarQ", Ev
, CL
, XX
}
1334 { "testA", Eb
, Ib
, XX
},
1335 { "(bad)", Eb
, XX
, XX
},
1336 { "notA", Eb
, XX
, XX
},
1337 { "negA", Eb
, XX
, XX
},
1338 { "mulA", Eb
, XX
, XX
}, /* Don't print the implicit %al register, */
1339 { "imulA", Eb
, XX
, XX
}, /* to distinguish these opcodes from other */
1340 { "divA", Eb
, XX
, XX
}, /* mul/imul opcodes. Do the same for div */
1341 { "idivA", Eb
, XX
, XX
} /* and idiv for consistency. */
1345 { "testQ", Ev
, Iv
, XX
},
1346 { "(bad)", XX
, XX
, XX
},
1347 { "notQ", Ev
, XX
, XX
},
1348 { "negQ", Ev
, XX
, XX
},
1349 { "mulQ", Ev
, XX
, XX
}, /* Don't print the implicit register. */
1350 { "imulQ", Ev
, XX
, XX
},
1351 { "divQ", Ev
, XX
, XX
},
1352 { "idivQ", Ev
, XX
, XX
},
1356 { "incA", Eb
, XX
, XX
},
1357 { "decA", Eb
, XX
, XX
},
1358 { "(bad)", XX
, XX
, XX
},
1359 { "(bad)", XX
, XX
, XX
},
1360 { "(bad)", XX
, XX
, XX
},
1361 { "(bad)", XX
, XX
, XX
},
1362 { "(bad)", XX
, XX
, XX
},
1363 { "(bad)", XX
, XX
, XX
},
1367 { "incQ", Ev
, XX
, XX
},
1368 { "decQ", Ev
, XX
, XX
},
1369 { "callT", indirEv
, XX
, XX
},
1370 { "JcallT", indirEp
, XX
, XX
},
1371 { "jmpT", indirEv
, XX
, XX
},
1372 { "JjmpT", indirEp
, XX
, XX
},
1373 { "pushU", stackEv
, XX
, XX
},
1374 { "(bad)", XX
, XX
, XX
},
1378 { "sldtQ", Ev
, XX
, XX
},
1379 { "strQ", Ev
, XX
, XX
},
1380 { "lldt", Ew
, XX
, XX
},
1381 { "ltr", Ew
, XX
, XX
},
1382 { "verr", Ew
, XX
, XX
},
1383 { "verw", Ew
, XX
, XX
},
1384 { "(bad)", XX
, XX
, XX
},
1385 { "(bad)", XX
, XX
, XX
}
1389 { "sgdtIQ", VMX_Fixup
, 0, XX
, XX
},
1390 { "sidtIQ", PNI_Fixup
, 0, XX
, XX
},
1391 { "lgdt{Q|Q||}", M
, XX
, XX
},
1392 { "lidt{Q|Q||}", SVME_Fixup
, 0, XX
, XX
},
1393 { "smswQ", Ev
, XX
, XX
},
1394 { "(bad)", XX
, XX
, XX
},
1395 { "lmsw", Ew
, XX
, XX
},
1396 { "invlpg", INVLPG_Fixup
, w_mode
, XX
, XX
},
1400 { "(bad)", XX
, XX
, XX
},
1401 { "(bad)", XX
, XX
, XX
},
1402 { "(bad)", XX
, XX
, XX
},
1403 { "(bad)", XX
, XX
, XX
},
1404 { "btQ", Ev
, Ib
, XX
},
1405 { "btsQ", Ev
, Ib
, XX
},
1406 { "btrQ", Ev
, Ib
, XX
},
1407 { "btcQ", Ev
, Ib
, XX
},
1411 { "(bad)", XX
, XX
, XX
},
1412 { "cmpxchg8b", Eq
, XX
, XX
},
1413 { "(bad)", XX
, XX
, XX
},
1414 { "(bad)", XX
, XX
, XX
},
1415 { "(bad)", XX
, XX
, XX
},
1416 { "(bad)", XX
, XX
, XX
},
1417 { "", VM
, XX
, XX
}, /* See OP_VMX. */
1418 { "vmptrst", Eq
, XX
, XX
},
1422 { "(bad)", XX
, XX
, XX
},
1423 { "(bad)", XX
, XX
, XX
},
1424 { "psrlw", MS
, Ib
, XX
},
1425 { "(bad)", XX
, XX
, XX
},
1426 { "psraw", MS
, Ib
, XX
},
1427 { "(bad)", XX
, XX
, XX
},
1428 { "psllw", MS
, Ib
, XX
},
1429 { "(bad)", XX
, XX
, XX
},
1433 { "(bad)", XX
, XX
, XX
},
1434 { "(bad)", XX
, XX
, XX
},
1435 { "psrld", MS
, Ib
, XX
},
1436 { "(bad)", XX
, XX
, XX
},
1437 { "psrad", MS
, Ib
, XX
},
1438 { "(bad)", XX
, XX
, XX
},
1439 { "pslld", MS
, Ib
, XX
},
1440 { "(bad)", XX
, XX
, XX
},
1444 { "(bad)", XX
, XX
, XX
},
1445 { "(bad)", XX
, XX
, XX
},
1446 { "psrlq", MS
, Ib
, XX
},
1447 { "psrldq", MS
, Ib
, XX
},
1448 { "(bad)", XX
, XX
, XX
},
1449 { "(bad)", XX
, XX
, XX
},
1450 { "psllq", MS
, Ib
, XX
},
1451 { "pslldq", MS
, Ib
, XX
},
1455 { "fxsave", Ev
, XX
, XX
},
1456 { "fxrstor", Ev
, XX
, XX
},
1457 { "ldmxcsr", Ev
, XX
, XX
},
1458 { "stmxcsr", Ev
, XX
, XX
},
1459 { "(bad)", XX
, XX
, XX
},
1460 { "lfence", OP_0fae
, 0, XX
, XX
},
1461 { "mfence", OP_0fae
, 0, XX
, XX
},
1462 { "clflush", OP_0fae
, 0, XX
, XX
},
1466 { "prefetchnta", Ev
, XX
, XX
},
1467 { "prefetcht0", Ev
, XX
, XX
},
1468 { "prefetcht1", Ev
, XX
, XX
},
1469 { "prefetcht2", Ev
, XX
, XX
},
1470 { "(bad)", XX
, XX
, XX
},
1471 { "(bad)", XX
, XX
, XX
},
1472 { "(bad)", XX
, XX
, XX
},
1473 { "(bad)", XX
, XX
, XX
},
1477 { "prefetch", Eb
, XX
, XX
},
1478 { "prefetchw", Eb
, XX
, XX
},
1479 { "(bad)", XX
, XX
, XX
},
1480 { "(bad)", XX
, XX
, XX
},
1481 { "(bad)", XX
, XX
, XX
},
1482 { "(bad)", XX
, XX
, XX
},
1483 { "(bad)", XX
, XX
, XX
},
1484 { "(bad)", XX
, XX
, XX
},
1488 { "xstore-rng", OP_0f07
, 0, XX
, XX
},
1489 { "xcrypt-ecb", OP_0f07
, 0, XX
, XX
},
1490 { "xcrypt-cbc", OP_0f07
, 0, XX
, XX
},
1491 { "xcrypt-ctr", OP_0f07
, 0, XX
, XX
},
1492 { "xcrypt-cfb", OP_0f07
, 0, XX
, XX
},
1493 { "xcrypt-ofb", OP_0f07
, 0, XX
, XX
},
1494 { "(bad)", OP_0f07
, 0, XX
, XX
},
1495 { "(bad)", OP_0f07
, 0, XX
, XX
},
1499 { "montmul", OP_0f07
, 0, XX
, XX
},
1500 { "xsha1", OP_0f07
, 0, XX
, XX
},
1501 { "xsha256", OP_0f07
, 0, XX
, XX
},
1502 { "(bad)", OP_0f07
, 0, XX
, XX
},
1503 { "(bad)", OP_0f07
, 0, XX
, XX
},
1504 { "(bad)", OP_0f07
, 0, XX
, XX
},
1505 { "(bad)", OP_0f07
, 0, XX
, XX
},
1506 { "(bad)", OP_0f07
, 0, XX
, XX
},
1510 static const struct dis386 prefix_user_table
[][4] = {
1513 { "addps", XM
, EX
, XX
},
1514 { "addss", XM
, EX
, XX
},
1515 { "addpd", XM
, EX
, XX
},
1516 { "addsd", XM
, EX
, XX
},
1520 { "", XM
, EX
, OPSIMD
}, /* See OP_SIMD_SUFFIX. */
1521 { "", XM
, EX
, OPSIMD
},
1522 { "", XM
, EX
, OPSIMD
},
1523 { "", XM
, EX
, OPSIMD
},
1527 { "cvtpi2ps", XM
, EM
, XX
},
1528 { "cvtsi2ssY", XM
, Ev
, XX
},
1529 { "cvtpi2pd", XM
, EM
, XX
},
1530 { "cvtsi2sdY", XM
, Ev
, XX
},
1534 { "cvtps2pi", MX
, EX
, XX
},
1535 { "cvtss2siY", Gv
, EX
, XX
},
1536 { "cvtpd2pi", MX
, EX
, XX
},
1537 { "cvtsd2siY", Gv
, EX
, XX
},
1541 { "cvttps2pi", MX
, EX
, XX
},
1542 { "cvttss2siY", Gv
, EX
, XX
},
1543 { "cvttpd2pi", MX
, EX
, XX
},
1544 { "cvttsd2siY", Gv
, EX
, XX
},
1548 { "divps", XM
, EX
, XX
},
1549 { "divss", XM
, EX
, XX
},
1550 { "divpd", XM
, EX
, XX
},
1551 { "divsd", XM
, EX
, XX
},
1555 { "maxps", XM
, EX
, XX
},
1556 { "maxss", XM
, EX
, XX
},
1557 { "maxpd", XM
, EX
, XX
},
1558 { "maxsd", XM
, EX
, XX
},
1562 { "minps", XM
, EX
, XX
},
1563 { "minss", XM
, EX
, XX
},
1564 { "minpd", XM
, EX
, XX
},
1565 { "minsd", XM
, EX
, XX
},
1569 { "movups", XM
, EX
, XX
},
1570 { "movss", XM
, EX
, XX
},
1571 { "movupd", XM
, EX
, XX
},
1572 { "movsd", XM
, EX
, XX
},
1576 { "movups", EX
, XM
, XX
},
1577 { "movss", EX
, XM
, XX
},
1578 { "movupd", EX
, XM
, XX
},
1579 { "movsd", EX
, XM
, XX
},
1583 { "mulps", XM
, EX
, XX
},
1584 { "mulss", XM
, EX
, XX
},
1585 { "mulpd", XM
, EX
, XX
},
1586 { "mulsd", XM
, EX
, XX
},
1590 { "rcpps", XM
, EX
, XX
},
1591 { "rcpss", XM
, EX
, XX
},
1592 { "(bad)", XM
, EX
, XX
},
1593 { "(bad)", XM
, EX
, XX
},
1597 { "rsqrtps", XM
, EX
, XX
},
1598 { "rsqrtss", XM
, EX
, XX
},
1599 { "(bad)", XM
, EX
, XX
},
1600 { "(bad)", XM
, EX
, XX
},
1604 { "sqrtps", XM
, EX
, XX
},
1605 { "sqrtss", XM
, EX
, XX
},
1606 { "sqrtpd", XM
, EX
, XX
},
1607 { "sqrtsd", XM
, EX
, XX
},
1611 { "subps", XM
, EX
, XX
},
1612 { "subss", XM
, EX
, XX
},
1613 { "subpd", XM
, EX
, XX
},
1614 { "subsd", XM
, EX
, XX
},
1618 { "(bad)", XM
, EX
, XX
},
1619 { "cvtdq2pd", XM
, EX
, XX
},
1620 { "cvttpd2dq", XM
, EX
, XX
},
1621 { "cvtpd2dq", XM
, EX
, XX
},
1625 { "cvtdq2ps", XM
, EX
, XX
},
1626 { "cvttps2dq",XM
, EX
, XX
},
1627 { "cvtps2dq",XM
, EX
, XX
},
1628 { "(bad)", XM
, EX
, XX
},
1632 { "cvtps2pd", XM
, EX
, XX
},
1633 { "cvtss2sd", XM
, EX
, XX
},
1634 { "cvtpd2ps", XM
, EX
, XX
},
1635 { "cvtsd2ss", XM
, EX
, XX
},
1639 { "maskmovq", MX
, MS
, XX
},
1640 { "(bad)", XM
, EX
, XX
},
1641 { "maskmovdqu", XM
, EX
, XX
},
1642 { "(bad)", XM
, EX
, XX
},
1646 { "movq", MX
, EM
, XX
},
1647 { "movdqu", XM
, EX
, XX
},
1648 { "movdqa", XM
, EX
, XX
},
1649 { "(bad)", XM
, EX
, XX
},
1653 { "movq", EM
, MX
, XX
},
1654 { "movdqu", EX
, XM
, XX
},
1655 { "movdqa", EX
, XM
, XX
},
1656 { "(bad)", EX
, XM
, XX
},
1660 { "(bad)", EX
, XM
, XX
},
1661 { "movq2dq", XM
, MS
, XX
},
1662 { "movq", EX
, XM
, XX
},
1663 { "movdq2q", MX
, XS
, XX
},
1667 { "pshufw", MX
, EM
, Ib
},
1668 { "pshufhw", XM
, EX
, Ib
},
1669 { "pshufd", XM
, EX
, Ib
},
1670 { "pshuflw", XM
, EX
, Ib
},
1674 { "movd", Edq
, MX
, XX
},
1675 { "movq", XM
, EX
, XX
},
1676 { "movd", Edq
, XM
, XX
},
1677 { "(bad)", Ed
, XM
, XX
},
1681 { "(bad)", MX
, EX
, XX
},
1682 { "(bad)", XM
, EX
, XX
},
1683 { "punpckhqdq", XM
, EX
, XX
},
1684 { "(bad)", XM
, EX
, XX
},
1688 { "movntq", EM
, MX
, XX
},
1689 { "(bad)", EM
, XM
, XX
},
1690 { "movntdq", EM
, XM
, XX
},
1691 { "(bad)", EM
, XM
, XX
},
1695 { "(bad)", MX
, EX
, XX
},
1696 { "(bad)", XM
, EX
, XX
},
1697 { "punpcklqdq", XM
, EX
, XX
},
1698 { "(bad)", XM
, EX
, XX
},
1702 { "(bad)", MX
, EX
, XX
},
1703 { "(bad)", XM
, EX
, XX
},
1704 { "addsubpd", XM
, EX
, XX
},
1705 { "addsubps", XM
, EX
, XX
},
1709 { "(bad)", MX
, EX
, XX
},
1710 { "(bad)", XM
, EX
, XX
},
1711 { "haddpd", XM
, EX
, XX
},
1712 { "haddps", XM
, EX
, XX
},
1716 { "(bad)", MX
, EX
, XX
},
1717 { "(bad)", XM
, EX
, XX
},
1718 { "hsubpd", XM
, EX
, XX
},
1719 { "hsubps", XM
, EX
, XX
},
1723 { "movlpX", XM
, EX
, SIMD_Fixup
, 'h' }, /* really only 2 operands */
1724 { "movsldup", XM
, EX
, XX
},
1725 { "movlpd", XM
, EX
, XX
},
1726 { "movddup", XM
, EX
, XX
},
1730 { "movhpX", XM
, EX
, SIMD_Fixup
, 'l' },
1731 { "movshdup", XM
, EX
, XX
},
1732 { "movhpd", XM
, EX
, XX
},
1733 { "(bad)", XM
, EX
, XX
},
1737 { "(bad)", XM
, EX
, XX
},
1738 { "(bad)", XM
, EX
, XX
},
1739 { "(bad)", XM
, EX
, XX
},
1740 { "lddqu", XM
, M
, XX
},
1744 static const struct dis386 x86_64_table
[][2] = {
1746 { "arpl", Ew
, Gw
, XX
},
1747 { "movs{||lq|xd}", Gv
, Ed
, XX
},
1751 #define INTERNAL_DISASSEMBLER_ERROR _("<internal disassembler error>")
1763 FETCH_DATA (the_info
, codep
+ 1);
1767 /* REX prefixes family. */
1784 if (address_mode
== mode_64bit
)
1790 prefixes
|= PREFIX_REPZ
;
1793 prefixes
|= PREFIX_REPNZ
;
1796 prefixes
|= PREFIX_LOCK
;
1799 prefixes
|= PREFIX_CS
;
1802 prefixes
|= PREFIX_SS
;
1805 prefixes
|= PREFIX_DS
;
1808 prefixes
|= PREFIX_ES
;
1811 prefixes
|= PREFIX_FS
;
1814 prefixes
|= PREFIX_GS
;
1817 prefixes
|= PREFIX_DATA
;
1820 prefixes
|= PREFIX_ADDR
;
1823 /* fwait is really an instruction. If there are prefixes
1824 before the fwait, they belong to the fwait, *not* to the
1825 following instruction. */
1826 if (prefixes
|| rex
)
1828 prefixes
|= PREFIX_FWAIT
;
1832 prefixes
= PREFIX_FWAIT
;
1837 /* Rex is ignored when followed by another prefix. */
1848 /* Return the name of the prefix byte PREF, or NULL if PREF is not a
1852 prefix_name (int pref
, int sizeflag
)
1856 /* REX prefixes family. */
1908 return (sizeflag
& DFLAG
) ? "data16" : "data32";
1910 if (address_mode
== mode_64bit
)
1911 return (sizeflag
& AFLAG
) ? "addr32" : "addr64";
1913 return (sizeflag
& AFLAG
) ? "addr16" : "addr32";
1921 static char op1out
[100], op2out
[100], op3out
[100];
1922 static int op_ad
, op_index
[3];
1923 static int two_source_ops
;
1924 static bfd_vma op_address
[3];
1925 static bfd_vma op_riprel
[3];
1926 static bfd_vma start_pc
;
1929 * On the 386's of 1988, the maximum length of an instruction is 15 bytes.
1930 * (see topic "Redundant prefixes" in the "Differences from 8086"
1931 * section of the "Virtual 8086 Mode" chapter.)
1932 * 'pc' should be the address of this instruction, it will
1933 * be used to print the target address if this is a relative jump or call
1934 * The function returns the length of this instruction in bytes.
1937 static char intel_syntax
;
1938 static char open_char
;
1939 static char close_char
;
1940 static char separator_char
;
1941 static char scale_char
;
1943 /* Here for backwards compatibility. When gdb stops using
1944 print_insn_i386_att and print_insn_i386_intel these functions can
1945 disappear, and print_insn_i386 be merged into print_insn. */
1947 print_insn_i386_att (bfd_vma pc
, disassemble_info
*info
)
1951 return print_insn (pc
, info
);
1955 print_insn_i386_intel (bfd_vma pc
, disassemble_info
*info
)
1959 return print_insn (pc
, info
);
1963 print_insn_i386 (bfd_vma pc
, disassemble_info
*info
)
1967 return print_insn (pc
, info
);
1971 print_insn (bfd_vma pc
, disassemble_info
*info
)
1973 const struct dis386
*dp
;
1975 char *first
, *second
, *third
;
1977 unsigned char uses_SSE_prefix
, uses_LOCK_prefix
;
1980 struct dis_private priv
;
1982 if (info
->mach
== bfd_mach_x86_64_intel_syntax
1983 || info
->mach
== bfd_mach_x86_64
)
1984 address_mode
= mode_64bit
;
1986 address_mode
= mode_32bit
;
1988 if (intel_syntax
== (char) -1)
1989 intel_syntax
= (info
->mach
== bfd_mach_i386_i386_intel_syntax
1990 || info
->mach
== bfd_mach_x86_64_intel_syntax
);
1992 if (info
->mach
== bfd_mach_i386_i386
1993 || info
->mach
== bfd_mach_x86_64
1994 || info
->mach
== bfd_mach_i386_i386_intel_syntax
1995 || info
->mach
== bfd_mach_x86_64_intel_syntax
)
1996 priv
.orig_sizeflag
= AFLAG
| DFLAG
;
1997 else if (info
->mach
== bfd_mach_i386_i8086
)
1998 priv
.orig_sizeflag
= 0;
2002 for (p
= info
->disassembler_options
; p
!= NULL
; )
2004 if (strncmp (p
, "x86-64", 6) == 0)
2006 address_mode
= mode_64bit
;
2007 priv
.orig_sizeflag
= AFLAG
| DFLAG
;
2009 else if (strncmp (p
, "i386", 4) == 0)
2011 address_mode
= mode_32bit
;
2012 priv
.orig_sizeflag
= AFLAG
| DFLAG
;
2014 else if (strncmp (p
, "i8086", 5) == 0)
2016 address_mode
= mode_16bit
;
2017 priv
.orig_sizeflag
= 0;
2019 else if (strncmp (p
, "intel", 5) == 0)
2023 else if (strncmp (p
, "att", 3) == 0)
2027 else if (strncmp (p
, "addr", 4) == 0)
2029 if (p
[4] == '1' && p
[5] == '6')
2030 priv
.orig_sizeflag
&= ~AFLAG
;
2031 else if (p
[4] == '3' && p
[5] == '2')
2032 priv
.orig_sizeflag
|= AFLAG
;
2034 else if (strncmp (p
, "data", 4) == 0)
2036 if (p
[4] == '1' && p
[5] == '6')
2037 priv
.orig_sizeflag
&= ~DFLAG
;
2038 else if (p
[4] == '3' && p
[5] == '2')
2039 priv
.orig_sizeflag
|= DFLAG
;
2041 else if (strncmp (p
, "suffix", 6) == 0)
2042 priv
.orig_sizeflag
|= SUFFIX_ALWAYS
;
2044 p
= strchr (p
, ',');
2051 names64
= intel_names64
;
2052 names32
= intel_names32
;
2053 names16
= intel_names16
;
2054 names8
= intel_names8
;
2055 names8rex
= intel_names8rex
;
2056 names_seg
= intel_names_seg
;
2057 index16
= intel_index16
;
2060 separator_char
= '+';
2065 names64
= att_names64
;
2066 names32
= att_names32
;
2067 names16
= att_names16
;
2068 names8
= att_names8
;
2069 names8rex
= att_names8rex
;
2070 names_seg
= att_names_seg
;
2071 index16
= att_index16
;
2074 separator_char
= ',';
2078 /* The output looks better if we put 7 bytes on a line, since that
2079 puts most long word instructions on a single line. */
2080 info
->bytes_per_line
= 7;
2082 info
->private_data
= &priv
;
2083 priv
.max_fetched
= priv
.the_buffer
;
2084 priv
.insn_start
= pc
;
2091 op_index
[0] = op_index
[1] = op_index
[2] = -1;
2095 start_codep
= priv
.the_buffer
;
2096 codep
= priv
.the_buffer
;
2098 if (setjmp (priv
.bailout
) != 0)
2102 /* Getting here means we tried for data but didn't get it. That
2103 means we have an incomplete instruction of some sort. Just
2104 print the first byte as a prefix or a .byte pseudo-op. */
2105 if (codep
> priv
.the_buffer
)
2107 name
= prefix_name (priv
.the_buffer
[0], priv
.orig_sizeflag
);
2109 (*info
->fprintf_func
) (info
->stream
, "%s", name
);
2112 /* Just print the first byte as a .byte instruction. */
2113 (*info
->fprintf_func
) (info
->stream
, ".byte 0x%x",
2114 (unsigned int) priv
.the_buffer
[0]);
2127 sizeflag
= priv
.orig_sizeflag
;
2129 FETCH_DATA (info
, codep
+ 1);
2130 two_source_ops
= (*codep
== 0x62) || (*codep
== 0xc8);
2132 if (((prefixes
& PREFIX_FWAIT
)
2133 && ((*codep
< 0xd8) || (*codep
> 0xdf)))
2134 || (rex
&& rex_used
))
2138 /* fwait not followed by floating point instruction, or rex followed
2139 by other prefixes. Print the first prefix. */
2140 name
= prefix_name (priv
.the_buffer
[0], priv
.orig_sizeflag
);
2142 name
= INTERNAL_DISASSEMBLER_ERROR
;
2143 (*info
->fprintf_func
) (info
->stream
, "%s", name
);
2149 FETCH_DATA (info
, codep
+ 2);
2150 dp
= &dis386_twobyte
[*++codep
];
2151 need_modrm
= twobyte_has_modrm
[*codep
];
2152 uses_SSE_prefix
= twobyte_uses_SSE_prefix
[*codep
];
2153 uses_LOCK_prefix
= (*codep
& ~0x02) == 0x20;
2157 dp
= &dis386
[*codep
];
2158 need_modrm
= onebyte_has_modrm
[*codep
];
2159 uses_SSE_prefix
= 0;
2160 uses_LOCK_prefix
= 0;
2164 if (!uses_SSE_prefix
&& (prefixes
& PREFIX_REPZ
))
2167 used_prefixes
|= PREFIX_REPZ
;
2169 if (!uses_SSE_prefix
&& (prefixes
& PREFIX_REPNZ
))
2172 used_prefixes
|= PREFIX_REPNZ
;
2174 if (!uses_LOCK_prefix
&& (prefixes
& PREFIX_LOCK
))
2177 used_prefixes
|= PREFIX_LOCK
;
2180 if (prefixes
& PREFIX_ADDR
)
2183 if (dp
->bytemode3
!= loop_jcxz_mode
|| intel_syntax
)
2185 if ((sizeflag
& AFLAG
) || address_mode
== mode_64bit
)
2186 oappend ("addr32 ");
2188 oappend ("addr16 ");
2189 used_prefixes
|= PREFIX_ADDR
;
2193 if (!uses_SSE_prefix
&& (prefixes
& PREFIX_DATA
))
2196 if (dp
->bytemode3
== cond_jump_mode
2197 && dp
->bytemode1
== v_mode
2200 if (sizeflag
& DFLAG
)
2201 oappend ("data32 ");
2203 oappend ("data16 ");
2204 used_prefixes
|= PREFIX_DATA
;
2210 FETCH_DATA (info
, codep
+ 1);
2211 mod
= (*codep
>> 6) & 3;
2212 reg
= (*codep
>> 3) & 7;
2216 if (dp
->name
== NULL
&& dp
->bytemode1
== FLOATCODE
)
2223 if (dp
->name
== NULL
)
2225 switch (dp
->bytemode1
)
2228 dp
= &grps
[dp
->bytemode2
][reg
];
2231 case USE_PREFIX_USER_TABLE
:
2233 used_prefixes
|= (prefixes
& PREFIX_REPZ
);
2234 if (prefixes
& PREFIX_REPZ
)
2238 used_prefixes
|= (prefixes
& PREFIX_DATA
);
2239 if (prefixes
& PREFIX_DATA
)
2243 used_prefixes
|= (prefixes
& PREFIX_REPNZ
);
2244 if (prefixes
& PREFIX_REPNZ
)
2248 dp
= &prefix_user_table
[dp
->bytemode2
][index
];
2251 case X86_64_SPECIAL
:
2252 index
= address_mode
== mode_64bit
? 1 : 0;
2253 dp
= &x86_64_table
[dp
->bytemode2
][index
];
2257 oappend (INTERNAL_DISASSEMBLER_ERROR
);
2262 if (putop (dp
->name
, sizeflag
) == 0)
2267 (*dp
->op1
) (dp
->bytemode1
, sizeflag
);
2272 (*dp
->op2
) (dp
->bytemode2
, sizeflag
);
2277 (*dp
->op3
) (dp
->bytemode3
, sizeflag
);
2281 /* See if any prefixes were not used. If so, print the first one
2282 separately. If we don't do this, we'll wind up printing an
2283 instruction stream which does not precisely correspond to the
2284 bytes we are disassembling. */
2285 if ((prefixes
& ~used_prefixes
) != 0)
2289 name
= prefix_name (priv
.the_buffer
[0], priv
.orig_sizeflag
);
2291 name
= INTERNAL_DISASSEMBLER_ERROR
;
2292 (*info
->fprintf_func
) (info
->stream
, "%s", name
);
2295 if (rex
& ~rex_used
)
2298 name
= prefix_name (rex
| 0x40, priv
.orig_sizeflag
);
2300 name
= INTERNAL_DISASSEMBLER_ERROR
;
2301 (*info
->fprintf_func
) (info
->stream
, "%s ", name
);
2304 obufp
= obuf
+ strlen (obuf
);
2305 for (i
= strlen (obuf
); i
< 6; i
++)
2308 (*info
->fprintf_func
) (info
->stream
, "%s", obuf
);
2310 /* The enter and bound instructions are printed with operands in the same
2311 order as the intel book; everything else is printed in reverse order. */
2312 if (intel_syntax
|| two_source_ops
)
2317 op_ad
= op_index
[0];
2318 op_index
[0] = op_index
[2];
2319 op_index
[2] = op_ad
;
2330 if (op_index
[0] != -1 && !op_riprel
[0])
2331 (*info
->print_address_func
) ((bfd_vma
) op_address
[op_index
[0]], info
);
2333 (*info
->fprintf_func
) (info
->stream
, "%s", first
);
2339 (*info
->fprintf_func
) (info
->stream
, ",");
2340 if (op_index
[1] != -1 && !op_riprel
[1])
2341 (*info
->print_address_func
) ((bfd_vma
) op_address
[op_index
[1]], info
);
2343 (*info
->fprintf_func
) (info
->stream
, "%s", second
);
2349 (*info
->fprintf_func
) (info
->stream
, ",");
2350 if (op_index
[2] != -1 && !op_riprel
[2])
2351 (*info
->print_address_func
) ((bfd_vma
) op_address
[op_index
[2]], info
);
2353 (*info
->fprintf_func
) (info
->stream
, "%s", third
);
2355 for (i
= 0; i
< 3; i
++)
2356 if (op_index
[i
] != -1 && op_riprel
[i
])
2358 (*info
->fprintf_func
) (info
->stream
, " # ");
2359 (*info
->print_address_func
) ((bfd_vma
) (start_pc
+ codep
- start_codep
2360 + op_address
[op_index
[i
]]), info
);
2362 return codep
- priv
.the_buffer
;
2365 static const char *float_mem
[] = {
2440 static const unsigned char float_mem_mode
[] = {
2516 #define STi OP_STi, 0
2518 #define FGRPd9_2 NULL, NULL, 0, NULL, 0, NULL, 0
2519 #define FGRPd9_4 NULL, NULL, 1, NULL, 0, NULL, 0
2520 #define FGRPd9_5 NULL, NULL, 2, NULL, 0, NULL, 0
2521 #define FGRPd9_6 NULL, NULL, 3, NULL, 0, NULL, 0
2522 #define FGRPd9_7 NULL, NULL, 4, NULL, 0, NULL, 0
2523 #define FGRPda_5 NULL, NULL, 5, NULL, 0, NULL, 0
2524 #define FGRPdb_4 NULL, NULL, 6, NULL, 0, NULL, 0
2525 #define FGRPde_3 NULL, NULL, 7, NULL, 0, NULL, 0
2526 #define FGRPdf_4 NULL, NULL, 8, NULL, 0, NULL, 0
2528 static const struct dis386 float_reg
[][8] = {
2531 { "fadd", ST
, STi
, XX
},
2532 { "fmul", ST
, STi
, XX
},
2533 { "fcom", STi
, XX
, XX
},
2534 { "fcomp", STi
, XX
, XX
},
2535 { "fsub", ST
, STi
, XX
},
2536 { "fsubr", ST
, STi
, XX
},
2537 { "fdiv", ST
, STi
, XX
},
2538 { "fdivr", ST
, STi
, XX
},
2542 { "fld", STi
, XX
, XX
},
2543 { "fxch", STi
, XX
, XX
},
2545 { "(bad)", XX
, XX
, XX
},
2553 { "fcmovb", ST
, STi
, XX
},
2554 { "fcmove", ST
, STi
, XX
},
2555 { "fcmovbe",ST
, STi
, XX
},
2556 { "fcmovu", ST
, STi
, XX
},
2557 { "(bad)", XX
, XX
, XX
},
2559 { "(bad)", XX
, XX
, XX
},
2560 { "(bad)", XX
, XX
, XX
},
2564 { "fcmovnb",ST
, STi
, XX
},
2565 { "fcmovne",ST
, STi
, XX
},
2566 { "fcmovnbe",ST
, STi
, XX
},
2567 { "fcmovnu",ST
, STi
, XX
},
2569 { "fucomi", ST
, STi
, XX
},
2570 { "fcomi", ST
, STi
, XX
},
2571 { "(bad)", XX
, XX
, XX
},
2575 { "fadd", STi
, ST
, XX
},
2576 { "fmul", STi
, ST
, XX
},
2577 { "(bad)", XX
, XX
, XX
},
2578 { "(bad)", XX
, XX
, XX
},
2580 { "fsub", STi
, ST
, XX
},
2581 { "fsubr", STi
, ST
, XX
},
2582 { "fdiv", STi
, ST
, XX
},
2583 { "fdivr", STi
, ST
, XX
},
2585 { "fsubr", STi
, ST
, XX
},
2586 { "fsub", STi
, ST
, XX
},
2587 { "fdivr", STi
, ST
, XX
},
2588 { "fdiv", STi
, ST
, XX
},
2593 { "ffree", STi
, XX
, XX
},
2594 { "(bad)", XX
, XX
, XX
},
2595 { "fst", STi
, XX
, XX
},
2596 { "fstp", STi
, XX
, XX
},
2597 { "fucom", STi
, XX
, XX
},
2598 { "fucomp", STi
, XX
, XX
},
2599 { "(bad)", XX
, XX
, XX
},
2600 { "(bad)", XX
, XX
, XX
},
2604 { "faddp", STi
, ST
, XX
},
2605 { "fmulp", STi
, ST
, XX
},
2606 { "(bad)", XX
, XX
, XX
},
2609 { "fsubp", STi
, ST
, XX
},
2610 { "fsubrp", STi
, ST
, XX
},
2611 { "fdivp", STi
, ST
, XX
},
2612 { "fdivrp", STi
, ST
, XX
},
2614 { "fsubrp", STi
, ST
, XX
},
2615 { "fsubp", STi
, ST
, XX
},
2616 { "fdivrp", STi
, ST
, XX
},
2617 { "fdivp", STi
, ST
, XX
},
2622 { "ffreep", STi
, XX
, XX
},
2623 { "(bad)", XX
, XX
, XX
},
2624 { "(bad)", XX
, XX
, XX
},
2625 { "(bad)", XX
, XX
, XX
},
2627 { "fucomip",ST
, STi
, XX
},
2628 { "fcomip", ST
, STi
, XX
},
2629 { "(bad)", XX
, XX
, XX
},
2633 static char *fgrps
[][8] = {
2636 "fnop","(bad)","(bad)","(bad)","(bad)","(bad)","(bad)","(bad)",
2641 "fchs","fabs","(bad)","(bad)","ftst","fxam","(bad)","(bad)",
2646 "fld1","fldl2t","fldl2e","fldpi","fldlg2","fldln2","fldz","(bad)",
2651 "f2xm1","fyl2x","fptan","fpatan","fxtract","fprem1","fdecstp","fincstp",
2656 "fprem","fyl2xp1","fsqrt","fsincos","frndint","fscale","fsin","fcos",
2661 "(bad)","fucompp","(bad)","(bad)","(bad)","(bad)","(bad)","(bad)",
2666 "feni(287 only)","fdisi(287 only)","fNclex","fNinit",
2667 "fNsetpm(287 only)","(bad)","(bad)","(bad)",
2672 "(bad)","fcompp","(bad)","(bad)","(bad)","(bad)","(bad)","(bad)",
2677 "fNstsw","(bad)","(bad)","(bad)","(bad)","(bad)","(bad)","(bad)",
2682 dofloat (int sizeflag
)
2684 const struct dis386
*dp
;
2685 unsigned char floatop
;
2687 floatop
= codep
[-1];
2691 int fp_indx
= (floatop
- 0xd8) * 8 + reg
;
2693 putop (float_mem
[fp_indx
], sizeflag
);
2696 OP_E (float_mem_mode
[fp_indx
], sizeflag
);
2699 /* Skip mod/rm byte. */
2703 dp
= &float_reg
[floatop
- 0xd8][reg
];
2704 if (dp
->name
== NULL
)
2706 putop (fgrps
[dp
->bytemode1
][rm
], sizeflag
);
2708 /* Instruction fnstsw is only one with strange arg. */
2709 if (floatop
== 0xdf && codep
[-1] == 0xe0)
2710 strcpy (op1out
, names16
[0]);
2714 putop (dp
->name
, sizeflag
);
2719 (*dp
->op1
) (dp
->bytemode1
, sizeflag
);
2724 (*dp
->op2
) (dp
->bytemode2
, sizeflag
);
2729 OP_ST (int bytemode ATTRIBUTE_UNUSED
, int sizeflag ATTRIBUTE_UNUSED
)
2731 oappend ("%st" + intel_syntax
);
2735 OP_STi (int bytemode ATTRIBUTE_UNUSED
, int sizeflag ATTRIBUTE_UNUSED
)
2737 sprintf (scratchbuf
, "%%st(%d)", rm
);
2738 oappend (scratchbuf
+ intel_syntax
);
2741 /* Capital letters in template are macros. */
2743 putop (const char *template, int sizeflag
)
2748 for (p
= template; *p
; p
++)
2759 if (address_mode
== mode_64bit
)
2767 /* Alternative not valid. */
2768 strcpy (obuf
, "(bad)");
2772 else if (*p
== '\0')
2793 if (mod
!= 3 || (sizeflag
& SUFFIX_ALWAYS
))
2799 if (sizeflag
& SUFFIX_ALWAYS
)
2803 if (intel_syntax
&& !alt
)
2805 if ((prefixes
& PREFIX_DATA
) || (sizeflag
& SUFFIX_ALWAYS
))
2807 if (sizeflag
& DFLAG
)
2808 *obufp
++ = intel_syntax
? 'd' : 'l';
2810 *obufp
++ = intel_syntax
? 'w' : 's';
2811 used_prefixes
|= (prefixes
& PREFIX_DATA
);
2814 case 'E': /* For jcxz/jecxz */
2815 if (address_mode
== mode_64bit
)
2817 if (sizeflag
& AFLAG
)
2823 if (sizeflag
& AFLAG
)
2825 used_prefixes
|= (prefixes
& PREFIX_ADDR
);
2830 if ((prefixes
& PREFIX_ADDR
) || (sizeflag
& SUFFIX_ALWAYS
))
2832 if (sizeflag
& AFLAG
)
2833 *obufp
++ = address_mode
== mode_64bit
? 'q' : 'l';
2835 *obufp
++ = address_mode
== mode_64bit
? 'l' : 'w';
2836 used_prefixes
|= (prefixes
& PREFIX_ADDR
);
2842 if ((prefixes
& (PREFIX_CS
| PREFIX_DS
)) == PREFIX_CS
2843 || (prefixes
& (PREFIX_CS
| PREFIX_DS
)) == PREFIX_DS
)
2845 used_prefixes
|= prefixes
& (PREFIX_CS
| PREFIX_DS
);
2848 if (prefixes
& PREFIX_DS
)
2862 if (sizeflag
& SUFFIX_ALWAYS
)
2866 if ((prefixes
& PREFIX_FWAIT
) == 0)
2869 used_prefixes
|= PREFIX_FWAIT
;
2872 USED_REX (REX_MODE64
);
2873 if (rex
& REX_MODE64
)
2881 if (address_mode
== mode_64bit
&& (sizeflag
& DFLAG
))
2890 if ((prefixes
& PREFIX_DATA
)
2891 || (rex
& REX_MODE64
)
2892 || (sizeflag
& SUFFIX_ALWAYS
))
2894 USED_REX (REX_MODE64
);
2895 if (rex
& REX_MODE64
)
2899 if (sizeflag
& DFLAG
)
2904 used_prefixes
|= (prefixes
& PREFIX_DATA
);
2910 if (address_mode
== mode_64bit
&& (sizeflag
& DFLAG
))
2912 if (mod
!= 3 || (sizeflag
& SUFFIX_ALWAYS
))
2918 if (intel_syntax
&& !alt
)
2920 USED_REX (REX_MODE64
);
2921 if (mod
!= 3 || (sizeflag
& SUFFIX_ALWAYS
))
2923 if (rex
& REX_MODE64
)
2927 if (sizeflag
& DFLAG
)
2928 *obufp
++ = intel_syntax
? 'd' : 'l';
2932 used_prefixes
|= (prefixes
& PREFIX_DATA
);
2936 USED_REX (REX_MODE64
);
2939 if (rex
& REX_MODE64
)
2944 else if (sizeflag
& DFLAG
)
2957 if (rex
& REX_MODE64
)
2959 else if (sizeflag
& DFLAG
)
2964 if (!(rex
& REX_MODE64
))
2965 used_prefixes
|= (prefixes
& PREFIX_DATA
);
2970 if (address_mode
== mode_64bit
&& (sizeflag
& DFLAG
))
2972 if (sizeflag
& SUFFIX_ALWAYS
)
2980 if (sizeflag
& SUFFIX_ALWAYS
)
2982 if (rex
& REX_MODE64
)
2986 if (sizeflag
& DFLAG
)
2990 used_prefixes
|= (prefixes
& PREFIX_DATA
);
2995 if (prefixes
& PREFIX_DATA
)
2999 used_prefixes
|= (prefixes
& PREFIX_DATA
);
3004 if (rex
& REX_MODE64
)
3006 USED_REX (REX_MODE64
);
3010 /* implicit operand size 'l' for i386 or 'q' for x86-64 */
3012 /* operand size flag for cwtl, cbtw */
3016 else if (sizeflag
& DFLAG
)
3027 if (sizeflag
& DFLAG
)
3038 used_prefixes
|= (prefixes
& PREFIX_DATA
);
3048 oappend (const char *s
)
3051 obufp
+= strlen (s
);
3057 if (prefixes
& PREFIX_CS
)
3059 used_prefixes
|= PREFIX_CS
;
3060 oappend ("%cs:" + intel_syntax
);
3062 if (prefixes
& PREFIX_DS
)
3064 used_prefixes
|= PREFIX_DS
;
3065 oappend ("%ds:" + intel_syntax
);
3067 if (prefixes
& PREFIX_SS
)
3069 used_prefixes
|= PREFIX_SS
;
3070 oappend ("%ss:" + intel_syntax
);
3072 if (prefixes
& PREFIX_ES
)
3074 used_prefixes
|= PREFIX_ES
;
3075 oappend ("%es:" + intel_syntax
);
3077 if (prefixes
& PREFIX_FS
)
3079 used_prefixes
|= PREFIX_FS
;
3080 oappend ("%fs:" + intel_syntax
);
3082 if (prefixes
& PREFIX_GS
)
3084 used_prefixes
|= PREFIX_GS
;
3085 oappend ("%gs:" + intel_syntax
);
3090 OP_indirE (int bytemode
, int sizeflag
)
3094 OP_E (bytemode
, sizeflag
);
3098 print_operand_value (char *buf
, int hex
, bfd_vma disp
)
3100 if (address_mode
== mode_64bit
)
3108 sprintf_vma (tmp
, disp
);
3109 for (i
= 0; tmp
[i
] == '0' && tmp
[i
+ 1]; i
++);
3110 strcpy (buf
+ 2, tmp
+ i
);
3114 bfd_signed_vma v
= disp
;
3121 /* Check for possible overflow on 0x8000000000000000. */
3124 strcpy (buf
, "9223372036854775808");
3138 tmp
[28 - i
] = (v
% 10) + '0';
3142 strcpy (buf
, tmp
+ 29 - i
);
3148 sprintf (buf
, "0x%x", (unsigned int) disp
);
3150 sprintf (buf
, "%d", (int) disp
);
3155 intel_operand_size (int bytemode
, int sizeflag
)
3160 oappend ("BYTE PTR ");
3164 oappend ("WORD PTR ");
3167 if (address_mode
== mode_64bit
&& (sizeflag
& DFLAG
))
3169 oappend ("QWORD PTR ");
3170 used_prefixes
|= (prefixes
& PREFIX_DATA
);
3176 USED_REX (REX_MODE64
);
3177 if (rex
& REX_MODE64
)
3178 oappend ("QWORD PTR ");
3179 else if ((sizeflag
& DFLAG
) || bytemode
== dq_mode
)
3180 oappend ("DWORD PTR ");
3182 oappend ("WORD PTR ");
3183 used_prefixes
|= (prefixes
& PREFIX_DATA
);
3186 oappend ("DWORD PTR ");
3189 oappend ("QWORD PTR ");
3192 if (address_mode
== mode_64bit
)
3193 oappend ("QWORD PTR ");
3195 oappend ("DWORD PTR ");
3198 if (sizeflag
& DFLAG
)
3199 oappend ("FWORD PTR ");
3201 oappend ("DWORD PTR ");
3202 used_prefixes
|= (prefixes
& PREFIX_DATA
);
3205 oappend ("TBYTE PTR ");
3208 oappend ("XMMWORD PTR ");
3216 OP_E (int bytemode
, int sizeflag
)
3221 USED_REX (REX_EXTZ
);
3225 /* Skip mod/rm byte. */
3236 oappend (names8rex
[rm
+ add
]);
3238 oappend (names8
[rm
+ add
]);
3241 oappend (names16
[rm
+ add
]);
3244 oappend (names32
[rm
+ add
]);
3247 oappend (names64
[rm
+ add
]);
3250 if (address_mode
== mode_64bit
)
3251 oappend (names64
[rm
+ add
]);
3253 oappend (names32
[rm
+ add
]);
3256 if (address_mode
== mode_64bit
&& (sizeflag
& DFLAG
))
3258 oappend (names64
[rm
+ add
]);
3259 used_prefixes
|= (prefixes
& PREFIX_DATA
);
3267 USED_REX (REX_MODE64
);
3268 if (rex
& REX_MODE64
)
3269 oappend (names64
[rm
+ add
]);
3270 else if ((sizeflag
& DFLAG
) || bytemode
!= v_mode
)
3271 oappend (names32
[rm
+ add
]);
3273 oappend (names16
[rm
+ add
]);
3274 used_prefixes
|= (prefixes
& PREFIX_DATA
);
3279 oappend (INTERNAL_DISASSEMBLER_ERROR
);
3287 intel_operand_size (bytemode
, sizeflag
);
3290 if ((sizeflag
& AFLAG
) || address_mode
== mode_64bit
) /* 32 bit address mode */
3305 FETCH_DATA (the_info
, codep
+ 1);
3306 index
= (*codep
>> 3) & 7;
3307 if (address_mode
== mode_64bit
|| index
!= 0x4)
3308 /* When INDEX == 0x4 in 32 bit mode, SCALE is ignored. */
3309 scale
= (*codep
>> 6) & 3;
3311 USED_REX (REX_EXTY
);
3321 if ((base
& 7) == 5)
3324 if (address_mode
== mode_64bit
&& !havesib
)
3330 FETCH_DATA (the_info
, codep
+ 1);
3332 if ((disp
& 0x80) != 0)
3341 if (mod
!= 0 || (base
& 7) == 5)
3343 print_operand_value (scratchbuf
, !riprel
, disp
);
3344 oappend (scratchbuf
);
3352 if (havebase
|| (havesib
&& (index
!= 4 || scale
!= 0)))
3354 *obufp
++ = open_char
;
3355 if (intel_syntax
&& riprel
)
3359 oappend (address_mode
== mode_64bit
&& (sizeflag
& AFLAG
)
3360 ? names64
[base
] : names32
[base
]);
3365 if (!intel_syntax
|| havebase
)
3367 *obufp
++ = separator_char
;
3370 oappend (address_mode
== mode_64bit
&& (sizeflag
& AFLAG
)
3371 ? names64
[index
] : names32
[index
]);
3373 if (scale
!= 0 || (!intel_syntax
&& index
!= 4))
3375 *obufp
++ = scale_char
;
3377 sprintf (scratchbuf
, "%d", 1 << scale
);
3378 oappend (scratchbuf
);
3381 if (intel_syntax
&& disp
)
3383 if ((bfd_signed_vma
) disp
> 0)
3392 disp
= - (bfd_signed_vma
) disp
;
3395 print_operand_value (scratchbuf
, mod
!= 1, disp
);
3396 oappend (scratchbuf
);
3399 *obufp
++ = close_char
;
3402 else if (intel_syntax
)
3404 if (mod
!= 0 || (base
& 7) == 5)
3406 if (prefixes
& (PREFIX_CS
| PREFIX_SS
| PREFIX_DS
3407 | PREFIX_ES
| PREFIX_FS
| PREFIX_GS
))
3411 oappend (names_seg
[ds_reg
- es_reg
]);
3414 print_operand_value (scratchbuf
, 1, disp
);
3415 oappend (scratchbuf
);
3420 { /* 16 bit address mode */
3427 if ((disp
& 0x8000) != 0)
3432 FETCH_DATA (the_info
, codep
+ 1);
3434 if ((disp
& 0x80) != 0)
3439 if ((disp
& 0x8000) != 0)
3445 if (mod
!= 0 || rm
== 6)
3447 print_operand_value (scratchbuf
, 0, disp
);
3448 oappend (scratchbuf
);
3451 if (mod
!= 0 || rm
!= 6)
3453 *obufp
++ = open_char
;
3455 oappend (index16
[rm
]);
3456 if (intel_syntax
&& disp
)
3458 if ((bfd_signed_vma
) disp
> 0)
3467 disp
= - (bfd_signed_vma
) disp
;
3470 print_operand_value (scratchbuf
, mod
!= 1, disp
);
3471 oappend (scratchbuf
);
3474 *obufp
++ = close_char
;
3477 else if (intel_syntax
)
3479 if (prefixes
& (PREFIX_CS
| PREFIX_SS
| PREFIX_DS
3480 | PREFIX_ES
| PREFIX_FS
| PREFIX_GS
))
3484 oappend (names_seg
[ds_reg
- es_reg
]);
3487 print_operand_value (scratchbuf
, 1, disp
& 0xffff);
3488 oappend (scratchbuf
);
3494 OP_G (int bytemode
, int sizeflag
)
3497 USED_REX (REX_EXTX
);
3505 oappend (names8rex
[reg
+ add
]);
3507 oappend (names8
[reg
+ add
]);
3510 oappend (names16
[reg
+ add
]);
3513 oappend (names32
[reg
+ add
]);
3516 oappend (names64
[reg
+ add
]);
3521 USED_REX (REX_MODE64
);
3522 if (rex
& REX_MODE64
)
3523 oappend (names64
[reg
+ add
]);
3524 else if ((sizeflag
& DFLAG
) || bytemode
!= v_mode
)
3525 oappend (names32
[reg
+ add
]);
3527 oappend (names16
[reg
+ add
]);
3528 used_prefixes
|= (prefixes
& PREFIX_DATA
);
3531 if (address_mode
== mode_64bit
)
3532 oappend (names64
[reg
+ add
]);
3534 oappend (names32
[reg
+ add
]);
3537 oappend (INTERNAL_DISASSEMBLER_ERROR
);
3550 FETCH_DATA (the_info
, codep
+ 8);
3551 a
= *codep
++ & 0xff;
3552 a
|= (*codep
++ & 0xff) << 8;
3553 a
|= (*codep
++ & 0xff) << 16;
3554 a
|= (*codep
++ & 0xff) << 24;
3555 b
= *codep
++ & 0xff;
3556 b
|= (*codep
++ & 0xff) << 8;
3557 b
|= (*codep
++ & 0xff) << 16;
3558 b
|= (*codep
++ & 0xff) << 24;
3559 x
= a
+ ((bfd_vma
) b
<< 32);
3567 static bfd_signed_vma
3570 bfd_signed_vma x
= 0;
3572 FETCH_DATA (the_info
, codep
+ 4);
3573 x
= *codep
++ & (bfd_signed_vma
) 0xff;
3574 x
|= (*codep
++ & (bfd_signed_vma
) 0xff) << 8;
3575 x
|= (*codep
++ & (bfd_signed_vma
) 0xff) << 16;
3576 x
|= (*codep
++ & (bfd_signed_vma
) 0xff) << 24;
3580 static bfd_signed_vma
3583 bfd_signed_vma x
= 0;
3585 FETCH_DATA (the_info
, codep
+ 4);
3586 x
= *codep
++ & (bfd_signed_vma
) 0xff;
3587 x
|= (*codep
++ & (bfd_signed_vma
) 0xff) << 8;
3588 x
|= (*codep
++ & (bfd_signed_vma
) 0xff) << 16;
3589 x
|= (*codep
++ & (bfd_signed_vma
) 0xff) << 24;
3591 x
= (x
^ ((bfd_signed_vma
) 1 << 31)) - ((bfd_signed_vma
) 1 << 31);
3601 FETCH_DATA (the_info
, codep
+ 2);
3602 x
= *codep
++ & 0xff;
3603 x
|= (*codep
++ & 0xff) << 8;
3608 set_op (bfd_vma op
, int riprel
)
3610 op_index
[op_ad
] = op_ad
;
3611 if (address_mode
== mode_64bit
)
3613 op_address
[op_ad
] = op
;
3614 op_riprel
[op_ad
] = riprel
;
3618 /* Mask to get a 32-bit address. */
3619 op_address
[op_ad
] = op
& 0xffffffff;
3620 op_riprel
[op_ad
] = riprel
& 0xffffffff;
3625 OP_REG (int code
, int sizeflag
)
3629 USED_REX (REX_EXTZ
);
3641 case ax_reg
: case cx_reg
: case dx_reg
: case bx_reg
:
3642 case sp_reg
: case bp_reg
: case si_reg
: case di_reg
:
3643 s
= names16
[code
- ax_reg
+ add
];
3645 case es_reg
: case ss_reg
: case cs_reg
:
3646 case ds_reg
: case fs_reg
: case gs_reg
:
3647 s
= names_seg
[code
- es_reg
+ add
];
3649 case al_reg
: case ah_reg
: case cl_reg
: case ch_reg
:
3650 case dl_reg
: case dh_reg
: case bl_reg
: case bh_reg
:
3653 s
= names8rex
[code
- al_reg
+ add
];
3655 s
= names8
[code
- al_reg
];
3657 case rAX_reg
: case rCX_reg
: case rDX_reg
: case rBX_reg
:
3658 case rSP_reg
: case rBP_reg
: case rSI_reg
: case rDI_reg
:
3659 if (address_mode
== mode_64bit
&& (sizeflag
& DFLAG
))
3661 s
= names64
[code
- rAX_reg
+ add
];
3664 code
+= eAX_reg
- rAX_reg
;
3666 case eAX_reg
: case eCX_reg
: case eDX_reg
: case eBX_reg
:
3667 case eSP_reg
: case eBP_reg
: case eSI_reg
: case eDI_reg
:
3668 USED_REX (REX_MODE64
);
3669 if (rex
& REX_MODE64
)
3670 s
= names64
[code
- eAX_reg
+ add
];
3671 else if (sizeflag
& DFLAG
)
3672 s
= names32
[code
- eAX_reg
+ add
];
3674 s
= names16
[code
- eAX_reg
+ add
];
3675 used_prefixes
|= (prefixes
& PREFIX_DATA
);
3678 s
= INTERNAL_DISASSEMBLER_ERROR
;
3685 OP_IMREG (int code
, int sizeflag
)
3697 case ax_reg
: case cx_reg
: case dx_reg
: case bx_reg
:
3698 case sp_reg
: case bp_reg
: case si_reg
: case di_reg
:
3699 s
= names16
[code
- ax_reg
];
3701 case es_reg
: case ss_reg
: case cs_reg
:
3702 case ds_reg
: case fs_reg
: case gs_reg
:
3703 s
= names_seg
[code
- es_reg
];
3705 case al_reg
: case ah_reg
: case cl_reg
: case ch_reg
:
3706 case dl_reg
: case dh_reg
: case bl_reg
: case bh_reg
:
3709 s
= names8rex
[code
- al_reg
];
3711 s
= names8
[code
- al_reg
];
3713 case eAX_reg
: case eCX_reg
: case eDX_reg
: case eBX_reg
:
3714 case eSP_reg
: case eBP_reg
: case eSI_reg
: case eDI_reg
:
3715 USED_REX (REX_MODE64
);
3716 if (rex
& REX_MODE64
)
3717 s
= names64
[code
- eAX_reg
];
3718 else if (sizeflag
& DFLAG
)
3719 s
= names32
[code
- eAX_reg
];
3721 s
= names16
[code
- eAX_reg
];
3722 used_prefixes
|= (prefixes
& PREFIX_DATA
);
3725 s
= INTERNAL_DISASSEMBLER_ERROR
;
3732 OP_I (int bytemode
, int sizeflag
)
3735 bfd_signed_vma mask
= -1;
3740 FETCH_DATA (the_info
, codep
+ 1);
3745 if (address_mode
== mode_64bit
)
3752 USED_REX (REX_MODE64
);
3753 if (rex
& REX_MODE64
)
3755 else if (sizeflag
& DFLAG
)
3765 used_prefixes
|= (prefixes
& PREFIX_DATA
);
3776 oappend (INTERNAL_DISASSEMBLER_ERROR
);
3781 scratchbuf
[0] = '$';
3782 print_operand_value (scratchbuf
+ 1, 1, op
);
3783 oappend (scratchbuf
+ intel_syntax
);
3784 scratchbuf
[0] = '\0';
3788 OP_I64 (int bytemode
, int sizeflag
)
3791 bfd_signed_vma mask
= -1;
3793 if (address_mode
!= mode_64bit
)
3795 OP_I (bytemode
, sizeflag
);
3802 FETCH_DATA (the_info
, codep
+ 1);
3807 USED_REX (REX_MODE64
);
3808 if (rex
& REX_MODE64
)
3810 else if (sizeflag
& DFLAG
)
3820 used_prefixes
|= (prefixes
& PREFIX_DATA
);
3827 oappend (INTERNAL_DISASSEMBLER_ERROR
);
3832 scratchbuf
[0] = '$';
3833 print_operand_value (scratchbuf
+ 1, 1, op
);
3834 oappend (scratchbuf
+ intel_syntax
);
3835 scratchbuf
[0] = '\0';
3839 OP_sI (int bytemode
, int sizeflag
)
3842 bfd_signed_vma mask
= -1;
3847 FETCH_DATA (the_info
, codep
+ 1);
3849 if ((op
& 0x80) != 0)
3854 USED_REX (REX_MODE64
);
3855 if (rex
& REX_MODE64
)
3857 else if (sizeflag
& DFLAG
)
3866 if ((op
& 0x8000) != 0)
3869 used_prefixes
|= (prefixes
& PREFIX_DATA
);
3874 if ((op
& 0x8000) != 0)
3878 oappend (INTERNAL_DISASSEMBLER_ERROR
);
3882 scratchbuf
[0] = '$';
3883 print_operand_value (scratchbuf
+ 1, 1, op
);
3884 oappend (scratchbuf
+ intel_syntax
);
3888 OP_J (int bytemode
, int sizeflag
)
3896 FETCH_DATA (the_info
, codep
+ 1);
3898 if ((disp
& 0x80) != 0)
3902 if ((sizeflag
& DFLAG
) || (rex
& REX_MODE64
))
3907 /* For some reason, a data16 prefix on a jump instruction
3908 means that the pc is masked to 16 bits after the
3909 displacement is added! */
3914 oappend (INTERNAL_DISASSEMBLER_ERROR
);
3917 disp
= (start_pc
+ codep
- start_codep
+ disp
) & mask
;
3919 print_operand_value (scratchbuf
, 1, disp
);
3920 oappend (scratchbuf
);
3924 OP_SEG (int dummy ATTRIBUTE_UNUSED
, int sizeflag ATTRIBUTE_UNUSED
)
3926 oappend (names_seg
[reg
]);
3930 OP_DIR (int dummy ATTRIBUTE_UNUSED
, int sizeflag
)
3934 if (sizeflag
& DFLAG
)
3944 used_prefixes
|= (prefixes
& PREFIX_DATA
);
3946 sprintf (scratchbuf
, "0x%x:0x%x", seg
, offset
);
3948 sprintf (scratchbuf
, "$0x%x,$0x%x", seg
, offset
);
3949 oappend (scratchbuf
);
3953 OP_OFF (int bytemode
, int sizeflag
)
3957 if (intel_syntax
&& (sizeflag
& SUFFIX_ALWAYS
))
3958 intel_operand_size (bytemode
, sizeflag
);
3961 if ((sizeflag
& AFLAG
) || address_mode
== mode_64bit
)
3968 if (!(prefixes
& (PREFIX_CS
| PREFIX_SS
| PREFIX_DS
3969 | PREFIX_ES
| PREFIX_FS
| PREFIX_GS
)))
3971 oappend (names_seg
[ds_reg
- es_reg
]);
3975 print_operand_value (scratchbuf
, 1, off
);
3976 oappend (scratchbuf
);
3980 OP_OFF64 (int bytemode
, int sizeflag
)
3984 if (address_mode
!= mode_64bit
)
3986 OP_OFF (bytemode
, sizeflag
);
3990 if (intel_syntax
&& (sizeflag
& SUFFIX_ALWAYS
))
3991 intel_operand_size (bytemode
, sizeflag
);
3998 if (!(prefixes
& (PREFIX_CS
| PREFIX_SS
| PREFIX_DS
3999 | PREFIX_ES
| PREFIX_FS
| PREFIX_GS
)))
4001 oappend (names_seg
[ds_reg
- es_reg
]);
4005 print_operand_value (scratchbuf
, 1, off
);
4006 oappend (scratchbuf
);
4010 ptr_reg (int code
, int sizeflag
)
4014 *obufp
++ = open_char
;
4015 used_prefixes
|= (prefixes
& PREFIX_ADDR
);
4016 if (address_mode
== mode_64bit
)
4018 if (!(sizeflag
& AFLAG
))
4019 s
= names32
[code
- eAX_reg
];
4021 s
= names64
[code
- eAX_reg
];
4023 else if (sizeflag
& AFLAG
)
4024 s
= names32
[code
- eAX_reg
];
4026 s
= names16
[code
- eAX_reg
];
4028 *obufp
++ = close_char
;
4033 OP_ESreg (int code
, int sizeflag
)
4036 intel_operand_size (codep
[-1] & 1 ? v_mode
: b_mode
, sizeflag
);
4037 oappend ("%es:" + intel_syntax
);
4038 ptr_reg (code
, sizeflag
);
4042 OP_DSreg (int code
, int sizeflag
)
4045 intel_operand_size (codep
[-1] != 0xd7 && (codep
[-1] & 1)
4056 prefixes
|= PREFIX_DS
;
4058 ptr_reg (code
, sizeflag
);
4062 OP_C (int dummy ATTRIBUTE_UNUSED
, int sizeflag ATTRIBUTE_UNUSED
)
4067 USED_REX (REX_EXTX
);
4070 else if (address_mode
!= mode_64bit
&& (prefixes
& PREFIX_LOCK
))
4072 used_prefixes
|= PREFIX_LOCK
;
4075 sprintf (scratchbuf
, "%%cr%d", reg
+ add
);
4076 oappend (scratchbuf
+ intel_syntax
);
4080 OP_D (int dummy ATTRIBUTE_UNUSED
, int sizeflag ATTRIBUTE_UNUSED
)
4083 USED_REX (REX_EXTX
);
4087 sprintf (scratchbuf
, "db%d", reg
+ add
);
4089 sprintf (scratchbuf
, "%%db%d", reg
+ add
);
4090 oappend (scratchbuf
);
4094 OP_T (int dummy ATTRIBUTE_UNUSED
, int sizeflag ATTRIBUTE_UNUSED
)
4096 sprintf (scratchbuf
, "%%tr%d", reg
);
4097 oappend (scratchbuf
+ intel_syntax
);
4101 OP_Rd (int bytemode
, int sizeflag
)
4104 OP_E (bytemode
, sizeflag
);
4110 OP_MMX (int bytemode ATTRIBUTE_UNUSED
, int sizeflag ATTRIBUTE_UNUSED
)
4112 used_prefixes
|= (prefixes
& PREFIX_DATA
);
4113 if (prefixes
& PREFIX_DATA
)
4116 USED_REX (REX_EXTX
);
4119 sprintf (scratchbuf
, "%%xmm%d", reg
+ add
);
4122 sprintf (scratchbuf
, "%%mm%d", reg
);
4123 oappend (scratchbuf
+ intel_syntax
);
4127 OP_XMM (int bytemode ATTRIBUTE_UNUSED
, int sizeflag ATTRIBUTE_UNUSED
)
4130 USED_REX (REX_EXTX
);
4133 sprintf (scratchbuf
, "%%xmm%d", reg
+ add
);
4134 oappend (scratchbuf
+ intel_syntax
);
4138 OP_EM (int bytemode
, int sizeflag
)
4142 if (intel_syntax
&& bytemode
== v_mode
)
4144 bytemode
= (prefixes
& PREFIX_DATA
) ? x_mode
: q_mode
;
4145 used_prefixes
|= (prefixes
& PREFIX_DATA
);
4147 OP_E (bytemode
, sizeflag
);
4151 /* Skip mod/rm byte. */
4154 used_prefixes
|= (prefixes
& PREFIX_DATA
);
4155 if (prefixes
& PREFIX_DATA
)
4159 USED_REX (REX_EXTZ
);
4162 sprintf (scratchbuf
, "%%xmm%d", rm
+ add
);
4165 sprintf (scratchbuf
, "%%mm%d", rm
);
4166 oappend (scratchbuf
+ intel_syntax
);
4170 OP_EX (int bytemode
, int sizeflag
)
4175 if (intel_syntax
&& bytemode
== v_mode
)
4177 switch (prefixes
& (PREFIX_DATA
|PREFIX_REPZ
|PREFIX_REPNZ
))
4179 case 0: bytemode
= x_mode
; break;
4180 case PREFIX_REPZ
: bytemode
= d_mode
; used_prefixes
|= PREFIX_REPZ
; break;
4181 case PREFIX_DATA
: bytemode
= x_mode
; used_prefixes
|= PREFIX_DATA
; break;
4182 case PREFIX_REPNZ
: bytemode
= q_mode
; used_prefixes
|= PREFIX_REPNZ
; break;
4183 default: bytemode
= 0; break;
4186 OP_E (bytemode
, sizeflag
);
4189 USED_REX (REX_EXTZ
);
4193 /* Skip mod/rm byte. */
4196 sprintf (scratchbuf
, "%%xmm%d", rm
+ add
);
4197 oappend (scratchbuf
+ intel_syntax
);
4201 OP_MS (int bytemode
, int sizeflag
)
4204 OP_EM (bytemode
, sizeflag
);
4210 OP_XS (int bytemode
, int sizeflag
)
4213 OP_EX (bytemode
, sizeflag
);
4219 OP_M (int bytemode
, int sizeflag
)
4222 BadOp (); /* bad lea,lds,les,lfs,lgs,lss modrm */
4224 OP_E (bytemode
, sizeflag
);
4228 OP_0f07 (int bytemode
, int sizeflag
)
4230 if (mod
!= 3 || rm
!= 0)
4233 OP_E (bytemode
, sizeflag
);
4237 OP_0fae (int bytemode
, int sizeflag
)
4242 strcpy (obuf
+ strlen (obuf
) - sizeof ("clflush") + 1, "sfence");
4244 if (reg
< 5 || rm
!= 0)
4246 BadOp (); /* bad sfence, mfence, or lfence */
4252 BadOp (); /* bad clflush */
4256 OP_E (bytemode
, sizeflag
);
4260 NOP_Fixup (int bytemode ATTRIBUTE_UNUSED
, int sizeflag ATTRIBUTE_UNUSED
)
4262 /* NOP with REPZ prefix is called PAUSE. */
4263 if (prefixes
== PREFIX_REPZ
)
4264 strcpy (obuf
, "pause");
4267 static const char *const Suffix3DNow
[] = {
4268 /* 00 */ NULL
, NULL
, NULL
, NULL
,
4269 /* 04 */ NULL
, NULL
, NULL
, NULL
,
4270 /* 08 */ NULL
, NULL
, NULL
, NULL
,
4271 /* 0C */ "pi2fw", "pi2fd", NULL
, NULL
,
4272 /* 10 */ NULL
, NULL
, NULL
, NULL
,
4273 /* 14 */ NULL
, NULL
, NULL
, NULL
,
4274 /* 18 */ NULL
, NULL
, NULL
, NULL
,
4275 /* 1C */ "pf2iw", "pf2id", NULL
, NULL
,
4276 /* 20 */ NULL
, NULL
, NULL
, NULL
,
4277 /* 24 */ NULL
, NULL
, NULL
, NULL
,
4278 /* 28 */ NULL
, NULL
, NULL
, NULL
,
4279 /* 2C */ NULL
, NULL
, NULL
, NULL
,
4280 /* 30 */ NULL
, NULL
, NULL
, NULL
,
4281 /* 34 */ NULL
, NULL
, NULL
, NULL
,
4282 /* 38 */ NULL
, NULL
, NULL
, NULL
,
4283 /* 3C */ NULL
, NULL
, NULL
, NULL
,
4284 /* 40 */ NULL
, NULL
, NULL
, NULL
,
4285 /* 44 */ NULL
, NULL
, NULL
, NULL
,
4286 /* 48 */ NULL
, NULL
, NULL
, NULL
,
4287 /* 4C */ NULL
, NULL
, NULL
, NULL
,
4288 /* 50 */ NULL
, NULL
, NULL
, NULL
,
4289 /* 54 */ NULL
, NULL
, NULL
, NULL
,
4290 /* 58 */ NULL
, NULL
, NULL
, NULL
,
4291 /* 5C */ NULL
, NULL
, NULL
, NULL
,
4292 /* 60 */ NULL
, NULL
, NULL
, NULL
,
4293 /* 64 */ NULL
, NULL
, NULL
, NULL
,
4294 /* 68 */ NULL
, NULL
, NULL
, NULL
,
4295 /* 6C */ NULL
, NULL
, NULL
, NULL
,
4296 /* 70 */ NULL
, NULL
, NULL
, NULL
,
4297 /* 74 */ NULL
, NULL
, NULL
, NULL
,
4298 /* 78 */ NULL
, NULL
, NULL
, NULL
,
4299 /* 7C */ NULL
, NULL
, NULL
, NULL
,
4300 /* 80 */ NULL
, NULL
, NULL
, NULL
,
4301 /* 84 */ NULL
, NULL
, NULL
, NULL
,
4302 /* 88 */ NULL
, NULL
, "pfnacc", NULL
,
4303 /* 8C */ NULL
, NULL
, "pfpnacc", NULL
,
4304 /* 90 */ "pfcmpge", NULL
, NULL
, NULL
,
4305 /* 94 */ "pfmin", NULL
, "pfrcp", "pfrsqrt",
4306 /* 98 */ NULL
, NULL
, "pfsub", NULL
,
4307 /* 9C */ NULL
, NULL
, "pfadd", NULL
,
4308 /* A0 */ "pfcmpgt", NULL
, NULL
, NULL
,
4309 /* A4 */ "pfmax", NULL
, "pfrcpit1", "pfrsqit1",
4310 /* A8 */ NULL
, NULL
, "pfsubr", NULL
,
4311 /* AC */ NULL
, NULL
, "pfacc", NULL
,
4312 /* B0 */ "pfcmpeq", NULL
, NULL
, NULL
,
4313 /* B4 */ "pfmul", NULL
, "pfrcpit2", "pfmulhrw",
4314 /* B8 */ NULL
, NULL
, NULL
, "pswapd",
4315 /* BC */ NULL
, NULL
, NULL
, "pavgusb",
4316 /* C0 */ NULL
, NULL
, NULL
, NULL
,
4317 /* C4 */ NULL
, NULL
, NULL
, NULL
,
4318 /* C8 */ NULL
, NULL
, NULL
, NULL
,
4319 /* CC */ NULL
, NULL
, NULL
, NULL
,
4320 /* D0 */ NULL
, NULL
, NULL
, NULL
,
4321 /* D4 */ NULL
, NULL
, NULL
, NULL
,
4322 /* D8 */ NULL
, NULL
, NULL
, NULL
,
4323 /* DC */ NULL
, NULL
, NULL
, NULL
,
4324 /* E0 */ NULL
, NULL
, NULL
, NULL
,
4325 /* E4 */ NULL
, NULL
, NULL
, NULL
,
4326 /* E8 */ NULL
, NULL
, NULL
, NULL
,
4327 /* EC */ NULL
, NULL
, NULL
, NULL
,
4328 /* F0 */ NULL
, NULL
, NULL
, NULL
,
4329 /* F4 */ NULL
, NULL
, NULL
, NULL
,
4330 /* F8 */ NULL
, NULL
, NULL
, NULL
,
4331 /* FC */ NULL
, NULL
, NULL
, NULL
,
4335 OP_3DNowSuffix (int bytemode ATTRIBUTE_UNUSED
, int sizeflag ATTRIBUTE_UNUSED
)
4337 const char *mnemonic
;
4339 FETCH_DATA (the_info
, codep
+ 1);
4340 /* AMD 3DNow! instructions are specified by an opcode suffix in the
4341 place where an 8-bit immediate would normally go. ie. the last
4342 byte of the instruction. */
4343 obufp
= obuf
+ strlen (obuf
);
4344 mnemonic
= Suffix3DNow
[*codep
++ & 0xff];
4349 /* Since a variable sized modrm/sib chunk is between the start
4350 of the opcode (0x0f0f) and the opcode suffix, we need to do
4351 all the modrm processing first, and don't know until now that
4352 we have a bad opcode. This necessitates some cleaning up. */
4359 static const char *simd_cmp_op
[] = {
4371 OP_SIMD_Suffix (int bytemode ATTRIBUTE_UNUSED
, int sizeflag ATTRIBUTE_UNUSED
)
4373 unsigned int cmp_type
;
4375 FETCH_DATA (the_info
, codep
+ 1);
4376 obufp
= obuf
+ strlen (obuf
);
4377 cmp_type
= *codep
++ & 0xff;
4380 char suffix1
= 'p', suffix2
= 's';
4381 used_prefixes
|= (prefixes
& PREFIX_REPZ
);
4382 if (prefixes
& PREFIX_REPZ
)
4386 used_prefixes
|= (prefixes
& PREFIX_DATA
);
4387 if (prefixes
& PREFIX_DATA
)
4391 used_prefixes
|= (prefixes
& PREFIX_REPNZ
);
4392 if (prefixes
& PREFIX_REPNZ
)
4393 suffix1
= 's', suffix2
= 'd';
4396 sprintf (scratchbuf
, "cmp%s%c%c",
4397 simd_cmp_op
[cmp_type
], suffix1
, suffix2
);
4398 used_prefixes
|= (prefixes
& PREFIX_REPZ
);
4399 oappend (scratchbuf
);
4403 /* We have a bad extension byte. Clean up. */
4411 SIMD_Fixup (int extrachar
, int sizeflag ATTRIBUTE_UNUSED
)
4413 /* Change movlps/movhps to movhlps/movlhps for 2 register operand
4414 forms of these instructions. */
4417 char *p
= obuf
+ strlen (obuf
);
4420 *(p
- 1) = *(p
- 2);
4421 *(p
- 2) = *(p
- 3);
4422 *(p
- 3) = extrachar
;
4427 PNI_Fixup (int extrachar ATTRIBUTE_UNUSED
, int sizeflag
)
4429 if (mod
== 3 && reg
== 1 && rm
<= 1)
4431 /* Override "sidt". */
4432 size_t olen
= strlen (obuf
);
4433 char *p
= obuf
+ olen
- 4;
4434 const char **names
= (address_mode
== mode_64bit
4435 ? names64
: names32
);
4437 /* We might have a suffix when disassembling with -Msuffix. */
4441 /* Remove "addr16/addr32" if we aren't in Intel mode. */
4443 && (prefixes
& PREFIX_ADDR
)
4446 && strncmp (p
- 7, "addr", 4) == 0
4447 && (strncmp (p
- 3, "16", 2) == 0
4448 || strncmp (p
- 3, "32", 2) == 0))
4453 /* mwait %eax,%ecx */
4454 strcpy (p
, "mwait");
4456 strcpy (op1out
, names
[0]);
4460 /* monitor %eax,%ecx,%edx" */
4461 strcpy (p
, "monitor");
4464 const char **op1_names
;
4465 if (!(prefixes
& PREFIX_ADDR
))
4466 op1_names
= (address_mode
== mode_16bit
4470 op1_names
= (address_mode
!= mode_32bit
4471 ? names32
: names16
);
4472 used_prefixes
|= PREFIX_ADDR
;
4474 strcpy (op1out
, op1_names
[0]);
4475 strcpy (op3out
, names
[2]);
4480 strcpy (op2out
, names
[1]);
4491 SVME_Fixup (int bytemode
, int sizeflag
)
4523 OP_M (bytemode
, sizeflag
);
4526 /* Override "lidt". */
4527 p
= obuf
+ strlen (obuf
) - 4;
4528 /* We might have a suffix. */
4532 if (!(prefixes
& PREFIX_ADDR
))
4537 used_prefixes
|= PREFIX_ADDR
;
4541 strcpy (op2out
, names32
[1]);
4547 *obufp
++ = open_char
;
4548 if (address_mode
== mode_64bit
|| (sizeflag
& AFLAG
))
4552 strcpy (obufp
, alt
);
4553 obufp
+= strlen (alt
);
4554 *obufp
++ = close_char
;
4561 INVLPG_Fixup (int bytemode
, int sizeflag
)
4574 OP_M (bytemode
, sizeflag
);
4577 /* Override "invlpg". */
4578 strcpy (obuf
+ strlen (obuf
) - 6, alt
);
4585 /* Throw away prefixes and 1st. opcode byte. */
4586 codep
= insn_codep
+ 1;
4591 SEG_Fixup (int extrachar
, int sizeflag
)
4595 /* We need to add a proper suffix with
4606 if (prefixes
& PREFIX_DATA
)
4610 USED_REX (REX_MODE64
);
4611 if (rex
& REX_MODE64
)
4616 strcat (obuf
, suffix
);
4620 /* We need to fix the suffix for
4627 Override "mov[l|q]". */
4628 char *p
= obuf
+ strlen (obuf
) - 1;
4630 /* We might not have a suffix. */
4636 OP_E (extrachar
, sizeflag
);
4640 VMX_Fixup (int extrachar ATTRIBUTE_UNUSED
, int sizeflag
)
4642 if (mod
== 3 && reg
== 0 && rm
>=1 && rm
<= 4)
4644 /* Override "sgdt". */
4645 char *p
= obuf
+ strlen (obuf
) - 4;
4647 /* We might have a suffix when disassembling with -Msuffix. */
4654 strcpy (p
, "vmcall");
4657 strcpy (p
, "vmlaunch");
4660 strcpy (p
, "vmresume");
4663 strcpy (p
, "vmxoff");
4674 OP_VMX (int bytemode
, int sizeflag
)
4676 used_prefixes
|= (prefixes
& (PREFIX_DATA
| PREFIX_REPZ
));
4677 if (prefixes
& PREFIX_DATA
)
4678 strcpy (obuf
, "vmclear");
4679 else if (prefixes
& PREFIX_REPZ
)
4680 strcpy (obuf
, "vmxon");
4682 strcpy (obuf
, "vmptrld");
4683 OP_E (bytemode
, sizeflag
);