The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/amd64/amd64/db_disasm.c

Version: -  FREEBSD  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-2  -  FREEBSD-11-1  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-4  -  FREEBSD-10-3  -  FREEBSD-10-2  -  FREEBSD-10-1  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-3  -  FREEBSD-9-2  -  FREEBSD-9-1  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-4  -  FREEBSD-8-3  -  FREEBSD-8-2  -  FREEBSD-8-1  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-4  -  FREEBSD-7-3  -  FREEBSD-7-2  -  FREEBSD-7-1  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-4  -  FREEBSD-6-3  -  FREEBSD-6-2  -  FREEBSD-6-1  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-5  -  FREEBSD-5-4  -  FREEBSD-5-3  -  FREEBSD-5-2  -  FREEBSD-5-1  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  linux-2.6  -  linux-2.4.22  -  MK83  -  MK84  -  PLAN9  -  DFBSD  -  NETBSD  -  NETBSD5  -  NETBSD4  -  NETBSD3  -  NETBSD20  -  OPENBSD  -  xnu-517  -  xnu-792  -  xnu-792.6.70  -  xnu-1228  -  xnu-1456.1.26  -  xnu-1699.24.8  -  xnu-2050.18.24  -  OPENSOLARIS  -  minix-3-1-1 
SearchContext: -  none  -  3  -  10 

    1 /*-
    2  * Mach Operating System
    3  * Copyright (c) 1991,1990 Carnegie Mellon University
    4  * All Rights Reserved.
    5  *
    6  * Permission to use, copy, modify and distribute this software and its
    7  * documentation is hereby granted, provided that both the copyright
    8  * notice and this permission notice appear in all copies of the
    9  * software, derivative works or modified versions, and any portions
   10  * thereof, and that both notices appear in supporting documentation.
   11  *
   12  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS
   13  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
   14  * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
   15  *
   16  * Carnegie Mellon requests users of this software to return to
   17  *
   18  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
   19  *  School of Computer Science
   20  *  Carnegie Mellon University
   21  *  Pittsburgh PA 15213-3890
   22  *
   23  * any improvements or extensions that they make and grant Carnegie the
   24  * rights to redistribute these changes.
   25  */
   26 
   27 #include <sys/cdefs.h>
   28 __FBSDID("$FreeBSD: releng/9.1/sys/amd64/amd64/db_disasm.c 181606 2008-08-11 20:19:42Z jhb $");
   29 
   30 /*
   31  * Instruction disassembler.
   32  */
   33 #include <sys/param.h>
   34 
   35 #include <ddb/ddb.h>
   36 #include <ddb/db_access.h>
   37 #include <ddb/db_sym.h>
   38 
   39 /*
   40  * Size attributes
   41  */
   42 #define BYTE    0
   43 #define WORD    1
   44 #define LONG    2
   45 #define QUAD    3
   46 #define SNGL    4
   47 #define DBLR    5
   48 #define EXTR    6
   49 #define SDEP    7
   50 #define NONE    8
   51 
   52 /*
   53  * REX prefix and bits
   54  */
   55 #define REX_B   1
   56 #define REX_X   2
   57 #define REX_R   4
   58 #define REX_W   8
   59 #define REX     0x40
   60 
   61 /*
   62  * Addressing modes
   63  */
   64 #define E       1                       /* general effective address */
   65 #define Eind    2                       /* indirect address (jump, call) */
   66 #define Ew      3                       /* address, word size */
   67 #define Eb      4                       /* address, byte size */
   68 #define R       5                       /* register, in 'reg' field */
   69 #define Rw      6                       /* word register, in 'reg' field */
   70 #define Ri      7                       /* register in instruction */
   71 #define S       8                       /* segment reg, in 'reg' field */
   72 #define Si      9                       /* segment reg, in instruction */
   73 #define A       10                      /* accumulator */
   74 #define BX      11                      /* (bx) */
   75 #define CL      12                      /* cl, for shifts */
   76 #define DX      13                      /* dx, for IO */
   77 #define SI      14                      /* si */
   78 #define DI      15                      /* di */
   79 #define CR      16                      /* control register */
   80 #define DR      17                      /* debug register */
   81 #define TR      18                      /* test register */
   82 #define I       19                      /* immediate, unsigned */
   83 #define Is      20                      /* immediate, signed */
   84 #define Ib      21                      /* byte immediate, unsigned */
   85 #define Ibs     22                      /* byte immediate, signed */
   86 #define Iw      23                      /* word immediate, unsigned */
   87 #define Ilq     24                      /* long/quad immediate, unsigned */
   88 #define O       25                      /* direct address */
   89 #define Db      26                      /* byte displacement from EIP */
   90 #define Dl      27                      /* long displacement from EIP */
   91 #define o1      28                      /* constant 1 */
   92 #define o3      29                      /* constant 3 */
   93 #define OS      30                      /* immediate offset/segment */
   94 #define ST      31                      /* FP stack top */
   95 #define STI     32                      /* FP stack */
   96 #define X       33                      /* extended FP op */
   97 #define XA      34                      /* for 'fstcw %ax' */
   98 #define El      35                      /* address, long/quad size */
   99 #define Ril     36                      /* long register in instruction */
  100 #define Iba     37                      /* byte immediate, don't print if 0xa */
  101 #define EL      38                      /* address, explicitly long size */
  102 
  103 struct inst {
  104         const char *    i_name;         /* name */
  105         short   i_has_modrm;            /* has regmodrm byte */
  106         short   i_size;                 /* operand size */
  107         int     i_mode;                 /* addressing modes */
  108         const void *    i_extra;        /* pointer to extra opcode table */
  109 };
  110 
  111 #define op1(x)          (x)
  112 #define op2(x,y)        ((x)|((y)<<8))
  113 #define op3(x,y,z)      ((x)|((y)<<8)|((z)<<16))
  114 
  115 struct finst {
  116         const char *    f_name;         /* name for memory instruction */
  117         int     f_size;                 /* size for memory instruction */
  118         int     f_rrmode;               /* mode for rr instruction */
  119         const void *    f_rrname;       /* name for rr instruction
  120                                            (or pointer to table) */
  121 };
  122 
  123 static const char * const db_Grp6[] = {
  124         "sldt",
  125         "str",
  126         "lldt",
  127         "ltr",
  128         "verr",
  129         "verw",
  130         "",
  131         ""
  132 };
  133 
  134 static const char * const db_Grp7[] = {
  135         "sgdt",
  136         "sidt",
  137         "lgdt",
  138         "lidt",
  139         "smsw",
  140         "",
  141         "lmsw",
  142         "invlpg"
  143 };
  144 
  145 static const char * const db_Grp8[] = {
  146         "",
  147         "",
  148         "",
  149         "",
  150         "bt",
  151         "bts",
  152         "btr",
  153         "btc"
  154 };
  155 
  156 static const char * const db_Grp9[] = {
  157         "",
  158         "cmpxchg8b",
  159         "",
  160         "",
  161         "",
  162         "",
  163         "",
  164         ""
  165 };
  166 
  167 static const char * const db_Grp15[] = {
  168         "fxsave",
  169         "fxrstor",
  170         "ldmxcsr",
  171         "stmxcsr",
  172         "",
  173         "",
  174         "",
  175         "clflush"
  176 };
  177 
  178 static const char * const db_Grp15b[] = {
  179         "",
  180         "",
  181         "",
  182         "",
  183         "",
  184         "lfence",
  185         "mfence",
  186         "sfence"
  187 };
  188 
  189 static const struct inst db_inst_0f0x[] = {
  190 /*00*/  { "",      TRUE,  NONE,  op1(Ew),     db_Grp6 },
  191 /*01*/  { "",      TRUE,  NONE,  op1(Ew),     db_Grp7 },
  192 /*02*/  { "lar",   TRUE,  LONG,  op2(E,R),    0 },
  193 /*03*/  { "lsl",   TRUE,  LONG,  op2(E,R),    0 },
  194 /*04*/  { "",      FALSE, NONE,  0,           0 },
  195 /*05*/  { "syscall",FALSE,NONE,  0,           0 },
  196 /*06*/  { "clts",  FALSE, NONE,  0,           0 },
  197 /*07*/  { "sysret",FALSE, NONE,  0,           0 },
  198 
  199 /*08*/  { "invd",  FALSE, NONE,  0,           0 },
  200 /*09*/  { "wbinvd",FALSE, NONE,  0,           0 },
  201 /*0a*/  { "",      FALSE, NONE,  0,           0 },
  202 /*0b*/  { "",      FALSE, NONE,  0,           0 },
  203 /*0c*/  { "",      FALSE, NONE,  0,           0 },
  204 /*0d*/  { "",      FALSE, NONE,  0,           0 },
  205 /*0e*/  { "",      FALSE, NONE,  0,           0 },
  206 /*0f*/  { "",      FALSE, NONE,  0,           0 },
  207 };
  208 
  209 static const struct inst db_inst_0f2x[] = {
  210 /*20*/  { "mov",   TRUE,  LONG,  op2(CR,El),  0 },
  211 /*21*/  { "mov",   TRUE,  LONG,  op2(DR,El),  0 },
  212 /*22*/  { "mov",   TRUE,  LONG,  op2(El,CR),  0 },
  213 /*23*/  { "mov",   TRUE,  LONG,  op2(El,DR),  0 },
  214 /*24*/  { "mov",   TRUE,  LONG,  op2(TR,El),  0 },
  215 /*25*/  { "",      FALSE, NONE,  0,           0 },
  216 /*26*/  { "mov",   TRUE,  LONG,  op2(El,TR),  0 },
  217 /*27*/  { "",      FALSE, NONE,  0,           0 },
  218 
  219 /*28*/  { "",      FALSE, NONE,  0,           0 },
  220 /*29*/  { "",      FALSE, NONE,  0,           0 },
  221 /*2a*/  { "",      FALSE, NONE,  0,           0 },
  222 /*2b*/  { "",      FALSE, NONE,  0,           0 },
  223 /*2c*/  { "",      FALSE, NONE,  0,           0 },
  224 /*2d*/  { "",      FALSE, NONE,  0,           0 },
  225 /*2e*/  { "",      FALSE, NONE,  0,           0 },
  226 /*2f*/  { "",      FALSE, NONE,  0,           0 },
  227 };
  228 
  229 static const struct inst db_inst_0f3x[] = {
  230 /*30*/  { "wrmsr", FALSE, NONE,  0,           0 },
  231 /*31*/  { "rdtsc", FALSE, NONE,  0,           0 },
  232 /*32*/  { "rdmsr", FALSE, NONE,  0,           0 },
  233 /*33*/  { "rdpmc", FALSE, NONE,  0,           0 },
  234 /*34*/  { "sysenter",FALSE,NONE,  0,          0 },
  235 /*35*/  { "sysexit",FALSE,NONE,  0,           0 },
  236 /*36*/  { "",      FALSE, NONE,  0,           0 },
  237 /*37*/  { "getsec",FALSE, NONE,  0,           0 },
  238 
  239 /*38*/  { "",      FALSE, NONE,  0,           0 },
  240 /*39*/  { "",      FALSE, NONE,  0,           0 },
  241 /*3a*/  { "",      FALSE, NONE,  0,           0 },
  242 /*3b*/  { "",      FALSE, NONE,  0,           0 },
  243 /*3c*/  { "",      FALSE, NONE,  0,           0 },
  244 /*3d*/  { "",      FALSE, NONE,  0,           0 },
  245 /*3e*/  { "",      FALSE, NONE,  0,           0 },
  246 /*3f*/  { "",      FALSE, NONE,  0,           0 },
  247 };
  248 
  249 static const struct inst db_inst_0f4x[] = {
  250 /*40*/  { "cmovo",  TRUE, NONE,  op2(E, R),   0 },
  251 /*41*/  { "cmovno", TRUE, NONE,  op2(E, R),   0 },
  252 /*42*/  { "cmovb",  TRUE, NONE,  op2(E, R),   0 },
  253 /*43*/  { "cmovnb", TRUE, NONE,  op2(E, R),   0 },
  254 /*44*/  { "cmovz",  TRUE, NONE,  op2(E, R),   0 },
  255 /*45*/  { "cmovnz", TRUE, NONE,  op2(E, R),   0 },
  256 /*46*/  { "cmovbe", TRUE, NONE,  op2(E, R),   0 },
  257 /*47*/  { "cmovnbe",TRUE, NONE,  op2(E, R),   0 },
  258 
  259 /*48*/  { "cmovs",  TRUE, NONE,  op2(E, R),   0 },
  260 /*49*/  { "cmovns", TRUE, NONE,  op2(E, R),   0 },
  261 /*4a*/  { "cmovp",  TRUE, NONE,  op2(E, R),   0 },
  262 /*4b*/  { "cmovnp", TRUE, NONE,  op2(E, R),   0 },
  263 /*4c*/  { "cmovl",  TRUE, NONE,  op2(E, R),   0 },
  264 /*4d*/  { "cmovnl", TRUE, NONE,  op2(E, R),   0 },
  265 /*4e*/  { "cmovle", TRUE, NONE,  op2(E, R),   0 },
  266 /*4f*/  { "cmovnle",TRUE, NONE,  op2(E, R),   0 },
  267 };
  268 
  269 static const struct inst db_inst_0f8x[] = {
  270 /*80*/  { "jo",    FALSE, NONE,  op1(Dl),     0 },
  271 /*81*/  { "jno",   FALSE, NONE,  op1(Dl),     0 },
  272 /*82*/  { "jb",    FALSE, NONE,  op1(Dl),     0 },
  273 /*83*/  { "jnb",   FALSE, NONE,  op1(Dl),     0 },
  274 /*84*/  { "jz",    FALSE, NONE,  op1(Dl),     0 },
  275 /*85*/  { "jnz",   FALSE, NONE,  op1(Dl),     0 },
  276 /*86*/  { "jbe",   FALSE, NONE,  op1(Dl),     0 },
  277 /*87*/  { "jnbe",  FALSE, NONE,  op1(Dl),     0 },
  278 
  279 /*88*/  { "js",    FALSE, NONE,  op1(Dl),     0 },
  280 /*89*/  { "jns",   FALSE, NONE,  op1(Dl),     0 },
  281 /*8a*/  { "jp",    FALSE, NONE,  op1(Dl),     0 },
  282 /*8b*/  { "jnp",   FALSE, NONE,  op1(Dl),     0 },
  283 /*8c*/  { "jl",    FALSE, NONE,  op1(Dl),     0 },
  284 /*8d*/  { "jnl",   FALSE, NONE,  op1(Dl),     0 },
  285 /*8e*/  { "jle",   FALSE, NONE,  op1(Dl),     0 },
  286 /*8f*/  { "jnle",  FALSE, NONE,  op1(Dl),     0 },
  287 };
  288 
  289 static const struct inst db_inst_0f9x[] = {
  290 /*90*/  { "seto",  TRUE,  NONE,  op1(Eb),     0 },
  291 /*91*/  { "setno", TRUE,  NONE,  op1(Eb),     0 },
  292 /*92*/  { "setb",  TRUE,  NONE,  op1(Eb),     0 },
  293 /*93*/  { "setnb", TRUE,  NONE,  op1(Eb),     0 },
  294 /*94*/  { "setz",  TRUE,  NONE,  op1(Eb),     0 },
  295 /*95*/  { "setnz", TRUE,  NONE,  op1(Eb),     0 },
  296 /*96*/  { "setbe", TRUE,  NONE,  op1(Eb),     0 },
  297 /*97*/  { "setnbe",TRUE,  NONE,  op1(Eb),     0 },
  298 
  299 /*98*/  { "sets",  TRUE,  NONE,  op1(Eb),     0 },
  300 /*99*/  { "setns", TRUE,  NONE,  op1(Eb),     0 },
  301 /*9a*/  { "setp",  TRUE,  NONE,  op1(Eb),     0 },
  302 /*9b*/  { "setnp", TRUE,  NONE,  op1(Eb),     0 },
  303 /*9c*/  { "setl",  TRUE,  NONE,  op1(Eb),     0 },
  304 /*9d*/  { "setnl", TRUE,  NONE,  op1(Eb),     0 },
  305 /*9e*/  { "setle", TRUE,  NONE,  op1(Eb),     0 },
  306 /*9f*/  { "setnle",TRUE,  NONE,  op1(Eb),     0 },
  307 };
  308 
  309 static const struct inst db_inst_0fax[] = {
  310 /*a0*/  { "push",  FALSE, NONE,  op1(Si),     0 },
  311 /*a1*/  { "pop",   FALSE, NONE,  op1(Si),     0 },
  312 /*a2*/  { "cpuid", FALSE, NONE,  0,           0 },
  313 /*a3*/  { "bt",    TRUE,  LONG,  op2(R,E),    0 },
  314 /*a4*/  { "shld",  TRUE,  LONG,  op3(Ib,R,E), 0 },
  315 /*a5*/  { "shld",  TRUE,  LONG,  op3(CL,R,E), 0 },
  316 /*a6*/  { "",      FALSE, NONE,  0,           0 },
  317 /*a7*/  { "",      FALSE, NONE,  0,           0 },
  318 
  319 /*a8*/  { "push",  FALSE, NONE,  op1(Si),     0 },
  320 /*a9*/  { "pop",   FALSE, NONE,  op1(Si),     0 },
  321 /*aa*/  { "rsm",   FALSE, NONE,  0,           0 },
  322 /*ab*/  { "bts",   TRUE,  LONG,  op2(R,E),    0 },
  323 /*ac*/  { "shrd",  TRUE,  LONG,  op3(Ib,R,E), 0 },
  324 /*ad*/  { "shrd",  TRUE,  LONG,  op3(CL,R,E), 0 },
  325 /*ae*/  { "",      TRUE,  LONG,  op1(E),      db_Grp15 },
  326 /*af*/  { "imul",  TRUE,  LONG,  op2(E,R),    0 },
  327 };
  328 
  329 static const struct inst db_inst_0fbx[] = {
  330 /*b0*/  { "cmpxchg",TRUE, BYTE,  op2(R, E),   0 },
  331 /*b0*/  { "cmpxchg",TRUE, LONG,  op2(R, E),   0 },
  332 /*b2*/  { "lss",   TRUE,  LONG,  op2(E, R),   0 },
  333 /*b3*/  { "btr",   TRUE,  LONG,  op2(R, E),   0 },
  334 /*b4*/  { "lfs",   TRUE,  LONG,  op2(E, R),   0 },
  335 /*b5*/  { "lgs",   TRUE,  LONG,  op2(E, R),   0 },
  336 /*b6*/  { "movzb", TRUE,  LONG,  op2(Eb, R),  0 },
  337 /*b7*/  { "movzw", TRUE,  LONG,  op2(Ew, R),  0 },
  338 
  339 /*b8*/  { "",      FALSE, NONE,  0,           0 },
  340 /*b9*/  { "",      FALSE, NONE,  0,           0 },
  341 /*ba*/  { "",      TRUE,  LONG,  op2(Ib, E),  db_Grp8 },
  342 /*bb*/  { "btc",   TRUE,  LONG,  op2(R, E),   0 },
  343 /*bc*/  { "bsf",   TRUE,  LONG,  op2(E, R),   0 },
  344 /*bd*/  { "bsr",   TRUE,  LONG,  op2(E, R),   0 },
  345 /*be*/  { "movsb", TRUE,  LONG,  op2(Eb, R),  0 },
  346 /*bf*/  { "movsw", TRUE,  LONG,  op2(Ew, R),  0 },
  347 };
  348 
  349 static const struct inst db_inst_0fcx[] = {
  350 /*c0*/  { "xadd",  TRUE,  BYTE,  op2(R, E),   0 },
  351 /*c1*/  { "xadd",  TRUE,  LONG,  op2(R, E),   0 },
  352 /*c2*/  { "",      FALSE, NONE,  0,           0 },
  353 /*c3*/  { "",      FALSE, NONE,  0,           0 },
  354 /*c4*/  { "",      FALSE, NONE,  0,           0 },
  355 /*c5*/  { "",      FALSE, NONE,  0,           0 },
  356 /*c6*/  { "",      FALSE, NONE,  0,           0 },
  357 /*c7*/  { "",      TRUE,  NONE,  op1(E),      db_Grp9 },
  358 /*c8*/  { "bswap", FALSE, LONG,  op1(Ril),    0 },
  359 /*c9*/  { "bswap", FALSE, LONG,  op1(Ril),    0 },
  360 /*ca*/  { "bswap", FALSE, LONG,  op1(Ril),    0 },
  361 /*cb*/  { "bswap", FALSE, LONG,  op1(Ril),    0 },
  362 /*cc*/  { "bswap", FALSE, LONG,  op1(Ril),    0 },
  363 /*cd*/  { "bswap", FALSE, LONG,  op1(Ril),    0 },
  364 /*ce*/  { "bswap", FALSE, LONG,  op1(Ril),    0 },
  365 /*cf*/  { "bswap", FALSE, LONG,  op1(Ril),    0 },
  366 };
  367 
  368 static const struct inst * const db_inst_0f[] = {
  369         db_inst_0f0x,
  370         0,
  371         db_inst_0f2x,
  372         db_inst_0f3x,
  373         db_inst_0f4x,
  374         0,
  375         0,
  376         0,
  377         db_inst_0f8x,
  378         db_inst_0f9x,
  379         db_inst_0fax,
  380         db_inst_0fbx,
  381         db_inst_0fcx,
  382         0,
  383         0,
  384         0
  385 };
  386 
  387 static const char * const db_Esc92[] = {
  388         "fnop", "",     "",     "",     "",     "",     "",     ""
  389 };
  390 static const char * const db_Esc94[] = {
  391         "fchs", "fabs", "",     "",     "ftst", "fxam", "",     ""
  392 };
  393 static const char * const db_Esc95[] = {
  394         "fld1", "fldl2t","fldl2e","fldpi","fldlg2","fldln2","fldz",""
  395 };
  396 static const char * const db_Esc96[] = {
  397         "f2xm1","fyl2x","fptan","fpatan","fxtract","fprem1","fdecstp",
  398         "fincstp"
  399 };
  400 static const char * const db_Esc97[] = {
  401         "fprem","fyl2xp1","fsqrt","fsincos","frndint","fscale","fsin","fcos"
  402 };
  403 
  404 static const char * const db_Esca5[] = {
  405         "",     "fucompp","",   "",     "",     "",     "",     ""
  406 };
  407 
  408 static const char * const db_Escb4[] = {
  409         "fneni","fndisi",       "fnclex","fninit","fsetpm",     "",     "",     ""
  410 };
  411 
  412 static const char * const db_Esce3[] = {
  413         "",     "fcompp","",    "",     "",     "",     "",     ""
  414 };
  415 
  416 static const char * const db_Escf4[] = {
  417         "fnstsw","",    "",     "",     "",     "",     "",     ""
  418 };
  419 
  420 static const struct finst db_Esc8[] = {
  421 /**/   { "fadd",   SNGL,  op2(STI,ST), 0 },
  422 /*1*/   { "fmul",   SNGL,  op2(STI,ST), 0 },
  423 /*2*/   { "fcom",   SNGL,  op2(STI,ST), 0 },
  424 /*3*/   { "fcomp",  SNGL,  op2(STI,ST), 0 },
  425 /*4*/   { "fsub",   SNGL,  op2(STI,ST), 0 },
  426 /*5*/   { "fsubr",  SNGL,  op2(STI,ST), 0 },
  427 /*6*/   { "fdiv",   SNGL,  op2(STI,ST), 0 },
  428 /*7*/   { "fdivr",  SNGL,  op2(STI,ST), 0 },
  429 };
  430 
  431 static const struct finst db_Esc9[] = {
  432 /**/   { "fld",    SNGL,  op1(STI),    0 },
  433 /*1*/   { "",       NONE,  op1(STI),    "fxch" },
  434 /*2*/   { "fst",    SNGL,  op1(X),      db_Esc92 },
  435 /*3*/   { "fstp",   SNGL,  0,           0 },
  436 /*4*/   { "fldenv", NONE,  op1(X),      db_Esc94 },
  437 /*5*/   { "fldcw",  NONE,  op1(X),      db_Esc95 },
  438 /*6*/   { "fnstenv",NONE,  op1(X),      db_Esc96 },
  439 /*7*/   { "fnstcw", NONE,  op1(X),      db_Esc97 },
  440 };
  441 
  442 static const struct finst db_Esca[] = {
  443 /**/   { "fiadd",  LONG,  0,           0 },
  444 /*1*/   { "fimul",  LONG,  0,           0 },
  445 /*2*/   { "ficom",  LONG,  0,           0 },
  446 /*3*/   { "ficomp", LONG,  0,           0 },
  447 /*4*/   { "fisub",  LONG,  0,           0 },
  448 /*5*/   { "fisubr", LONG,  op1(X),      db_Esca5 },
  449 /*6*/   { "fidiv",  LONG,  0,           0 },
  450 /*7*/   { "fidivr", LONG,  0,           0 }
  451 };
  452 
  453 static const struct finst db_Escb[] = {
  454 /**/   { "fild",   LONG,  0,           0 },
  455 /*1*/   { "",       NONE,  0,           0 },
  456 /*2*/   { "fist",   LONG,  0,           0 },
  457 /*3*/   { "fistp",  LONG,  0,           0 },
  458 /*4*/   { "",       WORD,  op1(X),      db_Escb4 },
  459 /*5*/   { "fld",    EXTR,  0,           0 },
  460 /*6*/   { "",       WORD,  0,           0 },
  461 /*7*/   { "fstp",   EXTR,  0,           0 },
  462 };
  463 
  464 static const struct finst db_Escc[] = {
  465 /**/   { "fadd",   DBLR,  op2(ST,STI), 0 },
  466 /*1*/   { "fmul",   DBLR,  op2(ST,STI), 0 },
  467 /*2*/   { "fcom",   DBLR,  0,           0 },
  468 /*3*/   { "fcomp",  DBLR,  0,           0 },
  469 /*4*/   { "fsub",   DBLR,  op2(ST,STI), "fsubr" },
  470 /*5*/   { "fsubr",  DBLR,  op2(ST,STI), "fsub" },
  471 /*6*/   { "fdiv",   DBLR,  op2(ST,STI), "fdivr" },
  472 /*7*/   { "fdivr",  DBLR,  op2(ST,STI), "fdiv" },
  473 };
  474 
  475 static const struct finst db_Escd[] = {
  476 /**/   { "fld",    DBLR,  op1(STI),    "ffree" },
  477 /*1*/   { "",       NONE,  0,           0 },
  478 /*2*/   { "fst",    DBLR,  op1(STI),    0 },
  479 /*3*/   { "fstp",   DBLR,  op1(STI),    0 },
  480 /*4*/   { "frstor", NONE,  op1(STI),    "fucom" },
  481 /*5*/   { "",       NONE,  op1(STI),    "fucomp" },
  482 /*6*/   { "fnsave", NONE,  0,           0 },
  483 /*7*/   { "fnstsw", NONE,  0,           0 },
  484 };
  485 
  486 static const struct finst db_Esce[] = {
  487 /**/   { "fiadd",  WORD,  op2(ST,STI), "faddp" },
  488 /*1*/   { "fimul",  WORD,  op2(ST,STI), "fmulp" },
  489 /*2*/   { "ficom",  WORD,  0,           0 },
  490 /*3*/   { "ficomp", WORD,  op1(X),      db_Esce3 },
  491 /*4*/   { "fisub",  WORD,  op2(ST,STI), "fsubrp" },
  492 /*5*/   { "fisubr", WORD,  op2(ST,STI), "fsubp" },
  493 /*6*/   { "fidiv",  WORD,  op2(ST,STI), "fdivrp" },
  494 /*7*/   { "fidivr", WORD,  op2(ST,STI), "fdivp" },
  495 };
  496 
  497 static const struct finst db_Escf[] = {
  498 /**/   { "fild",   WORD,  0,           0 },
  499 /*1*/   { "",       NONE,  0,           0 },
  500 /*2*/   { "fist",   WORD,  0,           0 },
  501 /*3*/   { "fistp",  WORD,  0,           0 },
  502 /*4*/   { "fbld",   NONE,  op1(XA),     db_Escf4 },
  503 /*5*/   { "fild",   QUAD,  0,           0 },
  504 /*6*/   { "fbstp",  NONE,  0,           0 },
  505 /*7*/   { "fistp",  QUAD,  0,           0 },
  506 };
  507 
  508 static const struct finst * const db_Esc_inst[] = {
  509         db_Esc8, db_Esc9, db_Esca, db_Escb,
  510         db_Escc, db_Escd, db_Esce, db_Escf
  511 };
  512 
  513 static const char * const db_Grp1[] = {
  514         "add",
  515         "or",
  516         "adc",
  517         "sbb",
  518         "and",
  519         "sub",
  520         "xor",
  521         "cmp"
  522 };
  523 
  524 static const char * const db_Grp2[] = {
  525         "rol",
  526         "ror",
  527         "rcl",
  528         "rcr",
  529         "shl",
  530         "shr",
  531         "shl",
  532         "sar"
  533 };
  534 
  535 static const struct inst db_Grp3[] = {
  536         { "test",  TRUE, NONE, op2(I,E), 0 },
  537         { "test",  TRUE, NONE, op2(I,E), 0 },
  538         { "not",   TRUE, NONE, op1(E),   0 },
  539         { "neg",   TRUE, NONE, op1(E),   0 },
  540         { "mul",   TRUE, NONE, op2(E,A), 0 },
  541         { "imul",  TRUE, NONE, op2(E,A), 0 },
  542         { "div",   TRUE, NONE, op2(E,A), 0 },
  543         { "idiv",  TRUE, NONE, op2(E,A), 0 },
  544 };
  545 
  546 static const struct inst db_Grp4[] = {
  547         { "inc",   TRUE, BYTE, op1(E),   0 },
  548         { "dec",   TRUE, BYTE, op1(E),   0 },
  549         { "",      TRUE, NONE, 0,        0 },
  550         { "",      TRUE, NONE, 0,        0 },
  551         { "",      TRUE, NONE, 0,        0 },
  552         { "",      TRUE, NONE, 0,        0 },
  553         { "",      TRUE, NONE, 0,        0 },
  554         { "",      TRUE, NONE, 0,        0 }
  555 };
  556 
  557 static const struct inst db_Grp5[] = {
  558         { "inc",   TRUE, LONG, op1(E),   0 },
  559         { "dec",   TRUE, LONG, op1(E),   0 },
  560         { "call",  TRUE, LONG, op1(Eind),0 },
  561         { "lcall", TRUE, LONG, op1(Eind),0 },
  562         { "jmp",   TRUE, LONG, op1(Eind),0 },
  563         { "ljmp",  TRUE, LONG, op1(Eind),0 },
  564         { "push",  TRUE, LONG, op1(E),   0 },
  565         { "",      TRUE, NONE, 0,        0 }
  566 };
  567 
  568 static const struct inst db_inst_table[256] = {
  569 /*00*/  { "add",   TRUE,  BYTE,  op2(R, E),  0 },
  570 /*01*/  { "add",   TRUE,  LONG,  op2(R, E),  0 },
  571 /*02*/  { "add",   TRUE,  BYTE,  op2(E, R),  0 },
  572 /*03*/  { "add",   TRUE,  LONG,  op2(E, R),  0 },
  573 /*04*/  { "add",   FALSE, BYTE,  op2(I, A),  0 },
  574 /*05*/  { "add",   FALSE, LONG,  op2(Is, A), 0 },
  575 /*06*/  { "push",  FALSE, NONE,  op1(Si),    0 },
  576 /*07*/  { "pop",   FALSE, NONE,  op1(Si),    0 },
  577 
  578 /*08*/  { "or",    TRUE,  BYTE,  op2(R, E),  0 },
  579 /*09*/  { "or",    TRUE,  LONG,  op2(R, E),  0 },
  580 /*0a*/  { "or",    TRUE,  BYTE,  op2(E, R),  0 },
  581 /*0b*/  { "or",    TRUE,  LONG,  op2(E, R),  0 },
  582 /*0c*/  { "or",    FALSE, BYTE,  op2(I, A),  0 },
  583 /*0d*/  { "or",    FALSE, LONG,  op2(I, A),  0 },
  584 /*0e*/  { "push",  FALSE, NONE,  op1(Si),    0 },
  585 /*0f*/  { "",      FALSE, NONE,  0,          0 },
  586 
  587 /*10*/  { "adc",   TRUE,  BYTE,  op2(R, E),  0 },
  588 /*11*/  { "adc",   TRUE,  LONG,  op2(R, E),  0 },
  589 /*12*/  { "adc",   TRUE,  BYTE,  op2(E, R),  0 },
  590 /*13*/  { "adc",   TRUE,  LONG,  op2(E, R),  0 },
  591 /*14*/  { "adc",   FALSE, BYTE,  op2(I, A),  0 },
  592 /*15*/  { "adc",   FALSE, LONG,  op2(Is, A), 0 },
  593 /*16*/  { "push",  FALSE, NONE,  op1(Si),    0 },
  594 /*17*/  { "pop",   FALSE, NONE,  op1(Si),    0 },
  595 
  596 /*18*/  { "sbb",   TRUE,  BYTE,  op2(R, E),  0 },
  597 /*19*/  { "sbb",   TRUE,  LONG,  op2(R, E),  0 },
  598 /*1a*/  { "sbb",   TRUE,  BYTE,  op2(E, R),  0 },
  599 /*1b*/  { "sbb",   TRUE,  LONG,  op2(E, R),  0 },
  600 /*1c*/  { "sbb",   FALSE, BYTE,  op2(I, A),  0 },
  601 /*1d*/  { "sbb",   FALSE, LONG,  op2(Is, A), 0 },
  602 /*1e*/  { "push",  FALSE, NONE,  op1(Si),    0 },
  603 /*1f*/  { "pop",   FALSE, NONE,  op1(Si),    0 },
  604 
  605 /*20*/  { "and",   TRUE,  BYTE,  op2(R, E),  0 },
  606 /*21*/  { "and",   TRUE,  LONG,  op2(R, E),  0 },
  607 /*22*/  { "and",   TRUE,  BYTE,  op2(E, R),  0 },
  608 /*23*/  { "and",   TRUE,  LONG,  op2(E, R),  0 },
  609 /*24*/  { "and",   FALSE, BYTE,  op2(I, A),  0 },
  610 /*25*/  { "and",   FALSE, LONG,  op2(I, A),  0 },
  611 /*26*/  { "",      FALSE, NONE,  0,          0 },
  612 /*27*/  { "daa",   FALSE, NONE,  0,          0 },
  613 
  614 /*28*/  { "sub",   TRUE,  BYTE,  op2(R, E),  0 },
  615 /*29*/  { "sub",   TRUE,  LONG,  op2(R, E),  0 },
  616 /*2a*/  { "sub",   TRUE,  BYTE,  op2(E, R),  0 },
  617 /*2b*/  { "sub",   TRUE,  LONG,  op2(E, R),  0 },
  618 /*2c*/  { "sub",   FALSE, BYTE,  op2(I, A),  0 },
  619 /*2d*/  { "sub",   FALSE, LONG,  op2(Is, A), 0 },
  620 /*2e*/  { "",      FALSE, NONE,  0,          0 },
  621 /*2f*/  { "das",   FALSE, NONE,  0,          0 },
  622 
  623 /*30*/  { "xor",   TRUE,  BYTE,  op2(R, E),  0 },
  624 /*31*/  { "xor",   TRUE,  LONG,  op2(R, E),  0 },
  625 /*32*/  { "xor",   TRUE,  BYTE,  op2(E, R),  0 },
  626 /*33*/  { "xor",   TRUE,  LONG,  op2(E, R),  0 },
  627 /*34*/  { "xor",   FALSE, BYTE,  op2(I, A),  0 },
  628 /*35*/  { "xor",   FALSE, LONG,  op2(I, A),  0 },
  629 /*36*/  { "",      FALSE, NONE,  0,          0 },
  630 /*37*/  { "aaa",   FALSE, NONE,  0,          0 },
  631 
  632 /*38*/  { "cmp",   TRUE,  BYTE,  op2(R, E),  0 },
  633 /*39*/  { "cmp",   TRUE,  LONG,  op2(R, E),  0 },
  634 /*3a*/  { "cmp",   TRUE,  BYTE,  op2(E, R),  0 },
  635 /*3b*/  { "cmp",   TRUE,  LONG,  op2(E, R),  0 },
  636 /*3c*/  { "cmp",   FALSE, BYTE,  op2(I, A),  0 },
  637 /*3d*/  { "cmp",   FALSE, LONG,  op2(Is, A), 0 },
  638 /*3e*/  { "",      FALSE, NONE,  0,          0 },
  639 /*3f*/  { "aas",   FALSE, NONE,  0,          0 },
  640 
  641 /*40*/  { "rex",   FALSE, NONE,  0,          0 },
  642 /*41*/  { "rex.b", FALSE, NONE,  0,          0 },
  643 /*42*/  { "rex.x", FALSE, NONE,  0,          0 },
  644 /*43*/  { "rex.xb", FALSE, NONE, 0,          0 },
  645 /*44*/  { "rex.r", FALSE, NONE,  0,          0 },
  646 /*45*/  { "rex.rb", FALSE, NONE, 0,          0 },
  647 /*46*/  { "rex.rx", FALSE, NONE, 0,          0 },
  648 /*47*/  { "rex.rxb", FALSE, NONE, 0,         0 },
  649 
  650 /*48*/  { "rex.w", FALSE, NONE,  0,          0 },
  651 /*49*/  { "rex.wb", FALSE, NONE, 0,          0 },
  652 /*4a*/  { "rex.wx", FALSE, NONE, 0,          0 },
  653 /*4b*/  { "rex.wxb", FALSE, NONE, 0,         0 },
  654 /*4c*/  { "rex.wr", FALSE, NONE, 0,          0 },
  655 /*4d*/  { "rex.wrb", FALSE, NONE, 0,         0 },
  656 /*4e*/  { "rex.wrx", FALSE, NONE, 0,         0 },
  657 /*4f*/  { "rex.wrxb", FALSE, NONE, 0,        0 },
  658 
  659 /*50*/  { "push",  FALSE, LONG,  op1(Ri),    0 },
  660 /*51*/  { "push",  FALSE, LONG,  op1(Ri),    0 },
  661 /*52*/  { "push",  FALSE, LONG,  op1(Ri),    0 },
  662 /*53*/  { "push",  FALSE, LONG,  op1(Ri),    0 },
  663 /*54*/  { "push",  FALSE, LONG,  op1(Ri),    0 },
  664 /*55*/  { "push",  FALSE, LONG,  op1(Ri),    0 },
  665 /*56*/  { "push",  FALSE, LONG,  op1(Ri),    0 },
  666 /*57*/  { "push",  FALSE, LONG,  op1(Ri),    0 },
  667 
  668 /*58*/  { "pop",   FALSE, LONG,  op1(Ri),    0 },
  669 /*59*/  { "pop",   FALSE, LONG,  op1(Ri),    0 },
  670 /*5a*/  { "pop",   FALSE, LONG,  op1(Ri),    0 },
  671 /*5b*/  { "pop",   FALSE, LONG,  op1(Ri),    0 },
  672 /*5c*/  { "pop",   FALSE, LONG,  op1(Ri),    0 },
  673 /*5d*/  { "pop",   FALSE, LONG,  op1(Ri),    0 },
  674 /*5e*/  { "pop",   FALSE, LONG,  op1(Ri),    0 },
  675 /*5f*/  { "pop",   FALSE, LONG,  op1(Ri),    0 },
  676 
  677 /*60*/  { "pusha", FALSE, LONG,  0,          0 },
  678 /*61*/  { "popa",  FALSE, LONG,  0,          0 },
  679 /*62*/  { "bound", TRUE,  LONG,  op2(E, R),  0 },
  680 /*63*/  { "movslq",  TRUE,  NONE,  op2(EL,R), 0 },
  681 
  682 /*64*/  { "",      FALSE, NONE,  0,          0 },
  683 /*65*/  { "",      FALSE, NONE,  0,          0 },
  684 /*66*/  { "",      FALSE, NONE,  0,          0 },
  685 /*67*/  { "",      FALSE, NONE,  0,          0 },
  686 
  687 /*68*/  { "push",  FALSE, LONG,  op1(I),     0 },
  688 /*69*/  { "imul",  TRUE,  LONG,  op3(I,E,R), 0 },
  689 /*6a*/  { "push",  FALSE, LONG,  op1(Ibs),   0 },
  690 /*6b*/  { "imul",  TRUE,  LONG,  op3(Ibs,E,R),0 },
  691 /*6c*/  { "ins",   FALSE, BYTE,  op2(DX, DI), 0 },
  692 /*6d*/  { "ins",   FALSE, LONG,  op2(DX, DI), 0 },
  693 /*6e*/  { "outs",  FALSE, BYTE,  op2(SI, DX), 0 },
  694 /*6f*/  { "outs",  FALSE, LONG,  op2(SI, DX), 0 },
  695 
  696 /*70*/  { "jo",    FALSE, NONE,  op1(Db),     0 },
  697 /*71*/  { "jno",   FALSE, NONE,  op1(Db),     0 },
  698 /*72*/  { "jb",    FALSE, NONE,  op1(Db),     0 },
  699 /*73*/  { "jnb",   FALSE, NONE,  op1(Db),     0 },
  700 /*74*/  { "jz",    FALSE, NONE,  op1(Db),     0 },
  701 /*75*/  { "jnz",   FALSE, NONE,  op1(Db),     0 },
  702 /*76*/  { "jbe",   FALSE, NONE,  op1(Db),     0 },
  703 /*77*/  { "jnbe",  FALSE, NONE,  op1(Db),     0 },
  704 
  705 /*78*/  { "js",    FALSE, NONE,  op1(Db),     0 },
  706 /*79*/  { "jns",   FALSE, NONE,  op1(Db),     0 },
  707 /*7a*/  { "jp",    FALSE, NONE,  op1(Db),     0 },
  708 /*7b*/  { "jnp",   FALSE, NONE,  op1(Db),     0 },
  709 /*7c*/  { "jl",    FALSE, NONE,  op1(Db),     0 },
  710 /*7d*/  { "jnl",   FALSE, NONE,  op1(Db),     0 },
  711 /*7e*/  { "jle",   FALSE, NONE,  op1(Db),     0 },
  712 /*7f*/  { "jnle",  FALSE, NONE,  op1(Db),     0 },
  713 
  714 /*80*/  { "",      TRUE,  BYTE,  op2(I, E),   db_Grp1 },
  715 /*81*/  { "",      TRUE,  LONG,  op2(I, E),   db_Grp1 },
  716 /*82*/  { "",      TRUE,  BYTE,  op2(I, E),   db_Grp1 },
  717 /*83*/  { "",      TRUE,  LONG,  op2(Ibs,E),  db_Grp1 },
  718 /*84*/  { "test",  TRUE,  BYTE,  op2(R, E),   0 },
  719 /*85*/  { "test",  TRUE,  LONG,  op2(R, E),   0 },
  720 /*86*/  { "xchg",  TRUE,  BYTE,  op2(R, E),   0 },
  721 /*87*/  { "xchg",  TRUE,  LONG,  op2(R, E),   0 },
  722 
  723 /*88*/  { "mov",   TRUE,  BYTE,  op2(R, E),   0 },
  724 /*89*/  { "mov",   TRUE,  LONG,  op2(R, E),   0 },
  725 /*8a*/  { "mov",   TRUE,  BYTE,  op2(E, R),   0 },
  726 /*8b*/  { "mov",   TRUE,  LONG,  op2(E, R),   0 },
  727 /*8c*/  { "mov",   TRUE,  NONE,  op2(S, Ew),  0 },
  728 /*8d*/  { "lea",   TRUE,  LONG,  op2(E, R),   0 },
  729 /*8e*/  { "mov",   TRUE,  NONE,  op2(Ew, S),  0 },
  730 /*8f*/  { "pop",   TRUE,  LONG,  op1(E),      0 },
  731 
  732 /*90*/  { "nop",   FALSE, NONE,  0,           0 },
  733 /*91*/  { "xchg",  FALSE, LONG,  op2(A, Ri),  0 },
  734 /*92*/  { "xchg",  FALSE, LONG,  op2(A, Ri),  0 },
  735 /*93*/  { "xchg",  FALSE, LONG,  op2(A, Ri),  0 },
  736 /*94*/  { "xchg",  FALSE, LONG,  op2(A, Ri),  0 },
  737 /*95*/  { "xchg",  FALSE, LONG,  op2(A, Ri),  0 },
  738 /*96*/  { "xchg",  FALSE, LONG,  op2(A, Ri),  0 },
  739 /*97*/  { "xchg",  FALSE, LONG,  op2(A, Ri),  0 },
  740 
  741 /*98*/  { "cbw",   FALSE, SDEP,  0,           "cwde" }, /* cbw/cwde */
  742 /*99*/  { "cwd",   FALSE, SDEP,  0,           "cdq"  }, /* cwd/cdq */
  743 /*9a*/  { "lcall", FALSE, NONE,  op1(OS),     0 },
  744 /*9b*/  { "wait",  FALSE, NONE,  0,           0 },
  745 /*9c*/  { "pushf", FALSE, LONG,  0,           0 },
  746 /*9d*/  { "popf",  FALSE, LONG,  0,           0 },
  747 /*9e*/  { "sahf",  FALSE, NONE,  0,           0 },
  748 /*9f*/  { "lahf",  FALSE, NONE,  0,           0 },
  749 
  750 /*a0*/  { "mov",   FALSE, BYTE,  op2(O, A),   0 },
  751 /*a1*/  { "mov",   FALSE, LONG,  op2(O, A),   0 },
  752 /*a2*/  { "mov",   FALSE, BYTE,  op2(A, O),   0 },
  753 /*a3*/  { "mov",   FALSE, LONG,  op2(A, O),   0 },
  754 /*a4*/  { "movs",  FALSE, BYTE,  op2(SI,DI),  0 },
  755 /*a5*/  { "movs",  FALSE, LONG,  op2(SI,DI),  0 },
  756 /*a6*/  { "cmps",  FALSE, BYTE,  op2(SI,DI),  0 },
  757 /*a7*/  { "cmps",  FALSE, LONG,  op2(SI,DI),  0 },
  758 
  759 /*a8*/  { "test",  FALSE, BYTE,  op2(I, A),   0 },
  760 /*a9*/  { "test",  FALSE, LONG,  op2(I, A),   0 },
  761 /*aa*/  { "stos",  FALSE, BYTE,  op1(DI),     0 },
  762 /*ab*/  { "stos",  FALSE, LONG,  op1(DI),     0 },
  763 /*ac*/  { "lods",  FALSE, BYTE,  op1(SI),     0 },
  764 /*ad*/  { "lods",  FALSE, LONG,  op1(SI),     0 },
  765 /*ae*/  { "scas",  FALSE, BYTE,  op1(SI),     0 },
  766 /*af*/  { "scas",  FALSE, LONG,  op1(SI),     0 },
  767 
  768 /*b0*/  { "mov",   FALSE, BYTE,  op2(I, Ri),  0 },
  769 /*b1*/  { "mov",   FALSE, BYTE,  op2(I, Ri),  0 },
  770 /*b2*/  { "mov",   FALSE, BYTE,  op2(I, Ri),  0 },
  771 /*b3*/  { "mov",   FALSE, BYTE,  op2(I, Ri),  0 },
  772 /*b4*/  { "mov",   FALSE, BYTE,  op2(I, Ri),  0 },
  773 /*b5*/  { "mov",   FALSE, BYTE,  op2(I, Ri),  0 },
  774 /*b6*/  { "mov",   FALSE, BYTE,  op2(I, Ri),  0 },
  775 /*b7*/  { "mov",   FALSE, BYTE,  op2(I, Ri),  0 },
  776 
  777 /*b8*/  { "mov",   FALSE, LONG,  op2(Ilq, Ri),  0 },
  778 /*b9*/  { "mov",   FALSE, LONG,  op2(Ilq, Ri),  0 },
  779 /*ba*/  { "mov",   FALSE, LONG,  op2(Ilq, Ri),  0 },
  780 /*bb*/  { "mov",   FALSE, LONG,  op2(Ilq, Ri),  0 },
  781 /*bc*/  { "mov",   FALSE, LONG,  op2(Ilq, Ri),  0 },
  782 /*bd*/  { "mov",   FALSE, LONG,  op2(Ilq, Ri),  0 },
  783 /*be*/  { "mov",   FALSE, LONG,  op2(Ilq, Ri),  0 },
  784 /*bf*/  { "mov",   FALSE, LONG,  op2(Ilq, Ri),  0 },
  785 
  786 /*c0*/  { "",      TRUE,  BYTE,  op2(Ib, E),  db_Grp2 },
  787 /*c1*/  { "",      TRUE,  LONG,  op2(Ib, E),  db_Grp2 },
  788 /*c2*/  { "ret",   FALSE, NONE,  op1(Iw),     0 },
  789 /*c3*/  { "ret",   FALSE, NONE,  0,           0 },
  790 /*c4*/  { "les",   TRUE,  LONG,  op2(E, R),   0 },
  791 /*c5*/  { "lds",   TRUE,  LONG,  op2(E, R),   0 },
  792 /*c6*/  { "mov",   TRUE,  BYTE,  op2(I, E),   0 },
  793 /*c7*/  { "mov",   TRUE,  LONG,  op2(I, E),   0 },
  794 
  795 /*c8*/  { "enter", FALSE, NONE,  op2(Iw, Ib), 0 },
  796 /*c9*/  { "leave", FALSE, NONE,  0,           0 },
  797 /*ca*/  { "lret",  FALSE, NONE,  op1(Iw),     0 },
  798 /*cb*/  { "lret",  FALSE, NONE,  0,           0 },
  799 /*cc*/  { "int",   FALSE, NONE,  op1(o3),     0 },
  800 /*cd*/  { "int",   FALSE, NONE,  op1(Ib),     0 },
  801 /*ce*/  { "into",  FALSE, NONE,  0,           0 },
  802 /*cf*/  { "iret",  FALSE, NONE,  0,           0 },
  803 
  804 /*d0*/  { "",      TRUE,  BYTE,  op2(o1, E),  db_Grp2 },
  805 /*d1*/  { "",      TRUE,  LONG,  op2(o1, E),  db_Grp2 },
  806 /*d2*/  { "",      TRUE,  BYTE,  op2(CL, E),  db_Grp2 },
  807 /*d3*/  { "",      TRUE,  LONG,  op2(CL, E),  db_Grp2 },
  808 /*d4*/  { "aam",   FALSE, NONE,  op1(Iba),    0 },
  809 /*d5*/  { "aad",   FALSE, NONE,  op1(Iba),    0 },
  810 /*d6*/  { ".byte\t0xd6", FALSE, NONE, 0,      0 },
  811 /*d7*/  { "xlat",  FALSE, BYTE,  op1(BX),     0 },
  812 
  813 /*d8*/  { "",      TRUE,  NONE,  0,           db_Esc8 },
  814 /*d9*/  { "",      TRUE,  NONE,  0,           db_Esc9 },
  815 /*da*/  { "",      TRUE,  NONE,  0,           db_Esca },
  816 /*db*/  { "",      TRUE,  NONE,  0,           db_Escb },
  817 /*dc*/  { "",      TRUE,  NONE,  0,           db_Escc },
  818 /*dd*/  { "",      TRUE,  NONE,  0,           db_Escd },
  819 /*de*/  { "",      TRUE,  NONE,  0,           db_Esce },
  820 /*df*/  { "",      TRUE,  NONE,  0,           db_Escf },
  821 
  822 /*e0*/  { "loopne",FALSE, NONE,  op1(Db),     0 },
  823 /*e1*/  { "loope", FALSE, NONE,  op1(Db),     0 },
  824 /*e2*/  { "loop",  FALSE, NONE,  op1(Db),     0 },
  825 /*e3*/  { "jcxz",  FALSE, SDEP,  op1(Db),     "jecxz" },
  826 /*e4*/  { "in",    FALSE, BYTE,  op2(Ib, A),  0 },
  827 /*e5*/  { "in",    FALSE, LONG,  op2(Ib, A) , 0 },
  828 /*e6*/  { "out",   FALSE, BYTE,  op2(A, Ib),  0 },
  829 /*e7*/  { "out",   FALSE, LONG,  op2(A, Ib) , 0 },
  830 
  831 /*e8*/  { "call",  FALSE, NONE,  op1(Dl),     0 },
  832 /*e9*/  { "jmp",   FALSE, NONE,  op1(Dl),     0 },
  833 /*ea*/  { "ljmp",  FALSE, NONE,  op1(OS),     0 },
  834 /*eb*/  { "jmp",   FALSE, NONE,  op1(Db),     0 },
  835 /*ec*/  { "in",    FALSE, BYTE,  op2(DX, A),  0 },
  836 /*ed*/  { "in",    FALSE, LONG,  op2(DX, A) , 0 },
  837 /*ee*/  { "out",   FALSE, BYTE,  op2(A, DX),  0 },
  838 /*ef*/  { "out",   FALSE, LONG,  op2(A, DX) , 0 },
  839 
  840 /*f0*/  { "",      FALSE, NONE,  0,          0 },
  841 /*f1*/  { ".byte\t0xf1", FALSE, NONE, 0,     0 },
  842 /*f2*/  { "",      FALSE, NONE,  0,          0 },
  843 /*f3*/  { "",      FALSE, NONE,  0,          0 },
  844 /*f4*/  { "hlt",   FALSE, NONE,  0,          0 },
  845 /*f5*/  { "cmc",   FALSE, NONE,  0,          0 },
  846 /*f6*/  { "",      TRUE,  BYTE,  0,          db_Grp3 },
  847 /*f7*/  { "",      TRUE,  LONG,  0,          db_Grp3 },
  848 
  849 /*f8*/  { "clc",   FALSE, NONE,  0,          0 },
  850 /*f9*/  { "stc",   FALSE, NONE,  0,          0 },
  851 /*fa*/  { "cli",   FALSE, NONE,  0,          0 },
  852 /*fb*/  { "sti",   FALSE, NONE,  0,          0 },
  853 /*fc*/  { "cld",   FALSE, NONE,  0,          0 },
  854 /*fd*/  { "std",   FALSE, NONE,  0,          0 },
  855 /*fe*/  { "",      TRUE,  NONE,  0,          db_Grp4 },
  856 /*ff*/  { "",      TRUE,  NONE,  0,          db_Grp5 },
  857 };
  858 
  859 static const struct inst db_bad_inst =
  860         { "???",   FALSE, NONE,  0,           0 }
  861 ;
  862 
  863 #define f_mod(rex, byte)        ((byte)>>6)
  864 #define f_reg(rex, byte)        ((((byte)>>3)&0x7) | (rex & REX_R ? 0x8 : 0x0))
  865 #define f_rm(rex, byte)         (((byte)&0x7) | (rex & REX_B ? 0x8 : 0x0))
  866 
  867 #define sib_ss(rex, byte)       ((byte)>>6)
  868 #define sib_index(rex, byte)    ((((byte)>>3)&0x7) | (rex & REX_X ? 0x8 : 0x0))
  869 #define sib_base(rex, byte)     (((byte)&0x7) | (rex & REX_B ? 0x8 : 0x0))
  870 
  871 struct i_addr {
  872         int             is_reg; /* if reg, reg number is in 'disp' */
  873         int             disp;
  874         const char *    base;
  875         const char *    index;
  876         int             ss;
  877 };
  878 
  879 static const char * const db_reg[2][4][16] = {
  880 
  881         {{"%al",  "%cl",  "%dl",  "%bl",  "%ah",  "%ch",  "%dh",  "%bh",
  882           "%r8b", "%r9b", "%r10b", "%r11b", "%r12b", "%r13b", "%r14b", "%r15b" },
  883         { "%ax",  "%cx",  "%dx",  "%bx",  "%sp",  "%bp",  "%si",  "%di",
  884           "%r8w", "%r9w", "%r10w", "%r11w", "%r12w", "%r13w", "%r14w", "%r15w" },
  885         { "%eax", "%ecx", "%edx", "%ebx", "%esp", "%ebp", "%esi", "%edi",
  886           "%r8d", "%r9d", "%r10d", "%r11d", "%r12d", "%r13d", "%r14d", "%r15d" },
  887         { "%rax", "%rcx", "%rdx", "%rbx", "%rsp", "%rbp", "%rsi", "%rdi",
  888           "%r8", "%r9", "%r10", "%r11", "%r12", "%r13", "%r14", "%r15" }},
  889 
  890         {{"%al",  "%cl",  "%dl",  "%bl",  "%spl",  "%bpl",  "%sil",  "%dil",
  891           "%r8b", "%r9b", "%r10b", "%r11b", "%r12b", "%r13b", "%r14b", "%r15b" },
  892         { "%ax",  "%cx",  "%dx",  "%bx",  "%sp",  "%bp",  "%si",  "%di",
  893           "%r8w", "%r9w", "%r10w", "%r11w", "%r12w", "%r13w", "%r14w", "%r15w" },
  894         { "%eax", "%ecx", "%edx", "%ebx", "%esp", "%ebp", "%esi", "%edi",
  895           "%r8d", "%r9d", "%r10d", "%r11d", "%r12d", "%r13d", "%r14d", "%r15d" },
  896         { "%rax", "%rcx", "%rdx", "%rbx", "%rsp", "%rbp", "%rsi", "%rdi",
  897           "%r8", "%r9", "%r10", "%r11", "%r12", "%r13", "%r14", "%r15" }}
  898 };
  899 
  900 static const char * const db_seg_reg[8] = {
  901         "%es", "%cs", "%ss", "%ds", "%fs", "%gs", "", ""
  902 };
  903 
  904 /*
  905  * lengths for size attributes
  906  */
  907 static const int db_lengths[] = {
  908         1,      /* BYTE */
  909         2,      /* WORD */
  910         4,      /* LONG */
  911         8,      /* QUAD */
  912         4,      /* SNGL */
  913         8,      /* DBLR */
  914         10,     /* EXTR */
  915 };
  916 
  917 #define get_value_inc(result, loc, size, is_signed) \
  918         result = db_get_value((loc), (size), (is_signed)); \
  919         (loc) += (size);
  920 
  921 static db_addr_t
  922                 db_disasm_esc(db_addr_t loc, int inst, int rex, int short_addr,
  923                     int size, const char *seg);
  924 static void     db_print_address(const char *seg, int size, int rex,
  925                     struct i_addr *addrp);
  926 static db_addr_t
  927                 db_read_address(db_addr_t loc, int short_addr, int rex, int regmodrm,
  928                     struct i_addr *addrp);
  929 
  930 /*
  931  * Read address at location and return updated location.
  932  */
  933 static db_addr_t
  934 db_read_address(loc, short_addr, rex, regmodrm, addrp)
  935         db_addr_t       loc;
  936         int             short_addr;
  937         int             rex;
  938         int             regmodrm;
  939         struct i_addr * addrp;          /* out */
  940 {
  941         int             mod, rm, sib, index, disp, size, have_sib;
  942 
  943         mod = f_mod(rex, regmodrm);
  944         rm  = f_rm(rex, regmodrm);
  945 
  946         if (mod == 3) {
  947             addrp->is_reg = TRUE;
  948             addrp->disp = rm;
  949             return (loc);
  950         }
  951         addrp->is_reg = FALSE;
  952         addrp->index = 0;
  953 
  954         if (short_addr)
  955             size = LONG;
  956         else
  957             size = QUAD;
  958 
  959         if ((rm & 0x7) == 4) {
  960             get_value_inc(sib, loc, 1, FALSE);
  961             rm = sib_base(rex, sib);
  962             index = sib_index(rex, sib);
  963             if (index != 4)
  964                 addrp->index = db_reg[1][size][index];
  965             addrp->ss = sib_ss(rex, sib);
  966             have_sib = 1;
  967         } else
  968             have_sib = 0;
  969 
  970         switch (mod) {
  971             case 0:
  972                 if (rm == 5) {
  973                     get_value_inc(addrp->disp, loc, 4, FALSE);
  974                     if (have_sib)
  975                         addrp->base = 0;
  976                     else if (short_addr)
  977                         addrp->base = "%eip";
  978                     else
  979                         addrp->base = "%rip";
  980                 } else {
  981                     addrp->disp = 0;
  982                     addrp->base = db_reg[1][size][rm];
  983                 }
  984                 break;
  985 
  986             case 1:
  987                 get_value_inc(disp, loc, 1, TRUE);
  988                 addrp->disp = disp;
  989                 addrp->base = db_reg[1][size][rm];
  990                 break;
  991 
  992             case 2:
  993                 get_value_inc(disp, loc, 4, FALSE);
  994                 addrp->disp = disp;
  995                 addrp->base = db_reg[1][size][rm];
  996                 break;
  997         }
  998         return (loc);
  999 }
 1000 
 1001 static void
 1002 db_print_address(seg, size, rex, addrp)
 1003         const char *    seg;
 1004         int             size;
 1005         int             rex;
 1006         struct i_addr * addrp;
 1007 {
 1008         if (addrp->is_reg) {
 1009             db_printf("%s", db_reg[rex != 0 ? 1 : 0][(size == LONG && (rex & REX_W)) ? QUAD : size][addrp->disp]);
 1010             return;
 1011         }
 1012 
 1013         if (seg) {
 1014             db_printf("%s:", seg);
 1015         }
 1016 
 1017         if (addrp->disp != 0 || (addrp->base == 0 && addrp->index == 0))
 1018                 db_printsym((db_addr_t)addrp->disp, DB_STGY_ANY);
 1019         if (addrp->base != 0 || addrp->index != 0) {
 1020             db_printf("(");
 1021             if (addrp->base)
 1022                 db_printf("%s", addrp->base);
 1023             if (addrp->index)
 1024                 db_printf(",%s,%d", addrp->index, 1<<addrp->ss);
 1025             db_printf(")");
 1026         }
 1027 }
 1028 
 1029 /*
 1030  * Disassemble floating-point ("escape") instruction
 1031  * and return updated location.
 1032  */
 1033 static db_addr_t
 1034 db_disasm_esc(loc, inst, rex, short_addr, size, seg)
 1035         db_addr_t       loc;
 1036         int             inst;
 1037         int             rex;
 1038         int             short_addr;
 1039         int             size;
 1040         const char *    seg;
 1041 {
 1042         int             regmodrm;
 1043         const struct finst *    fp;
 1044         int             mod;
 1045         struct i_addr   address;
 1046         const char *    name;
 1047 
 1048         get_value_inc(regmodrm, loc, 1, FALSE);
 1049         fp = &db_Esc_inst[inst - 0xd8][f_reg(rex, regmodrm)];
 1050         mod = f_mod(rex, regmodrm);
 1051         if (mod != 3) {
 1052             if (*fp->f_name == '\0') {
 1053                 db_printf("<bad instruction>");
 1054                 return (loc);
 1055             }
 1056             /*
 1057              * Normal address modes.
 1058              */
 1059             loc = db_read_address(loc, short_addr, rex, regmodrm, &address);
 1060             db_printf("%s", fp->f_name);
 1061             switch(fp->f_size) {
 1062                 case SNGL:
 1063                     db_printf("s");
 1064                     break;
 1065                 case DBLR:
 1066                     db_printf("l");
 1067                     break;
 1068                 case EXTR:
 1069                     db_printf("t");
 1070                     break;
 1071                 case WORD:
 1072                     db_printf("s");
 1073                     break;
 1074                 case LONG:
 1075                     db_printf("l");
 1076                     break;
 1077                 case QUAD:
 1078                     db_printf("q");
 1079                     break;
 1080                 default:
 1081                     break;
 1082             }
 1083             db_printf("\t");
 1084             db_print_address(seg, BYTE, rex, &address);
 1085         }
 1086         else {
 1087             /*
 1088              * 'reg-reg' - special formats
 1089              */
 1090             switch (fp->f_rrmode) {
 1091                 case op2(ST,STI):
 1092                     name = (fp->f_rrname) ? fp->f_rrname : fp->f_name;
 1093                     db_printf("%s\t%%st,%%st(%d)",name,f_rm(rex, regmodrm));
 1094                     break;
 1095                 case op2(STI,ST):
 1096                     name = (fp->f_rrname) ? fp->f_rrname : fp->f_name;
 1097                     db_printf("%s\t%%st(%d),%%st",name, f_rm(rex, regmodrm));
 1098                     break;
 1099                 case op1(STI):
 1100                     name = (fp->f_rrname) ? fp->f_rrname : fp->f_name;
 1101                     db_printf("%s\t%%st(%d)",name, f_rm(rex, regmodrm));
 1102                     break;
 1103                 case op1(X):
 1104                     name = ((const char * const *)fp->f_rrname)[f_rm(rex, regmodrm)];
 1105                     if (*name == '\0')
 1106                         goto bad;
 1107                     db_printf("%s", name);
 1108                     break;
 1109                 case op1(XA):
 1110                     name = ((const char * const *)fp->f_rrname)[f_rm(rex, regmodrm)];
 1111                     if (*name == '\0')
 1112                         goto bad;
 1113                     db_printf("%s\t%%ax", name);
 1114                     break;
 1115                 default:
 1116                 bad:
 1117                     db_printf("<bad instruction>");
 1118                     break;
 1119             }
 1120         }
 1121 
 1122         return (loc);
 1123 }
 1124 
 1125 /*
 1126  * Disassemble instruction at 'loc'.  'altfmt' specifies an
 1127  * (optional) alternate format.  Return address of start of
 1128  * next instruction.
 1129  */
 1130 db_addr_t
 1131 db_disasm(loc, altfmt)
 1132         db_addr_t       loc;
 1133         boolean_t       altfmt;
 1134 {
 1135         int     inst;
 1136         int     size;
 1137         int     short_addr;
 1138         const char *    seg;
 1139         const struct inst *     ip;
 1140         const char *    i_name;
 1141         int     i_size;
 1142         int     i_mode;
 1143         int     rex = 0;
 1144         int     regmodrm = 0;
 1145         boolean_t       first;
 1146         int     displ;
 1147         int     prefix;
 1148         int     rep;
 1149         int     imm;
 1150         int     imm2;
 1151         long    imm64;
 1152         int     len;
 1153         struct i_addr   address;
 1154 
 1155         get_value_inc(inst, loc, 1, FALSE);
 1156         short_addr = FALSE;
 1157         size = LONG;
 1158         seg = 0;
 1159 
 1160         /*
 1161          * Get prefixes
 1162          */
 1163         rep = FALSE;
 1164         prefix = TRUE;
 1165         do {
 1166             switch (inst) {
 1167                 case 0x66:              /* data16 */
 1168                     size = WORD;
 1169                     break;
 1170                 case 0x67:
 1171                     short_addr = TRUE;
 1172                     break;
 1173                 case 0x26:
 1174                     seg = "%es";
 1175                     break;
 1176                 case 0x36:
 1177                     seg = "%ss";
 1178                     break;
 1179                 case 0x2e:
 1180                     seg = "%cs";
 1181                     break;
 1182                 case 0x3e:
 1183                     seg = "%ds";
 1184                     break;
 1185                 case 0x64:
 1186                     seg = "%fs";
 1187                     break;
 1188                 case 0x65:
 1189                     seg = "%gs";
 1190                     break;
 1191                 case 0xf0:
 1192                     db_printf("lock ");
 1193                     break;
 1194                 case 0xf2:
 1195                     db_printf("repne ");
 1196                     break;
 1197                 case 0xf3:
 1198                     rep = TRUE;
 1199                     break;
 1200                 default:
 1201                     prefix = FALSE;
 1202                     break;
 1203             }
 1204             if (inst >= 0x40 && inst < 0x50) {
 1205                 rex = inst;
 1206                 prefix = TRUE;
 1207             }
 1208             if (prefix) {
 1209                 get_value_inc(inst, loc, 1, FALSE);
 1210             }
 1211             if (rep == TRUE) {
 1212                 if (inst == 0x90) {
 1213                     db_printf("pause\n");
 1214                     return (loc);
 1215                 }
 1216                 db_printf("repe ");     /* XXX repe VS rep */
 1217                 rep = FALSE;
 1218             }
 1219         } while (prefix);
 1220 
 1221         if (inst >= 0xd8 && inst <= 0xdf) {
 1222             loc = db_disasm_esc(loc, inst, rex, short_addr, size, seg);
 1223             db_printf("\n");
 1224             return (loc);
 1225         }
 1226 
 1227         if (inst == 0x0f) {
 1228             get_value_inc(inst, loc, 1, FALSE);
 1229             ip = db_inst_0f[inst>>4];
 1230             if (ip == 0) {
 1231                 ip = &db_bad_inst;
 1232             }
 1233             else {
 1234                 ip = &ip[inst&0xf];
 1235             }
 1236         }
 1237         else
 1238             ip = &db_inst_table[inst];
 1239 
 1240         if (ip->i_has_modrm) {
 1241             get_value_inc(regmodrm, loc, 1, FALSE);
 1242             loc = db_read_address(loc, short_addr, rex, regmodrm, &address);
 1243         }
 1244 
 1245         i_name = ip->i_name;
 1246         i_size = ip->i_size;
 1247         i_mode = ip->i_mode;
 1248 
 1249         if (ip->i_extra == db_Grp1 || ip->i_extra == db_Grp2 ||
 1250             ip->i_extra == db_Grp6 || ip->i_extra == db_Grp7 ||
 1251             ip->i_extra == db_Grp8 || ip->i_extra == db_Grp9 ||
 1252             ip->i_extra == db_Grp15) {
 1253             i_name = ((const char * const *)ip->i_extra)[f_reg(rex, regmodrm)];
 1254         }
 1255         else if (ip->i_extra == db_Grp3) {
 1256             ip = ip->i_extra;
 1257             ip = &ip[f_reg(rex, regmodrm)];
 1258             i_name = ip->i_name;
 1259             i_mode = ip->i_mode;
 1260         }
 1261         else if (ip->i_extra == db_Grp4 || ip->i_extra == db_Grp5) {
 1262             ip = ip->i_extra;
 1263             ip = &ip[f_reg(rex, regmodrm)];
 1264             i_name = ip->i_name;
 1265             i_mode = ip->i_mode;
 1266             i_size = ip->i_size;
 1267         }
 1268 
 1269         /* Special cases that don't fit well in the tables. */
 1270         if (ip->i_extra == db_Grp7 && f_mod(rex, regmodrm) == 3) {
 1271                 switch (regmodrm) {
 1272                 case 0xc8:
 1273                         i_name = "monitor";
 1274                         i_size = NONE;
 1275                         i_mode = 0;                     
 1276                         break;
 1277                 case 0xc9:
 1278                         i_name = "mwait";
 1279                         i_size = NONE;
 1280                         i_mode = 0;
 1281                         break;
 1282                 case 0xf8:
 1283                         i_name = "swapgs";
 1284                         i_size = NONE;
 1285                         i_mode = 0;
 1286                         break;
 1287                 }
 1288         }
 1289         if (ip->i_extra == db_Grp15 && f_mod(rex, regmodrm) == 3) {
 1290                 i_name = db_Grp15b[f_reg(rex, regmodrm)];
 1291                 i_size = NONE;
 1292                 i_mode = 0;
 1293         }
 1294 
 1295         if (i_size == SDEP) {
 1296             if (size == WORD)
 1297                 db_printf("%s", i_name);
 1298             else
 1299                 db_printf("%s", (const char *)ip->i_extra);
 1300         }
 1301         else {
 1302             db_printf("%s", i_name);
 1303             if ((inst >= 0x50 && inst <= 0x5f) || inst == 0x68 || inst == 0x6a) {
 1304                 i_size = NONE;
 1305                 db_printf("q");
 1306             }
 1307             if (i_size != NONE) {
 1308                 if (i_size == BYTE) {
 1309                     db_printf("b");
 1310                     size = BYTE;
 1311                 }
 1312                 else if (i_size == WORD) {
 1313                     db_printf("w");
 1314                     size = WORD;
 1315                 }
 1316                 else if (size == WORD)
 1317                     db_printf("w");
 1318                 else {
 1319                     if (rex & REX_W)
 1320                         db_printf("q");
 1321                     else
 1322                         db_printf("l");
 1323                 }
 1324             }
 1325         }
 1326         db_printf("\t");
 1327         for (first = TRUE;
 1328              i_mode != 0;
 1329              i_mode >>= 8, first = FALSE)
 1330         {
 1331             if (!first)
 1332                 db_printf(",");
 1333 
 1334             switch (i_mode & 0xFF) {
 1335 
 1336                 case E:
 1337                     db_print_address(seg, size, rex, &address);
 1338                     break;
 1339 
 1340                 case Eind:
 1341                     db_printf("*");
 1342                     db_print_address(seg, size, rex, &address);
 1343                     break;
 1344 
 1345                 case El:
 1346                     db_print_address(seg, (rex & REX_W) ? QUAD : LONG, rex, &address);
 1347                     break;
 1348 
 1349                 case EL:
 1350                     db_print_address(seg, LONG, 0, &address);
 1351                     break;
 1352 
 1353                 case Ew:
 1354                     db_print_address(seg, WORD, rex, &address);
 1355                     break;
 1356 
 1357                 case Eb:
 1358                     db_print_address(seg, BYTE, rex, &address);
 1359                     break;
 1360 
 1361                 case R:
 1362                     db_printf("%s", db_reg[rex != 0 ? 1 : 0][(size == LONG && (rex & REX_W)) ? QUAD : size][f_reg(rex, regmodrm)]);
 1363                     break;
 1364 
 1365                 case Rw:
 1366                     db_printf("%s", db_reg[rex != 0 ? 1 : 0][WORD][f_reg(rex, regmodrm)]);
 1367                     break;
 1368 
 1369                 case Ri:
 1370                     db_printf("%s", db_reg[0][QUAD][f_rm(rex, inst)]);
 1371                     break;
 1372 
 1373                 case Ril:
 1374                     db_printf("%s", db_reg[rex != 0 ? 1 : 0][(rex & REX_R) ? QUAD : LONG][f_rm(rex, inst)]);
 1375                     break;
 1376 
 1377                 case S:
 1378                     db_printf("%s", db_seg_reg[f_reg(rex, regmodrm)]);
 1379                     break;
 1380 
 1381                 case Si:
 1382                     db_printf("%s", db_seg_reg[f_reg(rex, inst)]);
 1383                     break;
 1384 
 1385                 case A:
 1386                     db_printf("%s", db_reg[rex != 0 ? 1 : 0][size][0]); /* acc */
 1387                     break;
 1388 
 1389                 case BX:
 1390                     if (seg)
 1391                         db_printf("%s:", seg);
 1392                     db_printf("(%s)", short_addr ? "%bx" : "%ebx");
 1393                     break;
 1394 
 1395                 case CL:
 1396                     db_printf("%%cl");
 1397                     break;
 1398 
 1399                 case DX:
 1400                     db_printf("%%dx");
 1401                     break;
 1402 
 1403                 case SI:
 1404                     if (seg)
 1405                         db_printf("%s:", seg);
 1406                     db_printf("(%s)", short_addr ? "%si" : "%rsi");
 1407                     break;
 1408 
 1409                 case DI:
 1410                     db_printf("%%es:(%s)", short_addr ? "%di" : "%rdi");
 1411                     break;
 1412 
 1413                 case CR:
 1414                     db_printf("%%cr%d", f_reg(rex, regmodrm));
 1415                     break;
 1416 
 1417                 case DR:
 1418                     db_printf("%%dr%d", f_reg(rex, regmodrm));
 1419                     break;
 1420 
 1421                 case TR:
 1422                     db_printf("%%tr%d", f_reg(rex, regmodrm));
 1423                     break;
 1424 
 1425                 case I:
 1426                     len = db_lengths[size];
 1427                     get_value_inc(imm, loc, len, FALSE);
 1428                     db_printf("$%#r", imm);
 1429                     break;
 1430 
 1431                 case Is:
 1432                     len = db_lengths[(size == LONG && (rex & REX_W)) ? QUAD : size];
 1433                     get_value_inc(imm, loc, len, FALSE);
 1434                     db_printf("$%+#r", imm);
 1435                     break;
 1436 
 1437                 case Ib:
 1438                     get_value_inc(imm, loc, 1, FALSE);
 1439                     db_printf("$%#r", imm);
 1440                     break;
 1441 
 1442                 case Iba:
 1443                     get_value_inc(imm, loc, 1, FALSE);
 1444                     if (imm != 0x0a)
 1445                         db_printf("$%#r", imm);
 1446                     break;
 1447 
 1448                 case Ibs:
 1449                     get_value_inc(imm, loc, 1, TRUE);
 1450                     if (size == WORD)
 1451                         imm &= 0xFFFF;
 1452                     db_printf("$%+#r", imm);
 1453                     break;
 1454 
 1455                 case Iw:
 1456                     get_value_inc(imm, loc, 2, FALSE);
 1457                     db_printf("$%#r", imm);
 1458                     break;
 1459 
 1460                 case Ilq:
 1461                     len = db_lengths[rex & REX_W ? QUAD : LONG];
 1462                     get_value_inc(imm64, loc, len, FALSE);
 1463                     db_printf("$%#lr", imm64);
 1464                     break;
 1465 
 1466                 case O:
 1467                     len = (short_addr ? 2 : 4);
 1468                     get_value_inc(displ, loc, len, FALSE);
 1469                     if (seg)
 1470                         db_printf("%s:%+#r",seg, displ);
 1471                     else
 1472                         db_printsym((db_addr_t)displ, DB_STGY_ANY);
 1473                     break;
 1474 
 1475                 case Db:
 1476                     get_value_inc(displ, loc, 1, TRUE);
 1477                     displ += loc;
 1478                     if (size == WORD)
 1479                         displ &= 0xFFFF;
 1480                     db_printsym((db_addr_t)displ, DB_STGY_XTRN);
 1481                     break;
 1482 
 1483                 case Dl:
 1484                     len = db_lengths[(size == LONG && (rex & REX_W)) ? QUAD : size];
 1485                     get_value_inc(displ, loc, len, FALSE);
 1486                     displ += loc;
 1487                     if (size == WORD)
 1488                         displ &= 0xFFFF;
 1489                     db_printsym((db_addr_t)displ, DB_STGY_XTRN);
 1490                     break;
 1491 
 1492                 case o1:
 1493                     db_printf("$1");
 1494                     break;
 1495 
 1496                 case o3:
 1497                     db_printf("$3");
 1498                     break;
 1499 
 1500                 case OS:
 1501                     len = db_lengths[size];
 1502                     get_value_inc(imm, loc, len, FALSE);        /* offset */
 1503                     get_value_inc(imm2, loc, 2, FALSE); /* segment */
 1504                     db_printf("$%#r,%#r", imm2, imm);
 1505                     break;
 1506             }
 1507         }
 1508         db_printf("\n");
 1509         return (loc);
 1510 }

Cache object: 2522278d0dde83d7c344471a0182c03f


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.