Search
lxdream.org :: lxdream/src/xlat/disasm/i386-dis.c
lxdream 0.9.1
released Jun 29
Download Now
filename src/xlat/disasm/i386-dis.c
changeset 1298:d0eb2307b847
prev1264:74ad81710528
author nkeynes
date Wed Feb 04 08:38:23 2015 +1000 (5 years ago)
permissions -rw-r--r--
last change Fix assorted compile warnings reported by Clang
file annotate diff log raw
nkeynes@362
     1
/* Print i386 instructions for GDB, the GNU debugger.
nkeynes@362
     2
   Copyright 1988, 1989, 1991, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
nkeynes@362
     3
   2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
nkeynes@362
     4
nkeynes@362
     5
   This file is part of GDB.
nkeynes@362
     6
nkeynes@362
     7
   This program is free software; you can redistribute it and/or modify
nkeynes@362
     8
   it under the terms of the GNU General Public License as published by
nkeynes@362
     9
   the Free Software Foundation; either version 2 of the License, or
nkeynes@362
    10
   (at your option) any later version.
nkeynes@362
    11
nkeynes@362
    12
   This program is distributed in the hope that it will be useful,
nkeynes@362
    13
   but WITHOUT ANY WARRANTY; without even the implied warranty of
nkeynes@362
    14
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
nkeynes@362
    15
   GNU General Public License for more details.
nkeynes@362
    16
nkeynes@362
    17
   You should have received a copy of the GNU General Public License
nkeynes@362
    18
   along with this program; if not, write to the Free Software
nkeynes@362
    19
   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
nkeynes@362
    20
nkeynes@362
    21
/* 80386 instruction printer by Pace Willisson (pace@prep.ai.mit.edu)
nkeynes@362
    22
   July 1988
nkeynes@362
    23
    modified by John Hassey (hassey@dg-rtp.dg.com)
nkeynes@362
    24
    x86-64 support added by Jan Hubicka (jh@suse.cz)
nkeynes@362
    25
    VIA PadLock support by Michal Ludvig (mludvig@suse.cz).  */
nkeynes@362
    26
nkeynes@362
    27
/* The main tables describing the instructions is essentially a copy
nkeynes@362
    28
   of the "Opcode Map" chapter (Appendix A) of the Intel 80386
nkeynes@362
    29
   Programmers Manual.  Usually, there is a capital letter, followed
nkeynes@362
    30
   by a small letter.  The capital letter tell the addressing mode,
nkeynes@362
    31
   and the small letter tells about the operand size.  Refer to
nkeynes@362
    32
   the Intel manual for details.  */
nkeynes@362
    33
nkeynes@1264
    34
#include "xlat/disasm/dis-asm.h"
nkeynes@1264
    35
#include "xlat/disasm/sysdep.h"
nkeynes@1263
    36
#include "xlat/xlatdasm.h"
nkeynes@755
    37
#include "gettext.h"
nkeynes@362
    38
nkeynes@362
    39
#define MAXLEN 20
nkeynes@362
    40
nkeynes@362
    41
#include <setjmp.h>
nkeynes@362
    42
nkeynes@362
    43
#ifndef UNIXWARE_COMPAT
nkeynes@362
    44
/* Set non-zero for broken, compatible instructions.  Set to zero for
nkeynes@362
    45
   non-broken opcodes.  */
nkeynes@362
    46
#define UNIXWARE_COMPAT 1
nkeynes@362
    47
#endif
nkeynes@362
    48
nkeynes@362
    49
static int fetch_data (struct disassemble_info *, bfd_byte *);
nkeynes@362
    50
static void ckprefix (void);
nkeynes@362
    51
static const char *prefix_name (int, int);
nkeynes@362
    52
static int print_insn (bfd_vma, disassemble_info *);
nkeynes@362
    53
static void dofloat (int);
nkeynes@362
    54
static void OP_ST (int, int);
nkeynes@362
    55
static void OP_STi (int, int);
nkeynes@362
    56
static int putop (const char *, int);
nkeynes@362
    57
static void oappend (const char *);
nkeynes@362
    58
static void append_seg (void);
nkeynes@362
    59
static void OP_indirE (int, int);
nkeynes@362
    60
static void OP_E (int, int);
nkeynes@362
    61
static void OP_G (int, int);
nkeynes@362
    62
static bfd_vma get64 (void);
nkeynes@362
    63
static bfd_signed_vma get32 (void);
nkeynes@362
    64
static bfd_signed_vma get32s (void);
nkeynes@362
    65
static int get16 (void);
nkeynes@362
    66
static void set_op (bfd_vma, int);
nkeynes@362
    67
static void OP_REG (int, int);
nkeynes@362
    68
static void OP_IMREG (int, int);
nkeynes@362
    69
static void OP_I (int, int);
nkeynes@362
    70
static void OP_I64 (int, int);
nkeynes@362
    71
static void OP_sI (int, int);
nkeynes@362
    72
static void OP_J (int, int);
nkeynes@362
    73
static void OP_SEG (int, int);
nkeynes@362
    74
static void OP_DIR (int, int);
nkeynes@362
    75
static void OP_OFF (int, int);
nkeynes@362
    76
static void OP_OFF64 (int, int);
nkeynes@362
    77
static void ptr_reg (int, int);
nkeynes@362
    78
static void OP_ESreg (int, int);
nkeynes@362
    79
static void OP_DSreg (int, int);
nkeynes@362
    80
static void OP_C (int, int);
nkeynes@362
    81
static void OP_D (int, int);
nkeynes@362
    82
static void OP_T (int, int);
nkeynes@362
    83
static void OP_Rd (int, int);
nkeynes@362
    84
static void OP_MMX (int, int);
nkeynes@362
    85
static void OP_XMM (int, int);
nkeynes@362
    86
static void OP_EM (int, int);
nkeynes@362
    87
static void OP_EX (int, int);
nkeynes@362
    88
static void OP_MS (int, int);
nkeynes@362
    89
static void OP_XS (int, int);
nkeynes@362
    90
static void OP_M (int, int);
nkeynes@362
    91
static void OP_0fae (int, int);
nkeynes@362
    92
static void OP_0f07 (int, int);
nkeynes@362
    93
static void NOP_Fixup (int, int);
nkeynes@362
    94
static void OP_3DNowSuffix (int, int);
nkeynes@362
    95
static void OP_SIMD_Suffix (int, int);
nkeynes@362
    96
static void SIMD_Fixup (int, int);
nkeynes@362
    97
static void PNI_Fixup (int, int);
nkeynes@362
    98
static void INVLPG_Fixup (int, int);
nkeynes@362
    99
static void BadOp (void);
nkeynes@362
   100
nkeynes@362
   101
struct dis_private {
nkeynes@362
   102
  /* Points to first byte not fetched.  */
nkeynes@362
   103
  bfd_byte *max_fetched;
nkeynes@362
   104
  bfd_byte the_buffer[MAXLEN];
nkeynes@362
   105
  bfd_vma insn_start;
nkeynes@362
   106
  int orig_sizeflag;
nkeynes@362
   107
  jmp_buf bailout;
nkeynes@362
   108
};
nkeynes@362
   109
nkeynes@362
   110
/* The opcode for the fwait instruction, which we treat as a prefix
nkeynes@362
   111
   when we can.  */
nkeynes@362
   112
#define FWAIT_OPCODE (0x9b)
nkeynes@362
   113
nkeynes@362
   114
/* Set to 1 for 64bit mode disassembly.  */
nkeynes@362
   115
static int mode_64bit;
nkeynes@362
   116
nkeynes@362
   117
/* Flags for the prefixes for the current instruction.  See below.  */
nkeynes@362
   118
static int prefixes;
nkeynes@362
   119
nkeynes@362
   120
/* REX prefix the current instruction.  See below.  */
nkeynes@362
   121
static int rex;
nkeynes@362
   122
/* Bits of REX we've already used.  */
nkeynes@362
   123
static int rex_used;
nkeynes@362
   124
#define REX_MODE64	8
nkeynes@362
   125
#define REX_EXTX	4
nkeynes@362
   126
#define REX_EXTY	2
nkeynes@362
   127
#define REX_EXTZ	1
nkeynes@362
   128
/* Mark parts used in the REX prefix.  When we are testing for
nkeynes@362
   129
   empty prefix (for 8bit register REX extension), just mask it
nkeynes@362
   130
   out.  Otherwise test for REX bit is excuse for existence of REX
nkeynes@362
   131
   only in case value is nonzero.  */
nkeynes@362
   132
#define USED_REX(value)					\
nkeynes@362
   133
  {							\
nkeynes@362
   134
    if (value)						\
nkeynes@362
   135
      rex_used |= (rex & value) ? (value) | 0x40 : 0;	\
nkeynes@362
   136
    else						\
nkeynes@362
   137
      rex_used |= 0x40;					\
nkeynes@362
   138
  }
nkeynes@362
   139
nkeynes@362
   140
/* Flags for prefixes which we somehow handled when printing the
nkeynes@362
   141
   current instruction.  */
nkeynes@362
   142
static int used_prefixes;
nkeynes@362
   143
nkeynes@362
   144
/* Flags stored in PREFIXES.  */
nkeynes@362
   145
#define PREFIX_REPZ 1
nkeynes@362
   146
#define PREFIX_REPNZ 2
nkeynes@362
   147
#define PREFIX_LOCK 4
nkeynes@362
   148
#define PREFIX_CS 8
nkeynes@362
   149
#define PREFIX_SS 0x10
nkeynes@362
   150
#define PREFIX_DS 0x20
nkeynes@362
   151
#define PREFIX_ES 0x40
nkeynes@362
   152
#define PREFIX_FS 0x80
nkeynes@362
   153
#define PREFIX_GS 0x100
nkeynes@362
   154
#define PREFIX_DATA 0x200
nkeynes@362
   155
#define PREFIX_ADDR 0x400
nkeynes@362
   156
#define PREFIX_FWAIT 0x800
nkeynes@362
   157
nkeynes@362
   158
/* Make sure that bytes from INFO->PRIVATE_DATA->BUFFER (inclusive)
nkeynes@362
   159
   to ADDR (exclusive) are valid.  Returns 1 for success, longjmps
nkeynes@362
   160
   on error.  */
nkeynes@362
   161
#define FETCH_DATA(info, addr) \
nkeynes@362
   162
  ((addr) <= ((struct dis_private *) (info->private_data))->max_fetched \
nkeynes@362
   163
   ? 1 : fetch_data ((info), (addr)))
nkeynes@362
   164
nkeynes@362
   165
static int
nkeynes@362
   166
fetch_data (struct disassemble_info *info, bfd_byte *addr)
nkeynes@362
   167
{
nkeynes@362
   168
  int status;
nkeynes@362
   169
  struct dis_private *priv = (struct dis_private *) info->private_data;
nkeynes@362
   170
  bfd_vma start = priv->insn_start + (priv->max_fetched - priv->the_buffer);
nkeynes@362
   171
nkeynes@362
   172
  status = (*info->read_memory_func) (start,
nkeynes@362
   173
				      priv->max_fetched,
nkeynes@362
   174
				      addr - priv->max_fetched,
nkeynes@362
   175
				      info);
nkeynes@362
   176
  if (status != 0)
nkeynes@362
   177
    {
nkeynes@362
   178
      /* If we did manage to read at least one byte, then
nkeynes@362
   179
	 print_insn_i386 will do something sensible.  Otherwise, print
nkeynes@362
   180
	 an error.  We do that here because this is where we know
nkeynes@362
   181
	 STATUS.  */
nkeynes@362
   182
      if (priv->max_fetched == priv->the_buffer)
nkeynes@362
   183
	(*info->memory_error_func) (status, start, info);
nkeynes@362
   184
      longjmp (priv->bailout, 1);
nkeynes@362
   185
    }
nkeynes@362
   186
  else
nkeynes@362
   187
    priv->max_fetched = addr;
nkeynes@362
   188
  return 1;
nkeynes@362
   189
}
nkeynes@362
   190
nkeynes@362
   191
#define XX NULL, 0
nkeynes@362
   192
nkeynes@362
   193
#define Eb OP_E, b_mode
nkeynes@362
   194
#define Ev OP_E, v_mode
nkeynes@362
   195
#define Ed OP_E, d_mode
nkeynes@362
   196
#define Eq OP_E, q_mode
nkeynes@362
   197
#define Edq OP_E, dq_mode
nkeynes@362
   198
#define Edqw OP_E, dqw_mode
nkeynes@362
   199
#define indirEv OP_indirE, v_mode
nkeynes@362
   200
#define indirEp OP_indirE, f_mode
nkeynes@362
   201
#define Ew OP_E, w_mode
nkeynes@362
   202
#define Ma OP_E, v_mode
nkeynes@362
   203
#define M OP_M, 0		/* lea, lgdt, etc. */
nkeynes@362
   204
#define Mp OP_M, f_mode		/* 32 or 48 bit memory operand for LDS, LES etc */
nkeynes@362
   205
#define Gb OP_G, b_mode
nkeynes@362
   206
#define Gv OP_G, v_mode
nkeynes@362
   207
#define Gd OP_G, d_mode
nkeynes@362
   208
#define Gdq OP_G, dq_mode
nkeynes@362
   209
#define Gw OP_G, w_mode
nkeynes@362
   210
#define Rd OP_Rd, d_mode
nkeynes@362
   211
#define Rm OP_Rd, m_mode
nkeynes@362
   212
#define Ib OP_I, b_mode
nkeynes@362
   213
#define sIb OP_sI, b_mode	/* sign extened byte */
nkeynes@362
   214
#define Iv OP_I, v_mode
nkeynes@362
   215
#define Iq OP_I, q_mode
nkeynes@362
   216
#define Iv64 OP_I64, v_mode
nkeynes@362
   217
#define Iw OP_I, w_mode
nkeynes@362
   218
#define I1 OP_I, const_1_mode
nkeynes@362
   219
#define Jb OP_J, b_mode
nkeynes@362
   220
#define Jv OP_J, v_mode
nkeynes@362
   221
#define Cm OP_C, m_mode
nkeynes@362
   222
#define Dm OP_D, m_mode
nkeynes@362
   223
#define Td OP_T, d_mode
nkeynes@362
   224
nkeynes@362
   225
#define RMeAX OP_REG, eAX_reg
nkeynes@362
   226
#define RMeBX OP_REG, eBX_reg
nkeynes@362
   227
#define RMeCX OP_REG, eCX_reg
nkeynes@362
   228
#define RMeDX OP_REG, eDX_reg
nkeynes@362
   229
#define RMeSP OP_REG, eSP_reg
nkeynes@362
   230
#define RMeBP OP_REG, eBP_reg
nkeynes@362
   231
#define RMeSI OP_REG, eSI_reg
nkeynes@362
   232
#define RMeDI OP_REG, eDI_reg
nkeynes@362
   233
#define RMrAX OP_REG, rAX_reg
nkeynes@362
   234
#define RMrBX OP_REG, rBX_reg
nkeynes@362
   235
#define RMrCX OP_REG, rCX_reg
nkeynes@362
   236
#define RMrDX OP_REG, rDX_reg
nkeynes@362
   237
#define RMrSP OP_REG, rSP_reg
nkeynes@362
   238
#define RMrBP OP_REG, rBP_reg
nkeynes@362
   239
#define RMrSI OP_REG, rSI_reg
nkeynes@362
   240
#define RMrDI OP_REG, rDI_reg
nkeynes@362
   241
#define RMAL OP_REG, al_reg
nkeynes@362
   242
#define RMAL OP_REG, al_reg
nkeynes@362
   243
#define RMCL OP_REG, cl_reg
nkeynes@362
   244
#define RMDL OP_REG, dl_reg
nkeynes@362
   245
#define RMBL OP_REG, bl_reg
nkeynes@362
   246
#define RMAH OP_REG, ah_reg
nkeynes@362
   247
#define RMCH OP_REG, ch_reg
nkeynes@362
   248
#define RMDH OP_REG, dh_reg
nkeynes@362
   249
#define RMBH OP_REG, bh_reg
nkeynes@362
   250
#define RMAX OP_REG, ax_reg
nkeynes@362
   251
#define RMDX OP_REG, dx_reg
nkeynes@362
   252
nkeynes@362
   253
#define eAX OP_IMREG, eAX_reg
nkeynes@362
   254
#define eBX OP_IMREG, eBX_reg
nkeynes@362
   255
#define eCX OP_IMREG, eCX_reg
nkeynes@362
   256
#define eDX OP_IMREG, eDX_reg
nkeynes@362
   257
#define eSP OP_IMREG, eSP_reg
nkeynes@362
   258
#define eBP OP_IMREG, eBP_reg
nkeynes@362
   259
#define eSI OP_IMREG, eSI_reg
nkeynes@362
   260
#define eDI OP_IMREG, eDI_reg
nkeynes@362
   261
#define AL OP_IMREG, al_reg
nkeynes@362
   262
#define AL OP_IMREG, al_reg
nkeynes@362
   263
#define CL OP_IMREG, cl_reg
nkeynes@362
   264
#define DL OP_IMREG, dl_reg
nkeynes@362
   265
#define BL OP_IMREG, bl_reg
nkeynes@362
   266
#define AH OP_IMREG, ah_reg
nkeynes@362
   267
#define CH OP_IMREG, ch_reg
nkeynes@362
   268
#define DH OP_IMREG, dh_reg
nkeynes@362
   269
#define BH OP_IMREG, bh_reg
nkeynes@362
   270
#define AX OP_IMREG, ax_reg
nkeynes@362
   271
#define DX OP_IMREG, dx_reg
nkeynes@362
   272
#define indirDX OP_IMREG, indir_dx_reg
nkeynes@362
   273
nkeynes@362
   274
#define Sw OP_SEG, w_mode
nkeynes@362
   275
#define Ap OP_DIR, 0
nkeynes@362
   276
#define Ob OP_OFF, b_mode
nkeynes@362
   277
#define Ob64 OP_OFF64, b_mode
nkeynes@362
   278
#define Ov OP_OFF, v_mode
nkeynes@362
   279
#define Ov64 OP_OFF64, v_mode
nkeynes@362
   280
#define Xb OP_DSreg, eSI_reg
nkeynes@362
   281
#define Xv OP_DSreg, eSI_reg
nkeynes@362
   282
#define Yb OP_ESreg, eDI_reg
nkeynes@362
   283
#define Yv OP_ESreg, eDI_reg
nkeynes@362
   284
#define DSBX OP_DSreg, eBX_reg
nkeynes@362
   285
nkeynes@362
   286
#define es OP_REG, es_reg
nkeynes@362
   287
#define ss OP_REG, ss_reg
nkeynes@362
   288
#define cs OP_REG, cs_reg
nkeynes@362
   289
#define ds OP_REG, ds_reg
nkeynes@362
   290
#define fs OP_REG, fs_reg
nkeynes@362
   291
#define gs OP_REG, gs_reg
nkeynes@362
   292
nkeynes@362
   293
#define MX OP_MMX, 0
nkeynes@362
   294
#define XM OP_XMM, 0
nkeynes@362
   295
#define EM OP_EM, v_mode
nkeynes@362
   296
#define EX OP_EX, v_mode
nkeynes@362
   297
#define MS OP_MS, v_mode
nkeynes@362
   298
#define XS OP_XS, v_mode
nkeynes@362
   299
#define OPSUF OP_3DNowSuffix, 0
nkeynes@362
   300
#define OPSIMD OP_SIMD_Suffix, 0
nkeynes@362
   301
nkeynes@362
   302
#define cond_jump_flag NULL, cond_jump_mode
nkeynes@362
   303
#define loop_jcxz_flag NULL, loop_jcxz_mode
nkeynes@362
   304
nkeynes@362
   305
/* bits in sizeflag */
nkeynes@362
   306
#define SUFFIX_ALWAYS 4
nkeynes@362
   307
#define AFLAG 2
nkeynes@362
   308
#define DFLAG 1
nkeynes@362
   309
nkeynes@362
   310
#define b_mode 1  /* byte operand */
nkeynes@362
   311
#define v_mode 2  /* operand size depends on prefixes */
nkeynes@362
   312
#define w_mode 3  /* word operand */
nkeynes@362
   313
#define d_mode 4  /* double word operand  */
nkeynes@362
   314
#define q_mode 5  /* quad word operand */
nkeynes@362
   315
#define t_mode 6  /* ten-byte operand */
nkeynes@362
   316
#define x_mode 7  /* 16-byte XMM operand */
nkeynes@362
   317
#define m_mode 8  /* d_mode in 32bit, q_mode in 64bit mode.  */
nkeynes@362
   318
#define cond_jump_mode 9
nkeynes@362
   319
#define loop_jcxz_mode 10
nkeynes@362
   320
#define dq_mode 11 /* operand size depends on REX prefixes.  */
nkeynes@362
   321
#define dqw_mode 12 /* registers like dq_mode, memory like w_mode.  */
nkeynes@362
   322
