db_disasm.c revision 11940
18876Srgrimes/* 24Srgrimes * Mach Operating System 34Srgrimes * Copyright (c) 1991,1990 Carnegie Mellon University 44Srgrimes * All Rights Reserved. 58876Srgrimes * 64Srgrimes * Permission to use, copy, modify and distribute this software and its 74Srgrimes * documentation is hereby granted, provided that both the copyright 84Srgrimes * notice and this permission notice appear in all copies of the 94Srgrimes * software, derivative works or modified versions, and any portions 104Srgrimes * thereof, and that both notices appear in supporting documentation. 118876Srgrimes * 128876Srgrimes * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS 134Srgrimes * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR 144Srgrimes * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. 158876Srgrimes * 164Srgrimes * Carnegie Mellon requests users of this software to return to 178876Srgrimes * 184Srgrimes * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU 194Srgrimes * School of Computer Science 204Srgrimes * Carnegie Mellon University 214Srgrimes * Pittsburgh PA 15213-3890 228876Srgrimes * 234Srgrimes * any improvements or extensions that they make and grant Carnegie the 244Srgrimes * rights to redistribute these changes. 25118Srgrimes * 2611940Sbde * $Id: db_disasm.c,v 1.10 1995/10/29 15:29:48 phk Exp $ 274Srgrimes */ 284Srgrimes 294Srgrimes/* 304Srgrimes * Instruction disassembler. 314Srgrimes */ 322056Swollman#include <sys/param.h> 332056Swollman#include <sys/systm.h> 342056Swollman#include <sys/proc.h> 352056Swollman#include <ddb/ddb.h> 364Srgrimes 374Srgrimes#include <ddb/db_access.h> 384Srgrimes#include <ddb/db_sym.h> 394Srgrimes 404Srgrimes/* 414Srgrimes * Size attributes 424Srgrimes */ 434Srgrimes#define BYTE 0 444Srgrimes#define WORD 1 454Srgrimes#define LONG 2 464Srgrimes#define QUAD 3 474Srgrimes#define SNGL 4 484Srgrimes#define DBLR 5 494Srgrimes#define EXTR 6 504Srgrimes#define SDEP 7 514Srgrimes#define NONE 8 524Srgrimes 534Srgrimes/* 544Srgrimes * Addressing modes 554Srgrimes */ 564Srgrimes#define E 1 /* general effective address */ 574Srgrimes#define Eind 2 /* indirect address (jump, call) */ 584Srgrimes#define Ew 3 /* address, word size */ 594Srgrimes#define Eb 4 /* address, byte size */ 604Srgrimes#define R 5 /* register, in 'reg' field */ 614Srgrimes#define Rw 6 /* word register, in 'reg' field */ 624Srgrimes#define Ri 7 /* register in instruction */ 634Srgrimes#define S 8 /* segment reg, in 'reg' field */ 644Srgrimes#define Si 9 /* segment reg, in instruction */ 654Srgrimes#define A 10 /* accumulator */ 664Srgrimes#define BX 11 /* (bx) */ 674Srgrimes#define CL 12 /* cl, for shifts */ 684Srgrimes#define DX 13 /* dx, for IO */ 694Srgrimes#define SI 14 /* si */ 704Srgrimes#define DI 15 /* di */ 714Srgrimes#define CR 16 /* control register */ 724Srgrimes#define DR 17 /* debug register */ 734Srgrimes#define TR 18 /* test register */ 744Srgrimes#define I 19 /* immediate, unsigned */ 754Srgrimes#define Is 20 /* immediate, signed */ 764Srgrimes#define Ib 21 /* byte immediate, unsigned */ 774Srgrimes#define Ibs 22 /* byte immediate, signed */ 784Srgrimes#define Iw 23 /* word immediate, unsigned */ 794Srgrimes#define Il 24 /* long immediate */ 804Srgrimes#define O 25 /* direct address */ 814Srgrimes#define Db 26 /* byte displacement from EIP */ 824Srgrimes#define Dl 27 /* long displacement from EIP */ 834Srgrimes#define o1 28 /* constant 1 */ 844Srgrimes#define o3 29 /* constant 3 */ 854Srgrimes#define OS 30 /* immediate offset/segment */ 864Srgrimes#define ST 31 /* FP stack top */ 874Srgrimes#define STI 32 /* FP stack */ 884Srgrimes#define X 33 /* extended FP op */ 894Srgrimes#define XA 34 /* for 'fstcw %ax' */ 904Srgrimes 9111940Sbdestruct inst { 924Srgrimes char * i_name; /* name */ 934Srgrimes short i_has_modrm; /* has regmodrm byte */ 944Srgrimes short i_size; /* operand size */ 954Srgrimes int i_mode; /* addressing modes */ 964Srgrimes char * i_extra; /* pointer to extra opcode table */ 974Srgrimes}; 984Srgrimes 994Srgrimes#define op1(x) (x) 1004Srgrimes#define op2(x,y) ((x)|((y)<<8)) 1014Srgrimes#define op3(x,y,z) ((x)|((y)<<8)|((z)<<16)) 1024Srgrimes 10311940Sbdestruct finst { 1044Srgrimes char * f_name; /* name for memory instruction */ 1054Srgrimes int f_size; /* size for memory instruction */ 1064Srgrimes int f_rrmode; /* mode for rr instruction */ 1074Srgrimes char * f_rrname; /* name for rr instruction 1084Srgrimes (or pointer to table) */ 1094Srgrimes}; 1104Srgrimes 11111921Sphkstatic char * db_Grp6[] = { 1124Srgrimes "sldt", 1134Srgrimes "str", 1144Srgrimes "lldt", 1154Srgrimes "ltr", 1164Srgrimes "verr", 1174Srgrimes "verw", 1184Srgrimes "", 1194Srgrimes "" 1204Srgrimes}; 1214Srgrimes 12211921Sphkstatic char * db_Grp7[] = { 1234Srgrimes "sgdt", 1244Srgrimes "sidt", 1254Srgrimes "lgdt", 1264Srgrimes "lidt", 1274Srgrimes "smsw", 1284Srgrimes "", 1294Srgrimes "lmsw", 1304Srgrimes "invlpg" 1314Srgrimes}; 1324Srgrimes 13311921Sphkstatic char * db_Grp8[] = { 1344Srgrimes "", 1354Srgrimes "", 1364Srgrimes "", 1374Srgrimes "", 1384Srgrimes "bt", 1394Srgrimes "bts", 1404Srgrimes "btr", 1414Srgrimes "btc" 1424Srgrimes}; 1434Srgrimes 14411921Sphkstatic struct inst db_inst_0f0x[] = { 1454Srgrimes/*00*/ { "", TRUE, NONE, op1(Ew), (char *)db_Grp6 }, 1464Srgrimes/*01*/ { "", TRUE, NONE, op1(Ew), (char *)db_Grp7 }, 1474Srgrimes/*02*/ { "lar", TRUE, LONG, op2(E,R), 0 }, 1484Srgrimes/*03*/ { "lsl", TRUE, LONG, op2(E,R), 0 }, 1494Srgrimes/*04*/ { "", FALSE, NONE, 0, 0 }, 1504Srgrimes/*05*/ { "", FALSE, NONE, 0, 0 }, 1514Srgrimes/*06*/ { "clts", FALSE, NONE, 0, 0 }, 1524Srgrimes/*07*/ { "", FALSE, NONE, 0, 0 }, 1534Srgrimes 1544Srgrimes/*08*/ { "invd", FALSE, NONE, 0, 0 }, 1554Srgrimes/*09*/ { "wbinvd",FALSE, NONE, 0, 0 }, 1564Srgrimes/*0a*/ { "", FALSE, NONE, 0, 0 }, 1574Srgrimes/*0b*/ { "", FALSE, NONE, 0, 0 }, 1584Srgrimes/*0c*/ { "", FALSE, NONE, 0, 0 }, 1594Srgrimes/*0d*/ { "", FALSE, NONE, 0, 0 }, 1604Srgrimes/*0e*/ { "", FALSE, NONE, 0, 0 }, 1614Srgrimes/*0f*/ { "", FALSE, NONE, 0, 0 }, 1624Srgrimes}; 1634Srgrimes 16411921Sphkstatic struct inst db_inst_0f2x[] = { 1654Srgrimes/*20*/ { "mov", TRUE, LONG, op2(CR,E), 0 }, /* use E for reg */ 1664Srgrimes/*21*/ { "mov", TRUE, LONG, op2(DR,E), 0 }, /* since mod == 11 */ 1674Srgrimes/*22*/ { "mov", TRUE, LONG, op2(E,CR), 0 }, 1684Srgrimes/*23*/ { "mov", TRUE, LONG, op2(E,DR), 0 }, 1694Srgrimes/*24*/ { "mov", TRUE, LONG, op2(TR,E), 0 }, 1704Srgrimes/*25*/ { "", FALSE, NONE, 0, 0 }, 1714Srgrimes/*26*/ { "mov", TRUE, LONG, op2(E,TR), 0 }, 1724Srgrimes/*27*/ { "", FALSE, NONE, 0, 0 }, 1734Srgrimes 1744Srgrimes/*28*/ { "", FALSE, NONE, 0, 0 }, 1754Srgrimes/*29*/ { "", FALSE, NONE, 0, 0 }, 1764Srgrimes/*2a*/ { "", FALSE, NONE, 0, 0 }, 1774Srgrimes/*2b*/ { "", FALSE, NONE, 0, 0 }, 1784Srgrimes/*2c*/ { "", FALSE, NONE, 0, 0 }, 1794Srgrimes/*2d*/ { "", FALSE, NONE, 0, 0 }, 1804Srgrimes/*2e*/ { "", FALSE, NONE, 0, 0 }, 1814Srgrimes/*2f*/ { "", FALSE, NONE, 0, 0 }, 1824Srgrimes}; 1834Srgrimes 18411921Sphkstatic struct inst db_inst_0f8x[] = { 1854Srgrimes/*80*/ { "jo", FALSE, NONE, op1(Dl), 0 }, 1864Srgrimes/*81*/ { "jno", FALSE, NONE, op1(Dl), 0 }, 1874Srgrimes/*82*/ { "jb", FALSE, NONE, op1(Dl), 0 }, 1884Srgrimes/*83*/ { "jnb", FALSE, NONE, op1(Dl), 0 }, 1894Srgrimes/*84*/ { "jz", FALSE, NONE, op1(Dl), 0 }, 1904Srgrimes/*85*/ { "jnz", FALSE, NONE, op1(Dl), 0 }, 1914Srgrimes/*86*/ { "jbe", FALSE, NONE, op1(Dl), 0 }, 1924Srgrimes/*87*/ { "jnbe", FALSE, NONE, op1(Dl), 0 }, 1934Srgrimes 1944Srgrimes/*88*/ { "js", FALSE, NONE, op1(Dl), 0 }, 1954Srgrimes/*89*/ { "jns", FALSE, NONE, op1(Dl), 0 }, 1964Srgrimes/*8a*/ { "jp", FALSE, NONE, op1(Dl), 0 }, 1974Srgrimes/*8b*/ { "jnp", FALSE, NONE, op1(Dl), 0 }, 1984Srgrimes/*8c*/ { "jl", FALSE, NONE, op1(Dl), 0 }, 1994Srgrimes/*8d*/ { "jnl", FALSE, NONE, op1(Dl), 0 }, 2004Srgrimes/*8e*/ { "jle", FALSE, NONE, op1(Dl), 0 }, 2014Srgrimes/*8f*/ { "jnle", FALSE, NONE, op1(Dl), 0 }, 2024Srgrimes}; 2034Srgrimes 20411921Sphkstatic struct inst db_inst_0f9x[] = { 2054Srgrimes/*90*/ { "seto", TRUE, NONE, op1(Eb), 0 }, 2064Srgrimes/*91*/ { "setno", TRUE, NONE, op1(Eb), 0 }, 2074Srgrimes/*92*/ { "setb", TRUE, NONE, op1(Eb), 0 }, 2084Srgrimes/*93*/ { "setnb", TRUE, NONE, op1(Eb), 0 }, 2094Srgrimes/*94*/ { "setz", TRUE, NONE, op1(Eb), 0 }, 2104Srgrimes/*95*/ { "setnz", TRUE, NONE, op1(Eb), 0 }, 2114Srgrimes/*96*/ { "setbe", TRUE, NONE, op1(Eb), 0 }, 2124Srgrimes/*97*/ { "setnbe",TRUE, NONE, op1(Eb), 0 }, 2134Srgrimes 2144Srgrimes/*98*/ { "sets", TRUE, NONE, op1(Eb), 0 }, 2154Srgrimes/*99*/ { "setns", TRUE, NONE, op1(Eb), 0 }, 2164Srgrimes/*9a*/ { "setp", TRUE, NONE, op1(Eb), 0 }, 2174Srgrimes/*9b*/ { "setnp", TRUE, NONE, op1(Eb), 0 }, 2184Srgrimes/*9c*/ { "setl", TRUE, NONE, op1(Eb), 0 }, 2194Srgrimes/*9d*/ { "setnl", TRUE, NONE, op1(Eb), 0 }, 2204Srgrimes/*9e*/ { "setle", TRUE, NONE, op1(Eb), 0 }, 2214Srgrimes/*9f*/ { "setnle",TRUE, NONE, op1(Eb), 0 }, 2224Srgrimes}; 2234Srgrimes 22411921Sphkstatic struct inst db_inst_0fax[] = { 2254Srgrimes/*a0*/ { "push", FALSE, NONE, op1(Si), 0 }, 2264Srgrimes/*a1*/ { "pop", FALSE, NONE, op1(Si), 0 }, 2274Srgrimes/*a2*/ { "", FALSE, NONE, 0, 0 }, 2284Srgrimes/*a3*/ { "bt", TRUE, LONG, op2(E,R), 0 }, 2294Srgrimes/*a4*/ { "shld", TRUE, LONG, op3(Ib,E,R), 0 }, 2304Srgrimes/*a5*/ { "shld", TRUE, LONG, op3(CL,E,R), 0 }, 2314Srgrimes/*a6*/ { "", FALSE, NONE, 0, 0 }, 2324Srgrimes/*a7*/ { "", FALSE, NONE, 0, 0 }, 2334Srgrimes 2344Srgrimes/*a8*/ { "push", FALSE, NONE, op1(Si), 0 }, 2354Srgrimes/*a9*/ { "pop", FALSE, NONE, op1(Si), 0 }, 2364Srgrimes/*aa*/ { "", FALSE, NONE, 0, 0 }, 2374Srgrimes/*ab*/ { "bts", TRUE, LONG, op2(E,R), 0 }, 2384Srgrimes/*ac*/ { "shrd", TRUE, LONG, op3(Ib,E,R), 0 }, 2394Srgrimes/*ad*/ { "shrd", TRUE, LONG, op3(CL,E,R), 0 }, 2404Srgrimes/*a6*/ { "", FALSE, NONE, 0, 0 }, 2414Srgrimes/*a7*/ { "imul", TRUE, LONG, op2(E,R), 0 }, 2424Srgrimes}; 2434Srgrimes 24411921Sphkstatic struct inst db_inst_0fbx[] = { 2454Srgrimes/*b0*/ { "", FALSE, NONE, 0, 0 }, 2464Srgrimes/*b1*/ { "", FALSE, NONE, 0, 0 }, 2474Srgrimes/*b2*/ { "lss", TRUE, LONG, op2(E, R), 0 }, 2484Srgrimes/*b3*/ { "bts", TRUE, LONG, op2(R, E), 0 }, 2494Srgrimes/*b4*/ { "lfs", TRUE, LONG, op2(E, R), 0 }, 2504Srgrimes/*b5*/ { "lgs", TRUE, LONG, op2(E, R), 0 }, 2514Srgrimes/*b6*/ { "movzb", TRUE, LONG, op2(E, R), 0 }, 2524Srgrimes/*b7*/ { "movzw", TRUE, LONG, op2(E, R), 0 }, 2534Srgrimes 2544Srgrimes/*b8*/ { "", FALSE, NONE, 0, 0 }, 2554Srgrimes/*b9*/ { "", FALSE, NONE, 0, 0 }, 2566008Sbde/*ba*/ { "", TRUE, LONG, op2(Ib, E), (char *)db_Grp8 }, 2574Srgrimes/*bb*/ { "btc", TRUE, LONG, op2(R, E), 0 }, 2584Srgrimes/*bc*/ { "bsf", TRUE, LONG, op2(E, R), 0 }, 2594Srgrimes/*bd*/ { "bsr", TRUE, LONG, op2(E, R), 0 }, 2604Srgrimes/*be*/ { "movsb", TRUE, LONG, op2(E, R), 0 }, 2614Srgrimes/*bf*/ { "movsw", TRUE, LONG, op2(E, R), 0 }, 2624Srgrimes}; 2634Srgrimes 26411921Sphkstatic struct inst db_inst_0fcx[] = { 2654Srgrimes/*c0*/ { "xadd", TRUE, BYTE, op2(R, E), 0 }, 2664Srgrimes/*c1*/ { "xadd", TRUE, LONG, op2(R, E), 0 }, 2674Srgrimes/*c2*/ { "", FALSE, NONE, 0, 0 }, 2684Srgrimes/*c3*/ { "", FALSE, NONE, 0, 0 }, 2694Srgrimes/*c4*/ { "", FALSE, NONE, 0, 0 }, 2704Srgrimes/*c5*/ { "", FALSE, NONE, 0, 0 }, 2714Srgrimes/*c6*/ { "", FALSE, NONE, 0, 0 }, 2724Srgrimes/*c7*/ { "", FALSE, NONE, 0, 0 }, 2734Srgrimes/*c8*/ { "bswap", FALSE, LONG, op1(Ri), 0 }, 2744Srgrimes/*c9*/ { "bswap", FALSE, LONG, op1(Ri), 0 }, 2754Srgrimes/*ca*/ { "bswap", FALSE, LONG, op1(Ri), 0 }, 2764Srgrimes/*cb*/ { "bswap", FALSE, LONG, op1(Ri), 0 }, 2774Srgrimes/*cc*/ { "bswap", FALSE, LONG, op1(Ri), 0 }, 2784Srgrimes/*cd*/ { "bswap", FALSE, LONG, op1(Ri), 0 }, 2794Srgrimes/*ce*/ { "bswap", FALSE, LONG, op1(Ri), 0 }, 2804Srgrimes/*cf*/ { "bswap", FALSE, LONG, op1(Ri), 0 }, 2814Srgrimes}; 2824Srgrimes 28311921Sphkstatic struct inst db_inst_0fdx[] = { 2844Srgrimes/*c0*/ { "cmpxchg",TRUE, BYTE, op2(R, E), 0 }, 2854Srgrimes/*c1*/ { "cmpxchg",TRUE, LONG, op2(R, E), 0 }, 2864Srgrimes/*c2*/ { "", FALSE, NONE, 0, 0 }, 2874Srgrimes/*c3*/ { "", FALSE, NONE, 0, 0 }, 2884Srgrimes/*c4*/ { "", FALSE, NONE, 0, 0 }, 2894Srgrimes/*c5*/ { "", FALSE, NONE, 0, 0 }, 2904Srgrimes/*c6*/ { "", FALSE, NONE, 0, 0 }, 2914Srgrimes/*c7*/ { "", FALSE, NONE, 0, 0 }, 2924Srgrimes/*c8*/ { "", FALSE, NONE, 0, 0 }, 2934Srgrimes/*c9*/ { "", FALSE, NONE, 0, 0 }, 2944Srgrimes/*ca*/ { "", FALSE, NONE, 0, 0 }, 2954Srgrimes/*cb*/ { "", FALSE, NONE, 0, 0 }, 2964Srgrimes/*cc*/ { "", FALSE, NONE, 0, 0 }, 2974Srgrimes/*cd*/ { "", FALSE, NONE, 0, 0 }, 2984Srgrimes/*ce*/ { "", FALSE, NONE, 0, 0 }, 2994Srgrimes/*cf*/ { "", FALSE, NONE, 0, 0 }, 3004Srgrimes}; 3014Srgrimes 30211921Sphkstatic struct inst *db_inst_0f[] = { 3034Srgrimes db_inst_0f0x, 3044Srgrimes 0, 3054Srgrimes db_inst_0f2x, 3064Srgrimes 0, 3074Srgrimes 0, 3084Srgrimes 0, 3094Srgrimes 0, 3104Srgrimes 0, 3114Srgrimes db_inst_0f8x, 3124Srgrimes db_inst_0f9x, 3134Srgrimes db_inst_0fax, 3144Srgrimes db_inst_0fbx, 3154Srgrimes db_inst_0fcx, 3164Srgrimes db_inst_0fdx, 3174Srgrimes 0, 3184Srgrimes 0 3194Srgrimes}; 3204Srgrimes 32111921Sphkstatic char * db_Esc92[] = { 3224Srgrimes "fnop", "", "", "", "", "", "", "" 3234Srgrimes}; 32411921Sphkstatic char * db_Esc93[] = { 3254Srgrimes "", "", "", "", "", "", "", "" 3264Srgrimes}; 32711921Sphkstatic char * db_Esc94[] = { 3284Srgrimes "fchs", "fabs", "", "", "ftst", "fxam", "", "" 3294Srgrimes}; 33011921Sphkstatic char * db_Esc95[] = { 3314Srgrimes "fld1", "fldl2t","fldl2e","fldpi","fldlg2","fldln2","fldz","" 3324Srgrimes}; 33311921Sphkstatic char * db_Esc96[] = { 3344Srgrimes "f2xm1","fyl2x","fptan","fpatan","fxtract","fprem1","fdecstp", 3354Srgrimes "fincstp" 3364Srgrimes}; 33711921Sphkstatic char * db_Esc97[] = { 3384Srgrimes "fprem","fyl2xp1","fsqrt","fsincos","frndint","fscale","fsin","fcos" 3394Srgrimes}; 3404Srgrimes 34111921Sphkstatic char * db_Esca4[] = { 3424Srgrimes "", "fucompp","", "", "", "", "", "" 3434Srgrimes}; 3444Srgrimes 34511921Sphkstatic char * db_Escb4[] = { 3464Srgrimes "", "", "fnclex","fninit","", "", "", "" 3474Srgrimes}; 3484Srgrimes 34911921Sphkstatic char * db_Esce3[] = { 3504Srgrimes "", "fcompp","", "", "", "", "", "" 3514Srgrimes}; 3524Srgrimes 35311921Sphkstatic char * db_Escf4[] = { 3544Srgrimes "fnstsw","", "", "", "", "", "", "" 3554Srgrimes}; 3564Srgrimes 35711921Sphkstatic struct finst db_Esc8[] = { 3584Srgrimes/*0*/ { "fadd", SNGL, op2(STI,ST), 0 }, 3594Srgrimes/*1*/ { "fmul", SNGL, op2(STI,ST), 0 }, 3604Srgrimes/*2*/ { "fcom", SNGL, op2(STI,ST), 0 }, 3614Srgrimes/*3*/ { "fcomp", SNGL, op2(STI,ST), 0 }, 3624Srgrimes/*4*/ { "fsub", SNGL, op2(STI,ST), 0 }, 3634Srgrimes/*5*/ { "fsubr", SNGL, op2(STI,ST), 0 }, 3644Srgrimes/*6*/ { "fdiv", SNGL, op2(STI,ST), 0 }, 3654Srgrimes/*7*/ { "fdivr", SNGL, op2(STI,ST), 0 }, 3664Srgrimes}; 3674Srgrimes 36811921Sphkstatic struct finst db_Esc9[] = { 3694Srgrimes/*0*/ { "fld", SNGL, op1(STI), 0 }, 3704Srgrimes/*1*/ { "", NONE, op1(STI), "fxch" }, 3714Srgrimes/*2*/ { "fst", SNGL, op1(X), (char *)db_Esc92 }, 3724Srgrimes/*3*/ { "fstp", SNGL, op1(X), (char *)db_Esc93 }, 3734Srgrimes/*4*/ { "fldenv", NONE, op1(X), (char *)db_Esc94 }, 3744Srgrimes/*5*/ { "fldcw", NONE, op1(X), (char *)db_Esc95 }, 3754Srgrimes/*6*/ { "fnstenv",NONE, op1(X), (char *)db_Esc96 }, 3764Srgrimes/*7*/ { "fnstcw", NONE, op1(X), (char *)db_Esc97 }, 3774Srgrimes}; 3784Srgrimes 37911921Sphkstatic struct finst db_Esca[] = { 3804Srgrimes/*0*/ { "fiadd", WORD, 0, 0 }, 3814Srgrimes/*1*/ { "fimul", WORD, 0, 0 }, 3824Srgrimes/*2*/ { "ficom", WORD, 0, 0 }, 3834Srgrimes/*3*/ { "ficomp", WORD, 0, 0 }, 3844Srgrimes/*4*/ { "fisub", WORD, op1(X), (char *)db_Esca4 }, 3854Srgrimes/*5*/ { "fisubr", WORD, 0, 0 }, 3864Srgrimes/*6*/ { "fidiv", WORD, 0, 0 }, 3874Srgrimes/*7*/ { "fidivr", WORD, 0, 0 } 3884Srgrimes}; 3894Srgrimes 39011921Sphkstatic struct finst db_Escb[] = { 3914Srgrimes/*0*/ { "fild", WORD, 0, 0 }, 3924Srgrimes/*1*/ { "", NONE, 0, 0 }, 3934Srgrimes/*2*/ { "fist", WORD, 0, 0 }, 3944Srgrimes/*3*/ { "fistp", WORD, 0, 0 }, 3954Srgrimes/*4*/ { "", WORD, op1(X), (char *)db_Escb4 }, 3964Srgrimes/*5*/ { "fld", EXTR, 0, 0 }, 3974Srgrimes/*6*/ { "", WORD, 0, 0 }, 3984Srgrimes/*7*/ { "fstp", EXTR, 0, 0 }, 3994Srgrimes}; 4004Srgrimes 40111921Sphkstatic struct finst db_Escc[] = { 4024Srgrimes/*0*/ { "fadd", DBLR, op2(ST,STI), 0 }, 4034Srgrimes/*1*/ { "fmul", DBLR, op2(ST,STI), 0 }, 4044Srgrimes/*2*/ { "fcom", DBLR, op2(ST,STI), 0 }, 4054Srgrimes/*3*/ { "fcomp", DBLR, op2(ST,STI), 0 }, 4064Srgrimes/*4*/ { "fsub", DBLR, op2(ST,STI), "fsubr" }, 4074Srgrimes/*5*/ { "fsubr", DBLR, op2(ST,STI), "fsub" }, 4084Srgrimes/*6*/ { "fdiv", DBLR, op2(ST,STI), "fdivr" }, 4094Srgrimes/*7*/ { "fdivr", DBLR, op2(ST,STI), "fdiv" }, 4104Srgrimes}; 4114Srgrimes 41211921Sphkstatic struct finst db_Escd[] = { 4134Srgrimes/*0*/ { "fld", DBLR, op1(STI), "ffree" }, 4144Srgrimes/*1*/ { "", NONE, 0, 0 }, 4154Srgrimes/*2*/ { "fst", DBLR, op1(STI), 0 }, 4164Srgrimes/*3*/ { "fstp", DBLR, op1(STI), 0 }, 4174Srgrimes/*4*/ { "frstor", NONE, op1(STI), "fucom" }, 4184Srgrimes/*5*/ { "", NONE, op1(STI), "fucomp" }, 4194Srgrimes/*6*/ { "fnsave", NONE, 0, 0 }, 4204Srgrimes/*7*/ { "fnstsw", NONE, 0, 0 }, 4214Srgrimes}; 4224Srgrimes 42311921Sphkstatic struct finst db_Esce[] = { 4244Srgrimes/*0*/ { "fiadd", LONG, op2(ST,STI), "faddp" }, 4254Srgrimes/*1*/ { "fimul", LONG, op2(ST,STI), "fmulp" }, 4264Srgrimes/*2*/ { "ficom", LONG, 0, 0 }, 4274Srgrimes/*3*/ { "ficomp", LONG, op1(X), (char *)db_Esce3 }, 4284Srgrimes/*4*/ { "fisub", LONG, op2(ST,STI), "fsubrp" }, 4294Srgrimes/*5*/ { "fisubr", LONG, op2(ST,STI), "fsubp" }, 4304Srgrimes/*6*/ { "fidiv", LONG, op2(ST,STI), "fdivrp" }, 4314Srgrimes/*7*/ { "fidivr", LONG, op2(ST,STI), "fdivp" }, 4324Srgrimes}; 4334Srgrimes 43411921Sphkstatic struct finst db_Escf[] = { 4354Srgrimes/*0*/ { "fild", LONG, 0, 0 }, 4364Srgrimes/*1*/ { "", LONG, 0, 0 }, 4374Srgrimes/*2*/ { "fist", LONG, 0, 0 }, 4384Srgrimes/*3*/ { "fistp", LONG, 0, 0 }, 4394Srgrimes/*4*/ { "fbld", NONE, op1(XA), (char *)db_Escf4 }, 4404Srgrimes/*5*/ { "fld", QUAD, 0, 0 }, 4414Srgrimes/*6*/ { "fbstp", NONE, 0, 0 }, 4424Srgrimes/*7*/ { "fstp", QUAD, 0, 0 }, 4434Srgrimes}; 4444Srgrimes 44511921Sphkstatic struct finst *db_Esc_inst[] = { 4464Srgrimes db_Esc8, db_Esc9, db_Esca, db_Escb, 4474Srgrimes db_Escc, db_Escd, db_Esce, db_Escf 4484Srgrimes}; 4494Srgrimes 45011921Sphkstatic char * db_Grp1[] = { 4514Srgrimes "add", 4524Srgrimes "or", 4534Srgrimes "adc", 4544Srgrimes "sbb", 4554Srgrimes "and", 4564Srgrimes "sub", 4574Srgrimes "xor", 4584Srgrimes "cmp" 4594Srgrimes}; 4604Srgrimes 46111921Sphkstatic char * db_Grp2[] = { 4624Srgrimes "rol", 4634Srgrimes "ror", 4644Srgrimes "rcl", 4654Srgrimes "rcr", 4664Srgrimes "shl", 4674Srgrimes "shr", 4684Srgrimes "shl", 4694Srgrimes "sar" 4704Srgrimes}; 4714Srgrimes 47211921Sphkstatic struct inst db_Grp3[] = { 4734Srgrimes { "test", TRUE, NONE, op2(I,E), 0 }, 4744Srgrimes { "test", TRUE, NONE, op2(I,E), 0 }, 4754Srgrimes { "not", TRUE, NONE, op1(E), 0 }, 4764Srgrimes { "neg", TRUE, NONE, op1(E), 0 }, 4774Srgrimes { "mul", TRUE, NONE, op2(E,A), 0 }, 4784Srgrimes { "imul", TRUE, NONE, op2(E,A), 0 }, 4794Srgrimes { "div", TRUE, NONE, op2(E,A), 0 }, 4804Srgrimes { "idiv", TRUE, NONE, op2(E,A), 0 }, 4814Srgrimes}; 4824Srgrimes 48311921Sphkstatic struct inst db_Grp4[] = { 4844Srgrimes { "inc", TRUE, BYTE, op1(E), 0 }, 4854Srgrimes { "dec", TRUE, BYTE, op1(E), 0 }, 4864Srgrimes { "", TRUE, NONE, 0, 0 }, 4874Srgrimes { "", TRUE, NONE, 0, 0 }, 4884Srgrimes { "", TRUE, NONE, 0, 0 }, 4894Srgrimes { "", TRUE, NONE, 0, 0 }, 4904Srgrimes { "", TRUE, NONE, 0, 0 }, 4914Srgrimes { "", TRUE, NONE, 0, 0 } 4924Srgrimes}; 4934Srgrimes 49411921Sphkstatic struct inst db_Grp5[] = { 4954Srgrimes { "inc", TRUE, LONG, op1(E), 0 }, 4964Srgrimes { "dec", TRUE, LONG, op1(E), 0 }, 4974Srgrimes { "call", TRUE, NONE, op1(Eind),0 }, 4984Srgrimes { "lcall", TRUE, NONE, op1(Eind),0 }, 4994Srgrimes { "jmp", TRUE, NONE, op1(Eind),0 }, 5004Srgrimes { "ljmp", TRUE, NONE, op1(Eind),0 }, 5014Srgrimes { "push", TRUE, LONG, op1(E), 0 }, 5024Srgrimes { "", TRUE, NONE, 0, 0 } 5034Srgrimes}; 5044Srgrimes 50511921Sphkstatic struct inst db_inst_table[256] = { 5064Srgrimes/*00*/ { "add", TRUE, BYTE, op2(R, E), 0 }, 5074Srgrimes/*01*/ { "add", TRUE, LONG, op2(R, E), 0 }, 5084Srgrimes/*02*/ { "add", TRUE, BYTE, op2(E, R), 0 }, 5094Srgrimes/*03*/ { "add", TRUE, LONG, op2(E, R), 0 }, 5104Srgrimes/*04*/ { "add", FALSE, BYTE, op2(Is, A), 0 }, 5114Srgrimes/*05*/ { "add", FALSE, LONG, op2(Is, A), 0 }, 5124Srgrimes/*06*/ { "push", FALSE, NONE, op1(Si), 0 }, 5134Srgrimes/*07*/ { "pop", FALSE, NONE, op1(Si), 0 }, 5144Srgrimes 5154Srgrimes/*08*/ { "or", TRUE, BYTE, op2(R, E), 0 }, 5164Srgrimes/*09*/ { "or", TRUE, LONG, op2(R, E), 0 }, 5174Srgrimes/*0a*/ { "or", TRUE, BYTE, op2(E, R), 0 }, 5184Srgrimes/*0b*/ { "or", TRUE, LONG, op2(E, R), 0 }, 5194Srgrimes/*0c*/ { "or", FALSE, BYTE, op2(I, A), 0 }, 5204Srgrimes/*0d*/ { "or", FALSE, LONG, op2(I, A), 0 }, 5214Srgrimes/*0e*/ { "push", FALSE, NONE, op1(Si), 0 }, 5224Srgrimes/*0f*/ { "", FALSE, NONE, 0, 0 }, 5234Srgrimes 5244Srgrimes/*10*/ { "adc", TRUE, BYTE, op2(R, E), 0 }, 5254Srgrimes/*11*/ { "adc", TRUE, LONG, op2(R, E), 0 }, 5264Srgrimes/*12*/ { "adc", TRUE, BYTE, op2(E, R), 0 }, 5274Srgrimes/*13*/ { "adc", TRUE, LONG, op2(E, R), 0 }, 5284Srgrimes/*14*/ { "adc", FALSE, BYTE, op2(Is, A), 0 }, 5294Srgrimes/*15*/ { "adc", FALSE, LONG, op2(Is, A), 0 }, 5304Srgrimes/*16*/ { "push", FALSE, NONE, op1(Si), 0 }, 5314Srgrimes/*17*/ { "pop", FALSE, NONE, op1(Si), 0 }, 5324Srgrimes 5334Srgrimes/*18*/ { "sbb", TRUE, BYTE, op2(R, E), 0 }, 5344Srgrimes/*19*/ { "sbb", TRUE, LONG, op2(R, E), 0 }, 5354Srgrimes/*1a*/ { "sbb", TRUE, BYTE, op2(E, R), 0 }, 5364Srgrimes/*1b*/ { "sbb", TRUE, LONG, op2(E, R), 0 }, 5374Srgrimes/*1c*/ { "sbb", FALSE, BYTE, op2(Is, A), 0 }, 5384Srgrimes/*1d*/ { "sbb", FALSE, LONG, op2(Is, A), 0 }, 5394Srgrimes/*1e*/ { "push", FALSE, NONE, op1(Si), 0 }, 5404Srgrimes/*1f*/ { "pop", FALSE, NONE, op1(Si), 0 }, 5414Srgrimes 5424Srgrimes/*20*/ { "and", TRUE, BYTE, op2(R, E), 0 }, 5434Srgrimes/*21*/ { "and", TRUE, LONG, op2(R, E), 0 }, 5444Srgrimes/*22*/ { "and", TRUE, BYTE, op2(E, R), 0 }, 5454Srgrimes/*23*/ { "and", TRUE, LONG, op2(E, R), 0 }, 5464Srgrimes/*24*/ { "and", FALSE, BYTE, op2(I, A), 0 }, 5474Srgrimes/*25*/ { "and", FALSE, LONG, op2(I, A), 0 }, 5484Srgrimes/*26*/ { "", FALSE, NONE, 0, 0 }, 5494Srgrimes/*27*/ { "aaa", FALSE, NONE, 0, 0 }, 5504Srgrimes 5514Srgrimes/*28*/ { "sub", TRUE, BYTE, op2(R, E), 0 }, 5524Srgrimes/*29*/ { "sub", TRUE, LONG, op2(R, E), 0 }, 5534Srgrimes/*2a*/ { "sub", TRUE, BYTE, op2(E, R), 0 }, 5544Srgrimes/*2b*/ { "sub", TRUE, LONG, op2(E, R), 0 }, 5554Srgrimes/*2c*/ { "sub", FALSE, BYTE, op2(Is, A), 0 }, 5564Srgrimes/*2d*/ { "sub", FALSE, LONG, op2(Is, A), 0 }, 5574Srgrimes/*2e*/ { "", FALSE, NONE, 0, 0 }, 5584Srgrimes/*2f*/ { "das", FALSE, NONE, 0, 0 }, 5594Srgrimes 5604Srgrimes/*30*/ { "xor", TRUE, BYTE, op2(R, E), 0 }, 5614Srgrimes/*31*/ { "xor", TRUE, LONG, op2(R, E), 0 }, 5624Srgrimes/*32*/ { "xor", TRUE, BYTE, op2(E, R), 0 }, 5634Srgrimes/*33*/ { "xor", TRUE, LONG, op2(E, R), 0 }, 5644Srgrimes/*34*/ { "xor", FALSE, BYTE, op2(I, A), 0 }, 5654Srgrimes/*35*/ { "xor", FALSE, LONG, op2(I, A), 0 }, 5664Srgrimes/*36*/ { "", FALSE, NONE, 0, 0 }, 5674Srgrimes/*37*/ { "daa", FALSE, NONE, 0, 0 }, 5684Srgrimes 5694Srgrimes/*38*/ { "cmp", TRUE, BYTE, op2(R, E), 0 }, 5704Srgrimes/*39*/ { "cmp", TRUE, LONG, op2(R, E), 0 }, 5714Srgrimes/*3a*/ { "cmp", TRUE, BYTE, op2(E, R), 0 }, 5724Srgrimes/*3b*/ { "cmp", TRUE, LONG, op2(E, R), 0 }, 5734Srgrimes/*3c*/ { "cmp", FALSE, BYTE, op2(Is, A), 0 }, 5744Srgrimes/*3d*/ { "cmp", FALSE, LONG, op2(Is, A), 0 }, 5754Srgrimes/*3e*/ { "", FALSE, NONE, 0, 0 }, 5764Srgrimes/*3f*/ { "aas", FALSE, NONE, 0, 0 }, 5774Srgrimes 5784Srgrimes/*40*/ { "inc", FALSE, LONG, op1(Ri), 0 }, 5794Srgrimes/*41*/ { "inc", FALSE, LONG, op1(Ri), 0 }, 5804Srgrimes/*42*/ { "inc", FALSE, LONG, op1(Ri), 0 }, 5814Srgrimes/*43*/ { "inc", FALSE, LONG, op1(Ri), 0 }, 5824Srgrimes/*44*/ { "inc", FALSE, LONG, op1(Ri), 0 }, 5834Srgrimes/*45*/ { "inc", FALSE, LONG, op1(Ri), 0 }, 5844Srgrimes/*46*/ { "inc", FALSE, LONG, op1(Ri), 0 }, 5854Srgrimes/*47*/ { "inc", FALSE, LONG, op1(Ri), 0 }, 5864Srgrimes 5874Srgrimes/*48*/ { "dec", FALSE, LONG, op1(Ri), 0 }, 5884Srgrimes/*49*/ { "dec", FALSE, LONG, op1(Ri), 0 }, 5894Srgrimes/*4a*/ { "dec", FALSE, LONG, op1(Ri), 0 }, 5904Srgrimes/*4b*/ { "dec", FALSE, LONG, op1(Ri), 0 }, 5914Srgrimes/*4c*/ { "dec", FALSE, LONG, op1(Ri), 0 }, 5924Srgrimes/*4d*/ { "dec", FALSE, LONG, op1(Ri), 0 }, 5934Srgrimes/*4e*/ { "dec", FALSE, LONG, op1(Ri), 0 }, 5944Srgrimes/*4f*/ { "dec", FALSE, LONG, op1(Ri), 0 }, 5954Srgrimes 5964Srgrimes/*50*/ { "push", FALSE, LONG, op1(Ri), 0 }, 5974Srgrimes/*51*/ { "push", FALSE, LONG, op1(Ri), 0 }, 5984Srgrimes/*52*/ { "push", FALSE, LONG, op1(Ri), 0 }, 5994Srgrimes/*53*/ { "push", FALSE, LONG, op1(Ri), 0 }, 6004Srgrimes/*54*/ { "push", FALSE, LONG, op1(Ri), 0 }, 6014Srgrimes/*55*/ { "push", FALSE, LONG, op1(Ri), 0 }, 6024Srgrimes/*56*/ { "push", FALSE, LONG, op1(Ri), 0 }, 6034Srgrimes/*57*/ { "push", FALSE, LONG, op1(Ri), 0 }, 6044Srgrimes 6054Srgrimes/*58*/ { "pop", FALSE, LONG, op1(Ri), 0 }, 6064Srgrimes/*59*/ { "pop", FALSE, LONG, op1(Ri), 0 }, 6074Srgrimes/*5a*/ { "pop", FALSE, LONG, op1(Ri), 0 }, 6084Srgrimes/*5b*/ { "pop", FALSE, LONG, op1(Ri), 0 }, 6094Srgrimes/*5c*/ { "pop", FALSE, LONG, op1(Ri), 0 }, 6104Srgrimes/*5d*/ { "pop", FALSE, LONG, op1(Ri), 0 }, 6114Srgrimes/*5e*/ { "pop", FALSE, LONG, op1(Ri), 0 }, 6124Srgrimes/*5f*/ { "pop", FALSE, LONG, op1(Ri), 0 }, 6134Srgrimes 6144Srgrimes/*60*/ { "pusha", FALSE, LONG, 0, 0 }, 6154Srgrimes/*61*/ { "popa", FALSE, LONG, 0, 0 }, 6164Srgrimes/*62*/ { "bound", TRUE, LONG, op2(E, R), 0 }, 6174Srgrimes/*63*/ { "arpl", TRUE, NONE, op2(Ew,Rw), 0 }, 6184Srgrimes 6194Srgrimes/*64*/ { "", FALSE, NONE, 0, 0 }, 6204Srgrimes/*65*/ { "", FALSE, NONE, 0, 0 }, 6214Srgrimes/*66*/ { "", FALSE, NONE, 0, 0 }, 6224Srgrimes/*67*/ { "", FALSE, NONE, 0, 0 }, 6234Srgrimes 6244Srgrimes/*68*/ { "push", FALSE, LONG, op1(I), 0 }, 6254Srgrimes/*69*/ { "imul", TRUE, LONG, op3(I,E,R), 0 }, 6264Srgrimes/*6a*/ { "push", FALSE, LONG, op1(Ib), 0 }, 6274Srgrimes/*6b*/ { "imul", TRUE, LONG, op3(Ibs,E,R),0 }, 6284Srgrimes/*6c*/ { "ins", FALSE, BYTE, op2(DX, DI), 0 }, 6294Srgrimes/*6d*/ { "ins", FALSE, LONG, op2(DX, DI), 0 }, 6304Srgrimes/*6e*/ { "outs", FALSE, BYTE, op2(SI, DX), 0 }, 6314Srgrimes/*6f*/ { "outs", FALSE, LONG, op2(SI, DX), 0 }, 6324Srgrimes 6334Srgrimes/*70*/ { "jo", FALSE, NONE, op1(Db), 0 }, 6344Srgrimes/*71*/ { "jno", FALSE, NONE, op1(Db), 0 }, 6354Srgrimes/*72*/ { "jb", FALSE, NONE, op1(Db), 0 }, 6364Srgrimes/*73*/ { "jnb", FALSE, NONE, op1(Db), 0 }, 6374Srgrimes/*74*/ { "jz", FALSE, NONE, op1(Db), 0 }, 6384Srgrimes/*75*/ { "jnz", FALSE, NONE, op1(Db), 0 }, 6394Srgrimes/*76*/ { "jbe", FALSE, NONE, op1(Db), 0 }, 6404Srgrimes/*77*/ { "jnbe", FALSE, NONE, op1(Db), 0 }, 6414Srgrimes 6424Srgrimes/*78*/ { "js", FALSE, NONE, op1(Db), 0 }, 6434Srgrimes/*79*/ { "jns", FALSE, NONE, op1(Db), 0 }, 6444Srgrimes/*7a*/ { "jp", FALSE, NONE, op1(Db), 0 }, 6454Srgrimes/*7b*/ { "jnp", FALSE, NONE, op1(Db), 0 }, 6464Srgrimes/*7c*/ { "jl", FALSE, NONE, op1(Db), 0 }, 6474Srgrimes/*7d*/ { "jnl", FALSE, NONE, op1(Db), 0 }, 6484Srgrimes/*7e*/ { "jle", FALSE, NONE, op1(Db), 0 }, 6494Srgrimes/*7f*/ { "jnle", FALSE, NONE, op1(Db), 0 }, 6504Srgrimes 6514Srgrimes/*80*/ { "", TRUE, BYTE, op2(I, E), (char *)db_Grp1 }, 6524Srgrimes/*81*/ { "", TRUE, LONG, op2(I, E), (char *)db_Grp1 }, 6534Srgrimes/*82*/ { "", TRUE, BYTE, op2(Is,E), (char *)db_Grp1 }, 6544Srgrimes/*83*/ { "", TRUE, LONG, op2(Ibs,E), (char *)db_Grp1 }, 6554Srgrimes/*84*/ { "test", TRUE, BYTE, op2(R, E), 0 }, 6564Srgrimes/*85*/ { "test", TRUE, LONG, op2(R, E), 0 }, 6574Srgrimes/*86*/ { "xchg", TRUE, BYTE, op2(R, E), 0 }, 6584Srgrimes/*87*/ { "xchg", TRUE, LONG, op2(R, E), 0 }, 6594Srgrimes 6604Srgrimes/*88*/ { "mov", TRUE, BYTE, op2(R, E), 0 }, 6614Srgrimes/*89*/ { "mov", TRUE, LONG, op2(R, E), 0 }, 6624Srgrimes/*8a*/ { "mov", TRUE, BYTE, op2(E, R), 0 }, 6634Srgrimes/*8b*/ { "mov", TRUE, LONG, op2(E, R), 0 }, 6644Srgrimes/*8c*/ { "mov", TRUE, NONE, op2(S, Ew), 0 }, 6654Srgrimes/*8d*/ { "lea", TRUE, LONG, op2(E, R), 0 }, 6664Srgrimes/*8e*/ { "mov", TRUE, NONE, op2(Ew, S), 0 }, 6674Srgrimes/*8f*/ { "pop", TRUE, LONG, op1(E), 0 }, 6684Srgrimes 6694Srgrimes/*90*/ { "nop", FALSE, NONE, 0, 0 }, 6704Srgrimes/*91*/ { "xchg", FALSE, LONG, op2(A, Ri), 0 }, 6714Srgrimes/*92*/ { "xchg", FALSE, LONG, op2(A, Ri), 0 }, 6724Srgrimes/*93*/ { "xchg", FALSE, LONG, op2(A, Ri), 0 }, 6734Srgrimes/*94*/ { "xchg", FALSE, LONG, op2(A, Ri), 0 }, 6744Srgrimes/*95*/ { "xchg", FALSE, LONG, op2(A, Ri), 0 }, 6754Srgrimes/*96*/ { "xchg", FALSE, LONG, op2(A, Ri), 0 }, 6764Srgrimes/*97*/ { "xchg", FALSE, LONG, op2(A, Ri), 0 }, 6774Srgrimes 6784Srgrimes/*98*/ { "cbw", FALSE, SDEP, 0, "cwde" }, /* cbw/cwde */ 6794Srgrimes/*99*/ { "cwd", FALSE, SDEP, 0, "cdq" }, /* cwd/cdq */ 6804Srgrimes/*9a*/ { "lcall", FALSE, NONE, op1(OS), 0 }, 6814Srgrimes/*9b*/ { "wait", FALSE, NONE, 0, 0 }, 6824Srgrimes/*9c*/ { "pushf", FALSE, LONG, 0, 0 }, 6834Srgrimes/*9d*/ { "popf", FALSE, LONG, 0, 0 }, 6844Srgrimes/*9e*/ { "sahf", FALSE, NONE, 0, 0 }, 6854Srgrimes/*9f*/ { "lahf", FALSE, NONE, 0, 0 }, 6864Srgrimes 6874Srgrimes/*a0*/ { "mov", FALSE, BYTE, op2(O, A), 0 }, 6884Srgrimes/*a1*/ { "mov", FALSE, LONG, op2(O, A), 0 }, 6894Srgrimes/*a2*/ { "mov", FALSE, BYTE, op2(A, O), 0 }, 6904Srgrimes/*a3*/ { "mov", FALSE, LONG, op2(A, O), 0 }, 6914Srgrimes/*a4*/ { "movs", FALSE, BYTE, op2(SI,DI), 0 }, 6924Srgrimes/*a5*/ { "movs", FALSE, LONG, op2(SI,DI), 0 }, 6934Srgrimes/*a6*/ { "cmps", FALSE, BYTE, op2(SI,DI), 0 }, 6944Srgrimes/*a7*/ { "cmps", FALSE, LONG, op2(SI,DI), 0 }, 6954Srgrimes 6964Srgrimes/*a8*/ { "test", FALSE, BYTE, op2(I, A), 0 }, 6974Srgrimes/*a9*/ { "test", FALSE, LONG, op2(I, A), 0 }, 6984Srgrimes/*aa*/ { "stos", FALSE, BYTE, op1(DI), 0 }, 6994Srgrimes/*ab*/ { "stos", FALSE, LONG, op1(DI), 0 }, 700118Srgrimes/*ac*/ { "lods", FALSE, BYTE, op1(SI), 0 }, 701118Srgrimes/*ad*/ { "lods", FALSE, LONG, op1(SI), 0 }, 7024Srgrimes/*ae*/ { "scas", FALSE, BYTE, op1(SI), 0 }, 7034Srgrimes/*af*/ { "scas", FALSE, LONG, op1(SI), 0 }, 7044Srgrimes 7054Srgrimes/*b0*/ { "mov", FALSE, BYTE, op2(I, Ri), 0 }, 7064Srgrimes/*b1*/ { "mov", FALSE, BYTE, op2(I, Ri), 0 }, 7074Srgrimes/*b2*/ { "mov", FALSE, BYTE, op2(I, Ri), 0 }, 7084Srgrimes/*b3*/ { "mov", FALSE, BYTE, op2(I, Ri), 0 }, 7094Srgrimes/*b4*/ { "mov", FALSE, BYTE, op2(I, Ri), 0 }, 7104Srgrimes/*b5*/ { "mov", FALSE, BYTE, op2(I, Ri), 0 }, 7114Srgrimes/*b6*/ { "mov", FALSE, BYTE, op2(I, Ri), 0 }, 7124Srgrimes/*b7*/ { "mov", FALSE, BYTE, op2(I, Ri), 0 }, 7134Srgrimes 7144Srgrimes/*b8*/ { "mov", FALSE, LONG, op2(I, Ri), 0 }, 7154Srgrimes/*b9*/ { "mov", FALSE, LONG, op2(I, Ri), 0 }, 7164Srgrimes/*ba*/ { "mov", FALSE, LONG, op2(I, Ri), 0 }, 7174Srgrimes/*bb*/ { "mov", FALSE, LONG, op2(I, Ri), 0 }, 7184Srgrimes/*bc*/ { "mov", FALSE, LONG, op2(I, Ri), 0 }, 7194Srgrimes/*bd*/ { "mov", FALSE, LONG, op2(I, Ri), 0 }, 7204Srgrimes/*be*/ { "mov", FALSE, LONG, op2(I, Ri), 0 }, 7214Srgrimes/*bf*/ { "mov", FALSE, LONG, op2(I, Ri), 0 }, 7224Srgrimes 7234Srgrimes/*c0*/ { "", TRUE, BYTE, op2(Ib, E), (char *)db_Grp2 }, 7244Srgrimes/*c1*/ { "", TRUE, LONG, op2(Ib, E), (char *)db_Grp2 }, 7254Srgrimes/*c2*/ { "ret", FALSE, NONE, op1(Iw), 0 }, 7264Srgrimes/*c3*/ { "ret", FALSE, NONE, 0, 0 }, 7274Srgrimes/*c4*/ { "les", TRUE, LONG, op2(E, R), 0 }, 7284Srgrimes/*c5*/ { "lds", TRUE, LONG, op2(E, R), 0 }, 7294Srgrimes/*c6*/ { "mov", TRUE, BYTE, op2(I, E), 0 }, 7304Srgrimes/*c7*/ { "mov", TRUE, LONG, op2(I, E), 0 }, 7314Srgrimes 7324Srgrimes/*c8*/ { "enter", FALSE, NONE, op2(Ib, Iw), 0 }, 7334Srgrimes/*c9*/ { "leave", FALSE, NONE, 0, 0 }, 7344Srgrimes/*ca*/ { "lret", FALSE, NONE, op1(Iw), 0 }, 7354Srgrimes/*cb*/ { "lret", FALSE, NONE, 0, 0 }, 7364Srgrimes/*cc*/ { "int", FALSE, NONE, op1(o3), 0 }, 7374Srgrimes/*cd*/ { "int", FALSE, NONE, op1(Ib), 0 }, 7384Srgrimes/*ce*/ { "into", FALSE, NONE, 0, 0 }, 7394Srgrimes/*cf*/ { "iret", FALSE, NONE, 0, 0 }, 7404Srgrimes 7414Srgrimes/*d0*/ { "", TRUE, BYTE, op2(o1, E), (char *)db_Grp2 }, 7424Srgrimes/*d1*/ { "", TRUE, LONG, op2(o1, E), (char *)db_Grp2 }, 7434Srgrimes/*d2*/ { "", TRUE, BYTE, op2(CL, E), (char *)db_Grp2 }, 7444Srgrimes/*d3*/ { "", TRUE, LONG, op2(CL, E), (char *)db_Grp2 }, 7454Srgrimes/*d4*/ { "aam", TRUE, NONE, 0, 0 }, 7464Srgrimes/*d5*/ { "aad", TRUE, NONE, 0, 0 }, 7474Srgrimes/*d6*/ { "", FALSE, NONE, 0, 0 }, 7484Srgrimes/*d7*/ { "xlat", FALSE, BYTE, op1(BX), 0 }, 7494Srgrimes 7504Srgrimes/*d8*/ { "", TRUE, NONE, 0, (char *)db_Esc8 }, 7514Srgrimes/*d9*/ { "", TRUE, NONE, 0, (char *)db_Esc9 }, 7524Srgrimes/*da*/ { "", TRUE, NONE, 0, (char *)db_Esca }, 7534Srgrimes/*db*/ { "", TRUE, NONE, 0, (char *)db_Escb }, 7544Srgrimes/*dc*/ { "", TRUE, NONE, 0, (char *)db_Escc }, 7554Srgrimes/*dd*/ { "", TRUE, NONE, 0, (char *)db_Escd }, 7564Srgrimes/*de*/ { "", TRUE, NONE, 0, (char *)db_Esce }, 7574Srgrimes/*df*/ { "", TRUE, NONE, 0, (char *)db_Escf }, 7584Srgrimes 7594Srgrimes/*e0*/ { "loopne",FALSE, NONE, op1(Db), 0 }, 7604Srgrimes/*e1*/ { "loope", FALSE, NONE, op1(Db), 0 }, 7614Srgrimes/*e2*/ { "loop", FALSE, NONE, op1(Db), 0 }, 7624Srgrimes/*e3*/ { "jcxz", FALSE, SDEP, op1(Db), "jecxz" }, 7634Srgrimes/*e4*/ { "in", FALSE, BYTE, op2(Ib, A), 0 }, 7644Srgrimes/*e5*/ { "in", FALSE, LONG, op2(Ib, A) , 0 }, 7654Srgrimes/*e6*/ { "out", FALSE, BYTE, op2(A, Ib), 0 }, 7664Srgrimes/*e7*/ { "out", FALSE, LONG, op2(A, Ib) , 0 }, 7674Srgrimes 7684Srgrimes/*e8*/ { "call", FALSE, NONE, op1(Dl), 0 }, 7694Srgrimes/*e9*/ { "jmp", FALSE, NONE, op1(Dl), 0 }, 7704Srgrimes/*ea*/ { "ljmp", FALSE, NONE, op1(OS), 0 }, 7714Srgrimes/*eb*/ { "jmp", FALSE, NONE, op1(Db), 0 }, 7724Srgrimes/*ec*/ { "in", FALSE, BYTE, op2(DX, A), 0 }, 7734Srgrimes/*ed*/ { "in", FALSE, LONG, op2(DX, A) , 0 }, 7744Srgrimes/*ee*/ { "out", FALSE, BYTE, op2(A, DX), 0 }, 7754Srgrimes/*ef*/ { "out", FALSE, LONG, op2(A, DX) , 0 }, 7764Srgrimes 7774Srgrimes/*f0*/ { "", FALSE, NONE, 0, 0 }, 7784Srgrimes/*f1*/ { "", FALSE, NONE, 0, 0 }, 7794Srgrimes/*f2*/ { "", FALSE, NONE, 0, 0 }, 7804Srgrimes/*f3*/ { "", FALSE, NONE, 0, 0 }, 7814Srgrimes/*f4*/ { "hlt", FALSE, NONE, 0, 0 }, 7824Srgrimes/*f5*/ { "cmc", FALSE, NONE, 0, 0 }, 7834Srgrimes/*f6*/ { "", TRUE, BYTE, 0, (char *)db_Grp3 }, 7844Srgrimes/*f7*/ { "", TRUE, LONG, 0, (char *)db_Grp3 }, 7854Srgrimes 7864Srgrimes/*f8*/ { "clc", FALSE, NONE, 0, 0 }, 7874Srgrimes/*f9*/ { "stc", FALSE, NONE, 0, 0 }, 7884Srgrimes/*fa*/ { "cli", FALSE, NONE, 0, 0 }, 7894Srgrimes/*fb*/ { "sti", FALSE, NONE, 0, 0 }, 7904Srgrimes/*fc*/ { "cld", FALSE, NONE, 0, 0 }, 7914Srgrimes/*fd*/ { "std", FALSE, NONE, 0, 0 }, 7924Srgrimes/*fe*/ { "", TRUE, NONE, 0, (char *)db_Grp4 }, 7934Srgrimes/*ff*/ { "", TRUE, NONE, 0, (char *)db_Grp5 }, 7944Srgrimes}; 7954Srgrimes 79611921Sphkstatic struct inst db_bad_inst = 7974Srgrimes { "???", FALSE, NONE, 0, 0 } 7984Srgrimes; 7994Srgrimes 8004Srgrimes#define f_mod(byte) ((byte)>>6) 8014Srgrimes#define f_reg(byte) (((byte)>>3)&0x7) 8024Srgrimes#define f_rm(byte) ((byte)&0x7) 8034Srgrimes 8044Srgrimes#define sib_ss(byte) ((byte)>>6) 8054Srgrimes#define sib_index(byte) (((byte)>>3)&0x7) 8064Srgrimes#define sib_base(byte) ((byte)&0x7) 8074Srgrimes 80811940Sbdestruct i_addr { 8094Srgrimes int is_reg; /* if reg, reg number is in 'disp' */ 8104Srgrimes int disp; 8114Srgrimes char * base; 8124Srgrimes char * index; 8134Srgrimes int ss; 8144Srgrimes}; 8154Srgrimes 81611921Sphkstatic char * db_index_reg_16[8] = { 8174Srgrimes "%bx,%si", 8184Srgrimes "%bx,%di", 8194Srgrimes "%bp,%si", 8204Srgrimes "%bp,%di", 8214Srgrimes "%si", 8224Srgrimes "%di", 8234Srgrimes "%bp", 8244Srgrimes "%bx" 8254Srgrimes}; 8264Srgrimes 82711921Sphkstatic char * db_reg[3][8] = { 8284Srgrimes "%al", "%cl", "%dl", "%bl", "%ah", "%ch", "%dh", "%bh", 8294Srgrimes "%ax", "%cx", "%dx", "%bx", "%sp", "%bp", "%si", "%di", 8304Srgrimes "%eax", "%ecx", "%edx", "%ebx", "%esp", "%ebp", "%esi", "%edi" 8314Srgrimes}; 8324Srgrimes 83311921Sphkstatic char * db_seg_reg[8] = { 8344Srgrimes "%es", "%cs", "%ss", "%ds", "%fs", "%gs", "", "" 8354Srgrimes}; 8364Srgrimes 8374Srgrimes/* 8384Srgrimes * lengths for size attributes 8394Srgrimes */ 84011921Sphkstatic int db_lengths[] = { 8414Srgrimes 1, /* BYTE */ 8424Srgrimes 2, /* WORD */ 8434Srgrimes 4, /* LONG */ 8444Srgrimes 8, /* QUAD */ 8454Srgrimes 4, /* SNGL */ 8464Srgrimes 8, /* DBLR */ 8474Srgrimes 10, /* EXTR */ 8484Srgrimes}; 8494Srgrimes 8504Srgrimes#define get_value_inc(result, loc, size, is_signed) \ 8514Srgrimes result = db_get_value((loc), (size), (is_signed)); \ 8524Srgrimes (loc) += (size); 8534Srgrimes 85411940Sbdestatic db_addr_t 85511940Sbde db_disasm_esc __P((db_addr_t loc, int inst, int short_addr, 85611940Sbde int size, char *seg)); 85711940Sbdestatic void db_print_address __P((char *seg, int size, 85811940Sbde struct i_addr *addrp)); 85911940Sbdestatic db_addr_t 86011940Sbde db_read_address __P((db_addr_t loc, int short_addr, 86111940Sbde int regmodrm, struct i_addr *addrp)); 86211940Sbde 8634Srgrimes/* 8644Srgrimes * Read address at location and return updated location. 8654Srgrimes */ 86611921Sphkstatic db_addr_t 8674Srgrimesdb_read_address(loc, short_addr, regmodrm, addrp) 8684Srgrimes db_addr_t loc; 8694Srgrimes int short_addr; 8704Srgrimes int regmodrm; 8714Srgrimes struct i_addr *addrp; /* out */ 8724Srgrimes{ 8733436Sphk int mod, rm, sib, index, disp; 8744Srgrimes 8754Srgrimes mod = f_mod(regmodrm); 8764Srgrimes rm = f_rm(regmodrm); 8774Srgrimes 8784Srgrimes if (mod == 3) { 8794Srgrimes addrp->is_reg = TRUE; 8804Srgrimes addrp->disp = rm; 8814Srgrimes return (loc); 8824Srgrimes } 8834Srgrimes addrp->is_reg = FALSE; 8844Srgrimes addrp->index = 0; 8854Srgrimes 8864Srgrimes if (short_addr) { 8874Srgrimes addrp->index = 0; 8884Srgrimes addrp->ss = 0; 8894Srgrimes switch (mod) { 8904Srgrimes case 0: 8914Srgrimes if (rm == 6) { 8924Srgrimes get_value_inc(disp, loc, 2, TRUE); 8934Srgrimes addrp->disp = disp; 8944Srgrimes addrp->base = 0; 8954Srgrimes } 8964Srgrimes else { 8974Srgrimes addrp->disp = 0; 8984Srgrimes addrp->base = db_index_reg_16[rm]; 8994Srgrimes } 9004Srgrimes break; 9014Srgrimes case 1: 9024Srgrimes get_value_inc(disp, loc, 1, TRUE); 9034Srgrimes addrp->disp = disp; 9044Srgrimes addrp->base = db_index_reg_16[rm]; 9054Srgrimes break; 9064Srgrimes case 2: 9074Srgrimes get_value_inc(disp, loc, 2, TRUE); 9084Srgrimes addrp->disp = disp; 9094Srgrimes addrp->base = db_index_reg_16[rm]; 9104Srgrimes break; 9114Srgrimes } 9124Srgrimes } 9134Srgrimes else { 9144Srgrimes if (mod != 3 && rm == 4) { 9154Srgrimes get_value_inc(sib, loc, 1, FALSE); 9164Srgrimes rm = sib_base(sib); 9174Srgrimes index = sib_index(sib); 9184Srgrimes if (index != 4) 9194Srgrimes addrp->index = db_reg[LONG][index]; 9204Srgrimes addrp->ss = sib_ss(sib); 9214Srgrimes } 9224Srgrimes 9234Srgrimes switch (mod) { 9244Srgrimes case 0: 9254Srgrimes if (rm == 5) { 9264Srgrimes get_value_inc(addrp->disp, loc, 4, FALSE); 9274Srgrimes addrp->base = 0; 9284Srgrimes } 9294Srgrimes else { 9304Srgrimes addrp->disp = 0; 9314Srgrimes addrp->base = db_reg[LONG][rm]; 9324Srgrimes } 9334Srgrimes break; 9344Srgrimes 9354Srgrimes case 1: 9364Srgrimes get_value_inc(disp, loc, 1, TRUE); 9374Srgrimes addrp->disp = disp; 9384Srgrimes addrp->base = db_reg[LONG][rm]; 9394Srgrimes break; 9404Srgrimes 9414Srgrimes case 2: 9424Srgrimes get_value_inc(disp, loc, 4, FALSE); 9434Srgrimes addrp->disp = disp; 9444Srgrimes addrp->base = db_reg[LONG][rm]; 9454Srgrimes break; 9464Srgrimes } 9474Srgrimes } 9484Srgrimes return (loc); 9494Srgrimes} 9504Srgrimes 95111921Sphkstatic void 9524Srgrimesdb_print_address(seg, size, addrp) 9534Srgrimes char * seg; 9544Srgrimes int size; 9554Srgrimes struct i_addr *addrp; 9564Srgrimes{ 9574Srgrimes if (addrp->is_reg) { 9584Srgrimes db_printf("%s", db_reg[size][addrp->disp]); 9594Srgrimes return; 9604Srgrimes } 9614Srgrimes 9624Srgrimes if (seg) { 9634Srgrimes db_printf("%s:", seg); 9644Srgrimes } 9654Srgrimes 9664Srgrimes db_printsym((db_addr_t)addrp->disp, DB_STGY_ANY); 9674Srgrimes if (addrp->base != 0 || addrp->index != 0) { 9684Srgrimes db_printf("("); 9694Srgrimes if (addrp->base) 9704Srgrimes db_printf("%s", addrp->base); 9714Srgrimes if (addrp->index) 9724Srgrimes db_printf(",%s,%d", addrp->index, 1<<addrp->ss); 9734Srgrimes db_printf(")"); 9744Srgrimes } 9754Srgrimes} 9764Srgrimes 9774Srgrimes/* 9784Srgrimes * Disassemble floating-point ("escape") instruction 9794Srgrimes * and return updated location. 9804Srgrimes */ 98111921Sphkstatic db_addr_t 9824Srgrimesdb_disasm_esc(loc, inst, short_addr, size, seg) 9834Srgrimes db_addr_t loc; 9844Srgrimes int inst; 9854Srgrimes int short_addr; 9864Srgrimes int size; 9874Srgrimes char * seg; 9884Srgrimes{ 9894Srgrimes int regmodrm; 9904Srgrimes struct finst *fp; 9914Srgrimes int mod; 9924Srgrimes struct i_addr address; 9934Srgrimes char * name; 9944Srgrimes 9954Srgrimes get_value_inc(regmodrm, loc, 1, FALSE); 9964Srgrimes fp = &db_Esc_inst[inst - 0xd8][f_reg(regmodrm)]; 9974Srgrimes mod = f_mod(regmodrm); 9984Srgrimes if (mod != 3) { 9994Srgrimes /* 10004Srgrimes * Normal address modes. 10014Srgrimes */ 10024Srgrimes loc = db_read_address(loc, short_addr, regmodrm, &address); 10034Srgrimes db_printf(fp->f_name); 10044Srgrimes switch(fp->f_size) { 10054Srgrimes case SNGL: 10064Srgrimes db_printf("s"); 10074Srgrimes break; 10084Srgrimes case DBLR: 10094Srgrimes db_printf("l"); 10104Srgrimes break; 10114Srgrimes case EXTR: 10124Srgrimes db_printf("t"); 10134Srgrimes break; 10144Srgrimes case WORD: 10154Srgrimes db_printf("s"); 10164Srgrimes break; 10174Srgrimes case LONG: 10184Srgrimes db_printf("l"); 10194Srgrimes break; 10204Srgrimes case QUAD: 10214Srgrimes db_printf("q"); 10224Srgrimes break; 10234Srgrimes default: 10244Srgrimes break; 10254Srgrimes } 10264Srgrimes db_printf("\t"); 10274Srgrimes db_print_address(seg, BYTE, &address); 10284Srgrimes } 10294Srgrimes else { 10304Srgrimes /* 10314Srgrimes * 'reg-reg' - special formats 10324Srgrimes */ 10334Srgrimes switch (fp->f_rrmode) { 10344Srgrimes case op2(ST,STI): 10354Srgrimes name = (fp->f_rrname) ? fp->f_rrname : fp->f_name; 10364Srgrimes db_printf("%s\t%%st,%%st(%d)",name,f_rm(regmodrm)); 10374Srgrimes break; 10384Srgrimes case op2(STI,ST): 10394Srgrimes name = (fp->f_rrname) ? fp->f_rrname : fp->f_name; 10404Srgrimes db_printf("%s\t%%st(%d),%%st",name, f_rm(regmodrm)); 10414Srgrimes break; 10424Srgrimes case op1(STI): 10434Srgrimes name = (fp->f_rrname) ? fp->f_rrname : fp->f_name; 10444Srgrimes db_printf("%s\t%%st(%d)",name, f_rm(regmodrm)); 10454Srgrimes break; 10464Srgrimes case op1(X): 10474Srgrimes db_printf("%s", ((char **)fp->f_rrname)[f_rm(regmodrm)]); 10484Srgrimes break; 10494Srgrimes case op1(XA): 10504Srgrimes db_printf("%s\t%%ax", 10514Srgrimes ((char **)fp->f_rrname)[f_rm(regmodrm)]); 10524Srgrimes break; 10534Srgrimes default: 10544Srgrimes db_printf("<bad instruction>"); 10554Srgrimes break; 10564Srgrimes } 10574Srgrimes } 10584Srgrimes 10594Srgrimes return (loc); 10604Srgrimes} 10614Srgrimes 10624Srgrimes/* 10634Srgrimes * Disassemble instruction at 'loc'. 'altfmt' specifies an 10644Srgrimes * (optional) alternate format. Return address of start of 10654Srgrimes * next instruction. 10664Srgrimes */ 10674Srgrimesdb_addr_t 10684Srgrimesdb_disasm(loc, altfmt) 10694Srgrimes db_addr_t loc; 10704Srgrimes boolean_t altfmt; 10714Srgrimes{ 10724Srgrimes int inst; 10734Srgrimes int size; 10744Srgrimes int short_addr; 10754Srgrimes char * seg; 10764Srgrimes struct inst * ip; 10774Srgrimes char * i_name; 10784Srgrimes int i_size; 10794Srgrimes int i_mode; 1080798Swollman int regmodrm = 0; 10814Srgrimes boolean_t first; 10824Srgrimes int displ; 10834Srgrimes int prefix; 10844Srgrimes int imm; 10854Srgrimes int imm2; 10864Srgrimes int len; 10874Srgrimes struct i_addr address; 10884Srgrimes 10894Srgrimes get_value_inc(inst, loc, 1, FALSE); 10904Srgrimes short_addr = FALSE; 10914Srgrimes size = LONG; 10924Srgrimes seg = 0; 10934Srgrimes 10944Srgrimes /* 10954Srgrimes * Get prefixes 10964Srgrimes */ 10974Srgrimes prefix = TRUE; 10984Srgrimes do { 10994Srgrimes switch (inst) { 11004Srgrimes case 0x66: /* data16 */ 11014Srgrimes size = WORD; 11024Srgrimes break; 11034Srgrimes case 0x67: 11044Srgrimes short_addr = TRUE; 11054Srgrimes break; 11064Srgrimes case 0x26: 11074Srgrimes seg = "%es"; 11084Srgrimes break; 11094Srgrimes case 0x36: 11104Srgrimes seg = "%ss"; 11114Srgrimes break; 11124Srgrimes case 0x2e: 11134Srgrimes seg = "%cs"; 11144Srgrimes break; 11154Srgrimes case 0x3e: 11164Srgrimes seg = "%ds"; 11174Srgrimes break; 11184Srgrimes case 0x64: 11194Srgrimes seg = "%fs"; 11204Srgrimes break; 11214Srgrimes case 0x65: 11224Srgrimes seg = "%gs"; 11234Srgrimes break; 11244Srgrimes case 0xf0: 11254Srgrimes db_printf("lock "); 11264Srgrimes break; 11274Srgrimes case 0xf2: 11284Srgrimes db_printf("repne "); 11294Srgrimes break; 11304Srgrimes case 0xf3: 11314Srgrimes db_printf("repe "); /* XXX repe VS rep */ 11324Srgrimes break; 11334Srgrimes default: 11344Srgrimes prefix = FALSE; 11354Srgrimes break; 11364Srgrimes } 11374Srgrimes if (prefix) { 11384Srgrimes get_value_inc(inst, loc, 1, FALSE); 11394Srgrimes } 11404Srgrimes } while (prefix); 11414Srgrimes 11424Srgrimes if (inst >= 0xd8 && inst <= 0xdf) { 11434Srgrimes loc = db_disasm_esc(loc, inst, short_addr, size, seg); 11444Srgrimes db_printf("\n"); 11454Srgrimes return (loc); 11464Srgrimes } 11474Srgrimes 11484Srgrimes if (inst == 0x0f) { 11494Srgrimes get_value_inc(inst, loc, 1, FALSE); 11504Srgrimes ip = db_inst_0f[inst>>4]; 11514Srgrimes if (ip == 0) { 11524Srgrimes ip = &db_bad_inst; 11534Srgrimes } 11544Srgrimes else { 11554Srgrimes ip = &ip[inst&0xf]; 11564Srgrimes } 11574Srgrimes } 11584Srgrimes else 11594Srgrimes ip = &db_inst_table[inst]; 11604Srgrimes 11614Srgrimes if (ip->i_has_modrm) { 11624Srgrimes get_value_inc(regmodrm, loc, 1, FALSE); 11634Srgrimes loc = db_read_address(loc, short_addr, regmodrm, &address); 11644Srgrimes } 11654Srgrimes 11664Srgrimes i_name = ip->i_name; 11674Srgrimes i_size = ip->i_size; 11684Srgrimes i_mode = ip->i_mode; 11694Srgrimes 11704Srgrimes if (ip->i_extra == (char *)db_Grp1 || 11714Srgrimes ip->i_extra == (char *)db_Grp2 || 11724Srgrimes ip->i_extra == (char *)db_Grp6 || 11734Srgrimes ip->i_extra == (char *)db_Grp7 || 11744Srgrimes ip->i_extra == (char *)db_Grp8) { 11754Srgrimes i_name = ((char **)ip->i_extra)[f_reg(regmodrm)]; 11764Srgrimes } 11774Srgrimes else if (ip->i_extra == (char *)db_Grp3) { 11784Srgrimes ip = (struct inst *)ip->i_extra; 11794Srgrimes ip = &ip[f_reg(regmodrm)]; 11804Srgrimes i_name = ip->i_name; 11814Srgrimes i_mode = ip->i_mode; 11824Srgrimes } 11834Srgrimes else if (ip->i_extra == (char *)db_Grp4 || 11844Srgrimes ip->i_extra == (char *)db_Grp5) { 11854Srgrimes ip = (struct inst *)ip->i_extra; 11864Srgrimes ip = &ip[f_reg(regmodrm)]; 11874Srgrimes i_name = ip->i_name; 11884Srgrimes i_mode = ip->i_mode; 11894Srgrimes i_size = ip->i_size; 11904Srgrimes } 11914Srgrimes 11924Srgrimes if (i_size == SDEP) { 11934Srgrimes if (size == WORD) 11944Srgrimes db_printf(i_name); 11954Srgrimes else 11964Srgrimes db_printf(ip->i_extra); 11974Srgrimes } 11984Srgrimes else { 11994Srgrimes db_printf(i_name); 12004Srgrimes if (i_size != NONE) { 12014Srgrimes if (i_size == BYTE) { 12024Srgrimes db_printf("b"); 12034Srgrimes size = BYTE; 12044Srgrimes } 12054Srgrimes else if (i_size == WORD) { 12064Srgrimes db_printf("w"); 12074Srgrimes size = WORD; 12084Srgrimes } 12094Srgrimes else if (size == WORD) 12104Srgrimes db_printf("w"); 12114Srgrimes else 12124Srgrimes db_printf("l"); 12134Srgrimes } 12144Srgrimes } 12154Srgrimes db_printf("\t"); 12164Srgrimes for (first = TRUE; 12174Srgrimes i_mode != 0; 12184Srgrimes i_mode >>= 8, first = FALSE) 12194Srgrimes { 12204Srgrimes if (!first) 12214Srgrimes db_printf(","); 12224Srgrimes 12234Srgrimes switch (i_mode & 0xFF) { 12244Srgrimes 12254Srgrimes case E: 12264Srgrimes db_print_address(seg, size, &address); 12274Srgrimes break; 12284Srgrimes 12294Srgrimes case Eind: 12304Srgrimes db_printf("*"); 12314Srgrimes db_print_address(seg, size, &address); 12324Srgrimes break; 12334Srgrimes 12344Srgrimes case Ew: 12354Srgrimes db_print_address(seg, WORD, &address); 12364Srgrimes break; 12374Srgrimes 12384Srgrimes case Eb: 12394Srgrimes db_print_address(seg, BYTE, &address); 12404Srgrimes break; 12414Srgrimes 12424Srgrimes case R: 12434Srgrimes db_printf("%s", db_reg[size][f_reg(regmodrm)]); 12444Srgrimes break; 12454Srgrimes 12464Srgrimes case Rw: 12474Srgrimes db_printf("%s", db_reg[WORD][f_reg(regmodrm)]); 12484Srgrimes break; 12494Srgrimes 12504Srgrimes case Ri: 12514Srgrimes db_printf("%s", db_reg[size][f_rm(inst)]); 12524Srgrimes break; 12534Srgrimes 12544Srgrimes case S: 12554Srgrimes db_printf("%s", db_seg_reg[f_reg(regmodrm)]); 12564Srgrimes break; 12574Srgrimes 12584Srgrimes case Si: 12594Srgrimes db_printf("%s", db_seg_reg[f_reg(inst)]); 12604Srgrimes break; 12614Srgrimes 12624Srgrimes case A: 12634Srgrimes db_printf("%s", db_reg[size][0]); /* acc */ 12644Srgrimes break; 12654Srgrimes 12664Srgrimes case BX: 12674Srgrimes if (seg) 12684Srgrimes db_printf("%s:", seg); 12694Srgrimes db_printf("(%s)", short_addr ? "%bx" : "%ebx"); 12704Srgrimes break; 12714Srgrimes 12724Srgrimes case CL: 12734Srgrimes db_printf("%%cl"); 12744Srgrimes break; 12754Srgrimes 12764Srgrimes case DX: 12774Srgrimes db_printf("%%dx"); 12784Srgrimes break; 12794Srgrimes 12804Srgrimes case SI: 12814Srgrimes if (seg) 12824Srgrimes db_printf("%s:", seg); 12834Srgrimes db_printf("(%s)", short_addr ? "%si" : "%esi"); 12844Srgrimes break; 12854Srgrimes 12864Srgrimes case DI: 12874Srgrimes db_printf("%%es:(%s)", short_addr ? "%di" : "%edi"); 12884Srgrimes break; 12894Srgrimes 12904Srgrimes case CR: 12914Srgrimes db_printf("%%cr%d", f_reg(regmodrm)); 12924Srgrimes break; 12934Srgrimes 12944Srgrimes case DR: 12954Srgrimes db_printf("%%dr%d", f_reg(regmodrm)); 12964Srgrimes break; 12974Srgrimes 12984Srgrimes case TR: 12994Srgrimes db_printf("%%tr%d", f_reg(regmodrm)); 13004Srgrimes break; 13014Srgrimes 13024Srgrimes case I: 13034Srgrimes len = db_lengths[size]; 13044Srgrimes get_value_inc(imm, loc, len, FALSE);/* unsigned */ 13054Srgrimes db_printf("$%#n", imm); 13064Srgrimes break; 13074Srgrimes 13084Srgrimes case Is: 13094Srgrimes len = db_lengths[size]; 13104Srgrimes get_value_inc(imm, loc, len, TRUE); /* signed */ 13114Srgrimes db_printf("$%#r", imm); 13124Srgrimes break; 13134Srgrimes 13144Srgrimes case Ib: 13154Srgrimes get_value_inc(imm, loc, 1, FALSE); /* unsigned */ 13164Srgrimes db_printf("$%#n", imm); 13174Srgrimes break; 13184Srgrimes 13194Srgrimes case Ibs: 13204Srgrimes get_value_inc(imm, loc, 1, TRUE); /* signed */ 13214Srgrimes db_printf("$%#r", imm); 13224Srgrimes break; 13234Srgrimes 13244Srgrimes case Iw: 13254Srgrimes get_value_inc(imm, loc, 2, FALSE); /* unsigned */ 13264Srgrimes db_printf("$%#n", imm); 13274Srgrimes break; 13284Srgrimes 13294Srgrimes case Il: 13304Srgrimes get_value_inc(imm, loc, 4, FALSE); 13314Srgrimes db_printf("$%#n", imm); 13324Srgrimes break; 13334Srgrimes 13344Srgrimes case O: 13354Srgrimes if (short_addr) { 13364Srgrimes get_value_inc(displ, loc, 2, TRUE); 13374Srgrimes } 13384Srgrimes else { 13394Srgrimes get_value_inc(displ, loc, 4, TRUE); 13404Srgrimes } 13414Srgrimes if (seg) 13424Srgrimes db_printf("%s:%#r",seg, displ); 13434Srgrimes else 13444Srgrimes db_printsym((db_addr_t)displ, DB_STGY_ANY); 13454Srgrimes break; 13464Srgrimes 13474Srgrimes case Db: 13484Srgrimes get_value_inc(displ, loc, 1, TRUE); 13494Srgrimes db_printsym((db_addr_t)(displ + loc), DB_STGY_XTRN); 13504Srgrimes break; 13514Srgrimes 13524Srgrimes case Dl: 13534Srgrimes get_value_inc(displ, loc, 4, TRUE); 13544Srgrimes db_printsym((db_addr_t)(displ + loc), DB_STGY_XTRN); 13554Srgrimes break; 13564Srgrimes 13574Srgrimes case o1: 13584Srgrimes db_printf("$1"); 13594Srgrimes break; 13604Srgrimes 13614Srgrimes case o3: 13624Srgrimes db_printf("$3"); 13634Srgrimes break; 13644Srgrimes 13654Srgrimes case OS: 13664Srgrimes get_value_inc(imm, loc, 4, FALSE); /* offset */ 13674Srgrimes get_value_inc(imm2, loc, 2, FALSE); /* segment */ 13684Srgrimes db_printf("$%#n,%#n", imm2, imm); 13694Srgrimes break; 13704Srgrimes } 13714Srgrimes } 13724Srgrimes 13734Srgrimes if (altfmt == 0) { 13744Srgrimes if (inst == 0xe9 || inst == 0xeb) { 13754Srgrimes /* 13764Srgrimes * GAS pads to longword boundary after unconditional jumps. 13774Srgrimes */ 13784Srgrimes loc = (loc + (4-1)) & ~(4-1); 13794Srgrimes } 13804Srgrimes } 13814Srgrimes db_printf("\n"); 13824Srgrimes return (loc); 13834Srgrimes} 13844Srgrimes 1385