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.
28 * Instruction disassembler.
32 #include <linux/kernel.h>
36 #include "db_access.h"
55 #define E 1 /* general effective address */
56 #define Eind 2 /* indirect address (jump, call) */
57 #define Ew 3 /* address, word size */
58 #define Eb 4 /* address, byte size */
59 #define R 5 /* register, in 'reg' field */
60 #define Rw 6 /* word register, in 'reg' field */
61 #define Ri 7 /* register in instruction */
62 #define S 8 /* segment reg, in 'reg' field */
63 #define Si 9 /* segment reg, in instruction */
64 #define A 10 /* accumulator */
65 #define BX 11 /* (bx) */
66 #define CL 12 /* cl, for shifts */
67 #define DX 13 /* dx, for IO */
68 #define SI 14 /* si */
69 #define DI 15 /* di */
70 #define CR 16 /* control register */
71 #define DR 17 /* debug register */
72 #define TR 18 /* test register */
73 #define I 19 /* immediate, unsigned */
74 #define Is 20 /* immediate, signed */
75 #define Ib 21 /* byte immediate, unsigned */
76 #define Ibs 22 /* byte immediate, signed */
77 #define Iw 23 /* word immediate, unsigned */
78 #define O 25 /* direct address */
79 #define Db 26 /* byte displacement from EIP */
80 #define Dl 27 /* long displacement from EIP */
81 #define o1 28 /* constant 1 */
82 #define o3 29 /* constant 3 */
83 #define OS 30 /* immediate offset/segment */
84 #define ST 31 /* FP stack top */
85 #define STI 32 /* FP stack */
86 #define X 33 /* extended FP op */
87 #define XA 34 /* for 'fstcw %ax' */
88 #define El 35 /* address, long size */
89 #define Ril 36 /* long register in instruction */
90 #define Iba 37 /* byte immediate, don't print if 0xa */
93 const char * i_name
; /* name */
94 short i_has_modrm
; /* has regmodrm byte */
95 short i_size
; /* operand size */
96 int i_mode
; /* addressing modes */
97 const void * i_extra
; /* pointer to extra opcode table */
101 #define op2(x,y) ((x)|((y)<<8))
102 #define op3(x,y,z) ((x)|((y)<<8)|((z)<<16))
105 const char * f_name
; /* name for memory instruction */
106 int f_size
; /* size for memory instruction */
107 int f_rrmode
; /* mode for rr instruction */
108 const void * f_rrname
; /* name for rr instruction
109 (or pointer to table) */
112 static const char * const db_Grp6
[] = {
123 static const char * const db_Grp7
[] = {
134 static const char * const db_Grp8
[] = {
145 static const char * const db_Grp9
[] = {
156 static const struct inst db_inst_0f0x
[] = {
157 /*00*/ { "", TRUE
, NONE
, op1(Ew
), db_Grp6
},
158 /*01*/ { "", TRUE
, NONE
, op1(Ew
), db_Grp7
},
159 /*02*/ { "lar", TRUE
, LONG
, op2(E
,R
), 0 },
160 /*03*/ { "lsl", TRUE
, LONG
, op2(E
,R
), 0 },
161 /*04*/ { "", FALSE
, NONE
, 0, 0 },
162 /*05*/ { "", FALSE
, NONE
, 0, 0 },
163 /*06*/ { "clts", FALSE
, NONE
, 0, 0 },
164 /*07*/ { "", FALSE
, NONE
, 0, 0 },
166 /*08*/ { "invd", FALSE
, NONE
, 0, 0 },
167 /*09*/ { "wbinvd",FALSE
, NONE
, 0, 0 },
168 /*0a*/ { "", FALSE
, NONE
, 0, 0 },
169 /*0b*/ { "", FALSE
, NONE
, 0, 0 },
170 /*0c*/ { "", FALSE
, NONE
, 0, 0 },
171 /*0d*/ { "", FALSE
, NONE
, 0, 0 },
172 /*0e*/ { "", FALSE
, NONE
, 0, 0 },
173 /*0f*/ { "", FALSE
, NONE
, 0, 0 },
176 static const struct inst db_inst_0f2x
[] = {
177 /*20*/ { "mov", TRUE
, LONG
, op2(CR
,El
), 0 },
178 /*21*/ { "mov", TRUE
, LONG
, op2(DR
,El
), 0 },
179 /*22*/ { "mov", TRUE
, LONG
, op2(El
,CR
), 0 },
180 /*23*/ { "mov", TRUE
, LONG
, op2(El
,DR
), 0 },
181 /*24*/ { "mov", TRUE
, LONG
, op2(TR
,El
), 0 },
182 /*25*/ { "", FALSE
, NONE
, 0, 0 },
183 /*26*/ { "mov", TRUE
, LONG
, op2(El
,TR
), 0 },
184 /*27*/ { "", FALSE
, NONE
, 0, 0 },
186 /*28*/ { "", FALSE
, NONE
, 0, 0 },
187 /*29*/ { "", FALSE
, NONE
, 0, 0 },
188 /*2a*/ { "", FALSE
, NONE
, 0, 0 },
189 /*2b*/ { "", FALSE
, NONE
, 0, 0 },
190 /*2c*/ { "", FALSE
, NONE
, 0, 0 },
191 /*2d*/ { "", FALSE
, NONE
, 0, 0 },
192 /*2e*/ { "", FALSE
, NONE
, 0, 0 },
193 /*2f*/ { "", FALSE
, NONE
, 0, 0 },
196 static const struct inst db_inst_0f3x
[] = {
197 /*30*/ { "wrmsr", FALSE
, NONE
, 0, 0 },
198 /*31*/ { "rdtsc", FALSE
, NONE
, 0, 0 },
199 /*32*/ { "rdmsr", FALSE
, NONE
, 0, 0 },
200 /*33*/ { "rdpmc", FALSE
, NONE
, 0, 0 },
201 /*34*/ { "", FALSE
, NONE
, 0, 0 },
202 /*35*/ { "", FALSE
, NONE
, 0, 0 },
203 /*36*/ { "", FALSE
, NONE
, 0, 0 },
204 /*37*/ { "", FALSE
, NONE
, 0, 0 },
206 /*38*/ { "", FALSE
, NONE
, 0, 0 },
207 /*39*/ { "", FALSE
, NONE
, 0, 0 },
208 /*3a*/ { "", FALSE
, NONE
, 0, 0 },
209 /*3b*/ { "", FALSE
, NONE
, 0, 0 },
210 /*3c*/ { "", FALSE
, NONE
, 0, 0 },
211 /*3d*/ { "", FALSE
, NONE
, 0, 0 },
212 /*3e*/ { "", FALSE
, NONE
, 0, 0 },
213 /*3f*/ { "", FALSE
, NONE
, 0, 0 },
216 static const struct inst db_inst_0f8x
[] = {
217 /*80*/ { "jo", FALSE
, NONE
, op1(Dl
), 0 },
218 /*81*/ { "jno", FALSE
, NONE
, op1(Dl
), 0 },
219 /*82*/ { "jb", FALSE
, NONE
, op1(Dl
), 0 },
220 /*83*/ { "jnb", FALSE
, NONE
, op1(Dl
), 0 },
221 /*84*/ { "jz", FALSE
, NONE
, op1(Dl
), 0 },
222 /*85*/ { "jnz", FALSE
, NONE
, op1(Dl
), 0 },
223 /*86*/ { "jbe", FALSE
, NONE
, op1(Dl
), 0 },
224 /*87*/ { "jnbe", FALSE
, NONE
, op1(Dl
), 0 },
226 /*88*/ { "js", FALSE
, NONE
, op1(Dl
), 0 },
227 /*89*/ { "jns", FALSE
, NONE
, op1(Dl
), 0 },
228 /*8a*/ { "jp", FALSE
, NONE
, op1(Dl
), 0 },
229 /*8b*/ { "jnp", FALSE
, NONE
, op1(Dl
), 0 },
230 /*8c*/ { "jl", FALSE
, NONE
, op1(Dl
), 0 },
231 /*8d*/ { "jnl", FALSE
, NONE
, op1(Dl
), 0 },
232 /*8e*/ { "jle", FALSE
, NONE
, op1(Dl
), 0 },
233 /*8f*/ { "jnle", FALSE
, NONE
, op1(Dl
), 0 },
236 static const struct inst db_inst_0f9x
[] = {
237 /*90*/ { "seto", TRUE
, NONE
, op1(Eb
), 0 },
238 /*91*/ { "setno", TRUE
, NONE
, op1(Eb
), 0 },
239 /*92*/ { "setb", TRUE
, NONE
, op1(Eb
), 0 },
240 /*93*/ { "setnb", TRUE
, NONE
, op1(Eb
), 0 },
241 /*94*/ { "setz", TRUE
, NONE
, op1(Eb
), 0 },
242 /*95*/ { "setnz", TRUE
, NONE
, op1(Eb
), 0 },
243 /*96*/ { "setbe", TRUE
, NONE
, op1(Eb
), 0 },
244 /*97*/ { "setnbe",TRUE
, NONE
, op1(Eb
), 0 },
246 /*98*/ { "sets", TRUE
, NONE
, op1(Eb
), 0 },
247 /*99*/ { "setns", TRUE
, NONE
, op1(Eb
), 0 },
248 /*9a*/ { "setp", TRUE
, NONE
, op1(Eb
), 0 },
249 /*9b*/ { "setnp", TRUE
, NONE
, op1(Eb
), 0 },
250 /*9c*/ { "setl", TRUE
, NONE
, op1(Eb
), 0 },
251 /*9d*/ { "setnl", TRUE
, NONE
, op1(Eb
), 0 },
252 /*9e*/ { "setle", TRUE
, NONE
, op1(Eb
), 0 },
253 /*9f*/ { "setnle",TRUE
, NONE
, op1(Eb
), 0 },
256 static const struct inst db_inst_0fax
[] = {
257 /*a0*/ { "push", FALSE
, NONE
, op1(Si
), 0 },
258 /*a1*/ { "pop", FALSE
, NONE
, op1(Si
), 0 },
259 /*a2*/ { "cpuid", FALSE
, NONE
, 0, 0 },
260 /*a3*/ { "bt", TRUE
, LONG
, op2(R
,E
), 0 },
261 /*a4*/ { "shld", TRUE
, LONG
, op3(Ib
,R
,E
), 0 },
262 /*a5*/ { "shld", TRUE
, LONG
, op3(CL
,R
,E
), 0 },
263 /*a6*/ { "", FALSE
, NONE
, 0, 0 },
264 /*a7*/ { "", FALSE
, NONE
, 0, 0 },
266 /*a8*/ { "push", FALSE
, NONE
, op1(Si
), 0 },
267 /*a9*/ { "pop", FALSE
, NONE
, op1(Si
), 0 },
268 /*aa*/ { "rsm", FALSE
, NONE
, 0, 0 },
269 /*ab*/ { "bts", TRUE
, LONG
, op2(R
,E
), 0 },
270 /*ac*/ { "shrd", TRUE
, LONG
, op3(Ib
,R
,E
), 0 },
271 /*ad*/ { "shrd", TRUE
, LONG
, op3(CL
,R
,E
), 0 },
272 /*a6*/ { "", FALSE
, NONE
, 0, 0 },
273 /*a7*/ { "imul", TRUE
, LONG
, op2(E
,R
), 0 },
276 static const struct inst db_inst_0fbx
[] = {
277 /*b0*/ { "cmpxchg",TRUE
, BYTE
, op2(R
, E
), 0 },
278 /*b0*/ { "cmpxchg",TRUE
, LONG
, op2(R
, E
), 0 },
279 /*b2*/ { "lss", TRUE
, LONG
, op2(E
, R
), 0 },
280 /*b3*/ { "btr", TRUE
, LONG
, op2(R
, E
), 0 },
281 /*b4*/ { "lfs", TRUE
, LONG
, op2(E
, R
), 0 },
282 /*b5*/ { "lgs", TRUE
, LONG
, op2(E
, R
), 0 },
283 /*b6*/ { "movzb", TRUE
, LONG
, op2(Eb
, R
), 0 },
284 /*b7*/ { "movzw", TRUE
, LONG
, op2(Ew
, R
), 0 },
286 /*b8*/ { "", FALSE
, NONE
, 0, 0 },
287 /*b9*/ { "", FALSE
, NONE
, 0, 0 },
288 /*ba*/ { "", TRUE
, LONG
, op2(Ib
, E
), db_Grp8
},
289 /*bb*/ { "btc", TRUE
, LONG
, op2(R
, E
), 0 },
290 /*bc*/ { "bsf", TRUE
, LONG
, op2(E
, R
), 0 },
291 /*bd*/ { "bsr", TRUE
, LONG
, op2(E
, R
), 0 },
292 /*be*/ { "movsb", TRUE
, LONG
, op2(Eb
, R
), 0 },
293 /*bf*/ { "movsw", TRUE
, LONG
, op2(Ew
, R
), 0 },
296 static const struct inst db_inst_0fcx
[] = {
297 /*c0*/ { "xadd", TRUE
, BYTE
, op2(R
, E
), 0 },
298 /*c1*/ { "xadd", TRUE
, LONG
, op2(R
, E
), 0 },
299 /*c2*/ { "", FALSE
, NONE
, 0, 0 },
300 /*c3*/ { "", FALSE
, NONE
, 0, 0 },
301 /*c4*/ { "", FALSE
, NONE
, 0, 0 },
302 /*c5*/ { "", FALSE
, NONE
, 0, 0 },
303 /*c6*/ { "", FALSE
, NONE
, 0, 0 },
304 /*c7*/ { "", TRUE
, NONE
, op1(E
), db_Grp9
},
305 /*c8*/ { "bswap", FALSE
, LONG
, op1(Ril
), 0 },
306 /*c9*/ { "bswap", FALSE
, LONG
, op1(Ril
), 0 },
307 /*ca*/ { "bswap", FALSE
, LONG
, op1(Ril
), 0 },
308 /*cb*/ { "bswap", FALSE
, LONG
, op1(Ril
), 0 },
309 /*cc*/ { "bswap", FALSE
, LONG
, op1(Ril
), 0 },
310 /*cd*/ { "bswap", FALSE
, LONG
, op1(Ril
), 0 },
311 /*ce*/ { "bswap", FALSE
, LONG
, op1(Ril
), 0 },
312 /*cf*/ { "bswap", FALSE
, LONG
, op1(Ril
), 0 },
315 static const struct inst
* const db_inst_0f
[] = {
334 static const char * const db_Esc92
[] = {
335 "fnop", "", "", "", "", "", "", ""
337 static const char * const db_Esc94
[] = {
338 "fchs", "fabs", "", "", "ftst", "fxam", "", ""
340 static const char * const db_Esc95
[] = {
341 "fld1", "fldl2t","fldl2e","fldpi","fldlg2","fldln2","fldz",""
343 static const char * const db_Esc96
[] = {
344 "f2xm1","fyl2x","fptan","fpatan","fxtract","fprem1","fdecstp",
347 static const char * const db_Esc97
[] = {
348 "fprem","fyl2xp1","fsqrt","fsincos","frndint","fscale","fsin","fcos"
351 static const char * const db_Esca5
[] = {
352 "", "fucompp","", "", "", "", "", ""
355 static const char * const db_Escb4
[] = {
356 "fneni","fndisi", "fnclex","fninit","fsetpm", "", "", ""
359 static const char * const db_Esce3
[] = {
360 "", "fcompp","", "", "", "", "", ""
363 static const char * const db_Escf4
[] = {
364 "fnstsw","", "", "", "", "", "", ""
367 static const struct finst db_Esc8
[] = {
368 /*0*/ { "fadd", SNGL
, op2(STI
,ST
), 0 },
369 /*1*/ { "fmul", SNGL
, op2(STI
,ST
), 0 },
370 /*2*/ { "fcom", SNGL
, op2(STI
,ST
), 0 },
371 /*3*/ { "fcomp", SNGL
, op2(STI
,ST
), 0 },
372 /*4*/ { "fsub", SNGL
, op2(STI
,ST
), 0 },
373 /*5*/ { "fsubr", SNGL
, op2(STI
,ST
), 0 },
374 /*6*/ { "fdiv", SNGL
, op2(STI
,ST
), 0 },
375 /*7*/ { "fdivr", SNGL
, op2(STI
,ST
), 0 },
378 static const struct finst db_Esc9
[] = {
379 /*0*/ { "fld", SNGL
, op1(STI
), 0 },
380 /*1*/ { "", NONE
, op1(STI
), "fxch" },
381 /*2*/ { "fst", SNGL
, op1(X
), db_Esc92
},
382 /*3*/ { "fstp", SNGL
, 0, 0 },
383 /*4*/ { "fldenv", NONE
, op1(X
), db_Esc94
},
384 /*5*/ { "fldcw", NONE
, op1(X
), db_Esc95
},
385 /*6*/ { "fnstenv",NONE
, op1(X
), db_Esc96
},
386 /*7*/ { "fnstcw", NONE
, op1(X
), db_Esc97
},
389 static const struct finst db_Esca
[] = {
390 /*0*/ { "fiadd", LONG
, 0, 0 },
391 /*1*/ { "fimul", LONG
, 0, 0 },
392 /*2*/ { "ficom", LONG
, 0, 0 },
393 /*3*/ { "ficomp", LONG
, 0, 0 },
394 /*4*/ { "fisub", LONG
, 0, 0 },
395 /*5*/ { "fisubr", LONG
, op1(X
), db_Esca5
},
396 /*6*/ { "fidiv", LONG
, 0, 0 },
397 /*7*/ { "fidivr", LONG
, 0, 0 }
400 static const struct finst db_Escb
[] = {
401 /*0*/ { "fild", LONG
, 0, 0 },
402 /*1*/ { "", NONE
, 0, 0 },
403 /*2*/ { "fist", LONG
, 0, 0 },
404 /*3*/ { "fistp", LONG
, 0, 0 },
405 /*4*/ { "", WORD
, op1(X
), db_Escb4
},
406 /*5*/ { "fld", EXTR
, 0, 0 },
407 /*6*/ { "", WORD
, 0, 0 },
408 /*7*/ { "fstp", EXTR
, 0, 0 },
411 static const struct finst db_Escc
[] = {
412 /*0*/ { "fadd", DBLR
, op2(ST
,STI
), 0 },
413 /*1*/ { "fmul", DBLR
, op2(ST
,STI
), 0 },
414 /*2*/ { "fcom", DBLR
, 0, 0 },
415 /*3*/ { "fcomp", DBLR
, 0, 0 },
416 /*4*/ { "fsub", DBLR
, op2(ST
,STI
), "fsubr" },
417 /*5*/ { "fsubr", DBLR
, op2(ST
,STI
), "fsub" },
418 /*6*/ { "fdiv", DBLR
, op2(ST
,STI
), "fdivr" },
419 /*7*/ { "fdivr", DBLR
, op2(ST
,STI
), "fdiv" },
422 static const struct finst db_Escd
[] = {
423 /*0*/ { "fld", DBLR
, op1(STI
), "ffree" },
424 /*1*/ { "", NONE
, 0, 0 },
425 /*2*/ { "fst", DBLR
, op1(STI
), 0 },
426 /*3*/ { "fstp", DBLR
, op1(STI
), 0 },
427 /*4*/ { "frstor", NONE
, op1(STI
), "fucom" },
428 /*5*/ { "", NONE
, op1(STI
), "fucomp" },
429 /*6*/ { "fnsave", NONE
, 0, 0 },
430 /*7*/ { "fnstsw", NONE
, 0, 0 },
433 static const struct finst db_Esce
[] = {
434 /*0*/ { "fiadd", WORD
, op2(ST
,STI
), "faddp" },
435 /*1*/ { "fimul", WORD
, op2(ST
,STI
), "fmulp" },
436 /*2*/ { "ficom", WORD
, 0, 0 },
437 /*3*/ { "ficomp", WORD
, op1(X
), db_Esce3
},
438 /*4*/ { "fisub", WORD
, op2(ST
,STI
), "fsubrp" },
439 /*5*/ { "fisubr", WORD
, op2(ST
,STI
), "fsubp" },
440 /*6*/ { "fidiv", WORD
, op2(ST
,STI
), "fdivrp" },
441 /*7*/ { "fidivr", WORD
, op2(ST
,STI
), "fdivp" },
444 static const struct finst db_Escf
[] = {
445 /*0*/ { "fild", WORD
, 0, 0 },
446 /*1*/ { "", NONE
, 0, 0 },
447 /*2*/ { "fist", WORD
, 0, 0 },
448 /*3*/ { "fistp", WORD
, 0, 0 },
449 /*4*/ { "fbld", NONE
, op1(XA
), db_Escf4
},
450 /*5*/ { "fild", QUAD
, 0, 0 },
451 /*6*/ { "fbstp", NONE
, 0, 0 },
452 /*7*/ { "fistp", QUAD
, 0, 0 },
455 static const struct finst
* const db_Esc_inst
[] = {
456 db_Esc8
, db_Esc9
, db_Esca
, db_Escb
,
457 db_Escc
, db_Escd
, db_Esce
, db_Escf
460 static const char * const db_Grp1
[] = {
471 static const char * const db_Grp2
[] = {
482 static const struct inst db_Grp3
[] = {
483 { "test", TRUE
, NONE
, op2(I
,E
), 0 },
484 { "test", TRUE
, NONE
, op2(I
,E
), 0 },
485 { "not", TRUE
, NONE
, op1(E
), 0 },
486 { "neg", TRUE
, NONE
, op1(E
), 0 },
487 { "mul", TRUE
, NONE
, op2(E
,A
), 0 },
488 { "imul", TRUE
, NONE
, op2(E
,A
), 0 },
489 { "div", TRUE
, NONE
, op2(E
,A
), 0 },
490 { "idiv", TRUE
, NONE
, op2(E
,A
), 0 },
493 static const struct inst db_Grp4
[] = {
494 { "inc", TRUE
, BYTE
, op1(E
), 0 },
495 { "dec", TRUE
, BYTE
, op1(E
), 0 },
496 { "", TRUE
, NONE
, 0, 0 },
497 { "", TRUE
, NONE
, 0, 0 },
498 { "", TRUE
, NONE
, 0, 0 },
499 { "", TRUE
, NONE
, 0, 0 },
500 { "", TRUE
, NONE
, 0, 0 },
501 { "", TRUE
, NONE
, 0, 0 }
504 static const struct inst db_Grp5
[] = {
505 { "inc", TRUE
, LONG
, op1(E
), 0 },
506 { "dec", TRUE
, LONG
, op1(E
), 0 },
507 { "call", TRUE
, LONG
, op1(Eind
),0 },
508 { "lcall", TRUE
, LONG
, op1(Eind
),0 },
509 { "jmp", TRUE
, LONG
, op1(Eind
),0 },
510 { "ljmp", TRUE
, LONG
, op1(Eind
),0 },
511 { "push", TRUE
, LONG
, op1(E
), 0 },
512 { "", TRUE
, NONE
, 0, 0 }
515 static const struct inst db_inst_table
[256] = {
516 /*00*/ { "add", TRUE
, BYTE
, op2(R
, E
), 0 },
517 /*01*/ { "add", TRUE
, LONG
, op2(R
, E
), 0 },
518 /*02*/ { "add", TRUE
, BYTE
, op2(E
, R
), 0 },
519 /*03*/ { "add", TRUE
, LONG
, op2(E
, R
), 0 },
520 /*04*/ { "add", FALSE
, BYTE
, op2(I
, A
), 0 },
521 /*05*/ { "add", FALSE
, LONG
, op2(Is
, A
), 0 },
522 /*06*/ { "push", FALSE
, NONE
, op1(Si
), 0 },
523 /*07*/ { "pop", FALSE
, NONE
, op1(Si
), 0 },
525 /*08*/ { "or", TRUE
, BYTE
, op2(R
, E
), 0 },
526 /*09*/ { "or", TRUE
, LONG
, op2(R
, E
), 0 },
527 /*0a*/ { "or", TRUE
, BYTE
, op2(E
, R
), 0 },
528 /*0b*/ { "or", TRUE
, LONG
, op2(E
, R
), 0 },
529 /*0c*/ { "or", FALSE
, BYTE
, op2(I
, A
), 0 },
530 /*0d*/ { "or", FALSE
, LONG
, op2(I
, A
), 0 },
531 /*0e*/ { "push", FALSE
, NONE
, op1(Si
), 0 },
532 /*0f*/ { "", FALSE
, NONE
, 0, 0 },
534 /*10*/ { "adc", TRUE
, BYTE
, op2(R
, E
), 0 },
535 /*11*/ { "adc", TRUE
, LONG
, op2(R
, E
), 0 },
536 /*12*/ { "adc", TRUE
, BYTE
, op2(E
, R
), 0 },
537 /*13*/ { "adc", TRUE
, LONG
, op2(E
, R
), 0 },
538 /*14*/ { "adc", FALSE
, BYTE
, op2(I
, A
), 0 },
539 /*15*/ { "adc", FALSE
, LONG
, op2(Is
, A
), 0 },
540 /*16*/ { "push", FALSE
, NONE
, op1(Si
), 0 },
541 /*17*/ { "pop", FALSE
, NONE
, op1(Si
), 0 },
543 /*18*/ { "sbb", TRUE
, BYTE
, op2(R
, E
), 0 },
544 /*19*/ { "sbb", TRUE
, LONG
, op2(R
, E
), 0 },
545 /*1a*/ { "sbb", TRUE
, BYTE
, op2(E
, R
), 0 },
546 /*1b*/ { "sbb", TRUE
, LONG
, op2(E
, R
), 0 },
547 /*1c*/ { "sbb", FALSE
, BYTE
, op2(I
, A
), 0 },
548 /*1d*/ { "sbb", FALSE
, LONG
, op2(Is
, A
), 0 },
549 /*1e*/ { "push", FALSE
, NONE
, op1(Si
), 0 },
550 /*1f*/ { "pop", FALSE
, NONE
, op1(Si
), 0 },
552 /*20*/ { "and", TRUE
, BYTE
, op2(R
, E
), 0 },
553 /*21*/ { "and", TRUE
, LONG
, op2(R
, E
), 0 },
554 /*22*/ { "and", TRUE
, BYTE
, op2(E
, R
), 0 },
555 /*23*/ { "and", TRUE
, LONG
, op2(E
, R
), 0 },
556 /*24*/ { "and", FALSE
, BYTE
, op2(I
, A
), 0 },
557 /*25*/ { "and", FALSE
, LONG
, op2(I
, A
), 0 },
558 /*26*/ { "", FALSE
, NONE
, 0, 0 },
559 /*27*/ { "daa", FALSE
, NONE
, 0, 0 },
561 /*28*/ { "sub", TRUE
, BYTE
, op2(R
, E
), 0 },
562 /*29*/ { "sub", TRUE
, LONG
, op2(R
, E
), 0 },
563 /*2a*/ { "sub", TRUE
, BYTE
, op2(E
, R
), 0 },
564 /*2b*/ { "sub", TRUE
, LONG
, op2(E
, R
), 0 },
565 /*2c*/ { "sub", FALSE
, BYTE
, op2(I
, A
), 0 },
566 /*2d*/ { "sub", FALSE
, LONG
, op2(Is
, A
), 0 },
567 /*2e*/ { "", FALSE
, NONE
, 0, 0 },
568 /*2f*/ { "das", FALSE
, NONE
, 0, 0 },
570 /*30*/ { "xor", TRUE
, BYTE
, op2(R
, E
), 0 },
571 /*31*/ { "xor", TRUE
, LONG
, op2(R
, E
), 0 },
572 /*32*/ { "xor", TRUE
, BYTE
, op2(E
, R
), 0 },
573 /*33*/ { "xor", TRUE
, LONG
, op2(E
, R
), 0 },
574 /*34*/ { "xor", FALSE
, BYTE
, op2(I
, A
), 0 },
575 /*35*/ { "xor", FALSE
, LONG
, op2(I
, A
), 0 },
576 /*36*/ { "", FALSE
, NONE
, 0, 0 },
577 /*37*/ { "aaa", FALSE
, NONE
, 0, 0 },
579 /*38*/ { "cmp", TRUE
, BYTE
, op2(R
, E
), 0 },
580 /*39*/ { "cmp", TRUE
, LONG
, op2(R
, E
), 0 },
581 /*3a*/ { "cmp", TRUE
, BYTE
, op2(E
, R
), 0 },
582 /*3b*/ { "cmp", TRUE
, LONG
, op2(E
, R
), 0 },
583 /*3c*/ { "cmp", FALSE
, BYTE
, op2(I
, A
), 0 },
584 /*3d*/ { "cmp", FALSE
, LONG
, op2(Is
, A
), 0 },
585 /*3e*/ { "", FALSE
, NONE
, 0, 0 },
586 /*3f*/ { "aas", FALSE
, NONE
, 0, 0 },
588 /*40*/ { "inc", FALSE
, LONG
, op1(Ri
), 0 },
589 /*41*/ { "inc", FALSE
, LONG
, op1(Ri
), 0 },
590 /*42*/ { "inc", FALSE
, LONG
, op1(Ri
), 0 },
591 /*43*/ { "inc", FALSE
, LONG
, op1(Ri
), 0 },
592 /*44*/ { "inc", FALSE
, LONG
, op1(Ri
), 0 },
593 /*45*/ { "inc", FALSE
, LONG
, op1(Ri
), 0 },
594 /*46*/ { "inc", FALSE
, LONG
, op1(Ri
), 0 },
595 /*47*/ { "inc", FALSE
, LONG
, op1(Ri
), 0 },
597 /*48*/ { "dec", FALSE
, LONG
, op1(Ri
), 0 },
598 /*49*/ { "dec", FALSE
, LONG
, op1(Ri
), 0 },
599 /*4a*/ { "dec", FALSE
, LONG
, op1(Ri
), 0 },
600 /*4b*/ { "dec", FALSE
, LONG
, op1(Ri
), 0 },
601 /*4c*/ { "dec", FALSE
, LONG
, op1(Ri
), 0 },
602 /*4d*/ { "dec", FALSE
, LONG
, op1(Ri
), 0 },
603 /*4e*/ { "dec", FALSE
, LONG
, op1(Ri
), 0 },
604 /*4f*/ { "dec", FALSE
, LONG
, op1(Ri
), 0 },
606 /*50*/ { "push", FALSE
, LONG
, op1(Ri
), 0 },
607 /*51*/ { "push", FALSE
, LONG
, op1(Ri
), 0 },
608 /*52*/ { "push", FALSE
, LONG
, op1(Ri
), 0 },
609 /*53*/ { "push", FALSE
, LONG
, op1(Ri
), 0 },
610 /*54*/ { "push", FALSE
, LONG
, op1(Ri
), 0 },
611 /*55*/ { "push", FALSE
, LONG
, op1(Ri
), 0 },
612 /*56*/ { "push", FALSE
, LONG
, op1(Ri
), 0 },
613 /*57*/ { "push", FALSE
, LONG
, op1(Ri
), 0 },
615 /*58*/ { "pop", FALSE
, LONG
, op1(Ri
), 0 },
616 /*59*/ { "pop", FALSE
, LONG
, op1(Ri
), 0 },
617 /*5a*/ { "pop", FALSE
, LONG
, op1(Ri
), 0 },
618 /*5b*/ { "pop", FALSE
, LONG
, op1(Ri
), 0 },
619 /*5c*/ { "pop", FALSE
, LONG
, op1(Ri
), 0 },
620 /*5d*/ { "pop", FALSE
, LONG
, op1(Ri
), 0 },
621 /*5e*/ { "pop", FALSE
, LONG
, op1(Ri
), 0 },
622 /*5f*/ { "pop", FALSE
, LONG
, op1(Ri
), 0 },
624 /*60*/ { "pusha", FALSE
, LONG
, 0, 0 },
625 /*61*/ { "popa", FALSE
, LONG
, 0, 0 },
626 /*62*/ { "bound", TRUE
, LONG
, op2(E
, R
), 0 },
627 /*63*/ { "arpl", TRUE
, NONE
, op2(Rw
,Ew
), 0 },
629 /*64*/ { "", FALSE
, NONE
, 0, 0 },
630 /*65*/ { "", FALSE
, NONE
, 0, 0 },
631 /*66*/ { "", FALSE
, NONE
, 0, 0 },
632 /*67*/ { "", FALSE
, NONE
, 0, 0 },
634 /*68*/ { "push", FALSE
, LONG
, op1(I
), 0 },
635 /*69*/ { "imul", TRUE
, LONG
, op3(I
,E
,R
), 0 },
636 /*6a*/ { "push", FALSE
, LONG
, op1(Ibs
), 0 },
637 /*6b*/ { "imul", TRUE
, LONG
, op3(Ibs
,E
,R
),0 },
638 /*6c*/ { "ins", FALSE
, BYTE
, op2(DX
, DI
), 0 },
639 /*6d*/ { "ins", FALSE
, LONG
, op2(DX
, DI
), 0 },
640 /*6e*/ { "outs", FALSE
, BYTE
, op2(SI
, DX
), 0 },
641 /*6f*/ { "outs", FALSE
, LONG
, op2(SI
, DX
), 0 },
643 /*70*/ { "jo", FALSE
, NONE
, op1(Db
), 0 },
644 /*71*/ { "jno", FALSE
, NONE
, op1(Db
), 0 },
645 /*72*/ { "jb", FALSE
, NONE
, op1(Db
), 0 },
646 /*73*/ { "jnb", FALSE
, NONE
, op1(Db
), 0 },
647 /*74*/ { "jz", FALSE
, NONE
, op1(Db
), 0 },
648 /*75*/ { "jnz", FALSE
, NONE
, op1(Db
), 0 },
649 /*76*/ { "jbe", FALSE
, NONE
, op1(Db
), 0 },
650 /*77*/ { "jnbe", FALSE
, NONE
, op1(Db
), 0 },
652 /*78*/ { "js", FALSE
, NONE
, op1(Db
), 0 },
653 /*79*/ { "jns", FALSE
, NONE
, op1(Db
), 0 },
654 /*7a*/ { "jp", FALSE
, NONE
, op1(Db
), 0 },
655 /*7b*/ { "jnp", FALSE
, NONE
, op1(Db
), 0 },
656 /*7c*/ { "jl", FALSE
, NONE
, op1(Db
), 0 },
657 /*7d*/ { "jnl", FALSE
, NONE
, op1(Db
), 0 },
658 /*7e*/ { "jle", FALSE
, NONE
, op1(Db
), 0 },
659 /*7f*/ { "jnle", FALSE
, NONE
, op1(Db
), 0 },
661 /*80*/ { "", TRUE
, BYTE
, op2(I
, E
), db_Grp1
},
662 /*81*/ { "", TRUE
, LONG
, op2(I
, E
), db_Grp1
},
663 /*82*/ { "", TRUE
, BYTE
, op2(I
, E
), db_Grp1
},
664 /*83*/ { "", TRUE
, LONG
, op2(Ibs
,E
), db_Grp1
},
665 /*84*/ { "test", TRUE
, BYTE
, op2(R
, E
), 0 },
666 /*85*/ { "test", TRUE
, LONG
, op2(R
, E
), 0 },
667 /*86*/ { "xchg", TRUE
, BYTE
, op2(R
, E
), 0 },
668 /*87*/ { "xchg", TRUE
, LONG
, op2(R
, E
), 0 },
670 /*88*/ { "mov", TRUE
, BYTE
, op2(R
, E
), 0 },
671 /*89*/ { "mov", TRUE
, LONG
, op2(R
, E
), 0 },
672 /*8a*/ { "mov", TRUE
, BYTE
, op2(E
, R
), 0 },
673 /*8b*/ { "mov", TRUE
, LONG
, op2(E
, R
), 0 },
674 /*8c*/ { "mov", TRUE
, NONE
, op2(S
, Ew
), 0 },
675 /*8d*/ { "lea", TRUE
, LONG
, op2(E
, R
), 0 },
676 /*8e*/ { "mov", TRUE
, NONE
, op2(Ew
, S
), 0 },
677 /*8f*/ { "pop", TRUE
, LONG
, op1(E
), 0 },
679 /*90*/ { "nop", FALSE
, NONE
, 0, 0 },
680 /*91*/ { "xchg", FALSE
, LONG
, op2(A
, Ri
), 0 },
681 /*92*/ { "xchg", FALSE
, LONG
, op2(A
, Ri
), 0 },
682 /*93*/ { "xchg", FALSE
, LONG
, op2(A
, Ri
), 0 },
683 /*94*/ { "xchg", FALSE
, LONG
, op2(A
, Ri
), 0 },
684 /*95*/ { "xchg", FALSE
, LONG
, op2(A
, Ri
), 0 },
685 /*96*/ { "xchg", FALSE
, LONG
, op2(A
, Ri
), 0 },
686 /*97*/ { "xchg", FALSE
, LONG
, op2(A
, Ri
), 0 },
688 /*98*/ { "cbw", FALSE
, SDEP
, 0, "cwde" }, /* cbw/cwde */
689 /*99*/ { "cwd", FALSE
, SDEP
, 0, "cdq" }, /* cwd/cdq */
690 /*9a*/ { "lcall", FALSE
, NONE
, op1(OS
), 0 },
691 /*9b*/ { "wait", FALSE
, NONE
, 0, 0 },
692 /*9c*/ { "pushf", FALSE
, LONG
, 0, 0 },
693 /*9d*/ { "popf", FALSE
, LONG
, 0, 0 },
694 /*9e*/ { "sahf", FALSE
, NONE
, 0, 0 },
695 /*9f*/ { "lahf", FALSE
, NONE
, 0, 0 },
697 /*a0*/ { "mov", FALSE
, BYTE
, op2(O
, A
), 0 },
698 /*a1*/ { "mov", FALSE
, LONG
, op2(O
, A
), 0 },
699 /*a2*/ { "mov", FALSE
, BYTE
, op2(A
, O
), 0 },
700 /*a3*/ { "mov", FALSE
, LONG
, op2(A
, O
), 0 },
701 /*a4*/ { "movs", FALSE
, BYTE
, op2(SI
,DI
), 0 },
702 /*a5*/ { "movs", FALSE
, LONG
, op2(SI
,DI
), 0 },
703 /*a6*/ { "cmps", FALSE
, BYTE
, op2(SI
,DI
), 0 },
704 /*a7*/ { "cmps", FALSE
, LONG
, op2(SI
,DI
), 0 },
706 /*a8*/ { "test", FALSE
, BYTE
, op2(I
, A
), 0 },
707 /*a9*/ { "test", FALSE
, LONG
, op2(I
, A
), 0 },
708 /*aa*/ { "stos", FALSE
, BYTE
, op1(DI
), 0 },
709 /*ab*/ { "stos", FALSE
, LONG
, op1(DI
), 0 },
710 /*ac*/ { "lods", FALSE
, BYTE
, op1(SI
), 0 },
711 /*ad*/ { "lods", FALSE
, LONG
, op1(SI
), 0 },
712 /*ae*/ { "scas", FALSE
, BYTE
, op1(SI
), 0 },
713 /*af*/ { "scas", FALSE
, LONG
, op1(SI
), 0 },
715 /*b0*/ { "mov", FALSE
, BYTE
, op2(I
, Ri
), 0 },
716 /*b1*/ { "mov", FALSE
, BYTE
, op2(I
, Ri
), 0 },
717 /*b2*/ { "mov", FALSE
, BYTE
, op2(I
, Ri
), 0 },
718 /*b3*/ { "mov", FALSE
, BYTE
, op2(I
, Ri
), 0 },
719 /*b4*/ { "mov", FALSE
, BYTE
, op2(I
, Ri
), 0 },
720 /*b5*/ { "mov", FALSE
, BYTE
, op2(I
, Ri
), 0 },
721 /*b6*/ { "mov", FALSE
, BYTE
, op2(I
, Ri
), 0 },
722 /*b7*/ { "mov", FALSE
, BYTE
, op2(I
, Ri
), 0 },
724 /*b8*/ { "mov", FALSE
, LONG
, op2(I
, Ri
), 0 },
725 /*b9*/ { "mov", FALSE
, LONG
, op2(I
, Ri
), 0 },
726 /*ba*/ { "mov", FALSE
, LONG
, op2(I
, Ri
), 0 },
727 /*bb*/ { "mov", FALSE
, LONG
, op2(I
, Ri
), 0 },
728 /*bc*/ { "mov", FALSE
, LONG
, op2(I
, Ri
), 0 },
729 /*bd*/ { "mov", FALSE
, LONG
, op2(I
, Ri
), 0 },
730 /*be*/ { "mov", FALSE
, LONG
, op2(I
, Ri
), 0 },
731 /*bf*/ { "mov", FALSE
, LONG
, op2(I
, Ri
), 0 },
733 /*c0*/ { "", TRUE
, BYTE
, op2(Ib
, E
), db_Grp2
},
734 /*c1*/ { "", TRUE
, LONG
, op2(Ib
, E
), db_Grp2
},
735 /*c2*/ { "ret", FALSE
, NONE
, op1(Iw
), 0 },
736 /*c3*/ { "ret", FALSE
, NONE
, 0, 0 },
737 /*c4*/ { "les", TRUE
, LONG
, op2(E
, R
), 0 },
738 /*c5*/ { "lds", TRUE
, LONG
, op2(E
, R
), 0 },
739 /*c6*/ { "mov", TRUE
, BYTE
, op2(I
, E
), 0 },
740 /*c7*/ { "mov", TRUE
, LONG
, op2(I
, E
), 0 },
742 /*c8*/ { "enter", FALSE
, NONE
, op2(Iw
, Ib
), 0 },
743 /*c9*/ { "leave", FALSE
, NONE
, 0, 0 },
744 /*ca*/ { "lret", FALSE
, NONE
, op1(Iw
), 0 },
745 /*cb*/ { "lret", FALSE
, NONE
, 0, 0 },
746 /*cc*/ { "int", FALSE
, NONE
, op1(o3
), 0 },
747 /*cd*/ { "int", FALSE
, NONE
, op1(Ib
), 0 },
748 /*ce*/ { "into", FALSE
, NONE
, 0, 0 },
749 /*cf*/ { "iret", FALSE
, NONE
, 0, 0 },
751 /*d0*/ { "", TRUE
, BYTE
, op2(o1
, E
), db_Grp2
},
752 /*d1*/ { "", TRUE
, LONG
, op2(o1
, E
), db_Grp2
},
753 /*d2*/ { "", TRUE
, BYTE
, op2(CL
, E
), db_Grp2
},
754 /*d3*/ { "", TRUE
, LONG
, op2(CL
, E
), db_Grp2
},
755 /*d4*/ { "aam", FALSE
, NONE
, op1(Iba
), 0 },
756 /*d5*/ { "aad", FALSE
, NONE
, op1(Iba
), 0 },
757 /*d6*/ { ".byte\t0xd6", FALSE
, NONE
, 0, 0 },
758 /*d7*/ { "xlat", FALSE
, BYTE
, op1(BX
), 0 },
760 /*d8*/ { "", TRUE
, NONE
, 0, db_Esc8
},
761 /*d9*/ { "", TRUE
, NONE
, 0, db_Esc9
},
762 /*da*/ { "", TRUE
, NONE
, 0, db_Esca
},
763 /*db*/ { "", TRUE
, NONE
, 0, db_Escb
},
764 /*dc*/ { "", TRUE
, NONE
, 0, db_Escc
},
765 /*dd*/ { "", TRUE
, NONE
, 0, db_Escd
},
766 /*de*/ { "", TRUE
, NONE
, 0, db_Esce
},
767 /*df*/ { "", TRUE
, NONE
, 0, db_Escf
},
769 /*e0*/ { "loopne",FALSE
, NONE
, op1(Db
), 0 },
770 /*e1*/ { "loope", FALSE
, NONE
, op1(Db
), 0 },
771 /*e2*/ { "loop", FALSE
, NONE
, op1(Db
), 0 },
772 /*e3*/ { "jcxz", FALSE
, SDEP
, op1(Db
), "jecxz" },
773 /*e4*/ { "in", FALSE
, BYTE
, op2(Ib
, A
), 0 },
774 /*e5*/ { "in", FALSE
, LONG
, op2(Ib
, A
) , 0 },
775 /*e6*/ { "out", FALSE
, BYTE
, op2(A
, Ib
), 0 },
776 /*e7*/ { "out", FALSE
, LONG
, op2(A
, Ib
) , 0 },
778 /*e8*/ { "call", FALSE
, NONE
, op1(Dl
), 0 },
779 /*e9*/ { "jmp", FALSE
, NONE
, op1(Dl
), 0 },
780 /*ea*/ { "ljmp", FALSE
, NONE
, op1(OS
), 0 },
781 /*eb*/ { "jmp", FALSE
, NONE
, op1(Db
), 0 },
782 /*ec*/ { "in", FALSE
, BYTE
, op2(DX
, A
), 0 },
783 /*ed*/ { "in", FALSE
, LONG
, op2(DX
, A
) , 0 },
784 /*ee*/ { "out", FALSE
, BYTE
, op2(A
, DX
), 0 },
785 /*ef*/ { "out", FALSE
, LONG
, op2(A
, DX
) , 0 },
787 /*f0*/ { "", FALSE
, NONE
, 0, 0 },
788 /*f1*/ { ".byte\t0xf1", FALSE
, NONE
, 0, 0 },
789 /*f2*/ { "", FALSE
, NONE
, 0, 0 },
790 /*f3*/ { "", FALSE
, NONE
, 0, 0 },
791 /*f4*/ { "hlt", FALSE
, NONE
, 0, 0 },
792 /*f5*/ { "cmc", FALSE
, NONE
, 0, 0 },
793 /*f6*/ { "", TRUE
, BYTE
, 0, db_Grp3
},
794 /*f7*/ { "", TRUE
, LONG
, 0, db_Grp3
},
796 /*f8*/ { "clc", FALSE
, NONE
, 0, 0 },
797 /*f9*/ { "stc", FALSE
, NONE
, 0, 0 },
798 /*fa*/ { "cli", FALSE
, NONE
, 0, 0 },
799 /*fb*/ { "sti", FALSE
, NONE
, 0, 0 },
800 /*fc*/ { "cld", FALSE
, NONE
, 0, 0 },
801 /*fd*/ { "std", FALSE
, NONE
, 0, 0 },
802 /*fe*/ { "", TRUE
, NONE
, 0, db_Grp4
},
803 /*ff*/ { "", TRUE
, NONE
, 0, db_Grp5
},
806 static const struct inst db_bad_inst
=
807 { "???", FALSE
, NONE
, 0, 0 }
810 #define f_mod(byte) ((byte)>>6)
811 #define f_reg(byte) (((byte)>>3)&0x7)
812 #define f_rm(byte) ((byte)&0x7)
814 #define sib_ss(byte) ((byte)>>6)
815 #define sib_index(byte) (((byte)>>3)&0x7)
816 #define sib_base(byte) ((byte)&0x7)
819 int is_reg
; /* if reg, reg number is in 'disp' */
826 static const char * const db_index_reg_16
[8] = {
837 static const char * const db_reg
[3][8] = {
838 {"%al", "%cl", "%dl", "%bl", "%ah", "%ch", "%dh", "%bh"},
839 {"%ax", "%cx", "%dx", "%bx", "%sp", "%bp", "%si", "%di"},
840 {"%eax", "%ecx", "%edx", "%ebx", "%esp", "%ebp", "%esi", "%edi"}
843 static const char * const db_seg_reg
[8] = {
844 "%es", "%cs", "%ss", "%ds", "%fs", "%gs", "", ""
848 * lengths for size attributes
850 static const int db_lengths
[] = {
860 #define get_value_inc(result, loc, size, is_signed) \
861 result = db_get_value((loc), (size), (is_signed)); \
865 // db_disasm_esc __P((db_addr_t loc, int inst, int short_addr,
866 // int size, const char *seg));
867 //static void db_print_address __P((const char *seg, int size,
868 // struct i_addr *addrp));
871 db_read_address
__P((db_addr_t loc
, int short_addr
,
872 int regmodrm
, struct i_addr
*addrp
));
875 * Read address at location and return updated location.
878 db_read_address(loc
, short_addr
, regmodrm
, addrp
)
882 struct i_addr
* addrp
; /* out */
884 int mod
, rm
, sib
, index
, disp
;
886 mod
= f_mod(regmodrm
);
890 addrp
->is_reg
= TRUE
;
894 addrp
->is_reg
= FALSE
;
903 get_value_inc(disp
, loc
, 2, FALSE
);
909 addrp
->base
= db_index_reg_16
[rm
];
913 get_value_inc(disp
, loc
, 1, TRUE
);
916 addrp
->base
= db_index_reg_16
[rm
];
919 get_value_inc(disp
, loc
, 2, FALSE
);
921 addrp
->base
= db_index_reg_16
[rm
];
926 if (mod
!= 3 && rm
== 4) {
927 get_value_inc(sib
, loc
, 1, FALSE
);
929 index
= sib_index(sib
);
931 addrp
->index
= db_reg
[LONG
][index
];
932 addrp
->ss
= sib_ss(sib
);
938 get_value_inc(addrp
->disp
, loc
, 4, FALSE
);
943 addrp
->base
= db_reg
[LONG
][rm
];
948 get_value_inc(disp
, loc
, 1, TRUE
);
950 addrp
->base
= db_reg
[LONG
][rm
];
954 get_value_inc(disp
, loc
, 4, FALSE
);
956 addrp
->base
= db_reg
[LONG
][rm
];
964 * NWT: fault injection routine only. disasm floating-point instruction
965 * and return updated location.
976 const struct finst
* fp
;
978 struct i_addr address
;
981 get_value_inc(regmodrm
, loc
, 1, FALSE
);
982 fp
= &db_Esc_inst
[inst
- 0xd8][f_reg(regmodrm
)];
983 mod
= f_mod(regmodrm
);
985 if (*fp
->f_name
== '\0') {
989 * Normal address modes.
991 loc
= db_read_address(loc
, short_addr
, regmodrm
, &address
);
1011 * 'reg-reg' - special formats
1013 switch (fp
->f_rrmode
) {
1015 name
= (fp
->f_rrname
) ? fp
->f_rrname
: fp
->f_name
;
1018 name
= (fp
->f_rrname
) ? fp
->f_rrname
: fp
->f_name
;
1021 name
= (fp
->f_rrname
) ? fp
->f_rrname
: fp
->f_name
;
1024 name
= ((const char * const *)fp
->f_rrname
)[f_rm(regmodrm
)];
1029 name
= ((const char * const *)fp
->f_rrname
)[f_rm(regmodrm
)];
1042 * Disassemble instruction at 'loc'. 'altfmt' specifies an
1043 * (optional) alternate format. Return address of start of
1047 my_disasm(db_addr_t loc
,
1054 const struct inst
* ip
;
1055 const char * i_name
;
1065 struct i_addr address
;
1067 get_value_inc(inst
, loc
, 1, FALSE
);
1078 case 0x66: /* data16 */
1104 // db_printf("lock ");
1109 // db_printf("repne ");
1114 // db_printf("repe "); /* XXX repe VS rep */
1122 get_value_inc(inst
, loc
, 1, FALSE
);
1126 if (inst
>= 0xd8 && inst
<= 0xdf) {
1127 loc
= my_disasm_esc(loc
, inst
, short_addr
, size
, seg
);
1132 get_value_inc(inst
, loc
, 1, FALSE
);
1133 ip
= db_inst_0f
[inst
>>4];
1142 ip
= &db_inst_table
[inst
];
1144 if (ip
->i_has_modrm
) {
1145 unsigned long prev_loc
=loc
;
1146 extern unsigned long modAddr
;
1148 get_value_inc(regmodrm
, loc
, 1, FALSE
);
1149 loc
= db_read_address(loc
, short_addr
, regmodrm
, &address
);
1152 // printf("modrm at %x, offset %d\n", loc, loc-prev_loc);
1156 i_name
= ip
->i_name
;
1157 i_size
= ip
->i_size
;
1158 i_mode
= ip
->i_mode
;
1160 if (ip
->i_extra
== db_Grp1
|| ip
->i_extra
== db_Grp2
||
1161 ip
->i_extra
== db_Grp6
|| ip
->i_extra
== db_Grp7
||
1162 ip
->i_extra
== db_Grp8
|| ip
->i_extra
== db_Grp9
) {
1163 i_name
= ((const char * const *)ip
->i_extra
)[f_reg(regmodrm
)];
1165 else if (ip
->i_extra
== db_Grp3
) {
1167 ip
= &ip
[f_reg(regmodrm
)];
1168 i_name
= ip
->i_name
;
1169 i_mode
= ip
->i_mode
;
1171 else if (ip
->i_extra
== db_Grp4
|| ip
->i_extra
== db_Grp5
) {
1173 ip
= &ip
[f_reg(regmodrm
)];
1174 i_name
= ip
->i_name
;
1175 i_mode
= ip
->i_mode
;
1176 i_size
= ip
->i_size
;
1179 if (i_size
== SDEP
) {
1182 if (i_size
!= NONE
) {
1183 if (i_size
== BYTE
) {
1186 else if (i_size
== WORD
) {
1193 i_mode
>>= 8, first
= FALSE
)
1196 switch (i_mode
& 0xFF) {
1200 // db_print_address(seg, size, &address);
1206 // db_print_address(seg, size, &address);
1212 // db_print_address(seg, LONG, &address);
1218 // db_print_address(seg, WORD, &address);
1224 // db_print_address(seg, BYTE, &address);
1230 // db_printf("%s", db_reg[size][f_reg(regmodrm)]);
1236 // db_printf("%s", db_reg[WORD][f_reg(regmodrm)]);
1242 // db_printf("%s", db_reg[size][f_rm(inst)]);
1248 // db_printf("%s", db_reg[LONG][f_rm(inst)]);
1254 // db_printf("%s", db_seg_reg[f_reg(regmodrm)]);
1260 // db_printf("%s", db_seg_reg[f_reg(inst)]);
1266 // db_printf("%s", db_reg[size][0]); /* acc */
1295 len
= db_lengths
[size
];
1296 get_value_inc(imm
, loc
, len
, FALSE
);
1300 len
= db_lengths
[size
];
1301 get_value_inc(imm
, loc
, len
, FALSE
);
1303 * XXX the + in this format doesn't seem to work right.
1304 * `Is' is equivalent to `I'.
1309 get_value_inc(imm
, loc
, 1, FALSE
);
1313 get_value_inc(imm
, loc
, 1, FALSE
);
1317 get_value_inc(imm
, loc
, 1, TRUE
);
1323 get_value_inc(imm
, loc
, 2, FALSE
);
1327 len
= (short_addr
? 2 : 4);
1328 get_value_inc(displ
, loc
, len
, FALSE
);
1332 // db_printsym((db_addr_t)displ, DB_STGY_ANY);
1337 get_value_inc(displ
, loc
, 1, TRUE
);
1342 // db_printsym((db_addr_t)displ, DB_STGY_XTRN);
1347 len
= db_lengths
[size
];
1348 get_value_inc(displ
, loc
, len
, FALSE
);
1353 // db_printsym((db_addr_t)displ, DB_STGY_XTRN);
1364 len
= db_lengths
[size
];
1365 get_value_inc(imm
, loc
, len
, FALSE
); /* offset */
1366 get_value_inc(imm2
, loc
, 2, FALSE
); /* segment */