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.
27 #include <sys/cdefs.h>
29 * Instruction disassembler.
31 #include <sys/param.h>
35 #include <ddb/db_access.h>
36 #include <ddb/db_sym.h>
54 #define E 1 /* general effective address */
55 #define Eind 2 /* indirect address (jump, call) */
56 #define Ew 3 /* address, word size */
57 #define Eb 4 /* address, byte size */
58 #define R 5 /* register, in 'reg' field */
59 #define Rw 6 /* word register, in 'reg' field */
60 #define Ri 7 /* register in instruction */
61 #define S 8 /* segment reg, in 'reg' field */
62 #define Si 9 /* segment reg, in instruction */
63 #define A 10 /* accumulator */
64 #define BX 11 /* (bx) */
65 #define CL 12 /* cl, for shifts */
66 #define DX 13 /* dx, for IO */
67 #define SI 14 /* si */
68 #define DI 15 /* di */
69 #define CR 16 /* control register */
70 #define DR 17 /* debug register */
71 #define TR 18 /* test register */
72 #define I 19 /* immediate, unsigned */
73 #define Is 20 /* immediate, signed */
74 #define Ib 21 /* byte immediate, unsigned */
75 #define Ibs 22 /* byte immediate, signed */
76 #define Iw 23 /* word immediate, unsigned */
77 #define O 25 /* direct address */
78 #define Db 26 /* byte displacement from EIP */
79 #define Dl 27 /* long displacement from EIP */
80 #define o1 28 /* constant 1 */
81 #define o3 29 /* constant 3 */
82 #define OS 30 /* immediate offset/segment */
83 #define ST 31 /* FP stack top */
84 #define STI 32 /* FP stack */
85 #define X 33 /* extended FP op */
86 #define XA 34 /* for 'fstcw %ax' */
87 #define El 35 /* address, long size */
88 #define Ril 36 /* long register in instruction */
89 #define Iba 37 /* byte immediate, don't print if 0xa */
92 const char * i_name; /* name */
93 bool i_has_modrm; /* has regmodrm byte */
94 short i_size; /* operand size */
95 int i_mode; /* addressing modes */
96 const void * i_extra; /* pointer to extra opcode table */
100 #define op2(x,y) ((x)|((y)<<8))
101 #define op3(x,y,z) ((x)|((y)<<8)|((z)<<16))
104 const char * f_name; /* name for memory instruction */
105 int f_size; /* size for memory instruction */
106 int f_rrmode; /* mode for rr instruction */
107 const void * f_rrname; /* name for rr instruction
108 (or pointer to table) */
111 static const char * const db_Grp6[] = {
122 static const char * const db_Grp7[] = {
133 static const char * const db_Grp8[] = {
144 static const char * const db_Grp9[] = {
155 static const char * const db_Grp15[] = {
166 static const char * const db_Grp15b[] = {
177 static const struct inst db_inst_0f0x[] = {
178 /*00*/ { "", true, NONE, op1(Ew), db_Grp6 },
179 /*01*/ { "", true, NONE, op1(Ew), db_Grp7 },
180 /*02*/ { "lar", true, LONG, op2(E,R), 0 },
181 /*03*/ { "lsl", true, LONG, op2(E,R), 0 },
182 /*04*/ { "", false, NONE, 0, 0 },
183 /*05*/ { "syscall",false,NONE, 0, 0 },
184 /*06*/ { "clts", false, NONE, 0, 0 },
185 /*07*/ { "sysret",false, NONE, 0, 0 },
187 /*08*/ { "invd", false, NONE, 0, 0 },
188 /*09*/ { "wbinvd",false, NONE, 0, 0 },
189 /*0a*/ { "", false, NONE, 0, 0 },
190 /*0b*/ { "", false, NONE, 0, 0 },
191 /*0c*/ { "", false, NONE, 0, 0 },
192 /*0d*/ { "", false, NONE, 0, 0 },
193 /*0e*/ { "", false, NONE, 0, 0 },
194 /*0f*/ { "", false, NONE, 0, 0 },
197 static const struct inst db_inst_0f1x[] = {
198 /*10*/ { "", false, NONE, 0, 0 },
199 /*11*/ { "", false, NONE, 0, 0 },
200 /*12*/ { "", false, NONE, 0, 0 },
201 /*13*/ { "", false, NONE, 0, 0 },
202 /*14*/ { "", false, NONE, 0, 0 },
203 /*15*/ { "", false, NONE, 0, 0 },
204 /*16*/ { "", false, NONE, 0, 0 },
205 /*17*/ { "", false, NONE, 0, 0 },
207 /*18*/ { "", false, NONE, 0, 0 },
208 /*19*/ { "", false, NONE, 0, 0 },
209 /*1a*/ { "", false, NONE, 0, 0 },
210 /*1b*/ { "", false, NONE, 0, 0 },
211 /*1c*/ { "", false, NONE, 0, 0 },
212 /*1d*/ { "", false, NONE, 0, 0 },
213 /*1e*/ { "", false, NONE, 0, 0 },
214 /*1f*/ { "nopl", true, SDEP, 0, "nopw" },
217 static const struct inst db_inst_0f2x[] = {
218 /*20*/ { "mov", true, LONG, op2(CR,El), 0 },
219 /*21*/ { "mov", true, LONG, op2(DR,El), 0 },
220 /*22*/ { "mov", true, LONG, op2(El,CR), 0 },
221 /*23*/ { "mov", true, LONG, op2(El,DR), 0 },
222 /*24*/ { "mov", true, LONG, op2(TR,El), 0 },
223 /*25*/ { "", false, NONE, 0, 0 },
224 /*26*/ { "mov", true, LONG, op2(El,TR), 0 },
225 /*27*/ { "", false, NONE, 0, 0 },
227 /*28*/ { "", false, NONE, 0, 0 },
228 /*29*/ { "", false, NONE, 0, 0 },
229 /*2a*/ { "", false, NONE, 0, 0 },
230 /*2b*/ { "", false, NONE, 0, 0 },
231 /*2c*/ { "", false, NONE, 0, 0 },
232 /*2d*/ { "", false, NONE, 0, 0 },
233 /*2e*/ { "", false, NONE, 0, 0 },
234 /*2f*/ { "", false, NONE, 0, 0 },
237 static const struct inst db_inst_0f3x[] = {
238 /*30*/ { "wrmsr", false, NONE, 0, 0 },
239 /*31*/ { "rdtsc", false, NONE, 0, 0 },
240 /*32*/ { "rdmsr", false, NONE, 0, 0 },
241 /*33*/ { "rdpmc", false, NONE, 0, 0 },
242 /*34*/ { "sysenter",false,NONE, 0, 0 },
243 /*35*/ { "sysexit",false,NONE, 0, 0 },
244 /*36*/ { "", false, NONE, 0, 0 },
245 /*37*/ { "getsec",false, NONE, 0, 0 },
247 /*38*/ { "", false, NONE, 0, 0 },
248 /*39*/ { "", false, NONE, 0, 0 },
249 /*3a*/ { "", false, NONE, 0, 0 },
250 /*3b*/ { "", false, NONE, 0, 0 },
251 /*3c*/ { "", false, NONE, 0, 0 },
252 /*3d*/ { "", false, NONE, 0, 0 },
253 /*3e*/ { "", false, NONE, 0, 0 },
254 /*3f*/ { "", false, NONE, 0, 0 },
257 static const struct inst db_inst_0f4x[] = {
258 /*40*/ { "cmovo", true, NONE, op2(E, R), 0 },
259 /*41*/ { "cmovno", true, NONE, op2(E, R), 0 },
260 /*42*/ { "cmovb", true, NONE, op2(E, R), 0 },
261 /*43*/ { "cmovnb", true, NONE, op2(E, R), 0 },
262 /*44*/ { "cmovz", true, NONE, op2(E, R), 0 },
263 /*45*/ { "cmovnz", true, NONE, op2(E, R), 0 },
264 /*46*/ { "cmovbe", true, NONE, op2(E, R), 0 },
265 /*47*/ { "cmovnbe",true, NONE, op2(E, R), 0 },
267 /*48*/ { "cmovs", true, NONE, op2(E, R), 0 },
268 /*49*/ { "cmovns", true, NONE, op2(E, R), 0 },
269 /*4a*/ { "cmovp", true, NONE, op2(E, R), 0 },
270 /*4b*/ { "cmovnp", true, NONE, op2(E, R), 0 },
271 /*4c*/ { "cmovl", true, NONE, op2(E, R), 0 },
272 /*4d*/ { "cmovnl", true, NONE, op2(E, R), 0 },
273 /*4e*/ { "cmovle", true, NONE, op2(E, R), 0 },
274 /*4f*/ { "cmovnle",true, NONE, op2(E, R), 0 },
277 static const struct inst db_inst_0f8x[] = {
278 /*80*/ { "jo", false, NONE, op1(Dl), 0 },
279 /*81*/ { "jno", false, NONE, op1(Dl), 0 },
280 /*82*/ { "jb", false, NONE, op1(Dl), 0 },
281 /*83*/ { "jnb", false, NONE, op1(Dl), 0 },
282 /*84*/ { "jz", false, NONE, op1(Dl), 0 },
283 /*85*/ { "jnz", false, NONE, op1(Dl), 0 },
284 /*86*/ { "jbe", false, NONE, op1(Dl), 0 },
285 /*87*/ { "jnbe", false, NONE, op1(Dl), 0 },
287 /*88*/ { "js", false, NONE, op1(Dl), 0 },
288 /*89*/ { "jns", false, NONE, op1(Dl), 0 },
289 /*8a*/ { "jp", false, NONE, op1(Dl), 0 },
290 /*8b*/ { "jnp", false, NONE, op1(Dl), 0 },
291 /*8c*/ { "jl", false, NONE, op1(Dl), 0 },
292 /*8d*/ { "jnl", false, NONE, op1(Dl), 0 },
293 /*8e*/ { "jle", false, NONE, op1(Dl), 0 },
294 /*8f*/ { "jnle", false, NONE, op1(Dl), 0 },
297 static const struct inst db_inst_0f9x[] = {
298 /*90*/ { "seto", true, NONE, op1(Eb), 0 },
299 /*91*/ { "setno", true, NONE, op1(Eb), 0 },
300 /*92*/ { "setb", true, NONE, op1(Eb), 0 },
301 /*93*/ { "setnb", true, NONE, op1(Eb), 0 },
302 /*94*/ { "setz", true, NONE, op1(Eb), 0 },
303 /*95*/ { "setnz", true, NONE, op1(Eb), 0 },
304 /*96*/ { "setbe", true, NONE, op1(Eb), 0 },
305 /*97*/ { "setnbe",true, NONE, op1(Eb), 0 },
307 /*98*/ { "sets", true, NONE, op1(Eb), 0 },
308 /*99*/ { "setns", true, NONE, op1(Eb), 0 },
309 /*9a*/ { "setp", true, NONE, op1(Eb), 0 },
310 /*9b*/ { "setnp", true, NONE, op1(Eb), 0 },
311 /*9c*/ { "setl", true, NONE, op1(Eb), 0 },
312 /*9d*/ { "setnl", true, NONE, op1(Eb), 0 },
313 /*9e*/ { "setle", true, NONE, op1(Eb), 0 },
314 /*9f*/ { "setnle",true, NONE, op1(Eb), 0 },
317 static const struct inst db_inst_0fax[] = {
318 /*a0*/ { "push", false, NONE, op1(Si), 0 },
319 /*a1*/ { "pop", false, NONE, op1(Si), 0 },
320 /*a2*/ { "cpuid", false, NONE, 0, 0 },
321 /*a3*/ { "bt", true, LONG, op2(R,E), 0 },
322 /*a4*/ { "shld", true, LONG, op3(Ib,R,E), 0 },
323 /*a5*/ { "shld", true, LONG, op3(CL,R,E), 0 },
324 /*a6*/ { "", false, NONE, 0, 0 },
325 /*a7*/ { "", false, NONE, 0, 0 },
327 /*a8*/ { "push", false, NONE, op1(Si), 0 },
328 /*a9*/ { "pop", false, NONE, op1(Si), 0 },
329 /*aa*/ { "rsm", false, NONE, 0, 0 },
330 /*ab*/ { "bts", true, LONG, op2(R,E), 0 },
331 /*ac*/ { "shrd", true, LONG, op3(Ib,R,E), 0 },
332 /*ad*/ { "shrd", true, LONG, op3(CL,R,E), 0 },
333 /*ae*/ { "", true, LONG, op1(E), db_Grp15 },
334 /*af*/ { "imul", true, LONG, op2(E,R), 0 },
337 static const struct inst db_inst_0fbx[] = {
338 /*b0*/ { "cmpxchg",true, BYTE, op2(R, E), 0 },
339 /*b0*/ { "cmpxchg",true, LONG, op2(R, E), 0 },
340 /*b2*/ { "lss", true, LONG, op2(E, R), 0 },
341 /*b3*/ { "btr", true, LONG, op2(R, E), 0 },
342 /*b4*/ { "lfs", true, LONG, op2(E, R), 0 },
343 /*b5*/ { "lgs", true, LONG, op2(E, R), 0 },
344 /*b6*/ { "movzb", true, LONG, op2(Eb, R), 0 },
345 /*b7*/ { "movzw", true, LONG, op2(Ew, R), 0 },
347 /*b8*/ { "", false, NONE, 0, 0 },
348 /*b9*/ { "", false, NONE, 0, 0 },
349 /*ba*/ { "", true, LONG, op2(Ib, E), db_Grp8 },
350 /*bb*/ { "btc", true, LONG, op2(R, E), 0 },
351 /*bc*/ { "bsf", true, LONG, op2(E, R), 0 },
352 /*bd*/ { "bsr", true, LONG, op2(E, R), 0 },
353 /*be*/ { "movsb", true, LONG, op2(Eb, R), 0 },
354 /*bf*/ { "movsw", true, LONG, op2(Ew, R), 0 },
357 static const struct inst db_inst_0fcx[] = {
358 /*c0*/ { "xadd", true, BYTE, op2(R, E), 0 },
359 /*c1*/ { "xadd", true, LONG, op2(R, E), 0 },
360 /*c2*/ { "", false, NONE, 0, 0 },
361 /*c3*/ { "", false, NONE, 0, 0 },
362 /*c4*/ { "", false, NONE, 0, 0 },
363 /*c5*/ { "", false, NONE, 0, 0 },
364 /*c6*/ { "", false, NONE, 0, 0 },
365 /*c7*/ { "", true, NONE, op1(E), db_Grp9 },
366 /*c8*/ { "bswap", false, LONG, op1(Ril), 0 },
367 /*c9*/ { "bswap", false, LONG, op1(Ril), 0 },
368 /*ca*/ { "bswap", false, LONG, op1(Ril), 0 },
369 /*cb*/ { "bswap", false, LONG, op1(Ril), 0 },
370 /*cc*/ { "bswap", false, LONG, op1(Ril), 0 },
371 /*cd*/ { "bswap", false, LONG, op1(Ril), 0 },
372 /*ce*/ { "bswap", false, LONG, op1(Ril), 0 },
373 /*cf*/ { "bswap", false, LONG, op1(Ril), 0 },
376 static const struct inst * const db_inst_0f[] = {
395 static const char * const db_Esc92[] = {
396 "fnop", "", "", "", "", "", "", ""
398 static const char * const db_Esc94[] = {
399 "fchs", "fabs", "", "", "ftst", "fxam", "", ""
401 static const char * const db_Esc95[] = {
402 "fld1", "fldl2t","fldl2e","fldpi","fldlg2","fldln2","fldz",""
404 static const char * const db_Esc96[] = {
405 "f2xm1","fyl2x","fptan","fpatan","fxtract","fprem1","fdecstp",
408 static const char * const db_Esc97[] = {
409 "fprem","fyl2xp1","fsqrt","fsincos","frndint","fscale","fsin","fcos"
412 static const char * const db_Esca5[] = {
413 "", "fucompp","", "", "", "", "", ""
416 static const char * const db_Escb4[] = {
417 "fneni","fndisi", "fnclex","fninit","fsetpm", "", "", ""
420 static const char * const db_Esce3[] = {
421 "", "fcompp","", "", "", "", "", ""
424 static const char * const db_Escf4[] = {
425 "fnstsw","", "", "", "", "", "", ""
428 static const struct finst db_Esc8[] = {
429 /*0*/ { "fadd", SNGL, op2(STI,ST), 0 },
430 /*1*/ { "fmul", SNGL, op2(STI,ST), 0 },
431 /*2*/ { "fcom", SNGL, op2(STI,ST), 0 },
432 /*3*/ { "fcomp", SNGL, op2(STI,ST), 0 },
433 /*4*/ { "fsub", SNGL, op2(STI,ST), 0 },
434 /*5*/ { "fsubr", SNGL, op2(STI,ST), 0 },
435 /*6*/ { "fdiv", SNGL, op2(STI,ST), 0 },
436 /*7*/ { "fdivr", SNGL, op2(STI,ST), 0 },
439 static const struct finst db_Esc9[] = {
440 /*0*/ { "fld", SNGL, op1(STI), 0 },
441 /*1*/ { "", NONE, op1(STI), "fxch" },
442 /*2*/ { "fst", SNGL, op1(X), db_Esc92 },
443 /*3*/ { "fstp", SNGL, 0, 0 },
444 /*4*/ { "fldenv", NONE, op1(X), db_Esc94 },
445 /*5*/ { "fldcw", NONE, op1(X), db_Esc95 },
446 /*6*/ { "fnstenv",NONE, op1(X), db_Esc96 },
447 /*7*/ { "fnstcw", NONE, op1(X), db_Esc97 },
450 static const struct finst db_Esca[] = {
451 /*0*/ { "fiadd", LONG, 0, 0 },
452 /*1*/ { "fimul", LONG, 0, 0 },
453 /*2*/ { "ficom", LONG, 0, 0 },
454 /*3*/ { "ficomp", LONG, 0, 0 },
455 /*4*/ { "fisub", LONG, 0, 0 },
456 /*5*/ { "fisubr", LONG, op1(X), db_Esca5 },
457 /*6*/ { "fidiv", LONG, 0, 0 },
458 /*7*/ { "fidivr", LONG, 0, 0 }
461 static const struct finst db_Escb[] = {
462 /*0*/ { "fild", LONG, 0, 0 },
463 /*1*/ { "", NONE, 0, 0 },
464 /*2*/ { "fist", LONG, 0, 0 },
465 /*3*/ { "fistp", LONG, 0, 0 },
466 /*4*/ { "", WORD, op1(X), db_Escb4 },
467 /*5*/ { "fld", EXTR, 0, 0 },
468 /*6*/ { "", WORD, 0, 0 },
469 /*7*/ { "fstp", EXTR, 0, 0 },
472 static const struct finst db_Escc[] = {
473 /*0*/ { "fadd", DBLR, op2(ST,STI), 0 },
474 /*1*/ { "fmul", DBLR, op2(ST,STI), 0 },
475 /*2*/ { "fcom", DBLR, 0, 0 },
476 /*3*/ { "fcomp", DBLR, 0, 0 },
477 /*4*/ { "fsub", DBLR, op2(ST,STI), "fsubr" },
478 /*5*/ { "fsubr", DBLR, op2(ST,STI), "fsub" },
479 /*6*/ { "fdiv", DBLR, op2(ST,STI), "fdivr" },
480 /*7*/ { "fdivr", DBLR, op2(ST,STI), "fdiv" },
483 static const struct finst db_Escd[] = {
484 /*0*/ { "fld", DBLR, op1(STI), "ffree" },
485 /*1*/ { "", NONE, 0, 0 },
486 /*2*/ { "fst", DBLR, op1(STI), 0 },
487 /*3*/ { "fstp", DBLR, op1(STI), 0 },
488 /*4*/ { "frstor", NONE, op1(STI), "fucom" },
489 /*5*/ { "", NONE, op1(STI), "fucomp" },
490 /*6*/ { "fnsave", NONE, 0, 0 },
491 /*7*/ { "fnstsw", NONE, 0, 0 },
494 static const struct finst db_Esce[] = {
495 /*0*/ { "fiadd", WORD, op2(ST,STI), "faddp" },
496 /*1*/ { "fimul", WORD, op2(ST,STI), "fmulp" },
497 /*2*/ { "ficom", WORD, 0, 0 },
498 /*3*/ { "ficomp", WORD, op1(X), db_Esce3 },
499 /*4*/ { "fisub", WORD, op2(ST,STI), "fsubrp" },
500 /*5*/ { "fisubr", WORD, op2(ST,STI), "fsubp" },
501 /*6*/ { "fidiv", WORD, op2(ST,STI), "fdivrp" },
502 /*7*/ { "fidivr", WORD, op2(ST,STI), "fdivp" },
505 static const struct finst db_Escf[] = {
506 /*0*/ { "fild", WORD, 0, 0 },
507 /*1*/ { "", NONE, 0, 0 },
508 /*2*/ { "fist", WORD, 0, 0 },
509 /*3*/ { "fistp", WORD, 0, 0 },
510 /*4*/ { "fbld", NONE, op1(XA), db_Escf4 },
511 /*5*/ { "fild", QUAD, 0, 0 },
512 /*6*/ { "fbstp", NONE, 0, 0 },
513 /*7*/ { "fistp", QUAD, 0, 0 },
516 static const struct finst * const db_Esc_inst[] = {
517 db_Esc8, db_Esc9, db_Esca, db_Escb,
518 db_Escc, db_Escd, db_Esce, db_Escf
521 static const char * const db_Grp1[] = {
532 static const char * const db_Grp2[] = {
543 static const struct inst db_Grp3[] = {
544 { "test", true, NONE, op2(I,E), 0 },
545 { "test", true, NONE, op2(I,E), 0 },
546 { "not", true, NONE, op1(E), 0 },
547 { "neg", true, NONE, op1(E), 0 },
548 { "mul", true, NONE, op2(E,A), 0 },
549 { "imul", true, NONE, op2(E,A), 0 },
550 { "div", true, NONE, op2(E,A), 0 },
551 { "idiv", true, NONE, op2(E,A), 0 },
554 static const struct inst db_Grp4[] = {
555 { "inc", true, BYTE, op1(E), 0 },
556 { "dec", true, BYTE, op1(E), 0 },
557 { "", true, NONE, 0, 0 },
558 { "", true, NONE, 0, 0 },
559 { "", true, NONE, 0, 0 },
560 { "", true, NONE, 0, 0 },
561 { "", true, NONE, 0, 0 },
562 { "", true, NONE, 0, 0 }
565 static const struct inst db_Grp5[] = {
566 { "inc", true, LONG, op1(E), 0 },
567 { "dec", true, LONG, op1(E), 0 },
568 { "call", true, LONG, op1(Eind),0 },
569 { "lcall", true, LONG, op1(Eind),0 },
570 { "jmp", true, LONG, op1(Eind),0 },
571 { "ljmp", true, LONG, op1(Eind),0 },
572 { "push", true, LONG, op1(E), 0 },
573 { "", true, NONE, 0, 0 }
576 static const struct inst db_inst_table[256] = {
577 /*00*/ { "add", true, BYTE, op2(R, E), 0 },
578 /*01*/ { "add", true, LONG, op2(R, E), 0 },
579 /*02*/ { "add", true, BYTE, op2(E, R), 0 },
580 /*03*/ { "add", true, LONG, op2(E, R), 0 },
581 /*04*/ { "add", false, BYTE, op2(I, A), 0 },
582 /*05*/ { "add", false, LONG, op2(Is, A), 0 },
583 /*06*/ { "push", false, NONE, op1(Si), 0 },
584 /*07*/ { "pop", false, NONE, op1(Si), 0 },
586 /*08*/ { "or", true, BYTE, op2(R, E), 0 },
587 /*09*/ { "or", true, LONG, op2(R, E), 0 },
588 /*0a*/ { "or", true, BYTE, op2(E, R), 0 },
589 /*0b*/ { "or", true, LONG, op2(E, R), 0 },
590 /*0c*/ { "or", false, BYTE, op2(I, A), 0 },
591 /*0d*/ { "or", false, LONG, op2(I, A), 0 },
592 /*0e*/ { "push", false, NONE, op1(Si), 0 },
593 /*0f*/ { "", false, NONE, 0, 0 },
595 /*10*/ { "adc", true, BYTE, op2(R, E), 0 },
596 /*11*/ { "adc", true, LONG, op2(R, E), 0 },
597 /*12*/ { "adc", true, BYTE, op2(E, R), 0 },
598 /*13*/ { "adc", true, LONG, op2(E, R), 0 },
599 /*14*/ { "adc", false, BYTE, op2(I, A), 0 },
600 /*15*/ { "adc", false, LONG, op2(Is, A), 0 },
601 /*16*/ { "push", false, NONE, op1(Si), 0 },
602 /*17*/ { "pop", false, NONE, op1(Si), 0 },
604 /*18*/ { "sbb", true, BYTE, op2(R, E), 0 },
605 /*19*/ { "sbb", true, LONG, op2(R, E), 0 },
606 /*1a*/ { "sbb", true, BYTE, op2(E, R), 0 },
607 /*1b*/ { "sbb", true, LONG, op2(E, R), 0 },
608 /*1c*/ { "sbb", false, BYTE, op2(I, A), 0 },
609 /*1d*/ { "sbb", false, LONG, op2(Is, A), 0 },
610 /*1e*/ { "push", false, NONE, op1(Si), 0 },
611 /*1f*/ { "pop", false, NONE, op1(Si), 0 },
613 /*20*/ { "and", true, BYTE, op2(R, E), 0 },
614 /*21*/ { "and", true, LONG, op2(R, E), 0 },
615 /*22*/ { "and", true, BYTE, op2(E, R), 0 },
616 /*23*/ { "and", true, LONG, op2(E, R), 0 },
617 /*24*/ { "and", false, BYTE, op2(I, A), 0 },
618 /*25*/ { "and", false, LONG, op2(I, A), 0 },
619 /*26*/ { "", false, NONE, 0, 0 },
620 /*27*/ { "daa", false, NONE, 0, 0 },
622 /*28*/ { "sub", true, BYTE, op2(R, E), 0 },
623 /*29*/ { "sub", true, LONG, op2(R, E), 0 },
624 /*2a*/ { "sub", true, BYTE, op2(E, R), 0 },
625 /*2b*/ { "sub", true, LONG, op2(E, R), 0 },
626 /*2c*/ { "sub", false, BYTE, op2(I, A), 0 },
627 /*2d*/ { "sub", false, LONG, op2(Is, A), 0 },
628 /*2e*/ { "", false, NONE, 0, 0 },
629 /*2f*/ { "das", false, NONE, 0, 0 },
631 /*30*/ { "xor", true, BYTE, op2(R, E), 0 },
632 /*31*/ { "xor", true, LONG, op2(R, E), 0 },
633 /*32*/ { "xor", true, BYTE, op2(E, R), 0 },
634 /*33*/ { "xor", true, LONG, op2(E, R), 0 },
635 /*34*/ { "xor", false, BYTE, op2(I, A), 0 },
636 /*35*/ { "xor", false, LONG, op2(I, A), 0 },
637 /*36*/ { "", false, NONE, 0, 0 },
638 /*37*/ { "aaa", false, NONE, 0, 0 },
640 /*38*/ { "cmp", true, BYTE, op2(R, E), 0 },
641 /*39*/ { "cmp", true, LONG, op2(R, E), 0 },
642 /*3a*/ { "cmp", true, BYTE, op2(E, R), 0 },
643 /*3b*/ { "cmp", true, LONG, op2(E, R), 0 },
644 /*3c*/ { "cmp", false, BYTE, op2(I, A), 0 },
645 /*3d*/ { "cmp", false, LONG, op2(Is, A), 0 },
646 /*3e*/ { "", false, NONE, 0, 0 },
647 /*3f*/ { "aas", false, NONE, 0, 0 },
649 /*40*/ { "inc", false, LONG, op1(Ri), 0 },
650 /*41*/ { "inc", false, LONG, op1(Ri), 0 },
651 /*42*/ { "inc", false, LONG, op1(Ri), 0 },
652 /*43*/ { "inc", false, LONG, op1(Ri), 0 },
653 /*44*/ { "inc", false, LONG, op1(Ri), 0 },
654 /*45*/ { "inc", false, LONG, op1(Ri), 0 },
655 /*46*/ { "inc", false, LONG, op1(Ri), 0 },
656 /*47*/ { "inc", false, LONG, op1(Ri), 0 },
658 /*48*/ { "dec", false, LONG, op1(Ri), 0 },
659 /*49*/ { "dec", false, LONG, op1(Ri), 0 },
660 /*4a*/ { "dec", false, LONG, op1(Ri), 0 },
661 /*4b*/ { "dec", false, LONG, op1(Ri), 0 },
662 /*4c*/ { "dec", false, LONG, op1(Ri), 0 },
663 /*4d*/ { "dec", false, LONG, op1(Ri), 0 },
664 /*4e*/ { "dec", false, LONG, op1(Ri), 0 },
665 /*4f*/ { "dec", false, LONG, op1(Ri), 0 },
667 /*50*/ { "push", false, LONG, op1(Ri), 0 },
668 /*51*/ { "push", false, LONG, op1(Ri), 0 },
669 /*52*/ { "push", false, LONG, op1(Ri), 0 },
670 /*53*/ { "push", false, LONG, op1(Ri), 0 },
671 /*54*/ { "push", false, LONG, op1(Ri), 0 },
672 /*55*/ { "push", false, LONG, op1(Ri), 0 },
673 /*56*/ { "push", false, LONG, op1(Ri), 0 },
674 /*57*/ { "push", false, LONG, op1(Ri), 0 },
676 /*58*/ { "pop", false, LONG, op1(Ri), 0 },
677 /*59*/ { "pop", false, LONG, op1(Ri), 0 },
678 /*5a*/ { "pop", false, LONG, op1(Ri), 0 },
679 /*5b*/ { "pop", false, LONG, op1(Ri), 0 },
680 /*5c*/ { "pop", false, LONG, op1(Ri), 0 },
681 /*5d*/ { "pop", false, LONG, op1(Ri), 0 },
682 /*5e*/ { "pop", false, LONG, op1(Ri), 0 },
683 /*5f*/ { "pop", false, LONG, op1(Ri), 0 },
685 /*60*/ { "pusha", false, LONG, 0, 0 },
686 /*61*/ { "popa", false, LONG, 0, 0 },
687 /*62*/ { "bound", true, LONG, op2(E, R), 0 },
688 /*63*/ { "arpl", true, NONE, op2(Rw,Ew), 0 },
690 /*64*/ { "", false, NONE, 0, 0 },
691 /*65*/ { "", false, NONE, 0, 0 },
692 /*66*/ { "", false, NONE, 0, 0 },
693 /*67*/ { "", false, NONE, 0, 0 },
695 /*68*/ { "push", false, LONG, op1(I), 0 },
696 /*69*/ { "imul", true, LONG, op3(I,E,R), 0 },
697 /*6a*/ { "push", false, LONG, op1(Ibs), 0 },
698 /*6b*/ { "imul", true, LONG, op3(Ibs,E,R),0 },
699 /*6c*/ { "ins", false, BYTE, op2(DX, DI), 0 },
700 /*6d*/ { "ins", false, LONG, op2(DX, DI), 0 },
701 /*6e*/ { "outs", false, BYTE, op2(SI, DX), 0 },
702 /*6f*/ { "outs", false, LONG, op2(SI, DX), 0 },
704 /*70*/ { "jo", false, NONE, op1(Db), 0 },
705 /*71*/ { "jno", false, NONE, op1(Db), 0 },
706 /*72*/ { "jb", false, NONE, op1(Db), 0 },
707 /*73*/ { "jnb", false, NONE, op1(Db), 0 },
708 /*74*/ { "jz", false, NONE, op1(Db), 0 },
709 /*75*/ { "jnz", false, NONE, op1(Db), 0 },
710 /*76*/ { "jbe", false, NONE, op1(Db), 0 },
711 /*77*/ { "jnbe", false, NONE, op1(Db), 0 },
713 /*78*/ { "js", false, NONE, op1(Db), 0 },
714 /*79*/ { "jns", false, NONE, op1(Db), 0 },
715 /*7a*/ { "jp", false, NONE, op1(Db), 0 },
716 /*7b*/ { "jnp", false, NONE, op1(Db), 0 },
717 /*7c*/ { "jl", false, NONE, op1(Db), 0 },
718 /*7d*/ { "jnl", false, NONE, op1(Db), 0 },
719 /*7e*/ { "jle", false, NONE, op1(Db), 0 },
720 /*7f*/ { "jnle", false, NONE, op1(Db), 0 },
722 /*80*/ { "", true, BYTE, op2(I, E), db_Grp1 },
723 /*81*/ { "", true, LONG, op2(I, E), db_Grp1 },
724 /*82*/ { "", true, BYTE, op2(I, E), db_Grp1 },
725 /*83*/ { "", true, LONG, op2(Ibs,E), db_Grp1 },
726 /*84*/ { "test", true, BYTE, op2(R, E), 0 },
727 /*85*/ { "test", true, LONG, op2(R, E), 0 },
728 /*86*/ { "xchg", true, BYTE, op2(R, E), 0 },
729 /*87*/ { "xchg", true, LONG, op2(R, E), 0 },
731 /*88*/ { "mov", true, BYTE, op2(R, E), 0 },
732 /*89*/ { "mov", true, LONG, op2(R, E), 0 },
733 /*8a*/ { "mov", true, BYTE, op2(E, R), 0 },
734 /*8b*/ { "mov", true, LONG, op2(E, R), 0 },
735 /*8c*/ { "mov", true, NONE, op2(S, Ew), 0 },
736 /*8d*/ { "lea", true, LONG, op2(E, R), 0 },
737 /*8e*/ { "mov", true, NONE, op2(Ew, S), 0 },
738 /*8f*/ { "pop", true, LONG, op1(E), 0 },
740 /*90*/ { "nop", false, NONE, 0, 0 },
741 /*91*/ { "xchg", false, LONG, op2(A, Ri), 0 },
742 /*92*/ { "xchg", false, LONG, op2(A, Ri), 0 },
743 /*93*/ { "xchg", false, LONG, op2(A, Ri), 0 },
744 /*94*/ { "xchg", false, LONG, op2(A, Ri), 0 },
745 /*95*/ { "xchg", false, LONG, op2(A, Ri), 0 },
746 /*96*/ { "xchg", false, LONG, op2(A, Ri), 0 },
747 /*97*/ { "xchg", false, LONG, op2(A, Ri), 0 },
749 /*98*/ { "cbw", false, SDEP, 0, "cwde" }, /* cbw/cwde */
750 /*99*/ { "cwd", false, SDEP, 0, "cdq" }, /* cwd/cdq */
751 /*9a*/ { "lcall", false, NONE, op1(OS), 0 },
752 /*9b*/ { "wait", false, NONE, 0, 0 },
753 /*9c*/ { "pushf", false, LONG, 0, 0 },
754 /*9d*/ { "popf", false, LONG, 0, 0 },
755 /*9e*/ { "sahf", false, NONE, 0, 0 },
756 /*9f*/ { "lahf", false, NONE, 0, 0 },
758 /*a0*/ { "mov", false, BYTE, op2(O, A), 0 },
759 /*a1*/ { "mov", false, LONG, op2(O, A), 0 },
760 /*a2*/ { "mov", false, BYTE, op2(A, O), 0 },
761 /*a3*/ { "mov", false, LONG, op2(A, O), 0 },
762 /*a4*/ { "movs", false, BYTE, op2(SI,DI), 0 },
763 /*a5*/ { "movs", false, LONG, op2(SI,DI), 0 },
764 /*a6*/ { "cmps", false, BYTE, op2(SI,DI), 0 },
765 /*a7*/ { "cmps", false, LONG, op2(SI,DI), 0 },
767 /*a8*/ { "test", false, BYTE, op2(I, A), 0 },
768 /*a9*/ { "test", false, LONG, op2(I, A), 0 },
769 /*aa*/ { "stos", false, BYTE, op1(DI), 0 },
770 /*ab*/ { "stos", false, LONG, op1(DI), 0 },
771 /*ac*/ { "lods", false, BYTE, op1(SI), 0 },
772 /*ad*/ { "lods", false, LONG, op1(SI), 0 },
773 /*ae*/ { "scas", false, BYTE, op1(SI), 0 },
774 /*af*/ { "scas", false, LONG, op1(SI), 0 },
776 /*b0*/ { "mov", false, BYTE, op2(I, Ri), 0 },
777 /*b1*/ { "mov", false, BYTE, op2(I, Ri), 0 },
778 /*b2*/ { "mov", false, BYTE, op2(I, Ri), 0 },
779 /*b3*/ { "mov", false, BYTE, op2(I, Ri), 0 },
780 /*b4*/ { "mov", false, BYTE, op2(I, Ri), 0 },
781 /*b5*/ { "mov", false, BYTE, op2(I, Ri), 0 },
782 /*b6*/ { "mov", false, BYTE, op2(I, Ri), 0 },
783 /*b7*/ { "mov", false, BYTE, op2(I, Ri), 0 },
785 /*b8*/ { "mov", false, LONG, op2(I, Ri), 0 },
786 /*b9*/ { "mov", false, LONG, op2(I, Ri), 0 },
787 /*ba*/ { "mov", false, LONG, op2(I, Ri), 0 },
788 /*bb*/ { "mov", false, LONG, op2(I, Ri), 0 },
789 /*bc*/ { "mov", false, LONG, op2(I, Ri), 0 },
790 /*bd*/ { "mov", false, LONG, op2(I, Ri), 0 },
791 /*be*/ { "mov", false, LONG, op2(I, Ri), 0 },
792 /*bf*/ { "mov", false, LONG, op2(I, Ri), 0 },
794 /*c0*/ { "", true, BYTE, op2(Ib, E), db_Grp2 },
795 /*c1*/ { "", true, LONG, op2(Ib, E), db_Grp2 },
796 /*c2*/ { "ret", false, NONE, op1(Iw), 0 },
797 /*c3*/ { "ret", false, NONE, 0, 0 },
798 /*c4*/ { "les", true, LONG, op2(E, R), 0 },
799 /*c5*/ { "lds", true, LONG, op2(E, R), 0 },
800 /*c6*/ { "mov", true, BYTE, op2(I, E), 0 },
801 /*c7*/ { "mov", true, LONG, op2(I, E), 0 },
803 /*c8*/ { "enter", false, NONE, op2(Iw, Ib), 0 },
804 /*c9*/ { "leave", false, NONE, 0, 0 },
805 /*ca*/ { "lret", false, NONE, op1(Iw), 0 },
806 /*cb*/ { "lret", false, NONE, 0, 0 },
807 /*cc*/ { "int", false, NONE, op1(o3), 0 },
808 /*cd*/ { "int", false, NONE, op1(Ib), 0 },
809 /*ce*/ { "into", false, NONE, 0, 0 },
810 /*cf*/ { "iret", false, NONE, 0, 0 },
812 /*d0*/ { "", true, BYTE, op2(o1, E), db_Grp2 },
813 /*d1*/ { "", true, LONG, op2(o1, E), db_Grp2 },
814 /*d2*/ { "", true, BYTE, op2(CL, E), db_Grp2 },
815 /*d3*/ { "", true, LONG, op2(CL, E), db_Grp2 },
816 /*d4*/ { "aam", false, NONE, op1(Iba), 0 },
817 /*d5*/ { "aad", false, NONE, op1(Iba), 0 },
818 /*d6*/ { ".byte\t0xd6", false, NONE, 0, 0 },
819 /*d7*/ { "xlat", false, BYTE, op1(BX), 0 },
821 /*d8*/ { "", true, NONE, 0, db_Esc8 },
822 /*d9*/ { "", true, NONE, 0, db_Esc9 },
823 /*da*/ { "", true, NONE, 0, db_Esca },
824 /*db*/ { "", true, NONE, 0, db_Escb },
825 /*dc*/ { "", true, NONE, 0, db_Escc },
826 /*dd*/ { "", true, NONE, 0, db_Escd },
827 /*de*/ { "", true, NONE, 0, db_Esce },
828 /*df*/ { "", true, NONE, 0, db_Escf },
830 /*e0*/ { "loopne",false, NONE, op1(Db), 0 },
831 /*e1*/ { "loope", false, NONE, op1(Db), 0 },
832 /*e2*/ { "loop", false, NONE, op1(Db), 0 },
833 /*e3*/ { "jcxz", false, SDEP, op1(Db), "jecxz" },
834 /*e4*/ { "in", false, BYTE, op2(Ib, A), 0 },
835 /*e5*/ { "in", false, LONG, op2(Ib, A) , 0 },
836 /*e6*/ { "out", false, BYTE, op2(A, Ib), 0 },
837 /*e7*/ { "out", false, LONG, op2(A, Ib) , 0 },
839 /*e8*/ { "call", false, NONE, op1(Dl), 0 },
840 /*e9*/ { "jmp", false, NONE, op1(Dl), 0 },
841 /*ea*/ { "ljmp", false, NONE, op1(OS), 0 },
842 /*eb*/ { "jmp", false, NONE, op1(Db), 0 },
843 /*ec*/ { "in", false, BYTE, op2(DX, A), 0 },
844 /*ed*/ { "in", false, LONG, op2(DX, A) , 0 },
845 /*ee*/ { "out", false, BYTE, op2(A, DX), 0 },
846 /*ef*/ { "out", false, LONG, op2(A, DX) , 0 },
848 /*f0*/ { "", false, NONE, 0, 0 },
849 /*f1*/ { ".byte\t0xf1", false, NONE, 0, 0 },
850 /*f2*/ { "", false, NONE, 0, 0 },
851 /*f3*/ { "", false, NONE, 0, 0 },
852 /*f4*/ { "hlt", false, NONE, 0, 0 },
853 /*f5*/ { "cmc", false, NONE, 0, 0 },
854 /*f6*/ { "", true, BYTE, 0, db_Grp3 },
855 /*f7*/ { "", true, LONG, 0, db_Grp3 },
857 /*f8*/ { "clc", false, NONE, 0, 0 },
858 /*f9*/ { "stc", false, NONE, 0, 0 },
859 /*fa*/ { "cli", false, NONE, 0, 0 },
860 /*fb*/ { "sti", false, NONE, 0, 0 },
861 /*fc*/ { "cld", false, NONE, 0, 0 },
862 /*fd*/ { "std", false, NONE, 0, 0 },
863 /*fe*/ { "", true, NONE, 0, db_Grp4 },
864 /*ff*/ { "", true, NONE, 0, db_Grp5 },
867 static const struct inst db_bad_inst =
868 { "???", false, NONE, 0, 0 }
871 #define f_mod(byte) ((byte)>>6)
872 #define f_reg(byte) (((byte)>>3)&0x7)
873 #define f_rm(byte) ((byte)&0x7)
875 #define sib_ss(byte) ((byte)>>6)
876 #define sib_index(byte) (((byte)>>3)&0x7)
877 #define sib_base(byte) ((byte)&0x7)
880 bool is_reg; /* if reg, reg number is in 'disp' */
885 bool defss; /* set if %ss is the default segment */
888 static const char * const db_index_reg_16[8] = {
899 static const char * const db_reg[3][8] = {
900 { "%al", "%cl", "%dl", "%bl", "%ah", "%ch", "%dh", "%bh" },
901 { "%ax", "%cx", "%dx", "%bx", "%sp", "%bp", "%si", "%di" },
902 { "%eax", "%ecx", "%edx", "%ebx", "%esp", "%ebp", "%esi", "%edi" }
905 static const char * const db_seg_reg[8] = {
906 "%es", "%cs", "%ss", "%ds", "%fs", "%gs", "", ""
910 * lengths for size attributes
912 static const int db_lengths[] = {
922 #define get_value_inc(result, loc, size, is_signed) \
923 result = db_get_value((loc), (size), (is_signed)); \
927 db_disasm_esc(db_addr_t loc, int inst, bool short_addr,
928 int size, const char *seg);
929 static void db_print_address(const char *seg, int size,
930 struct i_addr *addrp);
932 db_read_address(db_addr_t loc, bool short_addr, int regmodrm,
933 struct i_addr *addrp);
936 * Read address at location and return updated location.
939 db_read_address(db_addr_t loc, bool short_addr, int regmodrm,
940 struct i_addr *addrp)
942 int mod, rm, sib, index, disp;
944 mod = f_mod(regmodrm);
948 addrp->is_reg = true;
952 addrp->is_reg = false;
955 addrp->defss = false;
958 if (rm == 2 || rm == 3 || (rm == 6 && mod != 0))
963 get_value_inc(disp, loc, 2, false);
969 addrp->base = db_index_reg_16[rm];
973 get_value_inc(disp, loc, 1, true);
976 addrp->base = db_index_reg_16[rm];
979 get_value_inc(disp, loc, 2, false);
981 addrp->base = db_index_reg_16[rm];
987 get_value_inc(sib, loc, 1, false);
989 index = sib_index(sib);
991 addrp->index = db_reg[LONG][index];
992 addrp->ss = sib_ss(sib);
998 get_value_inc(addrp->disp, loc, 4, false);
1003 addrp->base = db_reg[LONG][rm];
1008 get_value_inc(disp, loc, 1, true);
1010 addrp->base = db_reg[LONG][rm];
1014 get_value_inc(disp, loc, 4, false);
1016 addrp->base = db_reg[LONG][rm];
1024 db_print_address(const char *seg, int size, struct i_addr *addrp)
1026 if (addrp->is_reg) {
1027 db_printf("%s", db_reg[size][addrp->disp]);
1032 db_printf("%s:", seg);
1034 else if (addrp->defss) {
1038 db_printsym((db_addr_t)addrp->disp, DB_STGY_ANY);
1039 if (addrp->base != NULL || addrp->index != NULL) {
1042 db_printf("%s", addrp->base);
1044 db_printf(",%s,%d", addrp->index, 1<<addrp->ss);
1050 * Disassemble floating-point ("escape") instruction
1051 * and return updated location.
1054 db_disasm_esc(db_addr_t loc, int inst, bool short_addr, int size,
1058 const struct finst * fp;
1060 struct i_addr address;
1063 get_value_inc(regmodrm, loc, 1, false);
1064 fp = &db_Esc_inst[inst - 0xd8][f_reg(regmodrm)];
1065 mod = f_mod(regmodrm);
1067 if (*fp->f_name == '\0') {
1068 db_printf("<bad instruction>");
1072 * Normal address modes.
1074 loc = db_read_address(loc, short_addr, regmodrm, &address);
1075 db_printf("%s", fp->f_name);
1076 switch(fp->f_size) {
1099 db_print_address(seg, BYTE, &address);
1103 * 'reg-reg' - special formats
1105 switch (fp->f_rrmode) {
1107 name = (fp->f_rrname) ? fp->f_rrname : fp->f_name;
1108 db_printf("%s\t%%st,%%st(%d)",name,f_rm(regmodrm));
1111 name = (fp->f_rrname) ? fp->f_rrname : fp->f_name;
1112 db_printf("%s\t%%st(%d),%%st",name, f_rm(regmodrm));
1115 name = (fp->f_rrname) ? fp->f_rrname : fp->f_name;
1116 db_printf("%s\t%%st(%d)",name, f_rm(regmodrm));
1119 name = ((const char * const *)fp->f_rrname)[f_rm(regmodrm)];
1122 db_printf("%s", name);
1125 name = ((const char * const *)fp->f_rrname)[f_rm(regmodrm)];
1128 db_printf("%s\t%%ax", name);
1132 db_printf("<bad instruction>");
1141 * Disassemble instruction at 'loc'. 'altfmt' specifies an
1142 * (optional) alternate format. Return address of start of
1146 db_disasm(db_addr_t loc, bool altfmt)
1152 const struct inst * ip;
1153 const char * i_name;
1164 struct i_addr address;
1166 if (db_segsize(kdb_frame) == 16)
1168 get_value_inc(inst, loc, 1, false);
1187 size = (altfmt ? LONG : WORD);
1190 short_addr = !altfmt;
1214 db_printf("repne ");
1224 get_value_inc(inst, loc, 1, false);
1228 db_printf("pause\n");
1231 db_printf("repe "); /* XXX repe VS rep */
1236 if (inst >= 0xd8 && inst <= 0xdf) {
1237 loc = db_disasm_esc(loc, inst, short_addr, size, seg);
1243 get_value_inc(inst, loc, 1, false);
1244 ip = db_inst_0f[inst>>4];
1253 ip = &db_inst_table[inst];
1255 if (ip->i_has_modrm) {
1256 get_value_inc(regmodrm, loc, 1, false);
1257 loc = db_read_address(loc, short_addr, regmodrm, &address);
1260 i_name = ip->i_name;
1261 i_size = ip->i_size;
1262 i_mode = ip->i_mode;
1264 if (ip->i_extra == db_Grp1 || ip->i_extra == db_Grp2 ||
1265 ip->i_extra == db_Grp6 || ip->i_extra == db_Grp7 ||
1266 ip->i_extra == db_Grp8 || ip->i_extra == db_Grp9 ||
1267 ip->i_extra == db_Grp15) {
1268 i_name = ((const char * const *)ip->i_extra)[f_reg(regmodrm)];
1270 else if (ip->i_extra == db_Grp3) {
1272 ip = &ip[f_reg(regmodrm)];
1273 i_name = ip->i_name;
1274 i_mode = ip->i_mode;
1276 else if (ip->i_extra == db_Grp4 || ip->i_extra == db_Grp5) {
1278 ip = &ip[f_reg(regmodrm)];
1279 i_name = ip->i_name;
1280 i_mode = ip->i_mode;
1281 i_size = ip->i_size;
1284 /* Special cases that don't fit well in the tables. */
1285 if (ip->i_extra == db_Grp7 && f_mod(regmodrm) == 3) {
1299 if (ip->i_extra == db_Grp15 && f_mod(regmodrm) == 3) {
1300 i_name = db_Grp15b[f_reg(regmodrm)];
1305 if (i_size == SDEP) {
1307 db_printf("%s", i_name);
1309 db_printf("%s", (const char *)ip->i_extra);
1312 db_printf("%s", i_name);
1313 if (i_size != NONE) {
1314 if (i_size == BYTE) {
1318 else if (i_size == WORD) {
1322 else if (size == WORD)
1331 i_mode >>= 8, first = false)
1336 switch (i_mode & 0xFF) {
1338 db_print_address(seg, size, &address);
1343 db_print_address(seg, size, &address);
1347 db_print_address(seg, LONG, &address);
1351 db_print_address(seg, WORD, &address);
1355 db_print_address(seg, BYTE, &address);
1359 db_printf("%s", db_reg[size][f_reg(regmodrm)]);
1363 db_printf("%s", db_reg[WORD][f_reg(regmodrm)]);
1367 db_printf("%s", db_reg[size][f_rm(inst)]);
1371 db_printf("%s", db_reg[LONG][f_rm(inst)]);
1375 db_printf("%s", db_seg_reg[f_reg(regmodrm)]);
1379 db_printf("%s", db_seg_reg[f_reg(inst)]);
1383 db_printf("%s", db_reg[size][0]); /* acc */
1388 db_printf("%s:", seg);
1389 db_printf("(%s)", short_addr ? "%bx" : "%ebx");
1402 db_printf("%s:", seg);
1403 db_printf("(%s)", short_addr ? "%si" : "%esi");
1407 db_printf("%%es:(%s)", short_addr ? "%di" : "%edi");
1411 db_printf("%%cr%d", f_reg(regmodrm));
1415 db_printf("%%dr%d", f_reg(regmodrm));
1419 db_printf("%%tr%d", f_reg(regmodrm));
1423 len = db_lengths[size];
1424 get_value_inc(imm, loc, len, false);
1425 db_printf("$%#r", imm);
1429 len = db_lengths[size];
1430 get_value_inc(imm, loc, len, false);
1431 db_printf("$%+#r", imm);
1435 get_value_inc(imm, loc, 1, false);
1436 db_printf("$%#r", imm);
1440 get_value_inc(imm, loc, 1, false);
1442 db_printf("$%#r", imm);
1446 get_value_inc(imm, loc, 1, true);
1449 db_printf("$%+#r", imm);
1453 get_value_inc(imm, loc, 2, false);
1454 db_printf("$%#r", imm);
1458 len = (short_addr ? 2 : 4);
1459 get_value_inc(displ, loc, len, false);
1461 db_printf("%s:%+#r",seg, displ);
1463 db_printsym((db_addr_t)displ, DB_STGY_ANY);
1467 get_value_inc(displ, loc, 1, true);
1471 db_printsym((db_addr_t)displ, DB_STGY_XTRN);
1475 len = db_lengths[size];
1476 get_value_inc(displ, loc, len, false);
1480 db_printsym((db_addr_t)displ, DB_STGY_XTRN);
1492 len = db_lengths[size];
1493 get_value_inc(imm, loc, len, false); /* offset */
1494 get_value_inc(imm2, loc, 2, false); /* segment */
1495 db_printf("$%#r,%#r", imm2, imm);