#define f_mode 13 /* 4- or 6-byte pointer operand */
nkeynes@362
   323
#define const_1_mode 14
nkeynes@362
   324
nkeynes@362
   325
#define es_reg 100
nkeynes@362
   326
#define cs_reg 101
nkeynes@362
   327
#define ss_reg 102
nkeynes@362
   328
#define ds_reg 103
nkeynes@362
   329
#define fs_reg 104
nkeynes@362
   330
#define gs_reg 105
nkeynes@362
   331
nkeynes@362
   332
#define eAX_reg 108
nkeynes@362
   333
#define eCX_reg 109
nkeynes@362
   334
#define eDX_reg 110
nkeynes@362
   335
#define eBX_reg 111
nkeynes@362
   336
#define eSP_reg 112
nkeynes@362
   337
#define eBP_reg 113
nkeynes@362
   338
#define eSI_reg 114
nkeynes@362
   339
#define eDI_reg 115
nkeynes@362
   340
nkeynes@362
   341
#define al_reg 116
nkeynes@362
   342
#define cl_reg 117
nkeynes@362
   343
#define dl_reg 118
nkeynes@362
   344
#define bl_reg 119
nkeynes@362
   345
#define ah_reg 120
nkeynes@362
   346
#define ch_reg 121
nkeynes@362
   347
#define dh_reg 122
nkeynes@362
   348
#define bh_reg 123
nkeynes@362
   349
nkeynes@362
   350
#define ax_reg 124
nkeynes@362
   351
#define cx_reg 125
nkeynes@362
   352
#define dx_reg 126
nkeynes@362
   353
#define bx_reg 127
nkeynes@362
   354
#define sp_reg 128
nkeynes@362
   355
#define bp_reg 129
nkeynes@362
   356
#define si_reg 130
nkeynes@362
   357
#define di_reg 131
nkeynes@362
   358
nkeynes@362
   359
#define rAX_reg 132
nkeynes@362
   360
#define rCX_reg 133
nkeynes@362
   361
#define rDX_reg 134
nkeynes@362
   362
#define rBX_reg 135
nkeynes@362
   363
#define rSP_reg 136
nkeynes@362
   364
#define rBP_reg 137
nkeynes@362
   365
#define rSI_reg 138
nkeynes@362
   366
#define rDI_reg 139
nkeynes@362
   367
nkeynes@362
   368
#define indir_dx_reg 150
nkeynes@362
   369
nkeynes@362
   370
#define FLOATCODE 1
nkeynes@362
   371
#define USE_GROUPS 2
nkeynes@362
   372
#define USE_PREFIX_USER_TABLE 3
nkeynes@362
   373
#define X86_64_SPECIAL 4
nkeynes@362
   374
nkeynes@362
   375
#define FLOAT	  NULL, NULL, FLOATCODE, NULL, 0, NULL, 0
nkeynes@362
   376
nkeynes@362
   377
#define GRP1b	  NULL, NULL, USE_GROUPS, NULL,  0, NULL, 0
nkeynes@362
   378
#define GRP1S	  NULL, NULL, USE_GROUPS, NULL,  1, NULL, 0
nkeynes@362
   379
#define GRP1Ss	  NULL, NULL, USE_GROUPS, NULL,  2, NULL, 0
nkeynes@362
   380
#define GRP2b	  NULL, NULL, USE_GROUPS, NULL,  3, NULL, 0
nkeynes@362
   381
#define GRP2S	  NULL, NULL, USE_GROUPS, NULL,  4, NULL, 0
nkeynes@362
   382
#define GRP2b_one NULL, NULL, USE_GROUPS, NULL,  5, NULL, 0
nkeynes@362
   383
#define GRP2S_one NULL, NULL, USE_GROUPS, NULL,  6, NULL, 0
nkeynes@362
   384
#define GRP2b_cl  NULL, NULL, USE_GROUPS, NULL,  7, NULL, 0
nkeynes@362
   385
#define GRP2S_cl  NULL, NULL, USE_GROUPS, NULL,  8, NULL, 0
nkeynes@362
   386
#define GRP3b	  NULL, NULL, USE_GROUPS, NULL,  9, NULL, 0
nkeynes@362
   387
#define GRP3S	  NULL, NULL, USE_GROUPS, NULL, 10, NULL, 0
nkeynes@362
   388
#define GRP4	  NULL, NULL, USE_GROUPS, NULL, 11, NULL, 0
nkeynes@362
   389
#define GRP5	  NULL, NULL, USE_GROUPS, NULL, 12, NULL, 0
nkeynes@362
   390
#define GRP6	  NULL, NULL, USE_GROUPS, NULL, 13, NULL, 0
nkeynes@362
   391
#define GRP7	  NULL, NULL, USE_GROUPS, NULL, 14, NULL, 0
nkeynes@362
   392
#define GRP8	  NULL, NULL, USE_GROUPS, NULL, 15, NULL, 0
nkeynes@362
   393
#define GRP9	  NULL, NULL, USE_GROUPS, NULL, 16, NULL, 0
nkeynes@362
   394
#define GRP10	  NULL, NULL, USE_GROUPS, NULL, 17, NULL, 0
nkeynes@362
   395
#define GRP11	  NULL, NULL, USE_GROUPS, NULL, 18, NULL, 0
nkeynes@362
   396
#define GRP12	  NULL, NULL, USE_GROUPS, NULL, 19, NULL, 0
nkeynes@362
   397
#define GRP13	  NULL, NULL, USE_GROUPS, NULL, 20, NULL, 0
nkeynes@362
   398
#define GRP14	  NULL, NULL, USE_GROUPS, NULL, 21, NULL, 0
nkeynes@362
   399
#define GRPAMD	  NULL, NULL, USE_GROUPS, NULL, 22, NULL, 0
nkeynes@362
   400
#define GRPPADLCK1 NULL, NULL, USE_GROUPS, NULL, 23, NULL, 0
nkeynes@362
   401
#define GRPPADLCK2 NULL, NULL, USE_GROUPS, NULL, 24, NULL, 0
nkeynes@362
   402
nkeynes@362
   403
#define PREGRP0   NULL, NULL, USE_PREFIX_USER_TABLE, NULL,  0, NULL, 0
nkeynes@362
   404
#define PREGRP1   NULL, NULL, USE_PREFIX_USER_TABLE, NULL,  1, NULL, 0
nkeynes@362
   405
#define PREGRP2   NULL, NULL, USE_PREFIX_USER_TABLE, NULL,  2, NULL, 0
nkeynes@362
   406
#define PREGRP3   NULL, NULL, USE_PREFIX_USER_TABLE, NULL,  3, NULL, 0
nkeynes@362
   407
#define PREGRP4   NULL, NULL, USE_PREFIX_USER_TABLE, NULL,  4, NULL, 0
nkeynes@362
   408
#define PREGRP5   NULL, NULL, USE_PREFIX_USER_TABLE, NULL,  5, NULL, 0
nkeynes@362
   409
#define PREGRP6   NULL, NULL, USE_PREFIX_USER_TABLE, NULL,  6, NULL, 0
nkeynes@362
   410
#define PREGRP7   NULL, NULL, USE_PREFIX_USER_TABLE, NULL,  7, NULL, 0
nkeynes@362
   411
#define PREGRP8   NULL, NULL, USE_PREFIX_USER_TABLE, NULL,  8, NULL, 0
nkeynes@362
   412
#define PREGRP9   NULL, NULL, USE_PREFIX_USER_TABLE, NULL,  9, NULL, 0
nkeynes@362
   413
#define PREGRP10  NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 10, NULL, 0
nkeynes@362
   414
#define PREGRP11  NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 11, NULL, 0
nkeynes@362
   415
#define PREGRP12  NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 12, NULL, 0
nkeynes@362
   416
#define PREGRP13  NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 13, NULL, 0
nkeynes@362
   417
#define PREGRP14  NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 14, NULL, 0
nkeynes@362
   418
#define PREGRP15  NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 15, NULL, 0
nkeynes@362
   419
#define PREGRP16  NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 16, NULL, 0
nkeynes@362
   420
#define PREGRP17  NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 17, NULL, 0
nkeynes@362
   421
#define PREGRP18  NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 18, NULL, 0
nkeynes@362
   422
#define PREGRP19  NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 19, NULL, 0
nkeynes@362
   423
#define PREGRP20  NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 20, NULL, 0
nkeynes@362
   424
#define PREGRP21  NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 21, NULL, 0
nkeynes@362
   425
#define PREGRP22  NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 22, NULL, 0
nkeynes@362
   426
#define PREGRP23  NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 23, NULL, 0
nkeynes@362
   427
#define PREGRP24  NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 24, NULL, 0
nkeynes@362
   428
#define PREGRP25  NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 25, NULL, 0
nkeynes@362
   429
#define PREGRP26  NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 26, NULL, 0
nkeynes@362
   430
#define PREGRP27  NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 27, NULL, 0
nkeynes@362
   431
#define PREGRP28  NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 28, NULL, 0
nkeynes@362
   432
#define PREGRP29  NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 29, NULL, 0
nkeynes@362
   433
#define PREGRP30  NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 30, NULL, 0
nkeynes@362
   434
#define PREGRP31  NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 31, NULL, 0
nkeynes@362
   435
#define PREGRP32  NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 32, NULL, 0
nkeynes@362
   436
nkeynes@362
   437
#define X86_64_0  NULL, NULL, X86_64_SPECIAL, NULL,  0, NULL, 0
nkeynes@362
   438
nkeynes@362
   439
typedef void (*op_rtn) (int bytemode, int sizeflag);
nkeynes@362
   440
nkeynes@362
   441
struct dis386 {
nkeynes@362
   442
  const char *name;
nkeynes@362
   443
  op_rtn op1;
nkeynes@362
   444
  int bytemode1;
nkeynes@362
   445
  op_rtn op2;
nkeynes@362
   446
  int bytemode2;
nkeynes@362
   447
  op_rtn op3;
nkeynes@362
   448
  int bytemode3;
nkeynes@362
   449
};
nkeynes@362
   450
nkeynes@362
   451
/* Upper case letters in the instruction names here are macros.
nkeynes@362
   452
   'A' => print 'b' if no register operands or suffix_always is true
nkeynes@362
   453
   'B' => print 'b' if suffix_always is true
nkeynes@362
   454
   'C' => print 's' or 'l' ('w' or 'd' in Intel mode) depending on operand
nkeynes@362
   455
   .      size prefix
nkeynes@362
   456
   'E' => print 'e' if 32-bit form of jcxz
nkeynes@362
   457
   'F' => print 'w' or 'l' depending on address size prefix (loop insns)
nkeynes@362
   458
   'H' => print ",pt" or ",pn" branch hint
nkeynes@362
   459
   'I' => honor following macro letter even in Intel mode (implemented only
nkeynes@362
   460
   .      for some of the macro letters)
nkeynes@362
   461
   'J' => print 'l'
nkeynes@362
   462
   'L' => print 'l' if suffix_always is true
nkeynes@362
   463
   'N' => print 'n' if instruction has no wait "prefix"
nkeynes@362
   464
   'O' => print 'd', or 'o'
nkeynes@362
   465
   'P' => print 'w', 'l' or 'q' if instruction has an operand size prefix,
nkeynes@362
   466
   .      or suffix_always is true.  print 'q' if rex prefix is present.
nkeynes@362
   467
   'Q' => print 'w', 'l' or 'q' if no register operands or suffix_always
nkeynes@362
   468
   .      is true
nkeynes@362
   469
   'R' => print 'w', 'l' or 'q' ("wd" or "dq" in intel mode)
nkeynes@362
   470
   'S' => print 'w', 'l' or 'q' if suffix_always is true
nkeynes@362
   471
   'T' => print 'q' in 64bit mode and behave as 'P' otherwise
nkeynes@362
   472
   'U' => print 'q' in 64bit mode and behave as 'Q' otherwise
nkeynes@362
   473
   'W' => print 'b' or 'w' ("w" or "de" in intel mode)
nkeynes@362
   474
   'X' => print 's', 'd' depending on data16 prefix (for XMM)
nkeynes@362
   475
   'Y' => 'q' if instruction has an REX 64bit overwrite prefix
nkeynes@362
   476
nkeynes@362
   477
   Many of the above letters print nothing in Intel mode.  See "putop"
nkeynes@362
   478
   for the details.
nkeynes@362
   479
nkeynes@362
   480
   Braces '{' and '}', and vertical bars '|', indicate alternative
nkeynes@362
   481
   mnemonic strings for AT&T, Intel, X86_64 AT&T, and X86_64 Intel
nkeynes@362
   482
   modes.  In cases where there are only two alternatives, the X86_64
nkeynes@362
   483
   instruction is reserved, and "(bad)" is printed.
nkeynes@362
   484
*/
nkeynes@362
   485
nkeynes@362
   486
