wininet: Make FTP_FtpOpenFileW() static.
[wine/multimedia.git] / programs / winedbg / db_disasm.c
blobdc1cc3d78c612a7d82c787e62185c1839f77c62b
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 SNGL 4
89 #define DBLR 5
90 #define EXTR 6
91 #define SDEP 7
92 #define NONE 8
95 * Addressing modes
97 #define E 1 /* general effective address */
98 #define Eind 2 /* indirect address (jump, call) */
99 #define Ew 3 /* address, word size */
100 #define Eb 4 /* address, byte size */
101 #define R 5 /* register, in 'reg' field */
102 #define Rw 6 /* word register, in 'reg' field */
103 #define Ri 7 /* register in instruction */
104 #define S 8 /* segment reg, in 'reg' field */
105 #define Si 9 /* segment reg, in instruction */
106 #define A 10 /* accumulator */
107 #define BX 11 /* (bx) */
108 #define CL 12 /* cl, for shifts */
109 #define DX 13 /* dx, for IO */
110 #define SI 14 /* si */
111 #define DI 15 /* di */
112 #define CR 16 /* control register */
113 #define DR 17 /* debug register */
114 #define TR 18 /* test register */
115 #define I 19 /* immediate, unsigned */
116 #define Is 20 /* immediate, signed */
117 #define Ib 21 /* byte immediate, unsigned */
118 #define Ibs 22 /* byte immediate, signed */
119 #define Iw 23 /* word immediate, unsigned */
120 #define Il 24 /* long immediate */
121 #define O 25 /* direct address */
122 #define Db 26 /* byte displacement from EIP */
123 #define Dl 27 /* long displacement from EIP */
124 #define o1 28 /* constant 1 */
125 #define o3 29 /* constant 3 */
126 #define OS 30 /* immediate offset/segment */
127 #define ST 31 /* FP stack top */
128 #define STI 32 /* FP stack */
129 #define X 33 /* extended FP op */
130 #define XA 34 /* for 'fstcw %ax' */
131 #define MX 35 /* special register (MMX reg %mm0-7) */
132 #define EMX 36 /* special register (MMX reg %mm0-7) */
133 #define XMM 37 /* special register (floating point reg %xmm0-7) */
134 #define EXMM 38 /* special register (floating point reg %xmm0-7) */
136 struct inst {
137 const char *i_name; /* name */
138 short i_has_modrm; /* has regmodrm byte */
139 short i_size; /* operand size */
140 int i_mode; /* addressing modes */
141 const char *i_extra; /* pointer to extra opcode table */
144 #define op1(x) (x)
145 #define op2(x,y) ((x)|((y)<<8))
146 #define op3(x,y,z) ((x)|((y)<<8)|((z)<<16))
148 struct finst {
149 const char *f_name; /* name for memory instruction */
150 int f_size; /* size for memory instruction */
151 int f_rrmode; /* mode for rr instruction */
152 const char *f_rrname; /* name for rr instruction
153 (or pointer to table) */
156 static const char * const db_Grp6[] = {
157 "sldt",
158 "str",
159 "lldt",
160 "ltr",
161 "verr",
162 "verw",
167 static const char * const db_Grp7[] = {
168 "sgdt",
169 "sidt",
170 "lgdt",
171 "lidt",
172 "smsw",
174 "lmsw",
175 "invlpg"
178 static const char * const db_Grp8[] = {
183 "bt",
184 "bts",
185 "btr",
186 "btc"
189 static const char * const db_Grp10[] = {
190 "(bad)",
191 "(bad)",
192 "psrlw",
193 "(bad)",
194 "psraw",
195 "(bad)",
196 "psllw",
197 "(bad)"
200 static const char * const db_Grp11[] = {
201 "(bad)",
202 "(bad)",
203 "psrld",
204 "(bad)",
205 "psrad",
206 "(bad)",
207 "pslld",
208 "(bad)"
211 static const char * const db_Grp12[] = {
212 "(bad)",
213 "(bad)",
214 "psrlq",
215 "(bad)",
216 "psraq",
217 "(bad)",
218 "psllq",
219 "(bad)"
222 static const struct inst db_inst_0f0x[] = {
223 /*00*/ { "", TRUE, NONE, op1(Ew), (const char *)db_Grp6 },
224 /*01*/ { "", TRUE, NONE, op1(Ew), (const char *)db_Grp7 },
225 /*02*/ { "lar", TRUE, LONG, op2(E,R), 0 },
226 /*03*/ { "lsl", TRUE, LONG, op2(E,R), 0 },
227 /*04*/ { "", FALSE, NONE, 0, 0 },
228 /*05*/ { "", FALSE, NONE, 0, 0 },
229 /*06*/ { "clts", FALSE, NONE, 0, 0 },
230 /*07*/ { "", FALSE, NONE, 0, 0 },
232 /*08*/ { "invd", FALSE, NONE, 0, 0 },
233 /*09*/ { "wbinvd",FALSE, NONE, 0, 0 },
234 /*0a*/ { "", FALSE, NONE, 0, 0 },
235 /*0b*/ { "", FALSE, NONE, 0, 0 },
236 /*0c*/ { "", FALSE, NONE, 0, 0 },
237 /*0d*/ { "", FALSE, NONE, 0, 0 },
238 /*0e*/ { "", FALSE, NONE, 0, 0 },
239 /*0f*/ { "", FALSE, NONE, 0, 0 },
242 static const struct inst db_inst_0f2x[] = {
243 /*20*/ { "mov", TRUE, LONG, op2(CR,E), 0 }, /* use E for reg */
244 /*21*/ { "mov", TRUE, LONG, op2(DR,E), 0 }, /* since mod == 11 */
245 /*22*/ { "mov", TRUE, LONG, op2(E,CR), 0 },
246 /*23*/ { "mov", TRUE, LONG, op2(E,DR), 0 },
247 /*24*/ { "mov", TRUE, LONG, op2(TR,E), 0 },
248 /*25*/ { "(bad)", FALSE, NONE, 0, 0 },
249 /*26*/ { "mov", TRUE, LONG, op2(E,TR), 0 },
250 /*27*/ { "(bad)", FALSE, NONE, 0, 0 },
252 /*28*/ { "", FALSE, NONE, 0, 0 },
253 /*29*/ { "", FALSE, NONE, 0, 0 },
254 /*2a*/ { "", FALSE, NONE, 0, 0 },
255 /*2b*/ { "", FALSE, NONE, 0, 0 },
256 /*2c*/ { "", FALSE, NONE, 0, 0 },
257 /*2d*/ { "", FALSE, NONE, 0, 0 },
258 /*2e*/ { "", FALSE, NONE, 0, 0 },
259 /*2f*/ { "", FALSE, NONE, 0, 0 },
262 static const struct inst db_inst_0f3x[] = {
263 /*30*/ { "wrmsr", FALSE, NONE, 0, 0 },
264 /*31*/ { "rdtsc", FALSE, NONE, 0, 0 },
265 /*32*/ { "rdmsr", FALSE, NONE, 0, 0 },
266 /*33*/ { "rdpmc", FALSE, NONE, 0, 0 },
267 /*34*/ { "sysenter",FALSE,NONE, 0, 0 },
268 /*35*/ { "sysexit",FALSE,NONE, 0, 0 },
269 /*36*/ { "(bad)", FALSE, NONE, 0, 0 },
270 /*37*/ { "(bad)", FALSE, NONE, 0, 0 },
272 /*38*/ { "(bad)",FALSE, NONE, 0, 0 },
273 /*39*/ { "(bad)",FALSE, NONE, 0, 0 },
274 /*3a*/ { "(bad)",FALSE, NONE, 0, 0 },
275 /*3b*/ { "(bad)",FALSE, NONE, 0, 0 },
276 /*3c*/ { "(bad)",FALSE, NONE, 0, 0 },
277 /*3d*/ { "(bad)",FALSE, NONE, 0, 0 },
278 /*3e*/ { "(bad)",FALSE, NONE, 0, 0 },
279 /*3f*/ { "(bad)",FALSE, NONE, 0, 0 },
282 static const struct inst db_inst_0f4x[] = {
283 /*40*/ { "cmovo", TRUE, NONE, op2(E, R), 0 },
284 /*41*/ { "cmovno", TRUE, NONE, op2(E, R), 0 },
285 /*42*/ { "cmovnae",TRUE, NONE, op2(E, R), 0 },
286 /*43*/ { "cmovnb", TRUE, NONE, op2(E, R), 0 },
287 /*44*/ { "cmove", TRUE, NONE, op2(E, R), 0 },
288 /*45*/ { "cmovne", TRUE, NONE, op2(E, R), 0 },
289 /*46*/ { "cmovna", TRUE, NONE, op2(E, R), 0 },
290 /*47*/ { "cmova", TRUE, NONE, op2(E, R), 0 },
292 /*48*/ { "cmovs", TRUE, NONE, op2(E, R), 0 },
293 /*49*/ { "cmovns", TRUE, NONE, op2(E, R), 0 },
294 /*4a*/ { "cmovpe", TRUE, NONE, op2(E, R), 0 },
295 /*4b*/ { "cmovpo", TRUE, NONE, op2(E, R), 0 },
296 /*4c*/ { "cmovl", TRUE, NONE, op2(E, R), 0 },
297 /*4d*/ { "cmovge", TRUE, NONE, op2(E, R), 0 },
298 /*4e*/ { "cmovle", TRUE, NONE, op2(E, R), 0 },
299 /*4f*/ { "cmovnle",TRUE, NONE, op2(E, R), 0 },
302 static const struct inst db_inst_0f5x[] = {
303 /*50*/ { "movmskps",TRUE, NONE, op2(E, XMM), 0 },
304 /*51*/ { "sqrtps", TRUE, NONE, op2(XMM, EXMM), 0 },
305 /*52*/ { "rsqrtps", TRUE, NONE, op2(XMM, EXMM), 0 },
306 /*53*/ { "rcpps", TRUE, NONE, op2(XMM, EXMM), 0 },
307 /*54*/ { "andps", TRUE, NONE, op2(XMM, EXMM), 0 },
308 /*55*/ { "andnps", TRUE, NONE, op2(XMM, EXMM), 0 },
309 /*56*/ { "orps", TRUE, NONE, op2(XMM, EXMM), 0 },
310 /*57*/ { "xorps", TRUE, NONE, op2(XMM, EXMM), 0 },
312 /*58*/ { "addps", TRUE, NONE, op2(XMM, EXMM), 0 },
313 /*59*/ { "mulps", TRUE, NONE, op2(XMM, EXMM), 0 },
314 /*5a*/ { "(bad)", FALSE, NONE, 0, 0 },
315 /*5b*/ { "(bad)", FALSE, NONE, 0, 0 },
316 /*5c*/ { "subps", TRUE, NONE, op2(XMM, EXMM), 0 },
317 /*5d*/ { "minps", TRUE, NONE, op2(XMM, EXMM), 0 },
318 /*5e*/ { "divps", TRUE, NONE, op2(XMM, EXMM), 0 },
319 /*5f*/ { "maxps", TRUE, NONE, op2(XMM, EXMM), 0 },
322 static const struct inst db_inst_0f6x[] = {
323 /*60*/ { "punpcklbw", TRUE, NONE, op2(E, MX), 0 },
324 /*61*/ { "punpcklwd", TRUE, NONE, op2(E, MX), 0 },
325 /*62*/ { "punpckldq", TRUE, NONE, op2(E, MX), 0 },
326 /*63*/ { "packsswb", TRUE, NONE, op2(E, MX), 0 },
327 /*64*/ { "pcmpgtb", TRUE, NONE, op2(E, MX), 0 },
328 /*65*/ { "pcmpgtw", TRUE, NONE, op2(E, MX), 0 },
329 /*66*/ { "pcmpgtd", TRUE, NONE, op2(E, MX), 0 },
330 /*67*/ { "packuswb", TRUE, NONE, op2(E, MX), 0 },
332 /*68*/ { "punpckhbw", TRUE, NONE, op2(E, MX), 0 },
333 /*69*/ { "punpckhwd", TRUE, NONE, op2(E, MX), 0 },
334 /*6a*/ { "punpckhdq", TRUE, NONE, op2(E, MX), 0 },
335 /*6b*/ { "packssdw", TRUE, NONE, op2(E, MX), 0 },
336 /*6c*/ { "(bad)", TRUE, NONE, 0, 0 },
337 /*6d*/ { "(bad)", TRUE, NONE, 0, 0 },
338 /*6e*/ { "movd", TRUE, NONE, op2(E, MX), 0 },
339 /*6f*/ { "movq", TRUE, NONE, op2(E, MX), 0 },
342 static const struct inst db_inst_0f7x[] = {
343 /*70*/ { "pshufw", TRUE, NONE, op2(MX, EMX), 0 },
344 /*71*/ { "(grp10)", TRUE, BYTE, op2(EMX, I), (const char*)db_Grp10 },
345 /*72*/ { "(grp11)", TRUE, BYTE, op2(EMX, I), (const char*)db_Grp11 },
346 /*73*/ { "(grp12)", TRUE, BYTE, op2(EMX, I), (const char*)db_Grp12 },
347 /*74*/ { "pcmpeqb", TRUE, NONE, op2(E, MX), 0 },
348 /*75*/ { "pcmpeqw", TRUE, NONE, op2(E, MX), 0 },
349 /*76*/ { "pcmpeqd", TRUE, NONE, op2(E, MX), 0 },
350 /*77*/ { "emms", FALSE,NONE, 0, 0 },
352 /*78*/ { "(bad)", TRUE, NONE, 0, 0 },
353 /*79*/ { "(bad)", TRUE, NONE, 0, 0 },
354 /*7a*/ { "(bad)", TRUE, NONE, 0, 0 },
355 /*7b*/ { "(bad)", TRUE, NONE, 0, 0 },
356 /*7c*/ { "(bad)", TRUE, NONE, 0, 0 },
357 /*7d*/ { "(bad)", TRUE, NONE, 0, 0 },
358 /*7e*/ { "movd", TRUE, NONE, op2(E, MX), 0 },
359 /*7f*/ { "movq", TRUE, NONE, op2(EMX, MX), 0 },
362 static const struct inst db_inst_0f8x[] = {
363 /*80*/ { "jo", FALSE, NONE, op1(Dl), 0 },
364 /*81*/ { "jno", FALSE, NONE, op1(Dl), 0 },
365 /*82*/ { "jb", FALSE, NONE, op1(Dl), 0 },
366 /*83*/ { "jnb", FALSE, NONE, op1(Dl), 0 },
367 /*84*/ { "jz", FALSE, NONE, op1(Dl), 0 },
368 /*85*/ { "jnz", FALSE, NONE, op1(Dl), 0 },
369 /*86*/ { "jbe", FALSE, NONE, op1(Dl), 0 },
370 /*87*/ { "jnbe", FALSE, NONE, op1(Dl), 0 },
372 /*88*/ { "js", FALSE, NONE, op1(Dl), 0 },
373 /*89*/ { "jns", FALSE, NONE, op1(Dl), 0 },
374 /*8a*/ { "jp", FALSE, NONE, op1(Dl), 0 },
375 /*8b*/ { "jnp", FALSE, NONE, op1(Dl), 0 },
376 /*8c*/ { "jl", FALSE, NONE, op1(Dl), 0 },
377 /*8d*/ { "jnl", FALSE, NONE, op1(Dl), 0 },
378 /*8e*/ { "jle", FALSE, NONE, op1(Dl), 0 },
379 /*8f*/ { "jnle", FALSE, NONE, op1(Dl), 0 },
382 static const struct inst db_inst_0f9x[] = {
383 /*90*/ { "seto", TRUE, NONE, op1(Eb), 0 },
384 /*91*/ { "setno", TRUE, NONE, op1(Eb), 0 },
385 /*92*/ { "setb", TRUE, NONE, op1(Eb), 0 },
386 /*93*/ { "setnb", TRUE, NONE, op1(Eb), 0 },
387 /*94*/ { "setz", TRUE, NONE, op1(Eb), 0 },
388 /*95*/ { "setnz", TRUE, NONE, op1(Eb), 0 },
389 /*96*/ { "setbe", TRUE, NONE, op1(Eb), 0 },
390 /*97*/ { "setnbe",TRUE, NONE, op1(Eb), 0 },
392 /*98*/ { "sets", TRUE, NONE, op1(Eb), 0 },
393 /*99*/ { "setns", TRUE, NONE, op1(Eb), 0 },
394 /*9a*/ { "setp", TRUE, NONE, op1(Eb), 0 },
395 /*9b*/ { "setnp", TRUE, NONE, op1(Eb), 0 },
396 /*9c*/ { "setl", TRUE, NONE, op1(Eb), 0 },
397 /*9d*/ { "setnl", TRUE, NONE, op1(Eb), 0 },
398 /*9e*/ { "setle", TRUE, NONE, op1(Eb), 0 },
399 /*9f*/ { "setnle",TRUE, NONE, op1(Eb), 0 },
402 static const struct inst db_inst_0fax[] = {
403 /*a0*/ { "push", FALSE, NONE, op1(Si), 0 },
404 /*a1*/ { "pop", FALSE, NONE, op1(Si), 0 },
405 /*a2*/ { "cpuid", FALSE, NONE, 0, 0 },
406 /*a3*/ { "bt", TRUE, LONG, op2(E,R), 0 },
407 /*a4*/ { "shld", TRUE, LONG, op3(Ib,E,R), 0 },
408 /*a5*/ { "shld", TRUE, LONG, op3(CL,E,R), 0 },
409 /*a6*/ { "", FALSE, NONE, 0, 0 },
410 /*a7*/ { "", FALSE, NONE, 0, 0 },
412 /*a8*/ { "push", FALSE, NONE, op1(Si), 0 },
413 /*a9*/ { "pop", FALSE, NONE, op1(Si), 0 },
414 /*aa*/ { "", FALSE, NONE, 0, 0 },
415 /*ab*/ { "bts", TRUE, LONG, op2(E,R), 0 },
416 /*ac*/ { "shrd", TRUE, LONG, op3(Ib,E,R), 0 },
417 /*ad*/ { "shrd", TRUE, LONG, op3(CL,E,R), 0 },
418 /*a6*/ { "", FALSE, NONE, 0, 0 },
419 /*a7*/ { "imul", TRUE, LONG, op2(E,R), 0 },
422 static const struct inst db_inst_0fbx[] = {
423 /*b0*/ { "cmpxchg",TRUE, BYTE, op2(E, R), 0 },
424 /*b1*/ { "cmpxchg",TRUE, LONG, op2(E, R), 0 },
425 /*b2*/ { "lss", TRUE, LONG, op2(E, R), 0 },
426 /*b3*/ { "bts", TRUE, LONG, op2(R, E), 0 },
427 /*b4*/ { "lfs", TRUE, LONG, op2(E, R), 0 },
428 /*b5*/ { "lgs", TRUE, LONG, op2(E, R), 0 },
429 /*b6*/ { "movzb", TRUE, LONG, op2(E, R), 0 },
430 /*b7*/ { "movzw", TRUE, LONG, op2(E, R), 0 },
432 /*b8*/ { "", FALSE, NONE, 0, 0 },
433 /*b9*/ { "", FALSE, NONE, 0, 0 },
434 /*ba*/ { "", TRUE, LONG, op2(Ib, E), (const char *)db_Grp8 },
435 /*bb*/ { "btc", TRUE, LONG, op2(R, E), 0 },
436 /*bc*/ { "bsf", TRUE, LONG, op2(E, R), 0 },
437 /*bd*/ { "bsr", TRUE, LONG, op2(E, R), 0 },
438 /*be*/ { "movsb", TRUE, LONG, op2(E, R), 0 },
439 /*bf*/ { "movsw", TRUE, LONG, op2(E, R), 0 },
442 static const struct inst db_inst_0fcx[] = {
443 /*c0*/ { "xadd", TRUE, BYTE, op2(R, E), 0 },
444 /*c1*/ { "xadd", TRUE, LONG, op2(R, E), 0 },
445 /*c2*/ { "", FALSE, NONE, 0, 0 },
446 /*c3*/ { "", FALSE, NONE, 0, 0 },
447 /*c4*/ { "", FALSE, NONE, 0, 0 },
448 /*c5*/ { "", FALSE, NONE, 0, 0 },
449 /*c6*/ { "", FALSE, NONE, 0, 0 },
450 /*c7*/ { "", FALSE, NONE, 0, 0 },
451 /*c8*/ { "bswap", FALSE, LONG, op1(Ri), 0 },
452 /*c9*/ { "bswap", FALSE, LONG, op1(Ri), 0 },
453 /*ca*/ { "bswap", FALSE, LONG, op1(Ri), 0 },
454 /*cb*/ { "bswap", FALSE, LONG, op1(Ri), 0 },
455 /*cc*/ { "bswap", FALSE, LONG, op1(Ri), 0 },
456 /*cd*/ { "bswap", FALSE, LONG, op1(Ri), 0 },
457 /*ce*/ { "bswap", FALSE, LONG, op1(Ri), 0 },
458 /*cf*/ { "bswap", FALSE, LONG, op1(Ri), 0 },
461 static const struct inst db_inst_0fdx[] = {
462 /*d0*/ { "(bad)", FALSE, NONE,0, 0 },
463 /*d1*/ { "psrlw", TRUE, NONE,op2(MX,EMX), 0 },
464 /*d2*/ { "psrld", TRUE, NONE,op2(MX,EMX), 0 },
465 /*d3*/ { "psrld", TRUE, NONE,op2(MX,EMX), 0 },
466 /*d4*/ { "(bad)", FALSE, NONE,0, 0 },
467 /*d5*/ { "pmulww", TRUE, NONE,op2(MX,EMX), 0 },
468 /*d6*/ { "(bad)", FALSE, NONE,0, 0 },
469 /*d7*/ { "pmovmskb",FALSE, NONE,op2(MX,EMX),0 },
470 /*d8*/ { "psubusb", TRUE, NONE,op2(MX,EMX), 0 },
471 /*d9*/ { "psubusw", TRUE, NONE,op2(MX,EMX), 0 },
472 /*da*/ { "pminub", TRUE, NONE,op2(MX,EMX), 0 },
473 /*db*/ { "pand", TRUE, NONE,op2(MX,EMX), 0 },
474 /*dc*/ { "paddusb", TRUE, NONE,op2(MX,EMX), 0 },
475 /*dd*/ { "paddusw", TRUE, NONE,op2(MX,EMX), 0 },
476 /*de*/ { "pmaxub", TRUE, NONE,op2(MX,EMX), 0 },
477 /*df*/ { "pandn", TRUE, NONE,op2(MX,EMX), 0 },
480 static const struct inst db_inst_0fex[] = {
481 /*e0*/ { "pavgb", TRUE, NONE, op2(MX, EMX), 0 },
482 /*e1*/ { "psraw", TRUE, NONE, op2(MX, EMX), 0 },
483 /*e2*/ { "psrad", TRUE, NONE, op2(MX, EMX), 0 },
484 /*e3*/ { "pavgw", TRUE, NONE, op2(MX, EMX), 0 },
485 /*e4*/ { "pmulhuw",TRUE, NONE, op2(MX, EMX), 0 },
486 /*e5*/ { "pmulhw", TRUE, NONE, op2(MX, EMX), 0 },
487 /*e6*/ { "(bad)", FALSE,NONE, 0, 0 },
488 /*e7*/ { "movntq", TRUE, NONE, op2(MX, EMX), 0 },
489 /*e8*/ { "psubsb", TRUE, NONE, op2(MX, EMX), 0 },
490 /*e9*/ { "psubsw", TRUE, NONE, op2(MX, EMX), 0 },
491 /*ea*/ { "pminsw", TRUE, NONE, op2(MX, EMX), 0 },
492 /*eb*/ { "por", TRUE, NONE, op2(MX, EMX), 0 },
493 /*ec*/ { "paddsb", TRUE, NONE, op2(MX, EMX), 0 },
494 /*ed*/ { "paddsw", TRUE, NONE, op2(MX, EMX), 0 },
495 /*ee*/ { "pmaxsw", TRUE, NONE, op2(MX, EMX), 0 },
496 /*ef*/ { "pxor", TRUE, NONE, op2(MX, EMX), 0 },
499 static const struct inst db_inst_0ffx[] = {
500 /*f0*/ { "(bad)", FALSE,NONE, 0, 0 },
501 /*f1*/ { "psllw", TRUE, NONE, op2(MX, EMX), 0 },
502 /*f2*/ { "pslld", TRUE, NONE, op2(MX, EMX), 0 },
503 /*f3*/ { "psllq", TRUE, NONE, op2(MX, EMX), 0 },
504 /*f4*/ { "(bad)", FALSE,NONE, 0, 0 },
505 /*f5*/ { "pmaddwd",TRUE, NONE, op2(MX, EMX), 0 },
506 /*f6*/ { "psadbw", TRUE, NONE, op2(MX, EMX), 0 },
507 /*f7*/ { "maskmovq",TRUE,NONE, op2(MX, EMX), 0 },
508 /*f8*/ { "psubb", TRUE, NONE, op2(MX, EMX), 0 },
509 /*f9*/ { "psubw", TRUE, NONE, op2(MX, EMX), 0 },
510 /*fa*/ { "psubd", TRUE, NONE, op2(MX, EMX), 0 },
511 /*fb*/ { "(bad)", FALSE,NONE, 0, 0 },
512 /*fc*/ { "paddb", TRUE, NONE, op2(MX, EMX), 0 },
513 /*fd*/ { "paddw", TRUE, NONE, op2(MX, EMX), 0 },
514 /*fe*/ { "paddd", TRUE, NONE, op2(MX, EMX), 0 },
515 /*ff*/ { "(bad)", FALSE, NONE, 0, 0 },
518 static const struct inst * const db_inst_0f[] = {
519 db_inst_0f0x,
521 db_inst_0f2x,
522 db_inst_0f3x,
523 db_inst_0f4x,
524 db_inst_0f5x,
525 db_inst_0f6x,
526 db_inst_0f7x,
527 db_inst_0f8x,
528 db_inst_0f9x,
529 db_inst_0fax,
530 db_inst_0fbx,
531 db_inst_0fcx,
532 db_inst_0fdx,
533 db_inst_0fex,
534 db_inst_0ffx
537 static const char * const db_Esc92[] = {
538 "fnop", "", "", "", "", "", "", ""
540 static const char * const db_Esc93[] = {
541 "", "", "", "", "", "", "", ""
543 static const char * const db_Esc94[] = {
544 "fchs", "fabs", "", "", "ftst", "fxam", "", ""
546 static const char * const db_Esc95[] = {
547 "fld1", "fldl2t","fldl2e","fldpi","fldlg2","fldln2","fldz",""
549 static const char * const db_Esc96[] = {
550 "f2xm1","fyl2x","fptan","fpatan","fxtract","fprem1","fdecstp",
551 "fincstp"
553 static const char * const db_Esc97[] = {
554 "fprem","fyl2xp1","fsqrt","fsincos","frndint","fscale","fsin","fcos"
557 static const char * const db_Esca4[] = {
558 "", "fucompp","", "", "", "", "", ""
561 static const char * const db_Escb4[] = {
562 "", "", "fnclex","fninit","", "", "", ""
565 static const char * const db_Esce3[] = {
566 "", "fcompp","", "", "", "", "", ""
569 static const char * const db_Escf4[] = {
570 "fnstsw","", "", "", "", "", "", ""
573 static const struct finst db_Esc8[] = {
574 /*0*/ { "fadd", SNGL, op2(STI,ST), 0 },
575 /*1*/ { "fmul", SNGL, op2(STI,ST), 0 },
576 /*2*/ { "fcom", SNGL, op2(STI,ST), 0 },
577 /*3*/ { "fcomp", SNGL, op2(STI,ST), 0 },
578 /*4*/ { "fsub", SNGL, op2(STI,ST), 0 },
579 /*5*/ { "fsubr", SNGL, op2(STI,ST), 0 },
580 /*6*/ { "fdiv", SNGL, op2(STI,ST), 0 },
581 /*7*/ { "fdivr", SNGL, op2(STI,ST), 0 },
584 static const struct finst db_Esc9[] = {
585 /*0*/ { "fld", SNGL, op1(STI), 0 },
586 /*1*/ { "", NONE, op1(STI), "fxch" },
587 /*2*/ { "fst", SNGL, op1(X), (const char *)db_Esc92 },
588 /*3*/ { "fstp", SNGL, op1(X), (const char *)db_Esc93 },
589 /*4*/ { "fldenv", NONE, op1(X), (const char *)db_Esc94 },
590 /*5*/ { "fldcw", NONE, op1(X), (const char *)db_Esc95 },
591 /*6*/ { "fnstenv",NONE, op1(X), (const char *)db_Esc96 },
592 /*7*/ { "fnstcw", NONE, op1(X), (const char *)db_Esc97 },
595 static const struct finst db_Esca[] = {
596 /*0*/ { "fiadd", WORD, 0, 0 },
597 /*1*/ { "fimul", WORD, 0, 0 },
598 /*2*/ { "ficom", WORD, 0, 0 },
599 /*3*/ { "ficomp", WORD, 0, 0 },
600 /*4*/ { "fisub", WORD, op1(X), (const char *)db_Esca4 },
601 /*5*/ { "fisubr", WORD, 0, 0 },
602 /*6*/ { "fidiv", WORD, 0, 0 },
603 /*7*/ { "fidivr", WORD, 0, 0 }
606 static const struct finst db_Escb[] = {
607 /*0*/ { "fild", WORD, 0, 0 },
608 /*1*/ { "", NONE, 0, 0 },
609 /*2*/ { "fist", WORD, 0, 0 },
610 /*3*/ { "fistp", WORD, 0, 0 },
611 /*4*/ { "", WORD, op1(X), (const char *)db_Escb4 },
612 /*5*/ { "fld", EXTR, 0, 0 },
613 /*6*/ { "", WORD, 0, 0 },
614 /*7*/ { "fstp", EXTR, 0, 0 },
617 static const struct finst db_Escc[] = {
618 /*0*/ { "fadd", DBLR, op2(ST,STI), 0 },
619 /*1*/ { "fmul", DBLR, op2(ST,STI), 0 },
620 /*2*/ { "fcom", DBLR, op2(ST,STI), 0 },
621 /*3*/ { "fcomp", DBLR, op2(ST,STI), 0 },
622 /*4*/ { "fsub", DBLR, op2(ST,STI), "fsubr" },
623 /*5*/ { "fsubr", DBLR, op2(ST,STI), "fsub" },
624 /*6*/ { "fdiv", DBLR, op2(ST,STI), "fdivr" },
625 /*7*/ { "fdivr", DBLR, op2(ST,STI), "fdiv" },
628 static const struct finst db_Escd[] = {
629 /*0*/ { "fld", DBLR, op1(STI), "ffree" },
630 /*1*/ { "", NONE, 0, 0 },
631 /*2*/ { "fst", DBLR, op1(STI), 0 },
632 /*3*/ { "fstp", DBLR, op1(STI), 0 },
633 /*4*/ { "frstor", NONE, op1(STI), "fucom" },
634 /*5*/ { "", NONE, op1(STI), "fucomp" },
635 /*6*/ { "fnsave", NONE, 0, 0 },
636 /*7*/ { "fnstsw", NONE, 0, 0 },
639 static const struct finst db_Esce[] = {
640 /*0*/ { "fiadd", LONG, op2(ST,STI), "faddp" },
641 /*1*/ { "fimul", LONG, op2(ST,STI), "fmulp" },
642 /*2*/ { "ficom", LONG, 0, 0 },
643 /*3*/ { "ficomp", LONG, op1(X), (const char *)db_Esce3 },
644 /*4*/ { "fisub", LONG, op2(ST,STI), "fsubrp" },
645 /*5*/ { "fisubr", LONG, op2(ST,STI), "fsubp" },
646 /*6*/ { "fidiv", LONG, op2(ST,STI), "fdivrp" },
647 /*7*/ { "fidivr", LONG, op2(ST,STI), "fdivp" },
650 static const struct finst db_Escf[] = {
651 /*0*/ { "fild", LONG, 0, 0 },
652 /*1*/ { "", LONG, 0, 0 },
653 /*2*/ { "fist", LONG, 0, 0 },
654 /*3*/ { "fistp", LONG, 0, 0 },
655 /*4*/ { "fbld", NONE, op1(XA), (const char *)db_Escf4 },
656 /*5*/ { "fld", QUAD, 0, 0 },
657 /*6*/ { "fbstp", NONE, 0, 0 },
658 /*7*/ { "fstp", QUAD, 0, 0 },
661 static const struct finst * const db_Esc_inst[] = {
662 db_Esc8, db_Esc9, db_Esca, db_Escb,
663 db_Escc, db_Escd, db_Esce, db_Escf
666 static const char * const db_Grp1[] = {
667 "add",
668 "or",
669 "adc",
670 "sbb",
671 "and",
672 "sub",
673 "xor",
674 "cmp"
677 static const char * const db_Grp2[] = {
678 "rol",
679 "ror",
680 "rcl",
681 "rcr",
682 "shl",
683 "shr",
684 "shl",
685 "sar"
688 static const struct inst db_Grp3[] = {
689 { "test", TRUE, NONE, op2(I,E), 0 },
690 { "test", TRUE, NONE, op2(I,E), 0 },
691 { "not", TRUE, NONE, op1(E), 0 },
692 { "neg", TRUE, NONE, op1(E), 0 },
693 { "mul", TRUE, NONE, op2(E,A), 0 },
694 { "imul", TRUE, NONE, op2(E,A), 0 },
695 { "div", TRUE, NONE, op2(E,A), 0 },
696 { "idiv", TRUE, NONE, op2(E,A), 0 },
699 static const struct inst db_Grp4[] = {
700 { "inc", TRUE, BYTE, op1(E), 0 },
701 { "dec", TRUE, BYTE, op1(E), 0 },
702 { "", TRUE, NONE, 0, 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 }
710 static const struct inst db_Grp5[] = {
711 { "inc", TRUE, LONG, op1(E), 0 },
712 { "dec", TRUE, LONG, op1(E), 0 },
713 { "call", TRUE, NONE, op1(Eind),0 },
714 { "lcall", TRUE, NONE, op1(Eind),0 },
715 { "jmp", TRUE, NONE, op1(Eind),0 },
716 { "ljmp", TRUE, NONE, op1(Eind),0 },
717 { "push", TRUE, LONG, op1(E), 0 },
718 { "", TRUE, NONE, 0, 0 }
721 static const struct inst db_inst_table[256] = {
722 /*00*/ { "add", TRUE, BYTE, op2(R, E), 0 },
723 /*01*/ { "add", TRUE, LONG, op2(R, E), 0 },
724 /*02*/ { "add", TRUE, BYTE, op2(E, R), 0 },
725 /*03*/ { "add", TRUE, LONG, op2(E, R), 0 },
726 /*04*/ { "add", FALSE, BYTE, op2(Is, A), 0 },
727 /*05*/ { "add", FALSE, LONG, op2(Is, A), 0 },
728 /*06*/ { "push", FALSE, NONE, op1(Si), 0 },
729 /*07*/ { "pop", FALSE, NONE, op1(Si), 0 },
731 /*08*/ { "or", TRUE, BYTE, op2(R, E), 0 },
732 /*09*/ { "or", TRUE, LONG, op2(R, E), 0 },
733 /*0a*/ { "or", TRUE, BYTE, op2(E, R), 0 },
734 /*0b*/ { "or", TRUE, LONG, op2(E, R), 0 },
735 /*0c*/ { "or", FALSE, BYTE, op2(I, A), 0 },
736 /*0d*/ { "or", FALSE, LONG, op2(I, A), 0 },
737 /*0e*/ { "push", FALSE, NONE, op1(Si), 0 },
738 /*0f*/ { "", FALSE, NONE, 0, 0 },
740 /*10*/ { "adc", TRUE, BYTE, op2(R, E), 0 },
741 /*11*/ { "adc", TRUE, LONG, op2(R, E), 0 },
742 /*12*/ { "adc", TRUE, BYTE, op2(E, R), 0 },
743 /*13*/ { "adc", TRUE, LONG, op2(E, R), 0 },
744 /*14*/ { "adc", FALSE, BYTE, op2(Is, A), 0 },
745 /*15*/ { "adc", FALSE, LONG, op2(Is, A), 0 },
746 /*16*/ { "push", FALSE, NONE, op1(Si), 0 },
747 /*17*/ { "pop", FALSE, NONE, op1(Si), 0 },
749 /*18*/ { "sbb", TRUE, BYTE, op2(R, E), 0 },
750 /*19*/ { "sbb", TRUE, LONG, op2(R, E), 0 },
751 /*1a*/ { "sbb", TRUE, BYTE, op2(E, R), 0 },
752 /*1b*/ { "sbb", TRUE, LONG, op2(E, R), 0 },
753 /*1c*/ { "sbb", FALSE, BYTE, op2(Is, A), 0 },
754 /*1d*/ { "sbb", FALSE, LONG, op2(Is, A), 0 },
755 /*1e*/ { "push", FALSE, NONE, op1(Si), 0 },
756 /*1f*/ { "pop", FALSE, NONE, op1(Si), 0 },
758 /*20*/ { "and", TRUE, BYTE, op2(R, E), 0 },
759 /*21*/ { "and", TRUE, LONG, op2(R, E), 0 },
760 /*22*/ { "and", TRUE, BYTE, op2(E, R), 0 },
761 /*23*/ { "and", TRUE, LONG, op2(E, R), 0 },
762 /*24*/ { "and", FALSE, BYTE, op2(I, A), 0 },
763 /*25*/ { "and", FALSE, LONG, op2(I, A), 0 },
764 /*26*/ { "", FALSE, NONE, 0, 0 },
765 /*27*/ { "aaa", FALSE, NONE, 0, 0 },
767 /*28*/ { "sub", TRUE, BYTE, op2(R, E), 0 },
768 /*29*/ { "sub", TRUE, LONG, op2(R, E), 0 },
769 /*2a*/ { "sub", TRUE, BYTE, op2(E, R), 0 },
770 /*2b*/ { "sub", TRUE, LONG, op2(E, R), 0 },
771 /*2c*/ { "sub", FALSE, BYTE, op2(Is, A), 0 },
772 /*2d*/ { "sub", FALSE, LONG, op2(Is, A), 0 },
773 /*2e*/ { "", FALSE, NONE, 0, 0 },
774 /*2f*/ { "das", FALSE, NONE, 0, 0 },
776 /*30*/ { "xor", TRUE, BYTE, op2(R, E), 0 },
777 /*31*/ { "xor", TRUE, LONG, op2(R, E), 0 },
778 /*32*/ { "xor", TRUE, BYTE, op2(E, R), 0 },
779 /*33*/ { "xor", TRUE, LONG, op2(E, R), 0 },
780 /*34*/ { "xor", FALSE, BYTE, op2(I, A), 0 },
781 /*35*/ { "xor", FALSE, LONG, op2(I, A), 0 },
782 /*36*/ { "", FALSE, NONE, 0, 0 },
783 /*37*/ { "daa", FALSE, NONE, 0, 0 },
785 /*38*/ { "cmp", TRUE, BYTE, op2(R, E), 0 },
786 /*39*/ { "cmp", TRUE, LONG, op2(R, E), 0 },
787 /*3a*/ { "cmp", TRUE, BYTE, op2(E, R), 0 },
788 /*3b*/ { "cmp", TRUE, LONG, op2(E, R), 0 },
789 /*3c*/ { "cmp", FALSE, BYTE, op2(Is, A), 0 },
790 /*3d*/ { "cmp", FALSE, LONG, op2(Is, A), 0 },
791 /*3e*/ { "", FALSE, NONE, 0, 0 },
792 /*3f*/ { "aas", FALSE, NONE, 0, 0 },
794 /*40*/ { "inc", FALSE, LONG, op1(Ri), 0 },
795 /*41*/ { "inc", FALSE, LONG, op1(Ri), 0 },
796 /*42*/ { "inc", FALSE, LONG, op1(Ri), 0 },
797 /*43*/ { "inc", FALSE, LONG, op1(Ri), 0 },
798 /*44*/ { "inc", FALSE, LONG, op1(Ri), 0 },
799 /*45*/ { "inc", FALSE, LONG, op1(Ri), 0 },
800 /*46*/ { "inc", FALSE, LONG, op1(Ri), 0 },
801 /*47*/ { "inc", FALSE, LONG, op1(Ri), 0 },
803 /*48*/ { "dec", FALSE, LONG, op1(Ri), 0 },
804 /*49*/ { "dec", FALSE, LONG, op1(Ri), 0 },
805 /*4a*/ { "dec", FALSE, LONG, op1(Ri), 0 },
806 /*4b*/ { "dec", FALSE, LONG, op1(Ri), 0 },
807 /*4c*/ { "dec", FALSE, LONG, op1(Ri), 0 },
808 /*4d*/ { "dec", FALSE, LONG, op1(Ri), 0 },
809 /*4e*/ { "dec", FALSE, LONG, op1(Ri), 0 },
810 /*4f*/ { "dec", FALSE, LONG, op1(Ri), 0 },
812 /*50*/ { "push", FALSE, LONG, op1(Ri), 0 },
813 /*51*/ { "push", FALSE, LONG, op1(Ri), 0 },
814 /*52*/ { "push", FALSE, LONG, op1(Ri), 0 },
815 /*53*/ { "push", FALSE, LONG, op1(Ri), 0 },
816 /*54*/ { "push", FALSE, LONG, op1(Ri), 0 },
817 /*55*/ { "push", FALSE, LONG, op1(Ri), 0 },
818 /*56*/ { "push", FALSE, LONG, op1(Ri), 0 },
819 /*57*/ { "push", FALSE, LONG, op1(Ri), 0 },
821 /*58*/ { "pop", FALSE, LONG, op1(Ri), 0 },
822 /*59*/ { "pop", FALSE, LONG, op1(Ri), 0 },
823 /*5a*/ { "pop", FALSE, LONG, op1(Ri), 0 },
824 /*5b*/ { "pop", FALSE, LONG, op1(Ri), 0 },
825 /*5c*/ { "pop", FALSE, LONG, op1(Ri), 0 },
826 /*5d*/ { "pop", FALSE, LONG, op1(Ri), 0 },
827 /*5e*/ { "pop", FALSE, LONG, op1(Ri), 0 },
828 /*5f*/ { "pop", FALSE, LONG, op1(Ri), 0 },
830 /*60*/ { "pusha", FALSE, LONG, 0, 0 },
831 /*61*/ { "popa", FALSE, LONG, 0, 0 },
832 /*62*/ { "bound", TRUE, LONG, op2(E, R), 0 },
833 /*63*/ { "arpl", TRUE, NONE, op2(Ew,Rw), 0 },
835 /*64*/ { "", FALSE, NONE, 0, 0 },
836 /*65*/ { "", FALSE, NONE, 0, 0 },
837 /*66*/ { "", FALSE, NONE, 0, 0 },
838 /*67*/ { "", FALSE, NONE, 0, 0 },
840 /*68*/ { "push", FALSE, LONG, op1(I), 0 },
841 /*69*/ { "imul", TRUE, LONG, op3(I,E,R), 0 },
842 /*6a*/ { "push", FALSE, LONG, op1(Ib), 0 },
843 /*6b*/ { "imul", TRUE, LONG, op3(Ibs,E,R),0 },
844 /*6c*/ { "ins", FALSE, BYTE, op2(DX, DI), 0 },
845 /*6d*/ { "ins", FALSE, LONG, op2(DX, DI), 0 },
846 /*6e*/ { "outs", FALSE, BYTE, op2(SI, DX), 0 },
847 /*6f*/ { "outs", FALSE, LONG, op2(SI, DX), 0 },
849 /*70*/ { "jo", FALSE, NONE, op1(Db), 0 },
850 /*71*/ { "jno", FALSE, NONE, op1(Db), 0 },
851 /*72*/ { "jb", FALSE, NONE, op1(Db), 0 },
852 /*73*/ { "jnb", FALSE, NONE, op1(Db), 0 },
853 /*74*/ { "jz", FALSE, NONE, op1(Db), 0 },
854 /*75*/ { "jnz", FALSE, NONE, op1(Db), 0 },
855 /*76*/ { "jbe", FALSE, NONE, op1(Db), 0 },
856 /*77*/ { "jnbe", FALSE, NONE, op1(Db), 0 },
858 /*78*/ { "js", FALSE, NONE, op1(Db), 0 },
859 /*79*/ { "jns", FALSE, NONE, op1(Db), 0 },
860 /*7a*/ { "jp", FALSE, NONE, op1(Db), 0 },
861 /*7b*/ { "jnp", FALSE, NONE, op1(Db), 0 },
862 /*7c*/ { "jl", FALSE, NONE, op1(Db), 0 },
863 /*7d*/ { "jnl", FALSE, NONE, op1(Db), 0 },
864 /*7e*/ { "jle", FALSE, NONE, op1(Db), 0 },
865 /*7f*/ { "jnle", FALSE, NONE, op1(Db), 0 },
867 /*80*/ { "", TRUE, BYTE, op2(I, E), (const char *)db_Grp1 },
868 /*81*/ { "", TRUE, LONG, op2(I, E), (const char *)db_Grp1 },
869 /*82*/ { "", TRUE, BYTE, op2(Is,E), (const char *)db_Grp1 },
870 /*83*/ { "", TRUE, LONG, op2(Ibs,E), (const char *)db_Grp1 },
871 /*84*/ { "test", TRUE, BYTE, op2(R, E), 0 },
872 /*85*/ { "test", TRUE, LONG, op2(R, E), 0 },
873 /*86*/ { "xchg", TRUE, BYTE, op2(R, E), 0 },
874 /*87*/ { "xchg", TRUE, LONG, op2(R, E), 0 },
876 /*88*/ { "mov", TRUE, BYTE, op2(R, E), 0 },
877 /*89*/ { "mov", TRUE, LONG, op2(R, E), 0 },
878 /*8a*/ { "mov", TRUE, BYTE, op2(E, R), 0 },
879 /*8b*/ { "mov", TRUE, LONG, op2(E, R), 0 },
880 /*8c*/ { "mov", TRUE, NONE, op2(S, Ew), 0 },
881 /*8d*/ { "lea", TRUE, LONG, op2(E, R), 0 },
882 /*8e*/ { "mov", TRUE, NONE, op2(Ew, S), 0 },
883 /*8f*/ { "pop", TRUE, LONG, op1(E), 0 },
885 /*90*/ { "nop", FALSE, NONE, 0, 0 },
886 /*91*/ { "xchg", FALSE, LONG, op2(A, Ri), 0 },
887 /*92*/ { "xchg", FALSE, LONG, op2(A, Ri), 0 },
888 /*93*/ { "xchg", FALSE, LONG, op2(A, Ri), 0 },
889 /*94*/ { "xchg", FALSE, LONG, op2(A, Ri), 0 },
890 /*95*/ { "xchg", FALSE, LONG, op2(A, Ri), 0 },
891 /*96*/ { "xchg", FALSE, LONG, op2(A, Ri), 0 },
892 /*97*/ { "xchg", FALSE, LONG, op2(A, Ri), 0 },
894 /*98*/ { "cbw", FALSE, SDEP, 0, "cwde" }, /* cbw/cwde */
895 /*99*/ { "cwd", FALSE, SDEP, 0, "cdq" }, /* cwd/cdq */
896 /*9a*/ { "lcall", FALSE, NONE, op1(OS), 0 },
897 /*9b*/ { "wait", FALSE, NONE, 0, 0 },
898 /*9c*/ { "pushf", FALSE, LONG, 0, 0 },
899 /*9d*/ { "popf", FALSE, LONG, 0, 0 },
900 /*9e*/ { "sahf", FALSE, NONE, 0, 0 },
901 /*9f*/ { "lahf", FALSE, NONE, 0, 0 },
903 /*a0*/ { "mov", FALSE, BYTE, op2(O, A), 0 },
904 /*a1*/ { "mov", FALSE, LONG, op2(O, A), 0 },
905 /*a2*/ { "mov", FALSE, BYTE, op2(A, O), 0 },
906 /*a3*/ { "mov", FALSE, LONG, op2(A, O), 0 },
907 /*a4*/ { "movs", FALSE, BYTE, op2(SI,DI), 0 },
908 /*a5*/ { "movs", FALSE, LONG, op2(SI,DI), 0 },
909 /*a6*/ { "cmps", FALSE, BYTE, op2(SI,DI), 0 },
910 /*a7*/ { "cmps", FALSE, LONG, op2(SI,DI), 0 },
912 /*a8*/ { "test", FALSE, BYTE, op2(I, A), 0 },
913 /*a9*/ { "test", FALSE, LONG, op2(I, A), 0 },
914 /*aa*/ { "stos", FALSE, BYTE, op1(DI), 0 },
915 /*ab*/ { "stos", FALSE, LONG, op1(DI), 0 },
916 /*ac*/ { "lods", FALSE, BYTE, op1(SI), 0 },
917 /*ad*/ { "lods", FALSE, LONG, op1(SI), 0 },
918 /*ae*/ { "scas", FALSE, BYTE, op1(DI), 0 },
919 /*af*/ { "scas", FALSE, LONG, op1(DI), 0 },
921 /*b0*/ { "mov", FALSE, BYTE, op2(I, Ri), 0 },
922 /*b1*/ { "mov", FALSE, BYTE, op2(I, Ri), 0 },
923 /*b2*/ { "mov", FALSE, BYTE, op2(I, Ri), 0 },
924 /*b3*/ { "mov", FALSE, BYTE, op2(I, Ri), 0 },
925 /*b4*/ { "mov", FALSE, BYTE, op2(I, Ri), 0 },
926 /*b5*/ { "mov", FALSE, BYTE, op2(I, Ri), 0 },
927 /*b6*/ { "mov", FALSE, BYTE, op2(I, Ri), 0 },
928 /*b7*/ { "mov", FALSE, BYTE, op2(I, Ri), 0 },
930 /*b8*/ { "mov", FALSE, LONG, op2(I, Ri), 0 },
931 /*b9*/ { "mov", FALSE, LONG, op2(I, Ri), 0 },
932 /*ba*/ { "mov", FALSE, LONG, op2(I, Ri), 0 },
933 /*bb*/ { "mov", FALSE, LONG, op2(I, Ri), 0 },
934 /*bc*/ { "mov", FALSE, LONG, op2(I, Ri), 0 },
935 /*bd*/ { "mov", FALSE, LONG, op2(I, Ri), 0 },
936 /*be*/ { "mov", FALSE, LONG, op2(I, Ri), 0 },
937 /*bf*/ { "mov", FALSE, LONG, op2(I, Ri), 0 },
939 /*c0*/ { "", TRUE, BYTE, op2(Ib, E), (const char *)db_Grp2 },
940 /*c1*/ { "", TRUE, LONG, op2(Ib, E), (const char *)db_Grp2 },
941 /*c2*/ { "ret", FALSE, NONE, op1(Iw), 0 },
942 /*c3*/ { "ret", FALSE, NONE, 0, 0 },
943 /*c4*/ { "les", TRUE, LONG, op2(E, R), 0 },
944 /*c5*/ { "lds", TRUE, LONG, op2(E, R), 0 },
945 /*c6*/ { "mov", TRUE, BYTE, op2(I, E), 0 },
946 /*c7*/ { "mov", TRUE, LONG, op2(I, E), 0 },
948 /*c8*/ { "enter", FALSE, NONE, op2(Iw, Ib), 0 },
949 /*c9*/ { "leave", FALSE, NONE, 0, 0 },
950 /*ca*/ { "lret", FALSE, NONE, op1(Iw), 0 },
951 /*cb*/ { "lret", FALSE, NONE, 0, 0 },
952 /*cc*/ { "int", FALSE, NONE, op1(o3), 0 },
953 /*cd*/ { "int", FALSE, NONE, op1(Ib), 0 },
954 /*ce*/ { "into", FALSE, NONE, 0, 0 },
955 /*cf*/ { "iret", FALSE, NONE, 0, 0 },
957 /*d0*/ { "", TRUE, BYTE, op2(o1, E), (const char *)db_Grp2 },
958 /*d1*/ { "", TRUE, LONG, op2(o1, E), (const char *)db_Grp2 },
959 /*d2*/ { "", TRUE, BYTE, op2(CL, E), (const char *)db_Grp2 },
960 /*d3*/ { "", TRUE, LONG, op2(CL, E), (const char *)db_Grp2 },
961 /*d4*/ { "aam", TRUE, NONE, 0, 0 },
962 /*d5*/ { "aad", TRUE, NONE, 0, 0 },
963 /*d6*/ { "", FALSE, NONE, 0, 0 },
964 /*d7*/ { "xlat", FALSE, BYTE, op1(BX), 0 },
966 /*d8*/ { "", TRUE, NONE, 0, (const char *)db_Esc8 },
967 /*d9*/ { "", TRUE, NONE, 0, (const char *)db_Esc9 },
968 /*da*/ { "", TRUE, NONE, 0, (const char *)db_Esca },
969 /*db*/ { "", TRUE, NONE, 0, (const char *)db_Escb },
970 /*dc*/ { "", TRUE, NONE, 0, (const char *)db_Escc },
971 /*dd*/ { "", TRUE, NONE, 0, (const char *)db_Escd },
972 /*de*/ { "", TRUE, NONE, 0, (const char *)db_Esce },
973 /*df*/ { "", TRUE, NONE, 0, (const char *)db_Escf },
975 /*e0*/ { "loopne",FALSE, NONE, op1(Db), 0 },
976 /*e1*/ { "loope", FALSE, NONE, op1(Db), 0 },
977 /*e2*/ { "loop", FALSE, NONE, op1(Db), 0 },
978 /*e3*/ { "jcxz", FALSE, SDEP, op1(Db), "jecxz" },
979 /*e4*/ { "in", FALSE, BYTE, op2(Ib, A), 0 },
980 /*e5*/ { "in", FALSE, LONG, op2(Ib, A) , 0 },
981 /*e6*/ { "out", FALSE, BYTE, op2(A, Ib), 0 },
982 /*e7*/ { "out", FALSE, LONG, op2(A, Ib) , 0 },
984 /*e8*/ { "call", FALSE, NONE, op1(Dl), 0 },
985 /*e9*/ { "jmp", FALSE, NONE, op1(Dl), 0 },
986 /*ea*/ { "ljmp", FALSE, NONE, op1(OS), 0 },
987 /*eb*/ { "jmp", FALSE, NONE, op1(Db), 0 },
988 /*ec*/ { "in", FALSE, BYTE, op2(DX, A), 0 },
989 /*ed*/ { "in", FALSE, LONG, op2(DX, A) , 0 },
990 /*ee*/ { "out", FALSE, BYTE, op2(A, DX), 0 },
991 /*ef*/ { "out", FALSE, LONG, op2(A, DX) , 0 },
993 /*f0*/ { "", FALSE, NONE, 0, 0 },
994 /*f1*/ { "", FALSE, NONE, 0, 0 },
995 /*f2*/ { "", FALSE, NONE, 0, 0 },
996 /*f3*/ { "", FALSE, NONE, 0, 0 },
997 /*f4*/ { "hlt", FALSE, NONE, 0, 0 },
998 /*f5*/ { "cmc", FALSE, NONE, 0, 0 },
999 /*f6*/ { "", TRUE, BYTE, 0, (const char *)db_Grp3 },
1000 /*f7*/ { "", TRUE, LONG, 0, (const char *)db_Grp3 },
1002 /*f8*/ { "clc", FALSE, NONE, 0, 0 },
1003 /*f9*/ { "stc", FALSE, NONE, 0, 0 },
1004 /*fa*/ { "cli", FALSE, NONE, 0, 0 },
1005 /*fb*/ { "sti", FALSE, NONE, 0, 0 },
1006 /*fc*/ { "cld", FALSE, NONE, 0, 0 },
1007 /*fd*/ { "std", FALSE, NONE, 0, 0 },
1008 /*fe*/ { "", TRUE, NONE, 0, (const char *)db_Grp4 },
1009 /*ff*/ { "", TRUE, NONE, 0, (const char *)db_Grp5 },
1012 static const struct inst db_bad_inst =
1013 { "???", FALSE, NONE, 0, 0 }
1016 #define f_mod(byte) ((byte)>>6)
1017 #define f_reg(byte) (((byte)>>3)&0x7)
1018 #define f_rm(byte) ((byte)&0x7)
1020 #define sib_ss(byte) ((byte)>>6)
1021 #define sib_index(byte) (((byte)>>3)&0x7)
1022 #define sib_base(byte) ((byte)&0x7)
1024 struct i_addr {
1025 int is_reg; /* if reg, reg number is in 'disp' */
1026 int disp;
1027 const char * base;
1028 const char * index;
1029 int ss;
1032 static const char * const db_index_reg_16[8] = {
1033 "%bx,%si",
1034 "%bx,%di",
1035 "%bp,%si",
1036 "%bp,%di",
1037 "%si",
1038 "%di",
1039 "%bp",
1040 "%bx"
1043 static const char * const db_reg[3][8] = {
1044 { "%al", "%cl", "%dl", "%bl", "%ah", "%ch", "%dh", "%bh" },
1045 { "%ax", "%cx", "%dx", "%bx", "%sp", "%bp", "%si", "%di" },
1046 { "%eax", "%ecx", "%edx", "%ebx", "%esp", "%ebp", "%esi", "%edi" }
1049 static const char * const db_seg_reg[8] = {
1050 "%es", "%cs", "%ss", "%ds", "%fs", "%gs", "", ""
1054 * lengths for size attributes
1056 static const int db_lengths[] = {
1057 1, /* BYTE */
1058 2, /* WORD */
1059 4, /* LONG */
1060 8, /* QUAD */
1061 4, /* SNGL */
1062 8, /* DBLR */
1063 10, /* EXTR */
1066 static unsigned int db_get_task_value( const ADDRESS64* addr,
1067 int size, int is_signed )
1069 unsigned int result = 0;
1070 char buffer[4];
1072 if (size != 1 && size != 2 && size != 4)
1074 dbg_printf("Illegal size specified\n");
1076 else
1078 dbg_read_memory(memory_to_linear_addr(addr), buffer, size);
1080 switch (size)
1082 case 4:
1083 if (is_signed) result = (unsigned int) *(int *)buffer;
1084 else result = *(unsigned int *)buffer;
1085 break;
1086 case 2:
1087 if (is_signed) result = (unsigned int) *(short int *)buffer;
1088 else result = *(unsigned short int *)buffer;
1089 break;
1090 case 1:
1091 if (is_signed) result = (unsigned int) *(char *)buffer;
1092 else result = *(unsigned char *)buffer;
1093 break;
1096 return result;
1099 #define get_value_inc(result, addr, size, is_signed) \
1100 result = db_get_task_value((addr), (size), (is_signed)); \
1101 if (!db_disasm_16) (addr)->Offset += (size); \
1102 else (addr)->Offset = ((addr)->Offset + (size)) & 0xffff;
1105 * Read address at location and return updated location.
1107 static void db_read_address( ADDRESS64* addr, int short_addr, int regmodrm,
1108 struct i_addr *addrp )
1110 int mod, rm, sib, index, disp;
1112 mod = f_mod(regmodrm);
1113 rm = f_rm(regmodrm);
1115 if (mod == 3) {
1116 addrp->is_reg = TRUE;
1117 addrp->disp = rm;
1118 return;
1120 addrp->is_reg = FALSE;
1121 addrp->index = 0;
1123 if (short_addr) {
1124 addrp->index = 0;
1125 addrp->ss = 0;
1126 switch (mod) {
1127 case 0:
1128 if (rm == 6) {
1129 get_value_inc(disp, addr, 2, TRUE);
1130 addrp->disp = disp;
1131 addrp->base = 0;
1133 else {
1134 addrp->disp = 0;
1135 addrp->base = db_index_reg_16[rm];
1137 break;
1138 case 1:
1139 get_value_inc(disp, addr, 1, TRUE);
1140 addrp->disp = disp;
1141 addrp->base = db_index_reg_16[rm];
1142 break;
1143 case 2:
1144 get_value_inc(disp, addr, 2, TRUE);
1145 addrp->disp = disp;
1146 addrp->base = db_index_reg_16[rm];
1147 break;
1150 else {
1151 if (mod != 3 && rm == 4) {
1152 get_value_inc(sib, addr, 1, FALSE);
1153 rm = sib_base(sib);
1154 index = sib_index(sib);
1155 if (index != 4)
1156 addrp->index = db_reg[LONG][index];
1157 addrp->ss = sib_ss(sib);
1160 switch (mod) {
1161 case 0:
1162 if (rm == 5) {
1163 get_value_inc(addrp->disp, addr, 4, FALSE);
1164 addrp->base = 0;
1166 else {
1167 addrp->disp = 0;
1168 addrp->base = db_reg[LONG][rm];
1170 break;
1172 case 1:
1173 get_value_inc(disp, addr, 1, TRUE);
1174 addrp->disp = disp;
1175 addrp->base = db_reg[LONG][rm];
1176 break;
1178 case 2:
1179 get_value_inc(disp, addr, 4, FALSE);
1180 addrp->disp = disp;
1181 addrp->base = db_reg[LONG][rm];
1182 break;
1187 static void db_task_printsym(unsigned int addr, int size)
1189 ADDRESS64 a;
1190 a.Mode = AddrModeFlat;
1191 a.Offset = addr;
1193 print_address(&a, TRUE);
1196 static void db_print_address(const char *seg, int size, struct i_addr *addrp, int byref)
1198 if (addrp->is_reg) {
1199 dbg_printf("%s", db_reg[size][addrp->disp]);
1200 return;
1203 if (seg) {
1204 dbg_printf("%s:", seg);
1207 if (addrp->base != 0 || addrp->index != 0) {
1208 dbg_printf("0x%x(", addrp->disp);
1209 if (addrp->base)
1210 dbg_printf("%s", addrp->base);
1211 if (addrp->index)
1212 dbg_printf(",%s,%d", addrp->index, 1<<addrp->ss);
1213 dbg_printf(")");
1215 else {
1217 /* try to get destination of indirect call
1218 does not work for segmented addresses */
1219 if (!seg && byref) {
1220 void* a1;
1221 void* a2;
1223 dbg_printf("0x%x -> ", addrp->disp);
1224 if (!dbg_read_memory((void*)addrp->disp, &a1, sizeof(a1))) {
1225 dbg_printf("(invalid source)");
1226 } else if (!dbg_read_memory(a1, &a2, sizeof(a2))) {
1227 dbg_printf("(invalid destination)");
1228 } else {
1229 db_task_printsym((unsigned long)a1, 0);
1232 else
1233 db_task_printsym(addrp->disp, size);
1238 * Disassemble floating-point ("escape") instruction
1239 * and return updated location.
1241 static void db_disasm_esc( ADDRESS64* addr, int inst, int short_addr,
1242 int size, const char *seg )
1244 int regmodrm;
1245 const struct finst *fp;
1246 int mod;
1247 struct i_addr address;
1248 const char * name;
1250 get_value_inc(regmodrm, addr, 1, FALSE);
1251 if( !db_display )
1253 return;
1256 fp = &db_Esc_inst[inst - 0xd8][f_reg(regmodrm)];
1257 mod = f_mod(regmodrm);
1258 if (mod != 3) {
1259 const char* p;
1261 * Normal address modes.
1263 db_read_address( addr, short_addr, regmodrm, &address);
1264 dbg_printf("%s", fp->f_name);
1265 switch(fp->f_size) {
1266 case SNGL: p = "s"; break;
1267 case DBLR: p = "l"; break;
1268 case EXTR: p = "t"; break;
1269 case WORD: p = "s"; break;
1270 case LONG: p = "l"; break;
1271 case QUAD: p = "q"; break;
1272 default: p = ""; break;
1274 dbg_printf("%s\t", p);
1275 db_print_address(seg, BYTE, &address, 0);
1277 else {
1279 * 'reg-reg' - special formats
1281 switch (fp->f_rrmode) {
1282 case op2(ST,STI):
1283 name = (fp->f_rrname) ? fp->f_rrname : fp->f_name;
1284 dbg_printf("%s\t%%st,%%st(%d)",name,f_rm(regmodrm));
1285 break;
1286 case op2(STI,ST):
1287 name = (fp->f_rrname) ? fp->f_rrname : fp->f_name;
1288 dbg_printf("%s\t%%st(%d),%%st",name, f_rm(regmodrm));
1289 break;
1290 case op1(STI):
1291 name = (fp->f_rrname) ? fp->f_rrname : fp->f_name;
1292 dbg_printf("%s\t%%st(%d)",name, f_rm(regmodrm));
1293 break;
1294 case op1(X):
1295 dbg_printf("%s", ((char * const*)fp->f_rrname)[f_rm(regmodrm)]);
1296 break;
1297 case op1(XA):
1298 dbg_printf("%s\t%%ax", ((char * const*)fp->f_rrname)[f_rm(regmodrm)]);
1299 break;
1300 default:
1301 dbg_printf("<bad instruction>");
1302 break;
1308 /***********************************************************************
1309 * disasm_one_insn
1311 * Disassemble instruction at 'addr'. addr is changed to point to the
1312 * start of the next instruction.
1314 void be_i386_disasm_one_insn(ADDRESS64 *addr, int display)
1316 int inst;
1317 int size;
1318 int short_addr;
1319 const char *seg;
1320 const struct inst *ip;
1321 const char *i_name;
1322 int i_size;
1323 int i_mode;
1324 int regmodrm = 0;
1325 BOOL first;
1326 int displ;
1327 int prefix;
1328 int imm;
1329 int len;
1330 struct i_addr address;
1333 * Set this so we get can suppress the printout if we need to.
1335 db_display = display;
1336 switch (addr->Mode)
1338 case AddrModeReal:
1339 case AddrMode1616: db_disasm_16 = 1; break;
1340 default: db_disasm_16 = 0; break;
1343 get_value_inc( inst, addr, 1, FALSE );
1345 if (db_disasm_16) {
1346 short_addr = TRUE;
1347 size = WORD;
1349 else {
1350 short_addr = FALSE;
1351 size = LONG;
1353 seg = 0;
1356 * Get prefixes
1358 prefix = TRUE;
1359 do {
1360 switch (inst) {
1361 case 0x66: /* data16 */
1362 if (size == LONG)
1363 size = WORD;
1364 else
1365 size = LONG;
1366 break;
1367 case 0x67:
1368 short_addr = !short_addr;
1369 break;
1370 case 0x26:
1371 seg = "%es";
1372 break;
1373 case 0x36:
1374 seg = "%ss";
1375 break;
1376 case 0x2e:
1377 seg = "%cs";
1378 break;
1379 case 0x3e:
1380 seg = "%ds";
1381 break;
1382 case 0x64:
1383 seg = "%fs";
1384 break;
1385 case 0x65:
1386 seg = "%gs";
1387 break;
1388 case 0xf0:
1389 if( db_display )
1390 dbg_printf("lock ");
1391 break;
1392 case 0xf2:
1393 if( db_display )
1394 dbg_printf("repne ");
1395 break;
1396 case 0xf3:
1397 if( db_display )
1398 dbg_printf("repe "); /* XXX repe VS rep */
1399 break;
1400 default:
1401 prefix = FALSE;
1402 break;
1404 if (prefix) {
1405 get_value_inc(inst, addr, 1, FALSE);
1407 } while (prefix);
1409 if (inst >= 0xd8 && inst <= 0xdf)
1411 db_disasm_esc( addr, inst, short_addr, size, seg);
1412 return;
1415 if (inst == 0x0f) {
1416 get_value_inc(inst, addr, 1, FALSE);
1417 ip = db_inst_0f[inst>>4];
1418 if (ip == 0) {
1419 ip = &db_bad_inst;
1421 else {
1422 ip = &ip[inst&0xf];
1425 else
1426 ip = &db_inst_table[inst];
1428 if (ip->i_has_modrm) {
1429 get_value_inc(regmodrm, addr, 1, FALSE);
1430 db_read_address( addr, short_addr, regmodrm, &address);
1433 i_name = ip->i_name;
1434 i_size = ip->i_size;
1435 i_mode = ip->i_mode;
1437 if (ip->i_extra == (const char *)db_Grp1 ||
1438 ip->i_extra == (const char *)db_Grp2 ||
1439 ip->i_extra == (const char *)db_Grp6 ||
1440 ip->i_extra == (const char *)db_Grp7 ||
1441 ip->i_extra == (const char *)db_Grp8 ||
1442 ip->i_extra == (const char *)db_Grp10 ||
1443 ip->i_extra == (const char *)db_Grp11 ||
1444 ip->i_extra == (const char *)db_Grp12) {
1445 i_name = ((const char * const*)ip->i_extra)[f_reg(regmodrm)];
1447 else if (ip->i_extra == (const char *)db_Grp3) {
1448 ip = (const struct inst *)ip->i_extra;
1449 ip = &ip[f_reg(regmodrm)];
1450 i_name = ip->i_name;
1451 i_mode = ip->i_mode;
1453 else if (ip->i_extra == (const char *)db_Grp4 ||
1454 ip->i_extra == (const char *)db_Grp5) {
1455 ip = (const struct inst *)ip->i_extra;
1456 ip = &ip[f_reg(regmodrm)];
1457 i_name = ip->i_name;
1458 i_mode = ip->i_mode;
1459 i_size = ip->i_size;
1462 if (i_size == SDEP) {
1463 if( db_display )
1465 if (size == WORD)
1466 dbg_printf("%s", i_name);
1467 else
1468 dbg_printf("%s", ip->i_extra);
1471 else {
1472 if( db_display )
1474 dbg_printf("%s", i_name);
1476 if (i_size != NONE) {
1477 if (i_size == BYTE) {
1478 if( db_display )
1480 dbg_printf("b");
1482 size = BYTE;
1484 else if (i_size == WORD) {
1485 if( db_display )
1487 dbg_printf("w");
1489 size = WORD;
1491 else if (size == WORD)
1493 if( db_display )
1495 dbg_printf("w");
1498 else
1500 if( db_display )
1502 dbg_printf("l");
1507 if( db_display )
1509 dbg_printf("\t");
1511 for (first = TRUE;
1512 i_mode != 0;
1513 i_mode >>= 8, first = FALSE)
1515 if (!first && db_display)
1516 dbg_printf(",");
1518 switch (i_mode & 0xFF) {
1520 case E:
1521 if( db_display )
1523 db_print_address(seg, size, &address, 0);
1525 break;
1527 case Eind:
1528 if( db_display )
1530 dbg_printf("*");
1531 db_print_address(seg, size, &address, 1);
1533 break;
1535 case Ew:
1536 if( db_display )
1538 db_print_address(seg, WORD, &address, 0);
1540 break;
1542 case Eb:
1543 if( db_display )
1545 db_print_address(seg, BYTE, &address, 0);
1547 break;
1549 case R:
1550 if( db_display )
1552 dbg_printf("%s", db_reg[size][f_reg(regmodrm)]);
1554 break;
1555 case MX:
1556 if( db_display )
1558 dbg_printf("%%mm%d", f_reg(regmodrm));
1560 break;
1561 case EMX:
1562 if( db_display )
1564 dbg_printf("%%mm%d", f_rm(regmodrm));
1566 break;
1567 case XMM:
1568 if( db_display )
1570 dbg_printf("%%xmm%d", f_reg(regmodrm));
1572 break;
1573 case EXMM:
1574 if( db_display )
1576 dbg_printf("%%xmm%d", f_rm(regmodrm));
1578 break;
1581 case Rw:
1582 if( db_display )
1584 dbg_printf("%s", db_reg[WORD][f_reg(regmodrm)]);
1586 break;
1588 case Ri:
1589 if( db_display )
1591 dbg_printf("%s", db_reg[size][f_rm(inst)]);
1593 break;
1595 case S:
1596 if( db_display )
1598 dbg_printf("%s", db_seg_reg[f_reg(regmodrm)]);
1600 break;
1602 case Si:
1603 if( db_display )
1605 dbg_printf("%s", db_seg_reg[f_reg(inst)]);
1607 break;
1609 case A:
1610 if( db_display )
1612 dbg_printf("%s", db_reg[size][0]); /* acc */
1614 break;
1616 case BX:
1617 if( db_display )
1619 if (seg)
1620 dbg_printf("%s:", seg);
1621 dbg_printf("(%s)", short_addr ? "%bx" : "%ebx");
1623 break;
1625 case CL:
1626 if( db_display )
1628 dbg_printf("%%cl");
1630 break;
1632 case DX:
1633 if( db_display )
1635 dbg_printf("%%dx");
1637 break;
1639 case SI:
1640 if( db_display )
1642 if (seg)
1643 dbg_printf("%s:", seg);
1644 dbg_printf("(%s)", short_addr ? "%si" : "%esi");
1646 break;
1648 case DI:
1649 if( db_display )
1651 dbg_printf("%%es:(%s)", short_addr ? "%di" : "%edi");
1653 break;
1655 case CR:
1656 if( db_display )
1658 dbg_printf("%%cr%d", f_reg(regmodrm));
1660 break;
1662 case DR:
1663 if( db_display )
1665 dbg_printf("%%dr%d", f_reg(regmodrm));
1667 break;
1669 case TR:
1670 if( db_display )
1672 dbg_printf("%%tr%d", f_reg(regmodrm));
1674 break;
1676 case I:
1677 len = db_lengths[size];
1678 get_value_inc(imm, addr, len, FALSE);/* unsigned */
1679 if( db_display )
1681 dbg_printf("$0x%x", imm);
1683 break;
1685 case Is:
1686 len = db_lengths[size];
1687 get_value_inc(imm, addr, len, TRUE); /* signed */
1688 if( db_display )
1690 dbg_printf("$%d", imm);
1692 break;
1694 case Ib:
1695 get_value_inc(imm, addr, 1, FALSE); /* unsigned */
1696 if( db_display )
1698 dbg_printf("$0x%x", imm);
1700 break;
1702 case Ibs:
1703 get_value_inc(imm, addr, 1, TRUE); /* signed */
1704 if( db_display )
1706 dbg_printf("$%d", imm);
1708 break;
1710 case Iw:
1711 get_value_inc(imm, addr, 2, FALSE); /* unsigned */
1712 if( db_display )
1714 dbg_printf("$0x%x", imm);
1716 break;
1718 case Il:
1719 get_value_inc(imm, addr, 4, FALSE);
1720 if( db_display )
1722 dbg_printf("$0x%x", imm);
1724 break;
1726 case O:
1727 if (short_addr) {
1728 get_value_inc(displ, addr, 2, TRUE);
1730 else {
1731 get_value_inc(displ, addr, 4, TRUE);
1733 if( !db_display )
1735 break;
1738 if (seg)
1739 dbg_printf("%s:0x%x",seg, displ);
1740 else
1741 db_task_printsym(displ, short_addr ? WORD : LONG);
1742 break;
1744 case Db:
1745 get_value_inc(displ, addr, 1, TRUE);
1746 if( !db_display )
1748 break;
1751 if (size == WORD) {
1752 /* offset only affects low 16 bits */
1753 displ = (addr->Offset & 0xffff0000)
1754 | ((addr->Offset + displ) & 0xffff);
1756 else displ += addr->Offset;
1757 db_task_printsym(displ, size);
1758 break;
1760 case Dl:
1761 if (size == WORD) {
1762 get_value_inc(displ, addr, 2, TRUE);
1763 /* Offset only affects low 16 bits */
1764 displ = (addr->Offset & 0xffff0000)
1765 | ((addr->Offset + displ) & 0xffff);
1767 else {
1768 get_value_inc(displ, addr, 4, TRUE);
1769 displ += addr->Offset;
1771 if( !db_display )
1773 break;
1775 db_task_printsym( displ, size );
1776 break;
1778 case o1:
1779 if( db_display )
1781 dbg_printf("$1");
1783 break;
1785 case o3:
1786 if( db_display )
1788 dbg_printf("$3");
1790 break;
1792 case OS:
1794 ADDRESS64 address;
1795 get_value_inc( address.Offset, addr, /* offset */
1796 short_addr ? 2 : 4, FALSE );
1797 get_value_inc( address.Segment, addr, /* segment */
1798 2, FALSE );
1799 be_cpu->build_addr(dbg_curr_thread->handle, &dbg_context,
1800 &address, address.Segment, address.Offset);
1801 if( db_display )
1803 print_address( &address, TRUE );
1807 break;
1811 #endif /* __i386__ */