2 * Mach Operating System
3 * Copyright (c) 1991,1990 Carnegie Mellon University
6 * Permission to use, copy, modify and distribute this software and its
7 * documentation is hereby granted, provided that both the copyright
8 * notice and this permission notice appear in all copies of the
9 * software, derivative works or modified versions, and any portions
10 * thereof, and that both notices appear in supporting documentation.
12 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS
13 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
14 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
16 * Carnegie Mellon requests users of this software to return to
18 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
19 * School of Computer Science
20 * Carnegie Mellon University
21 * Pittsburgh PA 15213-3890
23 * any improvements or extensions that they make and grant Carnegie the
24 * rights to redistribute these changes.
26 * $Id: db_disasm.c,v 1.1 2003/01/15 21:50:58 mikesw Exp $
30 * Instruction disassembler.
34 #include <linux/kernel.h>
38 #include "db_access.h"
57 #define E 1 /* general effective address */
58 #define Eind 2 /* indirect address (jump, call) */
59 #define Ew 3 /* address, word size */
60 #define Eb 4 /* address, byte size */
61 #define R 5 /* register, in 'reg' field */
62 #define Rw 6 /* word register, in 'reg' field */
63 #define Ri 7 /* register in instruction */
64 #define S 8 /* segment reg, in 'reg' field */
65 #define Si 9 /* segment reg, in instruction */
66 #define A 10 /* accumulator */
67 #define BX 11 /* (bx) */
68 #define CL 12 /* cl, for shifts */
69 #define DX 13 /* dx, for IO */
70 #define SI 14 /* si */
71 #define DI 15 /* di */
72 #define CR 16 /* control register */
73 #define DR 17 /* debug register */
74 #define TR 18 /* test register */
75 #define I 19 /* immediate, unsigned */
76 #define Is 20 /* immediate, signed */
77 #define Ib 21 /* byte immediate, unsigned */
78 #define Ibs 22 /* byte immediate, signed */
79 #define Iw 23 /* word immediate, unsigned */
80 #define O 25 /* direct address */
81 #define Db 26 /* byte displacement from EIP */
82 #define Dl 27 /* long displacement from EIP */
83 #define o1 28 /* constant 1 */
84 #define o3 29 /* constant 3 */
85 #define OS 30 /* immediate offset/segment */
86 #define ST 31 /* FP stack top */
87 #define STI 32 /* FP stack */
88 #define X 33 /* extended FP op */
89 #define XA 34 /* for 'fstcw %ax' */
90 #define El 35 /* address, long size */
91 #define Ril 36 /* long register in instruction */
92 #define Iba 37 /* byte immediate, don't print if 0xa */
95 const char * i_name
; /* name */
96 short i_has_modrm
; /* has regmodrm byte */
97 short i_size
; /* operand size */
98 int i_mode
; /* addressing modes */
99 const void * i_extra
; /* pointer to extra opcode table */
103 #define op2(x,y) ((x)|((y)<<8))
104 #define op3(x,y,z) ((x)|((y)<<8)|((z)<<16))
107 const char * f_name
; /* name for memory instruction */
108 int f_size
; /* size for memory instruction */
109 int f_rrmode
; /* mode for rr instruction */
110 const void * f_rrname
; /* name for rr instruction
111 (or pointer to table) */
114 static const char * const db_Grp6
[] = {
125 static const char * const db_Grp7
[] = {
136 static const char * const db_Grp8
[] = {
147 static const char * const db_Grp9
[] = {
158 static const struct inst db_inst_0f0x
[] = {
159 /*00*/ { "", TRUE
, NONE
, op1(Ew
), db_Grp6
},
160 /*01*/ { "", TRUE
, NONE
, op1(Ew
), db_Grp7
},
161 /*02*/ { "lar", TRUE
, LONG
, op2(E
,R
), 0 },
162 /*03*/ { "lsl", TRUE
, LONG
, op2(E
,R
), 0 },
163 /*04*/ { "", FALSE
, NONE
, 0, 0 },
164 /*05*/ { "", FALSE
, NONE
, 0, 0 },
165 /*06*/ { "clts", FALSE
, NONE
, 0, 0 },
166 /*07*/ { "", FALSE
, NONE
, 0, 0 },
168 /*08*/ { "invd", FALSE
, NONE
, 0, 0 },
169 /*09*/ { "wbinvd",FALSE
, NONE
, 0, 0 },
170 /*0a*/ { "", FALSE
, NONE
, 0, 0 },
171 /*0b*/ { "", FALSE
, NONE
, 0, 0 },
172 /*0c*/ { "", FALSE
, NONE
, 0, 0 },
173 /*0d*/ { "", FALSE
, NONE
, 0, 0 },
174 /*0e*/ { "", FALSE
, NONE
, 0, 0 },
175 /*0f*/ { "", FALSE
, NONE
, 0, 0 },
178 static const struct inst db_inst_0f2x
[] = {
179 /*20*/ { "mov", TRUE
, LONG
, op2(CR
,El
), 0 },
180 /*21*/ { "mov", TRUE
, LONG
, op2(DR
,El
), 0 },
181 /*22*/ { "mov", TRUE
, LONG
, op2(El
,CR
), 0 },
182 /*23*/ { "mov", TRUE
, LONG
, op2(El
,DR
), 0 },
183 /*24*/ { "mov", TRUE
, LONG
, op2(TR
,El
), 0 },
184 /*25*/ { "", FALSE
, NONE
, 0, 0 },
185 /*26*/ { "mov", TRUE
, LONG
, op2(El
,TR
), 0 },
186 /*27*/ { "", FALSE
, NONE
, 0, 0 },
188 /*28*/ { "", FALSE
, NONE
, 0, 0 },
189 /*29*/ { "", FALSE
, NONE
, 0, 0 },
190 /*2a*/ { "", FALSE
, NONE
, 0, 0 },
191 /*2b*/ { "", FALSE
, NONE
, 0, 0 },
192 /*2c*/ { "", FALSE
, NONE
, 0, 0 },
193 /*2d*/ { "", FALSE
, NONE
, 0, 0 },
194 /*2e*/ { "", FALSE
, NONE
, 0, 0 },
195 /*2f*/ { "", FALSE
, NONE
, 0, 0 },
198 static const struct inst db_inst_0f3x
[] = {
199 /*30*/ { "wrmsr", FALSE
, NONE
, 0, 0 },
200 /*31*/ { "rdtsc", FALSE
, NONE
, 0, 0 },
201 /*32*/ { "rdmsr", FALSE
, NONE
, 0, 0 },
202 /*33*/ { "rdpmc", FALSE
, NONE
, 0, 0 },
203 /*34*/ { "", FALSE
, NONE
, 0, 0 },
204 /*35*/ { "", FALSE
, NONE
, 0, 0 },
205 /*36*/ { "", FALSE
, NONE
, 0, 0 },
206 /*37*/ { "", FALSE
, NONE
, 0, 0 },
208 /*38*/ { "", FALSE
, NONE
, 0, 0 },
209 /*39*/ { "", FALSE
, NONE
, 0, 0 },
210 /*3a*/ { "", FALSE
, NONE
, 0, 0 },
211 /*3b*/ { "", FALSE
, NONE
, 0, 0 },
212 /*3c*/ { "", FALSE
, NONE
, 0, 0 },
213 /*3d*/ { "", FALSE
, NONE
, 0, 0 },
214 /*3e*/ { "", FALSE
, NONE
, 0, 0 },
215 /*3f*/ { "", FALSE
, NONE
, 0, 0 },
218 static const struct inst db_inst_0f8x
[] = {
219 /*80*/ { "jo", FALSE
, NONE
, op1(Dl
), 0 },
220 /*81*/ { "jno", FALSE
, NONE
, op1(Dl
), 0 },
221 /*82*/ { "jb", FALSE
, NONE
, op1(Dl
), 0 },
222 /*83*/ { "jnb", FALSE
, NONE
, op1(Dl
), 0 },
223 /*84*/ { "jz", FALSE
, NONE
, op1(Dl
), 0 },
224 /*85*/ { "jnz", FALSE
, NONE
, op1(Dl
), 0 },
225 /*86*/ { "jbe", FALSE
, NONE
, op1(Dl
), 0 },
226 /*87*/ { "jnbe", FALSE
, NONE
, op1(Dl
), 0 },
228 /*88*/ { "js", FALSE
, NONE
, op1(Dl
), 0 },
229 /*89*/ { "jns", FALSE
, NONE
, op1(Dl
), 0 },
230 /*8a*/ { "jp", FALSE
, NONE
, op1(Dl
), 0 },
231 /*8b*/ { "jnp", FALSE
, NONE
, op1(Dl
), 0 },
232 /*8c*/ { "jl", FALSE
, NONE
, op1(Dl
), 0 },
233 /*8d*/ { "jnl", FALSE
, NONE
, op1(Dl
), 0 },
234 /*8e*/ { "jle", FALSE
, NONE
, op1(Dl
), 0 },
235 /*8f*/ { "jnle", FALSE
, NONE
, op1(Dl
), 0 },
238 static const struct inst db_inst_0f9x
[] = {
239 /*90*/ { "seto", TRUE
, NONE
, op1(Eb
), 0 },
240 /*91*/ { "setno", TRUE
, NONE
, op1(Eb
), 0 },
241 /*92*/ { "setb", TRUE
, NONE
, op1(Eb
), 0 },
242 /*93*/ { "setnb", TRUE
, NONE
, op1(Eb
), 0 },
243 /*94*/ { "setz", TRUE
, NONE
, op1(Eb
), 0 },
244 /*95*/ { "setnz", TRUE
, NONE
, op1(Eb
), 0 },
245 /*96*/ { "setbe", TRUE
, NONE
, op1(Eb
), 0 },
246 /*97*/ { "setnbe",TRUE
, NONE
, op1(Eb
), 0 },
248 /*98*/ { "sets", TRUE
, NONE
, op1(Eb
), 0 },
249 /*99*/ { "setns", TRUE
, NONE
, op1(Eb
), 0 },
250 /*9a*/ { "setp", TRUE
, NONE
, op1(Eb
), 0 },
251 /*9b*/ { "setnp", TRUE
, NONE
, op1(Eb
), 0 },
252 /*9c*/ { "setl", TRUE
, NONE
, op1(Eb
), 0 },
253 /*9d*/ { "setnl", TRUE
, NONE
, op1(Eb
), 0 },
254 /*9e*/ { "setle", TRUE
, NONE
, op1(Eb
), 0 },
255 /*9f*/ { "setnle",TRUE
, NONE
, op1(Eb
), 0 },
258 static const struct inst db_inst_0fax
[] = {
259 /*a0*/ { "push", FALSE
, NONE
, op1(Si
), 0 },
260 /*a1*/ { "pop", FALSE
, NONE
, op1(Si
), 0 },
261 /*a2*/ { "cpuid", FALSE
, NONE
, 0, 0 },
262 /*a3*/ { "bt", TRUE
, LONG
, op2(R
,E
), 0 },
263 /*a4*/ { "shld", TRUE
, LONG
, op3(Ib
,R
,E
), 0 },
264 /*a5*/ { "shld", TRUE
, LONG
, op3(CL
,R
,E
), 0 },
265 /*a6*/ { "", FALSE
, NONE
, 0, 0 },
266 /*a7*/ { "", FALSE
, NONE
, 0, 0 },
268 /*a8*/ { "push", FALSE
, NONE
, op1(Si
), 0 },
269 /*a9*/ { "pop", FALSE
, NONE
, op1(Si
), 0 },
270 /*aa*/ { "rsm", FALSE
, NONE
, 0, 0 },
271 /*ab*/ { "bts", TRUE
, LONG
, op2(R
,E
), 0 },
272 /*ac*/ { "shrd", TRUE
, LONG
, op3(Ib
,R
,E
), 0 },
273 /*ad*/ { "shrd", TRUE
, LONG
, op3(CL
,R
,E
), 0 },
274 /*a6*/ { "", FALSE
, NONE
, 0, 0 },
275 /*a7*/ { "imul", TRUE
, LONG
, op2(E
,R
), 0 },
278 static const struct inst db_inst_0fbx
[] = {
279 /*b0*/ { "cmpxchg",TRUE
, BYTE
, op2(R
, E
), 0 },
280 /*b0*/ { "cmpxchg",TRUE
, LONG
, op2(R
, E
), 0 },
281 /*b2*/ { "lss", TRUE
, LONG
, op2(E
, R
), 0 },
282 /*b3*/ { "btr", TRUE
, LONG
, op2(R
, E
), 0 },
283 /*b4*/ { "lfs", TRUE
, LONG
, op2(E
, R
), 0 },
284 /*b5*/ { "lgs", TRUE
, LONG
, op2(E
, R
), 0 },
285 /*b6*/ { "movzb", TRUE
, LONG
, op2(Eb
, R
), 0 },
286 /*b7*/ { "movzw", TRUE
, LONG
, op2(Ew
, R
), 0 },
288 /*b8*/ { "", FALSE
, NONE
, 0, 0 },
289 /*b9*/ { "", FALSE
, NONE
, 0, 0 },
290 /*ba*/ { "", TRUE
, LONG
, op2(Ib
, E
), db_Grp8
},
291 /*bb*/ { "btc", TRUE
, LONG
, op2(R
, E
), 0 },
292 /*bc*/ { "bsf", TRUE
, LONG
, op2(E
, R
), 0 },
293 /*bd*/ { "bsr", TRUE
, LONG
, op2(E
, R
), 0 },
294 /*be*/ { "movsb", TRUE
, LONG
, op2(Eb
, R
), 0 },
295 /*bf*/ { "movsw", TRUE
, LONG
, op2(Ew
, R
), 0 },
298 static const struct inst db_inst_0fcx
[] = {
299 /*c0*/ { "xadd", TRUE
, BYTE
, op2(R
, E
), 0 },
300 /*c1*/ { "xadd", TRUE
, LONG
, op2(R
, E
), 0 },
301 /*c2*/ { "", FALSE
, NONE
, 0, 0 },
302 /*c3*/ { "", FALSE
, NONE
, 0, 0 },
303 /*c4*/ { "", FALSE
, NONE
, 0, 0 },
304 /*c5*/ { "", FALSE
, NONE
, 0, 0 },
305 /*c6*/ { "", FALSE
, NONE
, 0, 0 },
306 /*c7*/ { "", TRUE
, NONE
, op1(E
), db_Grp9
},
307 /*c8*/ { "bswap", FALSE
, LONG
, op1(Ril
), 0 },
308 /*c9*/ { "bswap", FALSE
, LONG
, op1(Ril
), 0 },
309 /*ca*/ { "bswap", FALSE
, LONG
, op1(Ril
), 0 },
310 /*cb*/ { "bswap", FALSE
, LONG
, op1(Ril
), 0 },
311 /*cc*/ { "bswap", FALSE
, LONG
, op1(Ril
), 0 },
312 /*cd*/ { "bswap", FALSE
, LONG
, op1(Ril
), 0 },
313 /*ce*/ { "bswap", FALSE
, LONG
, op1(Ril
), 0 },
314 /*cf*/ { "bswap", FALSE
, LONG
, op1(Ril
), 0 },
317 static const struct inst
* const db_inst_0f
[] = {
336 static const char * const db_Esc92
[] = {
337 "fnop", "", "", "", "", "", "", ""
339 static const char * const db_Esc94
[] = {
340 "fchs", "fabs", "", "", "ftst", "fxam", "", ""
342 static const char * const db_Esc95
[] = {
343 "fld1", "fldl2t","fldl2e","fldpi","fldlg2","fldln2","fldz",""
345 static const char * const db_Esc96
[] = {
346 "f2xm1","fyl2x","fptan","fpatan","fxtract","fprem1","fdecstp",
349 static const char * const db_Esc97
[] = {
350 "fprem","fyl2xp1","fsqrt","fsincos","frndint","fscale","fsin","fcos"
353 static const char * const db_Esca5
[] = {
354 "", "fucompp","", "", "", "", "", ""
357 static const char * const db_Escb4
[] = {
358 "fneni","fndisi", "fnclex","fninit","fsetpm", "", "", ""
361 static const char * const db_Esce3
[] = {
362 "", "fcompp","", "", "", "", "", ""
365 static const char * const db_Escf4
[] = {
366 "fnstsw","", "", "", "", "", "", ""
369 static const struct finst db_Esc8
[] = {
370 /*0*/ { "fadd", SNGL
, op2(STI
,ST
), 0 },
371 /*1*/ { "fmul", SNGL
, op2(STI
,ST
), 0 },
372 /*2*/ { "fcom", SNGL
, op2(STI
,ST
), 0 },
373 /*3*/ { "fcomp", SNGL
, op2(STI
,ST
), 0 },
374 /*4*/ { "fsub", SNGL
, op2(STI
,ST
), 0 },
375 /*5*/ { "fsubr", SNGL
, op2(STI
,ST
), 0 },
376 /*6*/ { "fdiv", SNGL
, op2(STI
,ST
), 0 },
377 /*7*/ { "fdivr", SNGL
, op2(STI
,ST
), 0 },
380 static const struct finst db_Esc9
[] = {
381 /*0*/ { "fld", SNGL
, op1(STI
), 0 },
382 /*1*/ { "", NONE
, op1(STI
), "fxch" },
383 /*2*/ { "fst", SNGL
, op1(X
), db_Esc92
},
384 /*3*/ { "fstp", SNGL
, 0, 0 },
385 /*4*/ { "fldenv", NONE
, op1(X
), db_Esc94
},
386 /*5*/ { "fldcw", NONE
, op1(X
), db_Esc95
},
387 /*6*/ { "fnstenv",NONE
, op1(X
), db_Esc96
},
388 /*7*/ { "fnstcw", NONE
, op1(X
), db_Esc97
},
391 static const struct finst db_Esca
[] = {
392 /*0*/ { "fiadd", LONG
, 0, 0 },
393 /*1*/ { "fimul", LONG
, 0, 0 },
394 /*2*/ { "ficom", LONG
, 0, 0 },
395 /*3*/ { "ficomp", LONG
, 0, 0 },
396 /*4*/ { "fisub", LONG
, 0, 0 },
397 /*5*/ { "fisubr", LONG
, op1(X
), db_Esca5
},
398 /*6*/ { "fidiv", LONG
, 0, 0 },
399 /*7*/ { "fidivr", LONG
, 0, 0 }
402 static const struct finst db_Escb
[] = {
403 /*0*/ { "fild", LONG
, 0, 0 },
404 /*1*/ { "", NONE
, 0, 0 },
405 /*2*/ { "fist", LONG
, 0, 0 },
406 /*3*/ { "fistp", LONG
, 0, 0 },
407 /*4*/ { "", WORD
, op1(X
), db_Escb4
},
408 /*5*/ { "fld", EXTR
, 0, 0 },
409 /*6*/ { "", WORD
, 0, 0 },
410 /*7*/ { "fstp", EXTR
, 0, 0 },
413 static const struct finst db_Escc
[] = {
414 /*0*/ { "fadd", DBLR
, op2(ST
,STI
), 0 },
415 /*1*/ { "fmul", DBLR
, op2(ST
,STI
), 0 },
416 /*2*/ { "fcom", DBLR
, 0, 0 },
417 /*3*/ { "fcomp", DBLR
, 0, 0 },
418 /*4*/ { "fsub", DBLR
, op2(ST
,STI
), "fsubr" },
419 /*5*/ { "fsubr", DBLR
, op2(ST
,STI
), "fsub" },
420 /*6*/ { "fdiv", DBLR
, op2(ST
,STI
), "fdivr" },
421 /*7*/ { "fdivr", DBLR
, op2(ST
,STI
), "fdiv" },
424 static const struct finst db_Escd
[] = {
425 /*0*/ { "fld", DBLR
, op1(STI
), "ffree" },
426 /*1*/ { "", NONE
, 0, 0 },
427 /*2*/ { "fst", DBLR
, op1(STI
), 0 },
428 /*3*/ { "fstp", DBLR
, op1(STI
), 0 },
429 /*4*/ { "frstor", NONE
, op1(STI
), "fucom" },
430 /*5*/ { "", NONE
, op1(STI
), "fucomp" },
431 /*6*/ { "fnsave", NONE
, 0, 0 },
432 /*7*/ { "fnstsw", NONE
, 0, 0 },
435 static const struct finst db_Esce
[] = {
436 /*0*/ { "fiadd", WORD
, op2(ST
,STI
), "faddp" },
437 /*1*/ { "fimul", WORD
, op2(ST
,STI
), "fmulp" },
438 /*2*/ { "ficom", WORD
, 0, 0 },
439 /*3*/ { "ficomp", WORD
, op1(X
), db_Esce3
},
440 /*4*/ { "fisub", WORD
, op2(ST
,STI
), "fsubrp" },
441 /*5*/ { "fisubr", WORD
, op2(ST
,STI
), "fsubp" },
442 /*6*/ { "fidiv", WORD
, op2(ST
,STI
), "fdivrp" },
443 /*7*/ { "fidivr", WORD
, op2(ST
,STI
), "fdivp" },
446 static const struct finst db_Escf
[] = {
447 /*0*/ { "fild", WORD
, 0, 0 },
448 /*1*/ { "", NONE
, 0, 0 },
449 /*2*/ { "fist", WORD
, 0, 0 },
450 /*3*/ { "fistp", WORD
, 0, 0 },
451 /*4*/ { "fbld", NONE
, op1(XA
), db_Escf4
},
452 /*5*/ { "fild", QUAD
, 0, 0 },
453 /*6*/ { "fbstp", NONE
, 0, 0 },
454 /*7*/ { "fistp", QUAD
, 0, 0 },
457 static const struct finst
* const db_Esc_inst
[] = {
458 db_Esc8
, db_Esc9
, db_Esca
, db_Escb
,
459 db_Escc
, db_Escd
, db_Esce
, db_Escf
462 static const char * const db_Grp1
[] = {
473 static const char * const db_Grp2
[] = {
484 static const struct inst db_Grp3
[] = {
485 { "test", TRUE
, NONE
, op2(I
,E
), 0 },
486 { "test", TRUE
, NONE
, op2(I
,E
), 0 },
487 { "not", TRUE
, NONE
, op1(E
), 0 },
488 { "neg", TRUE
, NONE
, op1(E
), 0 },
489 { "mul", TRUE
, NONE
, op2(E
,A
), 0 },
490 { "imul", TRUE
, NONE
, op2(E
,A
), 0 },
491 { "div", TRUE
, NONE
, op2(E
,A
), 0 },
492 { "idiv", TRUE
, NONE
, op2(E
,A
), 0 },
495 static const struct inst db_Grp4
[] = {
496 { "inc", TRUE
, BYTE
, op1(E
), 0 },
497 { "dec", TRUE
, BYTE
, op1(E
), 0 },
498 { "", TRUE
, NONE
, 0, 0 },
499 { "", TRUE
, NONE
, 0, 0 },
500 { "", TRUE
, NONE
, 0, 0 },
501 { "", TRUE
, NONE
, 0, 0 },
502 { "", TRUE
, NONE
, 0, 0 },
503 { "", TRUE
, NONE
, 0, 0 }
506 static const struct inst db_Grp5
[] = {
507 { "inc", TRUE
, LONG
, op1(E
), 0 },
508 { "dec", TRUE
, LONG
, op1(E
), 0 },
509 { "call", TRUE
, LONG
, op1(Eind
),0 },
510 { "lcall", TRUE
, LONG
, op1(Eind
),0 },
511 { "jmp", TRUE
, LONG
, op1(Eind
),0 },
512 { "ljmp", TRUE
, LONG
, op1(Eind
),0 },
513 { "push", TRUE
, LONG
, op1(E
), 0 },
514 { "", TRUE
, NONE
, 0, 0 }
517 static const struct inst db_inst_table
[256] = {
518 /*00*/ { "add", TRUE
, BYTE
, op2(R
, E
), 0 },
519 /*01*/ { "add", TRUE
, LONG
, op2(R
, E
), 0 },
520 /*02*/ { "add", TRUE
, BYTE
, op2(E
, R
), 0 },
521 /*03*/ { "add", TRUE
, LONG
, op2(E
, R
), 0 },
522 /*04*/ { "add", FALSE
, BYTE
, op2(I
, A
), 0 },
523 /*05*/ { "add", FALSE
, LONG
, op2(Is
, A
), 0 },
524 /*06*/ { "push", FALSE
, NONE
, op1(Si
), 0 },
525 /*07*/ { "pop", FALSE
, NONE
, op1(Si
), 0 },
527 /*08*/ { "or", TRUE
, BYTE
, op2(R
, E
), 0 },
528 /*09*/ { "or", TRUE
, LONG
, op2(R
, E
), 0 },
529 /*0a*/ { "or", TRUE
, BYTE
, op2(E
, R
), 0 },
530 /*0b*/ { "or", TRUE
, LONG
, op2(E
, R
), 0 },
531 /*0c*/ { "or", FALSE
, BYTE
, op2(I
, A
), 0 },
532 /*0d*/ { "or", FALSE
, LONG
, op2(I
, A
), 0 },
533 /*0e*/ { "push", FALSE
, NONE
, op1(Si
), 0 },
534 /*0f*/ { "", FALSE
, NONE
, 0, 0 },
536 /*10*/ { "adc", TRUE
, BYTE
, op2(R
, E
), 0 },
537 /*11*/ { "adc", TRUE
, LONG
, op2(R
, E
), 0 },
538 /*12*/ { "adc", TRUE
, BYTE
, op2(E
, R
), 0 },
539 /*13*/ { "adc", TRUE
, LONG
, op2(E
, R
), 0 },
540 /*14*/ { "adc", FALSE
, BYTE
, op2(I
, A
), 0 },
541 /*15*/ { "adc", FALSE
, LONG
, op2(Is
, A
), 0 },
542 /*16*/ { "push", FALSE
, NONE
, op1(Si
), 0 },
543 /*17*/ { "pop", FALSE
, NONE
, op1(Si
), 0 },
545 /*18*/ { "sbb", TRUE
, BYTE
, op2(R
, E
), 0 },
546 /*19*/ { "sbb", TRUE
, LONG
, op2(R
, E
), 0 },
547 /*1a*/ { "sbb", TRUE
, BYTE
, op2(E
, R
), 0 },
548 /*1b*/ { "sbb", TRUE
, LONG
, op2(E
, R
), 0 },
549 /*1c*/ { "sbb", FALSE
, BYTE
, op2(I
, A
), 0 },
550 /*1d*/ { "sbb", FALSE
, LONG
, op2(Is
, A
), 0 },
551 /*1e*/ { "push", FALSE
, NONE
, op1(Si
), 0 },
552 /*1f*/ { "pop", FALSE
, NONE
, op1(Si
), 0 },
554 /*20*/ { "and", TRUE
, BYTE
, op2(R
, E
), 0 },
555 /*21*/ { "and", TRUE
, LONG
, op2(R
, E
), 0 },
556 /*22*/ { "and", TRUE
, BYTE
, op2(E
, R
), 0 },
557 /*23*/ { "and", TRUE
, LONG
, op2(E
, R
), 0 },
558 /*24*/ { "and", FALSE
, BYTE
, op2(I
, A
), 0 },
559 /*25*/ { "and", FALSE
, LONG
, op2(I
, A
), 0 },
560 /*26*/ { "", FALSE
, NONE
, 0, 0 },
561 /*27*/ { "daa", FALSE
, NONE
, 0, 0 },
563 /*28*/ { "sub", TRUE
, BYTE
, op2(R
, E
), 0 },
564 /*29*/ { "sub", TRUE
, LONG
, op2(R
, E
), 0 },
565 /*2a*/ { "sub", TRUE
, BYTE
, op2(E
, R
), 0 },
566 /*2b*/ { "sub", TRUE
, LONG
, op2(E
, R
), 0 },
567 /*2c*/ { "sub", FALSE
, BYTE
, op2(I
, A
), 0 },
568 /*2d*/ { "sub", FALSE
, LONG
, op2(Is
, A
), 0 },
569 /*2e*/ { "", FALSE
, NONE
, 0, 0 },
570 /*2f*/ { "das", FALSE
, NONE
, 0, 0 },
572 /*30*/ { "xor", TRUE
, BYTE
, op2(R
, E
), 0 },
573 /*31*/ { "xor", TRUE
, LONG
, op2(R
, E
), 0 },
574 /*32*/ { "xor", TRUE
, BYTE
, op2(E
, R
), 0 },
575 /*33*/ { "xor", TRUE
, LONG
, op2(E
, R
), 0 },
576 /*34*/ { "xor", FALSE
, BYTE
, op2(I
, A
), 0 },
577 /*35*/ { "xor", FALSE
, LONG
, op2(I
, A
), 0 },
578 /*36*/ { "", FALSE
, NONE
, 0, 0 },
579 /*37*/ { "aaa", FALSE
, NONE
, 0, 0 },
581 /*38*/ { "cmp", TRUE
, BYTE
, op2(R
, E
), 0 },
582 /*39*/ { "cmp", TRUE
, LONG
, op2(R
, E
), 0 },
583 /*3a*/ { "cmp", TRUE
, BYTE
, op2(E
, R
), 0 },
584 /*3b*/ { "cmp", TRUE
, LONG
, op2(E
, R
), 0 },
585 /*3c*/ { "cmp", FALSE
, BYTE
, op2(I
, A
), 0 },
586 /*3d*/ { "cmp", FALSE
, LONG
, op2(Is
, A
), 0 },
587 /*3e*/ { "", FALSE
, NONE
, 0, 0 },
588 /*3f*/ { "aas", FALSE
, NONE
, 0, 0 },
590 /*40*/ { "inc", FALSE
, LONG
, op1(Ri
), 0 },
591 /*41*/ { "inc", FALSE
, LONG
, op1(Ri
), 0 },
592 /*42*/ { "inc", FALSE
, LONG
, op1(Ri
), 0 },
593 /*43*/ { "inc", FALSE
, LONG
, op1(Ri
), 0 },
594 /*44*/ { "inc", FALSE
, LONG
, op1(Ri
), 0 },
595 /*45*/ { "inc", FALSE
, LONG
, op1(Ri
), 0 },
596 /*46*/ { "inc", FALSE
, LONG
, op1(Ri
), 0 },
597 /*47*/ { "inc", FALSE
, LONG
, op1(Ri
), 0 },
599 /*48*/ { "dec", FALSE
, LONG
, op1(Ri
), 0 },
600 /*49*/ { "dec", FALSE
, LONG
, op1(Ri
), 0 },
601 /*4a*/ { "dec", FALSE
, LONG
, op1(Ri
), 0 },
602 /*4b*/ { "dec", FALSE
, LONG
, op1(Ri
), 0 },
603 /*4c*/ { "dec", FALSE
, LONG
, op1(Ri
), 0 },
604 /*4d*/ { "dec", FALSE
, LONG
, op1(Ri
), 0 },
605 /*4e*/ { "dec", FALSE
, LONG
, op1(Ri
), 0 },
606 /*4f*/ { "dec", FALSE
, LONG
, op1(Ri
), 0 },
608 /*50*/ { "push", FALSE
, LONG
, op1(Ri
), 0 },
609 /*51*/ { "push", FALSE
, LONG
, op1(Ri
), 0 },
610 /*52*/ { "push", FALSE
, LONG
, op1(Ri
), 0 },
611 /*53*/ { "push", FALSE
, LONG
, op1(Ri
), 0 },
612 /*54*/ { "push", FALSE
, LONG
, op1(Ri
), 0 },
613 /*55*/ { "push", FALSE
, LONG
, op1(Ri
), 0 },
614 /*56*/ { "push", FALSE
, LONG
, op1(Ri
), 0 },
615 /*57*/ { "push", FALSE
, LONG
, op1(Ri
), 0 },
617 /*58*/ { "pop", FALSE
, LONG
, op1(Ri
), 0 },
618 /*59*/ { "pop", FALSE
, LONG
, op1(Ri
), 0 },
619 /*5a*/ { "pop", FALSE
, LONG
, op1(Ri
), 0 },
620 /*5b*/ { "pop", FALSE
, LONG
, op1(Ri
), 0 },
621 /*5c*/ { "pop", FALSE
, LONG
, op1(Ri
), 0 },
622 /*5d*/ { "pop", FALSE
, LONG
, op1(Ri
), 0 },
623 /*5e*/ { "pop", FALSE
, LONG
, op1(Ri
), 0 },
624 /*5f*/ { "pop", FALSE
, LONG
, op1(Ri
), 0 },
626 /*60*/ { "pusha", FALSE
, LONG
, 0, 0 },
627 /*61*/ { "popa", FALSE
, LONG
, 0, 0 },
628 /*62*/ { "bound", TRUE
, LONG
, op2(E
, R
), 0 },
629 /*63*/ { "arpl", TRUE
, NONE
, op2(Rw
,Ew
), 0 },
631 /*64*/ { "", FALSE
, NONE
, 0, 0 },
632 /*65*/ { "", FALSE
, NONE
, 0, 0 },
633 /*66*/ { "", FALSE
, NONE
, 0, 0 },
634 /*67*/ { "", FALSE
, NONE
, 0, 0 },
636 /*68*/ { "push", FALSE
, LONG
, op1(I
), 0 },
637 /*69*/ { "imul", TRUE
, LONG
, op3(I
,E
,R
), 0 },
638 /*6a*/ { "push", FALSE
, LONG
, op1(Ibs
), 0 },
639 /*6b*/ { "imul", TRUE
, LONG
, op3(Ibs
,E
,R
),0 },
640 /*6c*/ { "ins", FALSE
, BYTE
, op2(DX
, DI
), 0 },
641 /*6d*/ { "ins", FALSE
, LONG
, op2(DX
, DI
), 0 },
642 /*6e*/ { "outs", FALSE
, BYTE
, op2(SI
, DX
), 0 },
643 /*6f*/ { "outs", FALSE
, LONG
, op2(SI
, DX
), 0 },
645 /*70*/ { "jo", FALSE
, NONE
, op1(Db
), 0 },
646 /*71*/ { "jno", FALSE
, NONE
, op1(Db
), 0 },
647 /*72*/ { "jb", FALSE
, NONE
, op1(Db
), 0 },
648 /*73*/ { "jnb", FALSE
, NONE
, op1(Db
), 0 },
649 /*74*/ { "jz", FALSE
, NONE
, op1(Db
), 0 },
650 /*75*/ { "jnz", FALSE
, NONE
, op1(Db
), 0 },
651 /*76*/ { "jbe", FALSE
, NONE
, op1(Db
), 0 },
652 /*77*/ { "jnbe", FALSE
, NONE
, op1(Db
), 0 },
654 /*78*/ { "js", FALSE
, NONE
, op1(Db
), 0 },
655 /*79*/ { "jns", FALSE
, NONE
, op1(Db
), 0 },
656 /*7a*/ { "jp", FALSE
, NONE
, op1(Db
), 0 },
657 /*7b*/ { "jnp", FALSE
, NONE
, op1(Db
), 0 },
658 /*7c*/ { "jl", FALSE
, NONE
, op1(Db
), 0 },
659 /*7d*/ { "jnl", FALSE
, NONE
, op1(Db
), 0 },
660 /*7e*/ { "jle", FALSE
, NONE
, op1(Db
), 0 },
661 /*7f*/ { "jnle", FALSE
, NONE
, op1(Db
), 0 },
663 /*80*/ { "", TRUE
, BYTE
, op2(I
, E
), db_Grp1
},
664 /*81*/ { "", TRUE
, LONG
, op2(I
, E
), db_Grp1
},
665 /*82*/ { "", TRUE
, BYTE
, op2(I
, E
), db_Grp1
},
666 /*83*/ { "", TRUE
, LONG
, op2(Ibs
,E
), db_Grp1
},
667 /*84*/ { "test", TRUE
, BYTE
, op2(R
, E
), 0 },
668 /*85*/ { "test", TRUE
, LONG
, op2(R
, E
), 0 },
669 /*86*/ { "xchg", TRUE
, BYTE
, op2(R
, E
), 0 },
670 /*87*/ { "xchg", TRUE
, LONG
, op2(R
, E
), 0 },
672 /*88*/ { "mov", TRUE
, BYTE
, op2(R
, E
), 0 },
673 /*89*/ { "mov", TRUE
, LONG
, op2(R
, E
), 0 },
674 /*8a*/ { "mov", TRUE
, BYTE
, op2(E
, R
), 0 },
675 /*8b*/ { "mov", TRUE
, LONG
, op2(E
, R
), 0 },
676 /*8c*/ { "mov", TRUE
, NONE
, op2(S
, Ew
), 0 },
677 /*8d*/ { "lea", TRUE
, LONG
, op2(E
, R
), 0 },
678 /*8e*/ { "mov", TRUE
, NONE
, op2(Ew
, S
), 0 },
679 /*8f*/ { "pop", TRUE
, LONG
, op1(E
), 0 },
681 /*90*/ { "nop", FALSE
, NONE
, 0, 0 },
682 /*91*/ { "xchg", FALSE
, LONG
, op2(A
, Ri
), 0 },
683 /*92*/ { "xchg", FALSE
, LONG
, op2(A
, Ri
), 0 },
684 /*93*/ { "xchg", FALSE
, LONG
, op2(A
, Ri
), 0 },
685 /*94*/ { "xchg", FALSE
, LONG
, op2(A
, Ri
), 0 },
686 /*95*/ { "xchg", FALSE
, LONG
, op2(A
, Ri
), 0 },
687 /*96*/ { "xchg", FALSE
, LONG
, op2(A
, Ri
), 0 },
688 /*97*/ { "xchg", FALSE
, LONG
, op2(A
, Ri
), 0 },
690 /*98*/ { "cbw", FALSE
, SDEP
, 0, "cwde" }, /* cbw/cwde */
691 /*99*/ { "cwd", FALSE
, SDEP
, 0, "cdq" }, /* cwd/cdq */
692 /*9a*/ { "lcall", FALSE
, NONE
, op1(OS
), 0 },
693 /*9b*/ { "wait", FALSE
, NONE
, 0, 0 },
694 /*9c*/ { "pushf", FALSE
, LONG
, 0, 0 },
695 /*9d*/ { "popf", FALSE
, LONG
, 0, 0 },
696 /*9e*/ { "sahf", FALSE
, NONE
, 0, 0 },
697 /*9f*/ { "lahf", FALSE
, NONE
, 0, 0 },
699 /*a0*/ { "mov", FALSE
, BYTE
, op2(O
, A
), 0 },
700 /*a1*/ { "mov", FALSE
, LONG
, op2(O
, A
), 0 },
701 /*a2*/ { "mov", FALSE
, BYTE
, op2(A
, O
), 0 },
702 /*a3*/ { "mov", FALSE
, LONG
, op2(A
, O
), 0 },
703 /*a4*/ { "movs", FALSE
, BYTE
, op2(SI
,DI
), 0 },
704 /*a5*/ { "movs", FALSE
, LONG
, op2(SI
,DI
), 0 },
705 /*a6*/ { "cmps", FALSE
, BYTE
, op2(SI
,DI
), 0 },
706 /*a7*/ { "cmps", FALSE
, LONG
, op2(SI
,DI
), 0 },
708 /*a8*/ { "test", FALSE
, BYTE
, op2(I
, A
), 0 },
709 /*a9*/ { "test", FALSE
, LONG
, op2(I
, A
), 0 },
710 /*aa*/ { "stos", FALSE
, BYTE
, op1(DI
), 0 },
711 /*ab*/ { "stos", FALSE
, LONG
, op1(DI
), 0 },
712 /*ac*/ { "lods", FALSE
, BYTE
, op1(SI
), 0 },
713 /*ad*/ { "lods", FALSE
, LONG
, op1(SI
), 0 },
714 /*ae*/ { "scas", FALSE
, BYTE
, op1(SI
), 0 },
715 /*af*/ { "scas", FALSE
, LONG
, op1(SI
), 0 },
717 /*b0*/ { "mov", FALSE
, BYTE
, op2(I
, Ri
), 0 },
718 /*b1*/ { "mov", FALSE
, BYTE
, op2(I
, Ri
), 0 },
719 /*b2*/ { "mov", FALSE
, BYTE
, op2(I
, Ri
), 0 },
720 /*b3*/ { "mov", FALSE
, BYTE
, op2(I
, Ri
), 0 },
721 /*b4*/ { "mov", FALSE
, BYTE
, op2(I
, Ri
), 0 },
722 /*b5*/ { "mov", FALSE
, BYTE
, op2(I
, Ri
), 0 },
723 /*b6*/ { "mov", FALSE
, BYTE
, op2(I
, Ri
), 0 },
724 /*b7*/ { "mov", FALSE
, BYTE
, op2(I
, Ri
), 0 },
726 /*b8*/ { "mov", FALSE
, LONG
, op2(I
, Ri
), 0 },
727 /*b9*/ { "mov", FALSE
, LONG
, op2(I
, Ri
), 0 },
728 /*ba*/ { "mov", FALSE
, LONG
, op2(I
, Ri
), 0 },
729 /*bb*/ { "mov", FALSE
, LONG
, op2(I
, Ri
), 0 },
730 /*bc*/ { "mov", FALSE
, LONG
, op2(I
, Ri
), 0 },
731 /*bd*/ { "mov", FALSE
, LONG
, op2(I
, Ri
), 0 },
732 /*be*/ { "mov", FALSE
, LONG
, op2(I
, Ri
), 0 },
733 /*bf*/ { "mov", FALSE
, LONG
, op2(I
, Ri
), 0 },
735 /*c0*/ { "", TRUE
, BYTE
, op2(Ib
, E
), db_Grp2
},
736 /*c1*/ { "", TRUE
, LONG
, op2(Ib
, E
), db_Grp2
},
737 /*c2*/ { "ret", FALSE
, NONE
, op1(Iw
), 0 },
738 /*c3*/ { "ret", FALSE
, NONE
, 0, 0 },
739 /*c4*/ { "les", TRUE
, LONG
, op2(E
, R
), 0 },
740 /*c5*/ { "lds", TRUE
, LONG
, op2(E
, R
), 0 },
741 /*c6*/ { "mov", TRUE
, BYTE
, op2(I
, E
), 0 },
742 /*c7*/ { "mov", TRUE
, LONG
, op2(I
, E
), 0 },
744 /*c8*/ { "enter", FALSE
, NONE
, op2(Iw
, Ib
), 0 },
745 /*c9*/ { "leave", FALSE
, NONE
, 0, 0 },
746 /*ca*/ { "lret", FALSE
, NONE
, op1(Iw
), 0 },
747 /*cb*/ { "lret", FALSE
, NONE
, 0, 0 },
748 /*cc*/ { "int", FALSE
, NONE
, op1(o3
), 0 },
749 /*cd*/ { "int", FALSE
, NONE
, op1(Ib
), 0 },
750 /*ce*/ { "into", FALSE
, NONE
, 0, 0 },
751 /*cf*/ { "iret", FALSE
, NONE
, 0, 0 },
753 /*d0*/ { "", TRUE
, BYTE
, op2(o1
, E
), db_Grp2
},
754 /*d1*/ { "", TRUE
, LONG
, op2(o1
, E
), db_Grp2
},
755 /*d2*/ { "", TRUE
, BYTE
, op2(CL
, E
), db_Grp2
},
756 /*d3*/ { "", TRUE
, LONG
, op2(CL
, E
), db_Grp2
},
757 /*d4*/ { "aam", FALSE
, NONE
, op1(Iba
), 0 },
758 /*d5*/ { "aad", FALSE
, NONE
, op1(Iba
), 0 },
759 /*d6*/ { ".byte\t0xd6", FALSE
, NONE
, 0, 0 },
760 /*d7*/ { "xlat", FALSE
, BYTE
, op1(BX
), 0 },
762 /*d8*/ { "", TRUE
, NONE
, 0, db_Esc8
},
763 /*d9*/ { "", TRUE
, NONE
, 0, db_Esc9
},
764 /*da*/ { "", TRUE
, NONE
, 0, db_Esca
},
765 /*db*/ { "", TRUE
, NONE
, 0, db_Escb
},
766 /*dc*/ { "", TRUE
, NONE
, 0, db_Escc
},
767 /*dd*/ { "", TRUE
, NONE
, 0, db_Escd
},
768 /*de*/ { "", TRUE
, NONE
, 0, db_Esce
},
769 /*df*/ { "", TRUE
, NONE
, 0, db_Escf
},
771 /*e0*/ { "loopne",FALSE
, NONE
, op1(Db
), 0 },
772 /*e1*/ { "loope", FALSE
, NONE
, op1(Db
), 0 },
773 /*e2*/ { "loop", FALSE
, NONE
, op1(Db
), 0 },
774 /*e3*/ { "jcxz", FALSE
, SDEP
, op1(Db
), "jecxz" },
775 /*e4*/ { "in", FALSE
, BYTE
, op2(Ib
, A
), 0 },
776 /*e5*/ { "in", FALSE
, LONG
, op2(Ib
, A
) , 0 },
777 /*e6*/ { "out", FALSE
, BYTE
, op2(A
, Ib
), 0 },
778 /*e7*/ { "out", FALSE
, LONG
, op2(A
, Ib
) , 0 },
780 /*e8*/ { "call", FALSE
, NONE
, op1(Dl
), 0 },
781 /*e9*/ { "jmp", FALSE
, NONE
, op1(Dl
), 0 },
782 /*ea*/ { "ljmp", FALSE
, NONE
, op1(OS
), 0 },
783 /*eb*/ { "jmp", FALSE
, NONE
, op1(Db
), 0 },
784 /*ec*/ { "in", FALSE
, BYTE
, op2(DX
, A
), 0 },
785 /*ed*/ { "in", FALSE
, LONG
, op2(DX
, A
) , 0 },
786 /*ee*/ { "out", FALSE
, BYTE
, op2(A
, DX
), 0 },
787 /*ef*/ { "out", FALSE
, LONG
, op2(A
, DX
) , 0 },
789 /*f0*/ { "", FALSE
, NONE
, 0, 0 },
790 /*f1*/ { ".byte\t0xf1", FALSE
, NONE
, 0, 0 },
791 /*f2*/ { "", FALSE
, NONE
, 0, 0 },
792 /*f3*/ { "", FALSE
, NONE
, 0, 0 },
793 /*f4*/ { "hlt", FALSE
, NONE
, 0, 0 },
794 /*f5*/ { "cmc", FALSE
, NONE
, 0, 0 },
795 /*f6*/ { "", TRUE
, BYTE
, 0, db_Grp3
},
796 /*f7*/ { "", TRUE
, LONG
, 0, db_Grp3
},
798 /*f8*/ { "clc", FALSE
, NONE
, 0, 0 },
799 /*f9*/ { "stc", FALSE
, NONE
, 0, 0 },
800 /*fa*/ { "cli", FALSE
, NONE
, 0, 0 },
801 /*fb*/ { "sti", FALSE
, NONE
, 0, 0 },
802 /*fc*/ { "cld", FALSE
, NONE
, 0, 0 },
803 /*fd*/ { "std", FALSE
, NONE
, 0, 0 },
804 /*fe*/ { "", TRUE
, NONE
, 0, db_Grp4
},
805 /*ff*/ { "", TRUE
, NONE
, 0, db_Grp5
},
808 static const struct inst db_bad_inst
=
809 { "???", FALSE
, NONE
, 0, 0 }
812 #define f_mod(byte) ((byte)>>6)
813 #define f_reg(byte) (((byte)>>3)&0x7)
814 #define f_rm(byte) ((byte)&0x7)
816 #define sib_ss(byte) ((byte)>>6)
817 #define sib_index(byte) (((byte)>>3)&0x7)
818 #define sib_base(byte) ((byte)&0x7)
821 int is_reg
; /* if reg, reg number is in 'disp' */
828 static const char * const db_index_reg_16
[8] = {
839 static const char * const db_reg
[3][8] = {
840 {"%al", "%cl", "%dl", "%bl", "%ah", "%ch", "%dh", "%bh"},
841 {"%ax", "%cx", "%dx", "%bx", "%sp", "%bp", "%si", "%di"},
842 {"%eax", "%ecx", "%edx", "%ebx", "%esp", "%ebp", "%esi", "%edi"}
845 static const char * const db_seg_reg
[8] = {
846 "%es", "%cs", "%ss", "%ds", "%fs", "%gs", "", ""
850 * lengths for size attributes
852 static const int db_lengths
[] = {
862 #define get_value_inc(result, loc, size, is_signed) \
863 result = db_get_value((loc), (size), (is_signed)); \
867 // db_disasm_esc __P((db_addr_t loc, int inst, int short_addr,
868 // int size, const char *seg));
869 //static void db_print_address __P((const char *seg, int size,
870 // struct i_addr *addrp));
873 db_read_address
__P((db_addr_t loc
, int short_addr
,
874 int regmodrm
, struct i_addr
*addrp
));
877 * Read address at location and return updated location.
880 db_read_address(loc
, short_addr
, regmodrm
, addrp
)
884 struct i_addr
* addrp
; /* out */
886 int mod
, rm
, sib
, index
, disp
;
888 mod
= f_mod(regmodrm
);
892 addrp
->is_reg
= TRUE
;
896 addrp
->is_reg
= FALSE
;
905 get_value_inc(disp
, loc
, 2, FALSE
);
911 addrp
->base
= db_index_reg_16
[rm
];
915 get_value_inc(disp
, loc
, 1, TRUE
);
918 addrp
->base
= db_index_reg_16
[rm
];
921 get_value_inc(disp
, loc
, 2, FALSE
);
923 addrp
->base
= db_index_reg_16
[rm
];
928 if (mod
!= 3 && rm
== 4) {
929 get_value_inc(sib
, loc
, 1, FALSE
);
931 index
= sib_index(sib
);
933 addrp
->index
= db_reg
[LONG
][index
];
934 addrp
->ss
= sib_ss(sib
);
940 get_value_inc(addrp
->disp
, loc
, 4, FALSE
);
945 addrp
->base
= db_reg
[LONG
][rm
];
950 get_value_inc(disp
, loc
, 1, TRUE
);
952 addrp
->base
= db_reg
[LONG
][rm
];
956 get_value_inc(disp
, loc
, 4, FALSE
);
958 addrp
->base
= db_reg
[LONG
][rm
];
966 * NWT: fault injection routine only. disasm floating-point instruction
967 * and return updated location.
978 const struct finst
* fp
;
980 struct i_addr address
;
983 get_value_inc(regmodrm
, loc
, 1, FALSE
);
984 fp
= &db_Esc_inst
[inst
- 0xd8][f_reg(regmodrm
)];
985 mod
= f_mod(regmodrm
);
987 if (*fp
->f_name
== '\0') {
991 * Normal address modes.
993 loc
= db_read_address(loc
, short_addr
, regmodrm
, &address
);
1013 * 'reg-reg' - special formats
1015 switch (fp
->f_rrmode
) {
1017 name
= (fp
->f_rrname
) ? fp
->f_rrname
: fp
->f_name
;
1020 name
= (fp
->f_rrname
) ? fp
->f_rrname
: fp
->f_name
;
1023 name
= (fp
->f_rrname
) ? fp
->f_rrname
: fp
->f_name
;
1026 name
= ((const char * const *)fp
->f_rrname
)[f_rm(regmodrm
)];
1031 name
= ((const char * const *)fp
->f_rrname
)[f_rm(regmodrm
)];
1044 * Disassemble instruction at 'loc'. 'altfmt' specifies an
1045 * (optional) alternate format. Return address of start of
1049 my_disasm(db_addr_t loc
,
1056 const struct inst
* ip
;
1057 const char * i_name
;
1067 struct i_addr address
;
1069 get_value_inc(inst
, loc
, 1, FALSE
);
1080 case 0x66: /* data16 */
1106 // db_printf("lock ");
1111 // db_printf("repne ");
1116 // db_printf("repe "); /* XXX repe VS rep */
1124 get_value_inc(inst
, loc
, 1, FALSE
);
1128 if (inst
>= 0xd8 && inst
<= 0xdf) {
1129 loc
= my_disasm_esc(loc
, inst
, short_addr
, size
, seg
);
1134 get_value_inc(inst
, loc
, 1, FALSE
);
1135 ip
= db_inst_0f
[inst
>>4];
1144 ip
= &db_inst_table
[inst
];
1146 if (ip
->i_has_modrm
) {
1147 unsigned long prev_loc
=loc
;
1148 extern unsigned long modAddr
;
1150 get_value_inc(regmodrm
, loc
, 1, FALSE
);
1151 loc
= db_read_address(loc
, short_addr
, regmodrm
, &address
);
1154 // printf("modrm at %x, offset %d\n", loc, loc-prev_loc);
1158 i_name
= ip
->i_name
;
1159 i_size
= ip
->i_size
;
1160 i_mode
= ip
->i_mode
;
1162 if (ip
->i_extra
== db_Grp1
|| ip
->i_extra
== db_Grp2
||
1163 ip
->i_extra
== db_Grp6
|| ip
->i_extra
== db_Grp7
||
1164 ip
->i_extra
== db_Grp8
|| ip
->i_extra
== db_Grp9
) {
1165 i_name
= ((const char * const *)ip
->i_extra
)[f_reg(regmodrm
)];
1167 else if (ip
->i_extra
== db_Grp3
) {
1169 ip
= &ip
[f_reg(regmodrm
)];
1170 i_name
= ip
->i_name
;
1171 i_mode
= ip
->i_mode
;
1173 else if (ip
->i_extra
== db_Grp4
|| ip
->i_extra
== db_Grp5
) {
1175 ip
= &ip
[f_reg(regmodrm
)];
1176 i_name
= ip
->i_name
;
1177 i_mode
= ip
->i_mode
;
1178 i_size
= ip
->i_size
;
1181 if (i_size
== SDEP
) {
1184 if (i_size
!= NONE
) {
1185 if (i_size
== BYTE
) {
1188 else if (i_size
== WORD
) {
1195 i_mode
>>= 8, first
= FALSE
)
1198 switch (i_mode
& 0xFF) {
1202 // db_print_address(seg, size, &address);
1208 // db_print_address(seg, size, &address);
1214 // db_print_address(seg, LONG, &address);
1220 // db_print_address(seg, WORD, &address);
1226 // db_print_address(seg, BYTE, &address);
1232 // db_printf("%s", db_reg[size][f_reg(regmodrm)]);
1238 // db_printf("%s", db_reg[WORD][f_reg(regmodrm)]);
1244 // db_printf("%s", db_reg[size][f_rm(inst)]);
1250 // db_printf("%s", db_reg[LONG][f_rm(inst)]);
1256 // db_printf("%s", db_seg_reg[f_reg(regmodrm)]);
1262 // db_printf("%s", db_seg_reg[f_reg(inst)]);
1268 // db_printf("%s", db_reg[size][0]); /* acc */
1297 len
= db_lengths
[size
];
1298 get_value_inc(imm
, loc
, len
, FALSE
);
1302 len
= db_lengths
[size
];
1303 get_value_inc(imm
, loc
, len
, FALSE
);
1305 * XXX the + in this format doesn't seem to work right.
1306 * `Is' is equivalent to `I'.
1311 get_value_inc(imm
, loc
, 1, FALSE
);
1315 get_value_inc(imm
, loc
, 1, FALSE
);
1319 get_value_inc(imm
, loc
, 1, TRUE
);
1325 get_value_inc(imm
, loc
, 2, FALSE
);
1329 len
= (short_addr
? 2 : 4);
1330 get_value_inc(displ
, loc
, len
, FALSE
);
1334 // db_printsym((db_addr_t)displ, DB_STGY_ANY);
1339 get_value_inc(displ
, loc
, 1, TRUE
);
1344 // db_printsym((db_addr_t)displ, DB_STGY_XTRN);
1349 len
= db_lengths
[size
];
1350 get_value_inc(displ
, loc
, len
, FALSE
);
1355 // db_printsym((db_addr_t)displ, DB_STGY_XTRN);
1366 len
= db_lengths
[size
];
1367 get_value_inc(imm
, loc
, len
, FALSE
); /* offset */
1368 get_value_inc(imm2
, loc
, 2, FALSE
); /* segment */