db_disasm.c revision 261213
1139731Simp/*-
24Srgrimes * Mach Operating System
34Srgrimes * Copyright (c) 1991,1990 Carnegie Mellon University
44Srgrimes * All Rights Reserved.
58876Srgrimes *
64Srgrimes * Permission to use, copy, modify and distribute this software and its
74Srgrimes * documentation is hereby granted, provided that both the copyright
84Srgrimes * notice and this permission notice appear in all copies of the
94Srgrimes * software, derivative works or modified versions, and any portions
104Srgrimes * thereof, and that both notices appear in supporting documentation.
118876Srgrimes *
128876Srgrimes * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS
134Srgrimes * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
144Srgrimes * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
158876Srgrimes *
164Srgrimes * Carnegie Mellon requests users of this software to return to
178876Srgrimes *
184Srgrimes *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
194Srgrimes *  School of Computer Science
204Srgrimes *  Carnegie Mellon University
214Srgrimes *  Pittsburgh PA 15213-3890
228876Srgrimes *
234Srgrimes * any improvements or extensions that they make and grant Carnegie the
244Srgrimes * rights to redistribute these changes.
254Srgrimes */
264Srgrimes
27118031Sobrien#include <sys/cdefs.h>
28118031Sobrien__FBSDID("$FreeBSD: head/sys/amd64/amd64/db_disasm.c 261213 2014-01-27 18:53:18Z jhb $");
29118031Sobrien
304Srgrimes/*
314Srgrimes * Instruction disassembler.
324Srgrimes */
332056Swollman#include <sys/param.h>
34238166Sjhb#include <sys/libkern.h>
3524494Sbde
362056Swollman#include <ddb/ddb.h>
374Srgrimes#include <ddb/db_access.h>
384Srgrimes#include <ddb/db_sym.h>
394Srgrimes
404Srgrimes/*
414Srgrimes * Size attributes
424Srgrimes */
434Srgrimes#define	BYTE	0
444Srgrimes#define	WORD	1
454Srgrimes#define	LONG	2
464Srgrimes#define	QUAD	3
474Srgrimes#define	SNGL	4
484Srgrimes#define	DBLR	5
494Srgrimes#define	EXTR	6
504Srgrimes#define	SDEP	7
51238166Sjhb#define	ADEP	8
52238166Sjhb#define	ESC	9
53238166Sjhb#define	NONE	10
544Srgrimes
554Srgrimes/*
56144353Speter * REX prefix and bits
57144353Speter */
58144353Speter#define REX_B	1
59144353Speter#define REX_X	2
60144353Speter#define REX_R	4
61144353Speter#define REX_W	8
62144353Speter#define REX	0x40
63144353Speter
64144353Speter/*
654Srgrimes * Addressing modes
664Srgrimes */
674Srgrimes#define	E	1			/* general effective address */
684Srgrimes#define	Eind	2			/* indirect address (jump, call) */
694Srgrimes#define	Ew	3			/* address, word size */
704Srgrimes#define	Eb	4			/* address, byte size */
714Srgrimes#define	R	5			/* register, in 'reg' field */
724Srgrimes#define	Rw	6			/* word register, in 'reg' field */
73238166Sjhb#define	Rq	39			/* quad register, in 'reg' field */
744Srgrimes#define	Ri	7			/* register in instruction */
754Srgrimes#define	S	8			/* segment reg, in 'reg' field */
764Srgrimes#define	Si	9			/* segment reg, in instruction */
774Srgrimes#define	A	10			/* accumulator */
784Srgrimes#define	BX	11			/* (bx) */
794Srgrimes#define	CL	12			/* cl, for shifts */
804Srgrimes#define	DX	13			/* dx, for IO */
814Srgrimes#define	SI	14			/* si */
824Srgrimes#define	DI	15			/* di */
834Srgrimes#define	CR	16			/* control register */
844Srgrimes#define	DR	17			/* debug register */
854Srgrimes#define	TR	18			/* test register */
864Srgrimes#define	I	19			/* immediate, unsigned */
874Srgrimes#define	Is	20			/* immediate, signed */
884Srgrimes#define	Ib	21			/* byte immediate, unsigned */
894Srgrimes#define	Ibs	22			/* byte immediate, signed */
904Srgrimes#define	Iw	23			/* word immediate, unsigned */
91164263Sjhb#define	Ilq	24			/* long/quad immediate, unsigned */
924Srgrimes#define	O	25			/* direct address */
934Srgrimes#define	Db	26			/* byte displacement from EIP */
944Srgrimes#define	Dl	27			/* long displacement from EIP */
954Srgrimes#define	o1	28			/* constant 1 */
964Srgrimes#define	o3	29			/* constant 3 */
974Srgrimes#define	OS	30			/* immediate offset/segment */
984Srgrimes#define	ST	31			/* FP stack top */
994Srgrimes#define	STI	32			/* FP stack */
1004Srgrimes#define	X	33			/* extended FP op */
1014Srgrimes#define	XA	34			/* for 'fstcw %ax' */
102144354Speter#define	El	35			/* address, long/quad size */
10321277Sbde#define	Ril	36			/* long register in instruction */
10421277Sbde#define	Iba	37			/* byte immediate, don't print if 0xa */
105144354Speter#define	EL	38			/* address, explicitly long size */
1064Srgrimes
10711940Sbdestruct inst {
10814887Swollman	const char *	i_name;		/* name */
1094Srgrimes	short	i_has_modrm;		/* has regmodrm byte */
1104Srgrimes	short	i_size;			/* operand size */
1114Srgrimes	int	i_mode;			/* addressing modes */
11217109Sbde	const void *	i_extra;	/* pointer to extra opcode table */
1134Srgrimes};
1144Srgrimes
1154Srgrimes#define	op1(x)		(x)
1164Srgrimes#define	op2(x,y)	((x)|((y)<<8))
1174Srgrimes#define	op3(x,y,z)	((x)|((y)<<8)|((z)<<16))
1184Srgrimes
11911940Sbdestruct finst {
12014887Swollman	const char *	f_name;		/* name for memory instruction */
1214Srgrimes	int	f_size;			/* size for memory instruction */
1224Srgrimes	int	f_rrmode;		/* mode for rr instruction */
12317109Sbde	const void *	f_rrname;	/* name for rr instruction
1244Srgrimes					   (or pointer to table) */
1254Srgrimes};
1264Srgrimes
127238166Sjhbstatic const struct inst db_inst_0f388x[] = {
128238166Sjhb/*80*/	{ "",	   TRUE,  SDEP,  op2(E, Rq),  "invept" },
129238166Sjhb/*81*/	{ "",	   TRUE,  SDEP,  op2(E, Rq),  "invvpid" },
130255192Sjhb/*82*/	{ "",	   TRUE,  SDEP,  op2(E, Rq),  "invpcid" },
131238166Sjhb/*83*/	{ "",	   FALSE, NONE,  0,	      0 },
132238166Sjhb/*84*/	{ "",	   FALSE, NONE,  0,	      0 },
133238166Sjhb/*85*/	{ "",	   FALSE, NONE,  0,	      0 },
134238166Sjhb/*86*/	{ "",	   FALSE, NONE,  0,	      0 },
135238166Sjhb/*87*/	{ "",	   FALSE, NONE,  0,	      0 },
136238166Sjhb
137238166Sjhb/*88*/	{ "",	   FALSE, NONE,  0,	      0 },
138238166Sjhb/*89*/	{ "",	   FALSE, NONE,  0,	      0 },
139238166Sjhb/*8a*/	{ "",	   FALSE, NONE,  0,	      0 },
140238166Sjhb/*8b*/	{ "",	   FALSE, NONE,  0,	      0 },
141238166Sjhb/*8c*/	{ "",	   FALSE, NONE,  0,	      0 },
142238166Sjhb/*8d*/	{ "",	   FALSE, NONE,  0,	      0 },
143238166Sjhb/*8e*/	{ "",	   FALSE, NONE,  0,	      0 },
144238166Sjhb/*8f*/	{ "",	   FALSE, NONE,  0,	      0 },
145238166Sjhb};
146238166Sjhb
147238166Sjhbstatic const struct inst * const db_inst_0f38[] = {
148238166Sjhb	0,
149238166Sjhb	0,
150238166Sjhb	0,
151238166Sjhb	0,
152238166Sjhb	0,
153238166Sjhb	0,
154238166Sjhb	0,
155238166Sjhb	0,
156238166Sjhb	db_inst_0f388x,
157238166Sjhb	0,
158238166Sjhb	0,
159238166Sjhb	0,
160238166Sjhb	0,
161238166Sjhb	0,
162238166Sjhb	0,
163238166Sjhb	0
164238166Sjhb};
165238166Sjhb
16614887Swollmanstatic const char * const db_Grp6[] = {
1674Srgrimes	"sldt",
1684Srgrimes	"str",
1694Srgrimes	"lldt",
1704Srgrimes	"ltr",
1714Srgrimes	"verr",
1724Srgrimes	"verw",
1734Srgrimes	"",
1744Srgrimes	""
1754Srgrimes};
1764Srgrimes
17714887Swollmanstatic const char * const db_Grp7[] = {
1784Srgrimes	"sgdt",
1794Srgrimes	"sidt",
1804Srgrimes	"lgdt",
1814Srgrimes	"lidt",
1824Srgrimes	"smsw",
1834Srgrimes	"",
1844Srgrimes	"lmsw",
1854Srgrimes	"invlpg"
1864Srgrimes};
1874Srgrimes
18814887Swollmanstatic const char * const db_Grp8[] = {
1894Srgrimes	"",
1904Srgrimes	"",
1914Srgrimes	"",
1924Srgrimes	"",
1934Srgrimes	"bt",
1944Srgrimes	"bts",
1954Srgrimes	"btr",
1964Srgrimes	"btc"
1974Srgrimes};
1984Srgrimes
19921277Sbdestatic const char * const db_Grp9[] = {
20021277Sbde	"",
20121277Sbde	"cmpxchg8b",
20221277Sbde	"",
20321277Sbde	"",
20421277Sbde	"",
20521277Sbde	"",
206238166Sjhb	"vmptrld",
207238166Sjhb	"vmptrst"
20821277Sbde};
20921277Sbde
210181606Sjhbstatic const char * const db_Grp15[] = {
211181606Sjhb	"fxsave",
212181606Sjhb	"fxrstor",
213181606Sjhb	"ldmxcsr",
214181606Sjhb	"stmxcsr",
215238109Sjhb	"xsave",
216238109Sjhb	"xrstor",
217238109Sjhb	"xsaveopt",
218181606Sjhb	"clflush"
219181606Sjhb};
220181606Sjhb
221181606Sjhbstatic const char * const db_Grp15b[] = {
222181606Sjhb	"",
223181606Sjhb	"",
224181606Sjhb	"",
225181606Sjhb	"",
226181606Sjhb	"",
227181606Sjhb	"lfence",
228181606Sjhb	"mfence",
229181606Sjhb	"sfence"
230181606Sjhb};
231181606Sjhb
23214887Swollmanstatic const struct inst db_inst_0f0x[] = {
23317109Sbde/*00*/	{ "",	   TRUE,  NONE,  op1(Ew),     db_Grp6 },
23417109Sbde/*01*/	{ "",	   TRUE,  NONE,  op1(Ew),     db_Grp7 },
2354Srgrimes/*02*/	{ "lar",   TRUE,  LONG,  op2(E,R),    0 },
2364Srgrimes/*03*/	{ "lsl",   TRUE,  LONG,  op2(E,R),    0 },
2374Srgrimes/*04*/	{ "",      FALSE, NONE,  0,	      0 },
238181606Sjhb/*05*/	{ "syscall",FALSE,NONE,  0,	      0 },
2394Srgrimes/*06*/	{ "clts",  FALSE, NONE,  0,	      0 },
240181606Sjhb/*07*/	{ "sysret",FALSE, NONE,  0,	      0 },
2414Srgrimes
2424Srgrimes/*08*/	{ "invd",  FALSE, NONE,  0,	      0 },
2434Srgrimes/*09*/	{ "wbinvd",FALSE, NONE,  0,	      0 },
2444Srgrimes/*0a*/	{ "",      FALSE, NONE,  0,	      0 },
2454Srgrimes/*0b*/	{ "",      FALSE, NONE,  0,	      0 },
2464Srgrimes/*0c*/	{ "",      FALSE, NONE,  0,	      0 },
2474Srgrimes/*0d*/	{ "",      FALSE, NONE,  0,	      0 },
2484Srgrimes/*0e*/	{ "",      FALSE, NONE,  0,	      0 },
2494Srgrimes/*0f*/	{ "",      FALSE, NONE,  0,	      0 },
2504Srgrimes};
2514Srgrimes
25217109Sbdestatic const struct inst db_inst_0f2x[] = {
25321277Sbde/*20*/	{ "mov",   TRUE,  LONG,  op2(CR,El),  0 },
25421277Sbde/*21*/	{ "mov",   TRUE,  LONG,  op2(DR,El),  0 },
25521277Sbde/*22*/	{ "mov",   TRUE,  LONG,  op2(El,CR),  0 },
25621277Sbde/*23*/	{ "mov",   TRUE,  LONG,  op2(El,DR),  0 },
25721277Sbde/*24*/	{ "mov",   TRUE,  LONG,  op2(TR,El),  0 },
2584Srgrimes/*25*/	{ "",      FALSE, NONE,  0,	      0 },
25921277Sbde/*26*/	{ "mov",   TRUE,  LONG,  op2(El,TR),  0 },
2604Srgrimes/*27*/	{ "",      FALSE, NONE,  0,	      0 },
2614Srgrimes
2624Srgrimes/*28*/	{ "",      FALSE, NONE,  0,	      0 },
2634Srgrimes/*29*/	{ "",      FALSE, NONE,  0,	      0 },
2644Srgrimes/*2a*/	{ "",      FALSE, NONE,  0,	      0 },
2654Srgrimes/*2b*/	{ "",      FALSE, NONE,  0,	      0 },
2664Srgrimes/*2c*/	{ "",      FALSE, NONE,  0,	      0 },
2674Srgrimes/*2d*/	{ "",      FALSE, NONE,  0,	      0 },
2684Srgrimes/*2e*/	{ "",      FALSE, NONE,  0,	      0 },
2694Srgrimes/*2f*/	{ "",      FALSE, NONE,  0,	      0 },
2704Srgrimes};
2714Srgrimes
27214887Swollmanstatic const struct inst db_inst_0f3x[] = {
27314887Swollman/*30*/	{ "wrmsr", FALSE, NONE,  0,	      0 },
27414887Swollman/*31*/	{ "rdtsc", FALSE, NONE,  0,	      0 },
27514887Swollman/*32*/	{ "rdmsr", FALSE, NONE,  0,	      0 },
27614887Swollman/*33*/	{ "rdpmc", FALSE, NONE,  0,	      0 },
277181606Sjhb/*34*/	{ "sysenter",FALSE,NONE,  0,	      0 },
278181606Sjhb/*35*/	{ "sysexit",FALSE,NONE,  0,	      0 },
27914887Swollman/*36*/	{ "",	   FALSE, NONE,  0,	      0 },
280181606Sjhb/*37*/	{ "getsec",FALSE, NONE,  0,	      0 },
28114887Swollman
282238166Sjhb/*38*/	{ "",	   FALSE, ESC,  0,	      db_inst_0f38 },
28314887Swollman/*39*/	{ "",	   FALSE, NONE,  0,	      0 },
28414887Swollman/*3a*/	{ "",	   FALSE, NONE,  0,	      0 },
28514887Swollman/*3b*/	{ "",	   FALSE, NONE,  0,	      0 },
28614887Swollman/*3c*/	{ "",	   FALSE, NONE,  0,	      0 },
28714887Swollman/*3d*/	{ "",	   FALSE, NONE,  0,	      0 },
28814887Swollman/*3e*/	{ "",	   FALSE, NONE,  0,	      0 },
28914887Swollman/*3f*/	{ "",	   FALSE, NONE,  0,	      0 },
29014887Swollman};
29114887Swollman
292144354Speterstatic const struct inst db_inst_0f4x[] = {
293144354Speter/*40*/	{ "cmovo",  TRUE, NONE,  op2(E, R),   0 },
294144354Speter/*41*/	{ "cmovno", TRUE, NONE,  op2(E, R),   0 },
295144354Speter/*42*/	{ "cmovb",  TRUE, NONE,  op2(E, R),   0 },
296144354Speter/*43*/	{ "cmovnb", TRUE, NONE,  op2(E, R),   0 },
297144354Speter/*44*/	{ "cmovz",  TRUE, NONE,  op2(E, R),   0 },
298144354Speter/*45*/	{ "cmovnz", TRUE, NONE,  op2(E, R),   0 },
299144354Speter/*46*/	{ "cmovbe", TRUE, NONE,  op2(E, R),   0 },
300144354Speter/*47*/	{ "cmovnbe",TRUE, NONE,  op2(E, R),   0 },
301144354Speter
302144354Speter/*48*/	{ "cmovs",  TRUE, NONE,  op2(E, R),   0 },
303144354Speter/*49*/	{ "cmovns", TRUE, NONE,  op2(E, R),   0 },
304144354Speter/*4a*/	{ "cmovp",  TRUE, NONE,  op2(E, R),   0 },
305144354Speter/*4b*/	{ "cmovnp", TRUE, NONE,  op2(E, R),   0 },
306144354Speter/*4c*/	{ "cmovl",  TRUE, NONE,  op2(E, R),   0 },
307144354Speter/*4d*/	{ "cmovnl", TRUE, NONE,  op2(E, R),   0 },
308144354Speter/*4e*/	{ "cmovle", TRUE, NONE,  op2(E, R),   0 },
309144354Speter/*4f*/	{ "cmovnle",TRUE, NONE,  op2(E, R),   0 },
310144354Speter};
311144354Speter
312238166Sjhbstatic const struct inst db_inst_0f7x[] = {
313238166Sjhb/*70*/	{ "",	   FALSE, NONE,  0,	      0 },
314238166Sjhb/*71*/	{ "",	   FALSE, NONE,  0,	      0 },
315238166Sjhb/*72*/	{ "",	   FALSE, NONE,  0,	      0 },
316238166Sjhb/*73*/	{ "",	   FALSE, NONE,  0,	      0 },
317238166Sjhb/*74*/	{ "",	   FALSE, NONE,  0,	      0 },
318238166Sjhb/*75*/	{ "",	   FALSE, NONE,  0,	      0 },
319238166Sjhb/*76*/	{ "",	   FALSE, NONE,  0,	      0 },
320238166Sjhb/*77*/	{ "",	   FALSE, NONE,  0,	      0 },
321238166Sjhb
322238166Sjhb/*78*/	{ "vmread", TRUE, NONE,  op2(Rq, E),  0 },
323238166Sjhb/*79*/	{ "vmwrite",TRUE, NONE,  op2(E, Rq),  0 },
324238166Sjhb/*7a*/	{ "",	   FALSE, NONE,  0,	      0 },
325238166Sjhb/*7b*/	{ "",	   FALSE, NONE,  0,	      0 },
326238166Sjhb/*7c*/	{ "",	   FALSE, NONE,  0,	      0 },
327238166Sjhb/*7d*/	{ "",	   FALSE, NONE,  0,	      0 },
328238166Sjhb/*7e*/	{ "",	   FALSE, NONE,  0,	      0 },
329238166Sjhb/*7f*/	{ "",	   FALSE, NONE,  0,	      0 },
330238166Sjhb};
331238166Sjhb
33217109Sbdestatic const struct inst db_inst_0f8x[] = {
3334Srgrimes/*80*/	{ "jo",    FALSE, NONE,  op1(Dl),     0 },
3344Srgrimes/*81*/	{ "jno",   FALSE, NONE,  op1(Dl),     0 },
3354Srgrimes/*82*/	{ "jb",    FALSE, NONE,  op1(Dl),     0 },
3364Srgrimes/*83*/	{ "jnb",   FALSE, NONE,  op1(Dl),     0 },
3374Srgrimes/*84*/	{ "jz",    FALSE, NONE,  op1(Dl),     0 },
3384Srgrimes/*85*/	{ "jnz",   FALSE, NONE,  op1(Dl),     0 },
3394Srgrimes/*86*/	{ "jbe",   FALSE, NONE,  op1(Dl),     0 },
3404Srgrimes/*87*/	{ "jnbe",  FALSE, NONE,  op1(Dl),     0 },
3414Srgrimes
3424Srgrimes/*88*/	{ "js",    FALSE, NONE,  op1(Dl),     0 },
3434Srgrimes/*89*/	{ "jns",   FALSE, NONE,  op1(Dl),     0 },
3444Srgrimes/*8a*/	{ "jp",    FALSE, NONE,  op1(Dl),     0 },
3454Srgrimes/*8b*/	{ "jnp",   FALSE, NONE,  op1(Dl),     0 },
3464Srgrimes/*8c*/	{ "jl",    FALSE, NONE,  op1(Dl),     0 },
3474Srgrimes/*8d*/	{ "jnl",   FALSE, NONE,  op1(Dl),     0 },
3484Srgrimes/*8e*/	{ "jle",   FALSE, NONE,  op1(Dl),     0 },
3494Srgrimes/*8f*/	{ "jnle",  FALSE, NONE,  op1(Dl),     0 },
3504Srgrimes};
3514Srgrimes
35217109Sbdestatic const struct inst db_inst_0f9x[] = {
3534Srgrimes/*90*/	{ "seto",  TRUE,  NONE,  op1(Eb),     0 },
3544Srgrimes/*91*/	{ "setno", TRUE,  NONE,  op1(Eb),     0 },
3554Srgrimes/*92*/	{ "setb",  TRUE,  NONE,  op1(Eb),     0 },
3564Srgrimes/*93*/	{ "setnb", TRUE,  NONE,  op1(Eb),     0 },
3574Srgrimes/*94*/	{ "setz",  TRUE,  NONE,  op1(Eb),     0 },
3584Srgrimes/*95*/	{ "setnz", TRUE,  NONE,  op1(Eb),     0 },
3594Srgrimes/*96*/	{ "setbe", TRUE,  NONE,  op1(Eb),     0 },
3604Srgrimes/*97*/	{ "setnbe",TRUE,  NONE,  op1(Eb),     0 },
3614Srgrimes
3624Srgrimes/*98*/	{ "sets",  TRUE,  NONE,  op1(Eb),     0 },
3634Srgrimes/*99*/	{ "setns", TRUE,  NONE,  op1(Eb),     0 },
3644Srgrimes/*9a*/	{ "setp",  TRUE,  NONE,  op1(Eb),     0 },
3654Srgrimes/*9b*/	{ "setnp", TRUE,  NONE,  op1(Eb),     0 },
3664Srgrimes/*9c*/	{ "setl",  TRUE,  NONE,  op1(Eb),     0 },
3674Srgrimes/*9d*/	{ "setnl", TRUE,  NONE,  op1(Eb),     0 },
3684Srgrimes/*9e*/	{ "setle", TRUE,  NONE,  op1(Eb),     0 },
3694Srgrimes/*9f*/	{ "setnle",TRUE,  NONE,  op1(Eb),     0 },
3704Srgrimes};
3714Srgrimes
37217109Sbdestatic const struct inst db_inst_0fax[] = {
3734Srgrimes/*a0*/	{ "push",  FALSE, NONE,  op1(Si),     0 },
3744Srgrimes/*a1*/	{ "pop",   FALSE, NONE,  op1(Si),     0 },
37521277Sbde/*a2*/	{ "cpuid", FALSE, NONE,  0,	      0 },
37621277Sbde/*a3*/	{ "bt",    TRUE,  LONG,  op2(R,E),    0 },
37717109Sbde/*a4*/	{ "shld",  TRUE,  LONG,  op3(Ib,R,E), 0 },
37817109Sbde/*a5*/	{ "shld",  TRUE,  LONG,  op3(CL,R,E), 0 },
3794Srgrimes/*a6*/	{ "",      FALSE, NONE,  0,	      0 },
3804Srgrimes/*a7*/	{ "",      FALSE, NONE,  0,	      0 },
3814Srgrimes
3824Srgrimes/*a8*/	{ "push",  FALSE, NONE,  op1(Si),     0 },
3834Srgrimes/*a9*/	{ "pop",   FALSE, NONE,  op1(Si),     0 },
38421277Sbde/*aa*/	{ "rsm",   FALSE, NONE,  0,	      0 },
38521277Sbde/*ab*/	{ "bts",   TRUE,  LONG,  op2(R,E),    0 },
38617109Sbde/*ac*/	{ "shrd",  TRUE,  LONG,  op3(Ib,R,E), 0 },
38717109Sbde/*ad*/	{ "shrd",  TRUE,  LONG,  op3(CL,R,E), 0 },
388181606Sjhb/*ae*/	{ "",      TRUE,  LONG,  op1(E),      db_Grp15 },
389181606Sjhb/*af*/	{ "imul",  TRUE,  LONG,  op2(E,R),    0 },
3904Srgrimes};
3914Srgrimes
39217109Sbdestatic const struct inst db_inst_0fbx[] = {
39321277Sbde/*b0*/	{ "cmpxchg",TRUE, BYTE,	 op2(R, E),   0 },
39421277Sbde/*b0*/	{ "cmpxchg",TRUE, LONG,	 op2(R, E),   0 },
3954Srgrimes/*b2*/	{ "lss",   TRUE,  LONG,  op2(E, R),   0 },
39621277Sbde/*b3*/	{ "btr",   TRUE,  LONG,  op2(R, E),   0 },
3974Srgrimes/*b4*/	{ "lfs",   TRUE,  LONG,  op2(E, R),   0 },
3984Srgrimes/*b5*/	{ "lgs",   TRUE,  LONG,  op2(E, R),   0 },
39921277Sbde/*b6*/	{ "movzb", TRUE,  LONG,  op2(Eb, R),  0 },
40021277Sbde/*b7*/	{ "movzw", TRUE,  LONG,  op2(Ew, R),  0 },
4014Srgrimes
4024Srgrimes/*b8*/	{ "",      FALSE, NONE,  0,	      0 },
4034Srgrimes/*b9*/	{ "",      FALSE, NONE,  0,	      0 },
40417109Sbde/*ba*/	{ "",      TRUE,  LONG,  op2(Ib, E),  db_Grp8 },
4054Srgrimes/*bb*/	{ "btc",   TRUE,  LONG,  op2(R, E),   0 },
4064Srgrimes/*bc*/	{ "bsf",   TRUE,  LONG,  op2(E, R),   0 },
4074Srgrimes/*bd*/	{ "bsr",   TRUE,  LONG,  op2(E, R),   0 },
40821277Sbde/*be*/	{ "movsb", TRUE,  LONG,  op2(Eb, R),  0 },
40921277Sbde/*bf*/	{ "movsw", TRUE,  LONG,  op2(Ew, R),  0 },
4104Srgrimes};
4114Srgrimes
41217109Sbdestatic const struct inst db_inst_0fcx[] = {
4134Srgrimes/*c0*/	{ "xadd",  TRUE,  BYTE,	 op2(R, E),   0 },
4144Srgrimes/*c1*/	{ "xadd",  TRUE,  LONG,	 op2(R, E),   0 },
4154Srgrimes/*c2*/	{ "",	   FALSE, NONE,	 0,	      0 },
4164Srgrimes/*c3*/	{ "",	   FALSE, NONE,	 0,	      0 },
4174Srgrimes/*c4*/	{ "",	   FALSE, NONE,	 0,	      0 },
4184Srgrimes/*c5*/	{ "",	   FALSE, NONE,	 0,	      0 },
4194Srgrimes/*c6*/	{ "",	   FALSE, NONE,	 0,	      0 },
42021277Sbde/*c7*/	{ "",	   TRUE,  NONE,  op1(E),      db_Grp9 },
42121277Sbde/*c8*/	{ "bswap", FALSE, LONG,  op1(Ril),    0 },
42221277Sbde/*c9*/	{ "bswap", FALSE, LONG,  op1(Ril),    0 },
42321277Sbde/*ca*/	{ "bswap", FALSE, LONG,  op1(Ril),    0 },
42421277Sbde/*cb*/	{ "bswap", FALSE, LONG,  op1(Ril),    0 },
42521277Sbde/*cc*/	{ "bswap", FALSE, LONG,  op1(Ril),    0 },
42621277Sbde/*cd*/	{ "bswap", FALSE, LONG,  op1(Ril),    0 },
42721277Sbde/*ce*/	{ "bswap", FALSE, LONG,  op1(Ril),    0 },
42821277Sbde/*cf*/	{ "bswap", FALSE, LONG,  op1(Ril),    0 },
4294Srgrimes};
4304Srgrimes
43114887Swollmanstatic const struct inst * const db_inst_0f[] = {
4324Srgrimes	db_inst_0f0x,
4334Srgrimes	0,
4344Srgrimes	db_inst_0f2x,
43514887Swollman	db_inst_0f3x,
436144354Speter	db_inst_0f4x,
4374Srgrimes	0,
4384Srgrimes	0,
439238166Sjhb	db_inst_0f7x,
4404Srgrimes	db_inst_0f8x,
4414Srgrimes	db_inst_0f9x,
4424Srgrimes	db_inst_0fax,
4434Srgrimes	db_inst_0fbx,
4444Srgrimes	db_inst_0fcx,
4454Srgrimes	0,
44621277Sbde	0,
4474Srgrimes	0
4484Srgrimes};
4494Srgrimes
45014887Swollmanstatic const char * const db_Esc92[] = {
4514Srgrimes	"fnop",	"",	"",	"",	"",	"",	"",	""
4524Srgrimes};
45314887Swollmanstatic const char * const db_Esc94[] = {
4544Srgrimes	"fchs",	"fabs",	"",	"",	"ftst",	"fxam",	"",	""
4554Srgrimes};
45617109Sbdestatic const char * const db_Esc95[] = {
4574Srgrimes	"fld1",	"fldl2t","fldl2e","fldpi","fldlg2","fldln2","fldz",""
4584Srgrimes};
45917109Sbdestatic const char * const db_Esc96[] = {
4604Srgrimes	"f2xm1","fyl2x","fptan","fpatan","fxtract","fprem1","fdecstp",
4614Srgrimes	"fincstp"
4624Srgrimes};
46314887Swollmanstatic const char * const db_Esc97[] = {
4644Srgrimes	"fprem","fyl2xp1","fsqrt","fsincos","frndint","fscale","fsin","fcos"
4654Srgrimes};
4664Srgrimes
46721277Sbdestatic const char * const db_Esca5[] = {
4684Srgrimes	"",	"fucompp","",	"",	"",	"",	"",	""
4694Srgrimes};
4704Srgrimes
47117109Sbdestatic const char * const db_Escb4[] = {
47221277Sbde	"fneni","fndisi",	"fnclex","fninit","fsetpm",	"",	"",	""
4734Srgrimes};
4744Srgrimes
47514887Swollmanstatic const char * const db_Esce3[] = {
4764Srgrimes	"",	"fcompp","",	"",	"",	"",	"",	""
4774Srgrimes};
4784Srgrimes
47917109Sbdestatic const char * const db_Escf4[] = {
4804Srgrimes	"fnstsw","",	"",	"",	"",	"",	"",	""
4814Srgrimes};
4824Srgrimes
48314887Swollmanstatic const struct finst db_Esc8[] = {
4844Srgrimes/*0*/	{ "fadd",   SNGL,  op2(STI,ST),	0 },
4854Srgrimes/*1*/	{ "fmul",   SNGL,  op2(STI,ST),	0 },
4864Srgrimes/*2*/	{ "fcom",   SNGL,  op2(STI,ST),	0 },
4874Srgrimes/*3*/	{ "fcomp",  SNGL,  op2(STI,ST),	0 },
4884Srgrimes/*4*/	{ "fsub",   SNGL,  op2(STI,ST),	0 },
4894Srgrimes/*5*/	{ "fsubr",  SNGL,  op2(STI,ST),	0 },
4904Srgrimes/*6*/	{ "fdiv",   SNGL,  op2(STI,ST),	0 },
4914Srgrimes/*7*/	{ "fdivr",  SNGL,  op2(STI,ST),	0 },
4924Srgrimes};
4934Srgrimes
49414887Swollmanstatic const struct finst db_Esc9[] = {
4954Srgrimes/*0*/	{ "fld",    SNGL,  op1(STI),	0 },
4964Srgrimes/*1*/	{ "",       NONE,  op1(STI),	"fxch" },
49717109Sbde/*2*/	{ "fst",    SNGL,  op1(X),	db_Esc92 },
49821277Sbde/*3*/	{ "fstp",   SNGL,  0,		0 },
49917109Sbde/*4*/	{ "fldenv", NONE,  op1(X),	db_Esc94 },
50017109Sbde/*5*/	{ "fldcw",  NONE,  op1(X),	db_Esc95 },
50117109Sbde/*6*/	{ "fnstenv",NONE,  op1(X),	db_Esc96 },
50217109Sbde/*7*/	{ "fnstcw", NONE,  op1(X),	db_Esc97 },
5034Srgrimes};
5044Srgrimes
50514887Swollmanstatic const struct finst db_Esca[] = {
50621277Sbde/*0*/	{ "fiadd",  LONG,  0,		0 },
50721277Sbde/*1*/	{ "fimul",  LONG,  0,		0 },
50821277Sbde/*2*/	{ "ficom",  LONG,  0,		0 },
50921277Sbde/*3*/	{ "ficomp", LONG,  0,		0 },
51021277Sbde/*4*/	{ "fisub",  LONG,  0,		0 },
51121277Sbde/*5*/	{ "fisubr", LONG,  op1(X),	db_Esca5 },
51221277Sbde/*6*/	{ "fidiv",  LONG,  0,		0 },
51321277Sbde/*7*/	{ "fidivr", LONG,  0,		0 }
5144Srgrimes};
5154Srgrimes
51614887Swollmanstatic const struct finst db_Escb[] = {
51721277Sbde/*0*/	{ "fild",   LONG,  0,		0 },
5184Srgrimes/*1*/	{ "",       NONE,  0,		0 },
51921277Sbde/*2*/	{ "fist",   LONG,  0,		0 },
52021277Sbde/*3*/	{ "fistp",  LONG,  0,		0 },
52117109Sbde/*4*/	{ "",       WORD,  op1(X),	db_Escb4 },
5224Srgrimes/*5*/	{ "fld",    EXTR,  0,		0 },
5234Srgrimes/*6*/	{ "",       WORD,  0,		0 },
5244Srgrimes/*7*/	{ "fstp",   EXTR,  0,		0 },
5254Srgrimes};
5264Srgrimes
52714887Swollmanstatic const struct finst db_Escc[] = {
5284Srgrimes/*0*/	{ "fadd",   DBLR,  op2(ST,STI),	0 },
5294Srgrimes/*1*/	{ "fmul",   DBLR,  op2(ST,STI),	0 },
53021277Sbde/*2*/	{ "fcom",   DBLR,  0,		0 },
53121277Sbde/*3*/	{ "fcomp",  DBLR,  0,		0 },
5324Srgrimes/*4*/	{ "fsub",   DBLR,  op2(ST,STI),	"fsubr" },
5334Srgrimes/*5*/	{ "fsubr",  DBLR,  op2(ST,STI),	"fsub" },
5344Srgrimes/*6*/	{ "fdiv",   DBLR,  op2(ST,STI),	"fdivr" },
5354Srgrimes/*7*/	{ "fdivr",  DBLR,  op2(ST,STI),	"fdiv" },
5364Srgrimes};
5374Srgrimes
53814887Swollmanstatic const struct finst db_Escd[] = {
5394Srgrimes/*0*/	{ "fld",    DBLR,  op1(STI),	"ffree" },
5404Srgrimes/*1*/	{ "",       NONE,  0,		0 },
5414Srgrimes/*2*/	{ "fst",    DBLR,  op1(STI),	0 },
5424Srgrimes/*3*/	{ "fstp",   DBLR,  op1(STI),	0 },
5434Srgrimes/*4*/	{ "frstor", NONE,  op1(STI),	"fucom" },
5444Srgrimes/*5*/	{ "",       NONE,  op1(STI),	"fucomp" },
5454Srgrimes/*6*/	{ "fnsave", NONE,  0,		0 },
5464Srgrimes/*7*/	{ "fnstsw", NONE,  0,		0 },
5474Srgrimes};
5484Srgrimes
54914887Swollmanstatic const struct finst db_Esce[] = {
55021277Sbde/*0*/	{ "fiadd",  WORD,  op2(ST,STI),	"faddp" },
55121277Sbde/*1*/	{ "fimul",  WORD,  op2(ST,STI),	"fmulp" },
55221277Sbde/*2*/	{ "ficom",  WORD,  0,		0 },
55321277Sbde/*3*/	{ "ficomp", WORD,  op1(X),	db_Esce3 },
55421277Sbde/*4*/	{ "fisub",  WORD,  op2(ST,STI),	"fsubrp" },
55521277Sbde/*5*/	{ "fisubr", WORD,  op2(ST,STI),	"fsubp" },
55621277Sbde/*6*/	{ "fidiv",  WORD,  op2(ST,STI),	"fdivrp" },
55721277Sbde/*7*/	{ "fidivr", WORD,  op2(ST,STI),	"fdivp" },
5584Srgrimes};
5594Srgrimes
56014887Swollmanstatic const struct finst db_Escf[] = {
56121277Sbde/*0*/	{ "fild",   WORD,  0,		0 },
56221277Sbde/*1*/	{ "",       NONE,  0,		0 },
56321277Sbde/*2*/	{ "fist",   WORD,  0,		0 },
56421277Sbde/*3*/	{ "fistp",  WORD,  0,		0 },
56517109Sbde/*4*/	{ "fbld",   NONE,  op1(XA),	db_Escf4 },
56621277Sbde/*5*/	{ "fild",   QUAD,  0,		0 },
5674Srgrimes/*6*/	{ "fbstp",  NONE,  0,		0 },
56821277Sbde/*7*/	{ "fistp",  QUAD,  0,		0 },
5694Srgrimes};
5704Srgrimes
57117109Sbdestatic const struct finst * const db_Esc_inst[] = {
5724Srgrimes	db_Esc8, db_Esc9, db_Esca, db_Escb,
5734Srgrimes	db_Escc, db_Escd, db_Esce, db_Escf
5744Srgrimes};
5754Srgrimes
57614887Swollmanstatic const char * const db_Grp1[] = {
5774Srgrimes	"add",
5784Srgrimes	"or",
5794Srgrimes	"adc",
5804Srgrimes	"sbb",
5814Srgrimes	"and",
5824Srgrimes	"sub",
5834Srgrimes	"xor",
5844Srgrimes	"cmp"
5854Srgrimes};
5864Srgrimes
58714887Swollmanstatic const char * const db_Grp2[] = {
5884Srgrimes	"rol",
5894Srgrimes	"ror",
5904Srgrimes	"rcl",
5914Srgrimes	"rcr",
5924Srgrimes	"shl",
5934Srgrimes	"shr",
5944Srgrimes	"shl",
5954Srgrimes	"sar"
5964Srgrimes};
5974Srgrimes
59814887Swollmanstatic const struct inst db_Grp3[] = {
5994Srgrimes	{ "test",  TRUE, NONE, op2(I,E), 0 },
6004Srgrimes	{ "test",  TRUE, NONE, op2(I,E), 0 },
6014Srgrimes	{ "not",   TRUE, NONE, op1(E),   0 },
6024Srgrimes	{ "neg",   TRUE, NONE, op1(E),   0 },
6034Srgrimes	{ "mul",   TRUE, NONE, op2(E,A), 0 },
6044Srgrimes	{ "imul",  TRUE, NONE, op2(E,A), 0 },
6054Srgrimes	{ "div",   TRUE, NONE, op2(E,A), 0 },
6064Srgrimes	{ "idiv",  TRUE, NONE, op2(E,A), 0 },
6074Srgrimes};
6084Srgrimes
60917109Sbdestatic const struct inst db_Grp4[] = {
6104Srgrimes	{ "inc",   TRUE, BYTE, op1(E),   0 },
6114Srgrimes	{ "dec",   TRUE, BYTE, op1(E),   0 },
6124Srgrimes	{ "",      TRUE, NONE, 0,	 0 },
6134Srgrimes	{ "",      TRUE, NONE, 0,	 0 },
6144Srgrimes	{ "",      TRUE, NONE, 0,	 0 },
6154Srgrimes	{ "",      TRUE, NONE, 0,	 0 },
6164Srgrimes	{ "",      TRUE, NONE, 0,	 0 },
6174Srgrimes	{ "",      TRUE, NONE, 0,	 0 }
6184Srgrimes};
6194Srgrimes
62017109Sbdestatic const struct inst db_Grp5[] = {
6214Srgrimes	{ "inc",   TRUE, LONG, op1(E),   0 },
6224Srgrimes	{ "dec",   TRUE, LONG, op1(E),   0 },
62321277Sbde	{ "call",  TRUE, LONG, op1(Eind),0 },
62421277Sbde	{ "lcall", TRUE, LONG, op1(Eind),0 },
62521277Sbde	{ "jmp",   TRUE, LONG, op1(Eind),0 },
62621277Sbde	{ "ljmp",  TRUE, LONG, op1(Eind),0 },
6274Srgrimes	{ "push",  TRUE, LONG, op1(E),   0 },
6284Srgrimes	{ "",      TRUE, NONE, 0,	 0 }
6294Srgrimes};
6304Srgrimes
63114887Swollmanstatic const struct inst db_inst_table[256] = {
6324Srgrimes/*00*/	{ "add",   TRUE,  BYTE,  op2(R, E),  0 },
6334Srgrimes/*01*/	{ "add",   TRUE,  LONG,  op2(R, E),  0 },
6344Srgrimes/*02*/	{ "add",   TRUE,  BYTE,  op2(E, R),  0 },
6354Srgrimes/*03*/	{ "add",   TRUE,  LONG,  op2(E, R),  0 },
63621277Sbde/*04*/	{ "add",   FALSE, BYTE,  op2(I, A),  0 },
6374Srgrimes/*05*/	{ "add",   FALSE, LONG,  op2(Is, A), 0 },
6384Srgrimes/*06*/	{ "push",  FALSE, NONE,  op1(Si),    0 },
6394Srgrimes/*07*/	{ "pop",   FALSE, NONE,  op1(Si),    0 },
6404Srgrimes
6414Srgrimes/*08*/	{ "or",    TRUE,  BYTE,  op2(R, E),  0 },
6424Srgrimes/*09*/	{ "or",    TRUE,  LONG,  op2(R, E),  0 },
6434Srgrimes/*0a*/	{ "or",    TRUE,  BYTE,  op2(E, R),  0 },
6444Srgrimes/*0b*/	{ "or",    TRUE,  LONG,  op2(E, R),  0 },
6454Srgrimes/*0c*/	{ "or",    FALSE, BYTE,  op2(I, A),  0 },
6464Srgrimes/*0d*/	{ "or",    FALSE, LONG,  op2(I, A),  0 },
6474Srgrimes/*0e*/	{ "push",  FALSE, NONE,  op1(Si),    0 },
648238166Sjhb/*0f*/	{ "",      FALSE, ESC,   0,	     db_inst_0f },
6494Srgrimes
6504Srgrimes/*10*/	{ "adc",   TRUE,  BYTE,  op2(R, E),  0 },
6514Srgrimes/*11*/	{ "adc",   TRUE,  LONG,  op2(R, E),  0 },
6524Srgrimes/*12*/	{ "adc",   TRUE,  BYTE,  op2(E, R),  0 },
6534Srgrimes/*13*/	{ "adc",   TRUE,  LONG,  op2(E, R),  0 },
65421277Sbde/*14*/	{ "adc",   FALSE, BYTE,  op2(I, A),  0 },
6554Srgrimes/*15*/	{ "adc",   FALSE, LONG,  op2(Is, A), 0 },
6564Srgrimes/*16*/	{ "push",  FALSE, NONE,  op1(Si),    0 },
6574Srgrimes/*17*/	{ "pop",   FALSE, NONE,  op1(Si),    0 },
6584Srgrimes
6594Srgrimes/*18*/	{ "sbb",   TRUE,  BYTE,  op2(R, E),  0 },
6604Srgrimes/*19*/	{ "sbb",   TRUE,  LONG,  op2(R, E),  0 },
6614Srgrimes/*1a*/	{ "sbb",   TRUE,  BYTE,  op2(E, R),  0 },
6624Srgrimes/*1b*/	{ "sbb",   TRUE,  LONG,  op2(E, R),  0 },
66321277Sbde/*1c*/	{ "sbb",   FALSE, BYTE,  op2(I, A),  0 },
6644Srgrimes/*1d*/	{ "sbb",   FALSE, LONG,  op2(Is, A), 0 },
6654Srgrimes/*1e*/	{ "push",  FALSE, NONE,  op1(Si),    0 },
6664Srgrimes/*1f*/	{ "pop",   FALSE, NONE,  op1(Si),    0 },
6674Srgrimes
6684Srgrimes/*20*/	{ "and",   TRUE,  BYTE,  op2(R, E),  0 },
6694Srgrimes/*21*/	{ "and",   TRUE,  LONG,  op2(R, E),  0 },
6704Srgrimes/*22*/	{ "and",   TRUE,  BYTE,  op2(E, R),  0 },
6714Srgrimes/*23*/	{ "and",   TRUE,  LONG,  op2(E, R),  0 },
6724Srgrimes/*24*/	{ "and",   FALSE, BYTE,  op2(I, A),  0 },
6734Srgrimes/*25*/	{ "and",   FALSE, LONG,  op2(I, A),  0 },
6744Srgrimes/*26*/	{ "",      FALSE, NONE,  0,	     0 },
67521277Sbde/*27*/	{ "daa",   FALSE, NONE,  0,	     0 },
6764Srgrimes
6774Srgrimes/*28*/	{ "sub",   TRUE,  BYTE,  op2(R, E),  0 },
6784Srgrimes/*29*/	{ "sub",   TRUE,  LONG,  op2(R, E),  0 },
6794Srgrimes/*2a*/	{ "sub",   TRUE,  BYTE,  op2(E, R),  0 },
6804Srgrimes/*2b*/	{ "sub",   TRUE,  LONG,  op2(E, R),  0 },
68121277Sbde/*2c*/	{ "sub",   FALSE, BYTE,  op2(I, A),  0 },
6824Srgrimes/*2d*/	{ "sub",   FALSE, LONG,  op2(Is, A), 0 },
6834Srgrimes/*2e*/	{ "",      FALSE, NONE,  0,	     0 },
6844Srgrimes/*2f*/	{ "das",   FALSE, NONE,  0,	     0 },
6854Srgrimes
6864Srgrimes/*30*/	{ "xor",   TRUE,  BYTE,  op2(R, E),  0 },
6874Srgrimes/*31*/	{ "xor",   TRUE,  LONG,  op2(R, E),  0 },
6884Srgrimes/*32*/	{ "xor",   TRUE,  BYTE,  op2(E, R),  0 },
6894Srgrimes/*33*/	{ "xor",   TRUE,  LONG,  op2(E, R),  0 },
6904Srgrimes/*34*/	{ "xor",   FALSE, BYTE,  op2(I, A),  0 },
6914Srgrimes/*35*/	{ "xor",   FALSE, LONG,  op2(I, A),  0 },
6924Srgrimes/*36*/	{ "",      FALSE, NONE,  0,	     0 },
69321277Sbde/*37*/	{ "aaa",   FALSE, NONE,  0,	     0 },
6944Srgrimes
6954Srgrimes/*38*/	{ "cmp",   TRUE,  BYTE,  op2(R, E),  0 },
6964Srgrimes/*39*/	{ "cmp",   TRUE,  LONG,  op2(R, E),  0 },
6974Srgrimes/*3a*/	{ "cmp",   TRUE,  BYTE,  op2(E, R),  0 },
6984Srgrimes/*3b*/	{ "cmp",   TRUE,  LONG,  op2(E, R),  0 },
69921277Sbde/*3c*/	{ "cmp",   FALSE, BYTE,  op2(I, A),  0 },
7004Srgrimes/*3d*/	{ "cmp",   FALSE, LONG,  op2(Is, A), 0 },
7014Srgrimes/*3e*/	{ "",      FALSE, NONE,  0,	     0 },
7024Srgrimes/*3f*/	{ "aas",   FALSE, NONE,  0,	     0 },
7034Srgrimes
704144353Speter/*40*/	{ "rex",   FALSE, NONE,  0,          0 },
705144353Speter/*41*/	{ "rex.b", FALSE, NONE,  0,          0 },
706144353Speter/*42*/	{ "rex.x", FALSE, NONE,  0,          0 },
707144353Speter/*43*/	{ "rex.xb", FALSE, NONE, 0,          0 },
708144353Speter/*44*/	{ "rex.r", FALSE, NONE,  0,          0 },
709144353Speter/*45*/	{ "rex.rb", FALSE, NONE, 0,          0 },
710144353Speter/*46*/	{ "rex.rx", FALSE, NONE, 0,          0 },
711144353Speter/*47*/	{ "rex.rxb", FALSE, NONE, 0,         0 },
7124Srgrimes
713144353Speter/*48*/	{ "rex.w", FALSE, NONE,  0,          0 },
714144353Speter/*49*/	{ "rex.wb", FALSE, NONE, 0,          0 },
715144353Speter/*4a*/	{ "rex.wx", FALSE, NONE, 0,          0 },
716144353Speter/*4b*/	{ "rex.wxb", FALSE, NONE, 0,         0 },
717144353Speter/*4c*/	{ "rex.wr", FALSE, NONE, 0,          0 },
718144353Speter/*4d*/	{ "rex.wrb", FALSE, NONE, 0,         0 },
719144353Speter/*4e*/	{ "rex.wrx", FALSE, NONE, 0,         0 },
720144353Speter/*4f*/	{ "rex.wrxb", FALSE, NONE, 0,        0 },
7214Srgrimes
7224Srgrimes/*50*/	{ "push",  FALSE, LONG,  op1(Ri),    0 },
7234Srgrimes/*51*/	{ "push",  FALSE, LONG,  op1(Ri),    0 },
7244Srgrimes/*52*/	{ "push",  FALSE, LONG,  op1(Ri),    0 },
7254Srgrimes/*53*/	{ "push",  FALSE, LONG,  op1(Ri),    0 },
7264Srgrimes/*54*/	{ "push",  FALSE, LONG,  op1(Ri),    0 },
7274Srgrimes/*55*/	{ "push",  FALSE, LONG,  op1(Ri),    0 },
7284Srgrimes/*56*/	{ "push",  FALSE, LONG,  op1(Ri),    0 },
7294Srgrimes/*57*/	{ "push",  FALSE, LONG,  op1(Ri),    0 },
7304Srgrimes
7314Srgrimes/*58*/	{ "pop",   FALSE, LONG,  op1(Ri),    0 },
7324Srgrimes/*59*/	{ "pop",   FALSE, LONG,  op1(Ri),    0 },
7334Srgrimes/*5a*/	{ "pop",   FALSE, LONG,  op1(Ri),    0 },
7344Srgrimes/*5b*/	{ "pop",   FALSE, LONG,  op1(Ri),    0 },
7354Srgrimes/*5c*/	{ "pop",   FALSE, LONG,  op1(Ri),    0 },
7364Srgrimes/*5d*/	{ "pop",   FALSE, LONG,  op1(Ri),    0 },
7374Srgrimes/*5e*/	{ "pop",   FALSE, LONG,  op1(Ri),    0 },
7384Srgrimes/*5f*/	{ "pop",   FALSE, LONG,  op1(Ri),    0 },
7394Srgrimes
7404Srgrimes/*60*/	{ "pusha", FALSE, LONG,  0,	     0 },
7414Srgrimes/*61*/	{ "popa",  FALSE, LONG,  0,	     0 },
7424Srgrimes/*62*/  { "bound", TRUE,  LONG,  op2(E, R),  0 },
743144354Speter/*63*/	{ "movslq",  TRUE,  NONE,  op2(EL,R), 0 },
7444Srgrimes
7454Srgrimes/*64*/	{ "",      FALSE, NONE,  0,	     0 },
7464Srgrimes/*65*/	{ "",      FALSE, NONE,  0,	     0 },
7474Srgrimes/*66*/	{ "",      FALSE, NONE,  0,	     0 },
7484Srgrimes/*67*/	{ "",      FALSE, NONE,  0,	     0 },
7494Srgrimes
7504Srgrimes/*68*/	{ "push",  FALSE, LONG,  op1(I),     0 },
7514Srgrimes/*69*/  { "imul",  TRUE,  LONG,  op3(I,E,R), 0 },
75221277Sbde/*6a*/	{ "push",  FALSE, LONG,  op1(Ibs),   0 },
7534Srgrimes/*6b*/  { "imul",  TRUE,  LONG,  op3(Ibs,E,R),0 },
7544Srgrimes/*6c*/	{ "ins",   FALSE, BYTE,  op2(DX, DI), 0 },
7554Srgrimes/*6d*/	{ "ins",   FALSE, LONG,  op2(DX, DI), 0 },
7564Srgrimes/*6e*/	{ "outs",  FALSE, BYTE,  op2(SI, DX), 0 },
7574Srgrimes/*6f*/	{ "outs",  FALSE, LONG,  op2(SI, DX), 0 },
7584Srgrimes
7594Srgrimes/*70*/	{ "jo",    FALSE, NONE,  op1(Db),     0 },
7604Srgrimes/*71*/	{ "jno",   FALSE, NONE,  op1(Db),     0 },
7614Srgrimes/*72*/	{ "jb",    FALSE, NONE,  op1(Db),     0 },
7624Srgrimes/*73*/	{ "jnb",   FALSE, NONE,  op1(Db),     0 },
7634Srgrimes/*74*/	{ "jz",    FALSE, NONE,  op1(Db),     0 },
7644Srgrimes/*75*/	{ "jnz",   FALSE, NONE,  op1(Db),     0 },
7654Srgrimes/*76*/	{ "jbe",   FALSE, NONE,  op1(Db),     0 },
7664Srgrimes/*77*/	{ "jnbe",  FALSE, NONE,  op1(Db),     0 },
7674Srgrimes
7684Srgrimes/*78*/	{ "js",    FALSE, NONE,  op1(Db),     0 },
7694Srgrimes/*79*/	{ "jns",   FALSE, NONE,  op1(Db),     0 },
7704Srgrimes/*7a*/	{ "jp",    FALSE, NONE,  op1(Db),     0 },
7714Srgrimes/*7b*/	{ "jnp",   FALSE, NONE,  op1(Db),     0 },
7724Srgrimes/*7c*/	{ "jl",    FALSE, NONE,  op1(Db),     0 },
7734Srgrimes/*7d*/	{ "jnl",   FALSE, NONE,  op1(Db),     0 },
7744Srgrimes/*7e*/	{ "jle",   FALSE, NONE,  op1(Db),     0 },
7754Srgrimes/*7f*/	{ "jnle",  FALSE, NONE,  op1(Db),     0 },
7764Srgrimes
77717109Sbde/*80*/  { "",	   TRUE,  BYTE,  op2(I, E),   db_Grp1 },
77817109Sbde/*81*/  { "",	   TRUE,  LONG,  op2(I, E),   db_Grp1 },
77921277Sbde/*82*/  { "",	   TRUE,  BYTE,  op2(I, E),   db_Grp1 },
78017109Sbde/*83*/  { "",	   TRUE,  LONG,  op2(Ibs,E),  db_Grp1 },
7814Srgrimes/*84*/	{ "test",  TRUE,  BYTE,  op2(R, E),   0 },
7824Srgrimes/*85*/	{ "test",  TRUE,  LONG,  op2(R, E),   0 },
7834Srgrimes/*86*/	{ "xchg",  TRUE,  BYTE,  op2(R, E),   0 },
7844Srgrimes/*87*/	{ "xchg",  TRUE,  LONG,  op2(R, E),   0 },
7854Srgrimes
7864Srgrimes/*88*/	{ "mov",   TRUE,  BYTE,  op2(R, E),   0 },
7874Srgrimes/*89*/	{ "mov",   TRUE,  LONG,  op2(R, E),   0 },
7884Srgrimes/*8a*/	{ "mov",   TRUE,  BYTE,  op2(E, R),   0 },
7894Srgrimes/*8b*/	{ "mov",   TRUE,  LONG,  op2(E, R),   0 },
7904Srgrimes/*8c*/  { "mov",   TRUE,  NONE,  op2(S, Ew),  0 },
7914Srgrimes/*8d*/	{ "lea",   TRUE,  LONG,  op2(E, R),   0 },
7924Srgrimes/*8e*/	{ "mov",   TRUE,  NONE,  op2(Ew, S),  0 },
7934Srgrimes/*8f*/	{ "pop",   TRUE,  LONG,  op1(E),      0 },
7944Srgrimes
7954Srgrimes/*90*/	{ "nop",   FALSE, NONE,  0,	      0 },
7964Srgrimes/*91*/	{ "xchg",  FALSE, LONG,  op2(A, Ri),  0 },
7974Srgrimes/*92*/	{ "xchg",  FALSE, LONG,  op2(A, Ri),  0 },
7984Srgrimes/*93*/	{ "xchg",  FALSE, LONG,  op2(A, Ri),  0 },
7994Srgrimes/*94*/	{ "xchg",  FALSE, LONG,  op2(A, Ri),  0 },
8004Srgrimes/*95*/	{ "xchg",  FALSE, LONG,  op2(A, Ri),  0 },
8014Srgrimes/*96*/	{ "xchg",  FALSE, LONG,  op2(A, Ri),  0 },
8024Srgrimes/*97*/	{ "xchg",  FALSE, LONG,  op2(A, Ri),  0 },
8034Srgrimes
804238166Sjhb/*98*/	{ "cwde",  FALSE, SDEP,  0,	      "cbw" },
805238166Sjhb/*99*/	{ "cdq",   FALSE, SDEP,  0,	      "cwd" },
8064Srgrimes/*9a*/	{ "lcall", FALSE, NONE,  op1(OS),     0 },
8074Srgrimes/*9b*/	{ "wait",  FALSE, NONE,  0,	      0 },
8084Srgrimes/*9c*/	{ "pushf", FALSE, LONG,  0,	      0 },
8094Srgrimes/*9d*/	{ "popf",  FALSE, LONG,  0,	      0 },
8104Srgrimes/*9e*/	{ "sahf",  FALSE, NONE,  0,	      0 },
8114Srgrimes/*9f*/	{ "lahf",  FALSE, NONE,  0,	      0 },
8124Srgrimes
8134Srgrimes/*a0*/	{ "mov",   FALSE, BYTE,  op2(O, A),   0 },
8144Srgrimes/*a1*/	{ "mov",   FALSE, LONG,  op2(O, A),   0 },
8154Srgrimes/*a2*/	{ "mov",   FALSE, BYTE,  op2(A, O),   0 },
8164Srgrimes/*a3*/	{ "mov",   FALSE, LONG,  op2(A, O),   0 },
8174Srgrimes/*a4*/	{ "movs",  FALSE, BYTE,  op2(SI,DI),  0 },
8184Srgrimes/*a5*/	{ "movs",  FALSE, LONG,  op2(SI,DI),  0 },
8194Srgrimes/*a6*/	{ "cmps",  FALSE, BYTE,  op2(SI,DI),  0 },
8204Srgrimes/*a7*/	{ "cmps",  FALSE, LONG,  op2(SI,DI),  0 },
8214Srgrimes
8224Srgrimes/*a8*/	{ "test",  FALSE, BYTE,  op2(I, A),   0 },
8234Srgrimes/*a9*/	{ "test",  FALSE, LONG,  op2(I, A),   0 },
8244Srgrimes/*aa*/	{ "stos",  FALSE, BYTE,  op1(DI),     0 },
8254Srgrimes/*ab*/	{ "stos",  FALSE, LONG,  op1(DI),     0 },
826118Srgrimes/*ac*/	{ "lods",  FALSE, BYTE,  op1(SI),     0 },
827118Srgrimes/*ad*/	{ "lods",  FALSE, LONG,  op1(SI),     0 },
8284Srgrimes/*ae*/	{ "scas",  FALSE, BYTE,  op1(SI),     0 },
8294Srgrimes/*af*/	{ "scas",  FALSE, LONG,  op1(SI),     0 },
8304Srgrimes
8314Srgrimes/*b0*/	{ "mov",   FALSE, BYTE,  op2(I, Ri),  0 },
8324Srgrimes/*b1*/	{ "mov",   FALSE, BYTE,  op2(I, Ri),  0 },
8334Srgrimes/*b2*/	{ "mov",   FALSE, BYTE,  op2(I, Ri),  0 },
8344Srgrimes/*b3*/	{ "mov",   FALSE, BYTE,  op2(I, Ri),  0 },
8354Srgrimes/*b4*/	{ "mov",   FALSE, BYTE,  op2(I, Ri),  0 },
8364Srgrimes/*b5*/	{ "mov",   FALSE, BYTE,  op2(I, Ri),  0 },
8374Srgrimes/*b6*/	{ "mov",   FALSE, BYTE,  op2(I, Ri),  0 },
8384Srgrimes/*b7*/	{ "mov",   FALSE, BYTE,  op2(I, Ri),  0 },
8394Srgrimes
840164263Sjhb/*b8*/	{ "mov",   FALSE, LONG,  op2(Ilq, Ri),  0 },
841164263Sjhb/*b9*/	{ "mov",   FALSE, LONG,  op2(Ilq, Ri),  0 },
842164263Sjhb/*ba*/	{ "mov",   FALSE, LONG,  op2(Ilq, Ri),  0 },
843164263Sjhb/*bb*/	{ "mov",   FALSE, LONG,  op2(Ilq, Ri),  0 },
844164263Sjhb/*bc*/	{ "mov",   FALSE, LONG,  op2(Ilq, Ri),  0 },
845164263Sjhb/*bd*/	{ "mov",   FALSE, LONG,  op2(Ilq, Ri),  0 },
846164263Sjhb/*be*/	{ "mov",   FALSE, LONG,  op2(Ilq, Ri),  0 },
847164263Sjhb/*bf*/	{ "mov",   FALSE, LONG,  op2(Ilq, Ri),  0 },
8484Srgrimes
84917109Sbde/*c0*/	{ "",	   TRUE,  BYTE,  op2(Ib, E),  db_Grp2 },
85017109Sbde/*c1*/	{ "",	   TRUE,  LONG,  op2(Ib, E),  db_Grp2 },
8514Srgrimes/*c2*/	{ "ret",   FALSE, NONE,  op1(Iw),     0 },
8524Srgrimes/*c3*/	{ "ret",   FALSE, NONE,  0,	      0 },
8534Srgrimes/*c4*/	{ "les",   TRUE,  LONG,  op2(E, R),   0 },
8544Srgrimes/*c5*/	{ "lds",   TRUE,  LONG,  op2(E, R),   0 },
8554Srgrimes/*c6*/	{ "mov",   TRUE,  BYTE,  op2(I, E),   0 },
8564Srgrimes/*c7*/	{ "mov",   TRUE,  LONG,  op2(I, E),   0 },
8574Srgrimes
85821277Sbde/*c8*/	{ "enter", FALSE, NONE,  op2(Iw, Ib), 0 },
8594Srgrimes/*c9*/	{ "leave", FALSE, NONE,  0,           0 },
8604Srgrimes/*ca*/	{ "lret",  FALSE, NONE,  op1(Iw),     0 },
8614Srgrimes/*cb*/	{ "lret",  FALSE, NONE,  0,	      0 },
8624Srgrimes/*cc*/	{ "int",   FALSE, NONE,  op1(o3),     0 },
8634Srgrimes/*cd*/	{ "int",   FALSE, NONE,  op1(Ib),     0 },
8644Srgrimes/*ce*/	{ "into",  FALSE, NONE,  0,	      0 },
8654Srgrimes/*cf*/	{ "iret",  FALSE, NONE,  0,	      0 },
8664Srgrimes
86717109Sbde/*d0*/	{ "",	   TRUE,  BYTE,  op2(o1, E),  db_Grp2 },
86817109Sbde/*d1*/	{ "",	   TRUE,  LONG,  op2(o1, E),  db_Grp2 },
86917109Sbde/*d2*/	{ "",	   TRUE,  BYTE,  op2(CL, E),  db_Grp2 },
87017109Sbde/*d3*/	{ "",	   TRUE,  LONG,  op2(CL, E),  db_Grp2 },
87121277Sbde/*d4*/	{ "aam",   FALSE, NONE,  op1(Iba),    0 },
87221277Sbde/*d5*/	{ "aad",   FALSE, NONE,  op1(Iba),    0 },
87321277Sbde/*d6*/	{ ".byte\t0xd6", FALSE, NONE, 0,      0 },
8744Srgrimes/*d7*/	{ "xlat",  FALSE, BYTE,  op1(BX),     0 },
8754Srgrimes
87617109Sbde/*d8*/  { "",      TRUE,  NONE,  0,	      db_Esc8 },
87717109Sbde/*d9*/  { "",      TRUE,  NONE,  0,	      db_Esc9 },
87817109Sbde/*da*/  { "",      TRUE,  NONE,  0,	      db_Esca },
87917109Sbde/*db*/  { "",      TRUE,  NONE,  0,	      db_Escb },
88017109Sbde/*dc*/  { "",      TRUE,  NONE,  0,	      db_Escc },
88117109Sbde/*dd*/  { "",      TRUE,  NONE,  0,	      db_Escd },
88217109Sbde/*de*/  { "",      TRUE,  NONE,  0,	      db_Esce },
88317109Sbde/*df*/  { "",      TRUE,  NONE,  0,	      db_Escf },
8844Srgrimes
8854Srgrimes/*e0*/	{ "loopne",FALSE, NONE,  op1(Db),     0 },
8864Srgrimes/*e1*/	{ "loope", FALSE, NONE,  op1(Db),     0 },
8874Srgrimes/*e2*/	{ "loop",  FALSE, NONE,  op1(Db),     0 },
888238166Sjhb/*e3*/	{ "jrcxz", FALSE, ADEP,  op1(Db),     "jecxz" },
8894Srgrimes/*e4*/	{ "in",    FALSE, BYTE,  op2(Ib, A),  0 },
8904Srgrimes/*e5*/	{ "in",    FALSE, LONG,  op2(Ib, A) , 0 },
8914Srgrimes/*e6*/	{ "out",   FALSE, BYTE,  op2(A, Ib),  0 },
8924Srgrimes/*e7*/	{ "out",   FALSE, LONG,  op2(A, Ib) , 0 },
8934Srgrimes
8944Srgrimes/*e8*/	{ "call",  FALSE, NONE,  op1(Dl),     0 },
8954Srgrimes/*e9*/	{ "jmp",   FALSE, NONE,  op1(Dl),     0 },
8964Srgrimes/*ea*/	{ "ljmp",  FALSE, NONE,  op1(OS),     0 },
8974Srgrimes/*eb*/	{ "jmp",   FALSE, NONE,  op1(Db),     0 },
8984Srgrimes/*ec*/	{ "in",    FALSE, BYTE,  op2(DX, A),  0 },
8994Srgrimes/*ed*/	{ "in",    FALSE, LONG,  op2(DX, A) , 0 },
9004Srgrimes/*ee*/	{ "out",   FALSE, BYTE,  op2(A, DX),  0 },
9014Srgrimes/*ef*/	{ "out",   FALSE, LONG,  op2(A, DX) , 0 },
9024Srgrimes
9034Srgrimes/*f0*/	{ "",      FALSE, NONE,  0,	     0 },
90421277Sbde/*f1*/	{ ".byte\t0xf1", FALSE, NONE, 0,     0 },
9054Srgrimes/*f2*/	{ "",      FALSE, NONE,  0,	     0 },
9064Srgrimes/*f3*/	{ "",      FALSE, NONE,  0,	     0 },
9074Srgrimes/*f4*/	{ "hlt",   FALSE, NONE,  0,	     0 },
9084Srgrimes/*f5*/	{ "cmc",   FALSE, NONE,  0,	     0 },
90917109Sbde/*f6*/	{ "",      TRUE,  BYTE,  0,	     db_Grp3 },
91017109Sbde/*f7*/	{ "",	   TRUE,  LONG,  0,	     db_Grp3 },
9114Srgrimes
9124Srgrimes/*f8*/	{ "clc",   FALSE, NONE,  0,	     0 },
9134Srgrimes/*f9*/	{ "stc",   FALSE, NONE,  0,	     0 },
9144Srgrimes/*fa*/	{ "cli",   FALSE, NONE,  0,	     0 },
9154Srgrimes/*fb*/	{ "sti",   FALSE, NONE,  0,	     0 },
9164Srgrimes/*fc*/	{ "cld",   FALSE, NONE,  0,	     0 },
9174Srgrimes/*fd*/	{ "std",   FALSE, NONE,  0,	     0 },
91817109Sbde/*fe*/	{ "",	   TRUE,  NONE,  0,	     db_Grp4 },
91917109Sbde/*ff*/	{ "",	   TRUE,  NONE,  0,	     db_Grp5 },
9204Srgrimes};
9214Srgrimes
92217109Sbdestatic const struct inst db_bad_inst =
9234Srgrimes	{ "???",   FALSE, NONE,  0,	      0 }
9244Srgrimes;
9254Srgrimes
926144353Speter#define	f_mod(rex, byte)	((byte)>>6)
927144353Speter#define	f_reg(rex, byte)	((((byte)>>3)&0x7) | (rex & REX_R ? 0x8 : 0x0))
928144353Speter#define	f_rm(rex, byte)		(((byte)&0x7) | (rex & REX_B ? 0x8 : 0x0))
9294Srgrimes
930144353Speter#define	sib_ss(rex, byte)	((byte)>>6)
931144353Speter#define	sib_index(rex, byte)	((((byte)>>3)&0x7) | (rex & REX_X ? 0x8 : 0x0))
932144353Speter#define	sib_base(rex, byte)	(((byte)&0x7) | (rex & REX_B ? 0x8 : 0x0))
9334Srgrimes
93411940Sbdestruct i_addr {
9354Srgrimes	int		is_reg;	/* if reg, reg number is in 'disp' */
9364Srgrimes	int		disp;
93714887Swollman	const char *	base;
93814887Swollman	const char *	index;
9394Srgrimes	int		ss;
9404Srgrimes};
9414Srgrimes
942144353Speterstatic const char * const db_reg[2][4][16] = {
943144353Speter
944144353Speter	{{"%al",  "%cl",  "%dl",  "%bl",  "%ah",  "%ch",  "%dh",  "%bh",
945144353Speter	  "%r8b", "%r9b", "%r10b", "%r11b", "%r12b", "%r13b", "%r14b", "%r15b" },
946144353Speter	{ "%ax",  "%cx",  "%dx",  "%bx",  "%sp",  "%bp",  "%si",  "%di",
947144353Speter	  "%r8w", "%r9w", "%r10w", "%r11w", "%r12w", "%r13w", "%r14w", "%r15w" },
948144353Speter	{ "%eax", "%ecx", "%edx", "%ebx", "%esp", "%ebp", "%esi", "%edi",
949144353Speter	  "%r8d", "%r9d", "%r10d", "%r11d", "%r12d", "%r13d", "%r14d", "%r15d" },
950144353Speter	{ "%rax", "%rcx", "%rdx", "%rbx", "%rsp", "%rbp", "%rsi", "%rdi",
951144353Speter	  "%r8", "%r9", "%r10", "%r11", "%r12", "%r13", "%r14", "%r15" }},
952144353Speter
953144353Speter	{{"%al",  "%cl",  "%dl",  "%bl",  "%spl",  "%bpl",  "%sil",  "%dil",
954144353Speter	  "%r8b", "%r9b", "%r10b", "%r11b", "%r12b", "%r13b", "%r14b", "%r15b" },
955144353Speter	{ "%ax",  "%cx",  "%dx",  "%bx",  "%sp",  "%bp",  "%si",  "%di",
956144353Speter	  "%r8w", "%r9w", "%r10w", "%r11w", "%r12w", "%r13w", "%r14w", "%r15w" },
957144353Speter	{ "%eax", "%ecx", "%edx", "%ebx", "%esp", "%ebp", "%esi", "%edi",
958144353Speter	  "%r8d", "%r9d", "%r10d", "%r11d", "%r12d", "%r13d", "%r14d", "%r15d" },
959144353Speter	{ "%rax", "%rcx", "%rdx", "%rbx", "%rsp", "%rbp", "%rsi", "%rdi",
960144353Speter	  "%r8", "%r9", "%r10", "%r11", "%r12", "%r13", "%r14", "%r15" }}
9614Srgrimes};
9624Srgrimes
96317109Sbdestatic const char * const db_seg_reg[8] = {
9644Srgrimes	"%es", "%cs", "%ss", "%ds", "%fs", "%gs", "", ""
9654Srgrimes};
9664Srgrimes
9674Srgrimes/*
9684Srgrimes * lengths for size attributes
9694Srgrimes */
97014887Swollmanstatic const int db_lengths[] = {
9714Srgrimes	1,	/* BYTE */
9724Srgrimes	2,	/* WORD */
9734Srgrimes	4,	/* LONG */
9744Srgrimes	8,	/* QUAD */
9754Srgrimes	4,	/* SNGL */
9764Srgrimes	8,	/* DBLR */
9774Srgrimes	10,	/* EXTR */
9784Srgrimes};
9794Srgrimes
9804Srgrimes#define	get_value_inc(result, loc, size, is_signed) \
9814Srgrimes	result = db_get_value((loc), (size), (is_signed)); \
9824Srgrimes	(loc) += (size);
9834Srgrimes
98411940Sbdestatic db_addr_t
985144353Speter		db_disasm_esc(db_addr_t loc, int inst, int rex, int short_addr,
98693017Sbde		    int size, const char *seg);
987144353Speterstatic void	db_print_address(const char *seg, int size, int rex,
98893017Sbde		    struct i_addr *addrp);
98911940Sbdestatic db_addr_t
990144353Speter		db_read_address(db_addr_t loc, int short_addr, int rex, int regmodrm,
99193017Sbde		    struct i_addr *addrp);
99211940Sbde
9934Srgrimes/*
9944Srgrimes * Read address at location and return updated location.
9954Srgrimes */
99611921Sphkstatic db_addr_t
997144353Speterdb_read_address(loc, short_addr, rex, regmodrm, addrp)
9984Srgrimes	db_addr_t	loc;
9994Srgrimes	int		short_addr;
1000144353Speter	int		rex;
10014Srgrimes	int		regmodrm;
100217109Sbde	struct i_addr *	addrp;		/* out */
10034Srgrimes{
1004164263Sjhb	int		mod, rm, sib, index, disp, size, have_sib;
10054Srgrimes
1006144353Speter	mod = f_mod(rex, regmodrm);
1007144353Speter	rm  = f_rm(rex, regmodrm);
10084Srgrimes
10094Srgrimes	if (mod == 3) {
10104Srgrimes	    addrp->is_reg = TRUE;
10114Srgrimes	    addrp->disp = rm;
10124Srgrimes	    return (loc);
10134Srgrimes	}
10144Srgrimes	addrp->is_reg = FALSE;
10154Srgrimes	addrp->index = 0;
10164Srgrimes
1017164263Sjhb	if (short_addr)
1018164263Sjhb	    size = LONG;
1019164263Sjhb	else
1020164263Sjhb	    size = QUAD;
10214Srgrimes
1022164263Sjhb	if ((rm & 0x7) == 4) {
1023164263Sjhb	    get_value_inc(sib, loc, 1, FALSE);
1024164263Sjhb	    rm = sib_base(rex, sib);
1025164263Sjhb	    index = sib_index(rex, sib);
1026164263Sjhb	    if (index != 4)
1027164263Sjhb		addrp->index = db_reg[1][size][index];
1028164263Sjhb	    addrp->ss = sib_ss(rex, sib);
1029164263Sjhb	    have_sib = 1;
1030164263Sjhb	} else
1031164263Sjhb	    have_sib = 0;
1032164263Sjhb
1033164263Sjhb	switch (mod) {
1034164263Sjhb	    case 0:
1035164263Sjhb		if (rm == 5) {
1036164263Sjhb		    get_value_inc(addrp->disp, loc, 4, FALSE);
1037164263Sjhb		    if (have_sib)
10384Srgrimes			addrp->base = 0;
1039164263Sjhb		    else if (short_addr)
1040164263Sjhb			addrp->base = "%eip";
1041164263Sjhb		    else
1042164263Sjhb			addrp->base = "%rip";
1043164263Sjhb		} else {
1044164263Sjhb		    addrp->disp = 0;
1045164263Sjhb		    addrp->base = db_reg[1][size][rm];
1046164263Sjhb		}
1047164263Sjhb		break;
10484Srgrimes
1049164263Sjhb	    case 1:
1050164263Sjhb		get_value_inc(disp, loc, 1, TRUE);
1051164263Sjhb		addrp->disp = disp;
1052164263Sjhb		addrp->base = db_reg[1][size][rm];
1053164263Sjhb		break;
10544Srgrimes
1055164263Sjhb	    case 2:
1056164263Sjhb		get_value_inc(disp, loc, 4, FALSE);
1057164263Sjhb		addrp->disp = disp;
1058164263Sjhb		addrp->base = db_reg[1][size][rm];
1059164263Sjhb		break;
10604Srgrimes	}
10614Srgrimes	return (loc);
10624Srgrimes}
10634Srgrimes
106411921Sphkstatic void
1065144353Speterdb_print_address(seg, size, rex, addrp)
106617109Sbde	const char *	seg;
10674Srgrimes	int		size;
1068144353Speter	int		rex;
106917109Sbde	struct i_addr *	addrp;
10704Srgrimes{
10714Srgrimes	if (addrp->is_reg) {
1072144354Speter	    db_printf("%s", db_reg[rex != 0 ? 1 : 0][(size == LONG && (rex & REX_W)) ? QUAD : size][addrp->disp]);
10734Srgrimes	    return;
10744Srgrimes	}
10754Srgrimes
10764Srgrimes	if (seg) {
10774Srgrimes	    db_printf("%s:", seg);
10784Srgrimes	}
10794Srgrimes
1080164263Sjhb	if (addrp->disp != 0 || (addrp->base == 0 && addrp->index == 0))
1081164263Sjhb		db_printsym((db_addr_t)addrp->disp, DB_STGY_ANY);
10824Srgrimes	if (addrp->base != 0 || addrp->index != 0) {
10834Srgrimes	    db_printf("(");
10844Srgrimes	    if (addrp->base)
10854Srgrimes		db_printf("%s", addrp->base);
10864Srgrimes	    if (addrp->index)
10874Srgrimes		db_printf(",%s,%d", addrp->index, 1<<addrp->ss);
10884Srgrimes	    db_printf(")");
10894Srgrimes	}
10904Srgrimes}
10914Srgrimes
10924Srgrimes/*
10934Srgrimes * Disassemble floating-point ("escape") instruction
10944Srgrimes * and return updated location.
10954Srgrimes */
109611921Sphkstatic db_addr_t
1097144353Speterdb_disasm_esc(loc, inst, rex, short_addr, size, seg)
10984Srgrimes	db_addr_t	loc;
10994Srgrimes	int		inst;
1100144353Speter	int		rex;
11014Srgrimes	int		short_addr;
11024Srgrimes	int		size;
110317109Sbde	const char *	seg;
11044Srgrimes{
11054Srgrimes	int		regmodrm;
110617109Sbde	const struct finst *	fp;
11074Srgrimes	int		mod;
11084Srgrimes	struct i_addr	address;
110917109Sbde	const char *	name;
11104Srgrimes
11114Srgrimes	get_value_inc(regmodrm, loc, 1, FALSE);
1112144353Speter	fp = &db_Esc_inst[inst - 0xd8][f_reg(rex, regmodrm)];
1113144353Speter	mod = f_mod(rex, regmodrm);
11144Srgrimes	if (mod != 3) {
111521277Sbde	    if (*fp->f_name == '\0') {
111621277Sbde		db_printf("<bad instruction>");
111721277Sbde		return (loc);
111821277Sbde	    }
11194Srgrimes	    /*
11204Srgrimes	     * Normal address modes.
11214Srgrimes	     */
1122144353Speter	    loc = db_read_address(loc, short_addr, rex, regmodrm, &address);
112379885Skris	    db_printf("%s", fp->f_name);
11244Srgrimes	    switch(fp->f_size) {
11254Srgrimes		case SNGL:
11264Srgrimes		    db_printf("s");
11274Srgrimes		    break;
11284Srgrimes		case DBLR:
11294Srgrimes		    db_printf("l");
11304Srgrimes		    break;
11314Srgrimes		case EXTR:
11324Srgrimes		    db_printf("t");
11334Srgrimes		    break;
11344Srgrimes		case WORD:
11354Srgrimes		    db_printf("s");
11364Srgrimes		    break;
11374Srgrimes		case LONG:
11384Srgrimes		    db_printf("l");
11394Srgrimes		    break;
11404Srgrimes		case QUAD:
11414Srgrimes		    db_printf("q");
11424Srgrimes		    break;
11434Srgrimes		default:
11444Srgrimes		    break;
11454Srgrimes	    }
11464Srgrimes	    db_printf("\t");
1147144353Speter	    db_print_address(seg, BYTE, rex, &address);
11484Srgrimes	}
11494Srgrimes	else {
11504Srgrimes	    /*
11514Srgrimes	     * 'reg-reg' - special formats
11524Srgrimes	     */
11534Srgrimes	    switch (fp->f_rrmode) {
11544Srgrimes		case op2(ST,STI):
11554Srgrimes		    name = (fp->f_rrname) ? fp->f_rrname : fp->f_name;
1156144353Speter		    db_printf("%s\t%%st,%%st(%d)",name,f_rm(rex, regmodrm));
11574Srgrimes		    break;
11584Srgrimes		case op2(STI,ST):
11594Srgrimes		    name = (fp->f_rrname) ? fp->f_rrname : fp->f_name;
1160144353Speter		    db_printf("%s\t%%st(%d),%%st",name, f_rm(rex, regmodrm));
11614Srgrimes		    break;
11624Srgrimes		case op1(STI):
11634Srgrimes		    name = (fp->f_rrname) ? fp->f_rrname : fp->f_name;
1164144353Speter		    db_printf("%s\t%%st(%d)",name, f_rm(rex, regmodrm));
11654Srgrimes		    break;
11664Srgrimes		case op1(X):
1167144353Speter		    name = ((const char * const *)fp->f_rrname)[f_rm(rex, regmodrm)];
116821277Sbde		    if (*name == '\0')
116921277Sbde			goto bad;
117021277Sbde		    db_printf("%s", name);
11714Srgrimes		    break;
11724Srgrimes		case op1(XA):
1173144353Speter		    name = ((const char * const *)fp->f_rrname)[f_rm(rex, regmodrm)];
117421277Sbde		    if (*name == '\0')
117521277Sbde			goto bad;
117621277Sbde		    db_printf("%s\t%%ax", name);
11774Srgrimes		    break;
11784Srgrimes		default:
117921277Sbde		bad:
11804Srgrimes		    db_printf("<bad instruction>");
11814Srgrimes		    break;
11824Srgrimes	    }
11834Srgrimes	}
11844Srgrimes
11854Srgrimes	return (loc);
11864Srgrimes}
11874Srgrimes
11884Srgrimes/*
11894Srgrimes * Disassemble instruction at 'loc'.  'altfmt' specifies an
11904Srgrimes * (optional) alternate format.  Return address of start of
11914Srgrimes * next instruction.
11924Srgrimes */
11934Srgrimesdb_addr_t
11944Srgrimesdb_disasm(loc, altfmt)
11954Srgrimes	db_addr_t	loc;
11964Srgrimes	boolean_t	altfmt;
11974Srgrimes{
11984Srgrimes	int	inst;
11994Srgrimes	int	size;
12004Srgrimes	int	short_addr;
120117109Sbde	const char *	seg;
120214887Swollman	const struct inst *	ip;
120314887Swollman	const char *	i_name;
12044Srgrimes	int	i_size;
12054Srgrimes	int	i_mode;
1206144353Speter	int	rex = 0;
1207798Swollman	int	regmodrm = 0;
12084Srgrimes	boolean_t	first;
12094Srgrimes	int	displ;
12104Srgrimes	int	prefix;
1211181606Sjhb	int	rep;
12124Srgrimes	int	imm;
12134Srgrimes	int	imm2;
1214164263Sjhb	long	imm64;
12154Srgrimes	int	len;
12164Srgrimes	struct i_addr	address;
12174Srgrimes
12184Srgrimes	get_value_inc(inst, loc, 1, FALSE);
12194Srgrimes	short_addr = FALSE;
12204Srgrimes	size = LONG;
12214Srgrimes	seg = 0;
12224Srgrimes
12234Srgrimes	/*
12244Srgrimes	 * Get prefixes
12254Srgrimes	 */
1226181606Sjhb	rep = FALSE;
12274Srgrimes	prefix = TRUE;
12284Srgrimes	do {
12294Srgrimes	    switch (inst) {
12304Srgrimes		case 0x66:		/* data16 */
12314Srgrimes		    size = WORD;
12324Srgrimes		    break;
12334Srgrimes		case 0x67:
12344Srgrimes		    short_addr = TRUE;
12354Srgrimes		    break;
12364Srgrimes		case 0x26:
12374Srgrimes		    seg = "%es";
12384Srgrimes		    break;
12394Srgrimes		case 0x36:
12404Srgrimes		    seg = "%ss";
12414Srgrimes		    break;
12424Srgrimes		case 0x2e:
12434Srgrimes		    seg = "%cs";
12444Srgrimes		    break;
12454Srgrimes		case 0x3e:
12464Srgrimes		    seg = "%ds";
12474Srgrimes		    break;
12484Srgrimes		case 0x64:
12494Srgrimes		    seg = "%fs";
12504Srgrimes		    break;
12514Srgrimes		case 0x65:
12524Srgrimes		    seg = "%gs";
12534Srgrimes		    break;
12544Srgrimes		case 0xf0:
12554Srgrimes		    db_printf("lock ");
12564Srgrimes		    break;
12574Srgrimes		case 0xf2:
12584Srgrimes		    db_printf("repne ");
12594Srgrimes		    break;
12604Srgrimes		case 0xf3:
1261181606Sjhb		    rep = TRUE;
12624Srgrimes		    break;
12634Srgrimes		default:
12644Srgrimes		    prefix = FALSE;
12654Srgrimes		    break;
12664Srgrimes	    }
1267144353Speter	    if (inst >= 0x40 && inst < 0x50) {
1268144353Speter		rex = inst;
1269144353Speter		prefix = TRUE;
1270144353Speter	    }
12714Srgrimes	    if (prefix) {
12724Srgrimes		get_value_inc(inst, loc, 1, FALSE);
12734Srgrimes	    }
12744Srgrimes	} while (prefix);
12754Srgrimes
12764Srgrimes	if (inst >= 0xd8 && inst <= 0xdf) {
1277144353Speter	    loc = db_disasm_esc(loc, inst, rex, short_addr, size, seg);
12784Srgrimes	    db_printf("\n");
12794Srgrimes	    return (loc);
12804Srgrimes	}
12814Srgrimes
1282238166Sjhb	ip = &db_inst_table[inst];
1283238166Sjhb	while (ip->i_size == ESC) {
12844Srgrimes	    get_value_inc(inst, loc, 1, FALSE);
1285238166Sjhb	    ip = ((const struct inst * const *)ip->i_extra)[inst>>4];
12864Srgrimes	    if (ip == 0) {
12874Srgrimes		ip = &db_bad_inst;
12884Srgrimes	    }
12894Srgrimes	    else {
12904Srgrimes		ip = &ip[inst&0xf];
12914Srgrimes	    }
12924Srgrimes	}
12934Srgrimes
12944Srgrimes	if (ip->i_has_modrm) {
12954Srgrimes	    get_value_inc(regmodrm, loc, 1, FALSE);
1296144353Speter	    loc = db_read_address(loc, short_addr, rex, regmodrm, &address);
12974Srgrimes	}
12984Srgrimes
12994Srgrimes	i_name = ip->i_name;
13004Srgrimes	i_size = ip->i_size;
13014Srgrimes	i_mode = ip->i_mode;
13024Srgrimes
130317109Sbde	if (ip->i_extra == db_Grp1 || ip->i_extra == db_Grp2 ||
130417109Sbde	    ip->i_extra == db_Grp6 || ip->i_extra == db_Grp7 ||
1305181606Sjhb	    ip->i_extra == db_Grp8 || ip->i_extra == db_Grp9 ||
1306181606Sjhb	    ip->i_extra == db_Grp15) {
1307144353Speter	    i_name = ((const char * const *)ip->i_extra)[f_reg(rex, regmodrm)];
13084Srgrimes	}
130917109Sbde	else if (ip->i_extra == db_Grp3) {
131017109Sbde	    ip = ip->i_extra;
1311144353Speter	    ip = &ip[f_reg(rex, regmodrm)];
13124Srgrimes	    i_name = ip->i_name;
13134Srgrimes	    i_mode = ip->i_mode;
13144Srgrimes	}
131517109Sbde	else if (ip->i_extra == db_Grp4 || ip->i_extra == db_Grp5) {
131617109Sbde	    ip = ip->i_extra;
1317144353Speter	    ip = &ip[f_reg(rex, regmodrm)];
13184Srgrimes	    i_name = ip->i_name;
13194Srgrimes	    i_mode = ip->i_mode;
13204Srgrimes	    i_size = ip->i_size;
13214Srgrimes	}
13224Srgrimes
1323181606Sjhb	/* Special cases that don't fit well in the tables. */
1324181606Sjhb	if (ip->i_extra == db_Grp7 && f_mod(rex, regmodrm) == 3) {
1325181606Sjhb		switch (regmodrm) {
1326238166Sjhb		case 0xc1:
1327238166Sjhb			i_name = "vmcall";
1328238166Sjhb			i_size = NONE;
1329238166Sjhb			i_mode = 0;
1330238166Sjhb			break;
1331238166Sjhb		case 0xc2:
1332238166Sjhb			i_name = "vmlaunch";
1333238166Sjhb			i_size = NONE;
1334238166Sjhb			i_mode = 0;
1335238166Sjhb			break;
1336238166Sjhb		case 0xc3:
1337238166Sjhb			i_name = "vmresume";
1338238166Sjhb			i_size = NONE;
1339238166Sjhb			i_mode = 0;
1340238166Sjhb			break;
1341238166Sjhb		case 0xc4:
1342238166Sjhb			i_name = "vmxoff";
1343238166Sjhb			i_size = NONE;
1344238166Sjhb			i_mode = 0;
1345238166Sjhb			break;
1346181606Sjhb		case 0xc8:
1347181606Sjhb			i_name = "monitor";
1348181606Sjhb			i_size = NONE;
1349181606Sjhb			i_mode = 0;
1350181606Sjhb			break;
1351181606Sjhb		case 0xc9:
1352181606Sjhb			i_name = "mwait";
1353181606Sjhb			i_size = NONE;
1354181606Sjhb			i_mode = 0;
1355181606Sjhb			break;
1356261213Sjhb		case 0xca:
1357261213Sjhb			i_name = "clac";
1358261213Sjhb			i_size = NONE;
1359261213Sjhb			i_mode = 0;
1360261213Sjhb			break;
1361261213Sjhb		case 0xcb:
1362261213Sjhb			i_name = "stac";
1363261213Sjhb			i_size = NONE;
1364261213Sjhb			i_mode = 0;
1365261213Sjhb			break;
1366238109Sjhb		case 0xd0:
1367238109Sjhb			i_name = "xgetbv";
1368238109Sjhb			i_size = NONE;
1369238109Sjhb			i_mode = 0;
1370238109Sjhb			break;
1371238109Sjhb		case 0xd1:
1372238109Sjhb			i_name = "xsetbv";
1373238109Sjhb			i_size = NONE;
1374238109Sjhb			i_mode = 0;
1375238109Sjhb			break;
1376181606Sjhb		case 0xf8:
1377181606Sjhb			i_name = "swapgs";
1378181606Sjhb			i_size = NONE;
1379181606Sjhb			i_mode = 0;
1380181606Sjhb			break;
1381238109Sjhb		case 0xf9:
1382238109Sjhb			i_name = "rdtscp";
1383238109Sjhb			i_size = NONE;
1384238109Sjhb			i_mode = 0;
1385238109Sjhb			break;
1386181606Sjhb		}
1387181606Sjhb	}
1388181606Sjhb	if (ip->i_extra == db_Grp15 && f_mod(rex, regmodrm) == 3) {
1389181606Sjhb		i_name = db_Grp15b[f_reg(rex, regmodrm)];
1390181606Sjhb		i_size = NONE;
1391181606Sjhb		i_mode = 0;
1392181606Sjhb	}
1393181606Sjhb
1394238166Sjhb	/* Handle instructions identified by mandatory prefixes. */
1395238166Sjhb	if (rep == TRUE) {
1396238166Sjhb	    if (inst == 0x90) {
1397238166Sjhb		i_name = "pause";
1398238166Sjhb		i_size = NONE;
1399238166Sjhb		i_mode = 0;
1400238166Sjhb		rep = FALSE;
1401238166Sjhb	    } else if (ip->i_extra == db_Grp9 && f_mod(rex, regmodrm) != 3 &&
1402238166Sjhb		f_reg(rex, regmodrm) == 0x6) {
1403238166Sjhb		i_name = "vmxon";
1404238166Sjhb		rep = FALSE;
1405238166Sjhb	    }
1406238166Sjhb	}
1407238166Sjhb	if (size == WORD) {
1408238166Sjhb	    if (ip->i_extra == db_Grp9 && f_mod(rex, regmodrm) != 3 &&
1409238166Sjhb		f_reg(rex, regmodrm) == 0x6) {
1410238166Sjhb		i_name = "vmclear";
1411238166Sjhb	    }
1412238166Sjhb	}
1413238166Sjhb	if (rex & REX_W) {
1414238166Sjhb	    if (strcmp(i_name, "cwde") == 0)
1415238166Sjhb		i_name = "cdqe";
1416238166Sjhb	    else if (strcmp(i_name, "cmpxchg8b") == 0)
1417238166Sjhb		i_name = "cmpxchg16b";
1418238166Sjhb	}
1419238166Sjhb
1420238166Sjhb	if (rep == TRUE)
1421238166Sjhb	    db_printf("repe ");	/* XXX repe VS rep */
1422238166Sjhb
14234Srgrimes	if (i_size == SDEP) {
1424238166Sjhb	    if (size == LONG)
142579885Skris		db_printf("%s", i_name);
14264Srgrimes	    else
142779885Skris		db_printf("%s", (const char *)ip->i_extra);
1428238166Sjhb	} else if (i_size == ADEP) {
1429238166Sjhb	    if (short_addr == FALSE)
1430238166Sjhb		db_printf("%s", i_name);
1431238166Sjhb	    else
1432238166Sjhb		db_printf("%s", (const char *)ip->i_extra);
14334Srgrimes	}
14344Srgrimes	else {
143579885Skris	    db_printf("%s", i_name);
1436144354Speter	    if ((inst >= 0x50 && inst <= 0x5f) || inst == 0x68 || inst == 0x6a) {
1437144354Speter		i_size = NONE;
1438144354Speter		db_printf("q");
1439144354Speter	    }
14404Srgrimes	    if (i_size != NONE) {
14414Srgrimes		if (i_size == BYTE) {
14424Srgrimes		    db_printf("b");
14434Srgrimes		    size = BYTE;
14444Srgrimes		}
14454Srgrimes		else if (i_size == WORD) {
14464Srgrimes		    db_printf("w");
14474Srgrimes		    size = WORD;
14484Srgrimes		}
14494Srgrimes		else if (size == WORD)
14504Srgrimes		    db_printf("w");
1451144353Speter		else {
1452144353Speter		    if (rex & REX_W)
1453144353Speter			db_printf("q");
1454144353Speter		    else
1455144353Speter			db_printf("l");
1456144353Speter		}
14574Srgrimes	    }
14584Srgrimes	}
14594Srgrimes	db_printf("\t");
14604Srgrimes	for (first = TRUE;
14614Srgrimes	     i_mode != 0;
14624Srgrimes	     i_mode >>= 8, first = FALSE)
14634Srgrimes	{
14644Srgrimes	    if (!first)
14654Srgrimes		db_printf(",");
14664Srgrimes
14674Srgrimes	    switch (i_mode & 0xFF) {
14684Srgrimes
14694Srgrimes		case E:
1470144353Speter		    db_print_address(seg, size, rex, &address);
14714Srgrimes		    break;
14724Srgrimes
14734Srgrimes		case Eind:
14744Srgrimes		    db_printf("*");
1475144353Speter		    db_print_address(seg, size, rex, &address);
14764Srgrimes		    break;
14774Srgrimes
147821277Sbde		case El:
1479144353Speter		    db_print_address(seg, (rex & REX_W) ? QUAD : LONG, rex, &address);
148021277Sbde		    break;
148121277Sbde
1482144354Speter		case EL:
1483144354Speter		    db_print_address(seg, LONG, 0, &address);
1484144354Speter		    break;
1485144354Speter
14864Srgrimes		case Ew:
1487144353Speter		    db_print_address(seg, WORD, rex, &address);
14884Srgrimes		    break;
14894Srgrimes
14904Srgrimes		case Eb:
1491144353Speter		    db_print_address(seg, BYTE, rex, &address);
14924Srgrimes		    break;
14934Srgrimes
14944Srgrimes		case R:
1495144354Speter		    db_printf("%s", db_reg[rex != 0 ? 1 : 0][(size == LONG && (rex & REX_W)) ? QUAD : size][f_reg(rex, regmodrm)]);
14964Srgrimes		    break;
14974Srgrimes
14984Srgrimes		case Rw:
1499144353Speter		    db_printf("%s", db_reg[rex != 0 ? 1 : 0][WORD][f_reg(rex, regmodrm)]);
15004Srgrimes		    break;
15014Srgrimes
1502238166Sjhb		case Rq:
1503238166Sjhb		    db_printf("%s", db_reg[rex != 0 ? 1 : 0][QUAD][f_reg(rex, regmodrm)]);
1504238166Sjhb		    break;
1505238166Sjhb
15064Srgrimes		case Ri:
1507144354Speter		    db_printf("%s", db_reg[0][QUAD][f_rm(rex, inst)]);
15084Srgrimes		    break;
15094Srgrimes
151021277Sbde		case Ril:
1511144353Speter		    db_printf("%s", db_reg[rex != 0 ? 1 : 0][(rex & REX_R) ? QUAD : LONG][f_rm(rex, inst)]);
151221277Sbde		    break;
151321277Sbde
15144Srgrimes		case S:
1515144353Speter		    db_printf("%s", db_seg_reg[f_reg(rex, regmodrm)]);
15164Srgrimes		    break;
15174Srgrimes
15184Srgrimes		case Si:
1519144353Speter		    db_printf("%s", db_seg_reg[f_reg(rex, inst)]);
15204Srgrimes		    break;
15214Srgrimes
15224Srgrimes		case A:
1523144353Speter		    db_printf("%s", db_reg[rex != 0 ? 1 : 0][size][0]);	/* acc */
15244Srgrimes		    break;
15254Srgrimes
15264Srgrimes		case BX:
15274Srgrimes		    if (seg)
15284Srgrimes			db_printf("%s:", seg);
15294Srgrimes		    db_printf("(%s)", short_addr ? "%bx" : "%ebx");
15304Srgrimes		    break;
15314Srgrimes
15324Srgrimes		case CL:
15334Srgrimes		    db_printf("%%cl");
15344Srgrimes		    break;
15354Srgrimes
15364Srgrimes		case DX:
15374Srgrimes		    db_printf("%%dx");
15384Srgrimes		    break;
15394Srgrimes
15404Srgrimes		case SI:
15414Srgrimes		    if (seg)
15424Srgrimes			db_printf("%s:", seg);
1543144353Speter		    db_printf("(%s)", short_addr ? "%si" : "%rsi");
15444Srgrimes		    break;
15454Srgrimes
15464Srgrimes		case DI:
1547144353Speter		    db_printf("%%es:(%s)", short_addr ? "%di" : "%rdi");
15484Srgrimes		    break;
15494Srgrimes
15504Srgrimes		case CR:
1551144353Speter		    db_printf("%%cr%d", f_reg(rex, regmodrm));
15524Srgrimes		    break;
15534Srgrimes
15544Srgrimes		case DR:
1555144353Speter		    db_printf("%%dr%d", f_reg(rex, regmodrm));
15564Srgrimes		    break;
15574Srgrimes
15584Srgrimes		case TR:
1559144353Speter		    db_printf("%%tr%d", f_reg(rex, regmodrm));
15604Srgrimes		    break;
15614Srgrimes
15624Srgrimes		case I:
1563144354Speter		    len = db_lengths[size];
156421277Sbde		    get_value_inc(imm, loc, len, FALSE);
156537506Sbde		    db_printf("$%#r", imm);
15664Srgrimes		    break;
15674Srgrimes
15684Srgrimes		case Is:
1569144353Speter		    len = db_lengths[(size == LONG && (rex & REX_W)) ? QUAD : size];
157021277Sbde		    get_value_inc(imm, loc, len, FALSE);
157137506Sbde		    db_printf("$%+#r", imm);
15724Srgrimes		    break;
15734Srgrimes
15744Srgrimes		case Ib:
157521277Sbde		    get_value_inc(imm, loc, 1, FALSE);
157637506Sbde		    db_printf("$%#r", imm);
15774Srgrimes		    break;
15784Srgrimes
157921277Sbde		case Iba:
158021277Sbde		    get_value_inc(imm, loc, 1, FALSE);
158121277Sbde		    if (imm != 0x0a)
158237506Sbde			db_printf("$%#r", imm);
158321277Sbde		    break;
158421277Sbde
15854Srgrimes		case Ibs:
158621277Sbde		    get_value_inc(imm, loc, 1, TRUE);
158721277Sbde		    if (size == WORD)
158821277Sbde			imm &= 0xFFFF;
158937506Sbde		    db_printf("$%+#r", imm);
15904Srgrimes		    break;
15914Srgrimes
15924Srgrimes		case Iw:
159321277Sbde		    get_value_inc(imm, loc, 2, FALSE);
159437506Sbde		    db_printf("$%#r", imm);
15954Srgrimes		    break;
15964Srgrimes
1597164263Sjhb		case Ilq:
1598164263Sjhb		    len = db_lengths[rex & REX_W ? QUAD : LONG];
1599164263Sjhb		    get_value_inc(imm64, loc, len, FALSE);
1600164263Sjhb		    db_printf("$%#lr", imm64);
1601164263Sjhb		    break;
1602164263Sjhb
16034Srgrimes		case O:
160421277Sbde		    len = (short_addr ? 2 : 4);
160521277Sbde		    get_value_inc(displ, loc, len, FALSE);
16064Srgrimes		    if (seg)
160737506Sbde			db_printf("%s:%+#r",seg, displ);
16084Srgrimes		    else
16094Srgrimes			db_printsym((db_addr_t)displ, DB_STGY_ANY);
16104Srgrimes		    break;
16114Srgrimes
16124Srgrimes		case Db:
16134Srgrimes		    get_value_inc(displ, loc, 1, TRUE);
161421277Sbde		    displ += loc;
161521277Sbde		    if (size == WORD)
161621277Sbde			displ &= 0xFFFF;
161721277Sbde		    db_printsym((db_addr_t)displ, DB_STGY_XTRN);
16184Srgrimes		    break;
16194Srgrimes
16204Srgrimes		case Dl:
1621144353Speter		    len = db_lengths[(size == LONG && (rex & REX_W)) ? QUAD : size];
162221277Sbde		    get_value_inc(displ, loc, len, FALSE);
162321277Sbde		    displ += loc;
162421277Sbde		    if (size == WORD)
162521277Sbde			displ &= 0xFFFF;
162621277Sbde		    db_printsym((db_addr_t)displ, DB_STGY_XTRN);
16274Srgrimes		    break;
16284Srgrimes
16294Srgrimes		case o1:
16304Srgrimes		    db_printf("$1");
16314Srgrimes		    break;
16324Srgrimes
16334Srgrimes		case o3:
16344Srgrimes		    db_printf("$3");
16354Srgrimes		    break;
16364Srgrimes
16374Srgrimes		case OS:
163821277Sbde		    len = db_lengths[size];
163921277Sbde		    get_value_inc(imm, loc, len, FALSE);	/* offset */
16404Srgrimes		    get_value_inc(imm2, loc, 2, FALSE);	/* segment */
164137506Sbde		    db_printf("$%#r,%#r", imm2, imm);
16424Srgrimes		    break;
16434Srgrimes	    }
16444Srgrimes	}
16454Srgrimes	db_printf("\n");
16464Srgrimes	return (loc);
16474Srgrimes}
1648