Add AppDefaults app selection to control panel
[wine/gsoc-2012-control.git] / programs / winedbg / db_disasm.c
blobc745617e69031a35f7c02c1b01068eaea16e0370
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 "AS IS"
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 Mellon
24 * the rights to redistribute these changes.
27 * HISTORY
29 * Revision 2.6 92/01/03 20:05:00 dbg
30 * Add a switch to disassemble 16-bit code.
31 * Fix spelling of 'lods' opcodes.
32 * [91/10/30 dbg]
34 * Revision 2.5 91/10/09 16:05:58 af
35 * Supported disassemble of non current task by passing task parameter.
36 * [91/08/29 tak]
38 * Revision 2.4 91/05/14 16:05:04 mrt
39 * Correcting copyright
41 * Revision 2.3 91/02/05 17:11:03 mrt
42 * Changed to new Mach copyright
43 * [91/02/01 17:31:03 mrt]
45 * Revision 2.2 90/08/27 21:55:56 dbg
46 * Fix register operand for move to/from control/test/debug
47 * register instructions. Add i486 instructions.
48 * [90/08/27 dbg]
50 * Import db_sym.h. Print instruction displacements in
51 * current radix (signed). Change calling sequence of
52 * db_disasm.
53 * [90/08/21 dbg]
54 * Fix includes.
55 * [90/08/08 dbg]
56 * Created.
57 * [90/07/25 dbg]
62 * Instruction disassembler.
65 #include "debugger.h"
67 #ifdef __i386__
70 * Switch to disassemble 16-bit code.
72 static BOOL db_disasm_16 = FALSE;
75 * Flag to indicate whether we need to display instruction,
76 * or whether we just need to know the address of the next
77 * instruction.
79 static BOOL db_display = FALSE;
82 * Size attributes
84 #define BYTE 0
85 #define WORD 1
86 #define LONG 2
87 #define QUAD 3
88 #define DQUA 4
89 #define SNGL 5
90 #define DBLR 6
91 #define EXTR 7
92 #define SDEP 8
93 #define NONE 9
96 * Addressing modes
98 #define E 1 /* general effective address */
99 #define Eind 2 /* indirect address (jump, call) */
100 #define Ew 3 /* address, word size */
101 #define Eb 4 /* address, byte size */
102 #define R 5 /* register, in 'reg' field */
103 #define Rw 6 /* word register, in 'reg' field */
104 #define Ri 7 /* register in instruction */
105 #define S 8 /* segment reg, in 'reg' field */
106 #define Si 9 /* segment reg, in instruction */
107 #define A 10 /* accumulator */
108 #define BX 11 /* (bx) */
109 #define CL 12 /* cl, for shifts */
110 #define DX 13 /* dx, for IO */
111 #define SI 14 /* si */
112 #define DI 15 /* di */
113 #define CR 16 /* control register */
114 #define DR 17 /* debug register */
115 #define TR 18 /* test register */
116 #define I 19 /* immediate, unsigned */
117 #define Is 20 /* immediate, signed */
118 #define Ib 21 /* byte immediate, unsigned */
119 #define Ibs 22 /* byte immediate, signed */
120 #define Iw 23 /* word immediate, unsigned */
121 #define Il 24 /* long immediate */
122 #define O 25 /* direct address */
123 #define Db 26 /* byte displacement from EIP */
124 #define Dl 27 /* long displacement from EIP */
125 #define o1 28 /* constant 1 */
126 #define o3 29 /* constant 3 */
127 #define OS 30 /* immediate offset/segment */
128 #define ST 31 /* FP stack top */
129 #define STI 32 /* FP stack */
130 #define X 33 /* extended FP op */
131 #define XA 34 /* for 'fstcw %ax' */
132 #define MX 35 /* special register (MMX reg %mm0-7) */
133 #define EMX 36 /* special register (MMX reg %mm0-7) */
134 #define XMM 37 /* special register (floating point reg %xmm0-7) */
135 #define EXMM 38 /* special register (floating point reg %xmm0-7) */
137 struct inst {
138 const char *i_name; /* name */
139 short i_has_modrm; /* has regmodrm byte */
140 short i_size; /* operand size */
141 int i_mode; /* addressing modes */
142 const char *i_extra; /* pointer to extra opcode table */
145 #define op1(x) (x)
146 #define op2(x,y) ((x)|((y)<<8))
147 #define op3(x,y,z) ((x)|((y)<<8)|((z)<<16))
149 struct finst {
150 const char *f_name; /* name for memory instruction */
151 int f_size; /* size for memory instruction */
152 int f_rrmode; /* mode for rr instruction */
153 const char *f_rrname; /* name for rr instruction
154 (or pointer to table) */
157 static const char * const db_Grp6[] = {
158 "sldt",
159 "str",
160 "lldt",
161 "ltr",
162 "verr",
163 "verw",
168 static const char * const db_Grp7[] = {
169 "sgdt",
170 "sidt",
171 "lgdt",
172 "lidt",
173 "smsw",
175 "lmsw",
176 "invlpg"
179 static const char * const db_Grp8[] = {
184 "bt",
185 "bts",
186 "btr",
187 "btc"
190 static const char * const db_Grp10[] = {
191 "(bad)",
192 "(bad)",
193 "psrlw",
194 "(bad)",
195 "psraw",
196 "(bad)",
197 "psllw",
198 "(bad)"
201 static const char * const db_Grp11[] = {
202 "(bad)",
203 "(bad)",
204 "psrld",
205 "(bad)",
206 "psrad",
207 "(bad)",
208 "pslld",
209 "(bad)"
212 static const char * const db_Grp12[] = {
213 "(bad)",
214 "(bad)",
215 "psrlq",
216 "(bad)",
217 "psraq",
218 "(bad)",
219 "psllq",
220 "(bad)"
223 static const struct inst db_inst_0f0x[] = {
224 /*00*/ { "", TRUE, NONE, op1(Ew), (const char *)db_Grp6 },
225 /*01*/ { "", TRUE, NONE, op1(Ew), (const char *)db_Grp7 },
226 /*02*/ { "lar", TRUE, LONG, op2(E,R), 0 },
227 /*03*/ { "lsl", TRUE, LONG, op2(E,R), 0 },
228 /*04*/ { "", FALSE, NONE, 0, 0 },
229 /*05*/ { "syscall", FALSE, NONE, 0, 0 },
230 /*06*/ { "clts", FALSE, NONE, 0, 0 },
231 /*07*/ { "sysret", FALSE, NONE, 0, 0 },
233 /*08*/ { "invd", FALSE, NONE, 0, 0 },
234 /*09*/ { "wbinvd",FALSE, NONE, 0, 0 },
235 /*0a*/ { "", FALSE, NONE, 0, 0 },
236 /*0b*/ { "", FALSE, NONE, 0, 0 },
237 /*0c*/ { "", FALSE, NONE, 0, 0 },
238 /*0d*/ { "", FALSE, NONE, 0, 0 },
239 /*0e*/ { "", FALSE, NONE, 0, 0 },
240 /*0f*/ { "", FALSE, NONE, 0, 0 },
243 static const struct inst db_inst_0f2x[] = {
244 /*20*/ { "mov", TRUE, LONG, op2(CR,E), 0 }, /* use E for reg */
245 /*21*/ { "mov", TRUE, LONG, op2(DR,E), 0 }, /* since mod == 11 */
246 /*22*/ { "mov", TRUE, LONG, op2(E,CR), 0 },
247 /*23*/ { "mov", TRUE, LONG, op2(E,DR), 0 },
248 /*24*/ { "mov", TRUE, LONG, op2(TR,E), 0 },
249 /*25*/ { "(bad)", FALSE, NONE, 0, 0 },
250 /*26*/ { "mov", TRUE, LONG, op2(E,TR), 0 },
251 /*27*/ { "(bad)", FALSE, NONE, 0, 0 },
253 /*28*/ { "", FALSE, NONE, 0, 0 },
254 /*29*/ { "", FALSE, NONE, 0, 0 },
255 /*2a*/ { "", FALSE, NONE, 0, 0 },
256 /*2b*/ { "", FALSE, NONE, 0, 0 },
257 /*2c*/ { "", FALSE, NONE, 0, 0 },
258 /*2d*/ { "", FALSE, NONE, 0, 0 },
259 /*2e*/ { "", FALSE, NONE, 0, 0 },
260 /*2f*/ { "", FALSE, NONE, 0, 0 },
263 static const struct inst db_inst_0f3x[] = {
264 /*30*/ { "wrmsr", FALSE, NONE, 0, 0 },
265 /*31*/ { "rdtsc", FALSE, NONE, 0, 0 },
266 /*32*/ { "rdmsr", FALSE, NONE, 0, 0 },
267 /*33*/ { "rdpmc", FALSE, NONE, 0, 0 },
268 /*34*/ { "sysenter",FALSE,NONE, 0, 0 },
269 /*35*/ { "sysexit",FALSE,NONE, 0, 0 },
270 /*36*/ { "(bad)", FALSE, NONE, 0, 0 },
271 /*37*/ { "(bad)", FALSE, NONE, 0, 0 },
273 /*38*/ { "(bad)",FALSE, NONE, 0, 0 },
274 /*39*/ { "(bad)",FALSE, NONE, 0, 0 },
275 /*3a*/ { "(bad)",FALSE, NONE, 0, 0 },
276 /*3b*/ { "(bad)",FALSE, NONE, 0, 0 },
277 /*3c*/ { "(bad)",FALSE, NONE, 0, 0 },
278 /*3d*/ { "(bad)",FALSE, NONE, 0, 0 },
279 /*3e*/ { "(bad)",FALSE, NONE, 0, 0 },
280 /*3f*/ { "(bad)",FALSE, NONE, 0, 0 },
283 static const struct inst db_inst_0f4x[] = {
284 /*40*/ { "cmovo", TRUE, NONE, op2(E, R), 0 },
285 /*41*/ { "cmovno", TRUE, NONE, op2(E, R), 0 },
286 /*42*/ { "cmovnae",TRUE, NONE, op2(E, R), 0 },
287 /*43*/ { "cmovnb", TRUE, NONE, op2(E, R), 0 },
288 /*44*/ { "cmove", TRUE, NONE, op2(E, R), 0 },
289 /*45*/ { "cmovne", TRUE, NONE, op2(E, R), 0 },
290 /*46*/ { "cmovna", TRUE, NONE, op2(E, R), 0 },
291 /*47*/ { "cmova", TRUE, NONE, op2(E, R), 0 },
293 /*48*/ { "cmovs", TRUE, NONE, op2(E, R), 0 },
294 /*49*/ { "cmovns", TRUE, NONE, op2(E, R), 0 },
295 /*4a*/ { "cmovpe", TRUE, NONE, op2(E, R), 0 },
296 /*4b*/ { "cmovpo", TRUE, NONE, op2(E, R), 0 },
297 /*4c*/ { "cmovl", TRUE, NONE, op2(E, R), 0 },
298 /*4d*/ { "cmovge", TRUE, NONE, op2(E, R), 0 },
299 /*4e*/ { "cmovle", TRUE, NONE, op2(E, R), 0 },
300 /*4f*/ { "cmovnle",TRUE, NONE, op2(E, R), 0 },
303 static const struct inst db_inst_0f5x[] = {
304 /*50*/ { "movmskps",TRUE, NONE, op2(E, XMM), 0 },
305 /*51*/ { "sqrtps", TRUE, NONE, op2(XMM, EXMM), 0 },
306 /*52*/ { "rsqrtps", TRUE, NONE, op2(XMM, EXMM), 0 },
307 /*53*/ { "rcpps", TRUE, NONE, op2(XMM, EXMM), 0 },
308 /*54*/ { "andps", TRUE, NONE, op2(XMM, EXMM), 0 },
309 /*55*/ { "andnps", TRUE, NONE, op2(XMM, EXMM), 0 },
310 /*56*/ { "orps", TRUE, NONE, op2(XMM, EXMM), 0 },
311 /*57*/ { "xorps", TRUE, NONE, op2(XMM, EXMM), 0 },
313 /*58*/ { "addps", TRUE, NONE, op2(XMM, EXMM), 0 },
314 /*59*/ { "mulps", TRUE, NONE, op2(XMM, EXMM), 0 },
315 /*5a*/ { "(bad)", FALSE, NONE, 0, 0 },
316 /*5b*/ { "(bad)", FALSE, NONE, 0, 0 },
317 /*5c*/ { "subps", TRUE, NONE, op2(XMM, EXMM), 0 },
318 /*5d*/ { "minps", TRUE, NONE, op2(XMM, EXMM), 0 },
319 /*5e*/ { "divps", TRUE, NONE, op2(XMM, EXMM), 0 },
320 /*5f*/ { "maxps", TRUE, NONE, op2(XMM, EXMM), 0 },
323 static const struct inst db_inst_0f6x[] = {
324 /*60*/ { "punpcklbw", TRUE, NONE, op2(E, MX), 0 },
325 /*61*/ { "punpcklwd", TRUE, NONE, op2(E, MX), 0 },
326 /*62*/ { "punpckldq", TRUE, NONE, op2(E, MX), 0 },
327 /*63*/ { "packsswb", TRUE, NONE, op2(E, MX), 0 },
328 /*64*/ { "pcmpgtb", TRUE, NONE, op2(E, MX), 0 },
329 /*65*/ { "pcmpgtw", TRUE, NONE, op2(E, MX), 0 },
330 /*66*/ { "pcmpgtd", TRUE, NONE, op2(E, MX), 0 },
331 /*67*/ { "packuswb", TRUE, NONE, op2(E, MX), 0 },
333 /*68*/ { "punpckhbw", TRUE, NONE, op2(E, MX), 0 },
334 /*69*/ { "punpckhwd", TRUE, NONE, op2(E, MX), 0 },
335 /*6a*/ { "punpckhdq", TRUE, NONE, op2(E, MX), 0 },
336 /*6b*/ { "packssdw", TRUE, NONE, op2(E, MX), 0 },
337 /*6c*/ { "(bad)", TRUE, NONE, 0, 0 },
338 /*6d*/ { "(bad)", TRUE, NONE, 0, 0 },
339 /*6e*/ { "movd", TRUE, NONE, op2(E, MX), 0 },
340 /*6f*/ { "movq", TRUE, NONE, op2(EMX, MX), 0 },
343 static const struct inst db_inst_0f7x[] = {
344 /*70*/ { "pshufw", TRUE, NONE, op2(MX, EMX), 0 },
345 /*71*/ { "(grp10)", TRUE, BYTE, op2(EMX, I), (const char*)db_Grp10 },
346 /*72*/ { "(grp11)", TRUE, BYTE, op2(EMX, I), (const char*)db_Grp11 },
347 /*73*/ { "(grp12)", TRUE, BYTE, op2(EMX, I), (const char*)db_Grp12 },
348 /*74*/ { "pcmpeqb", TRUE, NONE, op2(E, MX), 0 },
349 /*75*/ { "pcmpeqw", TRUE, NONE, op2(E, MX), 0 },
350 /*76*/ { "pcmpeqd", TRUE, NONE, op2(E, MX), 0 },
351 /*77*/ { "emms", FALSE,NONE, 0, 0 },
353 /*78*/ { "(bad)", TRUE, NONE, 0, 0 },
354 /*79*/ { "(bad)", TRUE, NONE, 0, 0 },
355 /*7a*/ { "(bad)", TRUE, NONE, 0, 0 },
356 /*7b*/ { "(bad)", TRUE, NONE, 0, 0 },
357 /*7c*/ { "(bad)", TRUE, NONE, 0, 0 },
358 /*7d*/ { "(bad)", TRUE, NONE, 0, 0 },
359 /*7e*/ { "movd", TRUE, NONE, op2(E, MX), 0 },
360 /*7f*/ { "movq", TRUE, NONE, op2(MX, EMX), 0 },
363 static const struct inst db_inst_0f8x[] = {
364 /*80*/ { "jo", FALSE, NONE, op1(Dl), 0 },
365 /*81*/ { "jno", FALSE, NONE, op1(Dl), 0 },
366 /*82*/ { "jb", FALSE, NONE, op1(Dl), 0 },
367 /*83*/ { "jnb", FALSE, NONE, op1(Dl), 0 },
368 /*84*/ { "jz", FALSE, NONE, op1(Dl), 0 },
369 /*85*/ { "jnz", FALSE, NONE, op1(Dl), 0 },
370 /*86*/ { "jbe", FALSE, NONE, op1(Dl), 0 },
371 /*87*/ { "jnbe", FALSE, NONE, op1(Dl), 0 },
373 /*88*/ { "js", FALSE, NONE, op1(Dl), 0 },
374 /*89*/ { "jns", FALSE, NONE, op1(Dl), 0 },
375 /*8a*/ { "jp", FALSE, NONE, op1(Dl), 0 },
376 /*8b*/ { "jnp", FALSE, NONE, op1(Dl), 0 },
377 /*8c*/ { "jl", FALSE, NONE, op1(Dl), 0 },
378 /*8d*/ { "jnl", FALSE, NONE, op1(Dl), 0 },
379 /*8e*/ { "jle", FALSE, NONE, op1(Dl), 0 },
380 /*8f*/ { "jnle", FALSE, NONE, op1(Dl), 0 },
383 static const struct inst db_inst_0f9x[] = {
384 /*90*/ { "seto", TRUE, NONE, op1(Eb), 0 },
385 /*91*/ { "setno", TRUE, NONE, op1(Eb), 0 },
386 /*92*/ { "setb", TRUE, NONE, op1(Eb), 0 },
387 /*93*/ { "setnb", TRUE, NONE, op1(Eb), 0 },
388 /*94*/ { "setz", TRUE, NONE, op1(Eb), 0 },
389 /*95*/ { "setnz", TRUE, NONE, op1(Eb), 0 },
390 /*96*/ { "setbe", TRUE, NONE, op1(Eb), 0 },
391 /*97*/ { "setnbe",TRUE, NONE, op1(Eb), 0 },
393 /*98*/ { "sets", TRUE, NONE, op1(Eb), 0 },
394 /*99*/ { "setns", TRUE, NONE, op1(Eb), 0 },
395 /*9a*/ { "setp", TRUE, NONE, op1(Eb), 0 },
396 /*9b*/ { "setnp", TRUE, NONE, op1(Eb), 0 },
397 /*9c*/ { "setl", TRUE, NONE, op1(Eb), 0 },
398 /*9d*/ { "setnl", TRUE, NONE, op1(Eb), 0 },
399 /*9e*/ { "setle", TRUE, NONE, op1(Eb), 0 },
400 /*9f*/ { "setnle",TRUE, NONE, op1(Eb), 0 },
403 static const struct inst db_inst_0fax[] = {
404 /*a0*/ { "push", FALSE, NONE, op1(Si), 0 },
405 /*a1*/ { "pop", FALSE, NONE, op1(Si), 0 },
406 /*a2*/ { "cpuid", FALSE, NONE, 0, 0 },
407 /*a3*/ { "bt", TRUE, LONG, op2(E,R), 0 },
408 /*a4*/ { "shld", TRUE, LONG, op3(Ib,E,R), 0 },
409 /*a5*/ { "shld", TRUE, LONG, op3(CL,E,R), 0 },
410 /*a6*/ { "", FALSE, NONE, 0, 0 },
411 /*a7*/ { "", FALSE, NONE, 0, 0 },
413 /*a8*/ { "push", FALSE, NONE, op1(Si), 0 },
414 /*a9*/ { "pop", FALSE, NONE, op1(Si), 0 },
415 /*aa*/ { "", FALSE, NONE, 0, 0 },
416 /*ab*/ { "bts", TRUE, LONG, op2(E,R), 0 },
417 /*ac*/ { "shrd", TRUE, LONG, op3(Ib,E,R), 0 },
418 /*ad*/ { "shrd", TRUE, LONG, op3(CL,E,R), 0 },
419 /*a6*/ { "", FALSE, NONE, 0, 0 },
420 /*a7*/ { "imul", TRUE, LONG, op2(E,R), 0 },
423 static const struct inst db_inst_0fbx[] = {
424 /*b0*/ { "cmpxchg",TRUE, BYTE, op2(E, R), 0 },
425 /*b1*/ { "cmpxchg",TRUE, LONG, op2(E, R), 0 },
426 /*b2*/ { "lss", TRUE, LONG, op2(E, R), 0 },
427 /*b3*/ { "bts", TRUE, LONG, op2(R, E), 0 },
428 /*b4*/ { "lfs", TRUE, LONG, op2(E, R), 0 },
429 /*b5*/ { "lgs", TRUE, LONG, op2(E, R), 0 },
430 /*b6*/ { "movzb", TRUE, LONG, op2(E, R), 0 },
431 /*b7*/ { "movzw", TRUE, LONG, op2(E, R), 0 },
433 /*b8*/ { "", FALSE, NONE, 0, 0 },
434 /*b9*/ { "", FALSE, NONE, 0, 0 },
435 /*ba*/ { "", TRUE, LONG, op2(Ib, E), (const char *)db_Grp8 },
436 /*bb*/ { "btc", TRUE, LONG, op2(R, E), 0 },
437 /*bc*/ { "bsf", TRUE, LONG, op2(E, R), 0 },
438 /*bd*/ { "bsr", TRUE, LONG, op2(E, R), 0 },
439 /*be*/ { "movsb", TRUE, LONG, op2(E, R), 0 },
440 /*bf*/ { "movsw", TRUE, LONG, op2(E, R), 0 },
443 static const struct inst db_inst_0fcx[] = {
444 /*c0*/ { "xadd", TRUE, BYTE, op2(R, E), 0 },
445 /*c1*/ { "xadd", TRUE, LONG, op2(R, E), 0 },
446 /*c2*/ { "", FALSE, NONE, 0, 0 },
447 /*c3*/ { "", FALSE, NONE, 0, 0 },
448 /*c4*/ { "", FALSE, NONE, 0, 0 },
449 /*c5*/ { "", FALSE, NONE, 0, 0 },
450 /*c6*/ { "", FALSE, NONE, 0, 0 },
451 /*c7*/ { "", FALSE, NONE, 0, 0 },
452 /*c8*/ { "bswap", FALSE, LONG, op1(Ri), 0 },
453 /*c9*/ { "bswap", FALSE, LONG, op1(Ri), 0 },
454 /*ca*/ { "bswap", FALSE, LONG, op1(Ri), 0 },
455 /*cb*/ { "bswap", FALSE, LONG, op1(Ri), 0 },
456 /*cc*/ { "bswap", FALSE, LONG, op1(Ri), 0 },
457 /*cd*/ { "bswap", FALSE, LONG, op1(Ri), 0 },
458 /*ce*/ { "bswap", FALSE, LONG, op1(Ri), 0 },
459 /*cf*/ { "bswap", FALSE, LONG, op1(Ri), 0 },
462 static const struct inst db_inst_0fdx[] = {
463 /*d0*/ { "(bad)", FALSE, NONE,0, 0 },
464 /*d1*/ { "psrlw", TRUE, NONE,op2(MX,EMX), 0 },
465 /*d2*/ { "psrld", TRUE, NONE,op2(MX,EMX), 0 },
466 /*d3*/ { "psrld", TRUE, NONE,op2(MX,EMX), 0 },
467 /*d4*/ { "(bad)", FALSE, NONE,0, 0 },
468 /*d5*/ { "pmulww", TRUE, NONE,op2(MX,EMX), 0 },
469 /*d6*/ { "(bad)", FALSE, NONE,0, 0 },
470 /*d7*/ { "pmovmskb",FALSE, NONE,op2(MX,EMX),0 },
471 /*d8*/ { "psubusb", TRUE, NONE,op2(MX,EMX), 0 },
472 /*d9*/ { "psubusw", TRUE, NONE,op2(MX,EMX), 0 },
473 /*da*/ { "pminub", TRUE, NONE,op2(MX,EMX), 0 },
474 /*db*/ { "pand", TRUE, NONE,op2(MX,EMX), 0 },
475 /*dc*/ { "paddusb", TRUE, NONE,op2(MX,EMX), 0 },
476 /*dd*/ { "paddusw", TRUE, NONE,op2(MX,EMX), 0 },
477 /*de*/ { "pmaxub", TRUE, NONE,op2(MX,EMX), 0 },
478 /*df*/ { "pandn", TRUE, NONE,op2(MX,EMX), 0 },
481 static const struct inst db_inst_0fex[] = {
482 /*e0*/ { "pavgb", TRUE, NONE, op2(MX, EMX), 0 },
483 /*e1*/ { "psraw", TRUE, NONE, op2(MX, EMX), 0 },
484 /*e2*/ { "psrad", TRUE, NONE, op2(MX, EMX), 0 },
485 /*e3*/ { "pavgw", TRUE, NONE, op2(MX, EMX), 0 },
486 /*e4*/ { "pmulhuw",TRUE, NONE, op2(MX, EMX), 0 },
487 /*e5*/ { "pmulhw", TRUE, NONE, op2(MX, EMX), 0 },
488 /*e6*/ { "(bad)", FALSE,NONE, 0, 0 },
489 /*e7*/ { "movntq", TRUE, NONE, op2(MX, EMX), 0 },
490 /*e8*/ { "psubsb", TRUE, NONE, op2(MX, EMX), 0 },
491 /*e9*/ { "psubsw", TRUE, NONE, op2(MX, EMX), 0 },
492 /*ea*/ { "pminsw", TRUE, NONE, op2(MX, EMX), 0 },
493 /*eb*/ { "por", TRUE, NONE, op2(MX, EMX), 0 },
494 /*ec*/ { "paddsb", TRUE, NONE, op2(MX, EMX), 0 },
495 /*ed*/ { "paddsw", TRUE, NONE, op2(MX, EMX), 0 },
496 /*ee*/ { "pmaxsw", TRUE, NONE, op2(MX, EMX), 0 },
497 /*ef*/ { "pxor", TRUE, NONE, op2(MX, EMX), 0 },
500 static const struct inst db_inst_0ffx[] = {
501 /*f0*/ { "(bad)", FALSE,NONE, 0, 0 },
502 /*f1*/ { "psllw", TRUE, NONE, op2(MX, EMX), 0 },
503 /*f2*/ { "pslld", TRUE, NONE, op2(MX, EMX), 0 },
504 /*f3*/ { "psllq", TRUE, NONE, op2(MX, EMX), 0 },
505 /*f4*/ { "(bad)", FALSE,NONE, 0, 0 },
506 /*f5*/ { "pmaddwd",TRUE, NONE, op2(MX, EMX), 0 },
507 /*f6*/ { "psadbw", TRUE, NONE, op2(MX, EMX), 0 },
508 /*f7*/ { "maskmovq",TRUE,NONE, op2(MX, EMX), 0 },
509 /*f8*/ { "psubb", TRUE, NONE, op2(MX, EMX), 0 },
510 /*f9*/ { "psubw", TRUE, NONE, op2(MX, EMX), 0 },
511 /*fa*/ { "psubd", TRUE, NONE, op2(MX, EMX), 0 },
512 /*fb*/ { "(bad)", FALSE,NONE, 0, 0 },
513 /*fc*/ { "paddb", TRUE, NONE, op2(MX, EMX), 0 },
514 /*fd*/ { "paddw", TRUE, NONE, op2(MX, EMX), 0 },
515 /*fe*/ { "paddd", TRUE, NONE, op2(MX, EMX), 0 },
516 /*ff*/ { "(bad)", FALSE, NONE, 0, 0 },
519 static const struct inst * const db_inst_0f[] = {
520 db_inst_0f0x,
522 db_inst_0f2x,
523 db_inst_0f3x,
524 db_inst_0f4x,
525 db_inst_0f5x,
526 db_inst_0f6x,
527 db_inst_0f7x,
528 db_inst_0f8x,
529 db_inst_0f9x,
530 db_inst_0fax,
531 db_inst_0fbx,
532 db_inst_0fcx,
533 db_inst_0fdx,
534 db_inst_0fex,
535 db_inst_0ffx
538 static const char * const db_Esc92[] = {
539 "fnop", "", "", "", "", "", "", ""
541 static const char * const db_Esc93[] = {
542 "", "", "", "", "", "", "", ""
544 static const char * const db_Esc94[] = {
545 "fchs", "fabs", "", "", "ftst", "fxam", "", ""
547 static const char * const db_Esc95[] = {
548 "fld1", "fldl2t","fldl2e","fldpi","fldlg2","fldln2","fldz",""
550 static const char * const db_Esc96[] = {
551 "f2xm1","fyl2x","fptan","fpatan","fxtract","fprem1","fdecstp",
552 "fincstp"
554 static const char * const db_Esc97[] = {
555 "fprem","fyl2xp1","fsqrt","fsincos","frndint","fscale","fsin","fcos"
558 static const char * const db_Esca4[] = {
559 "", "fucompp","", "", "", "", "", ""
562 static const char * const db_Escb4[] = {
563 "", "", "fnclex","fninit","", "", "", ""
566 static const char * const db_Esce3[] = {
567 "", "fcompp","", "", "", "", "", ""
570 static const char * const db_Escf4[] = {
571 "fnstsw","", "", "", "", "", "", ""
574 static const struct finst db_Esc8[] = {
575 /*0*/ { "fadd", SNGL, op2(STI,ST), 0 },
576 /*1*/ { "fmul", SNGL, op2(STI,ST), 0 },
577 /*2*/ { "fcom", SNGL, op2(STI,ST), 0 },
578 /*3*/ { "fcomp", SNGL, op2(STI,ST), 0 },
579 /*4*/ { "fsub", SNGL, op2(STI,ST), 0 },
580 /*5*/ { "fsubr", SNGL, op2(STI,ST), 0 },
581 /*6*/ { "fdiv", SNGL, op2(STI,ST), 0 },
582 /*7*/ { "fdivr", SNGL, op2(STI,ST), 0 },
585 static const struct finst db_Esc9[] = {
586 /*0*/ { "fld", SNGL, op1(STI), 0 },
587 /*1*/ { "", NONE, op1(STI), "fxch" },
588 /*2*/ { "fst", SNGL, op1(X), (const char *)db_Esc92 },
589 /*3*/ { "fstp", SNGL, op1(X), (const char *)db_Esc93 },
590 /*4*/ { "fldenv", NONE, op1(X), (const char *)db_Esc94 },
591 /*5*/ { "fldcw", NONE, op1(X), (const char *)db_Esc95 },
592 /*6*/ { "fnstenv",NONE, op1(X), (const char *)db_Esc96 },
593 /*7*/ { "fnstcw", NONE, op1(X), (const char *)db_Esc97 },
596 static const struct finst db_Esca[] = {
597 /*0*/ { "fiadd", WORD, 0, 0 },
598 /*1*/ { "fimul", WORD, 0, 0 },
599 /*2*/ { "ficom", WORD, 0, 0 },
600 /*3*/ { "ficomp", WORD, 0, 0 },
601 /*4*/ { "fisub", WORD, op1(X), (const char *)db_Esca4 },
602 /*5*/ { "fisubr", WORD, 0, 0 },
603 /*6*/ { "fidiv", WORD, 0, 0 },
604 /*7*/ { "fidivr", WORD, 0, 0 }
607 static const struct finst db_Escb[] = {
608 /*0*/ { "fild", WORD, 0, 0 },
609 /*1*/ { "", NONE, 0, 0 },
610 /*2*/ { "fist", WORD, 0, 0 },
611 /*3*/ { "fistp", WORD, 0, 0 },
612 /*4*/ { "", WORD, op1(X), (const char *)db_Escb4 },
613 /*5*/ { "fld", EXTR, 0, 0 },
614 /*6*/ { "", WORD, 0, 0 },
615 /*7*/ { "fstp", EXTR, 0, 0 },
618 static const struct finst db_Escc[] = {
619 /*0*/ { "fadd", DBLR, op2(ST,STI), 0 },
620 /*1*/ { "fmul", DBLR, op2(ST,STI), 0 },
621 /*2*/ { "fcom", DBLR, op2(ST,STI), 0 },
622 /*3*/ { "fcomp", DBLR, op2(ST,STI), 0 },
623 /*4*/ { "fsub", DBLR, op2(ST,STI), "fsubr" },
624 /*5*/ { "fsubr", DBLR, op2(ST,STI), "fsub" },
625 /*6*/ { "fdiv", DBLR, op2(ST,STI), "fdivr" },
626 /*7*/ { "fdivr", DBLR, op2(ST,STI), "fdiv" },
629 static const struct finst db_Escd[] = {
630 /*0*/ { "fld", DBLR, op1(STI), "ffree" },
631 /*1*/ { "", NONE, 0, 0 },
632 /*2*/ { "fst", DBLR, op1(STI), 0 },
633 /*3*/ { "fstp", DBLR, op1(STI), 0 },
634 /*4*/ { "frstor", NONE, op1(STI), "fucom" },
635 /*5*/ { "", NONE, op1(STI), "fucomp" },
636 /*6*/ { "fnsave", NONE, 0, 0 },
637 /*7*/ { "fnstsw", NONE, 0, 0 },
640 static const struct finst db_Esce[] = {
641 /*0*/ { "fiadd", LONG, op2(ST,STI), "faddp" },
642 /*1*/ { "fimul", LONG, op2(ST,STI), "fmulp" },
643 /*2*/ { "ficom", LONG, 0, 0 },
644 /*3*/ { "ficomp", LONG, op1(X), (const char *)db_Esce3 },
645 /*4*/ { "fisub", LONG, op2(ST,STI), "fsubrp" },
646 /*5*/ { "fisubr", LONG, op2(ST,STI), "fsubp" },
647 /*6*/ { "fidiv", LONG, op2(ST,STI), "fdivrp" },
648 /*7*/ { "fidivr", LONG, op2(ST,STI), "fdivp" },
651 static const struct finst db_Escf[] = {
652 /*0*/ { "fild", LONG, 0, 0 },
653 /*1*/ { "", LONG, 0, 0 },
654 /*2*/ { "fist", LONG, 0, 0 },
655 /*3*/ { "fistp", LONG, 0, 0 },
656 /*4*/ { "fbld", NONE, op1(XA), (const char *)db_Escf4 },
657 /*5*/ { "fld", QUAD, 0, 0 },
658 /*6*/ { "fbstp", NONE, 0, 0 },
659 /*7*/ { "fstp", QUAD, 0, 0 },
662 static const struct finst * const db_Esc_inst[] = {
663 db_Esc8, db_Esc9, db_Esca, db_Escb,
664 db_Escc, db_Escd, db_Esce, db_Escf
667 static const char * const db_Grp1[] = {
668 "add",
669 "or",
670 "adc",
671 "sbb",
672 "and",
673 "sub",
674 "xor",
675 "cmp"
678 static const char * const db_Grp2[] = {
679 "rol",
680 "ror",
681 "rcl",
682 "rcr",
683 "shl",
684 "shr",
685 "shl",
686 "sar"
689 static const struct inst db_Grp3[] = {
690 { "test", TRUE, NONE, op2(I,E), 0 },
691 { "test", TRUE, NONE, op2(I,E), 0 },
692 { "not", TRUE, NONE, op1(E), 0 },
693 { "neg", TRUE, NONE, op1(E), 0 },
694 { "mul", TRUE, NONE, op2(E,A), 0 },
695 { "imul", TRUE, NONE, op2(E,A), 0 },
696 { "div", TRUE, NONE, op2(E,A), 0 },
697 { "idiv", TRUE, NONE, op2(E,A), 0 },
700 static const struct inst db_Grp4[] = {
701 { "inc", TRUE, BYTE, op1(E), 0 },
702 { "dec", TRUE, BYTE, op1(E), 0 },
703 { "", TRUE, NONE, 0, 0 },
704 { "", TRUE, NONE, 0, 0 },
705 { "", TRUE, NONE, 0, 0 },
706 { "", TRUE, NONE, 0, 0 },
707 { "", TRUE, NONE, 0, 0 },
708 { "", TRUE, NONE, 0, 0 }
711 static const struct inst db_Grp5[] = {
712 { "inc", TRUE, LONG, op1(E), 0 },
713 { "dec", TRUE, LONG, op1(E), 0 },
714 { "call", TRUE, NONE, op1(Eind),0 },
715 { "lcall", TRUE, NONE, op1(Eind),0 },
716 { "jmp", TRUE, NONE, op1(Eind),0 },
717 { "ljmp", TRUE, NONE, op1(Eind),0 },
718 { "push", TRUE, LONG, op1(E), 0 },
719 { "", TRUE, NONE, 0, 0 }
722 static const struct inst db_inst_table[256] = {
723 /*00*/ { "add", TRUE, BYTE, op2(R, E), 0 },
724 /*01*/ { "add", TRUE, LONG, op2(R, E), 0 },
725 /*02*/ { "add", TRUE, BYTE, op2(E, R), 0 },
726 /*03*/ { "add", TRUE, LONG, op2(E, R), 0 },
727 /*04*/ { "add", FALSE, BYTE, op2(Is, A), 0 },
728 /*05*/ { "add", FALSE, LONG, op2(Is, A), 0 },
729 /*06*/ { "push", FALSE, NONE, op1(Si), 0 },
730 /*07*/ { "pop", FALSE, NONE, op1(Si), 0 },
732 /*08*/ { "or", TRUE, BYTE, op2(R, E), 0 },
733 /*09*/ { "or", TRUE, LONG, op2(R, E), 0 },
734 /*0a*/ { "or", TRUE, BYTE, op2(E, R), 0 },
735 /*0b*/ { "or", TRUE, LONG, op2(E, R), 0 },
736 /*0c*/ { "or", FALSE, BYTE, op2(I, A), 0 },
737 /*0d*/ { "or", FALSE, LONG, op2(I, A), 0 },
738 /*0e*/ { "push", FALSE, NONE, op1(Si), 0 },
739 /*0f*/ { "", FALSE, NONE, 0, 0 },
741 /*10*/ { "adc", TRUE, BYTE, op2(R, E), 0 },
742 /*11*/ { "adc", TRUE, LONG, op2(R, E), 0 },
743 /*12*/ { "adc", TRUE, BYTE, op2(E, R), 0 },
744 /*13*/ { "adc", TRUE, LONG, op2(E, R), 0 },
745 /*14*/ { "adc", FALSE, BYTE, op2(Is, A), 0 },
746 /*15*/ { "adc", FALSE, LONG, op2(Is, A), 0 },
747 /*16*/ { "push", FALSE, NONE, op1(Si), 0 },
748 /*17*/ { "pop", FALSE, NONE, op1(Si), 0 },
750 /*18*/ { "sbb", TRUE, BYTE, op2(R, E), 0 },
751 /*19*/ { "sbb", TRUE, LONG, op2(R, E), 0 },
752 /*1a*/ { "sbb", TRUE, BYTE, op2(E, R), 0 },
753 /*1b*/ { "sbb", TRUE, LONG, op2(E, R), 0 },
754 /*1c*/ { "sbb", FALSE, BYTE, op2(Is, A), 0 },
755 /*1d*/ { "sbb", FALSE, LONG, op2(Is, A), 0 },
756 /*1e*/ { "push", FALSE, NONE, op1(Si), 0 },
757 /*1f*/ { "pop", FALSE, NONE, op1(Si), 0 },
759 /*20*/ { "and", TRUE, BYTE, op2(R, E), 0 },
760 /*21*/ { "and", TRUE, LONG, op2(R, E), 0 },
761 /*22*/ { "and", TRUE, BYTE, op2(E, R), 0 },
762 /*23*/ { "and", TRUE, LONG, op2(E, R), 0 },
763 /*24*/ { "and", FALSE, BYTE, op2(I, A), 0 },
764 /*25*/ { "and", FALSE, LONG, op2(I, A), 0 },
765 /*26*/ { "", FALSE, NONE, 0, 0 },
766 /*27*/ { "aaa", FALSE, NONE, 0, 0 },
768 /*28*/ { "sub", TRUE, BYTE, op2(R, E), 0 },
769 /*29*/ { "sub", TRUE, LONG, op2(R, E), 0 },
770 /*2a*/ { "sub", TRUE, BYTE, op2(E, R), 0 },
771 /*2b*/ { "sub", TRUE, LONG, op2(E, R), 0 },
772 /*2c*/ { "sub", FALSE, BYTE, op2(Is, A), 0 },
773 /*2d*/ { "sub", FALSE, LONG, op2(Is, A), 0 },
774 /*2e*/ { "", FALSE, NONE, 0, 0 },
775 /*2f*/ { "das", FALSE, NONE, 0, 0 },
777 /*30*/ { "xor", TRUE, BYTE, op2(R, E), 0 },
778 /*31*/ { "xor", TRUE, LONG, op2(R, E), 0 },
779 /*32*/ { "xor", TRUE, BYTE, op2(E, R), 0 },
780 /*33*/ { "xor", TRUE, LONG, op2(E, R), 0 },
781 /*34*/ { "xor", FALSE, BYTE, op2(I, A), 0 },
782 /*35*/ { "xor", FALSE, LONG, op2(I, A), 0 },
783 /*36*/ { "", FALSE, NONE, 0, 0 },
784 /*37*/ { "daa", FALSE, NONE, 0, 0 },
786 /*38*/ { "cmp", TRUE, BYTE, op2(R, E), 0 },
787 /*39*/ { "cmp", TRUE, LONG, op2(R, E), 0 },
788 /*3a*/ { "cmp", TRUE, BYTE, op2(E, R), 0 },
789 /*3b*/ { "cmp", TRUE, LONG, op2(E, R), 0 },
790 /*3c*/ { "cmp", FALSE, BYTE, op2(Is, A), 0 },
791 /*3d*/ { "cmp", FALSE, LONG, op2(Is, A), 0 },
792 /*3e*/ { "", FALSE, NONE, 0, 0 },
793 /*3f*/ { "aas", FALSE, NONE, 0, 0 },
795 /*40*/ { "inc", FALSE, LONG, op1(Ri), 0 },
796 /*41*/ { "inc", FALSE, LONG, op1(Ri), 0 },
797 /*42*/ { "inc", FALSE, LONG, op1(Ri), 0 },
798 /*43*/ { "inc", FALSE, LONG, op1(Ri), 0 },
799 /*44*/ { "inc", FALSE, LONG, op1(Ri), 0 },
800 /*45*/ { "inc", FALSE, LONG, op1(Ri), 0 },
801 /*46*/ { "inc", FALSE, LONG, op1(Ri), 0 },
802 /*47*/ { "inc", FALSE, LONG, op1(Ri), 0 },
804 /*48*/ { "dec", FALSE, LONG, op1(Ri), 0 },
805 /*49*/ { "dec", FALSE, LONG, op1(Ri), 0 },
806 /*4a*/ { "dec", FALSE, LONG, op1(Ri), 0 },
807 /*4b*/ { "dec", FALSE, LONG, op1(Ri), 0 },
808 /*4c*/ { "dec", FALSE, LONG, op1(Ri), 0 },
809 /*4d*/ { "dec", FALSE, LONG, op1(Ri), 0 },
810 /*4e*/ { "dec", FALSE, LONG, op1(Ri), 0 },
811 /*4f*/ { "dec", FALSE, LONG, op1(Ri), 0 },
813 /*50*/ { "push", FALSE, LONG, op1(Ri), 0 },
814 /*51*/ { "push", FALSE, LONG, op1(Ri), 0 },
815 /*52*/ { "push", FALSE, LONG, op1(Ri), 0 },
816 /*53*/ { "push", FALSE, LONG, op1(Ri), 0 },
817 /*54*/ { "push", FALSE, LONG, op1(Ri), 0 },
818 /*55*/ { "push", FALSE, LONG, op1(Ri), 0 },
819 /*56*/ { "push", FALSE, LONG, op1(Ri), 0 },
820 /*57*/ { "push", FALSE, LONG, op1(Ri), 0 },
822 /*58*/ { "pop", FALSE, LONG, op1(Ri), 0 },
823 /*59*/ { "pop", FALSE, LONG, op1(Ri), 0 },
824 /*5a*/ { "pop", FALSE, LONG, op1(Ri), 0 },
825 /*5b*/ { "pop", FALSE, LONG, op1(Ri), 0 },
826 /*5c*/ { "pop", FALSE, LONG, op1(Ri), 0 },
827 /*5d*/ { "pop", FALSE, LONG, op1(Ri), 0 },
828 /*5e*/ { "pop", FALSE, LONG, op1(Ri), 0 },
829 /*5f*/ { "pop", FALSE, LONG, op1(Ri), 0 },
831 /*60*/ { "pusha", FALSE, LONG, 0, 0 },
832 /*61*/ { "popa", FALSE, LONG, 0, 0 },
833 /*62*/ { "bound", TRUE, LONG, op2(E, R), 0 },
834 /*63*/ { "arpl", TRUE, NONE, op2(Ew,Rw), 0 },
836 /*64*/ { "", FALSE, NONE, 0, 0 },
837 /*65*/ { "", FALSE, NONE, 0, 0 },
838 /*66*/ { "", FALSE, NONE, 0, 0 },
839 /*67*/ { "", FALSE, NONE, 0, 0 },
841 /*68*/ { "push", FALSE, LONG, op1(I), 0 },
842 /*69*/ { "imul", TRUE, LONG, op3(I,E,R), 0 },
843 /*6a*/ { "push", FALSE, LONG, op1(Ib), 0 },
844 /*6b*/ { "imul", TRUE, LONG, op3(Ibs,E,R),0 },
845 /*6c*/ { "ins", FALSE, BYTE, op2(DX, DI), 0 },
846 /*6d*/ { "ins", FALSE, LONG, op2(DX, DI), 0 },
847 /*6e*/ { "outs", FALSE, BYTE, op2(SI, DX), 0 },
848 /*6f*/ { "outs", FALSE, LONG, op2(SI, DX), 0 },
850 /*70*/ { "jo", FALSE, NONE, op1(Db), 0 },
851 /*71*/ { "jno", FALSE, NONE, op1(Db), 0 },
852 /*72*/ { "jb", FALSE, NONE, op1(Db), 0 },
853 /*73*/ { "jnb", FALSE, NONE, op1(Db), 0 },
854 /*74*/ { "jz", FALSE, NONE, op1(Db), 0 },
855 /*75*/ { "jnz", FALSE, NONE, op1(Db), 0 },
856 /*76*/ { "jbe", FALSE, NONE, op1(Db), 0 },
857 /*77*/ { "jnbe", FALSE, NONE, op1(Db), 0 },
859 /*78*/ { "js", FALSE, NONE, op1(Db), 0 },
860 /*79*/ { "jns", FALSE, NONE, op1(Db), 0 },
861 /*7a*/ { "jp", FALSE, NONE, op1(Db), 0 },
862 /*7b*/ { "jnp", FALSE, NONE, op1(Db), 0 },
863 /*7c*/ { "jl", FALSE, NONE, op1(Db), 0 },
864 /*7d*/ { "jnl", FALSE, NONE, op1(Db), 0 },
865 /*7e*/ { "jle", FALSE, NONE, op1(Db), 0 },
866 /*7f*/ { "jnle", FALSE, NONE, op1(Db), 0 },
868 /*80*/ { "", TRUE, BYTE, op2(I, E), (const char *)db_Grp1 },
869 /*81*/ { "", TRUE, LONG, op2(I, E), (const char *)db_Grp1 },
870 /*82*/ { "", TRUE, BYTE, op2(Is,E), (const char *)db_Grp1 },
871 /*83*/ { "", TRUE, LONG, op2(Ibs,E), (const char *)db_Grp1 },
872 /*84*/ { "test", TRUE, BYTE, op2(R, E), 0 },
873 /*85*/ { "test", TRUE, LONG, op2(R, E), 0 },
874 /*86*/ { "xchg", TRUE, BYTE, op2(R, E), 0 },
875 /*87*/ { "xchg", TRUE, LONG, op2(R, E), 0 },
877 /*88*/ { "mov", TRUE, BYTE, op2(R, E), 0 },
878 /*89*/ { "mov", TRUE, LONG, op2(R, E), 0 },
879 /*8a*/ { "mov", TRUE, BYTE, op2(E, R), 0 },
880 /*8b*/ { "mov", TRUE, LONG, op2(E, R), 0 },
881 /*8c*/ { "mov", TRUE, NONE, op2(S, Ew), 0 },
882 /*8d*/ { "lea", TRUE, LONG, op2(E, R), 0 },
883 /*8e*/ { "mov", TRUE, NONE, op2(Ew, S), 0 },
884 /*8f*/ { "pop", TRUE, LONG, op1(E), 0 },
886 /*90*/ { "nop", FALSE, NONE, 0, 0 },
887 /*91*/ { "xchg", FALSE, LONG, op2(A, Ri), 0 },
888 /*92*/ { "xchg", FALSE, LONG, op2(A, Ri), 0 },
889 /*93*/ { "xchg", FALSE, LONG, op2(A, Ri), 0 },
890 /*94*/ { "xchg", FALSE, LONG, op2(A, Ri), 0 },
891 /*95*/ { "xchg", FALSE, LONG, op2(A, Ri), 0 },
892 /*96*/ { "xchg", FALSE, LONG, op2(A, Ri), 0 },
893 /*97*/ { "xchg", FALSE, LONG, op2(A, Ri), 0 },
895 /*98*/ { "cbw", FALSE, SDEP, 0, "cwde" }, /* cbw/cwde */
896 /*99*/ { "cwd", FALSE, SDEP, 0, "cdq" }, /* cwd/cdq */
897 /*9a*/ { "lcall", FALSE, NONE, op1(OS), 0 },
898 /*9b*/ { "wait", FALSE, NONE, 0, 0 },
899 /*9c*/ { "pushf", FALSE, LONG, 0, 0 },
900 /*9d*/ { "popf", FALSE, LONG, 0, 0 },
901 /*9e*/ { "sahf", FALSE, NONE, 0, 0 },
902 /*9f*/ { "lahf", FALSE, NONE, 0, 0 },
904 /*a0*/ { "mov", FALSE, BYTE, op2(O, A), 0 },
905 /*a1*/ { "mov", FALSE, LONG, op2(O, A), 0 },
906 /*a2*/ { "mov", FALSE, BYTE, op2(A, O), 0 },
907 /*a3*/ { "mov", FALSE, LONG, op2(A, O), 0 },
908 /*a4*/ { "movs", FALSE, BYTE, op2(SI,DI), 0 },
909 /*a5*/ { "movs", FALSE, LONG, op2(SI,DI), 0 },
910 /*a6*/ { "cmps", FALSE, BYTE, op2(SI,DI), 0 },
911 /*a7*/ { "cmps", FALSE, LONG, op2(SI,DI), 0 },
913 /*a8*/ { "test", FALSE, BYTE, op2(I, A), 0 },
914 /*a9*/ { "test", FALSE, LONG, op2(I, A), 0 },
915 /*aa*/ { "stos", FALSE, BYTE, op1(DI), 0 },
916 /*ab*/ { "stos", FALSE, LONG, op1(DI), 0 },
917 /*ac*/ { "lods", FALSE, BYTE, op1(SI), 0 },
918 /*ad*/ { "lods", FALSE, LONG, op1(SI), 0 },
919 /*ae*/ { "scas", FALSE, BYTE, op1(DI), 0 },
920 /*af*/ { "scas", FALSE, LONG, op1(DI), 0 },
922 /*b0*/ { "mov", FALSE, BYTE, op2(I, Ri), 0 },
923 /*b1*/ { "mov", FALSE, BYTE, op2(I, Ri), 0 },
924 /*b2*/ { "mov", FALSE, BYTE, op2(I, Ri), 0 },
925 /*b3*/ { "mov", FALSE, BYTE, op2(I, Ri), 0 },
926 /*b4*/ { "mov", FALSE, BYTE, op2(I, Ri), 0 },
927 /*b5*/ { "mov", FALSE, BYTE, op2(I, Ri), 0 },
928 /*b6*/ { "mov", FALSE, BYTE, op2(I, Ri), 0 },
929 /*b7*/ { "mov", FALSE, BYTE, op2(I, Ri), 0 },
931 /*b8*/ { "mov", FALSE, LONG, op2(I, Ri), 0 },
932 /*b9*/ { "mov", FALSE, LONG, op2(I, Ri), 0 },
933 /*ba*/ { "mov", FALSE, LONG, op2(I, Ri), 0 },
934 /*bb*/ { "mov", FALSE, LONG, op2(I, Ri), 0 },
935 /*bc*/ { "mov", FALSE, LONG, op2(I, Ri), 0 },
936 /*bd*/ { "mov", FALSE, LONG, op2(I, Ri), 0 },
937 /*be*/ { "mov", FALSE, LONG, op2(I, Ri), 0 },
938 /*bf*/ { "mov", FALSE, LONG, op2(I, Ri), 0 },
940 /*c0*/ { "", TRUE, BYTE, op2(Ib, E), (const char *)db_Grp2 },
941 /*c1*/ { "", TRUE, LONG, op2(Ib, E), (const char *)db_Grp2 },
942 /*c2*/ { "ret", FALSE, NONE, op1(Iw), 0 },
943 /*c3*/ { "ret", FALSE, NONE, 0, 0 },
944 /*c4*/ { "les", TRUE, LONG, op2(E, R), 0 },
945 /*c5*/ { "lds", TRUE, LONG, op2(E, R), 0 },
946 /*c6*/ { "mov", TRUE, BYTE, op2(I, E), 0 },
947 /*c7*/ { "mov", TRUE, LONG, op2(I, E), 0 },
949 /*c8*/ { "enter", FALSE, NONE, op2(Iw, Ib), 0 },
950 /*c9*/ { "leave", FALSE, NONE, 0, 0 },
951 /*ca*/ { "lret", FALSE, NONE, op1(Iw), 0 },
952 /*cb*/ { "lret", FALSE, NONE, 0, 0 },
953 /*cc*/ { "int", FALSE, NONE, op1(o3), 0 },
954 /*cd*/ { "int", FALSE, NONE, op1(Ib), 0 },
955 /*ce*/ { "into", FALSE, NONE, 0, 0 },
956 /*cf*/ { "iret", FALSE, NONE, 0, 0 },
958 /*d0*/ { "", TRUE, BYTE, op2(o1, E), (const char *)db_Grp2 },
959 /*d1*/ { "", TRUE, LONG, op2(o1, E), (const char *)db_Grp2 },
960 /*d2*/ { "", TRUE, BYTE, op2(CL, E), (const char *)db_Grp2 },
961 /*d3*/ { "", TRUE, LONG, op2(CL, E), (const char *)db_Grp2 },
962 /*d4*/ { "aam", TRUE, NONE, 0, 0 },
963 /*d5*/ { "aad", TRUE, NONE, 0, 0 },
964 /*d6*/ { "", FALSE, NONE, 0, 0 },
965 /*d7*/ { "xlat", FALSE, BYTE, op1(BX), 0 },
967 /*d8*/ { "", TRUE, NONE, 0, (const char *)db_Esc8 },
968 /*d9*/ { "", TRUE, NONE, 0, (const char *)db_Esc9 },
969 /*da*/ { "", TRUE, NONE, 0, (const char *)db_Esca },
970 /*db*/ { "", TRUE, NONE, 0, (const char *)db_Escb },
971 /*dc*/ { "", TRUE, NONE, 0, (const char *)db_Escc },
972 /*dd*/ { "", TRUE, NONE, 0, (const char *)db_Escd },
973 /*de*/ { "", TRUE, NONE, 0, (const char *)db_Esce },
974 /*df*/ { "", TRUE, NONE, 0, (const char *)db_Escf },
976 /*e0*/ { "loopne",FALSE, NONE, op1(Db), 0 },
977 /*e1*/ { "loope", FALSE, NONE, op1(Db), 0 },
978 /*e2*/ { "loop", FALSE, NONE, op1(Db), 0 },
979 /*e3*/ { "jcxz", FALSE, SDEP, op1(Db), "jecxz" },
980 /*e4*/ { "in", FALSE, BYTE, op2(Ib, A), 0 },
981 /*e5*/ { "in", FALSE, LONG, op2(Ib, A) , 0 },
982 /*e6*/ { "out", FALSE, BYTE, op2(A, Ib), 0 },
983 /*e7*/ { "out", FALSE, LONG, op2(A, Ib) , 0 },
985 /*e8*/ { "call", FALSE, NONE, op1(Dl), 0 },
986 /*e9*/ { "jmp", FALSE, NONE, op1(Dl), 0 },
987 /*ea*/ { "ljmp", FALSE, NONE, op1(OS), 0 },
988 /*eb*/ { "jmp", FALSE, NONE, op1(Db), 0 },
989 /*ec*/ { "in", FALSE, BYTE, op2(DX, A), 0 },
990 /*ed*/ { "in", FALSE, LONG, op2(DX, A) , 0 },
991 /*ee*/ { "out", FALSE, BYTE, op2(A, DX), 0 },
992 /*ef*/ { "out", FALSE, LONG, op2(A, DX) , 0 },
994 /*f0*/ { "", FALSE, NONE, 0, 0 },
995 /*f1*/ { "icebp", FALSE, NONE, 0, 0 },
996 /*f2*/ { "", FALSE, NONE, 0, 0 },
997 /*f3*/ { "", FALSE, NONE, 0, 0 },
998 /*f4*/ { "hlt", FALSE, NONE, 0, 0 },
999 /*f5*/ { "cmc", FALSE, NONE, 0, 0 },
1000 /*f6*/ { "", TRUE, BYTE, 0, (const char *)db_Grp3 },
1001 /*f7*/ { "", TRUE, LONG, 0, (const char *)db_Grp3 },
1003 /*f8*/ { "clc", FALSE, NONE, 0, 0 },
1004 /*f9*/ { "stc", FALSE, NONE, 0, 0 },
1005 /*fa*/ { "cli", FALSE, NONE, 0, 0 },
1006 /*fb*/ { "sti", FALSE, NONE, 0, 0 },
1007 /*fc*/ { "cld", FALSE, NONE, 0, 0 },
1008 /*fd*/ { "std", FALSE, NONE, 0, 0 },
1009 /*fe*/ { "", TRUE, NONE, 0, (const char *)db_Grp4 },
1010 /*ff*/ { "", TRUE, NONE, 0, (const char *)db_Grp5 },
1013 static const struct inst db_bad_inst =
1014 { "???", FALSE, NONE, 0, 0 }
1017 #define f_mod(byte) ((byte)>>6)
1018 #define f_reg(byte) (((byte)>>3)&0x7)
1019 #define f_rm(byte) ((byte)&0x7)
1021 #define sib_ss(byte) ((byte)>>6)
1022 #define sib_index(byte) (((byte)>>3)&0x7)
1023 #define sib_base(byte) ((byte)&0x7)
1025 struct i_addr {
1026 int is_reg; /* if reg, reg number is in 'disp' */
1027 int disp;
1028 const char * base;
1029 const char * index;
1030 int ss;
1033 static const char * const db_index_reg_16[8] = {
1034 "%bx,%si",
1035 "%bx,%di",
1036 "%bp,%si",
1037 "%bp,%di",
1038 "%si",
1039 "%di",
1040 "%bp",
1041 "%bx"
1044 static const char * const db_reg[5][8] = {
1045 /*BYTE*/{ "%al", "%cl", "%dl", "%bl", "%ah", "%ch", "%dh", "%bh" },
1046 /*WORD*/{ "%ax", "%cx", "%dx", "%bx", "%sp", "%bp", "%si", "%di" },
1047 /*LONG*/{ "%eax", "%ecx", "%edx", "%ebx", "%esp", "%ebp", "%esi", "%edi" },
1048 /*QUAD*/{ "%mm0", "%mm1", "%mm2", "%mm3", "%mm4", "%mm5", "%mm6", "%mm7" },
1049 /*DQUA*/{ "%xmm0","%xmm1","%xmm2","%xmm3","%xmm4","%xmm5","%xmm6","%xmm7" }
1052 static const char * const db_seg_reg[8] = {
1053 "%es", "%cs", "%ss", "%ds", "%fs", "%gs", "", ""
1057 * lengths for size attributes
1059 static const int db_lengths[] = {
1060 1, /* BYTE */
1061 2, /* WORD */
1062 4, /* LONG */
1063 8, /* QUAD */
1064 16, /* DQUA */
1065 4, /* SNGL */
1066 8, /* DBLR */
1067 10, /* EXTR */
1070 static unsigned int db_get_task_value( const ADDRESS64* addr,
1071 int size, int is_signed )
1073 unsigned int result = 0;
1074 char buffer[4];
1076 if (size != 1 && size != 2 && size != 4)
1078 dbg_printf("Illegal size specified\n");
1080 else
1082 dbg_read_memory(memory_to_linear_addr(addr), buffer, size);
1084 switch (size)
1086 case 4:
1087 if (is_signed) result = (unsigned int) *(int *)buffer;
1088 else result = *(unsigned int *)buffer;
1089 break;
1090 case 2:
1091 if (is_signed) result = (unsigned int) *(short int *)buffer;
1092 else result = *(unsigned short int *)buffer;
1093 break;
1094 case 1:
1095 if (is_signed) result = (unsigned int) *(char *)buffer;
1096 else result = *(unsigned char *)buffer;
1097 break;
1100 return result;
1103 #define get_value_inc(result, addr, size, is_signed) \
1104 result = db_get_task_value((addr), (size), (is_signed)); \
1105 if (!db_disasm_16) (addr)->Offset += (size); \
1106 else (addr)->Offset = ((addr)->Offset + (size)) & 0xffff;
1109 * Read address at location and return updated location.
1111 static void db_read_address( ADDRESS64* addr, int short_addr, int regmodrm,
1112 struct i_addr *addrp )
1114 int mod, rm, sib, index, disp;
1116 mod = f_mod(regmodrm);
1117 rm = f_rm(regmodrm);
1119 if (mod == 3) {
1120 addrp->is_reg = TRUE;
1121 addrp->disp = rm;
1122 return;
1124 addrp->is_reg = FALSE;
1125 addrp->index = 0;
1127 if (short_addr) {
1128 addrp->index = 0;
1129 addrp->ss = 0;
1130 switch (mod) {
1131 case 0:
1132 if (rm == 6) {
1133 get_value_inc(disp, addr, 2, TRUE);
1134 addrp->disp = disp;
1135 addrp->base = 0;
1137 else {
1138 addrp->disp = 0;
1139 addrp->base = db_index_reg_16[rm];
1141 break;
1142 case 1:
1143 get_value_inc(disp, addr, 1, TRUE);
1144 addrp->disp = disp;
1145 addrp->base = db_index_reg_16[rm];
1146 break;
1147 case 2:
1148 get_value_inc(disp, addr, 2, TRUE);
1149 addrp->disp = disp;
1150 addrp->base = db_index_reg_16[rm];
1151 break;
1154 else {
1155 if (mod != 3 && rm == 4) {
1156 get_value_inc(sib, addr, 1, FALSE);
1157 rm = sib_base(sib);
1158 index = sib_index(sib);
1159 if (index != 4)
1160 addrp->index = db_reg[LONG][index];
1161 addrp->ss = sib_ss(sib);
1164 switch (mod) {
1165 case 0:
1166 if (rm == 5) {
1167 get_value_inc(addrp->disp, addr, 4, FALSE);
1168 addrp->base = 0;
1170 else {
1171 addrp->disp = 0;
1172 addrp->base = db_reg[LONG][rm];
1174 break;
1176 case 1:
1177 get_value_inc(disp, addr, 1, TRUE);
1178 addrp->disp = disp;
1179 addrp->base = db_reg[LONG][rm];
1180 break;
1182 case 2:
1183 get_value_inc(disp, addr, 4, FALSE);
1184 addrp->disp = disp;
1185 addrp->base = db_reg[LONG][rm];
1186 break;
1191 static void db_task_printsym(unsigned int addr, int size)
1193 ADDRESS64 a;
1194 a.Mode = AddrModeFlat;
1195 a.Offset = addr;
1197 print_address(&a, TRUE);
1200 static void db_print_address(const char *seg, int size, struct i_addr *addrp, int byref)
1202 if (addrp->is_reg) {
1203 dbg_printf("%s", db_reg[size][addrp->disp]);
1204 return;
1207 if (seg) {
1208 dbg_printf("%s:", seg);
1211 if (addrp->base != 0 || addrp->index != 0) {
1212 dbg_printf("0x%x(", addrp->disp);
1213 if (addrp->base)
1214 dbg_printf("%s", addrp->base);
1215 if (addrp->index)
1216 dbg_printf(",%s,%d", addrp->index, 1<<addrp->ss);
1217 dbg_printf(")");
1219 else {
1221 /* try to get destination of indirect call
1222 does not work for segmented addresses */
1223 if (!seg && byref) {
1224 void* a1;
1225 void* a2;
1227 dbg_printf("0x%x -> ", addrp->disp);
1228 if (!dbg_read_memory((void*)addrp->disp, &a1, sizeof(a1))) {
1229 dbg_printf("(invalid source)");
1230 } else if (!dbg_read_memory(a1, &a2, sizeof(a2))) {
1231 dbg_printf("(invalid destination)");
1232 } else {
1233 db_task_printsym((unsigned long)a1, 0);
1236 else
1237 db_task_printsym(addrp->disp, size);
1242 * Disassemble floating-point ("escape") instruction
1243 * and return updated location.
1245 static void db_disasm_esc( ADDRESS64* addr, int inst, int short_addr,
1246 int size, const char *seg )
1248 int regmodrm;
1249 const struct finst *fp;
1250 int mod;
1251 struct i_addr address;
1252 const char * name;
1254 get_value_inc(regmodrm, addr, 1, FALSE);
1255 if( !db_display )
1257 return;
1260 fp = &db_Esc_inst[inst - 0xd8][f_reg(regmodrm)];
1261 mod = f_mod(regmodrm);
1262 if (mod != 3) {
1263 const char* p;
1265 * Normal address modes.
1267 db_read_address( addr, short_addr, regmodrm, &address);
1268 dbg_printf("%s", fp->f_name);
1269 switch(fp->f_size) {
1270 case SNGL: p = "s"; break;
1271 case DBLR: p = "l"; break;
1272 case EXTR: p = "t"; break;
1273 case WORD: p = "s"; break;
1274 case LONG: p = "l"; break;
1275 case QUAD: p = "q"; break;
1276 default: p = ""; break;
1278 dbg_printf("%s\t", p);
1279 db_print_address(seg, BYTE, &address, 0);
1281 else {
1283 * 'reg-reg' - special formats
1285 switch (fp->f_rrmode) {
1286 case op2(ST,STI):
1287 name = (fp->f_rrname) ? fp->f_rrname : fp->f_name;
1288 dbg_printf("%s\t%%st,%%st(%d)",name,f_rm(regmodrm));
1289 break;
1290 case op2(STI,ST):
1291 name = (fp->f_rrname) ? fp->f_rrname : fp->f_name;
1292 dbg_printf("%s\t%%st(%d),%%st",name, f_rm(regmodrm));
1293 break;
1294 case op1(STI):
1295 name = (fp->f_rrname) ? fp->f_rrname : fp->f_name;
1296 dbg_printf("%s\t%%st(%d)",name, f_rm(regmodrm));
1297 break;
1298 case op1(X):
1299 dbg_printf("%s", ((char * const*)fp->f_rrname)[f_rm(regmodrm)]);
1300 break;
1301 case op1(XA):
1302 dbg_printf("%s\t%%ax", ((char * const*)fp->f_rrname)[f_rm(regmodrm)]);
1303 break;
1304 default:
1305 dbg_printf("<bad instruction>");
1306 break;
1312 /***********************************************************************
1313 * disasm_one_insn
1315 * Disassemble instruction at 'addr'. addr is changed to point to the
1316 * start of the next instruction.
1318 void be_i386_disasm_one_insn(ADDRESS64 *addr, int display)
1320 int inst;
1321 int size;
1322 int short_addr;
1323 const char *seg;
1324 const struct inst *ip;
1325 const char *i_name;
1326 int i_size;
1327 int i_mode;
1328 int regmodrm = 0;
1329 BOOL first;
1330 int displ;
1331 int prefix;
1332 int imm;
1333 int len;
1334 struct i_addr address;
1337 * Set this so we can suppress the printout if we need to.
1339 db_display = display;
1340 switch (addr->Mode)
1342 case AddrModeReal:
1343 case AddrMode1616: db_disasm_16 = 1; break;
1344 default: db_disasm_16 = 0; break;
1347 get_value_inc( inst, addr, 1, FALSE );
1349 if (db_disasm_16) {
1350 short_addr = TRUE;
1351 size = WORD;
1353 else {
1354 short_addr = FALSE;
1355 size = LONG;
1357 seg = 0;
1360 * Get prefixes
1362 prefix = TRUE;
1363 do {
1364 switch (inst) {
1365 case 0x66: /* data16 */
1366 if (size == LONG)
1367 size = WORD;
1368 else
1369 size = LONG;
1370 break;
1371 case 0x67:
1372 short_addr = !short_addr;
1373 break;
1374 case 0x26:
1375 seg = "%es";
1376 break;
1377 case 0x36:
1378 seg = "%ss";
1379 break;
1380 case 0x2e:
1381 seg = "%cs";
1382 break;
1383 case 0x3e:
1384 seg = "%ds";
1385 break;
1386 case 0x64:
1387 seg = "%fs";
1388 break;
1389 case 0x65:
1390 seg = "%gs";
1391 break;
1392 case 0xf0:
1393 if( db_display )
1394 dbg_printf("lock ");
1395 break;
1396 case 0xf2:
1397 if( db_display )
1398 dbg_printf("repne ");
1399 break;
1400 case 0xf3:
1401 if( db_display )
1402 dbg_printf("repe "); /* XXX repe VS rep */
1403 break;
1404 default:
1405 prefix = FALSE;
1406 break;
1408 if (prefix) {
1409 get_value_inc(inst, addr, 1, FALSE);
1411 } while (prefix);
1413 if (inst >= 0xd8 && inst <= 0xdf)
1415 db_disasm_esc( addr, inst, short_addr, size, seg);
1416 return;
1419 if (inst == 0x0f) {
1420 get_value_inc(inst, addr, 1, FALSE);
1421 ip = db_inst_0f[inst>>4];
1422 if (ip == 0) {
1423 ip = &db_bad_inst;
1425 else {
1426 ip = &ip[inst&0xf];
1429 else
1430 ip = &db_inst_table[inst];
1432 if (ip->i_has_modrm) {
1433 get_value_inc(regmodrm, addr, 1, FALSE);
1434 db_read_address( addr, short_addr, regmodrm, &address);
1437 i_name = ip->i_name;
1438 i_size = ip->i_size;
1439 i_mode = ip->i_mode;
1441 if (ip->i_extra == (const char *)db_Grp1 ||
1442 ip->i_extra == (const char *)db_Grp2 ||
1443 ip->i_extra == (const char *)db_Grp6 ||
1444 ip->i_extra == (const char *)db_Grp7 ||
1445 ip->i_extra == (const char *)db_Grp8 ||
1446 ip->i_extra == (const char *)db_Grp10 ||
1447 ip->i_extra == (const char *)db_Grp11 ||
1448 ip->i_extra == (const char *)db_Grp12) {
1449 i_name = ((const char * const*)ip->i_extra)[f_reg(regmodrm)];
1451 else if (ip->i_extra == (const char *)db_Grp3) {
1452 ip = (const struct inst *)ip->i_extra;
1453 ip = &ip[f_reg(regmodrm)];
1454 i_name = ip->i_name;
1455 i_mode = ip->i_mode;
1457 else if (ip->i_extra == (const char *)db_Grp4 ||
1458 ip->i_extra == (const char *)db_Grp5) {
1459 ip = (const struct inst *)ip->i_extra;
1460 ip = &ip[f_reg(regmodrm)];
1461 i_name = ip->i_name;
1462 i_mode = ip->i_mode;
1463 i_size = ip->i_size;
1466 if (i_size == SDEP) {
1467 if( db_display )
1469 if (size == WORD)
1470 dbg_printf("%s", i_name);
1471 else
1472 dbg_printf("%s", ip->i_extra);
1475 else {
1476 if( db_display )
1478 dbg_printf("%s", i_name);
1480 if (i_size != NONE) {
1481 if (i_size == BYTE) {
1482 if( db_display )
1484 dbg_printf("b");
1486 size = BYTE;
1488 else if (i_size == WORD) {
1489 if( db_display )
1491 dbg_printf("w");
1493 size = WORD;
1495 else if (size == WORD)
1497 if( db_display )
1499 dbg_printf("w");
1502 else
1504 if( db_display )
1506 dbg_printf("l");
1511 if( db_display )
1513 dbg_printf("\t");
1515 for (first = TRUE;
1516 i_mode != 0;
1517 i_mode >>= 8, first = FALSE)
1519 if (!first && db_display)
1520 dbg_printf(",");
1522 switch (i_mode & 0xFF) {
1524 case E:
1525 if( db_display )
1527 db_print_address(seg, size, &address, 0);
1529 break;
1531 case Eind:
1532 if( db_display )
1534 dbg_printf("*");
1535 db_print_address(seg, size, &address, 1);
1537 break;
1539 case Ew:
1540 if( db_display )
1542 db_print_address(seg, WORD, &address, 0);
1544 break;
1546 case Eb:
1547 if( db_display )
1549 db_print_address(seg, BYTE, &address, 0);
1551 break;
1553 case R:
1554 if( db_display )
1556 dbg_printf("%s", db_reg[size][f_reg(regmodrm)]);
1558 break;
1559 case MX:
1560 if( db_display )
1562 dbg_printf("%%mm%d", f_reg(regmodrm));
1564 break;
1565 case EMX:
1566 if( db_display )
1568 db_print_address(seg, QUAD, &address, 0);
1570 break;
1571 case XMM:
1572 if( db_display )
1574 dbg_printf("%%xmm%d", f_reg(regmodrm));
1576 break;
1577 case EXMM:
1578 if( db_display )
1580 db_print_address(seg, DQUA, &address, 0);
1582 break;
1585 case Rw:
1586 if( db_display )
1588 dbg_printf("%s", db_reg[WORD][f_reg(regmodrm)]);
1590 break;
1592 case Ri:
1593 if( db_display )
1595 dbg_printf("%s", db_reg[size][f_rm(inst)]);
1597 break;
1599 case S:
1600 if( db_display )
1602 dbg_printf("%s", db_seg_reg[f_reg(regmodrm)]);
1604 break;
1606 case Si:
1607 if( db_display )
1609 dbg_printf("%s", db_seg_reg[f_reg(inst)]);
1611 break;
1613 case A:
1614 if( db_display )
1616 dbg_printf("%s", db_reg[size][0]); /* acc */
1618 break;
1620 case BX:
1621 if( db_display )
1623 if (seg)
1624 dbg_printf("%s:", seg);
1625 dbg_printf("(%s)", short_addr ? "%bx" : "%ebx");
1627 break;
1629 case CL:
1630 if( db_display )
1632 dbg_printf("%%cl");
1634 break;
1636 case DX:
1637 if( db_display )
1639 dbg_printf("%%dx");
1641 break;
1643 case SI:
1644 if( db_display )
1646 if (seg)
1647 dbg_printf("%s:", seg);
1648 dbg_printf("(%s)", short_addr ? "%si" : "%esi");
1650 break;
1652 case DI:
1653 if( db_display )
1655 dbg_printf("%%es:(%s)", short_addr ? "%di" : "%edi");
1657 break;
1659 case CR:
1660 if( db_display )
1662 dbg_printf("%%cr%d", f_reg(regmodrm));
1664 break;
1666 case DR:
1667 if( db_display )
1669 dbg_printf("%%dr%d", f_reg(regmodrm));
1671 break;
1673 case TR:
1674 if( db_display )
1676 dbg_printf("%%tr%d", f_reg(regmodrm));
1678 break;
1680 case I:
1681 len = db_lengths[size];
1682 get_value_inc(imm, addr, len, FALSE);/* unsigned */
1683 if( db_display )
1685 dbg_printf("$0x%x", imm);
1687 break;
1689 case Is:
1690 len = db_lengths[size];
1691 get_value_inc(imm, addr, len, TRUE); /* signed */
1692 if( db_display )
1694 dbg_printf("$%d", imm);
1696 break;
1698 case Ib:
1699 get_value_inc(imm, addr, 1, FALSE); /* unsigned */
1700 if( db_display )
1702 dbg_printf("$0x%x", imm);
1704 break;
1706 case Ibs:
1707 get_value_inc(imm, addr, 1, TRUE); /* signed */
1708 if( db_display )
1710 dbg_printf("$%d", imm);
1712 break;
1714 case Iw:
1715 get_value_inc(imm, addr, 2, FALSE); /* unsigned */
1716 if( db_display )
1718 dbg_printf("$0x%x", imm);
1720 break;
1722 case Il:
1723 get_value_inc(imm, addr, 4, FALSE);
1724 if( db_display )
1726 dbg_printf("$0x%x", imm);
1728 break;
1730 case O:
1731 if (short_addr) {
1732 get_value_inc(displ, addr, 2, TRUE);
1734 else {
1735 get_value_inc(displ, addr, 4, TRUE);
1737 if( !db_display )
1739 break;
1742 if (seg)
1743 dbg_printf("%s:0x%x",seg, displ);
1744 else
1745 db_task_printsym(displ, short_addr ? WORD : LONG);
1746 break;
1748 case Db:
1749 get_value_inc(displ, addr, 1, TRUE);
1750 if( !db_display )
1752 break;
1755 if (size == WORD) {
1756 /* offset only affects low 16 bits */
1757 displ = (addr->Offset & 0xffff0000)
1758 | ((addr->Offset + displ) & 0xffff);
1760 else displ += addr->Offset;
1761 db_task_printsym(displ, size);
1762 break;
1764 case Dl:
1765 if (size == WORD) {
1766 get_value_inc(displ, addr, 2, TRUE);
1767 /* Offset only affects low 16 bits */
1768 displ = (addr->Offset & 0xffff0000)
1769 | ((addr->Offset + displ) & 0xffff);
1771 else {
1772 get_value_inc(displ, addr, 4, TRUE);
1773 displ += addr->Offset;
1775 if( !db_display )
1777 break;
1779 db_task_printsym( displ, size );
1780 break;
1782 case o1:
1783 if( db_display )
1785 dbg_printf("$1");
1787 break;
1789 case o3:
1790 if( db_display )
1792 dbg_printf("$3");
1794 break;
1796 case OS:
1798 ADDRESS64 address;
1799 get_value_inc( address.Offset, addr, /* offset */
1800 short_addr ? 2 : 4, FALSE );
1801 get_value_inc( address.Segment, addr, /* segment */
1802 2, FALSE );
1803 be_cpu->build_addr(dbg_curr_thread->handle, &dbg_context,
1804 &address, address.Segment, address.Offset);
1805 if( db_display )
1807 print_address( &address, TRUE );
1811 break;
1815 #endif /* __i386__ */