static const struct dis386 dis386[] = {
nkeynes@362
   487
  /* 00 */
nkeynes@362
   488
  { "addB",		Eb, Gb, XX },
nkeynes@362
   489
  { "addS",		Ev, Gv, XX },
nkeynes@362
   490
  { "addB",		Gb, Eb, XX },
nkeynes@362
   491
  { "addS",		Gv, Ev, XX },
nkeynes@362
   492
  { "addB",		AL, Ib, XX },
nkeynes@362
   493
  { "addS",		eAX, Iv, XX },
nkeynes@362
   494
  { "push{T|}",		es, XX, XX },
nkeynes@362
   495
  { "pop{T|}",		es, XX, XX },
nkeynes@362
   496
  /* 08 */
nkeynes@362
   497
  { "orB",		Eb, Gb, XX },
nkeynes@362
   498
  { "orS",		Ev, Gv, XX },
nkeynes@362
   499
  { "orB",		Gb, Eb, XX },
nkeynes@362
   500
  { "orS",		Gv, Ev, XX },
nkeynes@362
   501
  { "orB",		AL, Ib, XX },
nkeynes@362
   502
  { "orS",		eAX, Iv, XX },
nkeynes@362
   503
  { "push{T|}",		cs, XX, XX },
nkeynes@362
   504
  { "(bad)",		XX, XX, XX },	/* 0x0f extended opcode escape */
nkeynes@362
   505
  /* 10 */
nkeynes@362
   506
  { "adcB",		Eb, Gb, XX },
nkeynes@362
   507
  { "adcS",		Ev, Gv, XX },
nkeynes@362
   508
  { "adcB",		Gb, Eb, XX },
nkeynes@362
   509
  { "adcS",		Gv, Ev, XX },
nkeynes@362
   510
  { "adcB",		AL, Ib, XX },
nkeynes@362
   511
  { "adcS",		eAX, Iv, XX },
nkeynes@362
   512
  { "push{T|}",		ss, XX, XX },
nkeynes@362
   513
  { "popT|}",		ss, XX, XX },
nkeynes@362
   514
  /* 18 */
nkeynes@362
   515
  { "sbbB",		Eb, Gb, XX },
nkeynes@362
   516
  { "sbbS",		Ev, Gv, XX },
nkeynes@362
   517
  { "sbbB",		Gb, Eb, XX },
nkeynes@362
   518
  { "sbbS",		Gv, Ev, XX },
nkeynes@362
   519
  { "sbbB",		AL, Ib, XX },
nkeynes@362
   520
  { "sbbS",		eAX, Iv, XX },
nkeynes@362
   521
  { "push{T|}",		ds, XX, XX },
nkeynes@362
   522
  { "pop{T|}",		ds, XX, XX },
nkeynes@362
   523
  /* 20 */
nkeynes@362
   524
  { "andB",		Eb, Gb, XX },
nkeynes@362
   525
  { "andS",		Ev, Gv, XX },
nkeynes@362
   526
  { "andB",		Gb, Eb, XX },
nkeynes@362
   527
  { "andS",		Gv, Ev, XX },
nkeynes@362
   528
  { "andB",		AL, Ib, XX },
nkeynes@362
   529
  { "andS",		eAX, Iv, XX },
nkeynes@362
   530
  { "(bad)",		XX, XX, XX },	/* SEG ES prefix */
nkeynes@362
   531
  { "daa{|}",		XX, XX, XX },
nkeynes@362
   532
  /* 28 */
nkeynes@362
   533
  { "subB",		Eb, Gb, XX },
nkeynes@362
   534
  { "subS",		Ev, Gv, XX },
nkeynes@362
   535
  { "subB",		Gb, Eb, XX },
nkeynes@362
   536
  { "subS",		Gv, Ev, XX },
nkeynes@362
   537
  { "subB",		AL, Ib, XX },
nkeynes@362
   538
  { "subS",		eAX, Iv, XX },
nkeynes@362
   539
  { "(bad)",		XX, XX, XX },	/* SEG CS prefix */
nkeynes@362
   540
  { "das{|}",		XX, XX, XX },
nkeynes@362
   541
  /* 30 */
nkeynes@362
   542
  { "xorB",		Eb, Gb, XX },
nkeynes@362
   543
  { "xorS",		Ev, Gv, XX },
nkeynes@362
   544
  { "xorB",		Gb, Eb, XX },
nkeynes@362
   545
  { "xorS",		Gv, Ev, XX },
nkeynes@362
   546
  { "xorB",		AL, Ib, XX },
nkeynes@362
   547
  { "xorS",		eAX, Iv, XX },
nkeynes@362
   548
  { "(bad)",		XX, XX, XX },	/* SEG SS prefix */
nkeynes@362
   549
  { "aaa{|}",		XX, XX, XX },
nkeynes@362
   550
  /* 38 */
nkeynes@362
   551
  { "cmpB",		Eb, Gb, XX },
nkeynes@362
   552
  { "cmpS",		Ev, Gv, XX },
nkeynes@362
   553
  { "cmpB",		Gb, Eb, XX },
nkeynes@362
   554
  { "cmpS",		Gv, Ev, XX },
nkeynes@362
   555
  { "cmpB",		AL, Ib, XX },
nkeynes@362
   556
  { "cmpS",		eAX, Iv, XX },
nkeynes@362
   557
  { "(bad)",		XX, XX, XX },	/* SEG DS prefix */
nkeynes@362
   558
  { "aas{|}",		XX, XX, XX },
nkeynes@362
   559
  /* 40 */
nkeynes@362
   560
  { "inc{S|}",		RMeAX, XX, XX },
nkeynes@362
   561
  { "inc{S|}",		RMeCX, XX, XX },
nkeynes@362
   562
  { "inc{S|}",		RMeDX, XX, XX },
nkeynes@362
   563
  { "inc{S|}",		RMeBX, XX, XX },
nkeynes@362
   564
  { "inc{S|}",		RMeSP, XX, XX },
nkeynes@362
   565
  { "inc{S|}",		RMeBP, XX, XX },
nkeynes@362
   566
  { "inc{S|}",		RMeSI, XX, XX },
nkeynes@362
   567
  { "inc{S|}",		RMeDI, XX, XX },
nkeynes@362
   568
  /* 48 */
nkeynes@362
   569
  { "dec{S|}",		RMeAX, XX, XX },
nkeynes@362
   570
  { "dec{S|}",		RMeCX, XX, XX },
nkeynes@362
   571
  { "dec{S|}",		RMeDX, XX, XX },
nkeynes@362
   572
  { "dec{S|}",		RMeBX, XX, XX },
nkeynes@362
   573
  { "dec{S|}",		RMeSP, XX, XX },
nkeynes@362
   574
  { "dec{S|}",		RMeBP, XX, XX },
nkeynes@362
   575
  { "dec{S|}",		RMeSI, XX, XX },
nkeynes@362
   576
  { "dec{S|}",		RMeDI, XX, XX },
nkeynes@362
   577
  /* 50 */
nkeynes@362
   578
  { "pushS",		RMrAX, XX, XX },
nkeynes@362
   579
  { "pushS",		RMrCX, XX, XX },
nkeynes@362
   580
  { "pushS",		RMrDX, XX, XX },
nkeynes@362
   581
  { "pushS",		RMrBX, XX, XX },
nkeynes@362
   582
  { "pushS",		RMrSP, XX, XX },
nkeynes@362
   583
  { "pushS",		RMrBP, XX, XX },
nkeynes@362
   584
  { "pushS",		RMrSI, XX, XX },
nkeynes@362
   585
  { "pushS",		RMrDI, XX, XX },
nkeynes@362
   586
  /* 58 */
nkeynes@362
   587
  { "popS",		RMrAX, XX, XX },
nkeynes@362
   588
  { "popS",		RMrCX, XX, XX },
nkeynes@362
   589
  { "popS",		RMrDX, XX, XX },
nkeynes@362
   590
  { "popS",		RMrBX, XX, XX },
nkeynes@362
   591
  { "popS",		RMrSP, XX, XX },
nkeynes@362
   592
  { "popS",		RMrBP, XX, XX },
nkeynes@362
   593
  { "popS",		RMrSI, XX, XX },
nkeynes@362
   594
  { "popS",		RMrDI, XX, XX },
nkeynes@362
   595
  /* 60 */
nkeynes@362
   596
  { "pusha{P|}",	XX, XX, XX },
nkeynes@362
   597
  { "popa{P|}",		XX, XX, XX },
nkeynes@362
   598
  { "bound{S|}",	Gv, Ma, XX },
nkeynes@362
   599
  { X86_64_0 },
nkeynes@362
   600
  { "(bad)",		XX, XX, XX },	/* seg fs */
nkeynes@362
   601
  { "(bad)",		XX, XX, XX },	/* seg gs */
nkeynes@362
   602
  { "(bad)",		XX, XX, XX },	/* op size prefix */
nkeynes@362
   603
  { "(bad)",		XX, XX, XX },	/* adr size prefix */
nkeynes@362
   604
  /* 68 */
nkeynes@362
   605
  { "pushT",		Iq, XX, XX },
nkeynes@362
   606
  { "imulS",		Gv, Ev, Iv },
nkeynes@362
   607
  { "pushT",		sIb, XX, XX },
nkeynes@362
   608
  { "imulS",		Gv, Ev, sIb },
nkeynes@362
   609
  { "ins{b||b|}",	Yb, indirDX, XX },
nkeynes@362
   610
  { "ins{R||R|}",	Yv, indirDX, XX },
nkeynes@362
   611
  { "outs{b||b|}",	indirDX, Xb, XX },
nkeynes@362
   612
  { "outs{R||R|}",	indirDX, Xv, XX },
nkeynes@362
   613
  /* 70 */
nkeynes@362
   614
  { "joH",		Jb, XX, cond_jump_flag },
nkeynes@362
   615
  { "jnoH",		Jb, XX, cond_jump_flag },
nkeynes@362
   616
  { "jbH",		Jb, XX, cond_jump_flag },
nkeynes@362
   617
  { "jaeH",		Jb, XX, cond_jump_flag },
nkeynes@362
   618
  { "jeH",		Jb, XX, cond_jump_flag },
nkeynes@362
   619
  { "jneH",		Jb, XX, cond_jump_flag },
nkeynes@362
   620
  { "jbeH",		Jb, XX, cond_jump_flag },
nkeynes@362
   621
  { "jaH",		Jb, XX, cond_jump_flag },
nkeynes@362
   622
  /* 78 */
nkeynes@362
   623
  { "jsH",		Jb, XX, cond_jump_flag },
nkeynes@362
   624
  { "jnsH",		Jb, XX, cond_jump_flag },
nkeynes@362
   625
  { "jpH",		Jb, XX, cond_jump_flag },
nkeynes@362
   626
  { "jnpH",		Jb, XX, cond_jump_flag },
nkeynes@362
   627
  { "jlH",		Jb, XX, cond_jump_flag },
nkeynes@362
   628
  { "jgeH",		Jb, XX, cond_jump_flag },
nkeynes@362
   629
  { "jleH",		Jb, XX, cond_jump_flag },
nkeynes@362
   630
  { "jgH",		Jb, XX, cond_jump_flag },
nkeynes@362
   631
  /* 80 */
nkeynes@362
   632
  { GRP1b },
nkeynes@362
   633
  { GRP1S },
nkeynes@362
   634
  { "(bad)",		XX, XX, XX },
nkeynes@362
   635
  { GRP1Ss },
nkeynes@362
   636
  { "testB",		Eb, Gb, XX },
nkeynes@362
   637
  { "testS",		Ev, Gv, XX },
nkeynes@362
   638
  { "xchgB",		Eb, Gb, XX },
nkeynes@362
   639
  { "xchgS",		Ev, Gv, XX },
nkeynes@362
   640
  /* 88 */
nkeynes@362
   641
  { "movB",		Eb, Gb, XX },
nkeynes@362
   642
  { "movS",		Ev, Gv, XX },
nkeynes@362
   643
  { "movB",		Gb, Eb, XX },
nkeynes@362
   644
  { "movS",		Gv, Ev, XX },
nkeynes@362
   645
  { "movQ",		Ev, Sw, XX },
nkeynes@362
   646
  { "leaS",		Gv, M, XX },
nkeynes@362
   647
  { "movQ",		Sw, Ev, XX },
nkeynes@362
   648
  { "popU",		Ev, XX, XX },
nkeynes@362
   649
  /* 90 */
nkeynes@362
   650
  { "nop",		NOP_Fixup, 0, XX, XX },
nkeynes@362
   651
  { "xchgS",		RMeCX, eAX, XX },
nkeynes@362
   652
  { "xchgS",		RMeDX, eAX, XX },
nkeynes@362
   653
  { "xchgS",		RMeBX, eAX, XX },
nkeynes@362
   654
  { "xchgS",		RMeSP, eAX, XX },
nkeynes@362
   655
  { "xchgS",		RMeBP, eAX, XX },
nkeynes@362
   656
  { "xchgS",		RMeSI, eAX, XX },
nkeynes@362
   657
  { "xchgS",		RMeDI, eAX, XX },
nkeynes@362
   658
  /* 98 */
nkeynes@362
   659
  { "cW{tR||tR|}",	XX, XX, XX },
nkeynes@362
   660
  { "cR{tO||tO|}",	XX, XX, XX },
nkeynes@362
   661
  { "Jcall{T|}",	Ap, XX, XX },
nkeynes@362
   662
  { "(bad)",		XX, XX, XX },	/* fwait */
nkeynes@362
   663
  { "pushfT",		XX, XX, XX },
nkeynes@362
   664
  { "popfT",		XX, XX, XX },
nkeynes@362
   665
  { "sahf{|}",		XX, XX, XX },
nkeynes@362
   666
  { "lahf{|}",		XX, XX, XX },
nkeynes@362
   667
  /* a0 */
nkeynes@362
   668
  { "movB",		AL, Ob64, XX },
nkeynes@362
   669
  { "movS",		eAX, Ov64, XX },
nkeynes@362
   670
  { "movB",		Ob64, AL, XX },
nkeynes@362
   671
  { "movS",		Ov64, eAX, XX },
nkeynes@362
   672
  { "movs{b||b|}",	Yb, Xb, XX },
nkeynes@362
   673
  { "movs{R||R|}",	Yv, Xv, XX },
nkeynes@362
   674
  { "cmps{b||b|}",	Xb, Yb, XX },
nkeynes@362
   675
  { "cmps{R||R|}",	Xv, Yv, XX },
nkeynes@362
   676
  /* a8 */
nkeynes@362
   677
  { "testB",		AL, Ib, XX },
nkeynes@362
   678
  { "testS",		eAX, Iv, XX },
nkeynes@362
   679
  { "stosB",		Yb, AL, XX },
nkeynes@362
   680
  { "stosS",		Yv, eAX, XX },
nkeynes@362
   681
  { "lodsB",		AL, Xb, XX },
nkeynes@362
   682
  { "lodsS",		eAX, Xv, XX },
nkeynes@362
   683
  { "scasB",		AL, Yb, XX },
nkeynes@362
   684
  { "scasS",		eAX, Yv, XX },
nkeynes@362
   685
  /* b0 */
nkeynes@362
   686
  { "movB",		RMAL, Ib, XX },
nkeynes@362
   687
  { "movB",		RMCL, Ib, XX },
nkeynes@362
   688
  { "movB",		RMDL, Ib, XX },
nkeynes@362
   689
  { "movB",		RMBL, Ib, XX },
nkeynes@362
   690
  { "movB",		RMAH, Ib, XX },
nkeynes@362
   691
  { "movB",		RMCH, Ib, XX },
nkeynes@362
   692
  { "movB",		RMDH, Ib, XX },
nkeynes@362
   693
  { "movB",		RMBH, Ib, XX },
nkeynes@362
   694
  /* b8 */
nkeynes@362
   695
  { "movS",		RMeAX, Iv64, XX },
nkeynes@362
   696
  { "movS",		RMeCX, Iv64, XX },
nkeynes@362
   697
  { "movS",		RMeDX, Iv64, XX },
nkeynes@362
   698
  { "movS",		RMeBX, Iv64, XX },
nkeynes@362
   699
  { "movS",		RMeSP, Iv64, XX },
nkeynes@362
   700
  { "movS",		RMeBP, Iv64, XX },
nkeynes@362
   701
  { "movS",		RMeSI, Iv64, XX },
nkeynes@362
   702
  { "movS",		RMeDI, Iv64, XX },
nkeynes@362
   703
  /* c0 */
nkeynes@362
   704
  { GRP2b },
nkeynes@362
   705
  { GRP2S },
nkeynes@362
   706
  { "retT",		Iw, XX, XX },
nkeynes@362
   707
  { "retT",		XX, XX, XX },
nkeynes@362
   708
  { "les{S|}",		Gv, Mp, XX },
nkeynes@362
   709
  { "ldsS",		Gv, Mp, XX },
nkeynes@362
   710
  { "movA",		Eb, Ib, XX },
nkeynes@362
   711
  { "movQ",		Ev, Iv, XX },
nkeynes@362
   712
  /* c8 */
nkeynes@362
   713
  { "enterT",		Iw, Ib, XX },
nkeynes@362
   714
  { "leaveT",		XX, XX, XX },
nkeynes@362
   715
  { "lretP",		Iw, XX, XX },
nkeynes@362
   716
  { "lretP",		XX, XX, XX },
nkeynes@362
   717
  { "int3",		XX, XX, XX },
nkeynes@362
   718
  { "int",		Ib, XX, XX },
nkeynes@362
   719
  { "into{|}",		XX, XX, XX },
nkeynes@362
   720
  { "iretP",		XX, XX, XX },
nkeynes@362
   721
  /* d0 */
nkeynes@362
   722
  { GRP2b_one },
nkeynes@362
   723
  { GRP2S_one },
nkeynes@362
   724
  { GRP2b_cl },
nkeynes@362
   725
  { GRP2S_cl },
nkeynes@362
   726
  { "aam{|}",		sIb, XX, XX },
nkeynes@362
   727
  { "aad{|}",		sIb, XX, XX },
nkeynes@362
   728
  { "(bad)",		XX, XX, XX },
nkeynes@362
   729
  { "xlat",		DSBX, XX, XX },
nkeynes@362
   730
  /* d8 */
nkeynes@362
   731
  { FLOAT },
nkeynes@362
   732
  { FLOAT },
nkeynes@362
   733
  { FLOAT },
nkeynes@362
   734
  { FLOAT },
nkeynes@362
   735
  { FLOAT },
nkeynes@362
   736
  { FLOAT },
nkeynes@362
   737
  { FLOAT },
nkeynes@362
   738
  { FLOAT },
nkeynes@362
   739
  /* e0 */
nkeynes@362
   740
  { "loopneFH",		Jb, XX, loop_jcxz_flag },
nkeynes@362
   741
  { "loopeFH",		Jb, XX, loop_jcxz_flag },
nkeynes@362
   742
  { "loopFH",		Jb, XX, loop_jcxz_flag },
nkeynes@362
   743
  { "jEcxzH",		Jb, XX, loop_jcxz_flag },
nkeynes@362
   744
  { "inB",		AL, Ib, XX },
nkeynes@362
   745
  { "inS",		eAX, Ib, XX },
nkeynes@362
   746
  { "outB",		Ib, AL, XX },
nkeynes@362
   747
  { "outS",		Ib, eAX, XX },
nkeynes@362
   748
  /* e8 */
nkeynes@362
   749
  { "callT",		Jv, XX, XX },
nkeynes@362
   750
  { "jmpT",		Jv, XX, XX },
nkeynes@362
   751
  { "Jjmp{T|}",		Ap, XX, XX },
nkeynes@362
   752
  { "jmp",		Jb, XX, XX },
nkeynes@362
   753
  { "inB",		AL, indirDX, XX },
nkeynes@362
   754
  { "inS",		eAX, indirDX, XX },
nkeynes@362
   755
  { "outB",		indirDX, AL, XX },
nkeynes@362
   756
  { "outS",		indirDX, eAX, XX },
nkeynes@362
   757
  /* f0 */
nkeynes@362
   758
  { "(bad)",		XX, XX, XX },	/* lock prefix */
nkeynes@362
   759
  { "icebp",		XX, XX, XX },
nkeynes@362
   760
  { "(bad)",		XX, XX, XX },	/* repne */
nkeynes@362
   761
  { "(bad)",		XX, XX, XX },	/* repz */
nkeynes@362
   762
  { "hlt",		XX, XX, XX },
nkeynes@362
   763
  { "cmc",		XX, XX, XX },
nkeynes@362
   764
  { GRP3b },
nkeynes@362
   765
  { GRP3S },
nkeynes@362
   766
  /* f8 */
nkeynes@362
   767
  { "clc",		XX, XX, XX },
nkeynes@362
   768
  { "stc",		XX, XX, XX },
nkeynes@362
   769
  { "cli",		XX, XX, XX },
nkeynes@362
   770
  { "sti",		XX, XX, XX },
nkeynes@362
   771
  { "cld",		XX, XX, XX },
nkeynes@362
   772
  { "std",		XX, XX, XX },
nkeynes@362
   773
  { GRP4 },
nkeynes@362
   774
  { GRP5 },
nkeynes@362
   775
};
nkeynes@362
   776
nkeynes@362
   777
