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