From e75f9a15ea31f347e439033e39dde1ebcf223f0b Mon Sep 17 00:00:00 2001 From: bde Date: Fri, 12 Jul 1996 04:40:21 +0000 Subject: Fixed operand order for shld and shrd. Finished the constant poisoning that was begun in rev.1.14. Consts aren't very poisonous (or useful) unless -Wcast-qual is in CFLAGS, and it isn't in the default CFLAGS. --- sys/amd64/amd64/db_disasm.c | 162 ++++++++++++++++++++++---------------------- sys/i386/i386/db_disasm.c | 162 ++++++++++++++++++++++---------------------- 2 files changed, 160 insertions(+), 164 deletions(-) (limited to 'sys') diff --git a/sys/amd64/amd64/db_disasm.c b/sys/amd64/amd64/db_disasm.c index 363ff70..17b3252 100644 --- a/sys/amd64/amd64/db_disasm.c +++ b/sys/amd64/amd64/db_disasm.c @@ -23,7 +23,7 @@ * any improvements or extensions that they make and grant Carnegie the * rights to redistribute these changes. * - * $Id: db_disasm.c,v 1.14 1996/03/28 20:35:03 wollman Exp $ + * $Id: db_disasm.c,v 1.15 1996/06/08 10:15:48 bde Exp $ */ /* @@ -95,7 +95,7 @@ struct inst { 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 */ + const void * i_extra; /* pointer to extra opcode table */ }; #define op1(x) (x) @@ -106,7 +106,7 @@ struct finst { const 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 + const void * f_rrname; /* name for rr instruction (or pointer to table) */ }; @@ -144,8 +144,8 @@ static const char * const db_Grp8[] = { }; static const 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 }, @@ -163,7 +163,7 @@ static const struct inst db_inst_0f0x[] = { /*0f*/ { "", FALSE, NONE, 0, 0 }, }; -static const struct inst db_inst_0f2x[] = { +static const struct inst db_inst_0f2x[] = { /*20*/ { "mov", TRUE, LONG, op2(CR,E), 0 }, /* use E for reg */ /*21*/ { "mov", TRUE, LONG, op2(DR,E), 0 }, /* since mod == 11 */ /*22*/ { "mov", TRUE, LONG, op2(E,CR), 0 }, @@ -203,7 +203,7 @@ static const struct inst db_inst_0f3x[] = { /*3f*/ { "", FALSE, NONE, 0, 0 }, }; -static const struct inst db_inst_0f8x[] = { +static const struct inst db_inst_0f8x[] = { /*80*/ { "jo", FALSE, NONE, op1(Dl), 0 }, /*81*/ { "jno", FALSE, NONE, op1(Dl), 0 }, /*82*/ { "jb", FALSE, NONE, op1(Dl), 0 }, @@ -223,7 +223,7 @@ static const struct inst db_inst_0f8x[] = { /*8f*/ { "jnle", FALSE, NONE, op1(Dl), 0 }, }; -static const struct inst db_inst_0f9x[] = { +static const struct inst db_inst_0f9x[] = { /*90*/ { "seto", TRUE, NONE, op1(Eb), 0 }, /*91*/ { "setno", TRUE, NONE, op1(Eb), 0 }, /*92*/ { "setb", TRUE, NONE, op1(Eb), 0 }, @@ -243,13 +243,13 @@ static const struct inst db_inst_0f9x[] = { /*9f*/ { "setnle",TRUE, NONE, op1(Eb), 0 }, }; -static const struct inst db_inst_0fax[] = { +static const struct inst db_inst_0fax[] = { /*a0*/ { "push", FALSE, NONE, op1(Si), 0 }, /*a1*/ { "pop", FALSE, NONE, op1(Si), 0 }, /*a2*/ { "", FALSE, NONE, 0, 0 }, /*a3*/ { "bt", TRUE, LONG, op2(E,R), 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 }, @@ -257,13 +257,13 @@ static const struct inst db_inst_0fax[] = { /*a9*/ { "pop", FALSE, NONE, op1(Si), 0 }, /*aa*/ { "", FALSE, NONE, 0, 0 }, /*ab*/ { "bts", TRUE, LONG, op2(E,R), 0 }, -/*ac*/ { "shrd", TRUE, LONG, op3(Ib,E,R), 0 }, -/*ad*/ { "shrd", TRUE, LONG, op3(CL,E,R), 0 }, +/*ac*/ { "shrd", TRUE, LONG, op3(Ib,R,E), 0 }, +/*ad*/ { "shrd", TRUE, LONG, op3(CL,R,E), 0 }, /*a6*/ { "", FALSE, NONE, 0, 0 }, /*a7*/ { "imul", TRUE, LONG, op2(E,R), 0 }, }; -static const struct inst db_inst_0fbx[] = { +static const struct inst db_inst_0fbx[] = { /*b0*/ { "", FALSE, NONE, 0, 0 }, /*b1*/ { "", FALSE, NONE, 0, 0 }, /*b2*/ { "lss", TRUE, LONG, op2(E, R), 0 }, @@ -275,7 +275,7 @@ static const struct inst db_inst_0fbx[] = { /*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 }, @@ -283,7 +283,7 @@ static const struct inst db_inst_0fbx[] = { /*bf*/ { "movsw", TRUE, LONG, op2(E, R), 0 }, }; -static const struct inst db_inst_0fcx[] = { +static const struct inst db_inst_0fcx[] = { /*c0*/ { "xadd", TRUE, BYTE, op2(R, E), 0 }, /*c1*/ { "xadd", TRUE, LONG, op2(R, E), 0 }, /*c2*/ { "", FALSE, NONE, 0, 0 }, @@ -302,7 +302,7 @@ static const struct inst db_inst_0fcx[] = { /*cf*/ { "bswap", FALSE, LONG, op1(Ri), 0 }, }; -static const struct inst db_inst_0fdx[] = { +static const 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 }, @@ -349,10 +349,10 @@ static const char * const db_Esc93[] = { static const char * const db_Esc94[] = { "fchs", "fabs", "", "", "ftst", "fxam", "", "" }; -static const char *const db_Esc95[] = { +static const char * const db_Esc95[] = { "fld1", "fldl2t","fldl2e","fldpi","fldlg2","fldln2","fldz","" }; -static const char *const db_Esc96[] = { +static const char * const db_Esc96[] = { "f2xm1","fyl2x","fptan","fpatan","fxtract","fprem1","fdecstp", "fincstp" }; @@ -360,11 +360,11 @@ static const char * const db_Esc97[] = { "fprem","fyl2xp1","fsqrt","fsincos","frndint","fscale","fsin","fcos" }; -static const char *const db_Esca4[] = { +static const char * const db_Esca4[] = { "", "fucompp","", "", "", "", "", "" }; -static const char *const db_Escb4[] = { +static const char * const db_Escb4[] = { "", "", "fnclex","fninit","", "", "", "" }; @@ -372,7 +372,7 @@ static const char * const db_Esce3[] = { "", "fcompp","", "", "", "", "", "" }; -static const char *const db_Escf4[] = { +static const char * const db_Escf4[] = { "fnstsw","", "", "", "", "", "", "" }; @@ -390,12 +390,12 @@ static const struct finst db_Esc8[] = { static const 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), db_Esc93 }, +/*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 }, }; static const struct finst db_Esca[] = { @@ -403,7 +403,7 @@ static const struct finst db_Esca[] = { /*1*/ { "fimul", WORD, 0, 0 }, /*2*/ { "ficom", WORD, 0, 0 }, /*3*/ { "ficomp", WORD, 0, 0 }, -/*4*/ { "fisub", WORD, op1(X), (char *)db_Esca4 }, +/*4*/ { "fisub", WORD, op1(X), db_Esca4 }, /*5*/ { "fisubr", WORD, 0, 0 }, /*6*/ { "fidiv", WORD, 0, 0 }, /*7*/ { "fidivr", WORD, 0, 0 } @@ -414,7 +414,7 @@ static const struct finst db_Escb[] = { /*1*/ { "", NONE, 0, 0 }, /*2*/ { "fist", WORD, 0, 0 }, /*3*/ { "fistp", WORD, 0, 0 }, -/*4*/ { "", WORD, op1(X), (char *)db_Escb4 }, +/*4*/ { "", WORD, op1(X), db_Escb4 }, /*5*/ { "fld", EXTR, 0, 0 }, /*6*/ { "", WORD, 0, 0 }, /*7*/ { "fstp", EXTR, 0, 0 }, @@ -446,7 +446,7 @@ static const 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 }, +/*3*/ { "ficomp", LONG, op1(X), db_Esce3 }, /*4*/ { "fisub", LONG, op2(ST,STI), "fsubrp" }, /*5*/ { "fisubr", LONG, op2(ST,STI), "fsubp" }, /*6*/ { "fidiv", LONG, op2(ST,STI), "fdivrp" }, @@ -458,13 +458,13 @@ static const struct finst db_Escf[] = { /*1*/ { "", LONG, 0, 0 }, /*2*/ { "fist", LONG, 0, 0 }, /*3*/ { "fistp", LONG, 0, 0 }, -/*4*/ { "fbld", NONE, op1(XA), (char *)db_Escf4 }, +/*4*/ { "fbld", NONE, op1(XA), db_Escf4 }, /*5*/ { "fld", QUAD, 0, 0 }, /*6*/ { "fbstp", NONE, 0, 0 }, /*7*/ { "fstp", QUAD, 0, 0 }, }; -static const struct finst *const db_Esc_inst[] = { +static const struct finst * const db_Esc_inst[] = { db_Esc8, db_Esc9, db_Esca, db_Escb, db_Escc, db_Escd, db_Esce, db_Escf }; @@ -502,7 +502,7 @@ static const struct inst db_Grp3[] = { { "idiv", TRUE, NONE, op2(E,A), 0 }, }; -static const struct inst db_Grp4[] = { +static const struct inst db_Grp4[] = { { "inc", TRUE, BYTE, op1(E), 0 }, { "dec", TRUE, BYTE, op1(E), 0 }, { "", TRUE, NONE, 0, 0 }, @@ -513,7 +513,7 @@ static const struct inst db_Grp4[] = { { "", TRUE, NONE, 0, 0 } }; -static const struct inst db_Grp5[] = { +static const struct inst db_Grp5[] = { { "inc", TRUE, LONG, op1(E), 0 }, { "dec", TRUE, LONG, op1(E), 0 }, { "call", TRUE, NONE, op1(Eind),0 }, @@ -670,10 +670,10 @@ static const 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(Is,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 }, @@ -742,8 +742,8 @@ static const 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 }, @@ -760,23 +760,23 @@ static const 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 }, +/*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, 0, 0 }, /*d5*/ { "aad", TRUE, NONE, 0, 0 }, /*d6*/ { "", 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 }, @@ -802,8 +802,8 @@ static const 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 }, @@ -811,11 +811,11 @@ static const 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 }, }; -static const struct inst db_bad_inst = +static const struct inst db_bad_inst = { "???", FALSE, NONE, 0, 0 } ; @@ -852,7 +852,7 @@ static const char * const db_reg[3][8] = { "%eax", "%ecx", "%edx", "%ebx", "%esp", "%ebp", "%esi", "%edi" }; -static const char *const db_seg_reg[8] = { +static const char * const db_seg_reg[8] = { "%es", "%cs", "%ss", "%ds", "%fs", "%gs", "", "" }; @@ -875,8 +875,8 @@ static const int db_lengths[] = { static db_addr_t db_disasm_esc __P((db_addr_t loc, int inst, int short_addr, - int size, char *seg)); -static void db_print_address __P((char *seg, int size, + int size, const char *seg)); +static void db_print_address __P((const char *seg, int size, struct i_addr *addrp)); static db_addr_t db_read_address __P((db_addr_t loc, int short_addr, @@ -890,7 +890,7 @@ db_read_address(loc, short_addr, regmodrm, addrp) db_addr_t loc; int short_addr; int regmodrm; - struct i_addr *addrp; /* out */ + struct i_addr * addrp; /* out */ { int mod, rm, sib, index, disp; @@ -972,9 +972,9 @@ db_read_address(loc, short_addr, regmodrm, addrp) static void db_print_address(seg, size, addrp) - char * seg; + const char * seg; int size; - struct i_addr *addrp; + struct i_addr * addrp; { if (addrp->is_reg) { db_printf("%s", db_reg[size][addrp->disp]); @@ -1006,13 +1006,13 @@ db_disasm_esc(loc, inst, short_addr, size, seg) int inst; int short_addr; int size; - char * seg; + const char * seg; { int regmodrm; - const struct finst *fp; + const struct finst * fp; int mod; struct i_addr address; - const char * name; + const char * name; get_value_inc(regmodrm, loc, 1, FALSE); fp = &db_Esc_inst[inst - 0xd8][f_reg(regmodrm)]; @@ -1066,11 +1066,12 @@ 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)]); + db_printf("%s", + ((const char * const *)fp->f_rrname)[f_rm(regmodrm)]); break; case op1(XA): db_printf("%s\t%%ax", - ((char **)fp->f_rrname)[f_rm(regmodrm)]); + ((const char * const *)fp->f_rrname)[f_rm(regmodrm)]); break; default: db_printf(""); @@ -1094,7 +1095,7 @@ db_disasm(loc, altfmt) int inst; int size; int short_addr; - char * seg; + const char * seg; const struct inst * ip; const char * i_name; int i_size; @@ -1189,22 +1190,19 @@ 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) { - i_name = ((char **)ip->i_extra)[f_reg(regmodrm)]; + 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) { + i_name = ((const char * const *)ip->i_extra)[f_reg(regmodrm)]; } - else if (ip->i_extra == (char *)db_Grp3) { - ip = (struct inst *)ip->i_extra; + else if (ip->i_extra == db_Grp3) { + ip = 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) { - ip = (struct inst *)ip->i_extra; + else if (ip->i_extra == db_Grp4 || ip->i_extra == db_Grp5) { + ip = ip->i_extra; ip = &ip[f_reg(regmodrm)]; i_name = ip->i_name; i_mode = ip->i_mode; @@ -1215,7 +1213,7 @@ db_disasm(loc, altfmt) if (size == WORD) db_printf(i_name); else - db_printf(ip->i_extra); + db_printf((const char *)ip->i_extra); } else { db_printf(i_name); diff --git a/sys/i386/i386/db_disasm.c b/sys/i386/i386/db_disasm.c index 363ff70..17b3252 100644 --- a/sys/i386/i386/db_disasm.c +++ b/sys/i386/i386/db_disasm.c @@ -23,7 +23,7 @@ * any improvements or extensions that they make and grant Carnegie the * rights to redistribute these changes. * - * $Id: db_disasm.c,v 1.14 1996/03/28 20:35:03 wollman Exp $ + * $Id: db_disasm.c,v 1.15 1996/06/08 10:15:48 bde Exp $ */ /* @@ -95,7 +95,7 @@ struct inst { 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 */ + const void * i_extra; /* pointer to extra opcode table */ }; #define op1(x) (x) @@ -106,7 +106,7 @@ struct finst { const 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 + const void * f_rrname; /* name for rr instruction (or pointer to table) */ }; @@ -144,8 +144,8 @@ static const char * const db_Grp8[] = { }; static const 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 }, @@ -163,7 +163,7 @@ static const struct inst db_inst_0f0x[] = { /*0f*/ { "", FALSE, NONE, 0, 0 }, }; -static const struct inst db_inst_0f2x[] = { +static const struct inst db_inst_0f2x[] = { /*20*/ { "mov", TRUE, LONG, op2(CR,E), 0 }, /* use E for reg */ /*21*/ { "mov", TRUE, LONG, op2(DR,E), 0 }, /* since mod == 11 */ /*22*/ { "mov", TRUE, LONG, op2(E,CR), 0 }, @@ -203,7 +203,7 @@ static const struct inst db_inst_0f3x[] = { /*3f*/ { "", FALSE, NONE, 0, 0 }, }; -static const struct inst db_inst_0f8x[] = { +static const struct inst db_inst_0f8x[] = { /*80*/ { "jo", FALSE, NONE, op1(Dl), 0 }, /*81*/ { "jno", FALSE, NONE, op1(Dl), 0 }, /*82*/ { "jb", FALSE, NONE, op1(Dl), 0 }, @@ -223,7 +223,7 @@ static const struct inst db_inst_0f8x[] = { /*8f*/ { "jnle", FALSE, NONE, op1(Dl), 0 }, }; -static const struct inst db_inst_0f9x[] = { +static const struct inst db_inst_0f9x[] = { /*90*/ { "seto", TRUE, NONE, op1(Eb), 0 }, /*91*/ { "setno", TRUE, NONE, op1(Eb), 0 }, /*92*/ { "setb", TRUE, NONE, op1(Eb), 0 }, @@ -243,13 +243,13 @@ static const struct inst db_inst_0f9x[] = { /*9f*/ { "setnle",TRUE, NONE, op1(Eb), 0 }, }; -static const struct inst db_inst_0fax[] = { +static const struct inst db_inst_0fax[] = { /*a0*/ { "push", FALSE, NONE, op1(Si), 0 }, /*a1*/ { "pop", FALSE, NONE, op1(Si), 0 }, /*a2*/ { "", FALSE, NONE, 0, 0 }, /*a3*/ { "bt", TRUE, LONG, op2(E,R), 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 }, @@ -257,13 +257,13 @@ static const struct inst db_inst_0fax[] = { /*a9*/ { "pop", FALSE, NONE, op1(Si), 0 }, /*aa*/ { "", FALSE, NONE, 0, 0 }, /*ab*/ { "bts", TRUE, LONG, op2(E,R), 0 }, -/*ac*/ { "shrd", TRUE, LONG, op3(Ib,E,R), 0 }, -/*ad*/ { "shrd", TRUE, LONG, op3(CL,E,R), 0 }, +/*ac*/ { "shrd", TRUE, LONG, op3(Ib,R,E), 0 }, +/*ad*/ { "shrd", TRUE, LONG, op3(CL,R,E), 0 }, /*a6*/ { "", FALSE, NONE, 0, 0 }, /*a7*/ { "imul", TRUE, LONG, op2(E,R), 0 }, }; -static const struct inst db_inst_0fbx[] = { +static const struct inst db_inst_0fbx[] = { /*b0*/ { "", FALSE, NONE, 0, 0 }, /*b1*/ { "", FALSE, NONE, 0, 0 }, /*b2*/ { "lss", TRUE, LONG, op2(E, R), 0 }, @@ -275,7 +275,7 @@ static const struct inst db_inst_0fbx[] = { /*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 }, @@ -283,7 +283,7 @@ static const struct inst db_inst_0fbx[] = { /*bf*/ { "movsw", TRUE, LONG, op2(E, R), 0 }, }; -static const struct inst db_inst_0fcx[] = { +static const struct inst db_inst_0fcx[] = { /*c0*/ { "xadd", TRUE, BYTE, op2(R, E), 0 }, /*c1*/ { "xadd", TRUE, LONG, op2(R, E), 0 }, /*c2*/ { "", FALSE, NONE, 0, 0 }, @@ -302,7 +302,7 @@ static const struct inst db_inst_0fcx[] = { /*cf*/ { "bswap", FALSE, LONG, op1(Ri), 0 }, }; -static const struct inst db_inst_0fdx[] = { +static const 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 }, @@ -349,10 +349,10 @@ static const char * const db_Esc93[] = { static const char * const db_Esc94[] = { "fchs", "fabs", "", "", "ftst", "fxam", "", "" }; -static const char *const db_Esc95[] = { +static const char * const db_Esc95[] = { "fld1", "fldl2t","fldl2e","fldpi","fldlg2","fldln2","fldz","" }; -static const char *const db_Esc96[] = { +static const char * const db_Esc96[] = { "f2xm1","fyl2x","fptan","fpatan","fxtract","fprem1","fdecstp", "fincstp" }; @@ -360,11 +360,11 @@ static const char * const db_Esc97[] = { "fprem","fyl2xp1","fsqrt","fsincos","frndint","fscale","fsin","fcos" }; -static const char *const db_Esca4[] = { +static const char * const db_Esca4[] = { "", "fucompp","", "", "", "", "", "" }; -static const char *const db_Escb4[] = { +static const char * const db_Escb4[] = { "", "", "fnclex","fninit","", "", "", "" }; @@ -372,7 +372,7 @@ static const char * const db_Esce3[] = { "", "fcompp","", "", "", "", "", "" }; -static const char *const db_Escf4[] = { +static const char * const db_Escf4[] = { "fnstsw","", "", "", "", "", "", "" }; @@ -390,12 +390,12 @@ static const struct finst db_Esc8[] = { static const 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), db_Esc93 }, +/*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 }, }; static const struct finst db_Esca[] = { @@ -403,7 +403,7 @@ static const struct finst db_Esca[] = { /*1*/ { "fimul", WORD, 0, 0 }, /*2*/ { "ficom", WORD, 0, 0 }, /*3*/ { "ficomp", WORD, 0, 0 }, -/*4*/ { "fisub", WORD, op1(X), (char *)db_Esca4 }, +/*4*/ { "fisub", WORD, op1(X), db_Esca4 }, /*5*/ { "fisubr", WORD, 0, 0 }, /*6*/ { "fidiv", WORD, 0, 0 }, /*7*/ { "fidivr", WORD, 0, 0 } @@ -414,7 +414,7 @@ static const struct finst db_Escb[] = { /*1*/ { "", NONE, 0, 0 }, /*2*/ { "fist", WORD, 0, 0 }, /*3*/ { "fistp", WORD, 0, 0 }, -/*4*/ { "", WORD, op1(X), (char *)db_Escb4 }, +/*4*/ { "", WORD, op1(X), db_Escb4 }, /*5*/ { "fld", EXTR, 0, 0 }, /*6*/ { "", WORD, 0, 0 }, /*7*/ { "fstp", EXTR, 0, 0 }, @@ -446,7 +446,7 @@ static const 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 }, +/*3*/ { "ficomp", LONG, op1(X), db_Esce3 }, /*4*/ { "fisub", LONG, op2(ST,STI), "fsubrp" }, /*5*/ { "fisubr", LONG, op2(ST,STI), "fsubp" }, /*6*/ { "fidiv", LONG, op2(ST,STI), "fdivrp" }, @@ -458,13 +458,13 @@ static const struct finst db_Escf[] = { /*1*/ { "", LONG, 0, 0 }, /*2*/ { "fist", LONG, 0, 0 }, /*3*/ { "fistp", LONG, 0, 0 }, -/*4*/ { "fbld", NONE, op1(XA), (char *)db_Escf4 }, +/*4*/ { "fbld", NONE, op1(XA), db_Escf4 }, /*5*/ { "fld", QUAD, 0, 0 }, /*6*/ { "fbstp", NONE, 0, 0 }, /*7*/ { "fstp", QUAD, 0, 0 }, }; -static const struct finst *const db_Esc_inst[] = { +static const struct finst * const db_Esc_inst[] = { db_Esc8, db_Esc9, db_Esca, db_Escb, db_Escc, db_Escd, db_Esce, db_Escf }; @@ -502,7 +502,7 @@ static const struct inst db_Grp3[] = { { "idiv", TRUE, NONE, op2(E,A), 0 }, }; -static const struct inst db_Grp4[] = { +static const struct inst db_Grp4[] = { { "inc", TRUE, BYTE, op1(E), 0 }, { "dec", TRUE, BYTE, op1(E), 0 }, { "", TRUE, NONE, 0, 0 }, @@ -513,7 +513,7 @@ static const struct inst db_Grp4[] = { { "", TRUE, NONE, 0, 0 } }; -static const struct inst db_Grp5[] = { +static const struct inst db_Grp5[] = { { "inc", TRUE, LONG, op1(E), 0 }, { "dec", TRUE, LONG, op1(E), 0 }, { "call", TRUE, NONE, op1(Eind),0 }, @@ -670,10 +670,10 @@ static const 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(Is,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 }, @@ -742,8 +742,8 @@ static const 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 }, @@ -760,23 +760,23 @@ static const 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 }, +/*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, 0, 0 }, /*d5*/ { "aad", TRUE, NONE, 0, 0 }, /*d6*/ { "", 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 }, @@ -802,8 +802,8 @@ static const 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 }, @@ -811,11 +811,11 @@ static const 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 }, }; -static const struct inst db_bad_inst = +static const struct inst db_bad_inst = { "???", FALSE, NONE, 0, 0 } ; @@ -852,7 +852,7 @@ static const char * const db_reg[3][8] = { "%eax", "%ecx", "%edx", "%ebx", "%esp", "%ebp", "%esi", "%edi" }; -static const char *const db_seg_reg[8] = { +static const char * const db_seg_reg[8] = { "%es", "%cs", "%ss", "%ds", "%fs", "%gs", "", "" }; @@ -875,8 +875,8 @@ static const int db_lengths[] = { static db_addr_t db_disasm_esc __P((db_addr_t loc, int inst, int short_addr, - int size, char *seg)); -static void db_print_address __P((char *seg, int size, + int size, const char *seg)); +static void db_print_address __P((const char *seg, int size, struct i_addr *addrp)); static db_addr_t db_read_address __P((db_addr_t loc, int short_addr, @@ -890,7 +890,7 @@ db_read_address(loc, short_addr, regmodrm, addrp) db_addr_t loc; int short_addr; int regmodrm; - struct i_addr *addrp; /* out */ + struct i_addr * addrp; /* out */ { int mod, rm, sib, index, disp; @@ -972,9 +972,9 @@ db_read_address(loc, short_addr, regmodrm, addrp) static void db_print_address(seg, size, addrp) - char * seg; + const char * seg; int size; - struct i_addr *addrp; + struct i_addr * addrp; { if (addrp->is_reg) { db_printf("%s", db_reg[size][addrp->disp]); @@ -1006,13 +1006,13 @@ db_disasm_esc(loc, inst, short_addr, size, seg) int inst; int short_addr; int size; - char * seg; + const char * seg; { int regmodrm; - const struct finst *fp; + const struct finst * fp; int mod; struct i_addr address; - const char * name; + const char * name; get_value_inc(regmodrm, loc, 1, FALSE); fp = &db_Esc_inst[inst - 0xd8][f_reg(regmodrm)]; @@ -1066,11 +1066,12 @@ 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)]); + db_printf("%s", + ((const char * const *)fp->f_rrname)[f_rm(regmodrm)]); break; case op1(XA): db_printf("%s\t%%ax", - ((char **)fp->f_rrname)[f_rm(regmodrm)]); + ((const char * const *)fp->f_rrname)[f_rm(regmodrm)]); break; default: db_printf(""); @@ -1094,7 +1095,7 @@ db_disasm(loc, altfmt) int inst; int size; int short_addr; - char * seg; + const char * seg; const struct inst * ip; const char * i_name; int i_size; @@ -1189,22 +1190,19 @@ 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) { - i_name = ((char **)ip->i_extra)[f_reg(regmodrm)]; + 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) { + i_name = ((const char * const *)ip->i_extra)[f_reg(regmodrm)]; } - else if (ip->i_extra == (char *)db_Grp3) { - ip = (struct inst *)ip->i_extra; + else if (ip->i_extra == db_Grp3) { + ip = 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) { - ip = (struct inst *)ip->i_extra; + else if (ip->i_extra == db_Grp4 || ip->i_extra == db_Grp5) { + ip = ip->i_extra; ip = &ip[f_reg(regmodrm)]; i_name = ip->i_name; i_mode = ip->i_mode; @@ -1215,7 +1213,7 @@ db_disasm(loc, altfmt) if (size == WORD) db_printf(i_name); else - db_printf(ip->i_extra); + db_printf((const char *)ip->i_extra); } else { db_printf(i_name); -- cgit v1.1