static const struct dis386 dis386_twobyte[] = {
nkeynes@362
   778
  /* 00 */
nkeynes@362
   779
  { GRP6 },
nkeynes@362
   780
  { GRP7 },
nkeynes@362
   781
  { "larS",		Gv, Ew, XX },
nkeynes@362
   782
  { "lslS",		Gv, Ew, XX },
nkeynes@362
   783
  { "(bad)",		XX, XX, XX },
nkeynes@362
   784
  { "syscall",		XX, XX, XX },
nkeynes@362
   785
  { "clts",		XX, XX, XX },
nkeynes@362
   786
  { "sysretP",		XX, XX, XX },
nkeynes@362
   787
  /* 08 */
nkeynes@362
   788
  { "invd",		XX, XX, XX },
nkeynes@362
   789
  { "wbinvd",		XX, XX, XX },
nkeynes@362
   790
  { "(bad)",		XX, XX, XX },
nkeynes@362
   791
  { "ud2a",		XX, XX, XX },
nkeynes@362
   792
  { "(bad)",		XX, XX, XX },
nkeynes@362
   793
  { GRPAMD },
nkeynes@362
   794
  { "femms",		XX, XX, XX },
nkeynes@362
   795
  { "",			MX, EM, OPSUF }, /* See OP_3DNowSuffix.  */
nkeynes@362
   796
  /* 10 */
nkeynes@362
   797
  { PREGRP8 },
nkeynes@362
   798
  { PREGRP9 },
nkeynes@362
   799
  { PREGRP30 },
nkeynes@362
   800
  { "movlpX",		EX, XM, SIMD_Fixup, 'h' },
nkeynes@362
   801
  { "unpcklpX",		XM, EX, XX },
nkeynes@362
   802
  { "unpckhpX",		XM, EX, XX },
nkeynes@362
   803
  { PREGRP31 },
nkeynes@362
   804
  { "movhpX",		EX, XM, SIMD_Fixup, 'l' },
nkeynes@362
   805
  /* 18 */
nkeynes@362
   806
  { GRP14 },
nkeynes@362
   807
  { "(bad)",		XX, XX, XX },
nkeynes@362
   808
  { "(bad)",		XX, XX, XX },
nkeynes@362
   809
  { "(bad)",		XX, XX, XX },
nkeynes@362
   810
  { "(bad)",		XX, XX, XX },
nkeynes@362
   811
  { "(bad)",		XX, XX, XX },
nkeynes@362
   812
  { "(bad)",		XX, XX, XX },
nkeynes@362
   813
  { "(bad)",		XX, XX, XX },
nkeynes@362
   814
  /* 20 */
nkeynes@362
   815
  { "movL",		Rm, Cm, XX },
nkeynes@362
   816
  { "movL",		Rm, Dm, XX },
nkeynes@362
   817
  { "movL",		Cm, Rm, XX },
nkeynes@362
   818
  { "movL",		Dm, Rm, XX },
nkeynes@362
   819
  { "movL",		Rd, Td, XX },
nkeynes@362
   820
  { "(bad)",		XX, XX, XX },
nkeynes@362
   821
  { "movL",		Td, Rd, XX },
nkeynes@362
   822
  { "(bad)",		XX, XX, XX },
nkeynes@362
   823
  /* 28 */
nkeynes@362
   824
  { "movapX",		XM, EX, XX },
nkeynes@362
   825
  { "movapX",		EX, XM, XX },
nkeynes@362
   826
  { PREGRP2 },
nkeynes@362
   827
  { "movntpX",		Ev, XM, XX },
nkeynes@362
   828
  { PREGRP4 },
nkeynes@362
   829
  { PREGRP3 },
nkeynes@362
   830
  { "ucomisX",		XM,EX, XX },
nkeynes@362
   831
  { "comisX",		XM,EX, XX },
nkeynes@362
   832
  /* 30 */
nkeynes@362
   833
  { "wrmsr",		XX, XX, XX },
nkeynes@362
   834
  { "rdtsc",		XX, XX, XX },
nkeynes@362
   835
  { "rdmsr",		XX, XX, XX },
nkeynes@362
   836
  { "rdpmc",		XX, XX, XX },
nkeynes@362
   837
  { "sysenter",		XX, XX, XX },
nkeynes@362
   838
  { "sysexit",		XX, XX, XX },
nkeynes@362
   839
  { "(bad)",		XX, XX, XX },
nkeynes@362
   840
  { "(bad)",		XX, XX, XX },
nkeynes@362
   841
  /* 38 */
nkeynes@362
   842
  { "(bad)",		XX, XX, XX },
nkeynes@362
   843
  { "(bad)",		XX, XX, XX },
nkeynes@362
   844
  { "(bad)",		XX, XX, XX },
nkeynes@362
   845
  { "(bad)",		XX, XX, XX },
nkeynes@362
   846
  { "(bad)",		XX, XX, XX },
nkeynes@362
   847
  { "(bad)",		XX, XX, XX },
nkeynes@362
   848
  { "(bad)",		XX, XX, XX },
nkeynes@362
   849
  { "(bad)",		XX, XX, XX },
nkeynes@362
   850
  /* 40 */
nkeynes@362
   851
  { "cmovo",		Gv, Ev, XX },
nkeynes@362
   852
  { "cmovno",		Gv, Ev, XX },
nkeynes@362
   853
  { "cmovb",		Gv, Ev, XX },
nkeynes@362
   854
  { "cmovae",		Gv, Ev, XX },
nkeynes@362
   855
  { "cmove",		Gv, Ev, XX },
nkeynes@362
   856
  { "cmovne",		Gv, Ev, XX },
nkeynes@362
   857
  { "cmovbe",		Gv, Ev, XX },
nkeynes@362
   858
  { "cmova",		Gv, Ev, XX },
nkeynes@362
   859
  /* 48 */
nkeynes@362
   860
  { "cmovs",		Gv, Ev, XX },
nkeynes@362
   861
  { "cmovns",		Gv, Ev, XX },
nkeynes@362
   862
  { "cmovp",		Gv, Ev, XX },
nkeynes@362
   863
  { "cmovnp",		Gv, Ev, XX },
nkeynes@362
   864
  { "cmovl",		Gv, Ev, XX },
nkeynes@362
   865
  { "cmovge",		Gv, Ev, XX },
nkeynes@362
   866
  { "cmovle",		Gv, Ev, XX },
nkeynes@362
   867
  { "cmovg",		Gv, Ev, XX },
nkeynes@362
   868
  /* 50 */
nkeynes@362
   869
  { "movmskpX",		Gdq, XS, XX },
nkeynes@362
   870
  { PREGRP13 },
nkeynes@362
   871
  { PREGRP12 },
nkeynes@362
   872
  { PREGRP11 },
nkeynes@362
   873
  { "andpX",		XM, EX, XX },
nkeynes@362
   874
  { "andnpX",		XM, EX, XX },
nkeynes@362
   875
  { "orpX",		XM, EX, XX },
nkeynes@362
   876
  { "xorpX",		XM, EX, XX },
nkeynes@362
   877
  /* 58 */
nkeynes@362
   878
  { PREGRP0 },
nkeynes@362
   879
  { PREGRP10 },
nkeynes@362
   880
  { PREGRP17 },
nkeynes@362
   881
  { PREGRP16 },
nkeynes@362
   882
  { PREGRP14 },
nkeynes@362
   883
  { PREGRP7 },
nkeynes@362
   884
  { PREGRP5 },
nkeynes@362
   885
  { PREGRP6 },
nkeynes@362
   886
  /* 60 */
nkeynes@362
   887
  { "punpcklbw",	MX, EM, XX },
nkeynes@362
   888
  { "punpcklwd",	MX, EM, XX },
nkeynes@362
   889
  { "punpckldq",	MX, EM, XX },
nkeynes@362
   890
  { "packsswb",		MX, EM, XX },
nkeynes@362
   891
  { "pcmpgtb",		MX, EM, XX },
nkeynes@362
   892
  { "pcmpgtw",		MX, EM, XX },
nkeynes@362
   893
  { "pcmpgtd",		MX, EM, XX },
nkeynes@362
   894
  { "packuswb",		MX, EM, XX },
nkeynes@362
   895
  /* 68 */
nkeynes@362
   896
  { "punpckhbw",	MX, EM, XX },
nkeynes@362
   897
  { "punpckhwd",	MX, EM, XX },
nkeynes@362
   898
  { "punpckhdq",	MX, EM, XX },
nkeynes@362
   899
  { "packssdw",		MX, EM, XX },
nkeynes@362
   900
  { PREGRP26 },
nkeynes@362
   901
  { PREGRP24 },
nkeynes@362
   902
  { "movd",		MX, Edq, XX },
nkeynes@362
   903
  { PREGRP19 },
nkeynes@362
   904
  /* 70 */
nkeynes@362
   905
  { PREGRP22 },
nkeynes@362
   906
  { GRP10 },
nkeynes@362
   907
  { GRP11 },
nkeynes@362
   908
  { GRP12 },
nkeynes@362
   909
  { "pcmpeqb",		MX, EM, XX },
nkeynes@362
   910
  { "pcmpeqw",		MX, EM, XX },
nkeynes@362
   911
  { "pcmpeqd",		MX, EM, XX },
nkeynes@362
   912
  { "emms",		XX, XX, XX },
nkeynes@362
   913
  /* 78 */
nkeynes@362
   914
  { "(bad)",		XX, XX, XX },
nkeynes@362
   915
  { "(bad)",		XX, XX, XX },
nkeynes@362
   916
  { "(bad)",		XX, XX, XX },
nkeynes@362
   917
  { "(bad)",		XX, XX, XX },
nkeynes@362
   918
  { PREGRP28 },
nkeynes@362
   919
  { PREGRP29 },
nkeynes@362
   920
  { PREGRP23 },
nkeynes@362
   921
  { PREGRP20 },
nkeynes@362
   922
  /* 80 */
nkeynes@362
   923
  { "joH",		Jv, XX, cond_jump_flag },
nkeynes@362
   924
  { "jnoH",		Jv, XX, cond_jump_flag },
nkeynes@362
   925
  { "jbH",		Jv, XX, cond_jump_flag },
nkeynes@362
   926
  { "jaeH",		Jv, XX, cond_jump_flag },
nkeynes@362
   927
  { "jeH",		Jv, XX, cond_jump_flag },
nkeynes@362
   928
  { "jneH",		Jv, XX, cond_jump_flag },
nkeynes@362
   929
  { "jbeH",		Jv, XX, cond_jump_flag },
nkeynes@362
   930
  { "jaH",		Jv, XX, cond_jump_flag },
nkeynes@362
   931
  /* 88 */
nkeynes@362
   932
  { "jsH",		Jv, XX, cond_jump_flag },
nkeynes@362
   933
  { "jnsH",		Jv, XX, cond_jump_flag },
nkeynes@362
   934
  { "jpH",		Jv, XX, cond_jump_flag },
nkeynes@362
   935
  { "jnpH",		Jv, XX, cond_jump_flag },
nkeynes@362
   936
  { "jlH",		Jv, XX, cond_jump_flag },
nkeynes@362
   937
  { "jgeH",		Jv, XX, cond_jump_flag },
nkeynes@362
   938
  { "jleH",		Jv, XX, cond_jump_flag },
nkeynes@362
   939
  { "jgH",		Jv, XX, cond_jump_flag },
nkeynes@362
   940
  /* 90 */
nkeynes@362
   941
  { "seto",		Eb, XX, XX },
nkeynes@362
   942
  { "setno",		Eb, XX, XX },
nkeynes@362
   943
  { "setb",		Eb, XX, XX },
nkeynes@362
   944
  { "setae",		Eb, XX, XX },
nkeynes@362
   945
  { "sete",		Eb, XX, XX },
nkeynes@362
   946
  { "setne",		Eb, XX, XX },
nkeynes@362
   947
  { "setbe",		Eb, XX, XX },
nkeynes@362
   948
  { "seta",		Eb, XX, XX },
nkeynes@362
   949
  /* 98 */
nkeynes@362
   950
  { "sets",		Eb, XX, XX },
nkeynes@362
   951
  { "setns",		Eb, XX, XX },
nkeynes@362
   952
  { "setp",		Eb, XX, XX },
nkeynes@362
   953
  { "setnp",		Eb, XX, XX },
nkeynes@362
   954
  { "setl",		Eb, XX, XX },
nkeynes@362
   955
  { "setge",		Eb, XX, XX },
nkeynes@362
   956
  { "setle",		Eb, XX, XX },
nkeynes@362
   957
  { "setg",		Eb, XX, XX },
nkeynes@362
   958
  /* a0 */
nkeynes@362
   959
  { "pushT",		fs, XX, XX },
nkeynes@362
   960
  { "popT",		fs, XX, XX },
nkeynes@362
   961
  { "cpuid",		XX, XX, XX },
nkeynes@362
   962
  { "btS",		Ev, Gv, XX },
nkeynes@362
   963
  { "shldS",		Ev, Gv, Ib },
nkeynes@362
   964
  { "shldS",		Ev, Gv, CL },
nkeynes@362
   965
  { GRPPADLCK2 },
nkeynes@362
   966
  { GRPPADLCK1 },
nkeynes@362
   967
  /* a8 */
nkeynes@362
   968
  { "pushT",		gs, XX, XX },
nkeynes@362
   969
  { "popT",		gs, XX, XX },
nkeynes@362
   970
  { "rsm",		XX, XX, XX },
nkeynes@362
   971
  { "btsS",		Ev, Gv, XX },
nkeynes@362
   972
  { "shrdS",		Ev, Gv, Ib },
nkeynes@362
   973
  { "shrdS",		Ev, Gv, CL },
nkeynes@362
   974
  { GRP13 },
nkeynes@362
   975
  { "imulS",		Gv, Ev, XX },
nkeynes@362
   976
  /* b0 */
nkeynes@362
   977
  { "cmpxchgB",		Eb, Gb, XX },
nkeynes@362
   978
  { "cmpxchgS",		Ev, Gv, XX },
nkeynes@362
   979
  { "lssS",		Gv, Mp, XX },
nkeynes@362
   980
  { "btrS",		Ev, Gv, XX },
nkeynes@362
   981
  { "lfsS",		Gv, Mp, XX },
nkeynes@362
   982
  { "lgsS",		Gv, Mp, XX },
nkeynes@362
   983
  { "movz{bR|x|bR|x}",	Gv, Eb, XX },
nkeynes@362
   984
  { "movz{wR|x|wR|x}",	Gv, Ew, XX }, /* yes, there really is movzww ! */
nkeynes@362
   985
  /* b8 */
nkeynes@362
   986
  { "(bad)",		XX, XX, XX },
nkeynes@362
   987
  { "ud2b",		XX, XX, XX },
nkeynes@362
   988
  { GRP8 },
nkeynes@362
   989
  { "btcS",		Ev, Gv, XX },
nkeynes@362
   990
  { "bsfS",		Gv, Ev, XX },
nkeynes@362
   991
  { "bsrS",		Gv, Ev, XX },
nkeynes@362
   992
  { "movs{bR|x|bR|x}",	Gv, Eb, XX },
nkeynes@362
   993
  { "movs{wR|x|wR|x}",	Gv, Ew, XX }, /* yes, there really is movsww ! */
nkeynes@362
   994
  /* c0 */
nkeynes@362
   995
  { "xaddB",		Eb, Gb, XX },
nkeynes@362
   996
  { "xaddS",		Ev, Gv, XX },
nkeynes@362
   997
  { PREGRP1 },
nkeynes@362
   998
  { "movntiS",		Ev, Gv, XX },
nkeynes@362
   999
  { "pinsrw",		MX, Edqw, Ib },
nkeynes@362
  1000
  { "pextrw",		Gdq, MS, Ib },
nkeynes@362
  1001
  { "shufpX",		XM, EX, Ib },
nkeynes@362
  1002
  { GRP9 },
nkeynes@362
  1003
  /* c8 */
nkeynes@362
  1004
  { "bswap",		RMeAX, XX, XX },
nkeynes@362
  1005
  { "bswap",		RMeCX, XX, XX },
nkeynes@362
  1006
  { "bswap",		RMeDX, XX, XX },
nkeynes@362
  1007
  { "bswap",		RMeBX, XX, XX },
nkeynes@362
  1008
  { "bswap",		RMeSP, XX, XX },
nkeynes@362
  1009
  { "bswap",		RMeBP, XX, XX },
nkeynes@362
  1010
  { "bswap",		RMeSI, XX, XX },
nkeynes@362
  1011
  { "bswap",		RMeDI, XX, XX },
nkeynes@362
  1012
  /* d0 */
nkeynes@362
  1013
  { PREGRP27 },
nkeynes@362
  1014
  { "psrlw",		MX, EM, XX },
nkeynes@362
  1015
  { "psrld",		MX, EM, XX },
nkeynes@362
  1016
  { "psrlq",		MX, EM, XX },
nkeynes@362
  1017
  { "paddq",		MX, EM, XX },
nkeynes@362
  1018
  { "pmullw",		MX, EM, XX },
nkeynes@362
  1019
  { PREGRP21 },
nkeynes@362
  1020
  { "pmovmskb",		Gdq, MS, XX },
nkeynes@362
  1021
  /* d8 */
nkeynes@362
  1022
  { "psubusb",		MX, EM, XX },
nkeynes@362
  1023
  { "psubusw",		MX, EM, XX },
nkeynes@362
  1024
  { "pminub",		MX, EM, XX },
nkeynes@362
  1025
  { "pand",		MX, EM, XX },
nkeynes@362
  1026
  { "paddusb",		MX, EM, XX },
nkeynes@362
  1027
  { "paddusw",		MX, EM, XX },
nkeynes@362
  1028
  { "pmaxub",		MX, EM, XX },
nkeynes@362
  1029
  { "pandn",		MX, EM, XX },
nkeynes@362
  1030
  /* e0 */
nkeynes@362
  1031
  { "pavgb",		MX, EM, XX },
nkeynes@362
  1032
  { "psraw",		MX, EM, XX },
nkeynes@362
  1033
  { "psrad",		MX, EM, XX },
nkeynes@362
  1034
  { "pavgw",		MX, EM, XX },
nkeynes@362
  1035
  { "pmulhuw",		MX, EM, XX },
nkeynes@362
  1036
  { "pmulhw",		MX, EM, XX },
nkeynes@362
  1037
  { PREGRP15 },
nkeynes@362
  1038
  { PREGRP25 },
nkeynes@362
  1039
  /* e8 */
nkeynes@362
  1040
  { "psubsb",		MX, EM, XX },
nkeynes@362
  1041
  { "psubsw",		MX, EM, XX },
nkeynes@362
  1042
  { "pminsw",		MX, EM, XX },
nkeynes@362
  1043
  { "por",		MX, EM, XX },
nkeynes@362
  1044
  { "paddsb",		MX, EM, XX },
nkeynes@362
  1045
  { "paddsw",		MX, EM, XX },
nkeynes@362
  1046
  { "pmaxsw",		MX, EM, XX },
nkeynes@362
  1047
  { "pxor",		MX, EM, XX },
nkeynes@362
  1048
  /* f0 */
nkeynes@362
  1049
  { PREGRP32 },
nkeynes@362
  1050
  { "psllw",		MX, EM, XX },
nkeynes@362
  1051
  { "pslld",		MX, EM, XX },
nkeynes@362
  1052
  { "psllq",		MX, EM, XX },
nkeynes@362
  1053
  { "pmuludq",		MX, EM, XX },
nkeynes@362
  1054
  { "pmaddwd",		MX, EM, XX },
nkeynes@362
  1055
  { "psadbw",		MX, EM, XX },
nkeynes@362
  1056
  { PREGRP18 },
nkeynes@362
  1057
  /* f8 */
nkeynes@362
  1058
  { "psubb",		MX, EM, XX },
nkeynes@362
  1059
  { "psubw",		MX, EM, XX },
nkeynes@362
  1060
  { "psubd",		MX, EM, XX },
nkeynes@362
  1061
  { "psubq",		MX, EM, XX },
nkeynes@362
  1062
  { "paddb",		MX, EM, XX },
nkeynes@362
  1063
  { "paddw",		MX, EM, XX },
nkeynes@362
  1064
  { "paddd",		MX, EM, XX },
nkeynes@362
  1065
  { "(bad)",		XX, XX, XX }
nkeynes@362
  1066
};
nkeynes@362
  1067
nkeynes@362
  1068
static const unsigned char onebyte_has_modrm[256] = {
nkeynes@362
  1069
  /*       0 1 2 3 4 5 6 7 8 9 a b c d e f        */
nkeynes@362
  1070
  /*       -------------------------------        */
nkeynes@362
  1071
  /* 00 */ 1,1,1,1,0,0,0,0,1,1,1,1,0,0,0,0, /* 00 */
nkeynes@362
  1072
  /* 10 */ 1,1,1,1,0,0,0,0,1,1,1,1,0,0,0,0, /* 10 */
nkeynes@362
  1073
  /* 20 */ 1,1,1,1,0,0,0,0,1,1,1,1,0,0,0,0, /* 20 */
nkeynes@362
  1074
  /* 30 */ 1,1,1,1,0,0,0,0,1,1,1,1,0,0,0,0, /* 30 */
nkeynes@362
  1075
  /* 40 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 40 */
nkeynes@362
  1076
  /* 50 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 50 */
nkeynes@362
  1077
  /* 60 */ 0,0,1,1,0,0,0,0,0,1,0,1,0,0,0,0, /* 60 */
nkeynes@362
  1078
  /* 70 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 70 */
nkeynes@362
  1079
  /* 80 */ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, /* 80 */
nkeynes@362
  1080
  /* 90 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 90 */
nkeynes@362
  1081
  /* a0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* a0 */
nkeynes@362
  1082
  /* b0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* b0 */
nkeynes@362
  1083
  /* c0 */ 1,1,0,0,1,1,1,1,0,0,0,0,0,0,0,0, /* c0 */
nkeynes@362
  1084
  /* d0 */ 1,1,1,1,0,0,0,0,1,1,1,1,1,1,1,1, /* d0 */
nkeynes@362
  1085
  /* e0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* e0 */
nkeynes@362
  1086
  /* f0 */ 0,0,0,0,0,0,1,1,0,0,0,0,0,0,1,1  /* f0 */
nkeynes@362
  1087
  /*       -------------------------------        */
nkeynes@362
  1088
  /*       0 1 2 3 4 5 6 7 8 9 a b c d e f        */
nkeynes@362
  1089
};
nkeynes@362
  1090
nkeynes@362
  1091
static const unsigned char twobyte_has_modrm[256] = {
nkeynes@362
  1092
  /*       0 1 2 3 4 5 6 7 8 9 a b c d e f        */
nkeynes@362
  1093
  /*       -------------------------------        */
nkeynes@362
  1094
  /* 00 */ 1,1,1,1,0,0,0,0,0,0,0,0,0,1,0,1, /* 0f */
nkeynes@362
  1095
  /* 10 */ 1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0, /* 1f */
nkeynes@362
  1096
  /* 20 */ 1,1,1,1,1,0,1,0,1,1,1,1,1,1,1,1, /* 2f */
nkeynes@362
  1097
  /* 30 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 3f */
nkeynes@362
  1098
  /* 40 */ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, /* 4f */
nkeynes@362
  1099
  /* 50 */ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, /* 5f */
nkeynes@362
  1100
  /* 60 */ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, /* 6f */
nkeynes@362
  1101
  /* 70 */ 1,1,1,1,1,1,1,0,0,0,0,0,1,1,1,1, /* 7f */
nkeynes@362
  1102
  /* 80 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 8f */
nkeynes@362
  1103
  /* 90 */ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, /* 9f */
nkeynes@362
  1104
  /* a0 */ 0,0,0,1,1,1,1,1,0,0,0,1,1,1,1,1, /* af */
nkeynes@362
  1105
  /* b0 */ 1,1,1,1,1,1,1,1,0,0,1,1,1,1,1,1, /* bf */
nkeynes@362
  1106
  /* c0 */ 1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0, /* cf */
nkeynes@362
  1107
  /* d0 */ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, /* df */
nkeynes@362
  1108
  /* e0 */ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, /* ef */
nkeynes@362
  1109
  /* f0 */ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0  /* ff */
nkeynes@362
  1110
  /*       -------------------------------        */
nkeynes@362
  1111
  /*       0 1 2 3 4 5 6 7 8 9 a b c d e f        */
nkeynes@362
  1112
};
nkeynes@362
  1113
nkeynes@362
  1114
static const unsigned char twobyte_uses_SSE_prefix[256] = {
nkeynes@362
  1115
  /*       0 1 2 3 4 5 6 7 8 9 a b c d e f        */
nkeynes@362
  1116
  /*       -------------------------------        */
nkeynes@362
  1117
  /* 00 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0f */
nkeynes@362
  1118
  /* 10 */ 1,1,1,0,0,0,1,0,0,0,0,0,0,0,0,0, /* 1f */
nkeynes@362
  1119
  /* 20 */ 0,0,0,0,0,0,0,0,0,0,1,0,1,1,0,0, /* 2f */
nkeynes@362
  1120
  /* 30 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 3f */
nkeynes@362
  1121
  /* 40 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 4f */
nkeynes@362
  1122
  /* 50 */ 0,1,1,1,0,0,0,0,1,1,1,1,1,1,1,1, /* 5f */
nkeynes@362
  1123
  /* 60 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1, /* 6f */
nkeynes@362
  1124
  /* 70 */ 1,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1, /* 7f */
nkeynes@362
  1125
  /* 80 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 8f */
nkeynes@362
  1126
  /* 90 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 9f */
nkeynes@362
  1127
  /* a0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* af */
nkeynes@362
  1128
  /* b0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* bf */
nkeynes@362
  1129
  /* c0 */ 0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0, /* cf */
nkeynes@362
  1130
  /* d0 */ 1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0, /* df */
nkeynes@362
  1131
  /* e0 */ 0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0, /* ef */
nkeynes@362
  1132
  /* f0 */ 1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0  /* ff */
nkeynes@362
  1133
  /*       -------------------------------        */
nkeynes@362
  1134
  /*       0 1 2 3 4 5 6 7 8 9 a b c d e f        */
nkeynes@362
  1135
};
nkeynes@362
  1136
nkeynes@362
  1137
static char obuf[100];
nkeynes@362
  1138
static char *obufp;
nkeynes@362
  1139
static char scratchbuf[100];
nkeynes@362
  1140
static unsigned char *start_codep;
nkeynes@362
  1141
static unsigned char *insn_codep;
nkeynes@362
  1142
static unsigned char *codep;
nkeynes@362
  1143
static disassemble_info *the_info;
nkeynes@362
  1144
static int mod;
nkeynes@362
  1145
static int rm;
nkeynes@362
  1146
static int reg;
nkeynes@362
  1147
static unsigned char need_modrm;
nkeynes@362
  1148
nkeynes@362
  1149
/* If we are accessing mod/rm/reg without need_modrm set, then the
nkeynes@362
  1150
   values are stale.  Hitting this abort likely indicates that you
nkeynes@362
  1151
   need to update onebyte_has_modrm or twobyte_has_modrm.  */
nkeynes@362
  1152
#define MODRM_CHECK  if (!need_modrm) abort ()
nkeynes@362
  1153
nkeynes@362
  1154
static const char **names64;
nkeynes@362
  1155
static const char **names32;
nkeynes@362
  1156
static const char **names16;
nkeynes@362
  1157
static const char **names8;
nkeynes@362
  1158
static const char **names8rex;
nkeynes@362
  1159
static const char **names_seg;
nkeynes@362
  1160
static const char **index16;
nkeynes@362
  1161
nkeynes@362
  1162
static const char *intel_names64[] = {
nkeynes@362
  1163
  "rax", "rcx", "rdx", "rbx", "rsp", "rbp", "rsi", "rdi",
nkeynes@362
  1164
  "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15"
nkeynes@362
  1165
};
nkeynes@362
  1166
static const char *intel_names32[] = {
nkeynes@362
  1167
  "eax", "ecx", "edx", "ebx", "esp", "ebp", "esi", "edi",
nkeynes@362
  1168
  "r8d", "r9d", "r10d", "r11d", "r12d", "r13d", "r14d", "r15d"
nkeynes@362
  1169
};
nkeynes@362
  1170
static const char *intel_names16[] = {
nkeynes@362
  1171
  "ax", "cx", "dx", "bx", "sp", "bp", "si", "di",
nkeynes@362
  1172
  "r8w", "r9w", "r10w", "r11w", "r12w", "r13w", "r14w", "r15w"
nkeynes@362
  1173
};
nkeynes@362
  1174
