diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2004-02-01 19:13:45 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2004-02-01 19:13:45 +0000 |
commit | cda203a1843ba66095060bf4f2bf811a599bf6fe (patch) | |
tree | 80be9a01bead3eae05eec94a23d44888d960e4c7 /sys/arch/i386 | |
parent | 674770922e1c4de03caa86793ce2b4a44d482978 (diff) |
Merge many freebsd diffs
add VIA c3 crypto instructions
add fxsave, fxrstor
Diffstat (limited to 'sys/arch/i386')
-rw-r--r-- | sys/arch/i386/i386/db_disasm.c | 419 |
1 files changed, 224 insertions, 195 deletions
diff --git a/sys/arch/i386/i386/db_disasm.c b/sys/arch/i386/i386/db_disasm.c index 6eec037a9be..0b7b83e61bf 100644 --- a/sys/arch/i386/i386/db_disasm.c +++ b/sys/arch/i386/i386/db_disasm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: db_disasm.c,v 1.9 2003/02/26 18:25:29 tedu Exp $ */ +/* $OpenBSD: db_disasm.c,v 1.10 2004/02/01 19:13:44 deraadt Exp $ */ /* $NetBSD: db_disasm.c,v 1.11 1996/05/03 19:41:58 christos Exp $ */ /* @@ -80,7 +80,6 @@ #define Ib 21 /* byte immediate, unsigned */ #define Ibs 22 /* byte immediate, signed */ #define Iw 23 /* word immediate, unsigned */ -#define Il 24 /* long immediate */ #define O 25 /* direct address */ #define Db 26 /* byte displacement from EIP */ #define Dl 27 /* long displacement from EIP */ @@ -91,13 +90,16 @@ #define STI 32 /* FP stack */ #define X 33 /* extended FP op */ #define XA 34 /* for 'fstcw %ax' */ +#define El 35 /* address, long size */ +#define Ril 36 /* long register in instruction */ +#define Iba 37 /* byte immediate, don't print if 0xa */ struct inst { char * i_name; /* name */ short i_has_modrm; /* has regmodrm byte */ short i_size; /* operand size */ int i_mode; /* addressing modes */ - char * i_extra; /* pointer to extra opcode table */ + void * i_extra; /* pointer to extra opcode table */ }; #define op1(x) (x) @@ -108,46 +110,43 @@ struct finst { char * f_name; /* name for memory instruction */ int f_size; /* size for memory instruction */ int f_rrmode; /* mode for rr instruction */ - char * f_rrname; /* name for rr instruction + void * f_rrname; /* name for rr instruction (or pointer to table) */ }; char * db_Grp6[] = { - "sldt", - "str", - "lldt", - "ltr", - "verr", - "verw", - "", - "" + "sldt", "str", "lldt", "ltr", + "verr", "verw", "", "" }; char * db_Grp7[] = { - "sgdt", - "sidt", - "lgdt", - "lidt", - "smsw", - "", - "lmsw", - "invlpg" + "sgdt", "sidt", "lgdt", "lidt", + "smsw", "", "lmsw", "invlpg" }; char * db_Grp8[] = { - "", - "", - "", - "", - "bt", - "bts", - "btr", - "btc" + "", "", "", "", + "bt", "bts", "btr", "btc" +}; + +char * db_Grp9[] = { + "fxsave", "fxrstor", "", "", + "", "", "", "" +}; + +char * db_GrpA[] = { + "", "cmpxchg8b", "", "", + "", "", "", "" +}; + +char * db_GrpB[] = { + "xstore-rng", "xcrypt-ecb", "xcrypt-cbc", "", + "xcrypt-cfb", "xcrypt-ofb", "", "" }; struct inst db_inst_0f0x[] = { -/*00*/ { "", TRUE, NONE, op1(Ew), (char *)db_Grp6 }, -/*01*/ { "", TRUE, NONE, op1(Ew), (char *)db_Grp7 }, +/*00*/ { "", TRUE, NONE, op1(Ew), db_Grp6 }, +/*01*/ { "", TRUE, NONE, op1(Ew), db_Grp7 }, /*02*/ { "lar", TRUE, LONG, op2(E,R), 0 }, /*03*/ { "lsl", TRUE, LONG, op2(E,R), 0 }, /*04*/ { "", FALSE, NONE, 0, 0 }, @@ -185,6 +184,26 @@ struct inst db_inst_0f2x[] = { /*2f*/ { "", FALSE, NONE, 0, 0 }, }; +struct inst db_inst_0f3x[] = { +/*30*/ { "wrmsr", FALSE, NONE, 0, 0 }, +/*31*/ { "rdtsc", FALSE, NONE, 0, 0 }, +/*32*/ { "rdmsr", FALSE, NONE, 0, 0 }, +/*33*/ { "rdpmc", FALSE, NONE, 0, 0 }, +/*34*/ { "", FALSE, NONE, 0, 0 }, +/*35*/ { "", FALSE, NONE, 0, 0 }, +/*36*/ { "", FALSE, NONE, 0, 0 }, +/*37*/ { "", FALSE, NONE, 0, 0 }, + +/*38*/ { "", FALSE, NONE, 0, 0 }, +/*39*/ { "", FALSE, NONE, 0, 0 }, +/*3a*/ { "", FALSE, NONE, 0, 0 }, +/*3b*/ { "", FALSE, NONE, 0, 0 }, +/*3c*/ { "", FALSE, NONE, 0, 0 }, +/*3d*/ { "", FALSE, NONE, 0, 0 }, +/*3e*/ { "", FALSE, NONE, 0, 0 }, +/*3f*/ { "", FALSE, NONE, 0, 0 }, +}; + struct inst db_inst_0f8x[] = { /*80*/ { "jo", FALSE, NONE, op1(Dl), 0 }, /*81*/ { "jno", FALSE, NONE, op1(Dl), 0 }, @@ -230,10 +249,10 @@ struct inst db_inst_0fax[] = { /*a1*/ { "pop", FALSE, NONE, op1(Si), 0 }, /*a2*/ { "cpuid", FALSE, NONE, 0, 0 }, /*a3*/ { "bt", TRUE, LONG, op2(R,E), 0 }, -/*a4*/ { "shld", TRUE, LONG, op3(Ib,E,R), 0 }, -/*a5*/ { "shld", TRUE, LONG, op3(CL,E,R), 0 }, +/*a4*/ { "shld", TRUE, LONG, op3(Ib,R,E), 0 }, +/*a5*/ { "shld", TRUE, LONG, op3(CL,R,E), 0 }, /*a6*/ { "", FALSE, NONE, 0, 0 }, -/*a7*/ { "", FALSE, NONE, 0, 0 }, +/*a7*/ { "", TRUE, NONE, 0, db_GrpB }, /*a8*/ { "push", FALSE, NONE, op1(Si), 0 }, /*a9*/ { "pop", FALSE, NONE, op1(Si), 0 }, @@ -241,8 +260,8 @@ struct inst db_inst_0fax[] = { /*ab*/ { "bts", TRUE, LONG, op2(R,E), 0 }, /*ac*/ { "shrd", TRUE, LONG, op3(Ib,E,R), 0 }, /*ad*/ { "shrd", TRUE, LONG, op3(CL,E,R), 0 }, -/*a6*/ { "", FALSE, NONE, 0, 0 }, -/*a7*/ { "imul", TRUE, LONG, op2(E,R), 0 }, +/*ae*/ { "", TRUE, NONE, op1(E), db_Grp9 }, +/*af*/ { "imul", TRUE, LONG, op2(E,R), 0 }, }; struct inst db_inst_0fbx[] = { @@ -252,17 +271,17 @@ struct inst db_inst_0fbx[] = { /*b3*/ { "btr", TRUE, LONG, op2(R, E), 0 }, /*b4*/ { "lfs", TRUE, LONG, op2(E, R), 0 }, /*b5*/ { "lgs", TRUE, LONG, op2(E, R), 0 }, -/*b6*/ { "movzb", TRUE, LONG, op2(E, R), 0 }, -/*b7*/ { "movzw", TRUE, LONG, op2(E, R), 0 }, +/*b6*/ { "movzb", TRUE, LONG, op2(Eb, R), 0 }, +/*b7*/ { "movzw", TRUE, LONG, op2(Ew, R), 0 }, /*b8*/ { "", FALSE, NONE, 0, 0 }, /*b9*/ { "", FALSE, NONE, 0, 0 }, -/*ba*/ { "", TRUE, LONG, op2(Ib, E), (char *)db_Grp8 }, +/*ba*/ { "", TRUE, LONG, op2(Ib, E), db_Grp8 }, /*bb*/ { "btc", TRUE, LONG, op2(R, E), 0 }, /*bc*/ { "bsf", TRUE, LONG, op2(E, R), 0 }, /*bd*/ { "bsr", TRUE, LONG, op2(E, R), 0 }, -/*be*/ { "movsb", TRUE, LONG, op2(E, R), 0 }, -/*bf*/ { "movsw", TRUE, LONG, op2(E, R), 0 }, +/*be*/ { "movsb", TRUE, LONG, op2(Eb, R), 0 }, +/*bf*/ { "movsw", TRUE, LONG, op2(Ew, R), 0 }, }; struct inst db_inst_0fcx[] = { @@ -273,89 +292,76 @@ struct inst db_inst_0fcx[] = { /*c4*/ { "", FALSE, NONE, 0, 0 }, /*c5*/ { "", FALSE, NONE, 0, 0 }, /*c6*/ { "", FALSE, NONE, 0, 0 }, -/*c7*/ { "", FALSE, NONE, 0, 0 }, -/*c8*/ { "bswap", FALSE, LONG, op1(Ri), 0 }, -/*c9*/ { "bswap", FALSE, LONG, op1(Ri), 0 }, -/*ca*/ { "bswap", FALSE, LONG, op1(Ri), 0 }, -/*cb*/ { "bswap", FALSE, LONG, op1(Ri), 0 }, -/*cc*/ { "bswap", FALSE, LONG, op1(Ri), 0 }, -/*cd*/ { "bswap", FALSE, LONG, op1(Ri), 0 }, -/*ce*/ { "bswap", FALSE, LONG, op1(Ri), 0 }, -/*cf*/ { "bswap", FALSE, LONG, op1(Ri), 0 }, -}; - -struct inst db_inst_0fdx[] = { -/*c0*/ { "cmpxchg",TRUE, BYTE, op2(R, E), 0 }, -/*c1*/ { "cmpxchg",TRUE, LONG, op2(R, E), 0 }, -/*c2*/ { "", FALSE, NONE, 0, 0 }, -/*c3*/ { "", FALSE, NONE, 0, 0 }, -/*c4*/ { "", FALSE, NONE, 0, 0 }, -/*c5*/ { "", FALSE, NONE, 0, 0 }, -/*c6*/ { "", FALSE, NONE, 0, 0 }, -/*c7*/ { "", FALSE, NONE, 0, 0 }, -/*c8*/ { "", FALSE, NONE, 0, 0 }, -/*c9*/ { "", FALSE, NONE, 0, 0 }, -/*ca*/ { "", FALSE, NONE, 0, 0 }, -/*cb*/ { "", FALSE, NONE, 0, 0 }, -/*cc*/ { "", FALSE, NONE, 0, 0 }, -/*cd*/ { "", FALSE, NONE, 0, 0 }, -/*ce*/ { "", FALSE, NONE, 0, 0 }, -/*cf*/ { "", FALSE, NONE, 0, 0 }, +/*c7*/ { "", TRUE, NONE, op1(E), db_GrpA }, + +/*c8*/ { "bswap", FALSE, LONG, op1(Ril), 0 }, +/*c9*/ { "bswap", FALSE, LONG, op1(Ril), 0 }, +/*ca*/ { "bswap", FALSE, LONG, op1(Ril), 0 }, +/*cb*/ { "bswap", FALSE, LONG, op1(Ril), 0 }, +/*cc*/ { "bswap", FALSE, LONG, op1(Ril), 0 }, +/*cd*/ { "bswap", FALSE, LONG, op1(Ril), 0 }, +/*ce*/ { "bswap", FALSE, LONG, op1(Ril), 0 }, +/*cf*/ { "bswap", FALSE, LONG, op1(Ril), 0 }, }; struct inst *db_inst_0f[] = { db_inst_0f0x, - 0, + NULL, db_inst_0f2x, - 0, - 0, - 0, - 0, - 0, + db_inst_0f3x, + NULL, + NULL, + NULL, + NULL, db_inst_0f8x, db_inst_0f9x, db_inst_0fax, db_inst_0fbx, db_inst_0fcx, - db_inst_0fdx, - 0, - 0 + NULL, + NULL, + NULL }; char * db_Esc92[] = { - "fnop", "", "", "", "", "", "", "" -}; -char * db_Esc93[] = { - "", "", "", "", "", "", "", "" + "fnop", "", "", "", + "", "", "", "" }; char * db_Esc94[] = { - "fchs", "fabs", "", "", "ftst", "fxam", "", "" + "fchs", "fabs", "", "", + "ftst", "fxam", "", "" }; char * db_Esc95[] = { - "fld1", "fldl2t","fldl2e","fldpi","fldlg2","fldln2","fldz","" + "fld1", "fldl2t", "fldl2e", "fldpi", + "fldlg2", "fldln2", "fldz", "" }; char * db_Esc96[] = { - "f2xm1","fyl2x","fptan","fpatan","fxtract","fprem1","fdecstp", - "fincstp" + "f2xm1", "fyl2x", "fptan", "fpatan", + "fxtract", "fprem1", "fdecstp", "fincstp" }; char * db_Esc97[] = { - "fprem","fyl2xp1","fsqrt","fsincos","frndint","fscale","fsin","fcos" + "fprem", "fyl2xp1", "fsqrt", "fsincos", + "frndint", "fscale", "fsin", "fcos" }; -char * db_Esca4[] = { - "", "fucompp","", "", "", "", "", "" +char * db_Esca5[] = { + "", "fucompp", "", "", + "", "", "", "" }; char * db_Escb4[] = { - "", "", "fnclex","fninit","", "", "", "" + "fneni", "fndisi", "fnclex", "fninit", + "fsetpm", "", "", "" }; char * db_Esce3[] = { - "", "fcompp","", "", "", "", "", "" + "", "fcompp", "", "", + "", "", "", "" }; char * db_Escf4[] = { - "fnstsw","", "", "", "", "", "", "" + "fnstsw", "", "", "", + "", "", "", "" }; struct finst db_Esc8[] = { @@ -372,31 +378,31 @@ struct finst db_Esc8[] = { struct finst db_Esc9[] = { /*0*/ { "fld", SNGL, op1(STI), 0 }, /*1*/ { "", NONE, op1(STI), "fxch" }, -/*2*/ { "fst", SNGL, op1(X), (char *)db_Esc92 }, -/*3*/ { "fstp", SNGL, op1(X), (char *)db_Esc93 }, -/*4*/ { "fldenv", NONE, op1(X), (char *)db_Esc94 }, -/*5*/ { "fldcw", NONE, op1(X), (char *)db_Esc95 }, -/*6*/ { "fnstenv",NONE, op1(X), (char *)db_Esc96 }, -/*7*/ { "fnstcw", NONE, op1(X), (char *)db_Esc97 }, +/*2*/ { "fst", SNGL, op1(X), db_Esc92 }, +/*3*/ { "fstp", SNGL, op1(X), 0 }, +/*4*/ { "fldenv", NONE, op1(X), db_Esc94 }, +/*5*/ { "fldcw", NONE, op1(X), db_Esc95 }, +/*6*/ { "fnstenv",NONE, op1(X), db_Esc96 }, +/*7*/ { "fnstcw", NONE, op1(X), db_Esc97 }, }; struct finst db_Esca[] = { -/*0*/ { "fiadd", WORD, 0, 0 }, -/*1*/ { "fimul", WORD, 0, 0 }, -/*2*/ { "ficom", WORD, 0, 0 }, -/*3*/ { "ficomp", WORD, 0, 0 }, -/*4*/ { "fisub", WORD, op1(X), (char *)db_Esca4 }, -/*5*/ { "fisubr", WORD, 0, 0 }, -/*6*/ { "fidiv", WORD, 0, 0 }, -/*7*/ { "fidivr", WORD, 0, 0 } +/*0*/ { "fiadd", LONG, 0, 0 }, +/*1*/ { "fimul", LONG, 0, 0 }, +/*2*/ { "ficom", LONG, 0, 0 }, +/*3*/ { "ficomp", LONG, 0, 0 }, +/*4*/ { "fisub", LONG, op1(X), 0 }, +/*5*/ { "fisubr", LONG, 0, 0 }, +/*6*/ { "fidiv", LONG, 0, 0 }, +/*7*/ { "fidivr", LONG, 0, 0 } }; struct finst db_Escb[] = { -/*0*/ { "fild", WORD, 0, 0 }, +/*0*/ { "fild", LONG, 0, 0 }, /*1*/ { "", NONE, 0, 0 }, -/*2*/ { "fist", WORD, 0, 0 }, -/*3*/ { "fistp", WORD, 0, 0 }, -/*4*/ { "", WORD, op1(X), (char *)db_Escb4 }, +/*2*/ { "fist", LONG, 0, 0 }, +/*3*/ { "fistp", LONG, 0, 0 }, +/*4*/ { "", WORD, op1(X), db_Escb4 }, /*5*/ { "fld", EXTR, 0, 0 }, /*6*/ { "", WORD, 0, 0 }, /*7*/ { "fstp", EXTR, 0, 0 }, @@ -405,8 +411,8 @@ struct finst db_Escb[] = { struct finst db_Escc[] = { /*0*/ { "fadd", DBLR, op2(ST,STI), 0 }, /*1*/ { "fmul", DBLR, op2(ST,STI), 0 }, -/*2*/ { "fcom", DBLR, op2(ST,STI), 0 }, -/*3*/ { "fcomp", DBLR, op2(ST,STI), 0 }, +/*2*/ { "fcom", DBLR, 0, 0 }, +/*3*/ { "fcomp", DBLR, 0, 0 }, /*4*/ { "fsub", DBLR, op2(ST,STI), "fsubr" }, /*5*/ { "fsubr", DBLR, op2(ST,STI), "fsub" }, /*6*/ { "fdiv", DBLR, op2(ST,STI), "fdivr" }, @@ -425,25 +431,25 @@ struct finst db_Escd[] = { }; struct finst db_Esce[] = { -/*0*/ { "fiadd", LONG, op2(ST,STI), "faddp" }, -/*1*/ { "fimul", LONG, op2(ST,STI), "fmulp" }, -/*2*/ { "ficom", LONG, 0, 0 }, -/*3*/ { "ficomp", LONG, op1(X), (char *)db_Esce3 }, -/*4*/ { "fisub", LONG, op2(ST,STI), "fsubrp" }, -/*5*/ { "fisubr", LONG, op2(ST,STI), "fsubp" }, -/*6*/ { "fidiv", LONG, op2(ST,STI), "fdivrp" }, -/*7*/ { "fidivr", LONG, op2(ST,STI), "fdivp" }, +/*0*/ { "fiadd", WORD, op2(ST,STI), "faddp" }, +/*1*/ { "fimul", WORD, op2(ST,STI), "fmulp" }, +/*2*/ { "ficom", WORD, 0, 0 }, +/*3*/ { "ficomp", WORD, op1(X), db_Esce3 }, +/*4*/ { "fisub", WORD, op2(ST,STI), "fsubrp" }, +/*5*/ { "fisubr", WORD, op2(ST,STI), "fsubp" }, +/*6*/ { "fidiv", WORD, op2(ST,STI), "fdivrp" }, +/*7*/ { "fidivr", WORD, op2(ST,STI), "fdivp" }, }; struct finst db_Escf[] = { -/*0*/ { "fild", LONG, 0, 0 }, -/*1*/ { "", LONG, 0, 0 }, -/*2*/ { "fist", LONG, 0, 0 }, -/*3*/ { "fistp", LONG, 0, 0 }, -/*4*/ { "fbld", NONE, op1(XA), (char *)db_Escf4 }, -/*5*/ { "fld", QUAD, 0, 0 }, +/*0*/ { "fild", WORD, 0, 0 }, +/*1*/ { "", WORD, 0, 0 }, +/*2*/ { "fist", WORD, 0, 0 }, +/*3*/ { "fistp", WORD, 0, 0 }, +/*4*/ { "fbld", NONE, op1(XA), db_Escf4 }, +/*5*/ { "fild", QUAD, 0, 0 }, /*6*/ { "fbstp", NONE, 0, 0 }, -/*7*/ { "fstp", QUAD, 0, 0 }, +/*7*/ { "fistp", QUAD, 0, 0 }, }; struct finst *db_Esc_inst[] = { @@ -511,7 +517,7 @@ struct inst db_inst_table[256] = { /*01*/ { "add", TRUE, LONG, op2(R, E), 0 }, /*02*/ { "add", TRUE, BYTE, op2(E, R), 0 }, /*03*/ { "add", TRUE, LONG, op2(E, R), 0 }, -/*04*/ { "add", FALSE, BYTE, op2(Is, A), 0 }, +/*04*/ { "add", FALSE, BYTE, op2(I, A), 0 }, /*05*/ { "add", FALSE, LONG, op2(Is, A), 0 }, /*06*/ { "push", FALSE, NONE, op1(Si), 0 }, /*07*/ { "pop", FALSE, NONE, op1(Si), 0 }, @@ -529,7 +535,7 @@ struct inst db_inst_table[256] = { /*11*/ { "adc", TRUE, LONG, op2(R, E), 0 }, /*12*/ { "adc", TRUE, BYTE, op2(E, R), 0 }, /*13*/ { "adc", TRUE, LONG, op2(E, R), 0 }, -/*14*/ { "adc", FALSE, BYTE, op2(Is, A), 0 }, +/*14*/ { "adc", FALSE, BYTE, op2(I, A), 0 }, /*15*/ { "adc", FALSE, LONG, op2(Is, A), 0 }, /*16*/ { "push", FALSE, NONE, op1(Si), 0 }, /*17*/ { "pop", FALSE, NONE, op1(Si), 0 }, @@ -538,7 +544,7 @@ struct inst db_inst_table[256] = { /*19*/ { "sbb", TRUE, LONG, op2(R, E), 0 }, /*1a*/ { "sbb", TRUE, BYTE, op2(E, R), 0 }, /*1b*/ { "sbb", TRUE, LONG, op2(E, R), 0 }, -/*1c*/ { "sbb", FALSE, BYTE, op2(Is, A), 0 }, +/*1c*/ { "sbb", FALSE, BYTE, op2(I, A), 0 }, /*1d*/ { "sbb", FALSE, LONG, op2(Is, A), 0 }, /*1e*/ { "push", FALSE, NONE, op1(Si), 0 }, /*1f*/ { "pop", FALSE, NONE, op1(Si), 0 }, @@ -556,7 +562,7 @@ struct inst db_inst_table[256] = { /*29*/ { "sub", TRUE, LONG, op2(R, E), 0 }, /*2a*/ { "sub", TRUE, BYTE, op2(E, R), 0 }, /*2b*/ { "sub", TRUE, LONG, op2(E, R), 0 }, -/*2c*/ { "sub", FALSE, BYTE, op2(Is, A), 0 }, +/*2c*/ { "sub", FALSE, BYTE, op2(I, A), 0 }, /*2d*/ { "sub", FALSE, LONG, op2(Is, A), 0 }, /*2e*/ { "", FALSE, NONE, 0, 0 }, /*2f*/ { "das", FALSE, NONE, 0, 0 }, @@ -574,7 +580,7 @@ struct inst db_inst_table[256] = { /*39*/ { "cmp", TRUE, LONG, op2(R, E), 0 }, /*3a*/ { "cmp", TRUE, BYTE, op2(E, R), 0 }, /*3b*/ { "cmp", TRUE, LONG, op2(E, R), 0 }, -/*3c*/ { "cmp", FALSE, BYTE, op2(Is, A), 0 }, +/*3c*/ { "cmp", FALSE, BYTE, op2(I, A), 0 }, /*3d*/ { "cmp", FALSE, LONG, op2(Is, A), 0 }, /*3e*/ { "", FALSE, NONE, 0, 0 }, /*3f*/ { "aas", FALSE, NONE, 0, 0 }, @@ -617,18 +623,17 @@ struct inst db_inst_table[256] = { /*60*/ { "pusha", FALSE, LONG, 0, 0 }, /*61*/ { "popa", FALSE, LONG, 0, 0 }, -/*62*/ { "bound", TRUE, LONG, op2(E, R), 0 }, -/*63*/ { "arpl", TRUE, NONE, op2(Ew,Rw), 0 }, - +/*62*/ { "bound", TRUE, LONG, op2(E, R), 0 }, +/*63*/ { "arpl", TRUE, NONE, op2(Rw,Ew), 0 }, /*64*/ { "", FALSE, NONE, 0, 0 }, /*65*/ { "", FALSE, NONE, 0, 0 }, /*66*/ { "", FALSE, NONE, 0, 0 }, /*67*/ { "", FALSE, NONE, 0, 0 }, /*68*/ { "push", FALSE, LONG, op1(I), 0 }, -/*69*/ { "imul", TRUE, LONG, op3(I,E,R), 0 }, -/*6a*/ { "push", FALSE, LONG, op1(Ib), 0 }, -/*6b*/ { "imul", TRUE, LONG, op3(Ibs,E,R),0 }, +/*69*/ { "imul", TRUE, LONG, op3(I,E,R), 0 }, +/*6a*/ { "push", FALSE, LONG, op1(Ibs), 0 }, +/*6b*/ { "imul", TRUE, LONG, op3(Ibs,E,R),0 }, /*6c*/ { "ins", FALSE, BYTE, op2(DX, DI), 0 }, /*6d*/ { "ins", FALSE, LONG, op2(DX, DI), 0 }, /*6e*/ { "outs", FALSE, BYTE, op2(SI, DX), 0 }, @@ -652,10 +657,10 @@ struct inst db_inst_table[256] = { /*7e*/ { "jle", FALSE, NONE, op1(Db), 0 }, /*7f*/ { "jnle", FALSE, NONE, op1(Db), 0 }, -/*80*/ { "", TRUE, BYTE, op2(I, E), (char *)db_Grp1 }, -/*81*/ { "", TRUE, LONG, op2(I, E), (char *)db_Grp1 }, -/*82*/ { "", TRUE, BYTE, op2(Is,E), (char *)db_Grp1 }, -/*83*/ { "", TRUE, LONG, op2(Ibs,E), (char *)db_Grp1 }, +/*80*/ { "", TRUE, BYTE, op2(I, E), db_Grp1 }, +/*81*/ { "", TRUE, LONG, op2(I, E), db_Grp1 }, +/*82*/ { "", TRUE, BYTE, op2(I, E), db_Grp1 }, +/*83*/ { "", TRUE, LONG, op2(Ibs,E), db_Grp1 }, /*84*/ { "test", TRUE, BYTE, op2(R, E), 0 }, /*85*/ { "test", TRUE, LONG, op2(R, E), 0 }, /*86*/ { "xchg", TRUE, BYTE, op2(R, E), 0 }, @@ -665,7 +670,7 @@ struct inst db_inst_table[256] = { /*89*/ { "mov", TRUE, LONG, op2(R, E), 0 }, /*8a*/ { "mov", TRUE, BYTE, op2(E, R), 0 }, /*8b*/ { "mov", TRUE, LONG, op2(E, R), 0 }, -/*8c*/ { "mov", TRUE, NONE, op2(S, Ew), 0 }, +/*8c*/ { "mov", TRUE, NONE, op2(S, Ew), 0 }, /*8d*/ { "lea", TRUE, LONG, op2(E, R), 0 }, /*8e*/ { "mov", TRUE, NONE, op2(Ew, S), 0 }, /*8f*/ { "pop", TRUE, LONG, op1(E), 0 }, @@ -724,8 +729,8 @@ struct inst db_inst_table[256] = { /*be*/ { "mov", FALSE, LONG, op2(I, Ri), 0 }, /*bf*/ { "mov", FALSE, LONG, op2(I, Ri), 0 }, -/*c0*/ { "", TRUE, BYTE, op2(Ib, E), (char *)db_Grp2 }, -/*c1*/ { "", TRUE, LONG, op2(Ib, E), (char *)db_Grp2 }, +/*c0*/ { "", TRUE, BYTE, op2(Ib, E), db_Grp2 }, +/*c1*/ { "", TRUE, LONG, op2(Ib, E), db_Grp2 }, /*c2*/ { "ret", FALSE, NONE, op1(Iw), 0 }, /*c3*/ { "ret", FALSE, NONE, 0, 0 }, /*c4*/ { "les", TRUE, LONG, op2(E, R), 0 }, @@ -733,7 +738,7 @@ struct inst db_inst_table[256] = { /*c6*/ { "mov", TRUE, BYTE, op2(I, E), 0 }, /*c7*/ { "mov", TRUE, LONG, op2(I, E), 0 }, -/*c8*/ { "enter", FALSE, NONE, op2(Ib, Iw), 0 }, +/*c8*/ { "enter", FALSE, NONE, op2(Iw, Ib), 0 }, /*c9*/ { "leave", FALSE, NONE, 0, 0 }, /*ca*/ { "lret", FALSE, NONE, op1(Iw), 0 }, /*cb*/ { "lret", FALSE, NONE, 0, 0 }, @@ -742,23 +747,23 @@ struct inst db_inst_table[256] = { /*ce*/ { "into", FALSE, NONE, 0, 0 }, /*cf*/ { "iret", FALSE, NONE, 0, 0 }, -/*d0*/ { "", TRUE, BYTE, op2(o1, E), (char *)db_Grp2 }, -/*d1*/ { "", TRUE, LONG, op2(o1, E), (char *)db_Grp2 }, -/*d2*/ { "", TRUE, BYTE, op2(CL, E), (char *)db_Grp2 }, -/*d3*/ { "", TRUE, LONG, op2(CL, E), (char *)db_Grp2 }, -/*d4*/ { "aam", TRUE, NONE, 0, 0 }, -/*d5*/ { "aad", TRUE, NONE, 0, 0 }, -/*d6*/ { "", FALSE, NONE, 0, 0 }, +/*d0*/ { "", TRUE, BYTE, op2(o1, E), db_Grp2 }, +/*d1*/ { "", TRUE, LONG, op2(o1, E), db_Grp2 }, +/*d2*/ { "", TRUE, BYTE, op2(CL, E), db_Grp2 }, +/*d3*/ { "", TRUE, LONG, op2(CL, E), db_Grp2 }, +/*d4*/ { "aam", TRUE, NONE, op1(Iba), 0 }, +/*d5*/ { "aad", TRUE, NONE, op1(Iba), 0 }, +/*d6*/ { ".byte\t0xd6",FALSE, NONE, 0, 0 }, /*d7*/ { "xlat", FALSE, BYTE, op1(BX), 0 }, -/*d8*/ { "", TRUE, NONE, 0, (char *)db_Esc8 }, -/*d9*/ { "", TRUE, NONE, 0, (char *)db_Esc9 }, -/*da*/ { "", TRUE, NONE, 0, (char *)db_Esca }, -/*db*/ { "", TRUE, NONE, 0, (char *)db_Escb }, -/*dc*/ { "", TRUE, NONE, 0, (char *)db_Escc }, -/*dd*/ { "", TRUE, NONE, 0, (char *)db_Escd }, -/*de*/ { "", TRUE, NONE, 0, (char *)db_Esce }, -/*df*/ { "", TRUE, NONE, 0, (char *)db_Escf }, +/*d8*/ { "", TRUE, NONE, 0, db_Esc8 }, +/*d9*/ { "", TRUE, NONE, 0, db_Esc9 }, +/*da*/ { "", TRUE, NONE, 0, db_Esca }, +/*db*/ { "", TRUE, NONE, 0, db_Escb }, +/*dc*/ { "", TRUE, NONE, 0, db_Escc }, +/*dd*/ { "", TRUE, NONE, 0, db_Escd }, +/*de*/ { "", TRUE, NONE, 0, db_Esce }, +/*df*/ { "", TRUE, NONE, 0, db_Escf }, /*e0*/ { "loopne",FALSE, NONE, op1(Db), 0 }, /*e1*/ { "loope", FALSE, NONE, op1(Db), 0 }, @@ -784,8 +789,8 @@ struct inst db_inst_table[256] = { /*f3*/ { "", FALSE, NONE, 0, 0 }, /*f4*/ { "hlt", FALSE, NONE, 0, 0 }, /*f5*/ { "cmc", FALSE, NONE, 0, 0 }, -/*f6*/ { "", TRUE, BYTE, 0, (char *)db_Grp3 }, -/*f7*/ { "", TRUE, LONG, 0, (char *)db_Grp3 }, +/*f6*/ { "", TRUE, BYTE, 0, db_Grp3 }, +/*f7*/ { "", TRUE, LONG, 0, db_Grp3 }, /*f8*/ { "clc", FALSE, NONE, 0, 0 }, /*f9*/ { "stc", FALSE, NONE, 0, 0 }, @@ -793,8 +798,8 @@ struct inst db_inst_table[256] = { /*fb*/ { "sti", FALSE, NONE, 0, 0 }, /*fc*/ { "cld", FALSE, NONE, 0, 0 }, /*fd*/ { "std", FALSE, NONE, 0, 0 }, -/*fe*/ { "", TRUE, NONE, 0, (char *)db_Grp4 }, -/*ff*/ { "", TRUE, NONE, 0, (char *)db_Grp5 }, +/*fe*/ { "", TRUE, NONE, 0, db_Grp4 }, +/*ff*/ { "", TRUE, NONE, 0, db_Grp5 }, }; struct inst db_bad_inst = @@ -891,7 +896,7 @@ db_read_address(loc, short_addr, regmodrm, addrp) switch (mod) { case 0: if (rm == 6) { - get_value_inc(disp, loc, 2, TRUE); + get_value_inc(disp, loc, 2, FALSE); addrp->disp = disp; addrp->base = 0; } else { @@ -901,11 +906,12 @@ db_read_address(loc, short_addr, regmodrm, addrp) break; case 1: get_value_inc(disp, loc, 1, TRUE); + disp &= 0xffff; addrp->disp = disp; addrp->base = db_index_reg_16[rm]; break; case 2: - get_value_inc(disp, loc, 2, TRUE); + get_value_inc(disp, loc, 2, FALSE); addrp->disp = disp; addrp->base = db_index_reg_16[rm]; break; @@ -992,6 +998,11 @@ db_disasm_esc(loc, inst, short_addr, size, seg) fp = &db_Esc_inst[inst - 0xd8][f_reg(regmodrm)]; mod = f_mod(regmodrm); if (mod != 3) { + if (*fp->f_name == '\0') { + db_printf("<bad instruction>"); + return (loc); + } + /* * Normal address modes. */ @@ -1039,13 +1050,19 @@ db_disasm_esc(loc, inst, short_addr, size, seg) db_printf("%s\t%%st(%d)",name, f_rm(regmodrm)); break; case op1(X): - db_printf("%s", ((char **)fp->f_rrname)[f_rm(regmodrm)]); + name = ((char * const *)fp->f_rrname)[f_rm(regmodrm)]; + if (*name == '\0') + goto bad; + db_printf("%s", name); break; case op1(XA): - db_printf("%s\t%%ax", - ((char **)fp->f_rrname)[f_rm(regmodrm)]); + name = ((char * const *)fp->f_rrname)[f_rm(regmodrm)]; + if (*name == '\0') + goto bad; + db_printf("%s\t%%ax", name); break; default: + bad: db_printf("<bad instruction>"); break; } @@ -1159,19 +1176,17 @@ db_disasm(loc, altfmt) i_size = ip->i_size; i_mode = ip->i_mode; - if (ip->i_extra == (char *)db_Grp1 || - ip->i_extra == (char *)db_Grp2 || - ip->i_extra == (char *)db_Grp6 || - ip->i_extra == (char *)db_Grp7 || - ip->i_extra == (char *)db_Grp8) { + if (ip->i_extra == db_Grp1 || ip->i_extra == db_Grp2 || + ip->i_extra == db_Grp6 || ip->i_extra == db_Grp7 || + ip->i_extra == db_Grp8 || ip->i_extra == db_Grp9 || + ip->i_extra == db_GrpA || ip->i_extra == db_GrpB) { i_name = ((char **)ip->i_extra)[f_reg(regmodrm)]; - } else if (ip->i_extra == (char *)db_Grp3) { + } else if (ip->i_extra == db_Grp3) { ip = (struct inst *)ip->i_extra; ip = &ip[f_reg(regmodrm)]; i_name = ip->i_name; i_mode = ip->i_mode; - } else if (ip->i_extra == (char *)db_Grp4 || - ip->i_extra == (char *)db_Grp5) { + } else if (ip->i_extra == db_Grp4 || ip->i_extra == db_Grp5) { ip = (struct inst *)ip->i_extra; ip = &ip[f_reg(regmodrm)]; i_name = ip->i_name; @@ -1181,11 +1196,11 @@ db_disasm(loc, altfmt) if (i_size == SDEP) { if (size == WORD) - db_printf(i_name); + db_printf("%s", i_name); else - db_printf(ip->i_extra); + db_printf("%s", ip->i_extra); } else { - db_printf(i_name); + db_printf("%s", i_name); if (i_size != NONE) { if (i_size == BYTE) { db_printf("b"); @@ -1215,6 +1230,9 @@ db_disasm(loc, altfmt) db_printf("*"); db_print_address(seg, size, &address); break; + case El: + db_print_address(seg, LONG, &address); + break; case Ew: db_print_address(seg, WORD, &address); break; @@ -1230,6 +1248,9 @@ db_disasm(loc, altfmt) case Ri: db_printf("%s", db_reg[size][f_rm(inst)]); break; + case Ril: + db_printf("%s", db_reg[LONG][f_rm(inst)]); + break; case S: db_printf("%s", db_seg_reg[f_reg(regmodrm)]); break; @@ -1269,28 +1290,31 @@ db_disasm(loc, altfmt) break; case I: len = db_lengths[size]; - get_value_inc(imm, loc, len, FALSE);/* unsigned */ + get_value_inc(imm, loc, len, FALSE); db_printf("$%#n", imm); break; case Is: len = db_lengths[size]; - get_value_inc(imm, loc, len, TRUE); /* signed */ + get_value_inc(imm, loc, len, TRUE); db_printf("$%#r", imm); break; case Ib: - get_value_inc(imm, loc, 1, FALSE); /* unsigned */ + get_value_inc(imm, loc, 1, FALSE); db_printf("$%#n", imm); break; + case Iba: + get_value_inc(imm, loc, 1, FALSE); + if (imm != 0x0a) + db_printf("$%#n", imm); + break; case Ibs: - get_value_inc(imm, loc, 1, TRUE); /* signed */ + get_value_inc(imm, loc, 1, TRUE); + if (size == WORD) + imm &= 0xFFFF; db_printf("$%#r", imm); break; case Iw: - get_value_inc(imm, loc, 2, FALSE); /* unsigned */ - db_printf("$%#n", imm); - break; - case Il: - get_value_inc(imm, loc, 4, FALSE); + get_value_inc(imm, loc, 2, FALSE); db_printf("$%#n", imm); break; case O: @@ -1306,13 +1330,18 @@ db_disasm(loc, altfmt) break; case Db: get_value_inc(displ, loc, 1, TRUE); - db_printsym((db_addr_t)(displ + loc), DB_STGY_XTRN, - db_printf); + displ += loc; + if (size == WORD) + displ &= 0xFFFF; + db_printsym((db_addr_t)displ, DB_STGY_XTRN, db_printf); break; case Dl: - get_value_inc(displ, loc, 4, TRUE); - db_printsym((db_addr_t)(displ + loc), DB_STGY_XTRN, - db_printf); + len = db_lengths[size]; + get_value_inc(displ, loc, len, FALSE); + displ += loc; + if (size == WORD) + displ &= 0xFFFF; + db_printsym((db_addr_t)displ, DB_STGY_XTRN, db_printf); break; case o1: db_printf("$1"); @@ -1321,7 +1350,7 @@ db_disasm(loc, altfmt) db_printf("$3"); break; case OS: - get_value_inc(imm, loc, 4, FALSE); /* offset */ + get_value_inc(imm, loc, len, FALSE); /* offset */ get_value_inc(imm2, loc, 2, FALSE); /* segment */ db_printf("$%#n,%#n", imm2, imm); break; |