2 * Mach Operating System
3 * Copyright (c) 1991,1990 Carnegie Mellon University
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.
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.
16 * Carnegie Mellon requests users of this software to return to
18 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
19 * School of Computer Science
20 * Carnegie Mellon University
21 * Pittsburgh PA 15213-3890
23 * any improvements or extensions that they make and grant Carnegie the
24 * rights to redistribute these changes.
28 * Instruction disassembler.
31 /* <Wine specific wrappers> */
35 static int (*db_printf
)(const char* format
, ...)
37 __attribute__((format (printf
,1,2)));
39 static int no_printf(const char* format
, ...) {return 0;}
40 typedef DWORD_PTR db_addr_t
;
41 typedef BOOL boolean_t
;
43 static ULONG64
db_get_value(db_addr_t addr
, int size
, int is_signed
)
48 if (size
!= 1 && size
!= 2 && size
!= 4 && size
!= 8)
50 db_printf("Illegal size specified\n");
52 else if (dbg_read_memory((void*)addr
, buffer
, size
))
57 if (is_signed
) result
= (ULONG64
)*(LONG64
*)buffer
;
58 else result
= *(ULONG64
*)buffer
;
61 if (is_signed
) result
= (ULONG
) *(LONG
*)buffer
;
62 else result
= *(ULONG64
*)buffer
;
65 if (is_signed
) result
= (unsigned int) *(short int *)buffer
;
66 else result
= *(unsigned short int *)buffer
;
69 if (is_signed
) result
= (unsigned int) *(char *)buffer
;
70 else result
= *(unsigned char *)buffer
;
78 #define DB_STGY_XTRN 0
80 static void db_printsym(db_addr_t addr
, unsigned unused
)
82 if (db_printf
!= no_printf
)
86 a
.Mode
= AddrModeFlat
;
89 print_address(&a
, FALSE
);
93 /* </Wine specific wrappers> */
109 * REX prefix and bits
120 #define E 1 /* general effective address */
121 #define Eind 2 /* indirect address (jump, call) */
122 #define Ew 3 /* address, word size */
123 #define Eb 4 /* address, byte size */
124 #define R 5 /* register, in 'reg' field */
125 #define Rw 6 /* word register, in 'reg' field */
126 #define Ri 7 /* register in instruction */
127 #define S 8 /* segment reg, in 'reg' field */
128 #define Si 9 /* segment reg, in instruction */
129 #define A 10 /* accumulator */
130 #define BX 11 /* (bx) */
131 #define CL 12 /* cl, for shifts */
132 #define DX 13 /* dx, for IO */
133 #define SI 14 /* si */
134 #define DI 15 /* di */
135 #define CR 16 /* control register */
136 #define DR 17 /* debug register */
137 #define TR 18 /* test register */
138 #define I 19 /* immediate, unsigned */
139 #define Is 20 /* immediate, signed */
140 #define Ib 21 /* byte immediate, unsigned */
141 #define Ibs 22 /* byte immediate, signed */
142 #define Iw 23 /* word immediate, unsigned */
143 #define Ilq 24 /* long/quad immediate, unsigned */
144 #define O 25 /* direct address */
145 #define Db 26 /* byte displacement from EIP */
146 #define Dl 27 /* long displacement from EIP */
147 #define o1 28 /* constant 1 */
148 #define o3 29 /* constant 3 */
149 #define OS 30 /* immediate offset/segment */
150 #define ST 31 /* FP stack top */
151 #define STI 32 /* FP stack */
152 #define X 33 /* extended FP op */
153 #define XA 34 /* for 'fstcw %ax' */
154 #define El 35 /* address, long/quad size */
155 #define Ril 36 /* long register in instruction */
156 #define Iba 37 /* byte immediate, don't print if 0xa */
157 #define EL 38 /* address, explicitly long size */
158 /* Wine extensions */
159 #define MX 39 /* special register (MMX reg %mm0-7) */
160 #define EMX 40 /* special register (MMX reg %mm0-7) */
161 #define XMM 41 /* special register (floating point reg %xmm0-7) */
162 #define EXMM 42 /* special register (floating point reg %xmm0-7) */
165 const char * i_name
; /* name */
166 short i_has_modrm
; /* has regmodrm byte */
167 short i_size
; /* operand size */
168 int i_mode
; /* addressing modes */
169 const void * i_extra
; /* pointer to extra opcode table */
173 #define op2(x,y) ((x)|((y)<<8))
174 #define op3(x,y,z) ((x)|((y)<<8)|((z)<<16))
177 const char * f_name
; /* name for memory instruction */
178 int f_size
; /* size for memory instruction */
179 int f_rrmode
; /* mode for rr instruction */
180 const void * f_rrname
; /* name for rr instruction
181 (or pointer to table) */
184 static const char * const db_Grp6
[] = {
195 static const char * const db_Grp7
[] = {
206 static const char * const db_Grp8
[] = {
217 static const char * const db_Grp9
[] = {
228 static const char * const db_Grp15
[] = {
239 static const char * const db_Grp15b
[] = {
250 static const struct inst db_inst_0f0x
[] = {
251 /*00*/ { "", TRUE
, NONE
, op1(Ew
), db_Grp6
},
252 /*01*/ { "", TRUE
, NONE
, op1(Ew
), db_Grp7
},
253 /*02*/ { "lar", TRUE
, LONG
, op2(E
,R
), 0 },
254 /*03*/ { "lsl", TRUE
, LONG
, op2(E
,R
), 0 },
255 /*04*/ { "", FALSE
, NONE
, 0, 0 },
256 /*05*/ { "syscall",FALSE
,NONE
, 0, 0 },
257 /*06*/ { "clts", FALSE
, NONE
, 0, 0 },
258 /*07*/ { "sysret",FALSE
, NONE
, 0, 0 },
260 /*08*/ { "invd", FALSE
, NONE
, 0, 0 },
261 /*09*/ { "wbinvd",FALSE
, NONE
, 0, 0 },
262 /*0a*/ { "", FALSE
, NONE
, 0, 0 },
263 /*0b*/ { "", FALSE
, NONE
, 0, 0 },
264 /*0c*/ { "", FALSE
, NONE
, 0, 0 },
265 /*0d*/ { "", FALSE
, NONE
, 0, 0 },
266 /*0e*/ { "", FALSE
, NONE
, 0, 0 },
267 /*0f*/ { "", FALSE
, NONE
, 0, 0 },
270 static const struct inst db_inst_0f2x
[] = {
271 /*20*/ { "mov", TRUE
, LONG
, op2(CR
,El
), 0 },
272 /*21*/ { "mov", TRUE
, LONG
, op2(DR
,El
), 0 },
273 /*22*/ { "mov", TRUE
, LONG
, op2(El
,CR
), 0 },
274 /*23*/ { "mov", TRUE
, LONG
, op2(El
,DR
), 0 },
275 /*24*/ { "mov", TRUE
, LONG
, op2(TR
,El
), 0 },
276 /*25*/ { "", FALSE
, NONE
, 0, 0 },
277 /*26*/ { "mov", TRUE
, LONG
, op2(El
,TR
), 0 },
278 /*27*/ { "", FALSE
, NONE
, 0, 0 },
280 /*28*/ { "", FALSE
, NONE
, 0, 0 },
281 /*29*/ { "", FALSE
, NONE
, 0, 0 },
282 /*2a*/ { "", FALSE
, NONE
, 0, 0 },
283 /*2b*/ { "", FALSE
, NONE
, 0, 0 },
284 /*2c*/ { "", FALSE
, NONE
, 0, 0 },
285 /*2d*/ { "", FALSE
, NONE
, 0, 0 },
286 /*2e*/ { "", FALSE
, NONE
, 0, 0 },
287 /*2f*/ { "", FALSE
, NONE
, 0, 0 },
290 static const struct inst db_inst_0f3x
[] = {
291 /*30*/ { "wrmsr", FALSE
, NONE
, 0, 0 },
292 /*31*/ { "rdtsc", FALSE
, NONE
, 0, 0 },
293 /*32*/ { "rdmsr", FALSE
, NONE
, 0, 0 },
294 /*33*/ { "rdpmc", FALSE
, NONE
, 0, 0 },
295 /*34*/ { "sysenter",FALSE
,NONE
, 0, 0 },
296 /*35*/ { "sysexit",FALSE
,NONE
, 0, 0 },
297 /*36*/ { "", FALSE
, NONE
, 0, 0 },
298 /*37*/ { "getsec",FALSE
, NONE
, 0, 0 },
300 /*38*/ { "", FALSE
, NONE
, 0, 0 },
301 /*39*/ { "", FALSE
, NONE
, 0, 0 },
302 /*3a*/ { "", FALSE
, NONE
, 0, 0 },
303 /*3b*/ { "", FALSE
, NONE
, 0, 0 },
304 /*3c*/ { "", FALSE
, NONE
, 0, 0 },
305 /*3d*/ { "", FALSE
, NONE
, 0, 0 },
306 /*3e*/ { "", FALSE
, NONE
, 0, 0 },
307 /*3f*/ { "", FALSE
, NONE
, 0, 0 },
310 static const struct inst db_inst_0f4x
[] = {
311 /*40*/ { "cmovo", TRUE
, NONE
, op2(E
, R
), 0 },
312 /*41*/ { "cmovno", TRUE
, NONE
, op2(E
, R
), 0 },
313 /*42*/ { "cmovb", TRUE
, NONE
, op2(E
, R
), 0 },
314 /*43*/ { "cmovnb", TRUE
, NONE
, op2(E
, R
), 0 },
315 /*44*/ { "cmovz", TRUE
, NONE
, op2(E
, R
), 0 },
316 /*45*/ { "cmovnz", TRUE
, NONE
, op2(E
, R
), 0 },
317 /*46*/ { "cmovbe", TRUE
, NONE
, op2(E
, R
), 0 },
318 /*47*/ { "cmovnbe",TRUE
, NONE
, op2(E
, R
), 0 },
320 /*48*/ { "cmovs", TRUE
, NONE
, op2(E
, R
), 0 },
321 /*49*/ { "cmovns", TRUE
, NONE
, op2(E
, R
), 0 },
322 /*4a*/ { "cmovp", TRUE
, NONE
, op2(E
, R
), 0 },
323 /*4b*/ { "cmovnp", TRUE
, NONE
, op2(E
, R
), 0 },
324 /*4c*/ { "cmovl", TRUE
, NONE
, op2(E
, R
), 0 },
325 /*4d*/ { "cmovnl", TRUE
, NONE
, op2(E
, R
), 0 },
326 /*4e*/ { "cmovle", TRUE
, NONE
, op2(E
, R
), 0 },
327 /*4f*/ { "cmovnle",TRUE
, NONE
, op2(E
, R
), 0 },
330 static const struct inst db_inst_0f5x
[] = {
331 /*50*/ { "movmskps",TRUE
, NONE
, op2(E
, XMM
), 0 },
332 /*51*/ { "sqrtps", TRUE
, NONE
, op2(XMM
, EXMM
), 0 },
333 /*52*/ { "rsqrtps", TRUE
, NONE
, op2(XMM
, EXMM
), 0 },
334 /*53*/ { "rcpps", TRUE
, NONE
, op2(XMM
, EXMM
), 0 },
335 /*54*/ { "andps", TRUE
, NONE
, op2(XMM
, EXMM
), 0 },
336 /*55*/ { "andnps", TRUE
, NONE
, op2(XMM
, EXMM
), 0 },
337 /*56*/ { "orps", TRUE
, NONE
, op2(XMM
, EXMM
), 0 },
338 /*57*/ { "xorps", TRUE
, NONE
, op2(XMM
, EXMM
), 0 },
340 /*58*/ { "addps", TRUE
, NONE
, op2(XMM
, EXMM
), 0 },
341 /*59*/ { "mulps", TRUE
, NONE
, op2(XMM
, EXMM
), 0 },
342 /*5a*/ { "(bad)", FALSE
, NONE
, 0, 0 },
343 /*5b*/ { "(bad)", FALSE
, NONE
, 0, 0 },
344 /*5c*/ { "subps", TRUE
, NONE
, op2(XMM
, EXMM
), 0 },
345 /*5d*/ { "minps", TRUE
, NONE
, op2(XMM
, EXMM
), 0 },
346 /*5e*/ { "divps", TRUE
, NONE
, op2(XMM
, EXMM
), 0 },
347 /*5f*/ { "maxps", TRUE
, NONE
, op2(XMM
, EXMM
), 0 },
350 static const struct inst db_inst_0f6x
[] = {
351 /*60*/ { "punpcklbw", TRUE
, NONE
, op2(E
, MX
), 0 },
352 /*61*/ { "punpcklwd", TRUE
, NONE
, op2(E
, MX
), 0 },
353 /*62*/ { "punpckldq", TRUE
, NONE
, op2(E
, MX
), 0 },
354 /*63*/ { "packsswb", TRUE
, NONE
, op2(E
, MX
), 0 },
355 /*64*/ { "pcmpgtb", TRUE
, NONE
, op2(E
, MX
), 0 },
356 /*65*/ { "pcmpgtw", TRUE
, NONE
, op2(E
, MX
), 0 },
357 /*66*/ { "pcmpgtd", TRUE
, NONE
, op2(E
, MX
), 0 },
358 /*67*/ { "packuswb", TRUE
, NONE
, op2(E
, MX
), 0 },
360 /*68*/ { "punpckhbw", TRUE
, NONE
, op2(E
, MX
), 0 },
361 /*69*/ { "punpckhwd", TRUE
, NONE
, op2(E
, MX
), 0 },
362 /*6a*/ { "punpckhdq", TRUE
, NONE
, op2(E
, MX
), 0 },
363 /*6b*/ { "packssdw", TRUE
, NONE
, op2(E
, MX
), 0 },
364 /*6c*/ { "(bad)", TRUE
, NONE
, 0, 0 },
365 /*6d*/ { "(bad)", TRUE
, NONE
, 0, 0 },
366 /*6e*/ { "movd", TRUE
, NONE
, op2(E
, MX
), 0 },
367 /*6f*/ { "movq", TRUE
, NONE
, op2(E
, MX
), 0 },
370 static const struct inst db_inst_0f7x
[] = {
371 /*70*/ { "pshufw", TRUE
, NONE
, op2(MX
, EMX
), 0 },
372 /*71*/ { "(bad)", TRUE
, NONE
, 0, 0 }, /* FIXME: grp 12 */
373 /*72*/ { "(bad)", TRUE
, NONE
, 0, 0 }, /* FIXME: grp 13 */
374 /*73*/ { "(bad)", TRUE
, NONE
, 0, 0 }, /* FIXME: grp 14 */
375 /*74*/ { "pcmpeqb", TRUE
, NONE
, op2(E
, MX
), 0 },
376 /*75*/ { "pcmpeqw", TRUE
, NONE
, op2(E
, MX
), 0 },
377 /*76*/ { "pcmpeqd", TRUE
, NONE
, op2(E
, MX
), 0 },
378 /*77*/ { "emms", FALSE
,NONE
, 0, 0 },
380 /*78*/ { "(bad)", TRUE
, NONE
, 0, 0 },
381 /*79*/ { "(bad)", TRUE
, NONE
, 0, 0 },
382 /*7a*/ { "(bad)", TRUE
, NONE
, 0, 0 },
383 /*7b*/ { "(bad)", TRUE
, NONE
, 0, 0 },
384 /*7c*/ { "(bad)", TRUE
, NONE
, 0, 0 },
385 /*7d*/ { "(bad)", TRUE
, NONE
, 0, 0 },
386 /*7e*/ { "movd", TRUE
, NONE
, op2(E
, MX
), 0 },
387 /*7f*/ { "movq", TRUE
, NONE
, op2(EMX
, MX
), 0 },
390 static const struct inst db_inst_0f8x
[] = {
391 /*80*/ { "jo", FALSE
, NONE
, op1(Dl
), 0 },
392 /*81*/ { "jno", FALSE
, NONE
, op1(Dl
), 0 },
393 /*82*/ { "jb", FALSE
, NONE
, op1(Dl
), 0 },
394 /*83*/ { "jnb", FALSE
, NONE
, op1(Dl
), 0 },
395 /*84*/ { "jz", FALSE
, NONE
, op1(Dl
), 0 },
396 /*85*/ { "jnz", FALSE
, NONE
, op1(Dl
), 0 },
397 /*86*/ { "jbe", FALSE
, NONE
, op1(Dl
), 0 },
398 /*87*/ { "jnbe", FALSE
, NONE
, op1(Dl
), 0 },
400 /*88*/ { "js", FALSE
, NONE
, op1(Dl
), 0 },
401 /*89*/ { "jns", FALSE
, NONE
, op1(Dl
), 0 },
402 /*8a*/ { "jp", FALSE
, NONE
, op1(Dl
), 0 },
403 /*8b*/ { "jnp", FALSE
, NONE
, op1(Dl
), 0 },
404 /*8c*/ { "jl", FALSE
, NONE
, op1(Dl
), 0 },
405 /*8d*/ { "jnl", FALSE
, NONE
, op1(Dl
), 0 },
406 /*8e*/ { "jle", FALSE
, NONE
, op1(Dl
), 0 },
407 /*8f*/ { "jnle", FALSE
, NONE
, op1(Dl
), 0 },
410 static const struct inst db_inst_0f9x
[] = {
411 /*90*/ { "seto", TRUE
, NONE
, op1(Eb
), 0 },
412 /*91*/ { "setno", TRUE
, NONE
, op1(Eb
), 0 },
413 /*92*/ { "setb", TRUE
, NONE
, op1(Eb
), 0 },
414 /*93*/ { "setnb", TRUE
, NONE
, op1(Eb
), 0 },
415 /*94*/ { "setz", TRUE
, NONE
, op1(Eb
), 0 },
416 /*95*/ { "setnz", TRUE
, NONE
, op1(Eb
), 0 },
417 /*96*/ { "setbe", TRUE
, NONE
, op1(Eb
), 0 },
418 /*97*/ { "setnbe",TRUE
, NONE
, op1(Eb
), 0 },
420 /*98*/ { "sets", TRUE
, NONE
, op1(Eb
), 0 },
421 /*99*/ { "setns", TRUE
, NONE
, op1(Eb
), 0 },
422 /*9a*/ { "setp", TRUE
, NONE
, op1(Eb
), 0 },
423 /*9b*/ { "setnp", TRUE
, NONE
, op1(Eb
), 0 },
424 /*9c*/ { "setl", TRUE
, NONE
, op1(Eb
), 0 },
425 /*9d*/ { "setnl", TRUE
, NONE
, op1(Eb
), 0 },
426 /*9e*/ { "setle", TRUE
, NONE
, op1(Eb
), 0 },
427 /*9f*/ { "setnle",TRUE
, NONE
, op1(Eb
), 0 },
430 static const struct inst db_inst_0fax
[] = {
431 /*a0*/ { "push", FALSE
, NONE
, op1(Si
), 0 },
432 /*a1*/ { "pop", FALSE
, NONE
, op1(Si
), 0 },
433 /*a2*/ { "cpuid", FALSE
, NONE
, 0, 0 },
434 /*a3*/ { "bt", TRUE
, LONG
, op2(R
,E
), 0 },
435 /*a4*/ { "shld", TRUE
, LONG
, op3(Ib
,R
,E
), 0 },
436 /*a5*/ { "shld", TRUE
, LONG
, op3(CL
,R
,E
), 0 },
437 /*a6*/ { "", FALSE
, NONE
, 0, 0 },
438 /*a7*/ { "", FALSE
, NONE
, 0, 0 },
440 /*a8*/ { "push", FALSE
, NONE
, op1(Si
), 0 },
441 /*a9*/ { "pop", FALSE
, NONE
, op1(Si
), 0 },
442 /*aa*/ { "rsm", FALSE
, NONE
, 0, 0 },
443 /*ab*/ { "bts", TRUE
, LONG
, op2(R
,E
), 0 },
444 /*ac*/ { "shrd", TRUE
, LONG
, op3(Ib
,R
,E
), 0 },
445 /*ad*/ { "shrd", TRUE
, LONG
, op3(CL
,R
,E
), 0 },
446 /*ae*/ { "", TRUE
, LONG
, op1(E
), db_Grp15
},
447 /*af*/ { "imul", TRUE
, LONG
, op2(E
,R
), 0 },
450 static const struct inst db_inst_0fbx
[] = {
451 /*b0*/ { "cmpxchg",TRUE
, BYTE
, op2(R
, E
), 0 },
452 /*b0*/ { "cmpxchg",TRUE
, LONG
, op2(R
, E
), 0 },
453 /*b2*/ { "lss", TRUE
, LONG
, op2(E
, R
), 0 },
454 /*b3*/ { "btr", TRUE
, LONG
, op2(R
, E
), 0 },
455 /*b4*/ { "lfs", TRUE
, LONG
, op2(E
, R
), 0 },
456 /*b5*/ { "lgs", TRUE
, LONG
, op2(E
, R
), 0 },
457 /*b6*/ { "movzb", TRUE
, LONG
, op2(Eb
, R
), 0 },
458 /*b7*/ { "movzw", TRUE
, LONG
, op2(Ew
, R
), 0 },
460 /*b8*/ { "", FALSE
, NONE
, 0, 0 },
461 /*b9*/ { "", FALSE
, NONE
, 0, 0 },
462 /*ba*/ { "", TRUE
, LONG
, op2(Ib
, E
), db_Grp8
},
463 /*bb*/ { "btc", TRUE
, LONG
, op2(R
, E
), 0 },
464 /*bc*/ { "bsf", TRUE
, LONG
, op2(E
, R
), 0 },
465 /*bd*/ { "bsr", TRUE
, LONG
, op2(E
, R
), 0 },
466 /*be*/ { "movsb", TRUE
, LONG
, op2(Eb
, R
), 0 },
467 /*bf*/ { "movsw", TRUE
, LONG
, op2(Ew
, R
), 0 },
470 static const struct inst db_inst_0fcx
[] = {
471 /*c0*/ { "xadd", TRUE
, BYTE
, op2(R
, E
), 0 },
472 /*c1*/ { "xadd", TRUE
, LONG
, op2(R
, E
), 0 },
473 /*c2*/ { "", FALSE
, NONE
, 0, 0 },
474 /*c3*/ { "", FALSE
, NONE
, 0, 0 },
475 /*c4*/ { "", FALSE
, NONE
, 0, 0 },
476 /*c5*/ { "", FALSE
, NONE
, 0, 0 },
477 /*c6*/ { "", FALSE
, NONE
, 0, 0 },
478 /*c7*/ { "", TRUE
, NONE
, op1(E
), db_Grp9
},
479 /*c8*/ { "bswap", FALSE
, LONG
, op1(Ril
), 0 },
480 /*c9*/ { "bswap", FALSE
, LONG
, op1(Ril
), 0 },
481 /*ca*/ { "bswap", FALSE
, LONG
, op1(Ril
), 0 },
482 /*cb*/ { "bswap", FALSE
, LONG
, op1(Ril
), 0 },
483 /*cc*/ { "bswap", FALSE
, LONG
, op1(Ril
), 0 },
484 /*cd*/ { "bswap", FALSE
, LONG
, op1(Ril
), 0 },
485 /*ce*/ { "bswap", FALSE
, LONG
, op1(Ril
), 0 },
486 /*cf*/ { "bswap", FALSE
, LONG
, op1(Ril
), 0 },
489 static const struct inst
* const db_inst_0f
[] = {
508 static const char * const db_Esc92
[] = {
509 "fnop", "", "", "", "", "", "", ""
511 static const char * const db_Esc94
[] = {
512 "fchs", "fabs", "", "", "ftst", "fxam", "", ""
514 static const char * const db_Esc95
[] = {
515 "fld1", "fldl2t","fldl2e","fldpi","fldlg2","fldln2","fldz",""
517 static const char * const db_Esc96
[] = {
518 "f2xm1","fyl2x","fptan","fpatan","fxtract","fprem1","fdecstp",
521 static const char * const db_Esc97
[] = {
522 "fprem","fyl2xp1","fsqrt","fsincos","frndint","fscale","fsin","fcos"
525 static const char * const db_Esca5
[] = {
526 "", "fucompp","", "", "", "", "", ""
529 static const char * const db_Escb4
[] = {
530 "fneni","fndisi", "fnclex","fninit","fsetpm", "", "", ""
533 static const char * const db_Esce3
[] = {
534 "", "fcompp","", "", "", "", "", ""
537 static const char * const db_Escf4
[] = {
538 "fnstsw","", "", "", "", "", "", ""
541 static const struct finst db_Esc8
[] = {
542 /*0*/ { "fadd", SNGL
, op2(STI
,ST
), 0 },
543 /*1*/ { "fmul", SNGL
, op2(STI
,ST
), 0 },
544 /*2*/ { "fcom", SNGL
, op2(STI
,ST
), 0 },
545 /*3*/ { "fcomp", SNGL
, op2(STI
,ST
), 0 },
546 /*4*/ { "fsub", SNGL
, op2(STI
,ST
), 0 },
547 /*5*/ { "fsubr", SNGL
, op2(STI
,ST
), 0 },
548 /*6*/ { "fdiv", SNGL
, op2(STI
,ST
), 0 },
549 /*7*/ { "fdivr", SNGL
, op2(STI
,ST
), 0 },
552 static const struct finst db_Esc9
[] = {
553 /*0*/ { "fld", SNGL
, op1(STI
), 0 },
554 /*1*/ { "", NONE
, op1(STI
), "fxch" },
555 /*2*/ { "fst", SNGL
, op1(X
), db_Esc92
},
556 /*3*/ { "fstp", SNGL
, 0, 0 },
557 /*4*/ { "fldenv", NONE
, op1(X
), db_Esc94
},
558 /*5*/ { "fldcw", NONE
, op1(X
), db_Esc95
},
559 /*6*/ { "fnstenv",NONE
, op1(X
), db_Esc96
},
560 /*7*/ { "fnstcw", NONE
, op1(X
), db_Esc97
},
563 static const struct finst db_Esca
[] = {
564 /*0*/ { "fiadd", LONG
, 0, 0 },
565 /*1*/ { "fimul", LONG
, 0, 0 },
566 /*2*/ { "ficom", LONG
, 0, 0 },
567 /*3*/ { "ficomp", LONG
, 0, 0 },
568 /*4*/ { "fisub", LONG
, 0, 0 },
569 /*5*/ { "fisubr", LONG
, op1(X
), db_Esca5
},
570 /*6*/ { "fidiv", LONG
, 0, 0 },
571 /*7*/ { "fidivr", LONG
, 0, 0 }
574 static const struct finst db_Escb
[] = {
575 /*0*/ { "fild", LONG
, 0, 0 },
576 /*1*/ { "", NONE
, 0, 0 },
577 /*2*/ { "fist", LONG
, 0, 0 },
578 /*3*/ { "fistp", LONG
, 0, 0 },
579 /*4*/ { "", WORD
, op1(X
), db_Escb4
},
580 /*5*/ { "fld", EXTR
, 0, 0 },
581 /*6*/ { "", WORD
, 0, 0 },
582 /*7*/ { "fstp", EXTR
, 0, 0 },
585 static const struct finst db_Escc
[] = {
586 /*0*/ { "fadd", DBLR
, op2(ST
,STI
), 0 },
587 /*1*/ { "fmul", DBLR
, op2(ST
,STI
), 0 },
588 /*2*/ { "fcom", DBLR
, 0, 0 },
589 /*3*/ { "fcomp", DBLR
, 0, 0 },
590 /*4*/ { "fsub", DBLR
, op2(ST
,STI
), "fsubr" },
591 /*5*/ { "fsubr", DBLR
, op2(ST
,STI
), "fsub" },
592 /*6*/ { "fdiv", DBLR
, op2(ST
,STI
), "fdivr" },
593 /*7*/ { "fdivr", DBLR
, op2(ST
,STI
), "fdiv" },
596 static const struct finst db_Escd
[] = {
597 /*0*/ { "fld", DBLR
, op1(STI
), "ffree" },
598 /*1*/ { "", NONE
, 0, 0 },
599 /*2*/ { "fst", DBLR
, op1(STI
), 0 },
600 /*3*/ { "fstp", DBLR
, op1(STI
), 0 },
601 /*4*/ { "frstor", NONE
, op1(STI
), "fucom" },
602 /*5*/ { "", NONE
, op1(STI
), "fucomp" },
603 /*6*/ { "fnsave", NONE
, 0, 0 },
604 /*7*/ { "fnstsw", NONE
, 0, 0 },
607 static const struct finst db_Esce
[] = {
608 /*0*/ { "fiadd", WORD
, op2(ST
,STI
), "faddp" },
609 /*1*/ { "fimul", WORD
, op2(ST
,STI
), "fmulp" },
610 /*2*/ { "ficom", WORD
, 0, 0 },
611 /*3*/ { "ficomp", WORD
, op1(X
), db_Esce3
},
612 /*4*/ { "fisub", WORD
, op2(ST
,STI
), "fsubrp" },
613 /*5*/ { "fisubr", WORD
, op2(ST
,STI
), "fsubp" },
614 /*6*/ { "fidiv", WORD
, op2(ST
,STI
), "fdivrp" },
615 /*7*/ { "fidivr", WORD
, op2(ST
,STI
), "fdivp" },
618 static const struct finst db_Escf
[] = {
619 /*0*/ { "fild", WORD
, 0, 0 },
620 /*1*/ { "", NONE
, 0, 0 },
621 /*2*/ { "fist", WORD
, 0, 0 },
622 /*3*/ { "fistp", WORD
, 0, 0 },
623 /*4*/ { "fbld", NONE
, op1(XA
), db_Escf4
},
624 /*5*/ { "fild", QUAD
, 0, 0 },
625 /*6*/ { "fbstp", NONE
, 0, 0 },
626 /*7*/ { "fistp", QUAD
, 0, 0 },
629 static const struct finst
* const db_Esc_inst
[] = {
630 db_Esc8
, db_Esc9
, db_Esca
, db_Escb
,
631 db_Escc
, db_Escd
, db_Esce
, db_Escf
634 static const char * const db_Grp1
[] = {
645 static const char * const db_Grp2
[] = {
656 static const struct inst db_Grp3
[] = {
657 { "test", TRUE
, NONE
, op2(I
,E
), 0 },
658 { "test", TRUE
, NONE
, op2(I
,E
), 0 },
659 { "not", TRUE
, NONE
, op1(E
), 0 },
660 { "neg", TRUE
, NONE
, op1(E
), 0 },
661 { "mul", TRUE
, NONE
, op2(E
,A
), 0 },
662 { "imul", TRUE
, NONE
, op2(E
,A
), 0 },
663 { "div", TRUE
, NONE
, op2(E
,A
), 0 },
664 { "idiv", TRUE
, NONE
, op2(E
,A
), 0 },
667 static const struct inst db_Grp4
[] = {
668 { "inc", TRUE
, BYTE
, op1(E
), 0 },
669 { "dec", TRUE
, BYTE
, op1(E
), 0 },
670 { "", TRUE
, NONE
, 0, 0 },
671 { "", TRUE
, NONE
, 0, 0 },
672 { "", TRUE
, NONE
, 0, 0 },
673 { "", TRUE
, NONE
, 0, 0 },
674 { "", TRUE
, NONE
, 0, 0 },
675 { "", TRUE
, NONE
, 0, 0 }
678 static const struct inst db_Grp5
[] = {
679 { "inc", TRUE
, LONG
, op1(E
), 0 },
680 { "dec", TRUE
, LONG
, op1(E
), 0 },
681 { "call", TRUE
, LONG
, op1(Eind
),0 },
682 { "lcall", TRUE
, LONG
, op1(Eind
),0 },
683 { "jmp", TRUE
, LONG
, op1(Eind
),0 },
684 { "ljmp", TRUE
, LONG
, op1(Eind
),0 },
685 { "push", TRUE
, LONG
, op1(E
), 0 },
686 { "", TRUE
, NONE
, 0, 0 }
689 static const struct inst db_inst_table
[256] = {
690 /*00*/ { "add", TRUE
, BYTE
, op2(R
, E
), 0 },
691 /*01*/ { "add", TRUE
, LONG
, op2(R
, E
), 0 },
692 /*02*/ { "add", TRUE
, BYTE
, op2(E
, R
), 0 },
693 /*03*/ { "add", TRUE
, LONG
, op2(E
, R
), 0 },
694 /*04*/ { "add", FALSE
, BYTE
, op2(I
, A
), 0 },
695 /*05*/ { "add", FALSE
, LONG
, op2(Is
, A
), 0 },
696 /*06*/ { "push", FALSE
, NONE
, op1(Si
), 0 },
697 /*07*/ { "pop", FALSE
, NONE
, op1(Si
), 0 },
699 /*08*/ { "or", TRUE
, BYTE
, op2(R
, E
), 0 },
700 /*09*/ { "or", TRUE
, LONG
, op2(R
, E
), 0 },
701 /*0a*/ { "or", TRUE
, BYTE
, op2(E
, R
), 0 },
702 /*0b*/ { "or", TRUE
, LONG
, op2(E
, R
), 0 },
703 /*0c*/ { "or", FALSE
, BYTE
, op2(I
, A
), 0 },
704 /*0d*/ { "or", FALSE
, LONG
, op2(I
, A
), 0 },
705 /*0e*/ { "push", FALSE
, NONE
, op1(Si
), 0 },
706 /*0f*/ { "", FALSE
, NONE
, 0, 0 },
708 /*10*/ { "adc", TRUE
, BYTE
, op2(R
, E
), 0 },
709 /*11*/ { "adc", TRUE
, LONG
, op2(R
, E
), 0 },
710 /*12*/ { "adc", TRUE
, BYTE
, op2(E
, R
), 0 },
711 /*13*/ { "adc", TRUE
, LONG
, op2(E
, R
), 0 },
712 /*14*/ { "adc", FALSE
, BYTE
, op2(I
, A
), 0 },
713 /*15*/ { "adc", FALSE
, LONG
, op2(Is
, A
), 0 },
714 /*16*/ { "push", FALSE
, NONE
, op1(Si
), 0 },
715 /*17*/ { "pop", FALSE
, NONE
, op1(Si
), 0 },
717 /*18*/ { "sbb", TRUE
, BYTE
, op2(R
, E
), 0 },
718 /*19*/ { "sbb", TRUE
, LONG
, op2(R
, E
), 0 },
719 /*1a*/ { "sbb", TRUE
, BYTE
, op2(E
, R
), 0 },
720 /*1b*/ { "sbb", TRUE
, LONG
, op2(E
, R
), 0 },
721 /*1c*/ { "sbb", FALSE
, BYTE
, op2(I
, A
), 0 },
722 /*1d*/ { "sbb", FALSE
, LONG
, op2(Is
, A
), 0 },
723 /*1e*/ { "push", FALSE
, NONE
, op1(Si
), 0 },
724 /*1f*/ { "pop", FALSE
, NONE
, op1(Si
), 0 },
726 /*20*/ { "and", TRUE
, BYTE
, op2(R
, E
), 0 },
727 /*21*/ { "and", TRUE
, LONG
, op2(R
, E
), 0 },
728 /*22*/ { "and", TRUE
, BYTE
, op2(E
, R
), 0 },
729 /*23*/ { "and", TRUE
, LONG
, op2(E
, R
), 0 },
730 /*24*/ { "and", FALSE
, BYTE
, op2(I
, A
), 0 },
731 /*25*/ { "and", FALSE
, LONG
, op2(I
, A
), 0 },
732 /*26*/ { "", FALSE
, NONE
, 0, 0 },
733 /*27*/ { "daa", FALSE
, NONE
, 0, 0 },
735 /*28*/ { "sub", TRUE
, BYTE
, op2(R
, E
), 0 },
736 /*29*/ { "sub", TRUE
, LONG
, op2(R
, E
), 0 },
737 /*2a*/ { "sub", TRUE
, BYTE
, op2(E
, R
), 0 },
738 /*2b*/ { "sub", TRUE
, LONG
, op2(E
, R
), 0 },
739 /*2c*/ { "sub", FALSE
, BYTE
, op2(I
, A
), 0 },
740 /*2d*/ { "sub", FALSE
, LONG
, op2(Is
, A
), 0 },
741 /*2e*/ { "", FALSE
, NONE
, 0, 0 },
742 /*2f*/ { "das", FALSE
, NONE
, 0, 0 },
744 /*30*/ { "xor", TRUE
, BYTE
, op2(R
, E
), 0 },
745 /*31*/ { "xor", TRUE
, LONG
, op2(R
, E
), 0 },
746 /*32*/ { "xor", TRUE
, BYTE
, op2(E
, R
), 0 },
747 /*33*/ { "xor", TRUE
, LONG
, op2(E
, R
), 0 },
748 /*34*/ { "xor", FALSE
, BYTE
, op2(I
, A
), 0 },
749 /*35*/ { "xor", FALSE
, LONG
, op2(I
, A
), 0 },
750 /*36*/ { "", FALSE
, NONE
, 0, 0 },
751 /*37*/ { "aaa", FALSE
, NONE
, 0, 0 },
753 /*38*/ { "cmp", TRUE
, BYTE
, op2(R
, E
), 0 },
754 /*39*/ { "cmp", TRUE
, LONG
, op2(R
, E
), 0 },
755 /*3a*/ { "cmp", TRUE
, BYTE
, op2(E
, R
), 0 },
756 /*3b*/ { "cmp", TRUE
, LONG
, op2(E
, R
), 0 },
757 /*3c*/ { "cmp", FALSE
, BYTE
, op2(I
, A
), 0 },
758 /*3d*/ { "cmp", FALSE
, LONG
, op2(Is
, A
), 0 },
759 /*3e*/ { "", FALSE
, NONE
, 0, 0 },
760 /*3f*/ { "aas", FALSE
, NONE
, 0, 0 },
762 /*40*/ { "rex", FALSE
, NONE
, 0, 0 },
763 /*41*/ { "rex.b", FALSE
, NONE
, 0, 0 },
764 /*42*/ { "rex.x", FALSE
, NONE
, 0, 0 },
765 /*43*/ { "rex.xb", FALSE
, NONE
, 0, 0 },
766 /*44*/ { "rex.r", FALSE
, NONE
, 0, 0 },
767 /*45*/ { "rex.rb", FALSE
, NONE
, 0, 0 },
768 /*46*/ { "rex.rx", FALSE
, NONE
, 0, 0 },
769 /*47*/ { "rex.rxb", FALSE
, NONE
, 0, 0 },
771 /*48*/ { "rex.w", FALSE
, NONE
, 0, 0 },
772 /*49*/ { "rex.wb", FALSE
, NONE
, 0, 0 },
773 /*4a*/ { "rex.wx", FALSE
, NONE
, 0, 0 },
774 /*4b*/ { "rex.wxb", FALSE
, NONE
, 0, 0 },
775 /*4c*/ { "rex.wr", FALSE
, NONE
, 0, 0 },
776 /*4d*/ { "rex.wrb", FALSE
, NONE
, 0, 0 },
777 /*4e*/ { "rex.wrx", FALSE
, NONE
, 0, 0 },
778 /*4f*/ { "rex.wrxb", FALSE
, NONE
, 0, 0 },
780 /*50*/ { "push", FALSE
, LONG
, op1(Ri
), 0 },
781 /*51*/ { "push", FALSE
, LONG
, op1(Ri
), 0 },
782 /*52*/ { "push", FALSE
, LONG
, op1(Ri
), 0 },
783 /*53*/ { "push", FALSE
, LONG
, op1(Ri
), 0 },
784 /*54*/ { "push", FALSE
, LONG
, op1(Ri
), 0 },
785 /*55*/ { "push", FALSE
, LONG
, op1(Ri
), 0 },
786 /*56*/ { "push", FALSE
, LONG
, op1(Ri
), 0 },
787 /*57*/ { "push", FALSE
, LONG
, op1(Ri
), 0 },
789 /*58*/ { "pop", FALSE
, LONG
, op1(Ri
), 0 },
790 /*59*/ { "pop", FALSE
, LONG
, op1(Ri
), 0 },
791 /*5a*/ { "pop", FALSE
, LONG
, op1(Ri
), 0 },
792 /*5b*/ { "pop", FALSE
, LONG
, op1(Ri
), 0 },
793 /*5c*/ { "pop", FALSE
, LONG
, op1(Ri
), 0 },
794 /*5d*/ { "pop", FALSE
, LONG
, op1(Ri
), 0 },
795 /*5e*/ { "pop", FALSE
, LONG
, op1(Ri
), 0 },
796 /*5f*/ { "pop", FALSE
, LONG
, op1(Ri
), 0 },
798 /*60*/ { "pusha", FALSE
, LONG
, 0, 0 },
799 /*61*/ { "popa", FALSE
, LONG
, 0, 0 },
800 /*62*/ { "bound", TRUE
, LONG
, op2(E
, R
), 0 },
801 /*63*/ { "movslq", TRUE
, NONE
, op2(EL
,R
), 0 },
803 /*64*/ { "", FALSE
, NONE
, 0, 0 },
804 /*65*/ { "", FALSE
, NONE
, 0, 0 },
805 /*66*/ { "", FALSE
, NONE
, 0, 0 },
806 /*67*/ { "", FALSE
, NONE
, 0, 0 },
808 /*68*/ { "push", FALSE
, LONG
, op1(I
), 0 },
809 /*69*/ { "imul", TRUE
, LONG
, op3(I
,E
,R
), 0 },
810 /*6a*/ { "push", FALSE
, LONG
, op1(Ibs
), 0 },
811 /*6b*/ { "imul", TRUE
, LONG
, op3(Ibs
,E
,R
),0 },
812 /*6c*/ { "ins", FALSE
, BYTE
, op2(DX
, DI
), 0 },
813 /*6d*/ { "ins", FALSE
, LONG
, op2(DX
, DI
), 0 },
814 /*6e*/ { "outs", FALSE
, BYTE
, op2(SI
, DX
), 0 },
815 /*6f*/ { "outs", FALSE
, LONG
, op2(SI
, DX
), 0 },
817 /*70*/ { "jo", FALSE
, NONE
, op1(Db
), 0 },
818 /*71*/ { "jno", FALSE
, NONE
, op1(Db
), 0 },
819 /*72*/ { "jb", FALSE
, NONE
, op1(Db
), 0 },
820 /*73*/ { "jnb", FALSE
, NONE
, op1(Db
), 0 },
821 /*74*/ { "jz", FALSE
, NONE
, op1(Db
), 0 },
822 /*75*/ { "jnz", FALSE
, NONE
, op1(Db
), 0 },
823 /*76*/ { "jbe", FALSE
, NONE
, op1(Db
), 0 },
824 /*77*/ { "jnbe", FALSE
, NONE
, op1(Db
), 0 },
826 /*78*/ { "js", FALSE
, NONE
, op1(Db
), 0 },
827 /*79*/ { "jns", FALSE
, NONE
, op1(Db
), 0 },
828 /*7a*/ { "jp", FALSE
, NONE
, op1(Db
), 0 },
829 /*7b*/ { "jnp", FALSE
, NONE
, op1(Db
), 0 },
830 /*7c*/ { "jl", FALSE
, NONE
, op1(Db
), 0 },
831 /*7d*/ { "jnl", FALSE
, NONE
, op1(Db
), 0 },
832 /*7e*/ { "jle", FALSE
, NONE
, op1(Db
), 0 },
833 /*7f*/ { "jnle", FALSE
, NONE
, op1(Db
), 0 },
835 /*80*/ { "", TRUE
, BYTE
, op2(I
, E
), db_Grp1
},
836 /*81*/ { "", TRUE
, LONG
, op2(I
, E
), db_Grp1
},
837 /*82*/ { "", TRUE
, BYTE
, op2(I
, E
), db_Grp1
},
838 /*83*/ { "", TRUE
, LONG
, op2(Ibs
,E
), db_Grp1
},
839 /*84*/ { "test", TRUE
, BYTE
, op2(R
, E
), 0 },
840 /*85*/ { "test", TRUE
, LONG
, op2(R
, E
), 0 },
841 /*86*/ { "xchg", TRUE
, BYTE
, op2(R
, E
), 0 },
842 /*87*/ { "xchg", TRUE
, LONG
, op2(R
, E
), 0 },
844 /*88*/ { "mov", TRUE
, BYTE
, op2(R
, E
), 0 },
845 /*89*/ { "mov", TRUE
, LONG
, op2(R
, E
), 0 },
846 /*8a*/ { "mov", TRUE
, BYTE
, op2(E
, R
), 0 },
847 /*8b*/ { "mov", TRUE
, LONG
, op2(E
, R
), 0 },
848 /*8c*/ { "mov", TRUE
, NONE
, op2(S
, Ew
), 0 },
849 /*8d*/ { "lea", TRUE
, LONG
, op2(E
, R
), 0 },
850 /*8e*/ { "mov", TRUE
, NONE
, op2(Ew
, S
), 0 },
851 /*8f*/ { "pop", TRUE
, LONG
, op1(E
), 0 },
853 /*90*/ { "nop", FALSE
, NONE
, 0, 0 },
854 /*91*/ { "xchg", FALSE
, LONG
, op2(A
, Ri
), 0 },
855 /*92*/ { "xchg", FALSE
, LONG
, op2(A
, Ri
), 0 },
856 /*93*/ { "xchg", FALSE
, LONG
, op2(A
, Ri
), 0 },
857 /*94*/ { "xchg", FALSE
, LONG
, op2(A
, Ri
), 0 },
858 /*95*/ { "xchg", FALSE
, LONG
, op2(A
, Ri
), 0 },
859 /*96*/ { "xchg", FALSE
, LONG
, op2(A
, Ri
), 0 },
860 /*97*/ { "xchg", FALSE
, LONG
, op2(A
, Ri
), 0 },
862 /*98*/ { "cbw", FALSE
, SDEP
, 0, "cwde" }, /* cbw/cwde */
863 /*99*/ { "cwd", FALSE
, SDEP
, 0, "cdq" }, /* cwd/cdq */
864 /*9a*/ { "lcall", FALSE
, NONE
, op1(OS
), 0 },
865 /*9b*/ { "wait", FALSE
, NONE
, 0, 0 },
866 /*9c*/ { "pushf", FALSE
, LONG
, 0, 0 },
867 /*9d*/ { "popf", FALSE
, LONG
, 0, 0 },
868 /*9e*/ { "sahf", FALSE
, NONE
, 0, 0 },
869 /*9f*/ { "lahf", FALSE
, NONE
, 0, 0 },
871 /*a0*/ { "mov", FALSE
, BYTE
, op2(O
, A
), 0 },
872 /*a1*/ { "mov", FALSE
, LONG
, op2(O
, A
), 0 },
873 /*a2*/ { "mov", FALSE
, BYTE
, op2(A
, O
), 0 },
874 /*a3*/ { "mov", FALSE
, LONG
, op2(A
, O
), 0 },
875 /*a4*/ { "movs", FALSE
, BYTE
, op2(SI
,DI
), 0 },
876 /*a5*/ { "movs", FALSE
, LONG
, op2(SI
,DI
), 0 },
877 /*a6*/ { "cmps", FALSE
, BYTE
, op2(SI
,DI
), 0 },
878 /*a7*/ { "cmps", FALSE
, LONG
, op2(SI
,DI
), 0 },
880 /*a8*/ { "test", FALSE
, BYTE
, op2(I
, A
), 0 },
881 /*a9*/ { "test", FALSE
, LONG
, op2(I
, A
), 0 },
882 /*aa*/ { "stos", FALSE
, BYTE
, op1(DI
), 0 },
883 /*ab*/ { "stos", FALSE
, LONG
, op1(DI
), 0 },
884 /*ac*/ { "lods", FALSE
, BYTE
, op1(SI
), 0 },
885 /*ad*/ { "lods", FALSE
, LONG
, op1(SI
), 0 },
886 /*ae*/ { "scas", FALSE
, BYTE
, op1(SI
), 0 },
887 /*af*/ { "scas", FALSE
, LONG
, op1(SI
), 0 },
889 /*b0*/ { "mov", FALSE
, BYTE
, op2(I
, Ri
), 0 },
890 /*b1*/ { "mov", FALSE
, BYTE
, op2(I
, Ri
), 0 },
891 /*b2*/ { "mov", FALSE
, BYTE
, op2(I
, Ri
), 0 },
892 /*b3*/ { "mov", FALSE
, BYTE
, op2(I
, Ri
), 0 },
893 /*b4*/ { "mov", FALSE
, BYTE
, op2(I
, Ri
), 0 },
894 /*b5*/ { "mov", FALSE
, BYTE
, op2(I
, Ri
), 0 },
895 /*b6*/ { "mov", FALSE
, BYTE
, op2(I
, Ri
), 0 },
896 /*b7*/ { "mov", FALSE
, BYTE
, op2(I
, Ri
), 0 },
898 /*b8*/ { "mov", FALSE
, LONG
, op2(Ilq
, Ri
), 0 },
899 /*b9*/ { "mov", FALSE
, LONG
, op2(Ilq
, Ri
), 0 },
900 /*ba*/ { "mov", FALSE
, LONG
, op2(Ilq
, Ri
), 0 },
901 /*bb*/ { "mov", FALSE
, LONG
, op2(Ilq
, Ri
), 0 },
902 /*bc*/ { "mov", FALSE
, LONG
, op2(Ilq
, Ri
), 0 },
903 /*bd*/ { "mov", FALSE
, LONG
, op2(Ilq
, Ri
), 0 },
904 /*be*/ { "mov", FALSE
, LONG
, op2(Ilq
, Ri
), 0 },
905 /*bf*/ { "mov", FALSE
, LONG
, op2(Ilq
, Ri
), 0 },
907 /*c0*/ { "", TRUE
, BYTE
, op2(Ib
, E
), db_Grp2
},
908 /*c1*/ { "", TRUE
, LONG
, op2(Ib
, E
), db_Grp2
},
909 /*c2*/ { "ret", FALSE
, NONE
, op1(Iw
), 0 },
910 /*c3*/ { "ret", FALSE
, NONE
, 0, 0 },
911 /*c4*/ { "les", TRUE
, LONG
, op2(E
, R
), 0 },
912 /*c5*/ { "lds", TRUE
, LONG
, op2(E
, R
), 0 },
913 /*c6*/ { "mov", TRUE
, BYTE
, op2(I
, E
), 0 },
914 /*c7*/ { "mov", TRUE
, LONG
, op2(I
, E
), 0 },
916 /*c8*/ { "enter", FALSE
, NONE
, op2(Iw
, Ib
), 0 },
917 /*c9*/ { "leave", FALSE
, NONE
, 0, 0 },
918 /*ca*/ { "lret", FALSE
, NONE
, op1(Iw
), 0 },
919 /*cb*/ { "lret", FALSE
, NONE
, 0, 0 },
920 /*cc*/ { "int", FALSE
, NONE
, op1(o3
), 0 },
921 /*cd*/ { "int", FALSE
, NONE
, op1(Ib
), 0 },
922 /*ce*/ { "into", FALSE
, NONE
, 0, 0 },
923 /*cf*/ { "iret", FALSE
, NONE
, 0, 0 },
925 /*d0*/ { "", TRUE
, BYTE
, op2(o1
, E
), db_Grp2
},
926 /*d1*/ { "", TRUE
, LONG
, op2(o1
, E
), db_Grp2
},
927 /*d2*/ { "", TRUE
, BYTE
, op2(CL
, E
), db_Grp2
},
928 /*d3*/ { "", TRUE
, LONG
, op2(CL
, E
), db_Grp2
},
929 /*d4*/ { "aam", FALSE
, NONE
, op1(Iba
), 0 },
930 /*d5*/ { "aad", FALSE
, NONE
, op1(Iba
), 0 },
931 /*d6*/ { ".byte\t0xd6", FALSE
, NONE
, 0, 0 },
932 /*d7*/ { "xlat", FALSE
, BYTE
, op1(BX
), 0 },
934 /*d8*/ { "", TRUE
, NONE
, 0, db_Esc8
},
935 /*d9*/ { "", TRUE
, NONE
, 0, db_Esc9
},
936 /*da*/ { "", TRUE
, NONE
, 0, db_Esca
},
937 /*db*/ { "", TRUE
, NONE
, 0, db_Escb
},
938 /*dc*/ { "", TRUE
, NONE
, 0, db_Escc
},
939 /*dd*/ { "", TRUE
, NONE
, 0, db_Escd
},
940 /*de*/ { "", TRUE
, NONE
, 0, db_Esce
},
941 /*df*/ { "", TRUE
, NONE
, 0, db_Escf
},
943 /*e0*/ { "loopne",FALSE
, NONE
, op1(Db
), 0 },
944 /*e1*/ { "loope", FALSE
, NONE
, op1(Db
), 0 },
945 /*e2*/ { "loop", FALSE
, NONE
, op1(Db
), 0 },
946 /*e3*/ { "jcxz", FALSE
, SDEP
, op1(Db
), "jecxz" },
947 /*e4*/ { "in", FALSE
, BYTE
, op2(Ib
, A
), 0 },
948 /*e5*/ { "in", FALSE
, LONG
, op2(Ib
, A
) , 0 },
949 /*e6*/ { "out", FALSE
, BYTE
, op2(A
, Ib
), 0 },
950 /*e7*/ { "out", FALSE
, LONG
, op2(A
, Ib
) , 0 },
952 /*e8*/ { "call", FALSE
, NONE
, op1(Dl
), 0 },
953 /*e9*/ { "jmp", FALSE
, NONE
, op1(Dl
), 0 },
954 /*ea*/ { "ljmp", FALSE
, NONE
, op1(OS
), 0 },
955 /*eb*/ { "jmp", FALSE
, NONE
, op1(Db
), 0 },
956 /*ec*/ { "in", FALSE
, BYTE
, op2(DX
, A
), 0 },
957 /*ed*/ { "in", FALSE
, LONG
, op2(DX
, A
) , 0 },
958 /*ee*/ { "out", FALSE
, BYTE
, op2(A
, DX
), 0 },
959 /*ef*/ { "out", FALSE
, LONG
, op2(A
, DX
) , 0 },
961 /*f0*/ { "", FALSE
, NONE
, 0, 0 },
962 /*f1*/ { ".byte\t0xf1", FALSE
, NONE
, 0, 0 },
963 /*f2*/ { "", FALSE
, NONE
, 0, 0 },
964 /*f3*/ { "", FALSE
, NONE
, 0, 0 },
965 /*f4*/ { "hlt", FALSE
, NONE
, 0, 0 },
966 /*f5*/ { "cmc", FALSE
, NONE
, 0, 0 },
967 /*f6*/ { "", TRUE
, BYTE
, 0, db_Grp3
},
968 /*f7*/ { "", TRUE
, LONG
, 0, db_Grp3
},
970 /*f8*/ { "clc", FALSE
, NONE
, 0, 0 },
971 /*f9*/ { "stc", FALSE
, NONE
, 0, 0 },
972 /*fa*/ { "cli", FALSE
, NONE
, 0, 0 },
973 /*fb*/ { "sti", FALSE
, NONE
, 0, 0 },
974 /*fc*/ { "cld", FALSE
, NONE
, 0, 0 },
975 /*fd*/ { "std", FALSE
, NONE
, 0, 0 },
976 /*fe*/ { "", TRUE
, NONE
, 0, db_Grp4
},
977 /*ff*/ { "", TRUE
, NONE
, 0, db_Grp5
},
980 static const struct inst db_bad_inst
=
981 { "???", FALSE
, NONE
, 0, 0 }
984 #define f_mod(rex, byte) ((byte)>>6)
985 #define f_reg(rex, byte) ((((byte)>>3)&0x7) | (rex & REX_R ? 0x8 : 0x0))
986 #define f_rm(rex, byte) (((byte)&0x7) | (rex & REX_B ? 0x8 : 0x0))
988 #define sib_ss(rex, byte) ((byte)>>6)
989 #define sib_index(rex, byte) ((((byte)>>3)&0x7) | (rex & REX_X ? 0x8 : 0x0))
990 #define sib_base(rex, byte) (((byte)&0x7) | (rex & REX_B ? 0x8 : 0x0))
993 int is_reg
; /* if reg, reg number is in 'disp' */
1000 static const char * const db_reg
[2][4][16] = {
1002 {{"%al", "%cl", "%dl", "%bl", "%ah", "%ch", "%dh", "%bh",
1003 "%r8b", "%r9b", "%r10b", "%r11b", "%r12b", "%r13b", "%r14b", "%r15b" },
1004 { "%ax", "%cx", "%dx", "%bx", "%sp", "%bp", "%si", "%di",
1005 "%r8w", "%r9w", "%r10w", "%r11w", "%r12w", "%r13w", "%r14w", "%r15w" },
1006 { "%eax", "%ecx", "%edx", "%ebx", "%esp", "%ebp", "%esi", "%edi",
1007 "%r8d", "%r9d", "%r10d", "%r11d", "%r12d", "%r13d", "%r14d", "%r15d" },
1008 { "%rax", "%rcx", "%rdx", "%rbx", "%rsp", "%rbp", "%rsi", "%rdi",
1009 "%r8", "%r9", "%r10", "%r11", "%r12", "%r13", "%r14", "%r15" }},
1011 {{"%al", "%cl", "%dl", "%bl", "%spl", "%bpl", "%sil", "%dil",
1012 "%r8b", "%r9b", "%r10b", "%r11b", "%r12b", "%r13b", "%r14b", "%r15b" },
1013 { "%ax", "%cx", "%dx", "%bx", "%sp", "%bp", "%si", "%di",
1014 "%r8w", "%r9w", "%r10w", "%r11w", "%r12w", "%r13w", "%r14w", "%r15w" },
1015 { "%eax", "%ecx", "%edx", "%ebx", "%esp", "%ebp", "%esi", "%edi",
1016 "%r8d", "%r9d", "%r10d", "%r11d", "%r12d", "%r13d", "%r14d", "%r15d" },
1017 { "%rax", "%rcx", "%rdx", "%rbx", "%rsp", "%rbp", "%rsi", "%rdi",
1018 "%r8", "%r9", "%r10", "%r11", "%r12", "%r13", "%r14", "%r15" }}
1021 static const char * const db_seg_reg
[8] = {
1022 "%es", "%cs", "%ss", "%ds", "%fs", "%gs", "", ""
1026 * lengths for size attributes
1028 static const int db_lengths
[] = {
1038 #define get_value_inc(result, loc, size, is_signed) \
1039 result = db_get_value((loc), (size), (is_signed)); \
1043 db_disasm_esc(db_addr_t loc
, int inst
, int rex
, int short_addr
,
1044 int size
, const char *seg
);
1045 static void db_print_address(const char *seg
, int size
, int rex
,
1046 struct i_addr
*addrp
);
1048 db_read_address(db_addr_t loc
, int short_addr
, int rex
, int regmodrm
,
1049 struct i_addr
*addrp
);
1052 * Read address at location and return updated location.
1055 db_read_address(loc
, short_addr
, rex
, regmodrm
, addrp
)
1060 struct i_addr
* addrp
; /* out */
1062 int mod
, rm
, sib
, index
, disp
, size
, have_sib
;
1064 mod
= f_mod(rex
, regmodrm
);
1065 rm
= f_rm(rex
, regmodrm
);
1068 addrp
->is_reg
= TRUE
;
1072 addrp
->is_reg
= FALSE
;
1080 if ((rm
& 0x7) == 4) {
1081 get_value_inc(sib
, loc
, 1, FALSE
);
1082 rm
= sib_base(rex
, sib
);
1083 index
= sib_index(rex
, sib
);
1085 addrp
->index
= db_reg
[1][size
][index
];
1086 addrp
->ss
= sib_ss(rex
, sib
);
1094 get_value_inc(addrp
->disp
, loc
, 4, FALSE
);
1097 else if (short_addr
)
1098 addrp
->base
= "%eip";
1100 addrp
->base
= "%rip";
1103 addrp
->base
= db_reg
[1][size
][rm
];
1108 get_value_inc(disp
, loc
, 1, TRUE
);
1110 addrp
->base
= db_reg
[1][size
][rm
];
1114 get_value_inc(disp
, loc
, 4, FALSE
);
1116 addrp
->base
= db_reg
[1][size
][rm
];
1123 db_print_address(seg
, size
, rex
, addrp
)
1127 struct i_addr
* addrp
;
1129 if (addrp
->is_reg
) {
1130 db_printf("%s", db_reg
[rex
!= 0 ? 1 : 0][(size
== LONG
&& (rex
& REX_W
)) ? QUAD
: size
][addrp
->disp
]);
1135 db_printf("%s:", seg
);
1138 if (addrp
->disp
!= 0 || (addrp
->base
== 0 && addrp
->index
== 0))
1139 db_printsym((db_addr_t
)addrp
->disp
, DB_STGY_ANY
);
1140 if (addrp
->base
!= 0 || addrp
->index
!= 0) {
1143 db_printf("%s", addrp
->base
);
1145 db_printf(",%s,%d", addrp
->index
, 1<<addrp
->ss
);
1151 * Disassemble floating-point ("escape") instruction
1152 * and return updated location.
1155 db_disasm_esc(loc
, inst
, rex
, short_addr
, size
, seg
)
1164 const struct finst
* fp
;
1166 struct i_addr address
;
1169 get_value_inc(regmodrm
, loc
, 1, FALSE
);
1170 fp
= &db_Esc_inst
[inst
- 0xd8][f_reg(rex
, regmodrm
)];
1171 mod
= f_mod(rex
, regmodrm
);
1173 if (*fp
->f_name
== '\0') {
1174 db_printf("<bad instruction>");
1178 * Normal address modes.
1180 loc
= db_read_address(loc
, short_addr
, rex
, regmodrm
, &address
);
1181 db_printf("%s", fp
->f_name
);
1182 switch(fp
->f_size
) {
1205 db_print_address(seg
, BYTE
, rex
, &address
);
1209 * 'reg-reg' - special formats
1211 switch (fp
->f_rrmode
) {
1213 name
= (fp
->f_rrname
) ? fp
->f_rrname
: fp
->f_name
;
1214 db_printf("%s\t%%st,%%st(%d)",name
,f_rm(rex
, regmodrm
));
1217 name
= (fp
->f_rrname
) ? fp
->f_rrname
: fp
->f_name
;
1218 db_printf("%s\t%%st(%d),%%st",name
, f_rm(rex
, regmodrm
));
1221 name
= (fp
->f_rrname
) ? fp
->f_rrname
: fp
->f_name
;
1222 db_printf("%s\t%%st(%d)",name
, f_rm(rex
, regmodrm
));
1225 name
= ((const char * const *)fp
->f_rrname
)[f_rm(rex
, regmodrm
)];
1228 db_printf("%s", name
);
1231 name
= ((const char * const *)fp
->f_rrname
)[f_rm(rex
, regmodrm
)];
1234 db_printf("%s\t%%ax", name
);
1238 db_printf("<bad instruction>");
1247 * Disassemble instruction at 'loc'. 'altfmt' specifies an
1248 * (optional) alternate format. Return address of start of
1252 db_disasm(db_addr_t loc
, boolean_t altfmt
)
1258 const struct inst
* ip
;
1259 const char * i_name
;
1272 struct i_addr address
;
1275 get_value_inc(inst
, loc
, 1, FALSE
);
1287 case 0x66: /* data16 */
1315 db_printf("repne ");
1324 if (inst
>= 0x40 && inst
< 0x50) {
1329 get_value_inc(inst
, loc
, 1, FALSE
);
1333 db_printf("pause\n");
1336 db_printf("repe "); /* XXX repe VS rep */
1341 if (inst
>= 0xd8 && inst
<= 0xdf) {
1342 loc
= db_disasm_esc(loc
, inst
, rex
, short_addr
, size
, seg
);
1348 get_value_inc(inst
, loc
, 1, FALSE
);
1349 ip
= db_inst_0f
[inst
>>4];
1358 ip
= &db_inst_table
[inst
];
1360 if (ip
->i_has_modrm
) {
1361 get_value_inc(regmodrm
, loc
, 1, FALSE
);
1362 loc
= db_read_address(loc
, short_addr
, rex
, regmodrm
, &address
);
1365 i_name
= ip
->i_name
;
1366 i_size
= ip
->i_size
;
1367 i_mode
= ip
->i_mode
;
1369 if (ip
->i_extra
== db_Grp1
|| ip
->i_extra
== db_Grp2
||
1370 ip
->i_extra
== db_Grp6
|| ip
->i_extra
== db_Grp7
||
1371 ip
->i_extra
== db_Grp8
|| ip
->i_extra
== db_Grp9
||
1372 ip
->i_extra
== db_Grp15
) {
1373 i_name
= ((const char * const *)ip
->i_extra
)[f_reg(rex
, regmodrm
)];
1375 else if (ip
->i_extra
== db_Grp3
) {
1377 ip
= &ip
[f_reg(rex
, regmodrm
)];
1378 i_name
= ip
->i_name
;
1379 i_mode
= ip
->i_mode
;
1381 else if (ip
->i_extra
== db_Grp4
|| ip
->i_extra
== db_Grp5
) {
1383 ip
= &ip
[f_reg(rex
, regmodrm
)];
1384 i_name
= ip
->i_name
;
1385 i_mode
= ip
->i_mode
;
1386 i_size
= ip
->i_size
;
1389 /* Special cases that don't fit well in the tables. */
1390 if (ip
->i_extra
== db_Grp7
&& f_mod(rex
, regmodrm
) == 3) {
1409 if (ip
->i_extra
== db_Grp15
&& f_mod(rex
, regmodrm
) == 3) {
1410 i_name
= db_Grp15b
[f_reg(rex
, regmodrm
)];
1415 if (i_size
== SDEP
) {
1417 db_printf("%s", i_name
);
1419 db_printf("%s", (const char *)ip
->i_extra
);
1422 db_printf("%s", i_name
);
1423 if ((inst
>= 0x50 && inst
<= 0x5f) || inst
== 0x68 || inst
== 0x6a) {
1427 if (i_size
!= NONE
) {
1428 if (i_size
== BYTE
) {
1432 else if (i_size
== WORD
) {
1436 else if (size
== WORD
)
1449 i_mode
>>= 8, first
= FALSE
)
1454 switch (i_mode
& 0xFF) {
1457 db_print_address(seg
, size
, rex
, &address
);
1462 db_print_address(seg
, size
, rex
, &address
);
1466 db_print_address(seg
, (rex
& REX_W
) ? QUAD
: LONG
, rex
, &address
);
1470 db_print_address(seg
, LONG
, 0, &address
);
1474 db_print_address(seg
, WORD
, rex
, &address
);
1478 db_print_address(seg
, BYTE
, rex
, &address
);
1482 db_printf("%s", db_reg
[rex
!= 0 ? 1 : 0][(size
== LONG
&& (rex
& REX_W
)) ? QUAD
: size
][f_reg(rex
, regmodrm
)]);
1486 db_printf("%s", db_reg
[rex
!= 0 ? 1 : 0][WORD
][f_reg(rex
, regmodrm
)]);
1490 db_printf("%s", db_reg
[0][QUAD
][f_rm(rex
, inst
)]);
1494 db_printf("%s", db_reg
[rex
!= 0 ? 1 : 0][(rex
& REX_R
) ? QUAD
: LONG
][f_rm(rex
, inst
)]);
1498 db_printf("%s", db_seg_reg
[f_reg(rex
, regmodrm
)]);
1502 db_printf("%s", db_seg_reg
[f_reg(rex
, inst
)]);
1506 db_printf("%s", db_reg
[rex
!= 0 ? 1 : 0][size
][0]); /* acc */
1511 db_printf("%s:", seg
);
1512 db_printf("(%s)", short_addr
? "%bx" : "%ebx");
1525 db_printf("%s:", seg
);
1526 db_printf("(%s)", short_addr
? "%si" : "%rsi");
1530 db_printf("%%es:(%s)", short_addr
? "%di" : "%rdi");
1534 db_printf("%%cr%d", f_reg(rex
, regmodrm
));
1538 db_printf("%%dr%d", f_reg(rex
, regmodrm
));
1542 db_printf("%%tr%d", f_reg(rex
, regmodrm
));
1546 len
= db_lengths
[size
];
1547 get_value_inc(imm
, loc
, len
, FALSE
);
1548 db_printf("$%#x", imm
);
1552 len
= db_lengths
[(size
== LONG
&& (rex
& REX_W
)) ? QUAD
: size
];
1553 get_value_inc(imm
, loc
, len
, FALSE
);
1554 db_printf("$%x", imm
);
1558 get_value_inc(imm
, loc
, 1, FALSE
);
1559 db_printf("$%#x", imm
);
1563 get_value_inc(imm
, loc
, 1, FALSE
);
1565 db_printf("$%#x", imm
);
1569 get_value_inc(imm
, loc
, 1, TRUE
);
1572 db_printf("$%x", imm
);
1576 get_value_inc(imm
, loc
, 2, FALSE
);
1577 db_printf("$%#x", imm
);
1581 len
= db_lengths
[rex
& REX_W
? QUAD
: LONG
];
1582 get_value_inc(imm64
, loc
, len
, FALSE
);
1583 db_printf("$%#lx", imm64
);
1587 len
= (short_addr
? 2 : 4);
1588 get_value_inc(displ
, loc
, len
, FALSE
);
1590 db_printf("%s:%x",seg
, displ
);
1592 db_printsym((db_addr_t
)displ
, DB_STGY_ANY
);
1596 get_value_inc(displ
, loc
, 1, TRUE
);
1597 addr
= loc
+ (LONG64
)displ
;
1600 db_printsym(addr
, DB_STGY_XTRN
);
1604 len
= db_lengths
[(size
== LONG
&& (rex
& REX_W
)) ? QUAD
: size
];
1605 get_value_inc(displ
, loc
, len
, FALSE
);
1606 addr
= loc
+ (LONG64
)displ
;
1609 db_printsym(addr
, DB_STGY_XTRN
);
1621 len
= db_lengths
[size
];
1622 get_value_inc(imm
, loc
, len
, FALSE
); /* offset */
1623 get_value_inc(imm2
, loc
, 2, FALSE
); /* segment */
1624 db_printf("$%#x,%#x", imm2
, imm
);
1627 db_printf("%%mm%d", f_reg(rex
, regmodrm
));
1630 db_printf("%%mm%d", f_rm(rex
, regmodrm
));
1633 db_printf("%%xmm%d", f_reg(rex
, regmodrm
));
1636 db_printf("%%xmm%d", f_rm(rex
, regmodrm
));
1643 void be_x86_64_disasm_one_insn(ADDRESS64
*addr
, int display
)
1645 db_printf
= display
? dbg_printf
: no_printf
;
1646 addr
->Offset
= db_disasm(addr
->Offset
, TRUE
);