static const char *intel_names8[] = {
nkeynes@362
  1175
  "al", "cl", "dl", "bl", "ah", "ch", "dh", "bh",
nkeynes@362
  1176
};
nkeynes@362
  1177
static const char *intel_names8rex[] = {
nkeynes@362
  1178
  "al", "cl", "dl", "bl", "spl", "bpl", "sil", "dil",
nkeynes@362
  1179
  "r8b", "r9b", "r10b", "r11b", "r12b", "r13b", "r14b", "r15b"
nkeynes@362
  1180
};
nkeynes@362
  1181
static const char *intel_names_seg[] = {
nkeynes@362
  1182
  "es", "cs", "ss", "ds", "fs", "gs", "?", "?",
nkeynes@362
  1183
};
nkeynes@362
  1184
static const char *intel_index16[] = {
nkeynes@362
  1185
  "bx+si", "bx+di", "bp+si", "bp+di", "si", "di", "bp", "bx"
nkeynes@362
  1186
};
nkeynes@362
  1187
nkeynes@362
  1188
static const char *att_names64[] = {
nkeynes@362
  1189
  "%rax", "%rcx", "%rdx", "%rbx", "%rsp", "%rbp", "%rsi", "%rdi",
nkeynes@362
  1190
  "%r8", "%r9", "%r10", "%r11", "%r12", "%r13", "%r14", "%r15"
nkeynes@362
  1191
};
nkeynes@362
  1192
static const char *att_names32[] = {
nkeynes@362
  1193
  "%eax", "%ecx", "%edx", "%ebx", "%esp", "%ebp", "%esi", "%edi",
nkeynes@362
  1194
  "%r8d", "%r9d", "%r10d", "%r11d", "%r12d", "%r13d", "%r14d", "%r15d"
nkeynes@362
  1195
};
nkeynes@362
  1196
static const char *att_names16[] = {
nkeynes@362
  1197
  "%ax", "%cx", "%dx", "%bx", "%sp", "%bp", "%si", "%di",
nkeynes@362
  1198
  "%r8w", "%r9w", "%r10w", "%r11w", "%r12w", "%r13w", "%r14w", "%r15w"
nkeynes@362
  1199
};
nkeynes@362
  1200
static const char *att_names8[] = {
nkeynes@362
  1201
  "%al", "%cl", "%dl", "%bl", "%ah", "%ch", "%dh", "%bh",
nkeynes@362
  1202
};
nkeynes@362
  1203
static const char *att_names8rex[] = {
nkeynes@362
  1204
  "%al", "%cl", "%dl", "%bl", "%spl", "%bpl", "%sil", "%dil",
nkeynes@362
  1205
  "%r8b", "%r9b", "%r10b", "%r11b", "%r12b", "%r13b", "%r14b", "%r15b"
nkeynes@362
  1206
};
nkeynes@362
  1207
static const char *att_names_seg[] = {
nkeynes@362
  1208
  "%es", "%cs", "%ss", "%ds", "%fs", "%gs", "%?", "%?",
nkeynes@362
  1209
};
nkeynes@362
  1210
static const char *att_index16[] = {
nkeynes@362
  1211
  "%bx,%si", "%bx,%di", "%bp,%si", "%bp,%di", "%si", "%di", "%bp", "%bx"
nkeynes@362
  1212
};
nkeynes@362
  1213
nkeynes@362
  1214
static const struct dis386 grps[][8] = {
nkeynes@362
  1215
  /* GRP1b */
nkeynes@362
  1216
  {
nkeynes@362
  1217
    { "addA",	Eb, Ib, XX },
nkeynes@362
  1218
    { "orA",	Eb, Ib, XX },
nkeynes@362
  1219
    { "adcA",	Eb, Ib, XX },
nkeynes@362
  1220
    { "sbbA",	Eb, Ib, XX },
nkeynes@362
  1221
    { "andA",	Eb, Ib, XX },
nkeynes@362
  1222
    { "subA",	Eb, Ib, XX },
nkeynes@362
  1223
    { "xorA",	Eb, Ib, XX },
nkeynes@362
  1224
    { "cmpA",	Eb, Ib, XX }
nkeynes@362
  1225
  },
nkeynes@362
  1226
  /* GRP1S */
nkeynes@362
  1227
  {
nkeynes@362
  1228
    { "addQ",	Ev, Iv, XX },
nkeynes@362
  1229
    { "orQ",	Ev, Iv, XX },
nkeynes@362
  1230
    { "adcQ",	Ev, Iv, XX },
nkeynes@362
  1231
    { "sbbQ",	Ev, Iv, XX },
nkeynes@362
  1232
    { "andQ",	Ev, Iv, XX },
nkeynes@362
  1233
    { "subQ",	Ev, Iv, XX },
nkeynes@362
  1234
    { "xorQ",	Ev, Iv, XX },
nkeynes@362
  1235
    { "cmpQ",	Ev, Iv, XX }
nkeynes@362
  1236
  },
nkeynes@362
  1237
  /* GRP1Ss */
nkeynes@362
  1238
  {
nkeynes@362
  1239
    { "addQ",	Ev, sIb, XX },
nkeynes@362
  1240
    { "orQ",	Ev, sIb, XX },
nkeynes@362
  1241
    { "adcQ",	Ev, sIb, XX },
nkeynes@362
  1242
    { "sbbQ",	Ev, sIb, XX },
nkeynes@362
  1243
    { "andQ",	Ev, sIb, XX },
nkeynes@362
  1244
    { "subQ",	Ev, sIb, XX },
nkeynes@362
  1245
    { "xorQ",	Ev, sIb, XX },
nkeynes@362
  1246
    { "cmpQ",	Ev, sIb, XX }
nkeynes@362
  1247
  },
nkeynes@362
  1248
  /* GRP2b */
nkeynes@362
  1249
  {
nkeynes@362
  1250
    { "rolA",	Eb, Ib, XX },
nkeynes@362
  1251
    { "rorA",	Eb, Ib, XX },
nkeynes@362
  1252
    { "rclA",	Eb, Ib, XX },
nkeynes@362
  1253
    { "rcrA",	Eb, Ib, XX },
nkeynes@362
  1254
    { "shlA",	Eb, Ib, XX },
nkeynes@362
  1255
    { "shrA",	Eb, Ib, XX },
nkeynes@362
  1256
    { "(bad)",	XX, XX, XX },
nkeynes@362
  1257
    { "sarA",	Eb, Ib, XX },
nkeynes@362
  1258
  },
nkeynes@362
  1259
  /* GRP2S */
nkeynes@362
  1260
  {
nkeynes@362
  1261
    { "rolQ",	Ev, Ib, XX },
nkeynes@362
  1262
    { "rorQ",	Ev, Ib, XX },
nkeynes@362
  1263
    { "rclQ",	Ev, Ib, XX },
nkeynes@362
  1264
    { "rcrQ",	Ev, Ib, XX },
nkeynes@362
  1265
    { "shlQ",	Ev, Ib, XX },
nkeynes@362
  1266
    { "shrQ",	Ev, Ib, XX },
nkeynes@362
  1267
    { "(bad)",	XX, XX, XX },
nkeynes@362
  1268
    { "sarQ",	Ev, Ib, XX },
nkeynes@362
  1269
  },
nkeynes@362
  1270
  /* GRP2b_one */
nkeynes@362
  1271
  {
nkeynes@362
  1272
    { "rolA",	Eb, I1, XX },
nkeynes@362
  1273
    { "rorA",	Eb, I1, XX },
nkeynes@362
  1274
    { "rclA",	Eb, I1, XX },
nkeynes@362
  1275
    { "rcrA",	Eb, I1, XX },
nkeynes@362
  1276
    { "shlA",	Eb, I1, XX },
nkeynes@362
  1277
    { "shrA",	Eb, I1, XX },
nkeynes@362
  1278
    { "(bad)",	XX, XX, XX },
nkeynes@362
  1279
    { "sarA",	Eb, I1, XX },
nkeynes@362
  1280
  },
nkeynes@362
  1281
  /* GRP2S_one */
nkeynes@362
  1282
  {
nkeynes@362
  1283
    { "rolQ",	Ev, I1, XX },
nkeynes@362
  1284
    { "rorQ",	Ev, I1, XX },
nkeynes@362
  1285
    { "rclQ",	Ev, I1, XX },
nkeynes@362
  1286
    { "rcrQ",	Ev, I1, XX },
nkeynes@362
  1287
    { "shlQ",	Ev, I1, XX },
nkeynes@362
  1288
    { "shrQ",	Ev, I1, XX },
nkeynes@362
  1289
    { "(bad)",	XX, XX, XX},
nkeynes@362
  1290
    { "sarQ",	Ev, I1, XX },
nkeynes@362
  1291
  },
nkeynes@362
  1292
  /* GRP2b_cl */
nkeynes@362
  1293
  {
nkeynes@362
  1294
    { "rolA",	Eb, CL, XX },
nkeynes@362
  1295
    { "rorA",	Eb, CL, XX },
nkeynes@362
  1296
    { "rclA",	Eb, CL, XX },
nkeynes@362
  1297
    { "rcrA",	Eb, CL, XX },
nkeynes@362
  1298
    { "shlA",	Eb, CL, XX },
nkeynes@362
  1299
    { "shrA",	Eb, CL, XX },
nkeynes@362
  1300
    { "(bad)",	XX, XX, XX },
nkeynes@362
  1301
    { "sarA",	Eb, CL, XX },
nkeynes@362
  1302
  },
nkeynes@362
  1303
  /* GRP2S_cl */
nkeynes@362
  1304
  {
nkeynes@362
  1305
    { "rolQ",	Ev, CL, XX },
nkeynes@362
  1306
    { "rorQ",	Ev, CL, XX },
nkeynes@362
  1307
    { "rclQ",	Ev, CL, XX },
nkeynes@362
  1308
    { "rcrQ",	Ev, CL, XX },
nkeynes@362
  1309
    { "shlQ",	Ev, CL, XX },
nkeynes@362
  1310
    { "shrQ",	Ev, CL, XX },
nkeynes@362
  1311
    { "(bad)",	XX, XX, XX },
nkeynes@362
  1312
    { "sarQ",	Ev, CL, XX }
nkeynes@362
  1313
  },
nkeynes@362
  1314
  /* GRP3b */
nkeynes@362
  1315
  {
nkeynes@362
  1316
    { "testA",	Eb, Ib, XX },
nkeynes@362
  1317
    { "(bad)",	Eb, XX, XX },
nkeynes@362
  1318
    { "notA",	Eb, XX, XX },
nkeynes@362
  1319
    { "negA",	Eb, XX, XX },
nkeynes@362
  1320
    { "mulA",	Eb, XX, XX },	/* Don't print the implicit %al register,  */
nkeynes@362
  1321
    { "imulA",	Eb, XX, XX },	/* to distinguish these opcodes from other */
nkeynes@362
  1322
    { "divA",	Eb, XX, XX },	/* mul/imul opcodes.  Do the same for div  */
nkeynes@362
  1323
    { "idivA",	Eb, XX, XX }	/* and idiv for consistency.		   */
nkeynes@362
  1324
  },
nkeynes@362
  1325
  /* GRP3S */
nkeynes@362
  1326
  {
nkeynes@362
  1327
    { "testQ",	Ev, Iv, XX },
nkeynes@362
  1328
    { "(bad)",	XX, XX, XX },
nkeynes@362
  1329
    { "notQ",	Ev, XX, XX },
nkeynes@362
  1330
    { "negQ",	Ev, XX, XX },
nkeynes@362
  1331
    { "mulQ",	Ev, XX, XX },	/* Don't print the implicit register.  */
nkeynes@362
  1332
    { "imulQ",	Ev, XX, XX },
nkeynes@362
  1333
    { "divQ",	Ev, XX, XX },
nkeynes@362
  1334
    { "idivQ",	Ev, XX, XX },
nkeynes@362
  1335
  },
nkeynes@362
  1336
  /* GRP4 */
nkeynes@362
  1337
  {
nkeynes@362
  1338
    { "incA",	Eb, XX, XX },
nkeynes@362
  1339
    { "decA",	Eb, XX, XX },
nkeynes@362
  1340
    { "(bad)",	XX, XX, XX },
nkeynes@362
  1341
    { "(bad)",	XX, XX, XX },
nkeynes@362
  1342
    { "(bad)",	XX, XX, XX },
nkeynes@362
  1343
    { "(bad)",	XX, XX, XX },
nkeynes@362
  1344
    { "(bad)",	XX, XX, XX },
nkeynes@362
  1345
    { "(bad)",	XX, XX, XX },
nkeynes@362
  1346
  },
nkeynes@362
  1347
  /* GRP5 */
nkeynes@362
  1348
  {
nkeynes@362
  1349
    { "incQ",	Ev, XX, XX },
nkeynes@362
  1350
    { "decQ",	Ev, XX, XX },
nkeynes@362
  1351
    { "callT",	indirEv, XX, XX },
nkeynes@362
  1352
    { "JcallT",	indirEp, XX, XX },
nkeynes@362
  1353
    { "jmpT",	indirEv, XX, XX },
nkeynes@362
  1354
    { "JjmpT",	indirEp, XX, XX },
nkeynes@362
  1355
    { "pushU",	Ev, XX, XX },
nkeynes@362
  1356
    { "(bad)",	XX, XX, XX },
nkeynes@362
  1357
  },
nkeynes@362
  1358
  /* GRP6 */
nkeynes@362
  1359
  {
nkeynes@362
  1360
    { "sldtQ",	Ev, XX, XX },
nkeynes@362
  1361
    { "strQ",	Ev, XX, XX },
nkeynes@362
  1362
    { "lldt",	Ew, XX, XX },
nkeynes@362
  1363
    { "ltr",	Ew, XX, XX },
nkeynes@362
  1364
    { "verr",	Ew, XX, XX },
nkeynes@362
  1365
    { "verw",	Ew, XX, XX },
nkeynes@362
  1366
    { "(bad)",	XX, XX, XX },
nkeynes@362
  1367
    { "(bad)",	XX, XX, XX }
nkeynes@362
  1368
  },
nkeynes@362
  1369
  /* GRP7 */
nkeynes@362
  1370
  {
nkeynes@362
  1371
    { "sgdtIQ",	 M, XX, XX },
nkeynes@362
  1372
    { "sidtIQ", PNI_Fixup, 0, XX, XX },
nkeynes@362
  1373
    { "lgdt{Q|Q||}",	 M, XX, XX },
nkeynes@362
  1374
    { "lidt{Q|Q||}",	 M, XX, XX },
nkeynes@362
  1375
    { "smswQ",	Ev, XX, XX },
nkeynes@362
  1376
    { "(bad)",	XX, XX, XX },
nkeynes@362
  1377
    { "lmsw",	Ew, XX, XX },
nkeynes@362
  1378
    { "invlpg",	INVLPG_Fixup, w_mode, XX, XX },
nkeynes@362
  1379
  },
nkeynes@362
  1380
  /* GRP8 */
nkeynes@362
  1381
  {
nkeynes@362
  1382
    { "(bad)",	XX, XX, XX },
nkeynes@362
  1383
    { "(bad)",	XX, XX, XX },
nkeynes@362
  1384
    { "(bad)",	XX, XX, XX },
nkeynes@362
  1385
    { "(bad)",	XX, XX, XX },
nkeynes@362
  1386
    { "btQ",	Ev, Ib, XX },
nkeynes@362
  1387
    { "btsQ",	Ev, Ib, XX },
nkeynes@362
  1388
    { "btrQ",	Ev, Ib, XX },
nkeynes@362
  1389
    { "btcQ",	Ev, Ib, XX },
nkeynes@362
  1390
  },
nkeynes@362
  1391
  /* GRP9 */
nkeynes@362
  1392
  {
nkeynes@362
  1393
    { "(bad)",	XX, XX, XX },
nkeynes@362
  1394
    { "cmpxchg8b", Eq, XX, XX },
nkeynes@362
  1395
    { "(bad)",	XX, XX, XX },
nkeynes@362
  1396
    { "(bad)",	XX, XX, XX },
nkeynes@362
  1397
    { "(bad)",	XX, XX, XX },
nkeynes@362
  1398
    { "(bad)",	XX, XX, XX },
nkeynes@362
  1399
    { "(bad)",	XX, XX, XX },
nkeynes@362
  1400
    { "(bad)",	XX, XX, XX },
nkeynes@362
  1401
  },
nkeynes@362
  1402
  /* GRP10 */
nkeynes@362
  1403
  {
nkeynes@362
  1404
    { "(bad)",	XX, XX, XX },
nkeynes@362
  1405
    { "(bad)",	XX, XX, XX },
nkeynes@362
  1406
    { "psrlw",	MS, Ib, XX },
nkeynes@362
  1407
    { "(bad)",	XX, XX, XX },
nkeynes@362
  1408
    { "psraw",	MS, Ib, XX },
nkeynes@362
  1409
    { "(bad)",	XX, XX, XX },
nkeynes@362
  1410
    { "psllw",	MS, Ib, XX },
nkeynes@362
  1411
    { "(bad)",	XX, XX, XX },
nkeynes@362
  1412
  },
nkeynes@362
  1413
  /* GRP11 */
nkeynes@362
  1414
  {
nkeynes@362
  1415
    { "(bad)",	XX, XX, XX },
nkeynes@362
  1416
    { "(bad)",	XX, XX, XX },
nkeynes@362
  1417
    { "psrld",	MS, Ib, XX },
nkeynes@362
  1418
    { "(bad)",	XX, XX, XX },
nkeynes@362
  1419
    { "psrad",	MS, Ib, XX },
nkeynes@362
  1420
    { "(bad)",	XX, XX, XX },
nkeynes@362
  1421
    { "pslld",	MS, Ib, XX },
nkeynes@362
  1422
    { "(bad)",	XX, XX, XX },
nkeynes@362
  1423
  },
nkeynes@362
  1424
  /* GRP12 */
nkeynes@362
  1425
  {
nkeynes@362
  1426
    { "(bad)",	XX, XX, XX },
nkeynes@362
  1427
    { "(bad)",	XX, XX, XX },
nkeynes@362
  1428
    { "psrlq",	MS, Ib, XX },
nkeynes@362
  1429
    { "psrldq",	MS, Ib, XX },
nkeynes@362
  1430
    { "(bad)",	XX, XX, XX },
nkeynes@362
  1431
    { "(bad)",	XX, XX, XX },
nkeynes@362
  1432
    { "psllq",	MS, Ib, XX },
nkeynes@362
  1433
    { "pslldq",	MS, Ib, XX },
nkeynes@362
  1434
  },
nkeynes@362
  1435
  /* GRP13 */
nkeynes@362
  1436
  {
nkeynes@362
  1437
    { "fxsave", Ev, XX, XX },
nkeynes@362
  1438
    { "fxrstor", Ev, XX, XX },
nkeynes@362
  1439
    { "ldmxcsr", Ev, XX, XX },
nkeynes@362
  1440
    { "stmxcsr", Ev, XX, XX },
nkeynes@362
  1441
    { "(bad)",	XX, XX, XX },
nkeynes@362
  1442
    { "lfence", OP_0fae, 0, XX, XX },
nkeynes@362
  1443
    { "mfence", OP_0fae, 0, XX, XX },
nkeynes@362
  1444
    { "clflush", OP_0fae, 0, XX, XX },
nkeynes@362
  1445
  },
nkeynes@362
  1446
  /* GRP14 */
nkeynes@362
  1447
  {
nkeynes@362
  1448
    { "prefetchnta", Ev, XX, XX },
nkeynes@362
  1449
    { "prefetcht0", Ev, XX, XX },
nkeynes@362
  1450
    { "prefetcht1", Ev, XX, XX },
nkeynes@362
  1451
    { "prefetcht2", Ev, XX, XX },
nkeynes@362
  1452
    { "(bad)",	XX, XX, XX },
nkeynes@362
  1453
    { "(bad)",	XX, XX, XX },
nkeynes@362
  1454
    { "(bad)",	XX, XX, XX },
nkeynes@362
  1455
    { "(bad)",	XX, XX, XX },
nkeynes@362
  1456
  },
nkeynes@362
  1457
  /* GRPAMD */
nkeynes@362
  1458
  {
nkeynes@362
  1459
    { "prefetch", Eb, XX, XX },
nkeynes@362
  1460
    { "prefetchw", Eb, XX, XX },
nkeynes@362
  1461
    { "(bad)",	XX, XX, XX },
nkeynes@362
  1462
    { "(bad)",	XX, XX, XX },
nkeynes@362
  1463
    { "(bad)",	XX, XX, XX },
nkeynes@362
  1464
    { "(bad)",	XX, XX, XX },
nkeynes@362
  1465
    { "(bad)",	XX, XX, XX },
nkeynes@362
  1466
    { "(bad)",	XX, XX, XX },
nkeynes@362
  1467
  },
nkeynes@362
  1468
  /* GRPPADLCK1 */
nkeynes@362
  1469
  {
nkeynes@362
  1470
    { "xstorerng", OP_0f07, 0, XX, XX },
nkeynes@362
  1471
    { "xcryptecb", OP_0f07, 0, XX, XX },
nkeynes@362
  1472
    { "xcryptcbc", OP_0f07, 0, XX, XX },
nkeynes@362
  1473
    { "(bad)",	   OP_0f07, 0, XX, XX },
nkeynes@362
  1474
    { "xcryptcfb", OP_0f07, 0, XX, XX },
nkeynes@362
  1475
    { "xcryptofb", OP_0f07, 0, XX, XX },
nkeynes@362
  1476
    { "(bad)",	   OP_0f07, 0, XX, XX },
nkeynes@362
  1477
    { "(bad)",	   OP_0f07, 0, XX, XX },
nkeynes@362
  1478
  },
nkeynes@362
  1479
  /* GRPPADLCK2 */
nkeynes@362
  1480
  {
nkeynes@362
  1481
    { "montmul", OP_0f07, 0, XX, XX },
nkeynes@362
  1482
    { "xsha1",   OP_0f07, 0, XX, XX },
nkeynes@362
  1483
    { "xsha256", OP_0f07, 0, XX, XX },
nkeynes@362
  1484
    { "(bad)",	 OP_0f07, 0, XX, XX },
nkeynes@362
  1485
    { "(bad)",   OP_0f07, 0, XX, XX },
nkeynes@362
  1486
    { "(bad)",   OP_0f07, 0, XX, XX },
nkeynes@362
  1487
    { "(bad)",	 OP_0f07, 0, XX, XX },
nkeynes@362
  1488
    { "(bad)",	 OP_0f07, 0, XX, XX },
nkeynes@362
  1489
  }
nkeynes@362
  1490
};
nkeynes@362
  1491
