[ 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  -  FREEBSD7  -  FREEBSD71  -  FREEBSD70  -  FREEBSD6  -  FREEBSD64  -  FREEBSD63  -  FREEBSD62  -  FREEBSD61  -  FREEBSD60  -  FREEBSD5  -  FREEBSD55  -  FREEBSD54  -  FREEBSD53  -  FREEBSD52  -  FREEBSD51  -  FREEBSD50  -  FREEBSD4  -  FREEBSD3  -  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  -  OPENSOLARIS  -  minix-3-1-1  -  TRUSTEDBSD-SEBSD  -  FREEBSD-LIBC  -  FREEBSD7-LIBC  -  FREEBSD6-LIBC  -  GLIBC27 
SearchContext: -  none  -  excerpts  -  bigexcerpts 

  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: src/sys/amd64/amd64/db_disasm.c,v 1.32 2008/08/11 20:19:42 jhb Exp $");
 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 },