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