nkeynes@362
  1492
static const struct dis386 prefix_user_table[][4] = {
nkeynes@362
  1493
  /* PREGRP0 */
nkeynes@362
  1494
  {
nkeynes@362
  1495
    { "addps", XM, EX, XX },
nkeynes@362
  1496
    { "addss", XM, EX, XX },
nkeynes@362
  1497
    { "addpd", XM, EX, XX },
nkeynes@362
  1498
    { "addsd", XM, EX, XX },
nkeynes@362
  1499
  },
nkeynes@362
  1500
  /* PREGRP1 */
nkeynes@362
  1501
  {
nkeynes@362
  1502
    { "", XM, EX, OPSIMD },	/* See OP_SIMD_SUFFIX.  */
nkeynes@362
  1503
    { "", XM, EX, OPSIMD },
nkeynes@362
  1504
    { "", XM, EX, OPSIMD },
nkeynes@362
  1505
    { "", XM, EX, OPSIMD },
nkeynes@362
  1506
  },
nkeynes@362
  1507
  /* PREGRP2 */
nkeynes@362
  1508
  {
nkeynes@362
  1509
    { "cvtpi2ps", XM, EM, XX },
nkeynes@362
  1510
    { "cvtsi2ssY", XM, Ev, XX },
nkeynes@362
  1511
    { "cvtpi2pd", XM, EM, XX },
nkeynes@362
  1512
    { "cvtsi2sdY", XM, Ev, XX },
nkeynes@362
  1513
  },
nkeynes@362
  1514
  /* PREGRP3 */
nkeynes@362
  1515
  {
nkeynes@362
  1516
    { "cvtps2pi", MX, EX, XX },
nkeynes@362
  1517
    { "cvtss2siY", Gv, EX, XX },
nkeynes@362
  1518
    { "cvtpd2pi", MX, EX, XX },
nkeynes@362
  1519
    { "cvtsd2siY", Gv, EX, XX },
nkeynes@362
  1520
  },
nkeynes@362
  1521
  /* PREGRP4 */
nkeynes@362
  1522
  {
nkeynes@362
  1523
    { "cvttps2pi", MX, EX, XX },
nkeynes@362
  1524
    { "cvttss2siY", Gv, EX, XX },
nkeynes@362
  1525
    { "cvttpd2pi", MX, EX, XX },
nkeynes@362
  1526
    { "cvttsd2siY", Gv, EX, XX },
nkeynes@362
  1527
  },
nkeynes@362
  1528
  /* PREGRP5 */
nkeynes@362
  1529
  {
nkeynes@362
  1530
    { "divps", XM, EX, XX },
nkeynes@362
  1531
    { "divss", XM, EX, XX },
nkeynes@362
  1532
    { "divpd", XM, EX, XX },
nkeynes@362
  1533
    { "divsd", XM, EX, XX },
nkeynes@362
  1534
  },
nkeynes@362
  1535
  /* PREGRP6 */
nkeynes@362
  1536
  {
nkeynes@362
  1537
    { "maxps", XM, EX, XX },
nkeynes@362
  1538
    { "maxss", XM, EX, XX },
nkeynes@362
  1539
    { "maxpd", XM, EX, XX },
nkeynes@362
  1540
    { "maxsd", XM, EX, XX },
nkeynes@362
  1541
  },
nkeynes@362
  1542
  /* PREGRP7 */
nkeynes@362
  1543
  {
nkeynes@362
  1544
    { "minps", XM, EX, XX },
nkeynes@362
  1545
    { "minss", XM, EX, XX },
nkeynes@362
  1546
    { "minpd", XM, EX, XX },
nkeynes@362
  1547
    { "minsd", XM, EX, XX },
nkeynes@362
  1548
  },
nkeynes@362
  1549
  /* PREGRP8 */
nkeynes@362
  1550
  {
nkeynes@362
  1551
    { "movups", XM, EX, XX },
nkeynes@362
  1552
    { "movss", XM, EX, XX },
nkeynes@362
  1553
    { "movupd", XM, EX, XX },
nkeynes@362
  1554
    { "movsd", XM, EX, XX },
nkeynes@362
  1555
  },
nkeynes@362
  1556
  /* PREGRP9 */
nkeynes@362
  1557
  {
nkeynes@362
  1558
    { "movups", EX, XM, XX },
nkeynes@362
  1559
    { "movss", EX, XM, XX },
nkeynes@362
  1560
    { "movupd", EX, XM, XX },
nkeynes@362
  1561
    { "movsd", EX, XM, XX },
nkeynes@362
  1562
  },
nkeynes@362
  1563
  /* PREGRP10 */
nkeynes@362
  1564
  {
nkeynes@362
  1565
    { "mulps", XM, EX, XX },
nkeynes@362
  1566
    { "mulss", XM, EX, XX },
nkeynes@362
  1567
    { "mulpd", XM, EX, XX },
nkeynes@362
  1568
    { "mulsd", XM, EX, XX },
nkeynes@362
  1569
  },
nkeynes@362
  1570
  /* PREGRP11 */
nkeynes@362
  1571
  {
nkeynes@362
  1572
    { "rcpps", XM, EX, XX },
nkeynes@362
  1573
    { "rcpss", XM, EX, XX },
nkeynes@362
  1574
    { "(bad)", XM, EX, XX },
nkeynes@362
  1575
    { "(bad)", XM, EX, XX },
nkeynes@362
  1576
  },
nkeynes@362
  1577
  /* PREGRP12 */
nkeynes@362
  1578
  {
nkeynes@362
  1579
    { "rsqrtps", XM, EX, XX },
nkeynes@362
  1580
    { "rsqrtss", XM, EX, XX },
nkeynes@362
  1581
    { "(bad)", XM, EX, XX },
nkeynes@362
  1582
    { "(bad)", XM, EX, XX },
nkeynes@362
  1583
  },
nkeynes@362
  1584
  /* PREGRP13 */
nkeynes@362
  1585
  {
nkeynes@362
  1586
    { "sqrtps", XM, EX, XX },
nkeynes@362
  1587
    { "sqrtss", XM, EX, XX },
nkeynes@362
  1588
    { "sqrtpd", XM, EX, XX },
nkeynes@362
  1589
    { "sqrtsd", XM, EX, XX },
nkeynes@362
  1590
  },
nkeynes@362
  1591
  /* PREGRP14 */
nkeynes@362
  1592
  {
nkeynes@362
  1593
    { "subps", XM, EX, XX },
nkeynes@362
  1594
    { "subss", XM, EX, XX },
nkeynes@362
  1595
    { "subpd", XM, EX, XX },
nkeynes@362
  1596
    { "subsd", XM, EX, XX },
nkeynes@362
  1597
  },
nkeynes@362
  1598
  /* PREGRP15 */
nkeynes@362
  1599
  {
nkeynes@362
  1600
    { "(bad)", XM, EX, XX },
nkeynes@362
  1601
    { "cvtdq2pd", XM, EX, XX },
nkeynes@362
  1602
    { "cvttpd2dq", XM, EX, XX },
nkeynes@362
  1603
    { "cvtpd2dq", XM, EX, XX },
nkeynes@362
  1604
  },
nkeynes@362
  1605
  /* PREGRP16 */
nkeynes@362
  1606
  {
nkeynes@362
  1607
    { "cvtdq2ps", XM, EX, XX },
nkeynes@362
  1608
    { "cvttps2dq",XM, EX, XX },
nkeynes@362
  1609
    { "cvtps2dq",XM, EX, XX },
nkeynes@362
  1610
    { "(bad)", XM, EX, XX },
nkeynes@362
  1611
  },
nkeynes@362
  1612
  /* PREGRP17 */
nkeynes@362
  1613
  {
nkeynes@362
  1614
    { "cvtps2pd", XM, EX, XX },
nkeynes@362
  1615
    { "cvtss2sd", XM, EX, XX },
nkeynes@362
  1616
    { "cvtpd2ps", XM, EX, XX },
nkeynes@362
  1617
    { "cvtsd2ss", XM, EX, XX },
nkeynes@362
  1618
  },
nkeynes@362
  1619
  /* PREGRP18 */
nkeynes@362
  1620
  {
nkeynes@362
  1621
    { "maskmovq", MX, MS, XX },
nkeynes@362
  1622
    { "(bad)", XM, EX, XX },
nkeynes@362
  1623
    { "maskmovdqu", XM, EX, XX },
nkeynes@362
  1624
    { "(bad)", XM, EX, XX },
nkeynes@362
  1625
  },
nkeynes@362
  1626
  /* PREGRP19 */
nkeynes@362
  1627
  {
nkeynes@362
  1628
    { "movq", MX, EM, XX },
nkeynes@362
  1629
    { "movdqu", XM, EX, XX },
nkeynes@362
  1630
    { "movdqa", XM, EX, XX },
nkeynes@362
  1631
    { "(bad)", XM, EX, XX },
nkeynes@362
  1632
  },
nkeynes@362
  1633
  /* PREGRP20 */
nkeynes@362
  1634
  {
nkeynes@362
  1635
    { "movq", EM, MX, XX },
nkeynes@362
  1636
    { "movdqu", EX, XM, XX },
nkeynes@362
  1637
    { "movdqa", EX, XM, XX },
nkeynes@362
  1638
    { "(bad)", EX, XM, XX },
nkeynes@362
  1639
  },
nkeynes@362
  1640
  /* PREGRP21 */
nkeynes@362
  1641
  {
nkeynes@362
  1642
    { "(bad)", EX, XM, XX },
nkeynes@362
  1643
    { "movq2dq", XM, MS, XX },
nkeynes@362
  1644
    { "movq", EX, XM, XX },
nkeynes@362
  1645
    { "movdq2q", MX, XS, XX },
nkeynes@362
  1646
  },
nkeynes@362
  1647
  /* PREGRP22 */
nkeynes@362
  1648
  {
nkeynes@362
  1649
    { "pshufw", MX, EM, Ib },
nkeynes@362
  1650
    { "pshufhw", XM, EX, Ib },
nkeynes@362
  1651
    { "pshufd", XM, EX, Ib },
nkeynes@362
  1652
    { "pshuflw", XM, EX, Ib },
nkeynes@362
  1653
  },
nkeynes@362
  1654
  /* PREGRP23 */
nkeynes@362
  1655
  {
nkeynes@362
  1656
    { "movd", Edq, MX, XX },
nkeynes@362
  1657
    { "movq", XM, EX, XX },
nkeynes@362
  1658
    { "movd", Edq, XM, XX },
nkeynes@362
  1659
    { "(bad)", Ed, XM, XX },
nkeynes@362
  1660
  },
nkeynes@362
  1661
  /* PREGRP24 */
nkeynes@362
  1662
  {
nkeynes@362
  1663
    { "(bad)", MX, EX, XX },
nkeynes@362
  1664
    { "(bad)", XM, EX, XX },
nkeynes@362
  1665
    { "punpckhqdq", XM, EX, XX },
nkeynes@362
  1666
    { "(bad)", XM, EX, XX },
nkeynes@362
  1667
  },
nkeynes@362
  1668
  /* PREGRP25 */
nkeynes@362
  1669
  {
nkeynes@362
  1670
    { "movntq", EM, MX, XX },
nkeynes@362
  1671
    { "(bad)", EM, XM, XX },
nkeynes@362
  1672
    { "movntdq", EM, XM, XX },
nkeynes@362
  1673
    { "(bad)", EM, XM, XX },
nkeynes@362
  1674
  },
nkeynes@362
  1675
  /* PREGRP26 */
nkeynes@362
  1676
  {
nkeynes@362
  1677
    { "(bad)", MX, EX, XX },
nkeynes@362
  1678
    { "(bad)", XM, EX, XX },
nkeynes@362
  1679
    { "punpcklqdq", XM, EX, XX },
nkeynes@362
  1680
    { "(bad)", XM, EX, XX },
nkeynes@362
  1681
  },
nkeynes@362
  1682
  /* PREGRP27 */
nkeynes@362
  1683
  {
nkeynes@362
  1684
    { "(bad)", MX, EX, XX },
nkeynes@362
  1685
    { "(bad)", XM, EX, XX },
nkeynes@362
  1686
    { "addsubpd", XM, EX, XX },
nkeynes@362
  1687
    { "addsubps", XM, EX, XX },
nkeynes@362
  1688
  },
nkeynes@362
  1689
  /* PREGRP28 */
nkeynes@362
  1690
  {
nkeynes@362
  1691
    { "(bad)", MX, EX, XX },
nkeynes@362
  1692
    { "(bad)", XM, EX, XX },
nkeynes@362
  1693
    { "haddpd", XM, EX, XX },
nkeynes@362
  1694
    { "haddps", XM, EX, XX },
nkeynes@362
  1695
  },
nkeynes@362
  1696
  /* PREGRP29 */
nkeynes@362
  1697
  {
nkeynes@362
  1698
    { "(bad)", MX, EX, XX },
nkeynes@362
  1699
    { "(bad)", XM, EX, XX },
nkeynes@362
  1700
    { "hsubpd", XM, EX, XX },
nkeynes@362
  1701
    { "hsubps", XM, EX, XX },
nkeynes@362
  1702
  },
nkeynes@362
  1703
  /* PREGRP30 */
nkeynes@362
  1704
  {
nkeynes@362
  1705
    { "movlpX", XM, EX, SIMD_Fixup, 'h' }, /* really only 2 operands */
nkeynes@362
  1706
    { "movsldup", XM, EX, XX },
nkeynes@362
  1707
    { "movlpd", XM, EX, XX },
nkeynes@362
  1708
    { "movddup", XM, EX, XX },
nkeynes@362
  1709
  },
nkeynes@362
  1710
  /* PREGRP31 */
nkeynes@362
  1711
  {
nkeynes@362
  1712
    { "movhpX", XM, EX, SIMD_Fixup, 'l' },
nkeynes@362
  1713
    { "movshdup", XM, EX, XX },
nkeynes@362
  1714
    { "movhpd", XM, EX, XX },
nkeynes@362
  1715
    { "(bad)", XM, EX, XX },
nkeynes@362
  1716
  },
nkeynes@362
  1717
  /* PREGRP32 */
nkeynes@362
  1718
  {
nkeynes@362
  1719
    { "(bad)", XM, EX, XX },
nkeynes@362
  1720
    { "(bad)", XM, EX, XX },
nkeynes@362
  1721
    { "(bad)", XM, EX, XX },
nkeynes@362
  1722
    { "lddqu", XM, M, XX },
nkeynes@362
  1723
  },
nkeynes@362
  1724
};
nkeynes@362
  1725
nkeynes@362
  1726
static const struct dis386 x86_64_table[][2] = {
nkeynes@362
  1727
  {
nkeynes@362
  1728
    { "arpl", Ew, Gw, XX },
nkeynes@362
  1729
    { "movs{||lq|xd}", Gv, Ed, XX },
nkeynes@362
  1730
  },
nkeynes@362
  1731
};
nkeynes@362
  1732
nkeynes@362
  1733
#define INTERNAL_DISASSEMBLER_ERROR _("<internal disassembler error>")
nkeynes@362
  1734
nkeynes@362
  1735
static void
nkeynes@362
  1736
ckprefix (void)
nkeynes@362
  1737
{
nkeynes@362
  1738
  int newrex;
nkeynes@362
  1739
  rex = 0;
nkeynes@362
  1740
  prefixes = 0;
nkeynes@362
  1741
  used_prefixes = 0;
nkeynes@362
  1742
  rex_used = 0;
nkeynes@362
  1743
  while (1)
nkeynes@362
  1744
    {
nkeynes@362
  1745
      FETCH_DATA (the_info, codep + 1);
nkeynes@362
  1746
      newrex = 0;
nkeynes@362
  1747
      switch (*codep)
nkeynes@362
  1748
	{
nkeynes@362
  1749
	/* REX prefixes family.  */
nkeynes@362
  1750
	case 0x40:
nkeynes@362
  1751
	case 0x41:
nkeynes@362
  1752
	case 0x42:
nkeynes@362
  1753
	case 0x43:
nkeynes@362
  1754
	case 0x44:
nkeynes@362
  1755
	case 0x45:
nkeynes@362
  1756
	case 0x46:
nkeynes@362
  1757
	case 0x47:
nkeynes@362
  1758
	case 0x48:
nkeynes@362
  1759
	case 0x49:
nkeynes@362
  1760
	case 0x4a:
nkeynes@362
  1761
	case 0x4b:
nkeynes@362
  1762
	case 0x4c:
nkeynes@362
  1763
	case 0x4d:
nkeynes@362
  1764
	case 0x4e:
nkeynes@362
  1765
	case 0x4f:
nkeynes@362
  1766
	    if (mode_64bit)
nkeynes@362
  1767
	      newrex = *codep;
nkeynes@362
  1768
	    else
nkeynes@362
  1769
	      return;
nkeynes@362
  1770
	  break;
nkeynes@362
  1771
	case 0xf3:
nkeynes@362
  1772
	  prefixes |= PREFIX_REPZ;
nkeynes@362
  1773
	  break;
nkeynes@362
  1774
	case 0xf2:
nkeynes@362
  1775
	  prefixes |= PREFIX_REPNZ;
nkeynes@362
  1776
	  break;
nkeynes@362
  1777
	case 0xf0:
nkeynes@362
  1778
	  prefixes |= PREFIX_LOCK;
nkeynes@362
  1779
	  break;
nkeynes@362
  1780
	case 0x2e:
nkeynes@362
  1781
	  prefixes |= PREFIX_CS;
nkeynes@362
  1782
	  break;
nkeynes@362
  1783
	case 0x36:
nkeynes@362
  1784
	  prefixes |= PREFIX_SS;
nkeynes@362
  1785
	  break;
nkeynes@362
  1786
	case 0x3e:
nkeynes@362
  1787
	  prefixes |= PREFIX_DS;
nkeynes@362
  1788
	  break;
nkeynes@362
  1789
	case 0x26:
nkeynes@362
  1790
	  prefixes |= PREFIX_ES;
nkeynes@362
  1791
	  break;
nkeynes@362
  1792
	case 0x64:
nkeynes@362
  1793
	  prefixes |= PREFIX_FS;
nkeynes@362
  1794
	  break;
nkeynes@362
  1795
	case 0x65:
nkeynes@362
  1796
	  prefixes |= PREFIX_GS;
nkeynes@362
  1797
	  break;
nkeynes@362
  1798
	case 0x66:
nkeynes@362
  1799
	  prefixes |= PREFIX_DATA;
nkeynes@362
  1800
	  break;
nkeynes@362
  1801
	case 0x67:
nkeynes@362
  1802
	  prefixes |= PREFIX_ADDR;
nkeynes@362
  1803
	  break;
nkeynes@362
  1804
	case FWAIT_OPCODE:
nkeynes@362
  1805
	  /* fwait is really an instruction.  If there are prefixes
nkeynes@362
  1806
	     before the fwait, they belong to the fwait, *not* to the
nkeynes@362
  1807
	     following instruction.  */
nkeynes@362
  1808
	  if (prefixes)
nkeynes@362
  1809
	    {
nkeynes@362
  1810
	      prefixes |= PREFIX_FWAIT;
nkeynes@362
  1811
	      codep++;
nkeynes@362
  1812
	      return;
nkeynes@362
  1813
	    }
nkeynes@362
  1814
	  prefixes = PREFIX_FWAIT;
nkeynes@362
  1815
	  break;
nkeynes@362
  1816
	default:
nkeynes@362
  1817
	  return;
nkeynes@362
  1818
	}
nkeynes@362
  1819
      /* Rex is ignored when followed by another prefix.  */
nkeynes@362
  1820
      if (rex)
nkeynes@362
  1821
	{
nkeynes@362
  1822
	  oappend (prefix_name (rex, 0));
nkeynes@362
  1823
	  oappend (" ");
nkeynes@362
  1824
	}
nkeynes@362
  1825
      rex = newrex;
nkeynes@362
  1826
      codep++;
nkeynes@362
  1827
    }
nkeynes@362
  1828
}
nkeynes@362
  1829
