msxml3: Fold in reset_output_buffer.
[wine/zf.git] / programs / winedbg / db_disasm64.c
blob4d9aca9d43b91543777fc8452f0d9ca8fc74b9e1
1 /*-
2 * Mach Operating System
3 * Copyright (c) 1991,1990 Carnegie Mellon University
4 * All Rights Reserved.
6 * Permission to use, copy, modify and distribute this software and its
7 * documentation is hereby granted, provided that both the copyright
8 * notice and this permission notice appear in all copies of the
9 * software, derivative works or modified versions, and any portions
10 * thereof, and that both notices appear in supporting documentation.
12 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS
13 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
14 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
16 * Carnegie Mellon requests users of this software to return to
18 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
19 * School of Computer Science
20 * Carnegie Mellon University
21 * Pittsburgh PA 15213-3890
23 * any improvements or extensions that they make and grant Carnegie the
24 * rights to redistribute these changes.
28 * Instruction disassembler.
31 /* <Wine specific wrappers> */
32 #include <stdio.h>
33 #include "debugger.h"
35 #if defined(__GNUC__) && (__GNUC__ >= 3)
36 static int (*db_printf)(const char* format, ...) __attribute__((format (printf,1,2)));
37 #else
38 static int (*db_printf)(const char* format, ...);
39 #endif
41 static int no_printf(const char* format, ...) {return 0;}
43 typedef DWORD_PTR db_addr_t;
44 typedef BOOL boolean_t;
46 static ULONG64 db_get_value(db_addr_t addr, int size, int is_signed)
48 ULONG64 result = 0;
49 char buffer[8];
51 if (size != 1 && size != 2 && size != 4 && size != 8)
53 db_printf("Illegal size specified\n");
55 else if (dbg_read_memory((void*)addr, buffer, size))
57 switch (size)
59 case 8:
60 if (is_signed) result = (ULONG64)*(LONG64*)buffer;
61 else result = *(ULONG64*)buffer;
62 break;
63 case 4:
64 if (is_signed) result = (ULONG) *(LONG*)buffer;
65 else result = *(ULONG64*)buffer;
66 break;
67 case 2:
68 if (is_signed) result = (unsigned int) *(short int *)buffer;
69 else result = *(unsigned short int *)buffer;
70 break;
71 case 1:
72 if (is_signed) result = (unsigned int) *(char *)buffer;
73 else result = *(unsigned char *)buffer;
74 break;
77 return result;
80 #define DB_STGY_ANY 0
81 #define DB_STGY_XTRN 0
83 static void db_printsym(db_addr_t addr, unsigned unused)
85 if (db_printf != no_printf)
87 ADDRESS64 a;
89 a.Mode = AddrModeFlat;
90 a.Offset = addr;
92 print_address(&a, FALSE);
96 /* </Wine specific wrappers> */
99 * Size attributes
101 #define BYTE 0
102 #define WORD 1
103 #define LONG 2
104 #define QUAD 3
105 #define SNGL 4
106 #define DBLR 5
107 #define EXTR 6
108 #define SDEP 7
109 #define NONE 8
112 * REX prefix and bits
114 #define REX_B 1
115 #define REX_X 2
116 #define REX_R 4
117 #define REX_W 8
118 #define REX 0x40
121 * Addressing modes
123 #define E 1 /* general effective address */
124 #define Eind 2 /* indirect address (jump, call) */
125 #define Ew 3 /* address, word size */
126 #define Eb 4 /* address, byte size */
127 #define R 5 /* register, in 'reg' field */
128 #define Rw 6 /* word register, in 'reg' field */
129 #define Ri 7 /* register in instruction */
130 #define S 8 /* segment reg, in 'reg' field */
131 #define Si 9 /* segment reg, in instruction */
132 #define A 10 /* accumulator */
133 #define BX 11 /* (bx) */
134 #define CL 12 /* cl, for shifts */
135 #define DX 13 /* dx, for IO */
136 #define SI 14 /* si */
137 #define DI 15 /* di */
138 #define CR 16 /* control register */
139 #define DR 17 /* debug register */
140 #define TR 18 /* test register */
141 #define I 19 /* immediate, unsigned */
142 #define Is 20 /* immediate, signed */
143 #define Ib 21 /* byte immediate, unsigned */
144 #define Ibs 22 /* byte immediate, signed */
145 #define Iw 23 /* word immediate, unsigned */
146 #define Ilq 24 /* long/quad immediate, unsigned */
147 #define O 25 /* direct address */
148 #define Db 26 /* byte displacement from EIP */
149 #define Dl 27 /* long displacement from EIP */
150 #define o1 28 /* constant 1 */
151 #define o3 29 /* constant 3 */
152 #define OS 30 /* immediate offset/segment */
153 #define ST 31 /* FP stack top */
154 #define STI 32 /* FP stack */
155 #define X 33 /* extended FP op */
156 #define XA 34 /* for 'fstcw %ax' */
157 #define El 35 /* address, long/quad size */
158 #define Ril 36 /* long register in instruction */
159 #define Iba 37 /* byte immediate, don't print if 0xa */
160 #define EL 38 /* address, explicitly long size */
161 /* Wine extensions */
162 #define MX 39 /* special register (MMX reg %mm0-7) */
163 #define EMX 40 /* special register (MMX reg %mm0-7) */
164 #define XMM 41 /* special register (floating point reg %xmm0-7) */
165 #define EXMM 42 /* special register (floating point reg %xmm0-7) */
167 struct inst {
168 const char * i_name; /* name */
169 short i_has_modrm; /* has regmodrm byte */
170 short i_size; /* operand size */
171 int i_mode; /* addressing modes */
172 const void * i_extra; /* pointer to extra opcode table */
175 #define op1(x) (x)
176 #define op2(x,y) ((x)|((y)<<8))
177 #define op3(x,y,z) ((x)|((y)<<8)|((z)<<16))
179 struct finst {
180 const char * f_name; /* name for memory instruction */
181 int f_size; /* size for memory instruction */
182 int f_rrmode; /* mode for rr instruction */
183 const void * f_rrname; /* name for rr instruction
184 (or pointer to table) */
187 static const char * const db_Grp6[] = {
188 "sldt",
189 "str",
190 "lldt",
191 "ltr",
192 "verr",
193 "verw",
198 static const char * const db_Grp7[] = {
199 "sgdt",
200 "sidt",
201 "lgdt",
202 "lidt",
203 "smsw",
205 "lmsw",
206 "invlpg"
209 static const char * const db_Grp8[] = {
214 "bt",
215 "bts",
216 "btr",
217 "btc"
220 static const char * const db_Grp9[] = {
222 "cmpxchg8b",
231 static const char * const db_Grp15[] = {
232 "fxsave",
233 "fxrstor",
234 "ldmxcsr",
235 "stmxcsr",
239 "clflush"
242 static const char * const db_Grp15b[] = {
248 "lfence",
249 "mfence",
250 "sfence"
253 static const struct inst db_inst_0f0x[] = {
254 /*00*/ { "", TRUE, NONE, op1(Ew), db_Grp6 },
255 /*01*/ { "", TRUE, NONE, op1(Ew), db_Grp7 },
256 /*02*/ { "lar", TRUE, LONG, op2(E,R), 0 },
257 /*03*/ { "lsl", TRUE, LONG, op2(E,R), 0 },
258 /*04*/ { "", FALSE, NONE, 0, 0 },
259 /*05*/ { "syscall",FALSE,NONE, 0, 0 },
260 /*06*/ { "clts", FALSE, NONE, 0, 0 },
261 /*07*/ { "sysret",FALSE, NONE, 0, 0 },
263 /*08*/ { "invd", FALSE, NONE, 0, 0 },
264 /*09*/ { "wbinvd",FALSE, NONE, 0, 0 },
265 /*0a*/ { "", FALSE, NONE, 0, 0 },
266 /*0b*/ { "", FALSE, NONE, 0, 0 },
267 /*0c*/ { "", FALSE, NONE, 0, 0 },
268 /*0d*/ { "", FALSE, NONE, 0, 0 },
269 /*0e*/ { "", FALSE, NONE, 0, 0 },
270 /*0f*/ { "", FALSE, NONE, 0, 0 },
273 static const struct inst db_inst_0f1x[] = {
274 /*10*/ { "movups",TRUE, NONE, op2(E, XMM), 0 },
275 /*11*/ { "movups",TRUE, NONE, op2(XMM, E), 0 },
276 /*12*/ { "", FALSE, NONE, 0, 0 },
277 /*13*/ { "", FALSE, NONE, 0, 0 },
278 /*14*/ { "", FALSE, NONE, 0, 0 },
279 /*15*/ { "", FALSE, NONE, 0, 0 },
280 /*16*/ { "", FALSE, NONE, 0, 0 },
281 /*17*/ { "", FALSE, NONE, 0, 0 },
283 /*18*/ { "", FALSE, NONE, 0, 0 },
284 /*19*/ { "", FALSE, NONE, 0, 0 },
285 /*1a*/ { "", FALSE, NONE, 0, 0 },
286 /*1b*/ { "", FALSE, NONE, 0, 0 },
287 /*1c*/ { "", FALSE, NONE, 0, 0 },
288 /*1d*/ { "", FALSE, NONE, 0, 0 },
289 /*1e*/ { "", FALSE, NONE, 0, 0 },
290 /*1f*/ { "", FALSE, NONE, 0, 0 },
293 static const struct inst db_inst_0f2x[] = {
294 /*20*/ { "mov", TRUE, LONG, op2(CR,El), 0 },
295 /*21*/ { "mov", TRUE, LONG, op2(DR,El), 0 },
296 /*22*/ { "mov", TRUE, LONG, op2(El,CR), 0 },
297 /*23*/ { "mov", TRUE, LONG, op2(El,DR), 0 },
298 /*24*/ { "mov", TRUE, LONG, op2(TR,El), 0 },
299 /*25*/ { "", FALSE, NONE, 0, 0 },
300 /*26*/ { "mov", TRUE, LONG, op2(El,TR), 0 },
301 /*27*/ { "", FALSE, NONE, 0, 0 },
303 /*28*/ { "movaps",TRUE, NONE, op2(E, XMM), 0 },
304 /*29*/ { "movaps",TRUE, NONE, op2(XMM, E), 0 },
305 /*2a*/ { "", FALSE, NONE, 0, 0 },
306 /*2b*/ { "", FALSE, NONE, 0, 0 },
307 /*2c*/ { "", FALSE, NONE, 0, 0 },
308 /*2d*/ { "", FALSE, NONE, 0, 0 },
309 /*2e*/ { "", FALSE, NONE, 0, 0 },
310 /*2f*/ { "", FALSE, NONE, 0, 0 },
313 static const struct inst db_inst_0f3x[] = {
314 /*30*/ { "wrmsr", FALSE, NONE, 0, 0 },
315 /*31*/ { "rdtsc", FALSE, NONE, 0, 0 },
316 /*32*/ { "rdmsr", FALSE, NONE, 0, 0 },
317 /*33*/ { "rdpmc", FALSE, NONE, 0, 0 },
318 /*34*/ { "sysenter",FALSE,NONE, 0, 0 },
319 /*35*/ { "sysexit",FALSE,NONE, 0, 0 },
320 /*36*/ { "", FALSE, NONE, 0, 0 },
321 /*37*/ { "getsec",FALSE, NONE, 0, 0 },
323 /*38*/ { "", FALSE, NONE, 0, 0 },
324 /*39*/ { "", FALSE, NONE, 0, 0 },
325 /*3a*/ { "", FALSE, NONE, 0, 0 },
326 /*3b*/ { "", FALSE, NONE, 0, 0 },
327 /*3c*/ { "", FALSE, NONE, 0, 0 },
328 /*3d*/ { "", FALSE, NONE, 0, 0 },
329 /*3e*/ { "", FALSE, NONE, 0, 0 },
330 /*3f*/ { "", FALSE, NONE, 0, 0 },
333 static const struct inst db_inst_0f4x[] = {
334 /*40*/ { "cmovo", TRUE, NONE, op2(E, R), 0 },
335 /*41*/ { "cmovno", TRUE, NONE, op2(E, R), 0 },
336 /*42*/ { "cmovb", TRUE, NONE, op2(E, R), 0 },
337 /*43*/ { "cmovnb", TRUE, NONE, op2(E, R), 0 },
338 /*44*/ { "cmovz", TRUE, NONE, op2(E, R), 0 },
339 /*45*/ { "cmovnz", TRUE, NONE, op2(E, R), 0 },
340 /*46*/ { "cmovbe", TRUE, NONE, op2(E, R), 0 },
341 /*47*/ { "cmovnbe",TRUE, NONE, op2(E, R), 0 },
343 /*48*/ { "cmovs", TRUE, NONE, op2(E, R), 0 },
344 /*49*/ { "cmovns", TRUE, NONE, op2(E, R), 0 },
345 /*4a*/ { "cmovp", TRUE, NONE, op2(E, R), 0 },
346 /*4b*/ { "cmovnp", TRUE, NONE, op2(E, R), 0 },
347 /*4c*/ { "cmovl", TRUE, NONE, op2(E, R), 0 },
348 /*4d*/ { "cmovnl", TRUE, NONE, op2(E, R), 0 },
349 /*4e*/ { "cmovle", TRUE, NONE, op2(E, R), 0 },
350 /*4f*/ { "cmovnle",TRUE, NONE, op2(E, R), 0 },
353 static const struct inst db_inst_0f5x[] = {
354 /*50*/ { "movmskps",TRUE, NONE, op2(EXMM, R), 0 },
355 /*51*/ { "sqrtps", TRUE, NONE, op2(EXMM, XMM), 0 },
356 /*52*/ { "rsqrtps", TRUE, NONE, op2(EXMM, XMM), 0 },
357 /*53*/ { "rcpps", TRUE, NONE, op2(EXMM, XMM), 0 },
358 /*54*/ { "andps", TRUE, NONE, op2(EXMM, XMM), 0 },
359 /*55*/ { "andnps", TRUE, NONE, op2(EXMM, XMM), 0 },
360 /*56*/ { "orps", TRUE, NONE, op2(EXMM, XMM), 0 },
361 /*57*/ { "xorps", TRUE, NONE, op2(EXMM, XMM), 0 },
363 /*58*/ { "addps", TRUE, NONE, op2(EXMM, XMM), 0 },
364 /*59*/ { "mulps", TRUE, NONE, op2(EXMM, XMM), 0 },
365 /*5a*/ { "cvtps2pd",TRUE, NONE, op2(EXMM, XMM), 0 },
366 /*5b*/ { "cvtdq2ps",TRUE, NONE, op2(EXMM, XMM), 0 },
367 /*5c*/ { "subps", TRUE, NONE, op2(EXMM, XMM), 0 },
368 /*5d*/ { "minps", TRUE, NONE, op2(EXMM, XMM), 0 },
369 /*5e*/ { "divps", TRUE, NONE, op2(EXMM, XMM), 0 },
370 /*5f*/ { "maxps", TRUE, NONE, op2(EXMM, XMM), 0 },
373 static const struct inst db_inst_0f6x[] = {
374 /*60*/ { "punpcklbw", TRUE, NONE, op2(E, MX), 0 },
375 /*61*/ { "punpcklwd", TRUE, NONE, op2(E, MX), 0 },
376 /*62*/ { "punpckldq", TRUE, NONE, op2(E, MX), 0 },
377 /*63*/ { "packsswb", TRUE, NONE, op2(E, MX), 0 },
378 /*64*/ { "pcmpgtb", TRUE, NONE, op2(E, MX), 0 },
379 /*65*/ { "pcmpgtw", TRUE, NONE, op2(E, MX), 0 },
380 /*66*/ { "pcmpgtd", TRUE, NONE, op2(E, MX), 0 },
381 /*67*/ { "packuswb", TRUE, NONE, op2(E, MX), 0 },
383 /*68*/ { "punpckhbw", TRUE, NONE, op2(E, MX), 0 },
384 /*69*/ { "punpckhwd", TRUE, NONE, op2(E, MX), 0 },
385 /*6a*/ { "punpckhdq", TRUE, NONE, op2(E, MX), 0 },
386 /*6b*/ { "packssdw", TRUE, NONE, op2(E, MX), 0 },
387 /*6c*/ { "(bad)", TRUE, NONE, 0, 0 },
388 /*6d*/ { "(bad)", TRUE, NONE, 0, 0 },
389 /*6e*/ { "movd", TRUE, NONE, op2(E, MX), 0 },
390 /*6f*/ { "movq", TRUE, NONE, op2(E, MX), 0 },
393 static const struct inst db_inst_0f7x[] = {
394 /*70*/ { "pshufw", TRUE, NONE, op2(MX, EMX), 0 },
395 /*71*/ { "(bad)", TRUE, NONE, 0, 0 }, /* FIXME: grp 12 */
396 /*72*/ { "(bad)", TRUE, NONE, 0, 0 }, /* FIXME: grp 13 */
397 /*73*/ { "(bad)", TRUE, NONE, 0, 0 }, /* FIXME: grp 14 */
398 /*74*/ { "pcmpeqb", TRUE, NONE, op2(E, MX), 0 },
399 /*75*/ { "pcmpeqw", TRUE, NONE, op2(E, MX), 0 },
400 /*76*/ { "pcmpeqd", TRUE, NONE, op2(E, MX), 0 },
401 /*77*/ { "emms", FALSE,NONE, 0, 0 },
403 /*78*/ { "(bad)", TRUE, NONE, 0, 0 },
404 /*79*/ { "(bad)", TRUE, NONE, 0, 0 },
405 /*7a*/ { "(bad)", TRUE, NONE, 0, 0 },
406 /*7b*/ { "(bad)", TRUE, NONE, 0, 0 },
407 /*7c*/ { "(bad)", TRUE, NONE, 0, 0 },
408 /*7d*/ { "(bad)", TRUE, NONE, 0, 0 },
409 /*7e*/ { "movd", TRUE, NONE, op2(E, MX), 0 },
410 /*7f*/ { "movq", TRUE, NONE, op2(EMX, MX), 0 },
413 static const struct inst db_inst_0f8x[] = {
414 /*80*/ { "jo", FALSE, NONE, op1(Dl), 0 },
415 /*81*/ { "jno", FALSE, NONE, op1(Dl), 0 },
416 /*82*/ { "jb", FALSE, NONE, op1(Dl), 0 },
417 /*83*/ { "jnb", FALSE, NONE, op1(Dl), 0 },
418 /*84*/ { "jz", FALSE, NONE, op1(Dl), 0 },
419 /*85*/ { "jnz", FALSE, NONE, op1(Dl), 0 },
420 /*86*/ { "jbe", FALSE, NONE, op1(Dl), 0 },
421 /*87*/ { "jnbe", FALSE, NONE, op1(Dl), 0 },
423 /*88*/ { "js", FALSE, NONE, op1(Dl), 0 },
424 /*89*/ { "jns", FALSE, NONE, op1(Dl), 0 },
425 /*8a*/ { "jp", FALSE, NONE, op1(Dl), 0 },
426 /*8b*/ { "jnp", FALSE, NONE, op1(Dl), 0 },
427 /*8c*/ { "jl", FALSE, NONE, op1(Dl), 0 },
428 /*8d*/ { "jnl", FALSE, NONE, op1(Dl), 0 },
429 /*8e*/ { "jle", FALSE, NONE, op1(Dl), 0 },
430 /*8f*/ { "jnle", FALSE, NONE, op1(Dl), 0 },
433 static const struct inst db_inst_0f9x[] = {
434 /*90*/ { "seto", TRUE, NONE, op1(Eb), 0 },
435 /*91*/ { "setno", TRUE, NONE, op1(Eb), 0 },
436 /*92*/ { "setb", TRUE, NONE, op1(Eb), 0 },
437 /*93*/ { "setnb", TRUE, NONE, op1(Eb), 0 },
438 /*94*/ { "setz", TRUE, NONE, op1(Eb), 0 },
439 /*95*/ { "setnz", TRUE, NONE, op1(Eb), 0 },
440 /*96*/ { "setbe", TRUE, NONE, op1(Eb), 0 },
441 /*97*/ { "setnbe",TRUE, NONE, op1(Eb), 0 },
443 /*98*/ { "sets", TRUE, NONE, op1(Eb), 0 },
444 /*99*/ { "setns", TRUE, NONE, op1(Eb), 0 },
445 /*9a*/ { "setp", TRUE, NONE, op1(Eb), 0 },
446 /*9b*/ { "setnp", TRUE, NONE, op1(Eb), 0 },
447 /*9c*/ { "setl", TRUE, NONE, op1(Eb), 0 },
448 /*9d*/ { "setnl", TRUE, NONE, op1(Eb), 0 },
449 /*9e*/ { "setle", TRUE, NONE, op1(Eb), 0 },
450 /*9f*/ { "setnle",TRUE, NONE, op1(Eb), 0 },
453 static const struct inst db_inst_0fax[] = {
454 /*a0*/ { "push", FALSE, NONE, op1(Si), 0 },
455 /*a1*/ { "pop", FALSE, NONE, op1(Si), 0 },
456 /*a2*/ { "cpuid", FALSE, NONE, 0, 0 },
457 /*a3*/ { "bt", TRUE, LONG, op2(R,E), 0 },
458 /*a4*/ { "shld", TRUE, LONG, op3(Ib,R,E), 0 },
459 /*a5*/ { "shld", TRUE, LONG, op3(CL,R,E), 0 },
460 /*a6*/ { "", FALSE, NONE, 0, 0 },
461 /*a7*/ { "", FALSE, NONE, 0, 0 },
463 /*a8*/ { "push", FALSE, NONE, op1(Si), 0 },
464 /*a9*/ { "pop", FALSE, NONE, op1(Si), 0 },
465 /*aa*/ { "rsm", FALSE, NONE, 0, 0 },
466 /*ab*/ { "bts", TRUE, LONG, op2(R,E), 0 },
467 /*ac*/ { "shrd", TRUE, LONG, op3(Ib,R,E), 0 },
468 /*ad*/ { "shrd", TRUE, LONG, op3(CL,R,E), 0 },
469 /*ae*/ { "", TRUE, LONG, op1(E), db_Grp15 },
470 /*af*/ { "imul", TRUE, LONG, op2(E,R), 0 },
473 static const struct inst db_inst_0fbx[] = {
474 /*b0*/ { "cmpxchg",TRUE, BYTE, op2(R, E), 0 },
475 /*b0*/ { "cmpxchg",TRUE, LONG, op2(R, E), 0 },
476 /*b2*/ { "lss", TRUE, LONG, op2(E, R), 0 },
477 /*b3*/ { "btr", TRUE, LONG, op2(R, E), 0 },
478 /*b4*/ { "lfs", TRUE, LONG, op2(E, R), 0 },
479 /*b5*/ { "lgs", TRUE, LONG, op2(E, R), 0 },
480 /*b6*/ { "movzb", TRUE, LONG, op2(Eb, R), 0 },
481 /*b7*/ { "movzw", TRUE, LONG, op2(Ew, R), 0 },
483 /*b8*/ { "", FALSE, NONE, 0, 0 },
484 /*b9*/ { "", FALSE, NONE, 0, 0 },
485 /*ba*/ { "", TRUE, LONG, op2(Ib, E), db_Grp8 },
486 /*bb*/ { "btc", TRUE, LONG, op2(R, E), 0 },
487 /*bc*/ { "bsf", TRUE, LONG, op2(E, R), 0 },
488 /*bd*/ { "bsr", TRUE, LONG, op2(E, R), 0 },
489 /*be*/ { "movsb", TRUE, LONG, op2(Eb, R), 0 },
490 /*bf*/ { "movsw", TRUE, LONG, op2(Ew, R), 0 },
493 static const struct inst db_inst_0fcx[] = {
494 /*c0*/ { "xadd", TRUE, BYTE, op2(R, E), 0 },
495 /*c1*/ { "xadd", TRUE, LONG, op2(R, E), 0 },
496 /*c2*/ { "", FALSE, NONE, 0, 0 },
497 /*c3*/ { "", FALSE, NONE, 0, 0 },
498 /*c4*/ { "", FALSE, NONE, 0, 0 },
499 /*c5*/ { "", FALSE, NONE, 0, 0 },
500 /*c6*/ { "", FALSE, NONE, 0, 0 },
501 /*c7*/ { "", TRUE, NONE, op1(E), db_Grp9 },
502 /*c8*/ { "bswap", FALSE, LONG, op1(Ril), 0 },
503 /*c9*/ { "bswap", FALSE, LONG, op1(Ril), 0 },
504 /*ca*/ { "bswap", FALSE, LONG, op1(Ril), 0 },
505 /*cb*/ { "bswap", FALSE, LONG, op1(Ril), 0 },
506 /*cc*/ { "bswap", FALSE, LONG, op1(Ril), 0 },
507 /*cd*/ { "bswap", FALSE, LONG, op1(Ril), 0 },
508 /*ce*/ { "bswap", FALSE, LONG, op1(Ril), 0 },
509 /*cf*/ { "bswap", FALSE, LONG, op1(Ril), 0 },
512 static const struct inst * const db_inst_0f[] = {
513 db_inst_0f0x,
514 db_inst_0f1x,
515 db_inst_0f2x,
516 db_inst_0f3x,
517 db_inst_0f4x,
518 db_inst_0f5x,
519 db_inst_0f6x,
520 db_inst_0f7x,
521 db_inst_0f8x,
522 db_inst_0f9x,
523 db_inst_0fax,
524 db_inst_0fbx,
525 db_inst_0fcx,
531 static const char * const db_Esc92[] = {
532 "fnop", "", "", "", "", "", "", ""
534 static const char * const db_Esc94[] = {
535 "fchs", "fabs", "", "", "ftst", "fxam", "", ""
537 static const char * const db_Esc95[] = {
538 "fld1", "fldl2t","fldl2e","fldpi","fldlg2","fldln2","fldz",""
540 static const char * const db_Esc96[] = {
541 "f2xm1","fyl2x","fptan","fpatan","fxtract","fprem1","fdecstp",
542 "fincstp"
544 static const char * const db_Esc97[] = {
545 "fprem","fyl2xp1","fsqrt","fsincos","frndint","fscale","fsin","fcos"
548 static const char * const db_Esca5[] = {
549 "", "fucompp","", "", "", "", "", ""
552 static const char * const db_Escb4[] = {
553 "fneni","fndisi", "fnclex","fninit","fsetpm", "", "", ""
556 static const char * const db_Esce3[] = {
557 "", "fcompp","", "", "", "", "", ""
560 static const char * const db_Escf4[] = {
561 "fnstsw","", "", "", "", "", "", ""
564 static const struct finst db_Esc8[] = {
565 /*0*/ { "fadd", SNGL, op2(STI,ST), 0 },
566 /*1*/ { "fmul", SNGL, op2(STI,ST), 0 },
567 /*2*/ { "fcom", SNGL, op2(STI,ST), 0 },
568 /*3*/ { "fcomp", SNGL, op2(STI,ST), 0 },
569 /*4*/ { "fsub", SNGL, op2(STI,ST), 0 },
570 /*5*/ { "fsubr", SNGL, op2(STI,ST), 0 },
571 /*6*/ { "fdiv", SNGL, op2(STI,ST), 0 },
572 /*7*/ { "fdivr", SNGL, op2(STI,ST), 0 },
575 static const struct finst db_Esc9[] = {
576 /*0*/ { "fld", SNGL, op1(STI), 0 },
577 /*1*/ { "", NONE, op1(STI), "fxch" },
578 /*2*/ { "fst", SNGL, op1(X), db_Esc92 },
579 /*3*/ { "fstp", SNGL, 0, 0 },
580 /*4*/ { "fldenv", NONE, op1(X), db_Esc94 },
581 /*5*/ { "fldcw", NONE, op1(X), db_Esc95 },
582 /*6*/ { "fnstenv",NONE, op1(X), db_Esc96 },
583 /*7*/ { "fnstcw", NONE, op1(X), db_Esc97 },
586 static const struct finst db_Esca[] = {
587 /*0*/ { "fiadd", LONG, 0, 0 },
588 /*1*/ { "fimul", LONG, 0, 0 },
589 /*2*/ { "ficom", LONG, 0, 0 },
590 /*3*/ { "ficomp", LONG, 0, 0 },
591 /*4*/ { "fisub", LONG, 0, 0 },
592 /*5*/ { "fisubr", LONG, op1(X), db_Esca5 },
593 /*6*/ { "fidiv", LONG, 0, 0 },
594 /*7*/ { "fidivr", LONG, 0, 0 }
597 static const struct finst db_Escb[] = {
598 /*0*/ { "fild", LONG, 0, 0 },
599 /*1*/ { "", NONE, 0, 0 },
600 /*2*/ { "fist", LONG, 0, 0 },
601 /*3*/ { "fistp", LONG, 0, 0 },
602 /*4*/ { "", WORD, op1(X), db_Escb4 },
603 /*5*/ { "fld", EXTR, 0, 0 },
604 /*6*/ { "", WORD, 0, 0 },
605 /*7*/ { "fstp", EXTR, 0, 0 },
608 static const struct finst db_Escc[] = {
609 /*0*/ { "fadd", DBLR, op2(ST,STI), 0 },
610 /*1*/ { "fmul", DBLR, op2(ST,STI), 0 },
611 /*2*/ { "fcom", DBLR, 0, 0 },
612 /*3*/ { "fcomp", DBLR, 0, 0 },
613 /*4*/ { "fsub", DBLR, op2(ST,STI), "fsubr" },
614 /*5*/ { "fsubr", DBLR, op2(ST,STI), "fsub" },
615 /*6*/ { "fdiv", DBLR, op2(ST,STI), "fdivr" },
616 /*7*/ { "fdivr", DBLR, op2(ST,STI), "fdiv" },
619 static const struct finst db_Escd[] = {
620 /*0*/ { "fld", DBLR, op1(STI), "ffree" },
621 /*1*/ { "", NONE, 0, 0 },
622 /*2*/ { "fst", DBLR, op1(STI), 0 },
623 /*3*/ { "fstp", DBLR, op1(STI), 0 },
624 /*4*/ { "frstor", NONE, op1(STI), "fucom" },
625 /*5*/ { "", NONE, op1(STI), "fucomp" },
626 /*6*/ { "fnsave", NONE, 0, 0 },
627 /*7*/ { "fnstsw", NONE, 0, 0 },
630 static const struct finst db_Esce[] = {
631 /*0*/ { "fiadd", WORD, op2(ST,STI), "faddp" },
632 /*1*/ { "fimul", WORD, op2(ST,STI), "fmulp" },
633 /*2*/ { "ficom", WORD, 0, 0 },
634 /*3*/ { "ficomp", WORD, op1(X), db_Esce3 },
635 /*4*/ { "fisub", WORD, op2(ST,STI), "fsubrp" },
636 /*5*/ { "fisubr", WORD, op2(ST,STI), "fsubp" },
637 /*6*/ { "fidiv", WORD, op2(ST,STI), "fdivrp" },
638 /*7*/ { "fidivr", WORD, op2(ST,STI), "fdivp" },
641 static const struct finst db_Escf[] = {
642 /*0*/ { "fild", WORD, 0, 0 },
643 /*1*/ { "", NONE, 0, 0 },
644 /*2*/ { "fist", WORD, 0, 0 },
645 /*3*/ { "fistp", WORD, 0, 0 },
646 /*4*/ { "fbld", NONE, op1(XA), db_Escf4 },
647 /*5*/ { "fild", QUAD, 0, 0 },
648 /*6*/ { "fbstp", NONE, 0, 0 },
649 /*7*/ { "fistp", QUAD, 0, 0 },
652 static const struct finst * const db_Esc_inst[] = {
653 db_Esc8, db_Esc9, db_Esca, db_Escb,
654 db_Escc, db_Escd, db_Esce, db_Escf
657 static const char * const db_Grp1[] = {
658 "add",
659 "or",
660 "adc",
661 "sbb",
662 "and",
663 "sub",
664 "xor",
665 "cmp"
668 static const char * const db_Grp2[] = {
669 "rol",
670 "ror",
671 "rcl",
672 "rcr",
673 "shl",
674 "shr",
675 "shl",
676 "sar"
679 static const struct inst db_Grp3[] = {
680 { "test", TRUE, NONE, op2(I,E), 0 },
681 { "test", TRUE, NONE, op2(I,E), 0 },
682 { "not", TRUE, NONE, op1(E), 0 },
683 { "neg", TRUE, NONE, op1(E), 0 },
684 { "mul", TRUE, NONE, op2(E,A), 0 },
685 { "imul", TRUE, NONE, op2(E,A), 0 },
686 { "div", TRUE, NONE, op2(E,A), 0 },
687 { "idiv", TRUE, NONE, op2(E,A), 0 },
690 static const struct inst db_Grp4[] = {
691 { "inc", TRUE, BYTE, op1(E), 0 },
692 { "dec", TRUE, BYTE, op1(E), 0 },
693 { "", TRUE, NONE, 0, 0 },
694 { "", TRUE, NONE, 0, 0 },
695 { "", TRUE, NONE, 0, 0 },
696 { "", TRUE, NONE, 0, 0 },
697 { "", TRUE, NONE, 0, 0 },
698 { "", TRUE, NONE, 0, 0 }
701 static const struct inst db_Grp5[] = {
702 { "inc", TRUE, LONG, op1(E), 0 },
703 { "dec", TRUE, LONG, op1(E), 0 },
704 { "call", TRUE, LONG, op1(Eind),0 },
705 { "lcall", TRUE, LONG, op1(Eind),0 },
706 { "jmp", TRUE, LONG, op1(Eind),0 },
707 { "ljmp", TRUE, LONG, op1(Eind),0 },
708 { "push", TRUE, LONG, op1(E), 0 },
709 { "", TRUE, NONE, 0, 0 }
712 static const struct inst db_inst_table[256] = {
713 /*00*/ { "add", TRUE, BYTE, op2(R, E), 0 },
714 /*01*/ { "add", TRUE, LONG, op2(R, E), 0 },
715 /*02*/ { "add", TRUE, BYTE, op2(E, R), 0 },
716 /*03*/ { "add", TRUE, LONG, op2(E, R), 0 },
717 /*04*/ { "add", FALSE, BYTE, op2(I, A), 0 },
718 /*05*/ { "add", FALSE, LONG, op2(Is, A), 0 },
719 /*06*/ { "push", FALSE, NONE, op1(Si), 0 },
720 /*07*/ { "pop", FALSE, NONE, op1(Si), 0 },
722 /*08*/ { "or", TRUE, BYTE, op2(R, E), 0 },
723 /*09*/ { "or", TRUE, LONG, op2(R, E), 0 },
724 /*0a*/ { "or", TRUE, BYTE, op2(E, R), 0 },
725 /*0b*/ { "or", TRUE, LONG, op2(E, R), 0 },
726 /*0c*/ { "or", FALSE, BYTE, op2(I, A), 0 },
727 /*0d*/ { "or", FALSE, LONG, op2(I, A), 0 },
728 /*0e*/ { "push", FALSE, NONE, op1(Si), 0 },
729 /*0f*/ { "", FALSE, NONE, 0, 0 },
731 /*10*/ { "adc", TRUE, BYTE, op2(R, E), 0 },
732 /*11*/ { "adc", TRUE, LONG, op2(R, E), 0 },
733 /*12*/ { "adc", TRUE, BYTE, op2(E, R), 0 },
734 /*13*/ { "adc", TRUE, LONG, op2(E, R), 0 },
735 /*14*/ { "adc", FALSE, BYTE, op2(I, A), 0 },
736 /*15*/ { "adc", FALSE, LONG, op2(Is, A), 0 },
737 /*16*/ { "push", FALSE, NONE, op1(Si), 0 },
738 /*17*/ { "pop", FALSE, NONE, op1(Si), 0 },
740 /*18*/ { "sbb", TRUE, BYTE, op2(R, E), 0 },
741 /*19*/ { "sbb", TRUE, LONG, op2(R, E), 0 },
742 /*1a*/ { "sbb", TRUE, BYTE, op2(E, R), 0 },
743 /*1b*/ { "sbb", TRUE, LONG, op2(E, R), 0 },
744 /*1c*/ { "sbb", FALSE, BYTE, op2(I, A), 0 },
745 /*1d*/ { "sbb", FALSE, LONG, op2(Is, A), 0 },
746 /*1e*/ { "push", FALSE, NONE, op1(Si), 0 },
747 /*1f*/ { "pop", FALSE, NONE, op1(Si), 0 },
749 /*20*/ { "and", TRUE, BYTE, op2(R, E), 0 },
750 /*21*/ { "and", TRUE, LONG, op2(R, E), 0 },
751 /*22*/ { "and", TRUE, BYTE, op2(E, R), 0 },
752 /*23*/ { "and", TRUE, LONG, op2(E, R), 0 },
753 /*24*/ { "and", FALSE, BYTE, op2(I, A), 0 },
754 /*25*/ { "and", FALSE, LONG, op2(I, A), 0 },
755 /*26*/ { "", FALSE, NONE, 0, 0 },
756 /*27*/ { "daa", FALSE, NONE, 0, 0 },
758 /*28*/ { "sub", TRUE, BYTE, op2(R, E), 0 },
759 /*29*/ { "sub", TRUE, LONG, op2(R, E), 0 },
760 /*2a*/ { "sub", TRUE, BYTE, op2(E, R), 0 },
761 /*2b*/ { "sub", TRUE, LONG, op2(E, R), 0 },
762 /*2c*/ { "sub", FALSE, BYTE, op2(I, A), 0 },
763 /*2d*/ { "sub", FALSE, LONG, op2(Is, A), 0 },
764 /*2e*/ { "", FALSE, NONE, 0, 0 },
765 /*2f*/ { "das", FALSE, NONE, 0, 0 },
767 /*30*/ { "xor", TRUE, BYTE, op2(R, E), 0 },
768 /*31*/ { "xor", TRUE, LONG, op2(R, E), 0 },
769 /*32*/ { "xor", TRUE, BYTE, op2(E, R), 0 },
770 /*33*/ { "xor", TRUE, LONG, op2(E, R), 0 },
771 /*34*/ { "xor", FALSE, BYTE, op2(I, A), 0 },
772 /*35*/ { "xor", FALSE, LONG, op2(I, A), 0 },
773 /*36*/ { "", FALSE, NONE, 0, 0 },
774 /*37*/ { "aaa", FALSE, NONE, 0, 0 },
776 /*38*/ { "cmp", TRUE, BYTE, op2(R, E), 0 },
777 /*39*/ { "cmp", TRUE, LONG, op2(R, E), 0 },
778 /*3a*/ { "cmp", TRUE, BYTE, op2(E, R), 0 },
779 /*3b*/ { "cmp", TRUE, LONG, op2(E, R), 0 },
780 /*3c*/ { "cmp", FALSE, BYTE, op2(I, A), 0 },
781 /*3d*/ { "cmp", FALSE, LONG, op2(Is, A), 0 },
782 /*3e*/ { "", FALSE, NONE, 0, 0 },
783 /*3f*/ { "aas", FALSE, NONE, 0, 0 },
785 /*40*/ { "rex", FALSE, NONE, 0, 0 },
786 /*41*/ { "rex.b", FALSE, NONE, 0, 0 },
787 /*42*/ { "rex.x", FALSE, NONE, 0, 0 },
788 /*43*/ { "rex.xb", FALSE, NONE, 0, 0 },
789 /*44*/ { "rex.r", FALSE, NONE, 0, 0 },
790 /*45*/ { "rex.rb", FALSE, NONE, 0, 0 },
791 /*46*/ { "rex.rx", FALSE, NONE, 0, 0 },
792 /*47*/ { "rex.rxb", FALSE, NONE, 0, 0 },
794 /*48*/ { "rex.w", FALSE, NONE, 0, 0 },
795 /*49*/ { "rex.wb", FALSE, NONE, 0, 0 },
796 /*4a*/ { "rex.wx", FALSE, NONE, 0, 0 },
797 /*4b*/ { "rex.wxb", FALSE, NONE, 0, 0 },
798 /*4c*/ { "rex.wr", FALSE, NONE, 0, 0 },
799 /*4d*/ { "rex.wrb", FALSE, NONE, 0, 0 },
800 /*4e*/ { "rex.wrx", FALSE, NONE, 0, 0 },
801 /*4f*/ { "rex.wrxb", FALSE, NONE, 0, 0 },
803 /*50*/ { "push", FALSE, LONG, op1(Ri), 0 },
804 /*51*/ { "push", FALSE, LONG, op1(Ri), 0 },
805 /*52*/ { "push", FALSE, LONG, op1(Ri), 0 },
806 /*53*/ { "push", FALSE, LONG, op1(Ri), 0 },
807 /*54*/ { "push", FALSE, LONG, op1(Ri), 0 },
808 /*55*/ { "push", FALSE, LONG, op1(Ri), 0 },
809 /*56*/ { "push", FALSE, LONG, op1(Ri), 0 },
810 /*57*/ { "push", FALSE, LONG, op1(Ri), 0 },
812 /*58*/ { "pop", FALSE, LONG, op1(Ri), 0 },
813 /*59*/ { "pop", FALSE, LONG, op1(Ri), 0 },
814 /*5a*/ { "pop", FALSE, LONG, op1(Ri), 0 },
815 /*5b*/ { "pop", FALSE, LONG, op1(Ri), 0 },
816 /*5c*/ { "pop", FALSE, LONG, op1(Ri), 0 },
817 /*5d*/ { "pop", FALSE, LONG, op1(Ri), 0 },
818 /*5e*/ { "pop", FALSE, LONG, op1(Ri), 0 },
819 /*5f*/ { "pop", FALSE, LONG, op1(Ri), 0 },
821 /*60*/ { "pusha", FALSE, LONG, 0, 0 },
822 /*61*/ { "popa", FALSE, LONG, 0, 0 },
823 /*62*/ { "bound", TRUE, LONG, op2(E, R), 0 },
824 /*63*/ { "movslq", TRUE, NONE, op2(EL,R), 0 },
826 /*64*/ { "", FALSE, NONE, 0, 0 },
827 /*65*/ { "", FALSE, NONE, 0, 0 },
828 /*66*/ { "", FALSE, NONE, 0, 0 },
829 /*67*/ { "", FALSE, NONE, 0, 0 },
831 /*68*/ { "push", FALSE, LONG, op1(I), 0 },
832 /*69*/ { "imul", TRUE, LONG, op3(I,E,R), 0 },
833 /*6a*/ { "push", FALSE, LONG, op1(Ibs), 0 },
834 /*6b*/ { "imul", TRUE, LONG, op3(Ibs,E,R),0 },
835 /*6c*/ { "ins", FALSE, BYTE, op2(DX, DI), 0 },
836 /*6d*/ { "ins", FALSE, LONG, op2(DX, DI), 0 },
837 /*6e*/ { "outs", FALSE, BYTE, op2(SI, DX), 0 },
838 /*6f*/ { "outs", FALSE, LONG, op2(SI, DX), 0 },
840 /*70*/ { "jo", FALSE, NONE, op1(Db), 0 },
841 /*71*/ { "jno", FALSE, NONE, op1(Db), 0 },
842 /*72*/ { "jb", FALSE, NONE, op1(Db), 0 },
843 /*73*/ { "jnb", FALSE, NONE, op1(Db), 0 },
844 /*74*/ { "jz", FALSE, NONE, op1(Db), 0 },
845 /*75*/ { "jnz", FALSE, NONE, op1(Db), 0 },
846 /*76*/ { "jbe", FALSE, NONE, op1(Db), 0 },
847 /*77*/ { "jnbe", FALSE, NONE, op1(Db), 0 },
849 /*78*/ { "js", FALSE, NONE, op1(Db), 0 },
850 /*79*/ { "jns", FALSE, NONE, op1(Db), 0 },
851 /*7a*/ { "jp", FALSE, NONE, op1(Db), 0 },
852 /*7b*/ { "jnp", FALSE, NONE, op1(Db), 0 },
853 /*7c*/ { "jl", FALSE, NONE, op1(Db), 0 },
854 /*7d*/ { "jnl", FALSE, NONE, op1(Db), 0 },
855 /*7e*/ { "jle", FALSE, NONE, op1(Db), 0 },
856 /*7f*/ { "jnle", FALSE, NONE, op1(Db), 0 },
858 /*80*/ { "", TRUE, BYTE, op2(I, E), db_Grp1 },
859 /*81*/ { "", TRUE, LONG, op2(I, E), db_Grp1 },
860 /*82*/ { "", TRUE, BYTE, op2(I, E), db_Grp1 },
861 /*83*/ { "", TRUE, LONG, op2(Ibs,E), db_Grp1 },
862 /*84*/ { "test", TRUE, BYTE, op2(R, E), 0 },
863 /*85*/ { "test", TRUE, LONG, op2(R, E), 0 },
864 /*86*/ { "xchg", TRUE, BYTE, op2(R, E), 0 },
865 /*87*/ { "xchg", TRUE, LONG, op2(R, E), 0 },
867 /*88*/ { "mov", TRUE, BYTE, op2(R, E), 0 },
868 /*89*/ { "mov", TRUE, LONG, op2(R, E), 0 },
869 /*8a*/ { "mov", TRUE, BYTE, op2(E, R), 0 },
870 /*8b*/ { "mov", TRUE, LONG, op2(E, R), 0 },
871 /*8c*/ { "mov", TRUE, NONE, op2(S, Ew), 0 },
872 /*8d*/ { "lea", TRUE, LONG, op2(E, R), 0 },
873 /*8e*/ { "mov", TRUE, NONE, op2(Ew, S), 0 },
874 /*8f*/ { "pop", TRUE, LONG, op1(E), 0 },
876 /*90*/ { "nop", FALSE, NONE, 0, 0 },
877 /*91*/ { "xchg", FALSE, LONG, op2(A, Ri), 0 },
878 /*92*/ { "xchg", FALSE, LONG, op2(A, Ri), 0 },
879 /*93*/ { "xchg", FALSE, LONG, op2(A, Ri), 0 },
880 /*94*/ { "xchg", FALSE, LONG, op2(A, Ri), 0 },
881 /*95*/ { "xchg", FALSE, LONG, op2(A, Ri), 0 },
882 /*96*/ { "xchg", FALSE, LONG, op2(A, Ri), 0 },
883 /*97*/ { "xchg", FALSE, LONG, op2(A, Ri), 0 },
885 /*98*/ { "cbw", FALSE, SDEP, 0, "cwde" }, /* cbw/cwde */
886 /*99*/ { "cwd", FALSE, SDEP, 0, "cdq" }, /* cwd/cdq */
887 /*9a*/ { "lcall", FALSE, NONE, op1(OS), 0 },
888 /*9b*/ { "wait", FALSE, NONE, 0, 0 },
889 /*9c*/ { "pushf", FALSE, LONG, 0, 0 },
890 /*9d*/ { "popf", FALSE, LONG, 0, 0 },
891 /*9e*/ { "sahf", FALSE, NONE, 0, 0 },
892 /*9f*/ { "lahf", FALSE, NONE, 0, 0 },
894 /*a0*/ { "mov", FALSE, BYTE, op2(O, A), 0 },
895 /*a1*/ { "mov", FALSE, LONG, op2(O, A), 0 },
896 /*a2*/ { "mov", FALSE, BYTE, op2(A, O), 0 },
897 /*a3*/ { "mov", FALSE, LONG, op2(A, O), 0 },
898 /*a4*/ { "movs", FALSE, BYTE, op2(SI,DI), 0 },
899 /*a5*/ { "movs", FALSE, LONG, op2(SI,DI), 0 },
900 /*a6*/ { "cmps", FALSE, BYTE, op2(SI,DI), 0 },
901 /*a7*/ { "cmps", FALSE, LONG, op2(SI,DI), 0 },
903 /*a8*/ { "test", FALSE, BYTE, op2(I, A), 0 },
904 /*a9*/ { "test", FALSE, LONG, op2(I, A), 0 },
905 /*aa*/ { "stos", FALSE, BYTE, op1(DI), 0 },
906 /*ab*/ { "stos", FALSE, LONG, op1(DI), 0 },
907 /*ac*/ { "lods", FALSE, BYTE, op1(SI), 0 },
908 /*ad*/ { "lods", FALSE, LONG, op1(SI), 0 },
909 /*ae*/ { "scas", FALSE, BYTE, op1(SI), 0 },
910 /*af*/ { "scas", FALSE, LONG, op1(SI), 0 },
912 /*b0*/ { "mov", FALSE, BYTE, op2(I, Ri), 0 },
913 /*b1*/ { "mov", FALSE, BYTE, op2(I, Ri), 0 },
914 /*b2*/ { "mov", FALSE, BYTE, op2(I, Ri), 0 },
915 /*b3*/ { "mov", FALSE, BYTE, op2(I, Ri), 0 },
916 /*b4*/ { "mov", FALSE, BYTE, op2(I, Ri), 0 },
917 /*b5*/ { "mov", FALSE, BYTE, op2(I, Ri), 0 },
918 /*b6*/ { "mov", FALSE, BYTE, op2(I, Ri), 0 },
919 /*b7*/ { "mov", FALSE, BYTE, op2(I, Ri), 0 },
921 /*b8*/ { "mov", FALSE, LONG, op2(Ilq, Ri), 0 },
922 /*b9*/ { "mov", FALSE, LONG, op2(Ilq, Ri), 0 },
923 /*ba*/ { "mov", FALSE, LONG, op2(Ilq, Ri), 0 },
924 /*bb*/ { "mov", FALSE, LONG, op2(Ilq, Ri), 0 },
925 /*bc*/ { "mov", FALSE, LONG, op2(Ilq, Ri), 0 },
926 /*bd*/ { "mov", FALSE, LONG, op2(Ilq, Ri), 0 },
927 /*be*/ { "mov", FALSE, LONG, op2(Ilq, Ri), 0 },
928 /*bf*/ { "mov", FALSE, LONG, op2(Ilq, Ri), 0 },
930 /*c0*/ { "", TRUE, BYTE, op2(Ib, E), db_Grp2 },
931 /*c1*/ { "", TRUE, LONG, op2(Ib, E), db_Grp2 },
932 /*c2*/ { "ret", FALSE, NONE, op1(Iw), 0 },
933 /*c3*/ { "ret", FALSE, NONE, 0, 0 },
934 /*c4*/ { "les", TRUE, LONG, op2(E, R), 0 },
935 /*c5*/ { "lds", TRUE, LONG, op2(E, R), 0 },
936 /*c6*/ { "mov", TRUE, BYTE, op2(I, E), 0 },
937 /*c7*/ { "mov", TRUE, LONG, op2(I, E), 0 },
939 /*c8*/ { "enter", FALSE, NONE, op2(Iw, Ib), 0 },
940 /*c9*/ { "leave", FALSE, NONE, 0, 0 },
941 /*ca*/ { "lret", FALSE, NONE, op1(Iw), 0 },
942 /*cb*/ { "lret", FALSE, NONE, 0, 0 },
943 /*cc*/ { "int", FALSE, NONE, op1(o3), 0 },
944 /*cd*/ { "int", FALSE, NONE, op1(Ib), 0 },
945 /*ce*/ { "into", FALSE, NONE, 0, 0 },
946 /*cf*/ { "iret", FALSE, NONE, 0, 0 },
948 /*d0*/ { "", TRUE, BYTE, op2(o1, E), db_Grp2 },
949 /*d1*/ { "", TRUE, LONG, op2(o1, E), db_Grp2 },
950 /*d2*/ { "", TRUE, BYTE, op2(CL, E), db_Grp2 },
951 /*d3*/ { "", TRUE, LONG, op2(CL, E), db_Grp2 },
952 /*d4*/ { "aam", FALSE, NONE, op1(Iba), 0 },
953 /*d5*/ { "aad", FALSE, NONE, op1(Iba), 0 },
954 /*d6*/ { ".byte\t0xd6", FALSE, NONE, 0, 0 },
955 /*d7*/ { "xlat", FALSE, BYTE, op1(BX), 0 },
957 /*d8*/ { "", TRUE, NONE, 0, db_Esc8 },
958 /*d9*/ { "", TRUE, NONE, 0, db_Esc9 },
959 /*da*/ { "", TRUE, NONE, 0, db_Esca },
960 /*db*/ { "", TRUE, NONE, 0, db_Escb },
961 /*dc*/ { "", TRUE, NONE, 0, db_Escc },
962 /*dd*/ { "", TRUE, NONE, 0, db_Escd },
963 /*de*/ { "", TRUE, NONE, 0, db_Esce },
964 /*df*/ { "", TRUE, NONE, 0, db_Escf },
966 /*e0*/ { "loopne",FALSE, NONE, op1(Db), 0 },
967 /*e1*/ { "loope", FALSE, NONE, op1(Db), 0 },
968 /*e2*/ { "loop", FALSE, NONE, op1(Db), 0 },
969 /*e3*/ { "jcxz", FALSE, SDEP, op1(Db), "jecxz" },
970 /*e4*/ { "in", FALSE, BYTE, op2(Ib, A), 0 },
971 /*e5*/ { "in", FALSE, LONG, op2(Ib, A) , 0 },
972 /*e6*/ { "out", FALSE, BYTE, op2(A, Ib), 0 },
973 /*e7*/ { "out", FALSE, LONG, op2(A, Ib) , 0 },
975 /*e8*/ { "call", FALSE, NONE, op1(Dl), 0 },
976 /*e9*/ { "jmp", FALSE, NONE, op1(Dl), 0 },
977 /*ea*/ { "ljmp", FALSE, NONE, op1(OS), 0 },
978 /*eb*/ { "jmp", FALSE, NONE, op1(Db), 0 },
979 /*ec*/ { "in", FALSE, BYTE, op2(DX, A), 0 },
980 /*ed*/ { "in", FALSE, LONG, op2(DX, A) , 0 },
981 /*ee*/ { "out", FALSE, BYTE, op2(A, DX), 0 },
982 /*ef*/ { "out", FALSE, LONG, op2(A, DX) , 0 },
984 /*f0*/ { "", FALSE, NONE, 0, 0 },
985 /*f1*/ { ".byte\t0xf1", FALSE, NONE, 0, 0 },
986 /*f2*/ { "", FALSE, NONE, 0, 0 },
987 /*f3*/ { "", FALSE, NONE, 0, 0 },
988 /*f4*/ { "hlt", FALSE, NONE, 0, 0 },
989 /*f5*/ { "cmc", FALSE, NONE, 0, 0 },
990 /*f6*/ { "", TRUE, BYTE, 0, db_Grp3 },
991 /*f7*/ { "", TRUE, LONG, 0, db_Grp3 },
993 /*f8*/ { "clc", FALSE, NONE, 0, 0 },
994 /*f9*/ { "stc", FALSE, NONE, 0, 0 },
995 /*fa*/ { "cli", FALSE, NONE, 0, 0 },
996 /*fb*/ { "sti", FALSE, NONE, 0, 0 },
997 /*fc*/ { "cld", FALSE, NONE, 0, 0 },
998 /*fd*/ { "std", FALSE, NONE, 0, 0 },
999 /*fe*/ { "", TRUE, NONE, 0, db_Grp4 },
1000 /*ff*/ { "", TRUE, NONE, 0, db_Grp5 },
1003 static const struct inst db_bad_inst =
1004 { "???", FALSE, NONE, 0, 0 }
1007 #define f_mod(rex, byte) ((byte)>>6)
1008 #define f_reg(rex, byte) ((((byte)>>3)&0x7) | (rex & REX_R ? 0x8 : 0x0))
1009 #define f_rm(rex, byte) (((byte)&0x7) | (rex & REX_B ? 0x8 : 0x0))
1011 #define sib_ss(rex, byte) ((byte)>>6)
1012 #define sib_index(rex, byte) ((((byte)>>3)&0x7) | (rex & REX_X ? 0x8 : 0x0))
1013 #define sib_base(rex, byte) (((byte)&0x7) | (rex & REX_B ? 0x8 : 0x0))
1015 struct i_addr {
1016 int is_reg; /* if reg, reg number is in 'disp' */
1017 int disp;
1018 const char * base;
1019 const char * index;
1020 int ss;
1023 static const char * const db_reg[2][4][16] = {
1025 {{"%al", "%cl", "%dl", "%bl", "%ah", "%ch", "%dh", "%bh",
1026 "%r8b", "%r9b", "%r10b", "%r11b", "%r12b", "%r13b", "%r14b", "%r15b" },
1027 { "%ax", "%cx", "%dx", "%bx", "%sp", "%bp", "%si", "%di",
1028 "%r8w", "%r9w", "%r10w", "%r11w", "%r12w", "%r13w", "%r14w", "%r15w" },
1029 { "%eax", "%ecx", "%edx", "%ebx", "%esp", "%ebp", "%esi", "%edi",
1030 "%r8d", "%r9d", "%r10d", "%r11d", "%r12d", "%r13d", "%r14d", "%r15d" },
1031 { "%rax", "%rcx", "%rdx", "%rbx", "%rsp", "%rbp", "%rsi", "%rdi",
1032 "%r8", "%r9", "%r10", "%r11", "%r12", "%r13", "%r14", "%r15" }},
1034 {{"%al", "%cl", "%dl", "%bl", "%spl", "%bpl", "%sil", "%dil",
1035 "%r8b", "%r9b", "%r10b", "%r11b", "%r12b", "%r13b", "%r14b", "%r15b" },
1036 { "%ax", "%cx", "%dx", "%bx", "%sp", "%bp", "%si", "%di",
1037 "%r8w", "%r9w", "%r10w", "%r11w", "%r12w", "%r13w", "%r14w", "%r15w" },
1038 { "%eax", "%ecx", "%edx", "%ebx", "%esp", "%ebp", "%esi", "%edi",
1039 "%r8d", "%r9d", "%r10d", "%r11d", "%r12d", "%r13d", "%r14d", "%r15d" },
1040 { "%rax", "%rcx", "%rdx", "%rbx", "%rsp", "%rbp", "%rsi", "%rdi",
1041 "%r8", "%r9", "%r10", "%r11", "%r12", "%r13", "%r14", "%r15" }}
1044 static const char * const db_seg_reg[8] = {
1045 "%es", "%cs", "%ss", "%ds", "%fs", "%gs", "", ""
1049 * lengths for size attributes
1051 static const int db_lengths[] = {
1052 1, /* BYTE */
1053 2, /* WORD */
1054 4, /* LONG */
1055 8, /* QUAD */
1056 4, /* SNGL */
1057 8, /* DBLR */
1058 10, /* EXTR */
1061 #define get_value_inc(result, loc, size, is_signed) \
1062 result = db_get_value((loc), (size), (is_signed)); \
1063 (loc) += (size);
1065 static db_addr_t
1066 db_disasm_esc(db_addr_t loc, int inst, int rex, int short_addr,
1067 int size, const char *seg);
1068 static void db_print_address(const char *seg, int size, int rex,
1069 struct i_addr *addrp);
1070 static db_addr_t
1071 db_read_address(db_addr_t loc, int short_addr, int rex, int regmodrm,
1072 struct i_addr *addrp);
1075 * Read address at location and return updated location.
1077 static db_addr_t
1078 db_read_address(loc, short_addr, rex, regmodrm, addrp)
1079 db_addr_t loc;
1080 int short_addr;
1081 int rex;
1082 int regmodrm;
1083 struct i_addr * addrp; /* out */
1085 int mod, rm, sib, index, disp, size, have_sib;
1087 mod = f_mod(rex, regmodrm);
1088 rm = f_rm(rex, regmodrm);
1090 if (mod == 3) {
1091 addrp->is_reg = TRUE;
1092 addrp->disp = rm;
1093 return (loc);
1095 addrp->is_reg = FALSE;
1096 addrp->index = 0;
1098 if (short_addr)
1099 size = LONG;
1100 else
1101 size = QUAD;
1103 if ((rm & 0x7) == 4) {
1104 get_value_inc(sib, loc, 1, FALSE);
1105 rm = sib_base(rex, sib);
1106 index = sib_index(rex, sib);
1107 if (index != 4)
1108 addrp->index = db_reg[1][size][index];
1109 addrp->ss = sib_ss(rex, sib);
1110 have_sib = 1;
1111 } else
1112 have_sib = 0;
1114 switch (mod) {
1115 case 0:
1116 if (rm == 5) {
1117 get_value_inc(addrp->disp, loc, 4, FALSE);
1118 if (have_sib)
1119 addrp->base = 0;
1120 else if (short_addr)
1121 addrp->base = "%eip";
1122 else
1123 addrp->base = "%rip";
1124 } else {
1125 addrp->disp = 0;
1126 addrp->base = db_reg[1][size][rm];
1128 break;
1130 case 1:
1131 get_value_inc(disp, loc, 1, TRUE);
1132 addrp->disp = disp;
1133 addrp->base = db_reg[1][size][rm];
1134 break;
1136 case 2:
1137 get_value_inc(disp, loc, 4, FALSE);
1138 addrp->disp = disp;
1139 addrp->base = db_reg[1][size][rm];
1140 break;
1142 return (loc);
1145 static void
1146 db_print_address(seg, size, rex, addrp)
1147 const char * seg;
1148 int size;
1149 int rex;
1150 struct i_addr * addrp;
1152 if (addrp->is_reg) {
1153 db_printf("%s", db_reg[rex != 0 ? 1 : 0][(size == LONG && (rex & REX_W)) ? QUAD : size][addrp->disp]);
1154 return;
1157 if (seg) {
1158 db_printf("%s:", seg);
1161 if (addrp->disp != 0 || (addrp->base == 0 && addrp->index == 0))
1162 db_printsym((db_addr_t)addrp->disp, DB_STGY_ANY);
1163 if (addrp->base != 0 || addrp->index != 0) {
1164 db_printf("(");
1165 if (addrp->base)
1166 db_printf("%s", addrp->base);
1167 if (addrp->index)
1168 db_printf(",%s,%d", addrp->index, 1<<addrp->ss);
1169 db_printf(")");
1174 * Disassemble floating-point ("escape") instruction
1175 * and return updated location.
1177 static db_addr_t
1178 db_disasm_esc(loc, inst, rex, short_addr, size, seg)
1179 db_addr_t loc;
1180 int inst;
1181 int rex;
1182 int short_addr;
1183 int size;
1184 const char * seg;
1186 int regmodrm;
1187 const struct finst * fp;
1188 int mod;
1189 struct i_addr address;
1190 const char * name;
1192 get_value_inc(regmodrm, loc, 1, FALSE);
1193 fp = &db_Esc_inst[inst - 0xd8][f_reg(rex, regmodrm)];
1194 mod = f_mod(rex, regmodrm);
1195 if (mod != 3) {
1196 if (*fp->f_name == '\0') {
1197 db_printf("<bad instruction>");
1198 return (loc);
1201 * Normal address modes.
1203 loc = db_read_address(loc, short_addr, rex, regmodrm, &address);
1204 db_printf("%s", fp->f_name);
1205 switch(fp->f_size) {
1206 case SNGL:
1207 db_printf("s");
1208 break;
1209 case DBLR:
1210 db_printf("l");
1211 break;
1212 case EXTR:
1213 db_printf("t");
1214 break;
1215 case WORD:
1216 db_printf("s");
1217 break;
1218 case LONG:
1219 db_printf("l");
1220 break;
1221 case QUAD:
1222 db_printf("q");
1223 break;
1224 default:
1225 break;
1227 db_printf("\t");
1228 db_print_address(seg, BYTE, rex, &address);
1230 else {
1232 * 'reg-reg' - special formats
1234 switch (fp->f_rrmode) {
1235 case op2(ST,STI):
1236 name = (fp->f_rrname) ? fp->f_rrname : fp->f_name;
1237 db_printf("%s\t%%st,%%st(%d)",name,f_rm(rex, regmodrm));
1238 break;
1239 case op2(STI,ST):
1240 name = (fp->f_rrname) ? fp->f_rrname : fp->f_name;
1241 db_printf("%s\t%%st(%d),%%st",name, f_rm(rex, regmodrm));
1242 break;
1243 case op1(STI):
1244 name = (fp->f_rrname) ? fp->f_rrname : fp->f_name;
1245 db_printf("%s\t%%st(%d)",name, f_rm(rex, regmodrm));
1246 break;
1247 case op1(X):
1248 name = ((const char * const *)fp->f_rrname)[f_rm(rex, regmodrm)];
1249 if (*name == '\0')
1250 goto bad;
1251 db_printf("%s", name);
1252 break;
1253 case op1(XA):
1254 name = ((const char * const *)fp->f_rrname)[f_rm(rex, regmodrm)];
1255 if (*name == '\0')
1256 goto bad;
1257 db_printf("%s\t%%ax", name);
1258 break;
1259 default:
1260 bad:
1261 db_printf("<bad instruction>");
1262 break;
1266 return (loc);
1270 * Disassemble instruction at 'loc'. 'altfmt' specifies an
1271 * (optional) alternate format. Return address of start of
1272 * next instruction.
1274 static db_addr_t
1275 db_disasm(db_addr_t loc, boolean_t altfmt)
1277 int inst;
1278 int size;
1279 int short_addr;
1280 const char * seg;
1281 const struct inst * ip;
1282 const char * i_name;
1283 int i_size;
1284 int i_mode;
1285 int rex = 0;
1286 int regmodrm = 0;
1287 boolean_t first;
1288 int displ;
1289 int prefix;
1290 int rep;
1291 int imm;
1292 int imm2;
1293 long imm64;
1294 int len;
1295 struct i_addr address;
1296 db_addr_t addr;
1298 get_value_inc(inst, loc, 1, FALSE);
1299 short_addr = FALSE;
1300 size = LONG;
1301 seg = 0;
1304 * Get prefixes
1306 rep = FALSE;
1307 prefix = TRUE;
1308 do {
1309 switch (inst) {
1310 case 0x66: /* data16 */
1311 size = WORD;
1312 break;
1313 case 0x67:
1314 short_addr = TRUE;
1315 break;
1316 case 0x26:
1317 seg = "%es";
1318 break;
1319 case 0x36:
1320 seg = "%ss";
1321 break;
1322 case 0x2e:
1323 seg = "%cs";
1324 break;
1325 case 0x3e:
1326 seg = "%ds";
1327 break;
1328 case 0x64:
1329 seg = "%fs";
1330 break;
1331 case 0x65:
1332 seg = "%gs";
1333 break;
1334 case 0xf0:
1335 db_printf("lock ");
1336 break;
1337 case 0xf2:
1338 db_printf("repne ");
1339 break;
1340 case 0xf3:
1341 rep = TRUE;
1342 break;
1343 default:
1344 prefix = FALSE;
1345 break;
1347 if (inst >= 0x40 && inst < 0x50) {
1348 rex = inst;
1349 prefix = TRUE;
1351 if (prefix) {
1352 get_value_inc(inst, loc, 1, FALSE);
1354 if (rep == TRUE) {
1355 if (inst == 0x90) {
1356 db_printf("pause\n");
1357 return (loc);
1359 db_printf("repe "); /* XXX repe VS rep */
1360 rep = FALSE;
1362 } while (prefix);
1364 if (inst >= 0xd8 && inst <= 0xdf) {
1365 loc = db_disasm_esc(loc, inst, rex, short_addr, size, seg);
1366 db_printf("\n");
1367 return (loc);
1370 if (inst == 0x0f) {
1371 get_value_inc(inst, loc, 1, FALSE);
1372 ip = db_inst_0f[inst>>4];
1373 if (ip == 0) {
1374 ip = &db_bad_inst;
1376 else {
1377 ip = &ip[inst&0xf];
1380 else
1381 ip = &db_inst_table[inst];
1383 if (ip->i_has_modrm) {
1384 get_value_inc(regmodrm, loc, 1, FALSE);
1385 loc = db_read_address(loc, short_addr, rex, regmodrm, &address);
1388 i_name = ip->i_name;
1389 i_size = ip->i_size;
1390 i_mode = ip->i_mode;
1392 if (ip->i_extra == db_Grp1 || ip->i_extra == db_Grp2 ||
1393 ip->i_extra == db_Grp6 || ip->i_extra == db_Grp7 ||
1394 ip->i_extra == db_Grp8 || ip->i_extra == db_Grp9 ||
1395 ip->i_extra == db_Grp15) {
1396 i_name = ((const char * const *)ip->i_extra)[f_reg(rex, regmodrm)];
1398 else if (ip->i_extra == db_Grp3) {
1399 ip = ip->i_extra;
1400 ip = &ip[f_reg(rex, regmodrm)];
1401 i_name = ip->i_name;
1402 i_mode = ip->i_mode;
1404 else if (ip->i_extra == db_Grp4 || ip->i_extra == db_Grp5) {
1405 ip = ip->i_extra;
1406 ip = &ip[f_reg(rex, regmodrm)];
1407 i_name = ip->i_name;
1408 i_mode = ip->i_mode;
1409 i_size = ip->i_size;
1412 /* Special cases that don't fit well in the tables. */
1413 if (ip->i_extra == db_Grp7 && f_mod(rex, regmodrm) == 3) {
1414 switch (regmodrm) {
1415 case 0xc8:
1416 i_name = "monitor";
1417 i_size = NONE;
1418 i_mode = 0;
1419 break;
1420 case 0xc9:
1421 i_name = "mwait";
1422 i_size = NONE;
1423 i_mode = 0;
1424 break;
1425 case 0xf8:
1426 i_name = "swapgs";
1427 i_size = NONE;
1428 i_mode = 0;
1429 break;
1432 if (ip->i_extra == db_Grp15 && f_mod(0, regmodrm) == 3) {
1433 i_name = db_Grp15b[f_reg(0, regmodrm)];
1434 i_size = NONE;
1435 i_mode = 0;
1438 if (i_size == SDEP) {
1439 if (size == WORD)
1440 db_printf("%s", i_name);
1441 else
1442 db_printf("%s", (const char *)ip->i_extra);
1444 else {
1445 db_printf("%s", i_name);
1446 if ((inst >= 0x50 && inst <= 0x5f) || inst == 0x68 || inst == 0x6a) {
1447 i_size = NONE;
1448 db_printf("q");
1450 if (i_size != NONE) {
1451 if (i_size == BYTE) {
1452 db_printf("b");
1453 size = BYTE;
1455 else if (i_size == WORD) {
1456 db_printf("w");
1457 size = WORD;
1459 else if (size == WORD)
1460 db_printf("w");
1461 else {
1462 if (rex & REX_W)
1463 db_printf("q");
1464 else
1465 db_printf("l");
1469 db_printf("\t");
1470 for (first = TRUE;
1471 i_mode != 0;
1472 i_mode >>= 8, first = FALSE)
1474 if (!first)
1475 db_printf(",");
1477 switch (i_mode & 0xFF) {
1479 case E:
1480 db_print_address(seg, size, rex, &address);
1481 break;
1483 case Eind:
1484 db_printf("*");
1485 db_print_address(seg, size, rex, &address);
1486 break;
1488 case El:
1489 db_print_address(seg, (rex & REX_W) ? QUAD : LONG, rex, &address);
1490 break;
1492 case EL:
1493 db_print_address(seg, LONG, 0, &address);
1494 break;
1496 case Ew:
1497 db_print_address(seg, WORD, rex, &address);
1498 break;
1500 case Eb:
1501 db_print_address(seg, BYTE, rex, &address);
1502 break;
1504 case R:
1505 db_printf("%s", db_reg[rex != 0 ? 1 : 0][(size == LONG && (rex & REX_W)) ? QUAD : size][f_reg(rex, regmodrm)]);
1506 break;
1508 case Rw:
1509 db_printf("%s", db_reg[rex != 0 ? 1 : 0][WORD][f_reg(rex, regmodrm)]);
1510 break;
1512 case Ri:
1513 db_printf("%s", db_reg[0][QUAD][f_rm(rex, inst)]);
1514 break;
1516 case Ril:
1517 db_printf("%s", db_reg[rex != 0 ? 1 : 0][(rex & REX_R) ? QUAD : LONG][f_rm(rex, inst)]);
1518 break;
1520 case S:
1521 db_printf("%s", db_seg_reg[f_reg(0, regmodrm)]);
1522 break;
1524 case Si:
1525 db_printf("%s", db_seg_reg[f_reg(0, inst)]);
1526 break;
1528 case A:
1529 db_printf("%s", db_reg[rex != 0 ? 1 : 0][size][0]); /* acc */
1530 break;
1532 case BX:
1533 if (seg)
1534 db_printf("%s:", seg);
1535 db_printf("(%s)", short_addr ? "%bx" : "%ebx");
1536 break;
1538 case CL:
1539 db_printf("%%cl");
1540 break;
1542 case DX:
1543 db_printf("%%dx");
1544 break;
1546 case SI:
1547 if (seg)
1548 db_printf("%s:", seg);
1549 db_printf("(%s)", short_addr ? "%si" : "%rsi");
1550 break;
1552 case DI:
1553 db_printf("%%es:(%s)", short_addr ? "%di" : "%rdi");
1554 break;
1556 case CR:
1557 db_printf("%%cr%d", f_reg(rex, regmodrm));
1558 break;
1560 case DR:
1561 db_printf("%%dr%d", f_reg(rex, regmodrm));
1562 break;
1564 case TR:
1565 db_printf("%%tr%d", f_reg(rex, regmodrm));
1566 break;
1568 case I:
1569 len = db_lengths[size];
1570 get_value_inc(imm, loc, len, FALSE);
1571 db_printf("$%#x", imm);
1572 break;
1574 case Is:
1575 len = db_lengths[(size == LONG && (rex & REX_W)) ? QUAD : size];
1576 get_value_inc(imm, loc, len, FALSE);
1577 db_printf("$%x", imm);
1578 break;
1580 case Ib:
1581 get_value_inc(imm, loc, 1, FALSE);
1582 db_printf("$%#x", imm);
1583 break;
1585 case Iba:
1586 get_value_inc(imm, loc, 1, FALSE);
1587 if (imm != 0x0a)
1588 db_printf("$%#x", imm);
1589 break;
1591 case Ibs:
1592 get_value_inc(imm, loc, 1, TRUE);
1593 if (size == WORD)
1594 imm &= 0xFFFF;
1595 db_printf("$%x", imm);
1596 break;
1598 case Iw:
1599 get_value_inc(imm, loc, 2, FALSE);
1600 db_printf("$%#x", imm);
1601 break;
1603 case Ilq:
1604 len = db_lengths[rex & REX_W ? QUAD : LONG];
1605 get_value_inc(imm64, loc, len, FALSE);
1606 db_printf("$%#lx", imm64);
1607 break;
1609 case O:
1610 len = (short_addr ? 2 : 4);
1611 get_value_inc(displ, loc, len, FALSE);
1612 if (seg)
1613 db_printf("%s:%x",seg, displ);
1614 else
1615 db_printsym((db_addr_t)displ, DB_STGY_ANY);
1616 break;
1618 case Db:
1619 get_value_inc(displ, loc, 1, TRUE);
1620 addr = loc + (LONG64)displ;
1621 if (size == WORD)
1622 addr &= 0xFFFF;
1623 db_printsym(addr, DB_STGY_XTRN);
1624 break;
1626 case Dl:
1627 len = db_lengths[(size == LONG && (rex & REX_W)) ? QUAD : size];
1628 get_value_inc(displ, loc, len, FALSE);
1629 addr = loc + (LONG64)displ;
1630 if (size == WORD)
1631 addr &= 0xFFFF;
1632 db_printsym(addr, DB_STGY_XTRN);
1633 break;
1635 case o1:
1636 db_printf("$1");
1637 break;
1639 case o3:
1640 db_printf("$3");
1641 break;
1643 case OS:
1644 len = db_lengths[size];
1645 get_value_inc(imm, loc, len, FALSE); /* offset */
1646 get_value_inc(imm2, loc, 2, FALSE); /* segment */
1647 db_printf("$%#x,%#x", imm2, imm);
1648 break;
1649 case MX:
1650 db_printf("%%mm%d", f_reg(rex, regmodrm));
1651 break;
1652 case EMX:
1653 db_printf("%%mm%d", f_rm(rex, regmodrm));
1654 break;
1655 case XMM:
1656 db_printf("%%xmm%d", f_reg(rex, regmodrm));
1657 break;
1658 case EXMM:
1659 db_printf("%%xmm%d", f_rm(rex, regmodrm));
1660 break;
1663 return (loc);
1666 void be_x86_64_disasm_one_insn(ADDRESS64 *addr, int display)
1668 db_printf = display ? dbg_printf : no_printf;
1669 addr->Offset = db_disasm(addr->Offset, TRUE);