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 "AS IS"
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 Mellon
24 * the rights to redistribute these changes.
29 * Revision 2.6 92/01/03 20:05:00 dbg
30 * Add a switch to disassemble 16-bit code.
31 * Fix spelling of 'lods' opcodes.
34 * Revision 2.5 91/10/09 16:05:58 af
35 * Supported disassemble of non current task by passing task parameter.
38 * Revision 2.4 91/05/14 16:05:04 mrt
39 * Correcting copyright
41 * Revision 2.3 91/02/05 17:11:03 mrt
42 * Changed to new Mach copyright
43 * [91/02/01 17:31:03 mrt]
45 * Revision 2.2 90/08/27 21:55:56 dbg
46 * Fix register operand for move to/from control/test/debug
47 * register instructions. Add i486 instructions.
50 * Import db_sym.h. Print instruction displacements in
51 * current radix (signed). Change calling sequence of
62 * Instruction disassembler.
70 * Switch to disassemble 16-bit code.
72 static BOOL db_disasm_16 = FALSE;
75 * Flag to indicate whether we need to display instruction,
76 * or whether we just need to know the address of the next
79 static BOOL db_display = FALSE;
97 #define E 1 /* general effective address */
98 #define Eind 2 /* indirect address (jump, call) */
99 #define Ew 3 /* address, word size */
100 #define Eb 4 /* address, byte size */
101 #define R 5 /* register, in 'reg' field */
102 #define Rw 6 /* word register, in 'reg' field */
103 #define Ri 7 /* register in instruction */
104 #define S 8 /* segment reg, in 'reg' field */
105 #define Si 9 /* segment reg, in instruction */
106 #define A 10 /* accumulator */
107 #define BX 11 /* (bx) */
108 #define CL 12 /* cl, for shifts */
109 #define DX 13 /* dx, for IO */
110 #define SI 14 /* si */
111 #define DI 15 /* di */
112 #define CR 16 /* control register */
113 #define DR 17 /* debug register */
114 #define TR 18 /* test register */
115 #define I 19 /* immediate, unsigned */
116 #define Is 20 /* immediate, signed */
117 #define Ib 21 /* byte immediate, unsigned */
118 #define Ibs 22 /* byte immediate, signed */
119 #define Iw 23 /* word immediate, unsigned */
120 #define Il 24 /* long immediate */
121 #define O 25 /* direct address */
122 #define Db 26 /* byte displacement from EIP */
123 #define Dl 27 /* long displacement from EIP */
124 #define o1 28 /* constant 1 */
125 #define o3 29 /* constant 3 */
126 #define OS 30 /* immediate offset/segment */
127 #define ST 31 /* FP stack top */
128 #define STI 32 /* FP stack */
129 #define X 33 /* extended FP op */
130 #define XA 34 /* for 'fstcw %ax' */
131 #define MX 35 /* special register (MMX reg %mm0-7) */
132 #define EMX 36 /* special register (MMX reg %mm0-7) */
133 #define XMM 37 /* special register (floating point reg %xmm0-7) */
134 #define EXMM 38 /* special register (floating point reg %xmm0-7) */
137 const char *i_name; /* name */
138 short i_has_modrm; /* has regmodrm byte */
139 short i_size; /* operand size */
140 int i_mode; /* addressing modes */
141 const char *i_extra; /* pointer to extra opcode table */
145 #define op2(x,y) ((x)|((y)<<8))
146 #define op3(x,y,z) ((x)|((y)<<8)|((z)<<16))
149 const char *f_name; /* name for memory instruction */
150 int f_size; /* size for memory instruction */
151 int f_rrmode; /* mode for rr instruction */
152 const char *f_rrname; /* name for rr instruction
153 (or pointer to table) */
156 static const char * const db_Grp6[] = {
167 static const char * const db_Grp7[] = {
178 static const char * const db_Grp8[] = {
189 static const char * const db_Grp10[] = {
200 static const char * const db_Grp11[] = {
211 static const char * const db_Grp12[] = {
222 static const struct inst db_inst_0f0x[] = {
223 /*00*/ { "", TRUE, NONE, op1(Ew), (const char *)db_Grp6 },
224 /*01*/ { "", TRUE, NONE, op1(Ew), (const char *)db_Grp7 },
225 /*02*/ { "lar", TRUE, LONG, op2(E,R), 0 },
226 /*03*/ { "lsl", TRUE, LONG, op2(E,R), 0 },
227 /*04*/ { "", FALSE, NONE, 0, 0 },
228 /*05*/ { "", FALSE, NONE, 0, 0 },
229 /*06*/ { "clts", FALSE, NONE, 0, 0 },
230 /*07*/ { "", FALSE, NONE, 0, 0 },
232 /*08*/ { "invd", FALSE, NONE, 0, 0 },
233 /*09*/ { "wbinvd",FALSE, NONE, 0, 0 },
234 /*0a*/ { "", FALSE, NONE, 0, 0 },
235 /*0b*/ { "", FALSE, NONE, 0, 0 },
236 /*0c*/ { "", FALSE, NONE, 0, 0 },
237 /*0d*/ { "", FALSE, NONE, 0, 0 },
238 /*0e*/ { "", FALSE, NONE, 0, 0 },
239 /*0f*/ { "", FALSE, NONE, 0, 0 },
242 static const struct inst db_inst_0f2x[] = {
243 /*20*/ { "mov", TRUE, LONG, op2(CR,E), 0 }, /* use E for reg */
244 /*21*/ { "mov", TRUE, LONG, op2(DR,E), 0 }, /* since mod == 11 */
245 /*22*/ { "mov", TRUE, LONG, op2(E,CR), 0 },
246 /*23*/ { "mov", TRUE, LONG, op2(E,DR), 0 },
247 /*24*/ { "mov", TRUE, LONG, op2(TR,E), 0 },
248 /*25*/ { "(bad)", FALSE, NONE, 0, 0 },
249 /*26*/ { "mov", TRUE, LONG, op2(E,TR), 0 },
250 /*27*/ { "(bad)", FALSE, NONE, 0, 0 },
252 /*28*/ { "", FALSE, NONE, 0, 0 },
253 /*29*/ { "", FALSE, NONE, 0, 0 },
254 /*2a*/ { "", FALSE, NONE, 0, 0 },
255 /*2b*/ { "", FALSE, NONE, 0, 0 },
256 /*2c*/ { "", FALSE, NONE, 0, 0 },
257 /*2d*/ { "", FALSE, NONE, 0, 0 },
258 /*2e*/ { "", FALSE, NONE, 0, 0 },
259 /*2f*/ { "", FALSE, NONE, 0, 0 },
262 static const struct inst db_inst_0f3x[] = {
263 /*30*/ { "wrmsr", FALSE, NONE, 0, 0 },
264 /*31*/ { "rdtsc", FALSE, NONE, 0, 0 },
265 /*32*/ { "rdmsr", FALSE, NONE, 0, 0 },
266 /*33*/ { "rdpmc", FALSE, NONE, 0, 0 },
267 /*34*/ { "sysenter",FALSE,NONE, 0, 0 },
268 /*35*/ { "sysexit",FALSE,NONE, 0, 0 },
269 /*36*/ { "(bad)", FALSE, NONE, 0, 0 },
270 /*37*/ { "(bad)", FALSE, NONE, 0, 0 },
272 /*38*/ { "(bad)",FALSE, NONE, 0, 0 },
273 /*39*/ { "(bad)",FALSE, NONE, 0, 0 },
274 /*3a*/ { "(bad)",FALSE, NONE, 0, 0 },
275 /*3b*/ { "(bad)",FALSE, NONE, 0, 0 },
276 /*3c*/ { "(bad)",FALSE, NONE, 0, 0 },
277 /*3d*/ { "(bad)",FALSE, NONE, 0, 0 },
278 /*3e*/ { "(bad)",FALSE, NONE, 0, 0 },
279 /*3f*/ { "(bad)",FALSE, NONE, 0, 0 },
282 static const struct inst db_inst_0f4x[] = {
283 /*40*/ { "cmovo", TRUE, NONE, op2(E, R), 0 },
284 /*41*/ { "cmovno", TRUE, NONE, op2(E, R), 0 },
285 /*42*/ { "cmovnae",TRUE, NONE, op2(E, R), 0 },
286 /*43*/ { "cmovnb", TRUE, NONE, op2(E, R), 0 },
287 /*44*/ { "cmove", TRUE, NONE, op2(E, R), 0 },
288 /*45*/ { "cmovne", TRUE, NONE, op2(E, R), 0 },
289 /*46*/ { "cmovna", TRUE, NONE, op2(E, R), 0 },
290 /*47*/ { "cmova", TRUE, NONE, op2(E, R), 0 },
292 /*48*/ { "cmovs", TRUE, NONE, op2(E, R), 0 },
293 /*49*/ { "cmovns", TRUE, NONE, op2(E, R), 0 },
294 /*4a*/ { "cmovpe", TRUE, NONE, op2(E, R), 0 },
295 /*4b*/ { "cmovpo", TRUE, NONE, op2(E, R), 0 },
296 /*4c*/ { "cmovl", TRUE, NONE, op2(E, R), 0 },
297 /*4d*/ { "cmovge", TRUE, NONE, op2(E, R), 0 },
298 /*4e*/ { "cmovle", TRUE, NONE, op2(E, R), 0 },
299 /*4f*/ { "cmovnle",TRUE, NONE, op2(E, R), 0 },
302 static const struct inst db_inst_0f5x[] = {
303 /*50*/ { "movmskps",TRUE, NONE, op2(E, XMM), 0 },
304 /*51*/ { "sqrtps", TRUE, NONE, op2(XMM, EXMM), 0 },
305 /*52*/ { "rsqrtps", TRUE, NONE, op2(XMM, EXMM), 0 },
306 /*53*/ { "rcpps", TRUE, NONE, op2(XMM, EXMM), 0 },
307 /*54*/ { "andps", TRUE, NONE, op2(XMM, EXMM), 0 },
308 /*55*/ { "andnps", TRUE, NONE, op2(XMM, EXMM), 0 },
309 /*56*/ { "orps", TRUE, NONE, op2(XMM, EXMM), 0 },
310 /*57*/ { "xorps", TRUE, NONE, op2(XMM, EXMM), 0 },
312 /*58*/ { "addps", TRUE, NONE, op2(XMM, EXMM), 0 },
313 /*59*/ { "mulps", TRUE, NONE, op2(XMM, EXMM), 0 },
314 /*5a*/ { "(bad)", FALSE, NONE, 0, 0 },
315 /*5b*/ { "(bad)", FALSE, NONE, 0, 0 },
316 /*5c*/ { "subps", TRUE, NONE, op2(XMM, EXMM), 0 },
317 /*5d*/ { "minps", TRUE, NONE, op2(XMM, EXMM), 0 },
318 /*5e*/ { "divps", TRUE, NONE, op2(XMM, EXMM), 0 },
319 /*5f*/ { "maxps", TRUE, NONE, op2(XMM, EXMM), 0 },
322 static const struct inst db_inst_0f6x[] = {
323 /*60*/ { "punpcklbw", TRUE, NONE, op2(E, MX), 0 },
324 /*61*/ { "punpcklwd", TRUE, NONE, op2(E, MX), 0 },
325 /*62*/ { "punpckldq", TRUE, NONE, op2(E, MX), 0 },
326 /*63*/ { "packsswb", TRUE, NONE, op2(E, MX), 0 },
327 /*64*/ { "pcmpgtb", TRUE, NONE, op2(E, MX), 0 },
328 /*65*/ { "pcmpgtw", TRUE, NONE, op2(E, MX), 0 },
329 /*66*/ { "pcmpgtd", TRUE, NONE, op2(E, MX), 0 },
330 /*67*/ { "packuswb", TRUE, NONE, op2(E, MX), 0 },
332 /*68*/ { "punpckhbw", TRUE, NONE, op2(E, MX), 0 },
333 /*69*/ { "punpckhwd", TRUE, NONE, op2(E, MX), 0 },
334 /*6a*/ { "punpckhdq", TRUE, NONE, op2(E, MX), 0 },
335 /*6b*/ { "packssdw", TRUE, NONE, op2(E, MX), 0 },
336 /*6c*/ { "(bad)", TRUE, NONE, 0, 0 },
337 /*6d*/ { "(bad)", TRUE, NONE, 0, 0 },
338 /*6e*/ { "movd", TRUE, NONE, op2(E, MX), 0 },
339 /*6f*/ { "movq", TRUE, NONE, op2(E, MX), 0 },
342 static const struct inst db_inst_0f7x[] = {
343 /*70*/ { "pshufw", TRUE, NONE, op2(MX, EMX), 0 },
344 /*71*/ { "(grp10)", TRUE, BYTE, op2(EMX, I), (const char*)db_Grp10 },
345 /*72*/ { "(grp11)", TRUE, BYTE, op2(EMX, I), (const char*)db_Grp11 },
346 /*73*/ { "(grp12)", TRUE, BYTE, op2(EMX, I), (const char*)db_Grp12 },
347 /*74*/ { "pcmpeqb", TRUE, NONE, op2(E, MX), 0 },
348 /*75*/ { "pcmpeqw", TRUE, NONE, op2(E, MX), 0 },
349 /*76*/ { "pcmpeqd", TRUE, NONE, op2(E, MX), 0 },
350 /*77*/ { "emms", FALSE,NONE, 0, 0 },
352 /*78*/ { "(bad)", TRUE, NONE, 0, 0 },
353 /*79*/ { "(bad)", TRUE, NONE, 0, 0 },
354 /*7a*/ { "(bad)", TRUE, NONE, 0, 0 },
355 /*7b*/ { "(bad)", TRUE, NONE, 0, 0 },
356 /*7c*/ { "(bad)", TRUE, NONE, 0, 0 },
357 /*7d*/ { "(bad)", TRUE, NONE, 0, 0 },
358 /*7e*/ { "movd", TRUE, NONE, op2(E, MX), 0 },
359 /*7f*/ { "movq", TRUE, NONE, op2(EMX, MX), 0 },
362 static const struct inst db_inst_0f8x[] = {
363 /*80*/ { "jo", FALSE, NONE, op1(Dl), 0 },
364 /*81*/ { "jno", FALSE, NONE, op1(Dl), 0 },
365 /*82*/ { "jb", FALSE, NONE, op1(Dl), 0 },
366 /*83*/ { "jnb", FALSE, NONE, op1(Dl), 0 },
367 /*84*/ { "jz", FALSE, NONE, op1(Dl), 0 },
368 /*85*/ { "jnz", FALSE, NONE, op1(Dl), 0 },
369 /*86*/ { "jbe", FALSE, NONE, op1(Dl), 0 },
370 /*87*/ { "jnbe", FALSE, NONE, op1(Dl), 0 },
372 /*88*/ { "js", FALSE, NONE, op1(Dl), 0 },
373 /*89*/ { "jns", FALSE, NONE, op1(Dl), 0 },
374 /*8a*/ { "jp", FALSE, NONE, op1(Dl), 0 },
375 /*8b*/ { "jnp", FALSE, NONE, op1(Dl), 0 },
376 /*8c*/ { "jl", FALSE, NONE, op1(Dl), 0 },
377 /*8d*/ { "jnl", FALSE, NONE, op1(Dl), 0 },
378 /*8e*/ { "jle", FALSE, NONE, op1(Dl), 0 },
379 /*8f*/ { "jnle", FALSE, NONE, op1(Dl), 0 },
382 static const struct inst db_inst_0f9x[] = {
383 /*90*/ { "seto", TRUE, NONE, op1(Eb), 0 },
384 /*91*/ { "setno", TRUE, NONE, op1(Eb), 0 },
385 /*92*/ { "setb", TRUE, NONE, op1(Eb), 0 },
386 /*93*/ { "setnb", TRUE, NONE, op1(Eb), 0 },
387 /*94*/ { "setz", TRUE, NONE, op1(Eb), 0 },
388 /*95*/ { "setnz", TRUE, NONE, op1(Eb), 0 },
389 /*96*/ { "setbe", TRUE, NONE, op1(Eb), 0 },
390 /*97*/ { "setnbe",TRUE, NONE, op1(Eb), 0 },
392 /*98*/ { "sets", TRUE, NONE, op1(Eb), 0 },
393 /*99*/ { "setns", TRUE, NONE, op1(Eb), 0 },
394 /*9a*/ { "setp", TRUE, NONE, op1(Eb), 0 },
395 /*9b*/ { "setnp", TRUE, NONE, op1(Eb), 0 },
396 /*9c*/ { "setl", TRUE, NONE, op1(Eb), 0 },
397 /*9d*/ { "setnl", TRUE, NONE, op1(Eb), 0 },
398 /*9e*/ { "setle", TRUE, NONE, op1(Eb), 0 },
399 /*9f*/ { "setnle",TRUE, NONE, op1(Eb), 0 },
402 static const struct inst db_inst_0fax[] = {
403 /*a0*/ { "push", FALSE, NONE, op1(Si), 0 },
404 /*a1*/ { "pop", FALSE, NONE, op1(Si), 0 },
405 /*a2*/ { "cpuid", FALSE, NONE, 0, 0 },
406 /*a3*/ { "bt", TRUE, LONG, op2(E,R), 0 },
407 /*a4*/ { "shld", TRUE, LONG, op3(Ib,E,R), 0 },
408 /*a5*/ { "shld", TRUE, LONG, op3(CL,E,R), 0 },
409 /*a6*/ { "", FALSE, NONE, 0, 0 },
410 /*a7*/ { "", FALSE, NONE, 0, 0 },
412 /*a8*/ { "push", FALSE, NONE, op1(Si), 0 },
413 /*a9*/ { "pop", FALSE, NONE, op1(Si), 0 },
414 /*aa*/ { "", FALSE, NONE, 0, 0 },
415 /*ab*/ { "bts", TRUE, LONG, op2(E,R), 0 },
416 /*ac*/ { "shrd", TRUE, LONG, op3(Ib,E,R), 0 },
417 /*ad*/ { "shrd", TRUE, LONG, op3(CL,E,R), 0 },
418 /*a6*/ { "", FALSE, NONE, 0, 0 },
419 /*a7*/ { "imul", TRUE, LONG, op2(E,R), 0 },
422 static const struct inst db_inst_0fbx[] = {
423 /*b0*/ { "cmpxchg",TRUE, BYTE, op2(E, R), 0 },
424 /*b1*/ { "cmpxchg",TRUE, LONG, op2(E, R), 0 },
425 /*b2*/ { "lss", TRUE, LONG, op2(E, R), 0 },
426 /*b3*/ { "bts", TRUE, LONG, op2(R, E), 0 },
427 /*b4*/ { "lfs", TRUE, LONG, op2(E, R), 0 },
428 /*b5*/ { "lgs", TRUE, LONG, op2(E, R), 0 },
429 /*b6*/ { "movzb", TRUE, LONG, op2(E, R), 0 },
430 /*b7*/ { "movzw", TRUE, LONG, op2(E, R), 0 },
432 /*b8*/ { "", FALSE, NONE, 0, 0 },
433 /*b9*/ { "", FALSE, NONE, 0, 0 },
434 /*ba*/ { "", TRUE, LONG, op2(Ib, E), (const char *)db_Grp8 },
435 /*bb*/ { "btc", TRUE, LONG, op2(R, E), 0 },
436 /*bc*/ { "bsf", TRUE, LONG, op2(E, R), 0 },
437 /*bd*/ { "bsr", TRUE, LONG, op2(E, R), 0 },
438 /*be*/ { "movsb", TRUE, LONG, op2(E, R), 0 },
439 /*bf*/ { "movsw", TRUE, LONG, op2(E, R), 0 },
442 static const struct inst db_inst_0fcx[] = {
443 /*c0*/ { "xadd", TRUE, BYTE, op2(R, E), 0 },
444 /*c1*/ { "xadd", TRUE, LONG, op2(R, E), 0 },
445 /*c2*/ { "", FALSE, NONE, 0, 0 },
446 /*c3*/ { "", FALSE, NONE, 0, 0 },
447 /*c4*/ { "", FALSE, NONE, 0, 0 },
448 /*c5*/ { "", FALSE, NONE, 0, 0 },
449 /*c6*/ { "", FALSE, NONE, 0, 0 },
450 /*c7*/ { "", FALSE, NONE, 0, 0 },
451 /*c8*/ { "bswap", FALSE, LONG, op1(Ri), 0 },
452 /*c9*/ { "bswap", FALSE, LONG, op1(Ri), 0 },
453 /*ca*/ { "bswap", FALSE, LONG, op1(Ri), 0 },
454 /*cb*/ { "bswap", FALSE, LONG, op1(Ri), 0 },
455 /*cc*/ { "bswap", FALSE, LONG, op1(Ri), 0 },
456 /*cd*/ { "bswap", FALSE, LONG, op1(Ri), 0 },
457 /*ce*/ { "bswap", FALSE, LONG, op1(Ri), 0 },
458 /*cf*/ { "bswap", FALSE, LONG, op1(Ri), 0 },
461 static const struct inst db_inst_0fdx[] = {
462 /*d0*/ { "(bad)", FALSE, NONE,0, 0 },
463 /*d1*/ { "psrlw", TRUE, NONE,op2(MX,EMX), 0 },
464 /*d2*/ { "psrld", TRUE, NONE,op2(MX,EMX), 0 },
465 /*d3*/ { "psrld", TRUE, NONE,op2(MX,EMX), 0 },
466 /*d4*/ { "(bad)", FALSE, NONE,0, 0 },
467 /*d5*/ { "pmulww", TRUE, NONE,op2(MX,EMX), 0 },
468 /*d6*/ { "(bad)", FALSE, NONE,0, 0 },
469 /*d7*/ { "pmovmskb",FALSE, NONE,op2(MX,EMX),0 },
470 /*d8*/ { "psubusb", TRUE, NONE,op2(MX,EMX), 0 },
471 /*d9*/ { "psubusw", TRUE, NONE,op2(MX,EMX), 0 },
472 /*da*/ { "pminub", TRUE, NONE,op2(MX,EMX), 0 },
473 /*db*/ { "pand", TRUE, NONE,op2(MX,EMX), 0 },
474 /*dc*/ { "paddusb", TRUE, NONE,op2(MX,EMX), 0 },
475 /*dd*/ { "paddusw", TRUE, NONE,op2(MX,EMX), 0 },
476 /*de*/ { "pmaxub", TRUE, NONE,op2(MX,EMX), 0 },
477 /*df*/ { "pandn", TRUE, NONE,op2(MX,EMX), 0 },
480 static const struct inst db_inst_0fex[] = {
481 /*e0*/ { "pavgb", TRUE, NONE, op2(MX, EMX), 0 },
482 /*e1*/ { "psraw", TRUE, NONE, op2(MX, EMX), 0 },
483 /*e2*/ { "psrad", TRUE, NONE, op2(MX, EMX), 0 },
484 /*e3*/ { "pavgw", TRUE, NONE, op2(MX, EMX), 0 },
485 /*e4*/ { "pmulhuw",TRUE, NONE, op2(MX, EMX), 0 },
486 /*e5*/ { "pmulhw", TRUE, NONE, op2(MX, EMX), 0 },
487 /*e6*/ { "(bad)", FALSE,NONE, 0, 0 },
488 /*e7*/ { "movntq", TRUE, NONE, op2(MX, EMX), 0 },
489 /*e8*/ { "psubsb", TRUE, NONE, op2(MX, EMX), 0 },
490 /*e9*/ { "psubsw", TRUE, NONE, op2(MX, EMX), 0 },
491 /*ea*/ { "pminsw", TRUE, NONE, op2(MX, EMX), 0 },
492 /*eb*/ { "por", TRUE, NONE, op2(MX, EMX), 0 },
493 /*ec*/ { "paddsb", TRUE, NONE, op2(MX, EMX), 0 },
494 /*ed*/ { "paddsw", TRUE, NONE, op2(MX, EMX), 0 },
495 /*ee*/ { "pmaxsw", TRUE, NONE, op2(MX, EMX), 0 },
496 /*ef*/ { "pxor", TRUE, NONE, op2(MX, EMX), 0 },
499 static const struct inst db_inst_0ffx[] = {
500 /*f0*/ { "(bad)", FALSE,NONE, 0, 0 },
501 /*f1*/ { "psllw", TRUE, NONE, op2(MX, EMX), 0 },
502 /*f2*/ { "pslld", TRUE, NONE, op2(MX, EMX), 0 },
503 /*f3*/ { "psllq", TRUE, NONE, op2(MX, EMX), 0 },
504 /*f4*/ { "(bad)", FALSE,NONE, 0, 0 },
505 /*f5*/ { "pmaddwd",TRUE, NONE, op2(MX, EMX), 0 },
506 /*f6*/ { "psadbw", TRUE, NONE, op2(MX, EMX), 0 },
507 /*f7*/ { "maskmovq",TRUE,NONE, op2(MX, EMX), 0 },
508 /*f8*/ { "psubb", TRUE, NONE, op2(MX, EMX), 0 },
509 /*f9*/ { "psubw", TRUE, NONE, op2(MX, EMX), 0 },
510 /*fa*/ { "psubd", TRUE, NONE, op2(MX, EMX), 0 },
511 /*fb*/ { "(bad)", FALSE,NONE, 0, 0 },
512 /*fc*/ { "paddb", TRUE, NONE, op2(MX, EMX), 0 },
513 /*fd*/ { "paddw", TRUE, NONE, op2(MX, EMX), 0 },
514 /*fe*/ { "paddd", TRUE, NONE, op2(MX, EMX), 0 },
515 /*ff*/ { "(bad)", FALSE, NONE, 0, 0 },
518 static const struct inst * const db_inst_0f[] = {
537 static const char * const db_Esc92[] = {
538 "fnop", "", "", "", "", "", "", ""
540 static const char * const db_Esc93[] = {
541 "", "", "", "", "", "", "", ""
543 static const char * const db_Esc94[] = {
544 "fchs", "fabs", "", "", "ftst", "fxam", "", ""
546 static const char * const db_Esc95[] = {
547 "fld1", "fldl2t","fldl2e","fldpi","fldlg2","fldln2","fldz",""
549 static const char * const db_Esc96[] = {
550 "f2xm1","fyl2x","fptan","fpatan","fxtract","fprem1","fdecstp",
553 static const char * const db_Esc97[] = {
554 "fprem","fyl2xp1","fsqrt","fsincos","frndint","fscale","fsin","fcos"
557 static const char * const db_Esca4[] = {
558 "", "fucompp","", "", "", "", "", ""
561 static const char * const db_Escb4[] = {
562 "", "", "fnclex","fninit","", "", "", ""
565 static const char * const db_Esce3[] = {
566 "", "fcompp","", "", "", "", "", ""
569 static const char * const db_Escf4[] = {
570 "fnstsw","", "", "", "", "", "", ""
573 static const struct finst db_Esc8[] = {
574 /*0*/ { "fadd", SNGL, op2(STI,ST), 0 },
575 /*1*/ { "fmul", SNGL, op2(STI,ST), 0 },
576 /*2*/ { "fcom", SNGL, op2(STI,ST), 0 },
577 /*3*/ { "fcomp", SNGL, op2(STI,ST), 0 },
578 /*4*/ { "fsub", SNGL, op2(STI,ST), 0 },
579 /*5*/ { "fsubr", SNGL, op2(STI,ST), 0 },
580 /*6*/ { "fdiv", SNGL, op2(STI,ST), 0 },
581 /*7*/ { "fdivr", SNGL, op2(STI,ST), 0 },
584 static const struct finst db_Esc9[] = {
585 /*0*/ { "fld", SNGL, op1(STI), 0 },
586 /*1*/ { "", NONE, op1(STI), "fxch" },
587 /*2*/ { "fst", SNGL, op1(X), (const char *)db_Esc92 },
588 /*3*/ { "fstp", SNGL, op1(X), (const char *)db_Esc93 },
589 /*4*/ { "fldenv", NONE, op1(X), (const char *)db_Esc94 },
590 /*5*/ { "fldcw", NONE, op1(X), (const char *)db_Esc95 },
591 /*6*/ { "fnstenv",NONE, op1(X), (const char *)db_Esc96 },
592 /*7*/ { "fnstcw", NONE, op1(X), (const char *)db_Esc97 },
595 static const struct finst db_Esca[] = {
596 /*0*/ { "fiadd", WORD, 0, 0 },
597 /*1*/ { "fimul", WORD, 0, 0 },
598 /*2*/ { "ficom", WORD, 0, 0 },
599 /*3*/ { "ficomp", WORD, 0, 0 },
600 /*4*/ { "fisub", WORD, op1(X), (const char *)db_Esca4 },
601 /*5*/ { "fisubr", WORD, 0, 0 },
602 /*6*/ { "fidiv", WORD, 0, 0 },
603 /*7*/ { "fidivr", WORD, 0, 0 }
606 static const struct finst db_Escb[] = {
607 /*0*/ { "fild", WORD, 0, 0 },
608 /*1*/ { "", NONE, 0, 0 },
609 /*2*/ { "fist", WORD, 0, 0 },
610 /*3*/ { "fistp", WORD, 0, 0 },
611 /*4*/ { "", WORD, op1(X), (const char *)db_Escb4 },
612 /*5*/ { "fld", EXTR, 0, 0 },
613 /*6*/ { "", WORD, 0, 0 },
614 /*7*/ { "fstp", EXTR, 0, 0 },
617 static const struct finst db_Escc[] = {
618 /*0*/ { "fadd", DBLR, op2(ST,STI), 0 },
619 /*1*/ { "fmul", DBLR, op2(ST,STI), 0 },
620 /*2*/ { "fcom", DBLR, op2(ST,STI), 0 },
621 /*3*/ { "fcomp", DBLR, op2(ST,STI), 0 },
622 /*4*/ { "fsub", DBLR, op2(ST,STI), "fsubr" },
623 /*5*/ { "fsubr", DBLR, op2(ST,STI), "fsub" },
624 /*6*/ { "fdiv", DBLR, op2(ST,STI), "fdivr" },
625 /*7*/ { "fdivr", DBLR, op2(ST,STI), "fdiv" },
628 static const struct finst db_Escd[] = {
629 /*0*/ { "fld", DBLR, op1(STI), "ffree" },
630 /*1*/ { "", NONE, 0, 0 },
631 /*2*/ { "fst", DBLR, op1(STI), 0 },
632 /*3*/ { "fstp", DBLR, op1(STI), 0 },
633 /*4*/ { "frstor", NONE, op1(STI), "fucom" },
634 /*5*/ { "", NONE, op1(STI), "fucomp" },
635 /*6*/ { "fnsave", NONE, 0, 0 },
636 /*7*/ { "fnstsw", NONE, 0, 0 },
639 static const struct finst db_Esce[] = {
640 /*0*/ { "fiadd", LONG, op2(ST,STI), "faddp" },
641 /*1*/ { "fimul", LONG, op2(ST,STI), "fmulp" },
642 /*2*/ { "ficom", LONG, 0, 0 },
643 /*3*/ { "ficomp", LONG, op1(X), (const char *)db_Esce3 },
644 /*4*/ { "fisub", LONG, op2(ST,STI), "fsubrp" },
645 /*5*/ { "fisubr", LONG, op2(ST,STI), "fsubp" },
646 /*6*/ { "fidiv", LONG, op2(ST,STI), "fdivrp" },
647 /*7*/ { "fidivr", LONG, op2(ST,STI), "fdivp" },
650 static const struct finst db_Escf[] = {
651 /*0*/ { "fild", LONG, 0, 0 },
652 /*1*/ { "", LONG, 0, 0 },
653 /*2*/ { "fist", LONG, 0, 0 },
654 /*3*/ { "fistp", LONG, 0, 0 },
655 /*4*/ { "fbld", NONE, op1(XA), (const char *)db_Escf4 },
656 /*5*/ { "fld", QUAD, 0, 0 },
657 /*6*/ { "fbstp", NONE, 0, 0 },
658 /*7*/ { "fstp", QUAD, 0, 0 },
661 static const struct finst * const db_Esc_inst[] = {
662 db_Esc8, db_Esc9, db_Esca, db_Escb,
663 db_Escc, db_Escd, db_Esce, db_Escf
666 static const char * const db_Grp1[] = {
677 static const char * const db_Grp2[] = {
688 static const struct inst db_Grp3[] = {
689 { "test", TRUE, NONE, op2(I,E), 0 },
690 { "test", TRUE, NONE, op2(I,E), 0 },
691 { "not", TRUE, NONE, op1(E), 0 },
692 { "neg", TRUE, NONE, op1(E), 0 },
693 { "mul", TRUE, NONE, op2(E,A), 0 },
694 { "imul", TRUE, NONE, op2(E,A), 0 },
695 { "div", TRUE, NONE, op2(E,A), 0 },
696 { "idiv", TRUE, NONE, op2(E,A), 0 },
699 static const struct inst db_Grp4[] = {
700 { "inc", TRUE, BYTE, op1(E), 0 },
701 { "dec", TRUE, BYTE, op1(E), 0 },
702 { "", TRUE, NONE, 0, 0 },
703 { "", TRUE, NONE, 0, 0 },
704 { "", TRUE, NONE, 0, 0 },
705 { "", TRUE, NONE, 0, 0 },
706 { "", TRUE, NONE, 0, 0 },
707 { "", TRUE, NONE, 0, 0 }
710 static const struct inst db_Grp5[] = {
711 { "inc", TRUE, LONG, op1(E), 0 },
712 { "dec", TRUE, LONG, op1(E), 0 },
713 { "call", TRUE, NONE, op1(Eind),0 },
714 { "lcall", TRUE, NONE, op1(Eind),0 },
715 { "jmp", TRUE, NONE, op1(Eind),0 },
716 { "ljmp", TRUE, NONE, op1(Eind),0 },
717 { "push", TRUE, LONG, op1(E), 0 },
718 { "", TRUE, NONE, 0, 0 }
721 static const struct inst db_inst_table[256] = {
722 /*00*/ { "add", TRUE, BYTE, op2(R, E), 0 },
723 /*01*/ { "add", TRUE, LONG, op2(R, E), 0 },
724 /*02*/ { "add", TRUE, BYTE, op2(E, R), 0 },
725 /*03*/ { "add", TRUE, LONG, op2(E, R), 0 },
726 /*04*/ { "add", FALSE, BYTE, op2(Is, A), 0 },
727 /*05*/ { "add", FALSE, LONG, op2(Is, A), 0 },
728 /*06*/ { "push", FALSE, NONE, op1(Si), 0 },
729 /*07*/ { "pop", FALSE, NONE, op1(Si), 0 },
731 /*08*/ { "or", TRUE, BYTE, op2(R, E), 0 },
732 /*09*/ { "or", TRUE, LONG, op2(R, E), 0 },
733 /*0a*/ { "or", TRUE, BYTE, op2(E, R), 0 },
734 /*0b*/ { "or", TRUE, LONG, op2(E, R), 0 },
735 /*0c*/ { "or", FALSE, BYTE, op2(I, A), 0 },
736 /*0d*/ { "or", FALSE, LONG, op2(I, A), 0 },
737 /*0e*/ { "push", FALSE, NONE, op1(Si), 0 },
738 /*0f*/ { "", FALSE, NONE, 0, 0 },
740 /*10*/ { "adc", TRUE, BYTE, op2(R, E), 0 },
741 /*11*/ { "adc", TRUE, LONG, op2(R, E), 0 },
742 /*12*/ { "adc", TRUE, BYTE, op2(E, R), 0 },
743 /*13*/ { "adc", TRUE, LONG, op2(E, R), 0 },
744 /*14*/ { "adc", FALSE, BYTE, op2(Is, A), 0 },
745 /*15*/ { "adc", FALSE, LONG, op2(Is, A), 0 },
746 /*16*/ { "push", FALSE, NONE, op1(Si), 0 },
747 /*17*/ { "pop", FALSE, NONE, op1(Si), 0 },
749 /*18*/ { "sbb", TRUE, BYTE, op2(R, E), 0 },
750 /*19*/ { "sbb", TRUE, LONG, op2(R, E), 0 },
751 /*1a*/ { "sbb", TRUE, BYTE, op2(E, R), 0 },
752 /*1b*/ { "sbb", TRUE, LONG, op2(E, R), 0 },
753 /*1c*/ { "sbb", FALSE, BYTE, op2(Is, A), 0 },
754 /*1d*/ { "sbb", FALSE, LONG, op2(Is, A), 0 },
755 /*1e*/ { "push", FALSE, NONE, op1(Si), 0 },
756 /*1f*/ { "pop", FALSE, NONE, op1(Si), 0 },
758 /*20*/ { "and", TRUE, BYTE, op2(R, E), 0 },
759 /*21*/ { "and", TRUE, LONG, op2(R, E), 0 },
760 /*22*/ { "and", TRUE, BYTE, op2(E, R), 0 },
761 /*23*/ { "and", TRUE, LONG, op2(E, R), 0 },
762 /*24*/ { "and", FALSE, BYTE, op2(I, A), 0 },
763 /*25*/ { "and", FALSE, LONG, op2(I, A), 0 },
764 /*26*/ { "", FALSE, NONE, 0, 0 },
765 /*27*/ { "aaa", FALSE, NONE, 0, 0 },
767 /*28*/ { "sub", TRUE, BYTE, op2(R, E), 0 },
768 /*29*/ { "sub", TRUE, LONG, op2(R, E), 0 },
769 /*2a*/ { "sub", TRUE, BYTE, op2(E, R), 0 },
770 /*2b*/ { "sub", TRUE, LONG, op2(E, R), 0 },
771 /*2c*/ { "sub", FALSE, BYTE, op2(Is, A), 0 },
772 /*2d*/ { "sub", FALSE, LONG, op2(Is, A), 0 },
773 /*2e*/ { "", FALSE, NONE, 0, 0 },
774 /*2f*/ { "das", FALSE, NONE, 0, 0 },
776 /*30*/ { "xor", TRUE, BYTE, op2(R, E), 0 },
777 /*31*/ { "xor", TRUE, LONG, op2(R, E), 0 },
778 /*32*/ { "xor", TRUE, BYTE, op2(E, R), 0 },
779 /*33*/ { "xor", TRUE, LONG, op2(E, R), 0 },
780 /*34*/ { "xor", FALSE, BYTE, op2(I, A), 0 },
781 /*35*/ { "xor", FALSE, LONG, op2(I, A), 0 },
782 /*36*/ { "", FALSE, NONE, 0, 0 },
783 /*37*/ { "daa", FALSE, NONE, 0, 0 },
785 /*38*/ { "cmp", TRUE, BYTE, op2(R, E), 0 },
786 /*39*/ { "cmp", TRUE, LONG, op2(R, E), 0 },
787 /*3a*/ { "cmp", TRUE, BYTE, op2(E, R), 0 },
788 /*3b*/ { "cmp", TRUE, LONG, op2(E, R), 0 },
789 /*3c*/ { "cmp", FALSE, BYTE, op2(Is, A), 0 },
790 /*3d*/ { "cmp", FALSE, LONG, op2(Is, A), 0 },
791 /*3e*/ { "", FALSE, NONE, 0, 0 },
792 /*3f*/ { "aas", FALSE, NONE, 0, 0 },
794 /*40*/ { "inc", FALSE, LONG, op1(Ri), 0 },
795 /*41*/ { "inc", FALSE, LONG, op1(Ri), 0 },
796 /*42*/ { "inc", FALSE, LONG, op1(Ri), 0 },
797 /*43*/ { "inc", FALSE, LONG, op1(Ri), 0 },
798 /*44*/ { "inc", FALSE, LONG, op1(Ri), 0 },
799 /*45*/ { "inc", FALSE, LONG, op1(Ri), 0 },
800 /*46*/ { "inc", FALSE, LONG, op1(Ri), 0 },
801 /*47*/ { "inc", FALSE, LONG, op1(Ri), 0 },
803 /*48*/ { "dec", FALSE, LONG, op1(Ri), 0 },
804 /*49*/ { "dec", FALSE, LONG, op1(Ri), 0 },
805 /*4a*/ { "dec", FALSE, LONG, op1(Ri), 0 },
806 /*4b*/ { "dec", FALSE, LONG, op1(Ri), 0 },
807 /*4c*/ { "dec", FALSE, LONG, op1(Ri), 0 },
808 /*4d*/ { "dec", FALSE, LONG, op1(Ri), 0 },
809 /*4e*/ { "dec", FALSE, LONG, op1(Ri), 0 },
810 /*4f*/ { "dec", FALSE, LONG, op1(Ri), 0 },
812 /*50*/ { "push", FALSE, LONG, op1(Ri), 0 },
813 /*51*/ { "push", FALSE, LONG, op1(Ri), 0 },
814 /*52*/ { "push", FALSE, LONG, op1(Ri), 0 },
815 /*53*/ { "push", FALSE, LONG, op1(Ri), 0 },
816 /*54*/ { "push", FALSE, LONG, op1(Ri), 0 },
817 /*55*/ { "push", FALSE, LONG, op1(Ri), 0 },
818 /*56*/ { "push", FALSE, LONG, op1(Ri), 0 },
819 /*57*/ { "push", FALSE, LONG, op1(Ri), 0 },
821 /*58*/ { "pop", FALSE, LONG, op1(Ri), 0 },
822 /*59*/ { "pop", FALSE, LONG, op1(Ri), 0 },
823 /*5a*/ { "pop", FALSE, LONG, op1(Ri), 0 },
824 /*5b*/ { "pop", FALSE, LONG, op1(Ri), 0 },
825 /*5c*/ { "pop", FALSE, LONG, op1(Ri), 0 },
826 /*5d*/ { "pop", FALSE, LONG, op1(Ri), 0 },
827 /*5e*/ { "pop", FALSE, LONG, op1(Ri), 0 },
828 /*5f*/ { "pop", FALSE, LONG, op1(Ri), 0 },
830 /*60*/ { "pusha", FALSE, LONG, 0, 0 },
831 /*61*/ { "popa", FALSE, LONG, 0, 0 },
832 /*62*/ { "bound", TRUE, LONG, op2(E, R), 0 },
833 /*63*/ { "arpl", TRUE, NONE, op2(Ew,Rw), 0 },
835 /*64*/ { "", FALSE, NONE, 0, 0 },
836 /*65*/ { "", FALSE, NONE, 0, 0 },
837 /*66*/ { "", FALSE, NONE, 0, 0 },
838 /*67*/ { "", FALSE, NONE, 0, 0 },
840 /*68*/ { "push", FALSE, LONG, op1(I), 0 },
841 /*69*/ { "imul", TRUE, LONG, op3(I,E,R), 0 },
842 /*6a*/ { "push", FALSE, LONG, op1(Ib), 0 },
843 /*6b*/ { "imul", TRUE, LONG, op3(Ibs,E,R),0 },
844 /*6c*/ { "ins", FALSE, BYTE, op2(DX, DI), 0 },
845 /*6d*/ { "ins", FALSE, LONG, op2(DX, DI), 0 },
846 /*6e*/ { "outs", FALSE, BYTE, op2(SI, DX), 0 },
847 /*6f*/ { "outs", FALSE, LONG, op2(SI, DX), 0 },
849 /*70*/ { "jo", FALSE, NONE, op1(Db), 0 },
850 /*71*/ { "jno", FALSE, NONE, op1(Db), 0 },
851 /*72*/ { "jb", FALSE, NONE, op1(Db), 0 },
852 /*73*/ { "jnb", FALSE, NONE, op1(Db), 0 },
853 /*74*/ { "jz", FALSE, NONE, op1(Db), 0 },
854 /*75*/ { "jnz", FALSE, NONE, op1(Db), 0 },
855 /*76*/ { "jbe", FALSE, NONE, op1(Db), 0 },
856 /*77*/ { "jnbe", FALSE, NONE, op1(Db), 0 },
858 /*78*/ { "js", FALSE, NONE, op1(Db), 0 },
859 /*79*/ { "jns", FALSE, NONE, op1(Db), 0 },
860 /*7a*/ { "jp", FALSE, NONE, op1(Db), 0 },
861 /*7b*/ { "jnp", FALSE, NONE, op1(Db), 0 },
862 /*7c*/ { "jl", FALSE, NONE, op1(Db), 0 },
863 /*7d*/ { "jnl", FALSE, NONE, op1(Db), 0 },
864 /*7e*/ { "jle", FALSE, NONE, op1(Db), 0 },
865 /*7f*/ { "jnle", FALSE, NONE, op1(Db), 0 },
867 /*80*/ { "", TRUE, BYTE, op2(I, E), (const char *)db_Grp1 },
868 /*81*/ { "", TRUE, LONG, op2(I, E), (const char *)db_Grp1 },
869 /*82*/ { "", TRUE, BYTE, op2(Is,E), (const char *)db_Grp1 },
870 /*83*/ { "", TRUE, LONG, op2(Ibs,E), (const char *)db_Grp1 },
871 /*84*/ { "test", TRUE, BYTE, op2(R, E), 0 },
872 /*85*/ { "test", TRUE, LONG, op2(R, E), 0 },
873 /*86*/ { "xchg", TRUE, BYTE, op2(R, E), 0 },
874 /*87*/ { "xchg", TRUE, LONG, op2(R, E), 0 },
876 /*88*/ { "mov", TRUE, BYTE, op2(R, E), 0 },
877 /*89*/ { "mov", TRUE, LONG, op2(R, E), 0 },
878 /*8a*/ { "mov", TRUE, BYTE, op2(E, R), 0 },
879 /*8b*/ { "mov", TRUE, LONG, op2(E, R), 0 },
880 /*8c*/ { "mov", TRUE, NONE, op2(S, Ew), 0 },
881 /*8d*/ { "lea", TRUE, LONG, op2(E, R), 0 },
882 /*8e*/ { "mov", TRUE, NONE, op2(Ew, S), 0 },
883 /*8f*/ { "pop", TRUE, LONG, op1(E), 0 },
885 /*90*/ { "nop", FALSE, NONE, 0, 0 },
886 /*91*/ { "xchg", FALSE, LONG, op2(A, Ri), 0 },
887 /*92*/ { "xchg", FALSE, LONG, op2(A, Ri), 0 },
888 /*93*/ { "xchg", FALSE, LONG, op2(A, Ri), 0 },
889 /*94*/ { "xchg", FALSE, LONG, op2(A, Ri), 0 },
890 /*95*/ { "xchg", FALSE, LONG, op2(A, Ri), 0 },
891 /*96*/ { "xchg", FALSE, LONG, op2(A, Ri), 0 },
892 /*97*/ { "xchg", FALSE, LONG, op2(A, Ri), 0 },
894 /*98*/ { "cbw", FALSE, SDEP, 0, "cwde" }, /* cbw/cwde */
895 /*99*/ { "cwd", FALSE, SDEP, 0, "cdq" }, /* cwd/cdq */
896 /*9a*/ { "lcall", FALSE, NONE, op1(OS), 0 },
897 /*9b*/ { "wait", FALSE, NONE, 0, 0 },
898 /*9c*/ { "pushf", FALSE, LONG, 0, 0 },
899 /*9d*/ { "popf", FALSE, LONG, 0, 0 },
900 /*9e*/ { "sahf", FALSE, NONE, 0, 0 },
901 /*9f*/ { "lahf", FALSE, NONE, 0, 0 },
903 /*a0*/ { "mov", FALSE, BYTE, op2(O, A), 0 },
904 /*a1*/ { "mov", FALSE, LONG, op2(O, A), 0 },
905 /*a2*/ { "mov", FALSE, BYTE, op2(A, O), 0 },
906 /*a3*/ { "mov", FALSE, LONG, op2(A, O), 0 },
907 /*a4*/ { "movs", FALSE, BYTE, op2(SI,DI), 0 },
908 /*a5*/ { "movs", FALSE, LONG, op2(SI,DI), 0 },
909 /*a6*/ { "cmps", FALSE, BYTE, op2(SI,DI), 0 },
910 /*a7*/ { "cmps", FALSE, LONG, op2(SI,DI), 0 },
912 /*a8*/ { "test", FALSE, BYTE, op2(I, A), 0 },
913 /*a9*/ { "test", FALSE, LONG, op2(I, A), 0 },
914 /*aa*/ { "stos", FALSE, BYTE, op1(DI), 0 },
915 /*ab*/ { "stos", FALSE, LONG, op1(DI), 0 },
916 /*ac*/ { "lods", FALSE, BYTE, op1(SI), 0 },
917 /*ad*/ { "lods", FALSE, LONG, op1(SI), 0 },
918 /*ae*/ { "scas", FALSE, BYTE, op1(DI), 0 },
919 /*af*/ { "scas", FALSE, LONG, op1(DI), 0 },
921 /*b0*/ { "mov", FALSE, BYTE, op2(I, Ri), 0 },
922 /*b1*/ { "mov", FALSE, BYTE, op2(I, Ri), 0 },
923 /*b2*/ { "mov", FALSE, BYTE, op2(I, Ri), 0 },
924 /*b3*/ { "mov", FALSE, BYTE, op2(I, Ri), 0 },
925 /*b4*/ { "mov", FALSE, BYTE, op2(I, Ri), 0 },
926 /*b5*/ { "mov", FALSE, BYTE, op2(I, Ri), 0 },
927 /*b6*/ { "mov", FALSE, BYTE, op2(I, Ri), 0 },
928 /*b7*/ { "mov", FALSE, BYTE, op2(I, Ri), 0 },
930 /*b8*/ { "mov", FALSE, LONG, op2(I, Ri), 0 },
931 /*b9*/ { "mov", FALSE, LONG, op2(I, Ri), 0 },
932 /*ba*/ { "mov", FALSE, LONG, op2(I, Ri), 0 },
933 /*bb*/ { "mov", FALSE, LONG, op2(I, Ri), 0 },
934 /*bc*/ { "mov", FALSE, LONG, op2(I, Ri), 0 },
935 /*bd*/ { "mov", FALSE, LONG, op2(I, Ri), 0 },
936 /*be*/ { "mov", FALSE, LONG, op2(I, Ri), 0 },
937 /*bf*/ { "mov", FALSE, LONG, op2(I, Ri), 0 },
939 /*c0*/ { "", TRUE, BYTE, op2(Ib, E), (const char *)db_Grp2 },
940 /*c1*/ { "", TRUE, LONG, op2(Ib, E), (const char *)db_Grp2 },
941 /*c2*/ { "ret", FALSE, NONE, op1(Iw), 0 },
942 /*c3*/ { "ret", FALSE, NONE, 0, 0 },
943 /*c4*/ { "les", TRUE, LONG, op2(E, R), 0 },
944 /*c5*/ { "lds", TRUE, LONG, op2(E, R), 0 },
945 /*c6*/ { "mov", TRUE, BYTE, op2(I, E), 0 },
946 /*c7*/ { "mov", TRUE, LONG, op2(I, E), 0 },
948 /*c8*/ { "enter", FALSE, NONE, op2(Iw, Ib), 0 },
949 /*c9*/ { "leave", FALSE, NONE, 0, 0 },
950 /*ca*/ { "lret", FALSE, NONE, op1(Iw), 0 },
951 /*cb*/ { "lret", FALSE, NONE, 0, 0 },
952 /*cc*/ { "int", FALSE, NONE, op1(o3), 0 },
953 /*cd*/ { "int", FALSE, NONE, op1(Ib), 0 },
954 /*ce*/ { "into", FALSE, NONE, 0, 0 },
955 /*cf*/ { "iret", FALSE, NONE, 0, 0 },
957 /*d0*/ { "", TRUE, BYTE, op2(o1, E), (const char *)db_Grp2 },
958 /*d1*/ { "", TRUE, LONG, op2(o1, E), (const char *)db_Grp2 },
959 /*d2*/ { "", TRUE, BYTE, op2(CL, E), (const char *)db_Grp2 },
960 /*d3*/ { "", TRUE, LONG, op2(CL, E), (const char *)db_Grp2 },
961 /*d4*/ { "aam", TRUE, NONE, 0, 0 },
962 /*d5*/ { "aad", TRUE, NONE, 0, 0 },
963 /*d6*/ { "", FALSE, NONE, 0, 0 },
964 /*d7*/ { "xlat", FALSE, BYTE, op1(BX), 0 },
966 /*d8*/ { "", TRUE, NONE, 0, (const char *)db_Esc8 },
967 /*d9*/ { "", TRUE, NONE, 0, (const char *)db_Esc9 },
968 /*da*/ { "", TRUE, NONE, 0, (const char *)db_Esca },
969 /*db*/ { "", TRUE, NONE, 0, (const char *)db_Escb },
970 /*dc*/ { "", TRUE, NONE, 0, (const char *)db_Escc },
971 /*dd*/ { "", TRUE, NONE, 0, (const char *)db_Escd },
972 /*de*/ { "", TRUE, NONE, 0, (const char *)db_Esce },
973 /*df*/ { "", TRUE, NONE, 0, (const char *)db_Escf },
975 /*e0*/ { "loopne",FALSE, NONE, op1(Db), 0 },
976 /*e1*/ { "loope", FALSE, NONE, op1(Db), 0 },
977 /*e2*/ { "loop", FALSE, NONE, op1(Db), 0 },
978 /*e3*/ { "jcxz", FALSE, SDEP, op1(Db), "jecxz" },
979 /*e4*/ { "in", FALSE, BYTE, op2(Ib, A), 0 },
980 /*e5*/ { "in", FALSE, LONG, op2(Ib, A) , 0 },
981 /*e6*/ { "out", FALSE, BYTE, op2(A, Ib), 0 },
982 /*e7*/ { "out", FALSE, LONG, op2(A, Ib) , 0 },
984 /*e8*/ { "call", FALSE, NONE, op1(Dl), 0 },
985 /*e9*/ { "jmp", FALSE, NONE, op1(Dl), 0 },
986 /*ea*/ { "ljmp", FALSE, NONE, op1(OS), 0 },
987 /*eb*/ { "jmp", FALSE, NONE, op1(Db), 0 },
988 /*ec*/ { "in", FALSE, BYTE, op2(DX, A), 0 },
989 /*ed*/ { "in", FALSE, LONG, op2(DX, A) , 0 },
990 /*ee*/ { "out", FALSE, BYTE, op2(A, DX), 0 },
991 /*ef*/ { "out", FALSE, LONG, op2(A, DX) , 0 },
993 /*f0*/ { "", FALSE, NONE, 0, 0 },
994 /*f1*/ { "", FALSE, NONE, 0, 0 },
995 /*f2*/ { "", FALSE, NONE, 0, 0 },
996 /*f3*/ { "", FALSE, NONE, 0, 0 },
997 /*f4*/ { "hlt", FALSE, NONE, 0, 0 },
998 /*f5*/ { "cmc", FALSE, NONE, 0, 0 },
999 /*f6*/ { "", TRUE, BYTE, 0, (const char *)db_Grp3 },
1000 /*f7*/ { "", TRUE, LONG, 0, (const char *)db_Grp3 },
1002 /*f8*/ { "clc", FALSE, NONE, 0, 0 },
1003 /*f9*/ { "stc", FALSE, NONE, 0, 0 },
1004 /*fa*/ { "cli", FALSE, NONE, 0, 0 },
1005 /*fb*/ { "sti", FALSE, NONE, 0, 0 },
1006 /*fc*/ { "cld", FALSE, NONE, 0, 0 },
1007 /*fd*/ { "std", FALSE, NONE, 0, 0 },
1008 /*fe*/ { "", TRUE, NONE, 0, (const char *)db_Grp4 },
1009 /*ff*/ { "", TRUE, NONE, 0, (const char *)db_Grp5 },
1012 static const struct inst db_bad_inst =
1013 { "???", FALSE, NONE, 0, 0 }
1016 #define f_mod(byte) ((byte)>>6)
1017 #define f_reg(byte) (((byte)>>3)&0x7)
1018 #define f_rm(byte) ((byte)&0x7)
1020 #define sib_ss(byte) ((byte)>>6)
1021 #define sib_index(byte) (((byte)>>3)&0x7)
1022 #define sib_base(byte) ((byte)&0x7)
1025 int is_reg; /* if reg, reg number is in 'disp' */
1032 static const char * const db_index_reg_16[8] = {
1043 static const char * const db_reg[3][8] = {
1044 { "%al", "%cl", "%dl", "%bl", "%ah", "%ch", "%dh", "%bh" },
1045 { "%ax", "%cx", "%dx", "%bx", "%sp", "%bp", "%si", "%di" },
1046 { "%eax", "%ecx", "%edx", "%ebx", "%esp", "%ebp", "%esi", "%edi" }
1049 static const char * const db_seg_reg[8] = {
1050 "%es", "%cs", "%ss", "%ds", "%fs", "%gs", "", ""
1054 * lengths for size attributes
1056 static const int db_lengths[] = {
1066 static unsigned int db_get_task_value( const ADDRESS64* addr,
1067 int size, int is_signed )
1069 unsigned int result = 0;
1072 if (size != 1 && size != 2 && size != 4)
1074 dbg_printf("Illegal size specified\n");
1078 dbg_read_memory(memory_to_linear_addr(addr), buffer, size);
1083 if (is_signed) result = (unsigned int) *(int *)buffer;
1084 else result = *(unsigned int *)buffer;
1087 if (is_signed) result = (unsigned int) *(short int *)buffer;
1088 else result = *(unsigned short int *)buffer;
1091 if (is_signed) result = (unsigned int) *(char *)buffer;
1092 else result = *(unsigned char *)buffer;
1099 #define get_value_inc(result, addr, size, is_signed) \
1100 result = db_get_task_value((addr), (size), (is_signed)); \
1101 if (!db_disasm_16) (addr)->Offset += (size); \
1102 else (addr)->Offset = ((addr)->Offset + (size)) & 0xffff;
1105 * Read address at location and return updated location.
1107 static void db_read_address( ADDRESS64* addr, int short_addr, int regmodrm,
1108 struct i_addr *addrp )
1110 int mod, rm, sib, index, disp;
1112 mod = f_mod(regmodrm);
1113 rm = f_rm(regmodrm);
1116 addrp->is_reg = TRUE;
1120 addrp->is_reg = FALSE;
1129 get_value_inc(disp, addr, 2, TRUE);
1135 addrp->base = db_index_reg_16[rm];
1139 get_value_inc(disp, addr, 1, TRUE);
1141 addrp->base = db_index_reg_16[rm];
1144 get_value_inc(disp, addr, 2, TRUE);
1146 addrp->base = db_index_reg_16[rm];
1151 if (mod != 3 && rm == 4) {
1152 get_value_inc(sib, addr, 1, FALSE);
1154 index = sib_index(sib);
1156 addrp->index = db_reg[LONG][index];
1157 addrp->ss = sib_ss(sib);
1163 get_value_inc(addrp->disp, addr, 4, FALSE);
1168 addrp->base = db_reg[LONG][rm];
1173 get_value_inc(disp, addr, 1, TRUE);
1175 addrp->base = db_reg[LONG][rm];
1179 get_value_inc(disp, addr, 4, FALSE);
1181 addrp->base = db_reg[LONG][rm];
1187 static void db_task_printsym(unsigned int addr, int size)
1190 a.Mode = AddrModeFlat;
1193 print_address(&a, TRUE);
1196 static void db_print_address(const char *seg, int size, struct i_addr *addrp, int byref)
1198 if (addrp->is_reg) {
1199 dbg_printf("%s", db_reg[size][addrp->disp]);
1204 dbg_printf("%s:", seg);
1207 if (addrp->base != 0 || addrp->index != 0) {
1208 dbg_printf("0x%x(", addrp->disp);
1210 dbg_printf("%s", addrp->base);
1212 dbg_printf(",%s,%d", addrp->index, 1<<addrp->ss);
1217 /* try to get destination of indirect call
1218 does not work for segmented addresses */
1219 if (!seg && byref) {
1223 dbg_printf("0x%x -> ", addrp->disp);
1224 if (!dbg_read_memory((void*)addrp->disp, &a1, sizeof(a1))) {
1225 dbg_printf("(invalid source)");
1226 } else if (!dbg_read_memory(a1, &a2, sizeof(a2))) {
1227 dbg_printf("(invalid destination)");
1229 db_task_printsym((unsigned long)a1, 0);
1233 db_task_printsym(addrp->disp, size);
1238 * Disassemble floating-point ("escape") instruction
1239 * and return updated location.
1241 static void db_disasm_esc( ADDRESS64* addr, int inst, int short_addr,
1242 int size, const char *seg )
1245 const struct finst *fp;
1247 struct i_addr address;
1250 get_value_inc(regmodrm, addr, 1, FALSE);
1256 fp = &db_Esc_inst[inst - 0xd8][f_reg(regmodrm)];
1257 mod = f_mod(regmodrm);
1261 * Normal address modes.
1263 db_read_address( addr, short_addr, regmodrm, &address);
1264 dbg_printf("%s", fp->f_name);
1265 switch(fp->f_size) {
1266 case SNGL: p = "s"; break;
1267 case DBLR: p = "l"; break;
1268 case EXTR: p = "t"; break;
1269 case WORD: p = "s"; break;
1270 case LONG: p = "l"; break;
1271 case QUAD: p = "q"; break;
1272 default: p = ""; break;
1274 dbg_printf("%s\t", p);
1275 db_print_address(seg, BYTE, &address, 0);
1279 * 'reg-reg' - special formats
1281 switch (fp->f_rrmode) {
1283 name = (fp->f_rrname) ? fp->f_rrname : fp->f_name;
1284 dbg_printf("%s\t%%st,%%st(%d)",name,f_rm(regmodrm));
1287 name = (fp->f_rrname) ? fp->f_rrname : fp->f_name;
1288 dbg_printf("%s\t%%st(%d),%%st",name, f_rm(regmodrm));
1291 name = (fp->f_rrname) ? fp->f_rrname : fp->f_name;
1292 dbg_printf("%s\t%%st(%d)",name, f_rm(regmodrm));
1295 dbg_printf("%s", ((char * const*)fp->f_rrname)[f_rm(regmodrm)]);
1298 dbg_printf("%s\t%%ax", ((char * const*)fp->f_rrname)[f_rm(regmodrm)]);
1301 dbg_printf("<bad instruction>");
1308 /***********************************************************************
1311 * Disassemble instruction at 'addr'. addr is changed to point to the
1312 * start of the next instruction.
1314 void be_i386_disasm_one_insn(ADDRESS64 *addr, int display)
1320 const struct inst *ip;
1330 struct i_addr address;
1333 * Set this so we get can suppress the printout if we need to.
1335 db_display = display;
1339 case AddrMode1616: db_disasm_16 = 1; break;
1340 default: db_disasm_16 = 0; break;
1343 get_value_inc( inst, addr, 1, FALSE );
1361 case 0x66: /* data16 */
1368 short_addr = !short_addr;
1390 dbg_printf("lock ");
1394 dbg_printf("repne ");
1398 dbg_printf("repe "); /* XXX repe VS rep */
1405 get_value_inc(inst, addr, 1, FALSE);
1409 if (inst >= 0xd8 && inst <= 0xdf)
1411 db_disasm_esc( addr, inst, short_addr, size, seg);
1416 get_value_inc(inst, addr, 1, FALSE);
1417 ip = db_inst_0f[inst>>4];
1426 ip = &db_inst_table[inst];
1428 if (ip->i_has_modrm) {
1429 get_value_inc(regmodrm, addr, 1, FALSE);
1430 db_read_address( addr, short_addr, regmodrm, &address);
1433 i_name = ip->i_name;
1434 i_size = ip->i_size;
1435 i_mode = ip->i_mode;
1437 if (ip->i_extra == (const char *)db_Grp1 ||
1438 ip->i_extra == (const char *)db_Grp2 ||
1439 ip->i_extra == (const char *)db_Grp6 ||
1440 ip->i_extra == (const char *)db_Grp7 ||
1441 ip->i_extra == (const char *)db_Grp8 ||
1442 ip->i_extra == (const char *)db_Grp10 ||
1443 ip->i_extra == (const char *)db_Grp11 ||
1444 ip->i_extra == (const char *)db_Grp12) {
1445 i_name = ((const char * const*)ip->i_extra)[f_reg(regmodrm)];
1447 else if (ip->i_extra == (const char *)db_Grp3) {
1448 ip = (const struct inst *)ip->i_extra;
1449 ip = &ip[f_reg(regmodrm)];
1450 i_name = ip->i_name;
1451 i_mode = ip->i_mode;
1453 else if (ip->i_extra == (const char *)db_Grp4 ||
1454 ip->i_extra == (const char *)db_Grp5) {
1455 ip = (const struct inst *)ip->i_extra;
1456 ip = &ip[f_reg(regmodrm)];
1457 i_name = ip->i_name;
1458 i_mode = ip->i_mode;
1459 i_size = ip->i_size;
1462 if (i_size == SDEP) {
1466 dbg_printf("%s", i_name);
1468 dbg_printf("%s", ip->i_extra);
1474 dbg_printf("%s", i_name);
1476 if (i_size != NONE) {
1477 if (i_size == BYTE) {
1484 else if (i_size == WORD) {
1491 else if (size == WORD)
1513 i_mode >>= 8, first = FALSE)
1515 if (!first && db_display)
1518 switch (i_mode & 0xFF) {
1523 db_print_address(seg, size, &address, 0);
1531 db_print_address(seg, size, &address, 1);
1538 db_print_address(seg, WORD, &address, 0);
1545 db_print_address(seg, BYTE, &address, 0);
1552 dbg_printf("%s", db_reg[size][f_reg(regmodrm)]);
1558 dbg_printf("%%mm%d", f_reg(regmodrm));
1564 dbg_printf("%%mm%d", f_rm(regmodrm));
1570 dbg_printf("%%xmm%d", f_reg(regmodrm));
1576 dbg_printf("%%xmm%d", f_rm(regmodrm));
1584 dbg_printf("%s", db_reg[WORD][f_reg(regmodrm)]);
1591 dbg_printf("%s", db_reg[size][f_rm(inst)]);
1598 dbg_printf("%s", db_seg_reg[f_reg(regmodrm)]);
1605 dbg_printf("%s", db_seg_reg[f_reg(inst)]);
1612 dbg_printf("%s", db_reg[size][0]); /* acc */
1620 dbg_printf("%s:", seg);
1621 dbg_printf("(%s)", short_addr ? "%bx" : "%ebx");
1643 dbg_printf("%s:", seg);
1644 dbg_printf("(%s)", short_addr ? "%si" : "%esi");
1651 dbg_printf("%%es:(%s)", short_addr ? "%di" : "%edi");
1658 dbg_printf("%%cr%d", f_reg(regmodrm));
1665 dbg_printf("%%dr%d", f_reg(regmodrm));
1672 dbg_printf("%%tr%d", f_reg(regmodrm));
1677 len = db_lengths[size];
1678 get_value_inc(imm, addr, len, FALSE);/* unsigned */
1681 dbg_printf("$0x%x", imm);
1686 len = db_lengths[size];
1687 get_value_inc(imm, addr, len, TRUE); /* signed */
1690 dbg_printf("$%d", imm);
1695 get_value_inc(imm, addr, 1, FALSE); /* unsigned */
1698 dbg_printf("$0x%x", imm);
1703 get_value_inc(imm, addr, 1, TRUE); /* signed */
1706 dbg_printf("$%d", imm);
1711 get_value_inc(imm, addr, 2, FALSE); /* unsigned */
1714 dbg_printf("$0x%x", imm);
1719 get_value_inc(imm, addr, 4, FALSE);
1722 dbg_printf("$0x%x", imm);
1728 get_value_inc(displ, addr, 2, TRUE);
1731 get_value_inc(displ, addr, 4, TRUE);
1739 dbg_printf("%s:0x%x",seg, displ);
1741 db_task_printsym(displ, short_addr ? WORD : LONG);
1745 get_value_inc(displ, addr, 1, TRUE);
1752 /* offset only affects low 16 bits */
1753 displ = (addr->Offset & 0xffff0000)
1754 | ((addr->Offset + displ) & 0xffff);
1756 else displ += addr->Offset;
1757 db_task_printsym(displ, size);
1762 get_value_inc(displ, addr, 2, TRUE);
1763 /* Offset only affects low 16 bits */
1764 displ = (addr->Offset & 0xffff0000)
1765 | ((addr->Offset + displ) & 0xffff);
1768 get_value_inc(displ, addr, 4, TRUE);
1769 displ += addr->Offset;
1775 db_task_printsym( displ, size );
1795 get_value_inc( address.Offset, addr, /* offset */
1796 short_addr ? 2 : 4, FALSE );
1797 get_value_inc( address.Segment, addr, /* segment */
1799 be_cpu->build_addr(dbg_curr_thread->handle, &dbg_context,
1800 &address, address.Segment, address.Offset);
1803 print_address( &address, TRUE );
1811 #endif /* __i386__ */