nkeynes@362
  1830
/* Return the name of the prefix byte PREF, or NULL if PREF is not a
nkeynes@362
  1831
   prefix byte.  */
nkeynes@362
  1832
nkeynes@362
  1833
static const char *
nkeynes@362
  1834
prefix_name (int pref, int sizeflag)
nkeynes@362
  1835
{
nkeynes@362
  1836
  switch (pref)
nkeynes@362
  1837
    {
nkeynes@362
  1838
    /* REX prefixes family.  */
nkeynes@362
  1839
    case 0x40:
nkeynes@362
  1840
      return "rex";
nkeynes@362
  1841
    case 0x41:
nkeynes@362
  1842
      return "rexZ";
nkeynes@362
  1843
    case 0x42:
nkeynes@362
  1844
      return "rexY";
nkeynes@362
  1845
    case 0x43:
nkeynes@362
  1846
      return "rexYZ";
nkeynes@362
  1847
    case 0x44:
nkeynes@362
  1848
      return "rexX";
nkeynes@362
  1849
    case 0x45:
nkeynes@362
  1850
      return "rexXZ";
nkeynes@362
  1851
    case 0x46:
nkeynes@362
  1852
      return "rexXY";
nkeynes@362
  1853
    case 0x47:
nkeynes@362
  1854
      return "rexXYZ";
nkeynes@362
  1855
    case 0x48:
nkeynes@362
  1856
      return "rex64";
nkeynes@362
  1857
    case 0x49:
nkeynes@362
  1858
      return "rex64Z";
nkeynes@362
  1859
    case 0x4a:
nkeynes@362
  1860
      return "rex64Y";
nkeynes@362
  1861
    case 0x4b:
nkeynes@362
  1862
      return "rex64YZ";
nkeynes@362
  1863
    case 0x4c:
nkeynes@362
  1864
      return "rex64X";
nkeynes@362
  1865
    case 0x4d:
nkeynes@362
  1866
      return "rex64XZ";
nkeynes@362
  1867
    case 0x4e:
nkeynes@362
  1868
      return "rex64XY";
nkeynes@362
  1869
    case 0x4f:
nkeynes@362
  1870
      return "rex64XYZ";
nkeynes@362
  1871
    case 0xf3:
nkeynes@362
  1872
      return "repz";
nkeynes@362
  1873
    case 0xf2:
nkeynes@362
  1874
      return "repnz";
nkeynes@362
  1875
    case 0xf0:
nkeynes@362
  1876
      return "lock";
nkeynes@362
  1877
    case 0x2e:
nkeynes@362
  1878
      return "cs";
nkeynes@362
  1879
    case 0x36:
nkeynes@362
  1880
      return "ss";
nkeynes@362
  1881
    case 0x3e:
nkeynes@362
  1882
      return "ds";
nkeynes@362
  1883
    case 0x26:
nkeynes@362
  1884
      return "es";
nkeynes@362
  1885
    case 0x64:
nkeynes@362
  1886
      return "fs";
nkeynes@362
  1887
    case 0x65:
nkeynes@362
  1888
      return "gs";
nkeynes@362
  1889
    case 0x66:
nkeynes@362
  1890
      return (sizeflag & DFLAG) ? "data16" : "data32";
nkeynes@362
  1891
    case 0x67:
nkeynes@362
  1892
      if (mode_64bit)
nkeynes@362
  1893
	return (sizeflag & AFLAG) ? "addr32" : "addr64";
nkeynes@362
  1894
      else
nkeynes@362
  1895
	return ((sizeflag & AFLAG) && !mode_64bit) ? "addr16" : "addr32";
nkeynes@362
  1896
    case FWAIT_OPCODE:
nkeynes@362
  1897
      return "fwait";
nkeynes@362
  1898
    default:
nkeynes@362
  1899
      return NULL;
nkeynes@362
  1900
    }
nkeynes@362
  1901
}
nkeynes@362
  1902
nkeynes@362
  1903
static char op1out[100], op2out[100], op3out[100];
nkeynes@362
  1904
static int op_ad, op_index[3];
nkeynes@362
  1905
static int two_source_ops;
nkeynes@362
  1906
static bfd_vma op_address[3];
nkeynes@362
  1907
static bfd_vma op_riprel[3];
nkeynes@362
  1908
static bfd_vma start_pc;
nkeynes@362
  1909

nkeynes@362
  1910
/*
nkeynes@362
  1911
 *   On the 386's of 1988, the maximum length of an instruction is 15 bytes.
nkeynes@362
  1912
 *   (see topic "Redundant prefixes" in the "Differences from 8086"
nkeynes@362
  1913
 *   section of the "Virtual 8086 Mode" chapter.)
nkeynes@362
  1914
 * 'pc' should be the address of this instruction, it will
nkeynes@362
  1915
 *   be used to print the target address if this is a relative jump or call
nkeynes@362
  1916
 * The function returns the length of this instruction in bytes.
nkeynes@362
  1917
 */
nkeynes@362
  1918
nkeynes@362
  1919
static char intel_syntax;
nkeynes@362
  1920
static char open_char;
nkeynes@362
  1921
static char close_char;
nkeynes@362
  1922
static char separator_char;
nkeynes@362
  1923
static char scale_char;
nkeynes@362
  1924
nkeynes@362
  1925
/* Here for backwards compatibility.  When gdb stops using
nkeynes@362
  1926
   print_insn_i386_att and print_insn_i386_intel these functions can
nkeynes@362
  1927
   disappear, and print_insn_i386 be merged into print_insn.  */
nkeynes@362
  1928
int
nkeynes@362
  1929
print_insn_i386_att (bfd_vma pc, disassemble_info *info)
nkeynes@362
  1930
{
nkeynes@362
  1931
  intel_syntax = 0;
nkeynes@362
  1932
nkeynes@362
  1933
  return print_insn (pc, info);
nkeynes@362
  1934
}
nkeynes@362
  1935
nkeynes@362
  1936
int
nkeynes@362
  1937
print_insn_i386_intel (bfd_vma pc, disassemble_info *info)
nkeynes@362
  1938
{
nkeynes@362
  1939
  intel_syntax = 1;
nkeynes@362
  1940
nkeynes@362
  1941
  return print_insn (pc, info);
nkeynes@362
  1942
}
nkeynes@362
  1943
nkeynes@362
  1944
int
nkeynes@362
  1945
print_insn_i386 (bfd_vma pc, disassemble_info *info)
nkeynes@362
  1946
{
nkeynes@362
  1947
  intel_syntax = -1;
nkeynes@362
  1948
nkeynes@362
  1949
  return print_insn (pc, info);
nkeynes@362
  1950
}
nkeynes@362
  1951
nkeynes@362
  1952
static int
nkeynes@362
  1953
print_insn (bfd_vma pc, disassemble_info *info)
nkeynes@362
  1954
{
nkeynes@362
  1955
  const struct dis386 *dp;
nkeynes@362
  1956
  int i;
nkeynes@362
  1957
  char *first, *second, *third;
nkeynes@362
  1958
  int needcomma;
nkeynes@362
  1959
  unsigned char uses_SSE_prefix, uses_LOCK_prefix;
nkeynes@362
  1960
  int sizeflag;
nkeynes@362
  1961
  const char *p;
nkeynes@362
  1962
  struct dis_private priv;
nkeynes@362
  1963
nkeynes@362
  1964
  mode_64bit = (info->mach == bfd_mach_x86_64_intel_syntax
nkeynes@362
  1965
		|| info->mach == bfd_mach_x86_64);
nkeynes@362
  1966
nkeynes@362
  1967
  if (intel_syntax == (char) -1)
nkeynes@362
  1968
    intel_syntax = (info->mach == bfd_mach_i386_i386_intel_syntax
nkeynes@362
  1969
		    || info->mach == bfd_mach_x86_64_intel_syntax);
nkeynes@362
  1970
nkeynes@362
  1971
  if (info->mach == bfd_mach_i386_i386
nkeynes@362
  1972
      || info->mach == bfd_mach_x86_64
nkeynes@362
  1973
      || info->mach == bfd_mach_i386_i386_intel_syntax
nkeynes@362
  1974
      || info->mach == bfd_mach_x86_64_intel_syntax)
nkeynes@362
  1975
    priv.orig_sizeflag = AFLAG | DFLAG;
nkeynes@362
  1976
  else if (info->mach == bfd_mach_i386_i8086)
nkeynes@362
  1977
    priv.orig_sizeflag = 0;
nkeynes@362
  1978
  else
nkeynes@362
  1979
    abort ();
nkeynes@362
  1980
nkeynes@362
  1981
  for (p = info->disassembler_options; p != NULL; )
nkeynes@362
  1982
    {
nkeynes@362
  1983
      if (strncmp (p, "x86-64", 6) == 0)
nkeynes@362
  1984
	{
nkeynes@362
  1985
	  mode_64bit = 1;
nkeynes@362
  1986
	  priv.orig_sizeflag = AFLAG | DFLAG;
nkeynes@362
  1987
	}
nkeynes@362
  1988
      else if (strncmp (p, "i386", 4) == 0)
nkeynes@362
  1989
	{
nkeynes@362
  1990
	  mode_64bit = 0;
nkeynes@362
  1991
	  priv.orig_sizeflag = AFLAG | DFLAG;
nkeynes@362
  1992
	}
nkeynes@362
  1993
      else if (strncmp (p, "i8086", 5) == 0)
nkeynes@362
  1994
	{
nkeynes@362
  1995
	  mode_64bit = 0;
nkeynes@362
  1996
	  priv.orig_sizeflag = 0;
nkeynes@362
  1997
	}
nkeynes@362
  1998
      else if (strncmp (p, "intel", 5) == 0)
nkeynes@362
  1999
	{
nkeynes@362
  2000
	  intel_syntax = 1;
nkeynes@362
  2001
	}
nkeynes@362
  2002
      else if (strncmp (p, "att", 3) == 0)
nkeynes@362
  2003
	{
nkeynes@362
  2004
	  intel_syntax = 0;
nkeynes@362
  2005
	}
nkeynes@362
  2006
      else if (strncmp (p, "addr", 4) == 0)
nkeynes@362
  2007
	{
nkeynes@362
  2008
	  if (p[4] == '1' && p[5] == '6')
nkeynes@362
  2009
	    priv.orig_sizeflag &= ~AFLAG;
nkeynes@362
  2010
	  else if (p[4] == '3' && p[5] == '2')
nkeynes@362
  2011
	    priv.orig_sizeflag |= AFLAG;
nkeynes@362
  2012
	}
nkeynes@362
  2013
      else if (strncmp (p, "data", 4) == 0)
nkeynes@362
  2014
	{
nkeynes@362
  2015
	  if (p[4] == '1' && p[5] == '6')
nkeynes@362
  2016
	    priv.orig_sizeflag &= ~DFLAG;
nkeynes@362
  2017
	  else if (p[4] == '3' && p[5] == '2')
nkeynes@362
  2018
	    priv.orig_sizeflag |= DFLAG;
nkeynes@362
  2019
	}
nkeynes@362
  2020
      else if (strncmp (p, "suffix", 6) == 0)
nkeynes@362
  2021
	priv.orig_sizeflag |= SUFFIX_ALWAYS;
nkeynes@362
  2022
nkeynes@362
  2023
      p = strchr (p, ',');
nkeynes@362
  2024
      if (p != NULL)
nkeynes@362
  2025
	p++;
nkeynes@362
  2026
    }
nkeynes@362
  2027
nkeynes@362
  2028
  if (intel_syntax)
nkeynes@362
  2029
    {
nkeynes@362
  2030
      names64 = intel_names64;
nkeynes@362
  2031
      names32 = intel_names32;
nkeynes@362
  2032
      names16 = intel_names16;
nkeynes@362
  2033
      names8 = intel_names8;
nkeynes@362
  2034
      names8rex = intel_names8rex;
nkeynes@362
  2035
      names_seg = intel_names_seg;
nkeynes@362
  2036
      index16 = intel_index16;
nkeynes@362
  2037
      open_char = '[';
nkeynes@362
  2038
      close_char = ']';
nkeynes@362
  2039
      separator_char = '+';
nkeynes@362
  2040
      scale_char = '*';
nkeynes@362
  2041
    }
nkeynes@362
  2042
  else
nkeynes@362
  2043
    {
nkeynes@362
  2044
      names64 = att_names64;
nkeynes@362
  2045
      names32 = att_names32;
nkeynes@362
  2046
      names16 = att_names16;
nkeynes@362
  2047
      names8 = att_names8;
nkeynes@362
  2048
      names8rex = att_names8rex;
nkeynes@362
  2049
      names_seg = att_names_seg;
nkeynes@362
  2050
      index16 = att_index16;
nkeynes@362
  2051
      open_char = '(';
nkeynes@362
  2052
      close_char =  ')';
nkeynes@362
  2053
      separator_char = ',';
nkeynes@362
  2054
      scale_char = ',';
nkeynes@362
  2055
    }
nkeynes@362
  2056
nkeynes@362
  2057
  /* The output looks better if we put 7 bytes on a line, since that
nkeynes@362
  2058
     puts most long word instructions on a single line.  */
nkeynes@362
  2059
  info->bytes_per_line = 7;
nkeynes@362
  2060
nkeynes@362
  2061
  info->private_data = &priv;
nkeynes@362
  2062
  priv.max_fetched = priv.the_buffer;
nkeynes@362
  2063
  priv.insn_start = pc;
nkeynes@362
  2064
nkeynes@362
  2065
  obuf[0] = 0;
nkeynes@362
  2066
  op1out[0] = 0;
nkeynes@362
  2067
  op2out[0] = 0;
nkeynes@362
  2068
  op3out[0] = 0;
nkeynes@362
  2069
nkeynes@362
  2070
  op_index[0] = op_index[1] = op_index[2] = -1;
nkeynes@362
  2071
nkeynes@362
  2072
  the_info = info;
nkeynes@362
  2073
  start_pc = pc;
nkeynes@362
  2074
  start_codep = priv.the_buffer;
nkeynes@362
  2075
  codep = priv.the_buffer;
nkeynes@362
  2076
nkeynes@362
  2077
  if (setjmp (priv.bailout) != 0)
nkeynes@362
  2078
    {
nkeynes@362
  2079
      const char *name;
nkeynes@362
  2080
nkeynes@362
  2081
      /* Getting here means we tried for data but didn't get it.  That
nkeynes@362
  2082
	 means we have an incomplete instruction of some sort.  Just
nkeynes@362
  2083
	 print the first byte as a prefix or a .byte pseudo-op.  */
nkeynes@362
  2084
      if (codep > priv.the_buffer)
nkeynes@362
  2085
	{
nkeynes@362
  2086
	  name = prefix_name (priv.the_buffer[0], priv.orig_sizeflag);
nkeynes@362
  2087
	  if (name != NULL)
nkeynes@362
  2088
	    (*info->fprintf_func) (info->stream, "%s", name);
nkeynes@362
  2089
	  else
nkeynes@362
  2090
	    {
nkeynes@362
  2091
	      /* Just print the first byte as a .byte instruction.  */
nkeynes@362
  2092
	      (*info->fprintf_func) (info->stream, ".byte 0x%x",
nkeynes@362
  2093
				     (unsigned int) priv.the_buffer[0]);
nkeynes@362
  2094
	    }
nkeynes@362
  2095
nkeynes@362
  2096
	  return 1;
nkeynes@362
  2097
	}
nkeynes@362
  2098
nkeynes@362
  2099
      return -1;
nkeynes@362
  2100
    }
nkeynes@362
  2101
nkeynes@362
  2102
  obufp = obuf;
nkeynes@362
  2103
  ckprefix ();
nkeynes@362
  2104
nkeynes@362
  2105
  insn_codep = codep;
nkeynes@362
  2106
  sizeflag = priv.orig_sizeflag;
nkeynes@362
  2107
nkeynes@362
  2108
  FETCH_DATA (info, codep + 1);
nkeynes@362
  2109
  two_source_ops = (*codep == 0x62) || (*codep == 0xc8);
nkeynes@362
  2110
nkeynes@362
  2111
  if ((prefixes & PREFIX_FWAIT)
nkeynes@362
  2112
      && ((*codep < 0xd8) || (*codep > 0xdf)))
nkeynes@362
  2113
    {
nkeynes@362
  2114
      const char *name;
nkeynes@362
  2115
nkeynes@362
  2116
      /* fwait not followed by floating point instruction.  Print the
nkeynes@362
  2117
	 first prefix, which is probably fwait itself.  */
nkeynes@362
  2118
      name = prefix_name (priv.the_buffer[0], priv.orig_sizeflag);
nkeynes@362
  2119
      if (name == NULL)
nkeynes@362
  2120
	name = INTERNAL_DISASSEMBLER_ERROR;
nkeynes@362
  2121
      (*info->fprintf_func) (info->stream, "%s", name);
nkeynes@362
  2122
      return 1;
nkeynes@362
  2123
    }
nkeynes@362
  2124
nkeynes@362
  2125
  if (*codep == 0x0f)
nkeynes@362
  2126
    {
nkeynes@362
  2127
      FETCH_DATA (info, codep + 2);
nkeynes@362
  2128
      dp = &dis386_twobyte[*++codep];
nkeynes@362
  2129
      need_modrm = twobyte_has_modrm[*codep];
nkeynes@362
  2130
      uses_SSE_prefix = twobyte_uses_SSE_prefix[*codep];
nkeynes@362
  2131
      uses_LOCK_prefix = (*codep & ~0x02) == 0x20;
nkeynes@362
  2132
    }
nkeynes@362
  2133
  else
nkeynes@362
  2134
    {
nkeynes@362
  2135
      dp = &dis386[*codep];
nkeynes@362
  2136
      need_modrm = onebyte_has_modrm[*codep];
nkeynes@362
  2137
      uses_SSE_prefix = 0;
nkeynes@362
  2138
      uses_LOCK_prefix = 0;
nkeynes@362
  2139
    }
nkeynes@362
  2140
  codep++;
nkeynes@362
  2141
nkeynes@362
  2142
  if (!uses_SSE_prefix && (prefixes & PREFIX_REPZ))
nkeynes@362
  2143
    {
nkeynes@362
  2144
      oappend ("repz ");
nkeynes@362
  2145
      used_prefixes |= PREFIX_REPZ;
nkeynes@362
  2146
    }
nkeynes@362
  2147
  if (!uses_SSE_prefix && (prefixes & PREFIX_REPNZ))
nkeynes@362
  2148
    {
nkeynes@362
  2149
      oappend ("repnz ");
nkeynes@362
  2150
      used_prefixes |= PREFIX_REPNZ;
nkeynes@362
  2151
    }
nkeynes@362
  2152
  if (!uses_LOCK_prefix && (prefixes & PREFIX_LOCK))
nkeynes@362
  2153
    {
nkeynes@362
  2154
      oappend ("lock ");
nkeynes@362
  2155
      used_prefixes |= PREFIX_LOCK;
nkeynes@362
  2156
    }
nkeynes@362
  2157
nkeynes@362
  2158
  if (prefixes & PREFIX_ADDR)
nkeynes@362
  2159
    {
nkeynes@362
  2160
      sizeflag ^= AFLAG;
nkeynes@362
  2161
      if (dp->bytemode3 != loop_jcxz_mode || intel_syntax)
nkeynes@362
  2162
	{
nkeynes@362
  2163
	  if ((sizeflag & AFLAG) || mode_64bit)
nkeynes@362
  2164
	    oappend ("addr32 ");
nkeynes@362
  2165
	  else
nkeynes@362
  2166
	    oappend ("addr16 ");
nkeynes@362
  2167
	  used_prefixes |= PREFIX_ADDR;
nkeynes@362
  2168
	}
nkeynes@362
  2169
    }
nkeynes@362
  2170
nkeynes@362
  2171
  if (!uses_SSE_prefix && (prefixes & PREFIX_DATA))
nkeynes@362
  2172
    {
nkeynes@362
  2173
      sizeflag ^= DFLAG;
nkeynes@362
  2174
      if (dp->bytemode3 == cond_jump_mode
nkeynes@362
  2175
	  && dp->bytemode1 == v_mode
nkeynes@362
  2176
	  && !intel_syntax)
nkeynes@362
  2177
	{
nkeynes@362
  2178
	  if (sizeflag & DFLAG)
nkeynes@362
  2179
	    oappend ("data32 ");
nkeynes@362
  2180
	  else
nkeynes@362
  2181
	    oappend ("data16 ");
nkeynes@362
  2182
	  used_prefixes |= PREFIX_DATA;
nkeynes@362
  2183
	}
nkeynes@362
  2184
    }
nkeynes@362
  2185
nkeynes@362
  2186
  if (need_modrm)
nkeynes@362
  2187
    {
nkeynes@362
  2188
      FETCH_DATA (info, codep + 1);
nkeynes@362
  2189
      mod = (*codep >> 6) & 3;
nkeynes@362
  2190
      reg = (*codep >> 3) & 7;
nkeynes@362
  2191
      rm = *codep & 7;
nkeynes@362
  2192
    }
nkeynes@362
  2193
nkeynes@362
  2194
  if (dp->name == NULL && dp->bytemode1 == FLOATCODE)
nkeynes@362
  2195
    {
nkeynes@362
  2196
      dofloat (sizeflag);
nkeynes@362
  2197
    }
nkeynes@362
  2198
  else
nkeynes@362
  2199
    {
nkeynes@362
  2200
      int index;
nkeynes@362
  2201
      if (dp->name == NULL)
nkeynes@362
  2202
	{
nkeynes@362
  2203
	  switch (dp->bytemode1)
nkeynes@362
  2204
	    {
nkeynes@362
  2205
	    case USE_GROUPS:
nkeynes@362
  2206
	      dp = &grps[dp->bytemode2][reg];
nkeynes@362
  2207
	      break;
nkeynes@362
  2208
nkeynes@362
  2209
	    case USE_PREFIX_USER_TABLE:
nkeynes@362
  2210
	      index = 0;
nkeynes@362
  2211
	      used_prefixes |= (prefixes & PREFIX_REPZ);
nkeynes@362
  2212
	      if (prefixes & PREFIX_REPZ)
nkeynes@362
  2213
		index = 1;
nkeynes@362
  2214
	      else
nkeynes@362
  2215
		{
nkeynes@362
  2216
		  used_prefixes |= (prefixes & PREFIX_DATA);
nkeynes@362
  2217
		  if (prefixes & PREFIX_DATA)
nkeynes@362
  2218
		    index = 2;
nkeynes@362
  2219
		  else
nkeynes@362
  2220
		    {
nkeynes@362
  2221
		      used_prefixes |= (prefixes & PREFIX_REPNZ);
nkeynes@362
  2222
		      if (prefixes & PREFIX_REPNZ)
nkeynes@362
  2223
			index = 3;
nkeynes@362
  2224
		    }
nkeynes@362
  2225
		}
nkeynes@362
  2226
	      dp = &prefix_user_table[dp->bytemode2][index];
nkeynes@362
  2227
	      break;
nkeynes@362
  2228
nkeynes@362
  2229
	    case X86_64_SPECIAL:
nkeynes@362
  2230
	      dp = &x86_64_table[dp->bytemode2][mode_64bit];
nkeynes@362
  2231
	      break;
nkeynes@362
  2232
nkeynes@362
  2233
	    default:
nkeynes@362
  2234
	      oappend (INTERNAL_DISASSEMBLER_ERROR);
nkeynes@362
  2235
	      break;
nkeynes@362
  2236
	    }
nkeynes@362
  2237
	}
nkeynes@362
  2238
nkeynes@362
  2239
      if (putop (dp->name, sizeflag) == 0)
nkeynes@362
  2240
	{
nkeynes@362
  2241
	  obufp = op1out;
nkeynes@362
  2242
	  op_ad = 2;
nkeynes@362
  2243
	  if (dp->op1)
nkeynes@362
  2244
	    (*dp->op1) (dp->bytemode1, sizeflag);
nkeynes@362
  2245
nkeynes@362
  2246
	  obufp = op2out;
nkeynes@362
  2247
	  op_ad = 1;
nkeynes@362
  2248
	  if (dp->op2)
nkeynes@362
  2249
	    (*dp->op2) (dp->bytemode2, sizeflag);
nkeynes@362
  2250
nkeynes@362
  2251
	  obufp = op3out;
nkeynes@362
  2252
	  op_ad = 0;
nkeynes@362
  2253
	  if (dp->op3)
nkeynes@362
  2254
	    (*dp->op3) (dp->bytemode3, sizeflag);
nkeynes@362
  2255
	}
nkeynes@362
  2256
    }
nkeynes@362
  2257
nkeynes@362
  2258
  /* See if any prefixes were not used.  If so, print the first one
nkeynes@362
  2259
     separately.  If we don't do this, we'll wind up printing an
nkeynes@362
  2260
     instruction stream which does not precisely correspond to the
nkeynes@362
  2261
     bytes we are disassembling.  */
nkeynes@362
  2262
  if ((prefixes & ~used_prefixes) != 0)
nkeynes@362
  2263
    {
nkeynes@362
  2264
      const char *name;
nkeynes@362
  2265
nkeynes@362
  2266
      name = prefix_name (priv.the_buffer[0], priv.orig_sizeflag);
nkeynes@362
  2267
      if (name == NULL)
nkeynes@362
  2268
	name = INTERNAL_DISASSEMBLER_ERROR;
nkeynes@362
  2269
      (*info->fprintf_func) (info->stream, "%s", name);
nkeynes@362
  2270
      return 1;
nkeynes@362
  2271
    }
nkeynes@362
  2272
  if (rex & ~rex_used)
nkeynes@362
  2273
    {
nkeynes@362
  2274
      const char *name;
nkeynes@362
  2275
      name = prefix_name (rex | 0x40, priv.orig_sizeflag);
nkeynes@362
  2276
      if (name == NULL)
nkeynes@362
  2277
	name = INTERNAL_DISASSEMBLER_ERROR;
nkeynes@362
  2278
      (*info->fprintf_func) (info->stream, "%s ", name);
nkeynes@362
  2279
    }
nkeynes@362
  2280
nkeynes@362
  2281
  obufp = obuf + strlen (obuf);
nkeynes@362
  2282
  for (i = strlen (obuf); i < 6; i++)
nkeynes@362
  2283
    oappend (" ");
nkeynes@362
  2284
  oappend (" ");
nkeynes@362
  2285
  (*info->fprintf_func) (info->stream, "%s", obuf);
nkeynes@362
  2286
nkeynes@362
  2287
  /* The enter and bound instructions are printed with operands in the same
nkeynes@362
  2288
     order as the intel book; everything else is printed in reverse order.  */
nkeynes@362
  2289
  if (intel_syntax || two_source_ops)
nkeynes@362
  2290
    {
nkeynes@362
  2291
      first = op1out;
nkeynes@362
  2292
      second = op2out;
nkeynes@362
  2293
      third = op3out;
nkeynes@362
  2294
      op_ad = op_index[0];
nkeynes@362
  2295
      op_index[0] = op_index[2];
nkeynes@362
  2296
      op_index[2] = op_ad;
nkeynes@362
  2297
    }
nkeynes@362
  2298
  else
nkeynes@362
  2299
    {
nkeynes@362
  2300
      first = op3out;
nkeynes@362
  2301
      second = op2out;
nkeynes@362
  2302
      third = op1out;
nkeynes@362
  2303
    }
nkeynes@362
  2304
  needcomma = 0;
nkeynes@362
  2305
  if (*first)
nkeynes@362
  2306
    {
nkeynes@362
  2307
      if (op_index[0] != -1 && !op_riprel[0])
nkeynes@362
  2308
	(*info->print_address_func) ((bfd_vma) op_address[op_index[0]], info);
nkeynes@362
  2309
      else
nkeynes@362
  2310
	(*info->fprintf_func) (info->stream, "%s", first);
nkeynes@362
  2311
      needcomma = 1;
nkeynes@362
  2312
    }
nkeynes@362
  2313
  if (*second)
nkeynes@362
  2314
    {
nkeynes@362
  2315
      if (needcomma)
nkeynes@362
  2316
	(*info->fprintf_func) (info->stream, ",");
nkeynes@362
  2317
      if (op_index[1] != -1 && !op_riprel[1])
nkeynes@362
  2318
	(*info->print_address_func) ((bfd_vma) op_address[op_index[1]], info);
nkeynes@362
  2319
      else
nkeynes@362
  2320
	(*info->fprintf_func) (info->stream, "%s", second);
nkeynes@362
  2321
      needcomma = 1;
nkeynes@362
  2322
    }
nkeynes@362
  2323
  if (*third)
nkeynes@362
  2324
    {
nkeynes@362
  2325
      if (needcomma)
nkeynes@362
  2326
	(*info->fprintf_func) (info->stream, ",");
nkeynes@362
  2327
      if (op_index[2] != -1 && !op_riprel[2])
nkeynes@362
  2328
	(*info->print_address_func) ((bfd_vma) op_address[op_index[2]], info);
nkeynes@362
  2329
      else
nkeynes@362
  2330
	(*info->fprintf_func) (info->stream, "%s", third);
nkeynes@362
  2331
    }
nkeynes@362
  2332
  for (i = 0; i < 3; i++)
nkeynes@362
  2333
    if (op_index[i] != -1 && op_riprel[i])
nkeynes@362
  2334
      {
nkeynes@362
  2335
	(*info->fprintf_func) (info->stream, "        # ");
nkeynes@362
  2336
	(*info->print_address_func) ((bfd_vma) (start_pc + codep - start_codep
nkeynes@362
  2337
						+ op_address[op_index[i]]), info);
nkeynes@362
  2338
      }
nkeynes@362
  2339
  return codep - priv.the_buffer;
nkeynes@362
  2340
}
nkeynes@362
  2341
nkeynes@362
  2342
static const char *float_mem[] = {
nkeynes@362
  2343
  /* d8 */
nkeynes@362
  2344
  "fadd{s||s|}",
nkeynes@362
  2345
  "fmul{s||s|}",
nkeynes@362
  2346
  "fcom{s||s|}",
nkeynes@362
  2347
  "fcomp{s||s|}",
nkeynes@362
  2348
  "fsub{s||s|}",
nkeynes@362
  2349
  "fsubr{s||s|}",
nkeynes@362
  2350
  "fdiv{s||s|}",
nkeynes@362
  2351
  "fdivr{s||s|}",
nkeynes@362
  2352
  /* d9 */
nkeynes@362
  2353
  "fld{s||s|}",
nkeynes@362
  2354
  "(bad)",
nkeynes@362
  2355
  "fst{s||s|}",
nkeynes@362
  2356
  "fstp{s||s|}",
nkeynes@362
  2357
  "fldenvIC",
nkeynes@362
  2358
  "fldcw",
nkeynes@362
  2359
  "fNstenvIC",
nkeynes@362
  2360
  "fNstcw",
nkeynes@362
  2361
  /* da */
nkeynes@362
  2362
  "fiadd{l||l|}",
nkeynes@362
  2363
  "fimul{l||l|}",
nkeynes@362
  2364
  "ficom{l||l|}",
nkeynes@362
  2365
  "ficomp{l||l|}",
nkeynes@362
  2366
  "fisub{l||l|}",
nkeynes@362
  2367
  "fisubr{l||l|}",
nkeynes@362
  2368
  "fidiv{l||l|}",
nkeynes@362
  2369
  "fidivr{l||l|}",
nkeynes@362
  2370
  /* db */
nkeynes@362
  2371
  "fild{l||l|}",
nkeynes@362
  2372
  "fisttp{l||l|}",
nkeynes@362
  2373
  "fist{l||l|}",
nkeynes@362
  2374
  "fistp{l||l|}",
nkeynes@362
  2375
  "(bad)",
nkeynes@362
  2376
  "fld{t||t|}",
nkeynes@362
  2377
  "(bad)",
nkeynes@362
  2378
  "fstp{t||t|}",
nkeynes@362
  2379
  /* dc */
nkeynes@362
  2380
  "fadd{l||l|}",
nkeynes@362
  2381
  "fmul{l||l|}",
nkeynes@362
  2382
  "fcom{l||l|}",
nkeynes@362
  2383
  "fcomp{l||l|}",
nkeynes@362
  2384
  "fsub{l||l|}",
nkeynes@362
  2385
  "fsubr{l||l|}",
nkeynes@362
  2386
  "fdiv{l||l|}",
nkeynes@362
  2387
  "fdivr{l||l|}",
nkeynes@362
  2388
  /* dd */
nkeynes@362
  2389
  "fld{l||l|}",
nkeynes@362
  2390
  "fisttp{ll||ll|}",
nkeynes@362
  2391
  "fst{l||l|}",
nkeynes@362
  2392
  "fstp{l||l|}",
nkeynes@362
  2393
  "frstorIC",
nkeynes@362
  2394
  "(bad)",
nkeynes@362
  2395
  "fNsaveIC",
nkeynes@362
  2396
  "fNstsw",
nkeynes@362
  2397
  /* de */
nkeynes@362
  2398
  "fiadd",
nkeynes@362
  2399
  "fimul",
nkeynes@362
  2400
  "ficom",
nkeynes@362
  2401
  "ficomp",
nkeynes@362
  2402
  "fisub",
nkeynes@362
  2403
  "fisubr",
nkeynes@362
  2404
  "fidiv",
nkeynes@362
  2405
  "fidivr",
nkeynes@362
  2406
  /* df */
nkeynes@362
  2407
  "fild",
nkeynes@362
  2408
  "fisttp",
nkeynes@362
  2409
  "fist",
nkeynes@362
  2410
  "fistp",
nkeynes@362
  2411
  "fbld",
nkeynes@362
  2412
  "fild{ll||ll|}",
nkeynes@362
  2413
  "fbstp",
nkeynes@362
  2414
  "fistp{ll||ll|}",
nkeynes@362
  2415
};
nkeynes@362
  2416
nkeynes@362
  2417
static const unsigned char float_mem_mode[] = {
nkeynes@362
  2418
  /* d8 */
nkeynes@362
  2419
  d_mode,
nkeynes@362
  2420
  d_mode,
nkeynes@362
  2421
  d_mode,
nkeynes@362
  2422
  d_mode,
nkeynes@362
  2423
  d_mode,
nkeynes@362
  2424
  d_mode,
nkeynes@362
  2425
  d_mode,
nkeynes@362
  2426
  d_mode,
nkeynes@362
  2427
  /* d9 */
nkeynes@362
  2428
  d_mode,
nkeynes@362
  2429
  0,
nkeynes@362
  2430
  d_mode,
nkeynes@362
  2431
  d_mode,
nkeynes@362
  2432
  0,
nkeynes@362
  2433
  w_mode,
nkeynes@362
  2434
  0,
nkeynes@362
  2435
  w_mode,
nkeynes@362
  2436
  /* da */
nkeynes@362
  2437
  d_mode,
nkeynes@362
  2438
  d_mode,
nkeynes@362
  2439
  d_mode,
nkeynes@362
  2440
  d_mode,
nkeynes@362
  2441
  d_mode,
nkeynes@362
  2442
  d_mode,
nkeynes@362
  2443
  d_mode,
nkeynes@362
  2444
  d_mode,
nkeynes@362
  2445
  /* db */
nkeynes@362
  2446
  d_mode,
nkeynes@362
  2447
  d_mode,
nkeynes@362
  2448
  d_mode,
nkeynes@362
  2449
  d_mode,
nkeynes@362
  2450
  0,
nkeynes@362
  2451
  t_mode,
nkeynes@362
  2452
  0,
nkeynes@362
  2453
  t_mode,
nkeynes@362
  2454
  /* dc */
nkeynes@362
  2455
  q_mode,
nkeynes@362
  2456
  q_mode,
nkeynes@362
  2457
  q_mode,
nkeynes@362
  2458
  q_mode,
nkeynes@362
  2459
  q_mode,
nkeynes@362
  2460
  q_mode,
nkeynes@362
  2461
  q_mode,
nkeynes@362
  2462
  q_mode,
nkeynes@362
  2463
  /* dd */
nkeynes@362
  2464
  q_mode,
nkeynes@362
  2465
  q_mode,
nkeynes@362
  2466
  q_mode,
nkeynes@362
  2467
  q_mode,
nkeynes@362
  2468
  0,
nkeynes@362
  2469
  0,
nkeynes@362
  2470
  0,
nkeynes@362
  2471
  w_mode,
nkeynes@362
  2472
  /* de */
nkeynes@362
  2473
  w_mode,
nkeynes@362
  2474
  w_mode,
nkeynes@362
  2475
  w_mode,
nkeynes@362
  2476
  w_mode,
nkeynes@362
  2477
  w_mode,
nkeynes@362
  2478
  w_mode,
nkeynes@362
  2479
  w_mode,
nkeynes@362
  2480
  w_mode,
nkeynes@362
  2481
  /* df */
nkeynes@362
  2482
  w_mode,
nkeynes@362
  2483
  w_mode,
nkeynes@362
  2484
  w_mode,
nkeynes@362
  2485
  w_mode,
nkeynes@362
  2486
  t_mode,
nkeynes@362
  2487
  q_mode,
nkeynes@362
  2488
  t_mode,
nkeynes@362
  2489
  q_mode
nkeynes@362
  2490
};
nkeynes@362
  2491
nkeynes@362
  2492
#define ST OP_ST, 0
nkeynes@362
  2493
#define STi OP_STi, 0
nkeynes@362
  2494
nkeynes@362
  2495
#define FGRPd9_2 NULL, NULL, 0, NULL, 0, NULL, 0
nkeynes@362
  2496
#define FGRPd9_4 NULL, NULL, 1, NULL, 0, NULL, 0
nkeynes@362
  2497
#define FGRPd9_5 NULL, NULL, 2, NULL, 0, NULL, 0
nkeynes@362
  2498
#define FGRPd9_6 NULL, NULL, 3, NULL, 0, NULL, 0
nkeynes@362
  2499
#define FGRPd9_7 NULL, NULL, 4, NULL, 0, NULL, 0
nkeynes@362
  2500
#define FGRPda_5 NULL, NULL, 5, NULL, 0, NULL, 0
nkeynes@362
  2501
#define FGRPdb_4 NULL, NULL, 6, NULL, 0, NULL, 0
nkeynes@362
  2502
#define FGRPde_3 NULL, NULL, 7, NULL, 0, NULL, 0
nkeynes@362
  2503
#define FGRPdf_4 NULL, NULL, 8, NULL, 0, NULL, 0
nkeynes@362
  2504
nkeynes@362
  2505
static const struct dis386 float_reg[][8] = {
nkeynes@362
  2506
  /* d8 */
nkeynes@362
  2507
  {
nkeynes@362
  2508
    { "fadd",	ST, STi, XX },
nkeynes@362
  2509
    { "fmul",	ST, STi, XX },
nkeynes@362
  2510
    { "fcom",	STi, XX, XX },
nkeynes@362
  2511
    { "fcomp",	STi, XX, XX },
nkeynes@362
  2512
    { "fsub",	ST, STi, XX },
nkeynes@362
  2513
    { "fsubr",	ST, STi, XX },
nkeynes@362
  2514
    { "fdiv",	ST, STi, XX },
nkeynes@362
  2515
    { "fdivr",	ST, STi, XX },
nkeynes@362
  2516
  },
nkeynes@362
  2517
  /* d9 */
nkeynes@362
  2518
  {
nkeynes@362
  2519
    { "fld",	STi, XX, XX },
nkeynes@362
  2520
    { "fxch",	STi, XX, XX },
nkeynes@362
  2521
    { FGRPd9_2 },
nkeynes@362
  2522
    { "(bad)",	XX, XX, XX },
nkeynes@362
  2523
    { FGRPd9_4 },
nkeynes@362
  2524
    { FGRPd9_5 },
nkeynes@362
  2525
    { FGRPd9_6 },
nkeynes@362
  2526
    { FGRPd9_7 },
nkeynes@362
  2527
  },
nkeynes@362
  2528
  /* da */
nkeynes@362
  2529
  {
nkeynes@362
  2530
    { "fcmovb",	ST, STi, XX },
nkeynes@362
  2531
    { "fcmove",	ST, STi, XX },
nkeynes@362
  2532
    { "fcmovbe",ST, STi, XX },
nkeynes@362
  2533
    { "fcmovu",	ST, STi, XX },
nkeynes@362
  2534
    { "(bad)",	XX, XX, XX },
nkeynes@362
  2535
    { FGRPda_5 },
nkeynes@362
  2536
    { "(bad)",	XX, XX, XX },
nkeynes@362
  2537
    { "(bad)",	XX, XX, XX },
nkeynes@362
  2538
  },