db_disasm.c revision 139731
1139731Simp/*- 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. 254Srgrimes */ 264Srgrimes 27118031Sobrien#include <sys/cdefs.h> 28118031Sobrien__FBSDID("$FreeBSD: head/sys/amd64/amd64/db_disasm.c 139731 2005-01-05 20:17:21Z imp $"); 29118031Sobrien 304Srgrimes/* 314Srgrimes * Instruction disassembler. 324Srgrimes */ 332056Swollman#include <sys/param.h> 3424494Sbde 352056Swollman#include <ddb/ddb.h> 364Srgrimes#include <ddb/db_access.h> 374Srgrimes#include <ddb/db_sym.h> 384Srgrimes 394Srgrimes/* 404Srgrimes * Size attributes 414Srgrimes */ 424Srgrimes#define BYTE 0 434Srgrimes#define WORD 1 444Srgrimes#define LONG 2 454Srgrimes#define QUAD 3 464Srgrimes#define SNGL 4 474Srgrimes#define DBLR 5 484Srgrimes#define EXTR 6 494Srgrimes#define SDEP 7 504Srgrimes#define NONE 8 514Srgrimes 524Srgrimes/* 534Srgrimes * Addressing modes 544Srgrimes */ 554Srgrimes#define E 1 /* general effective address */ 564Srgrimes#define Eind 2 /* indirect address (jump, call) */ 574Srgrimes#define Ew 3 /* address, word size */ 584Srgrimes#define Eb 4 /* address, byte size */ 594Srgrimes#define R 5 /* register, in 'reg' field */ 604Srgrimes#define Rw 6 /* word register, in 'reg' field */ 614Srgrimes#define Ri 7 /* register in instruction */ 624Srgrimes#define S 8 /* segment reg, in 'reg' field */ 634Srgrimes#define Si 9 /* segment reg, in instruction */ 644Srgrimes#define A 10 /* accumulator */ 654Srgrimes#define BX 11 /* (bx) */ 664Srgrimes#define CL 12 /* cl, for shifts */ 674Srgrimes#define DX 13 /* dx, for IO */ 684Srgrimes#define SI 14 /* si */ 694Srgrimes#define DI 15 /* di */ 704Srgrimes#define CR 16 /* control register */ 714Srgrimes#define DR 17 /* debug register */ 724Srgrimes#define TR 18 /* test register */ 734Srgrimes#define I 19 /* immediate, unsigned */ 744Srgrimes#define Is 20 /* immediate, signed */ 754Srgrimes#define Ib 21 /* byte immediate, unsigned */ 764Srgrimes#define Ibs 22 /* byte immediate, signed */ 774Srgrimes#define Iw 23 /* word immediate, unsigned */ 784Srgrimes#define O 25 /* direct address */ 794Srgrimes#define Db 26 /* byte displacement from EIP */ 804Srgrimes#define Dl 27 /* long displacement from EIP */ 814Srgrimes#define o1 28 /* constant 1 */ 824Srgrimes#define o3 29 /* constant 3 */ 834Srgrimes#define OS 30 /* immediate offset/segment */ 844Srgrimes#define ST 31 /* FP stack top */ 854Srgrimes#define STI 32 /* FP stack */ 864Srgrimes#define X 33 /* extended FP op */ 874Srgrimes#define XA 34 /* for 'fstcw %ax' */ 8821277Sbde#define El 35 /* address, long size */ 8921277Sbde#define Ril 36 /* long register in instruction */ 9021277Sbde#define Iba 37 /* byte immediate, don't print if 0xa */ 914Srgrimes 9211940Sbdestruct inst { 9314887Swollman const char * i_name; /* name */ 944Srgrimes short i_has_modrm; /* has regmodrm byte */ 954Srgrimes short i_size; /* operand size */ 964Srgrimes int i_mode; /* addressing modes */ 9717109Sbde const void * i_extra; /* pointer to extra opcode table */ 984Srgrimes}; 994Srgrimes 1004Srgrimes#define op1(x) (x) 1014Srgrimes#define op2(x,y) ((x)|((y)<<8)) 1024Srgrimes#define op3(x,y,z) ((x)|((y)<<8)|((z)<<16)) 1034Srgrimes 10411940Sbdestruct finst { 10514887Swollman const char * f_name; /* name for memory instruction */ 1064Srgrimes int f_size; /* size for memory instruction */ 1074Srgrimes int f_rrmode; /* mode for rr instruction */ 10817109Sbde const void * f_rrname; /* name for rr instruction 1094Srgrimes (or pointer to table) */ 1104Srgrimes}; 1114Srgrimes 11214887Swollmanstatic const char * const db_Grp6[] = { 1134Srgrimes "sldt", 1144Srgrimes "str", 1154Srgrimes "lldt", 1164Srgrimes "ltr", 1174Srgrimes "verr", 1184Srgrimes "verw", 1194Srgrimes "", 1204Srgrimes "" 1214Srgrimes}; 1224Srgrimes 12314887Swollmanstatic const char * const db_Grp7[] = { 1244Srgrimes "sgdt", 1254Srgrimes "sidt", 1264Srgrimes "lgdt", 1274Srgrimes "lidt", 1284Srgrimes "smsw", 1294Srgrimes "", 1304Srgrimes "lmsw", 1314Srgrimes "invlpg" 1324Srgrimes}; 1334Srgrimes 13414887Swollmanstatic const char * const db_Grp8[] = { 1354Srgrimes "", 1364Srgrimes "", 1374Srgrimes "", 1384Srgrimes "", 1394Srgrimes "bt", 1404Srgrimes "bts", 1414Srgrimes "btr", 1424Srgrimes "btc" 1434Srgrimes}; 1444Srgrimes 14521277Sbdestatic const char * const db_Grp9[] = { 14621277Sbde "", 14721277Sbde "cmpxchg8b", 14821277Sbde "", 14921277Sbde "", 15021277Sbde "", 15121277Sbde "", 15221277Sbde "", 15321277Sbde "" 15421277Sbde}; 15521277Sbde 15614887Swollmanstatic const struct inst db_inst_0f0x[] = { 15717109Sbde/*00*/ { "", TRUE, NONE, op1(Ew), db_Grp6 }, 15817109Sbde/*01*/ { "", TRUE, NONE, op1(Ew), db_Grp7 }, 1594Srgrimes/*02*/ { "lar", TRUE, LONG, op2(E,R), 0 }, 1604Srgrimes/*03*/ { "lsl", TRUE, LONG, op2(E,R), 0 }, 1614Srgrimes/*04*/ { "", FALSE, NONE, 0, 0 }, 1624Srgrimes/*05*/ { "", FALSE, NONE, 0, 0 }, 1634Srgrimes/*06*/ { "clts", FALSE, NONE, 0, 0 }, 1644Srgrimes/*07*/ { "", FALSE, NONE, 0, 0 }, 1654Srgrimes 1664Srgrimes/*08*/ { "invd", FALSE, NONE, 0, 0 }, 1674Srgrimes/*09*/ { "wbinvd",FALSE, NONE, 0, 0 }, 1684Srgrimes/*0a*/ { "", FALSE, NONE, 0, 0 }, 1694Srgrimes/*0b*/ { "", FALSE, NONE, 0, 0 }, 1704Srgrimes/*0c*/ { "", FALSE, NONE, 0, 0 }, 1714Srgrimes/*0d*/ { "", FALSE, NONE, 0, 0 }, 1724Srgrimes/*0e*/ { "", FALSE, NONE, 0, 0 }, 1734Srgrimes/*0f*/ { "", FALSE, NONE, 0, 0 }, 1744Srgrimes}; 1754Srgrimes 17617109Sbdestatic const struct inst db_inst_0f2x[] = { 17721277Sbde/*20*/ { "mov", TRUE, LONG, op2(CR,El), 0 }, 17821277Sbde/*21*/ { "mov", TRUE, LONG, op2(DR,El), 0 }, 17921277Sbde/*22*/ { "mov", TRUE, LONG, op2(El,CR), 0 }, 18021277Sbde/*23*/ { "mov", TRUE, LONG, op2(El,DR), 0 }, 18121277Sbde/*24*/ { "mov", TRUE, LONG, op2(TR,El), 0 }, 1824Srgrimes/*25*/ { "", FALSE, NONE, 0, 0 }, 18321277Sbde/*26*/ { "mov", TRUE, LONG, op2(El,TR), 0 }, 1844Srgrimes/*27*/ { "", FALSE, NONE, 0, 0 }, 1854Srgrimes 1864Srgrimes/*28*/ { "", FALSE, NONE, 0, 0 }, 1874Srgrimes/*29*/ { "", FALSE, NONE, 0, 0 }, 1884Srgrimes/*2a*/ { "", FALSE, NONE, 0, 0 }, 1894Srgrimes/*2b*/ { "", FALSE, NONE, 0, 0 }, 1904Srgrimes/*2c*/ { "", FALSE, NONE, 0, 0 }, 1914Srgrimes/*2d*/ { "", FALSE, NONE, 0, 0 }, 1924Srgrimes/*2e*/ { "", FALSE, NONE, 0, 0 }, 1934Srgrimes/*2f*/ { "", FALSE, NONE, 0, 0 }, 1944Srgrimes}; 1954Srgrimes 19614887Swollmanstatic const struct inst db_inst_0f3x[] = { 19714887Swollman/*30*/ { "wrmsr", FALSE, NONE, 0, 0 }, 19814887Swollman/*31*/ { "rdtsc", FALSE, NONE, 0, 0 }, 19914887Swollman/*32*/ { "rdmsr", FALSE, NONE, 0, 0 }, 20014887Swollman/*33*/ { "rdpmc", FALSE, NONE, 0, 0 }, 20114887Swollman/*34*/ { "", FALSE, NONE, 0, 0 }, 20214887Swollman/*35*/ { "", FALSE, NONE, 0, 0 }, 20314887Swollman/*36*/ { "", FALSE, NONE, 0, 0 }, 20414887Swollman/*37*/ { "", FALSE, NONE, 0, 0 }, 20514887Swollman 20614887Swollman/*38*/ { "", FALSE, NONE, 0, 0 }, 20714887Swollman/*39*/ { "", FALSE, NONE, 0, 0 }, 20814887Swollman/*3a*/ { "", FALSE, NONE, 0, 0 }, 20914887Swollman/*3b*/ { "", FALSE, NONE, 0, 0 }, 21014887Swollman/*3c*/ { "", FALSE, NONE, 0, 0 }, 21114887Swollman/*3d*/ { "", FALSE, NONE, 0, 0 }, 21214887Swollman/*3e*/ { "", FALSE, NONE, 0, 0 }, 21314887Swollman/*3f*/ { "", FALSE, NONE, 0, 0 }, 21414887Swollman}; 21514887Swollman 21617109Sbdestatic const struct inst db_inst_0f8x[] = { 2174Srgrimes/*80*/ { "jo", FALSE, NONE, op1(Dl), 0 }, 2184Srgrimes/*81*/ { "jno", FALSE, NONE, op1(Dl), 0 }, 2194Srgrimes/*82*/ { "jb", FALSE, NONE, op1(Dl), 0 }, 2204Srgrimes/*83*/ { "jnb", FALSE, NONE, op1(Dl), 0 }, 2214Srgrimes/*84*/ { "jz", FALSE, NONE, op1(Dl), 0 }, 2224Srgrimes/*85*/ { "jnz", FALSE, NONE, op1(Dl), 0 }, 2234Srgrimes/*86*/ { "jbe", FALSE, NONE, op1(Dl), 0 }, 2244Srgrimes/*87*/ { "jnbe", FALSE, NONE, op1(Dl), 0 }, 2254Srgrimes 2264Srgrimes/*88*/ { "js", FALSE, NONE, op1(Dl), 0 }, 2274Srgrimes/*89*/ { "jns", FALSE, NONE, op1(Dl), 0 }, 2284Srgrimes/*8a*/ { "jp", FALSE, NONE, op1(Dl), 0 }, 2294Srgrimes/*8b*/ { "jnp", FALSE, NONE, op1(Dl), 0 }, 2304Srgrimes/*8c*/ { "jl", FALSE, NONE, op1(Dl), 0 }, 2314Srgrimes/*8d*/ { "jnl", FALSE, NONE, op1(Dl), 0 }, 2324Srgrimes/*8e*/ { "jle", FALSE, NONE, op1(Dl), 0 }, 2334Srgrimes/*8f*/ { "jnle", FALSE, NONE, op1(Dl), 0 }, 2344Srgrimes}; 2354Srgrimes 23617109Sbdestatic const struct inst db_inst_0f9x[] = { 2374Srgrimes/*90*/ { "seto", TRUE, NONE, op1(Eb), 0 }, 2384Srgrimes/*91*/ { "setno", TRUE, NONE, op1(Eb), 0 }, 2394Srgrimes/*92*/ { "setb", TRUE, NONE, op1(Eb), 0 }, 2404Srgrimes/*93*/ { "setnb", TRUE, NONE, op1(Eb), 0 }, 2414Srgrimes/*94*/ { "setz", TRUE, NONE, op1(Eb), 0 }, 2424Srgrimes/*95*/ { "setnz", TRUE, NONE, op1(Eb), 0 }, 2434Srgrimes/*96*/ { "setbe", TRUE, NONE, op1(Eb), 0 }, 2444Srgrimes/*97*/ { "setnbe",TRUE, NONE, op1(Eb), 0 }, 2454Srgrimes 2464Srgrimes/*98*/ { "sets", TRUE, NONE, op1(Eb), 0 }, 2474Srgrimes/*99*/ { "setns", TRUE, NONE, op1(Eb), 0 }, 2484Srgrimes/*9a*/ { "setp", TRUE, NONE, op1(Eb), 0 }, 2494Srgrimes/*9b*/ { "setnp", TRUE, NONE, op1(Eb), 0 }, 2504Srgrimes/*9c*/ { "setl", TRUE, NONE, op1(Eb), 0 }, 2514Srgrimes/*9d*/ { "setnl", TRUE, NONE, op1(Eb), 0 }, 2524Srgrimes/*9e*/ { "setle", TRUE, NONE, op1(Eb), 0 }, 2534Srgrimes/*9f*/ { "setnle",TRUE, NONE, op1(Eb), 0 }, 2544Srgrimes}; 2554Srgrimes 25617109Sbdestatic const struct inst db_inst_0fax[] = { 2574Srgrimes/*a0*/ { "push", FALSE, NONE, op1(Si), 0 }, 2584Srgrimes/*a1*/ { "pop", FALSE, NONE, op1(Si), 0 }, 25921277Sbde/*a2*/ { "cpuid", FALSE, NONE, 0, 0 }, 26021277Sbde/*a3*/ { "bt", TRUE, LONG, op2(R,E), 0 }, 26117109Sbde/*a4*/ { "shld", TRUE, LONG, op3(Ib,R,E), 0 }, 26217109Sbde/*a5*/ { "shld", TRUE, LONG, op3(CL,R,E), 0 }, 2634Srgrimes/*a6*/ { "", FALSE, NONE, 0, 0 }, 2644Srgrimes/*a7*/ { "", FALSE, NONE, 0, 0 }, 2654Srgrimes 2664Srgrimes/*a8*/ { "push", FALSE, NONE, op1(Si), 0 }, 2674Srgrimes/*a9*/ { "pop", FALSE, NONE, op1(Si), 0 }, 26821277Sbde/*aa*/ { "rsm", FALSE, NONE, 0, 0 }, 26921277Sbde/*ab*/ { "bts", TRUE, LONG, op2(R,E), 0 }, 27017109Sbde/*ac*/ { "shrd", TRUE, LONG, op3(Ib,R,E), 0 }, 27117109Sbde/*ad*/ { "shrd", TRUE, LONG, op3(CL,R,E), 0 }, 2724Srgrimes/*a6*/ { "", FALSE, NONE, 0, 0 }, 2734Srgrimes/*a7*/ { "imul", TRUE, LONG, op2(E,R), 0 }, 2744Srgrimes}; 2754Srgrimes 27617109Sbdestatic const struct inst db_inst_0fbx[] = { 27721277Sbde/*b0*/ { "cmpxchg",TRUE, BYTE, op2(R, E), 0 }, 27821277Sbde/*b0*/ { "cmpxchg",TRUE, LONG, op2(R, E), 0 }, 2794Srgrimes/*b2*/ { "lss", TRUE, LONG, op2(E, R), 0 }, 28021277Sbde/*b3*/ { "btr", TRUE, LONG, op2(R, E), 0 }, 2814Srgrimes/*b4*/ { "lfs", TRUE, LONG, op2(E, R), 0 }, 2824Srgrimes/*b5*/ { "lgs", TRUE, LONG, op2(E, R), 0 }, 28321277Sbde/*b6*/ { "movzb", TRUE, LONG, op2(Eb, R), 0 }, 28421277Sbde/*b7*/ { "movzw", TRUE, LONG, op2(Ew, R), 0 }, 2854Srgrimes 2864Srgrimes/*b8*/ { "", FALSE, NONE, 0, 0 }, 2874Srgrimes/*b9*/ { "", FALSE, NONE, 0, 0 }, 28817109Sbde/*ba*/ { "", TRUE, LONG, op2(Ib, E), db_Grp8 }, 2894Srgrimes/*bb*/ { "btc", TRUE, LONG, op2(R, E), 0 }, 2904Srgrimes/*bc*/ { "bsf", TRUE, LONG, op2(E, R), 0 }, 2914Srgrimes/*bd*/ { "bsr", TRUE, LONG, op2(E, R), 0 }, 29221277Sbde/*be*/ { "movsb", TRUE, LONG, op2(Eb, R), 0 }, 29321277Sbde/*bf*/ { "movsw", TRUE, LONG, op2(Ew, R), 0 }, 2944Srgrimes}; 2954Srgrimes 29617109Sbdestatic const struct inst db_inst_0fcx[] = { 2974Srgrimes/*c0*/ { "xadd", TRUE, BYTE, op2(R, E), 0 }, 2984Srgrimes/*c1*/ { "xadd", TRUE, LONG, op2(R, E), 0 }, 2994Srgrimes/*c2*/ { "", FALSE, NONE, 0, 0 }, 3004Srgrimes/*c3*/ { "", FALSE, NONE, 0, 0 }, 3014Srgrimes/*c4*/ { "", FALSE, NONE, 0, 0 }, 3024Srgrimes/*c5*/ { "", FALSE, NONE, 0, 0 }, 3034Srgrimes/*c6*/ { "", FALSE, NONE, 0, 0 }, 30421277Sbde/*c7*/ { "", TRUE, NONE, op1(E), db_Grp9 }, 30521277Sbde/*c8*/ { "bswap", FALSE, LONG, op1(Ril), 0 }, 30621277Sbde/*c9*/ { "bswap", FALSE, LONG, op1(Ril), 0 }, 30721277Sbde/*ca*/ { "bswap", FALSE, LONG, op1(Ril), 0 }, 30821277Sbde/*cb*/ { "bswap", FALSE, LONG, op1(Ril), 0 }, 30921277Sbde/*cc*/ { "bswap", FALSE, LONG, op1(Ril), 0 }, 31021277Sbde/*cd*/ { "bswap", FALSE, LONG, op1(Ril), 0 }, 31121277Sbde/*ce*/ { "bswap", FALSE, LONG, op1(Ril), 0 }, 31221277Sbde/*cf*/ { "bswap", FALSE, LONG, op1(Ril), 0 }, 3134Srgrimes}; 3144Srgrimes 31514887Swollmanstatic const struct inst * const db_inst_0f[] = { 3164Srgrimes db_inst_0f0x, 3174Srgrimes 0, 3184Srgrimes db_inst_0f2x, 31914887Swollman db_inst_0f3x, 3204Srgrimes 0, 3214Srgrimes 0, 3224Srgrimes 0, 3234Srgrimes 0, 3244Srgrimes db_inst_0f8x, 3254Srgrimes db_inst_0f9x, 3264Srgrimes db_inst_0fax, 3274Srgrimes db_inst_0fbx, 3284Srgrimes db_inst_0fcx, 3294Srgrimes 0, 33021277Sbde 0, 3314Srgrimes 0 3324Srgrimes}; 3334Srgrimes 33414887Swollmanstatic const char * const db_Esc92[] = { 3354Srgrimes "fnop", "", "", "", "", "", "", "" 3364Srgrimes}; 33714887Swollmanstatic const char * const db_Esc94[] = { 3384Srgrimes "fchs", "fabs", "", "", "ftst", "fxam", "", "" 3394Srgrimes}; 34017109Sbdestatic const char * const db_Esc95[] = { 3414Srgrimes "fld1", "fldl2t","fldl2e","fldpi","fldlg2","fldln2","fldz","" 3424Srgrimes}; 34317109Sbdestatic const char * const db_Esc96[] = { 3444Srgrimes "f2xm1","fyl2x","fptan","fpatan","fxtract","fprem1","fdecstp", 3454Srgrimes "fincstp" 3464Srgrimes}; 34714887Swollmanstatic const char * const db_Esc97[] = { 3484Srgrimes "fprem","fyl2xp1","fsqrt","fsincos","frndint","fscale","fsin","fcos" 3494Srgrimes}; 3504Srgrimes 35121277Sbdestatic const char * const db_Esca5[] = { 3524Srgrimes "", "fucompp","", "", "", "", "", "" 3534Srgrimes}; 3544Srgrimes 35517109Sbdestatic const char * const db_Escb4[] = { 35621277Sbde "fneni","fndisi", "fnclex","fninit","fsetpm", "", "", "" 3574Srgrimes}; 3584Srgrimes 35914887Swollmanstatic const char * const db_Esce3[] = { 3604Srgrimes "", "fcompp","", "", "", "", "", "" 3614Srgrimes}; 3624Srgrimes 36317109Sbdestatic const char * const db_Escf4[] = { 3644Srgrimes "fnstsw","", "", "", "", "", "", "" 3654Srgrimes}; 3664Srgrimes 36714887Swollmanstatic const struct finst db_Esc8[] = { 3684Srgrimes/*0*/ { "fadd", SNGL, op2(STI,ST), 0 }, 3694Srgrimes/*1*/ { "fmul", SNGL, op2(STI,ST), 0 }, 3704Srgrimes/*2*/ { "fcom", SNGL, op2(STI,ST), 0 }, 3714Srgrimes/*3*/ { "fcomp", SNGL, op2(STI,ST), 0 }, 3724Srgrimes/*4*/ { "fsub", SNGL, op2(STI,ST), 0 }, 3734Srgrimes/*5*/ { "fsubr", SNGL, op2(STI,ST), 0 }, 3744Srgrimes/*6*/ { "fdiv", SNGL, op2(STI,ST), 0 }, 3754Srgrimes/*7*/ { "fdivr", SNGL, op2(STI,ST), 0 }, 3764Srgrimes}; 3774Srgrimes 37814887Swollmanstatic const struct finst db_Esc9[] = { 3794Srgrimes/*0*/ { "fld", SNGL, op1(STI), 0 }, 3804Srgrimes/*1*/ { "", NONE, op1(STI), "fxch" }, 38117109Sbde/*2*/ { "fst", SNGL, op1(X), db_Esc92 }, 38221277Sbde/*3*/ { "fstp", SNGL, 0, 0 }, 38317109Sbde/*4*/ { "fldenv", NONE, op1(X), db_Esc94 }, 38417109Sbde/*5*/ { "fldcw", NONE, op1(X), db_Esc95 }, 38517109Sbde/*6*/ { "fnstenv",NONE, op1(X), db_Esc96 }, 38617109Sbde/*7*/ { "fnstcw", NONE, op1(X), db_Esc97 }, 3874Srgrimes}; 3884Srgrimes 38914887Swollmanstatic const struct finst db_Esca[] = { 39021277Sbde/*0*/ { "fiadd", LONG, 0, 0 }, 39121277Sbde/*1*/ { "fimul", LONG, 0, 0 }, 39221277Sbde/*2*/ { "ficom", LONG, 0, 0 }, 39321277Sbde/*3*/ { "ficomp", LONG, 0, 0 }, 39421277Sbde/*4*/ { "fisub", LONG, 0, 0 }, 39521277Sbde/*5*/ { "fisubr", LONG, op1(X), db_Esca5 }, 39621277Sbde/*6*/ { "fidiv", LONG, 0, 0 }, 39721277Sbde/*7*/ { "fidivr", LONG, 0, 0 } 3984Srgrimes}; 3994Srgrimes 40014887Swollmanstatic const struct finst db_Escb[] = { 40121277Sbde/*0*/ { "fild", LONG, 0, 0 }, 4024Srgrimes/*1*/ { "", NONE, 0, 0 }, 40321277Sbde/*2*/ { "fist", LONG, 0, 0 }, 40421277Sbde/*3*/ { "fistp", LONG, 0, 0 }, 40517109Sbde/*4*/ { "", WORD, op1(X), db_Escb4 }, 4064Srgrimes/*5*/ { "fld", EXTR, 0, 0 }, 4074Srgrimes/*6*/ { "", WORD, 0, 0 }, 4084Srgrimes/*7*/ { "fstp", EXTR, 0, 0 }, 4094Srgrimes}; 4104Srgrimes 41114887Swollmanstatic const struct finst db_Escc[] = { 4124Srgrimes/*0*/ { "fadd", DBLR, op2(ST,STI), 0 }, 4134Srgrimes/*1*/ { "fmul", DBLR, op2(ST,STI), 0 }, 41421277Sbde/*2*/ { "fcom", DBLR, 0, 0 }, 41521277Sbde/*3*/ { "fcomp", DBLR, 0, 0 }, 4164Srgrimes/*4*/ { "fsub", DBLR, op2(ST,STI), "fsubr" }, 4174Srgrimes/*5*/ { "fsubr", DBLR, op2(ST,STI), "fsub" }, 4184Srgrimes/*6*/ { "fdiv", DBLR, op2(ST,STI), "fdivr" }, 4194Srgrimes/*7*/ { "fdivr", DBLR, op2(ST,STI), "fdiv" }, 4204Srgrimes}; 4214Srgrimes 42214887Swollmanstatic const struct finst db_Escd[] = { 4234Srgrimes/*0*/ { "fld", DBLR, op1(STI), "ffree" }, 4244Srgrimes/*1*/ { "", NONE, 0, 0 }, 4254Srgrimes/*2*/ { "fst", DBLR, op1(STI), 0 }, 4264Srgrimes/*3*/ { "fstp", DBLR, op1(STI), 0 }, 4274Srgrimes/*4*/ { "frstor", NONE, op1(STI), "fucom" }, 4284Srgrimes/*5*/ { "", NONE, op1(STI), "fucomp" }, 4294Srgrimes/*6*/ { "fnsave", NONE, 0, 0 }, 4304Srgrimes/*7*/ { "fnstsw", NONE, 0, 0 }, 4314Srgrimes}; 4324Srgrimes 43314887Swollmanstatic const struct finst db_Esce[] = { 43421277Sbde/*0*/ { "fiadd", WORD, op2(ST,STI), "faddp" }, 43521277Sbde/*1*/ { "fimul", WORD, op2(ST,STI), "fmulp" }, 43621277Sbde/*2*/ { "ficom", WORD, 0, 0 }, 43721277Sbde/*3*/ { "ficomp", WORD, op1(X), db_Esce3 }, 43821277Sbde/*4*/ { "fisub", WORD, op2(ST,STI), "fsubrp" }, 43921277Sbde/*5*/ { "fisubr", WORD, op2(ST,STI), "fsubp" }, 44021277Sbde/*6*/ { "fidiv", WORD, op2(ST,STI), "fdivrp" }, 44121277Sbde/*7*/ { "fidivr", WORD, op2(ST,STI), "fdivp" }, 4424Srgrimes}; 4434Srgrimes 44414887Swollmanstatic const struct finst db_Escf[] = { 44521277Sbde/*0*/ { "fild", WORD, 0, 0 }, 44621277Sbde/*1*/ { "", NONE, 0, 0 }, 44721277Sbde/*2*/ { "fist", WORD, 0, 0 }, 44821277Sbde/*3*/ { "fistp", WORD, 0, 0 }, 44917109Sbde/*4*/ { "fbld", NONE, op1(XA), db_Escf4 }, 45021277Sbde/*5*/ { "fild", QUAD, 0, 0 }, 4514Srgrimes/*6*/ { "fbstp", NONE, 0, 0 }, 45221277Sbde/*7*/ { "fistp", QUAD, 0, 0 }, 4534Srgrimes}; 4544Srgrimes 45517109Sbdestatic const struct finst * const db_Esc_inst[] = { 4564Srgrimes db_Esc8, db_Esc9, db_Esca, db_Escb, 4574Srgrimes db_Escc, db_Escd, db_Esce, db_Escf 4584Srgrimes}; 4594Srgrimes 46014887Swollmanstatic const char * const db_Grp1[] = { 4614Srgrimes "add", 4624Srgrimes "or", 4634Srgrimes "adc", 4644Srgrimes "sbb", 4654Srgrimes "and", 4664Srgrimes "sub", 4674Srgrimes "xor", 4684Srgrimes "cmp" 4694Srgrimes}; 4704Srgrimes 47114887Swollmanstatic const char * const db_Grp2[] = { 4724Srgrimes "rol", 4734Srgrimes "ror", 4744Srgrimes "rcl", 4754Srgrimes "rcr", 4764Srgrimes "shl", 4774Srgrimes "shr", 4784Srgrimes "shl", 4794Srgrimes "sar" 4804Srgrimes}; 4814Srgrimes 48214887Swollmanstatic const struct inst db_Grp3[] = { 4834Srgrimes { "test", TRUE, NONE, op2(I,E), 0 }, 4844Srgrimes { "test", TRUE, NONE, op2(I,E), 0 }, 4854Srgrimes { "not", TRUE, NONE, op1(E), 0 }, 4864Srgrimes { "neg", TRUE, NONE, op1(E), 0 }, 4874Srgrimes { "mul", TRUE, NONE, op2(E,A), 0 }, 4884Srgrimes { "imul", TRUE, NONE, op2(E,A), 0 }, 4894Srgrimes { "div", TRUE, NONE, op2(E,A), 0 }, 4904Srgrimes { "idiv", TRUE, NONE, op2(E,A), 0 }, 4914Srgrimes}; 4924Srgrimes 49317109Sbdestatic const struct inst db_Grp4[] = { 4944Srgrimes { "inc", TRUE, BYTE, op1(E), 0 }, 4954Srgrimes { "dec", TRUE, BYTE, op1(E), 0 }, 4964Srgrimes { "", TRUE, NONE, 0, 0 }, 4974Srgrimes { "", TRUE, NONE, 0, 0 }, 4984Srgrimes { "", TRUE, NONE, 0, 0 }, 4994Srgrimes { "", TRUE, NONE, 0, 0 }, 5004Srgrimes { "", TRUE, NONE, 0, 0 }, 5014Srgrimes { "", TRUE, NONE, 0, 0 } 5024Srgrimes}; 5034Srgrimes 50417109Sbdestatic const struct inst db_Grp5[] = { 5054Srgrimes { "inc", TRUE, LONG, op1(E), 0 }, 5064Srgrimes { "dec", TRUE, LONG, op1(E), 0 }, 50721277Sbde { "call", TRUE, LONG, op1(Eind),0 }, 50821277Sbde { "lcall", TRUE, LONG, op1(Eind),0 }, 50921277Sbde { "jmp", TRUE, LONG, op1(Eind),0 }, 51021277Sbde { "ljmp", TRUE, LONG, op1(Eind),0 }, 5114Srgrimes { "push", TRUE, LONG, op1(E), 0 }, 5124Srgrimes { "", TRUE, NONE, 0, 0 } 5134Srgrimes}; 5144Srgrimes 51514887Swollmanstatic const struct inst db_inst_table[256] = { 5164Srgrimes/*00*/ { "add", TRUE, BYTE, op2(R, E), 0 }, 5174Srgrimes/*01*/ { "add", TRUE, LONG, op2(R, E), 0 }, 5184Srgrimes/*02*/ { "add", TRUE, BYTE, op2(E, R), 0 }, 5194Srgrimes/*03*/ { "add", TRUE, LONG, op2(E, R), 0 }, 52021277Sbde/*04*/ { "add", FALSE, BYTE, op2(I, A), 0 }, 5214Srgrimes/*05*/ { "add", FALSE, LONG, op2(Is, A), 0 }, 5224Srgrimes/*06*/ { "push", FALSE, NONE, op1(Si), 0 }, 5234Srgrimes/*07*/ { "pop", FALSE, NONE, op1(Si), 0 }, 5244Srgrimes 5254Srgrimes/*08*/ { "or", TRUE, BYTE, op2(R, E), 0 }, 5264Srgrimes/*09*/ { "or", TRUE, LONG, op2(R, E), 0 }, 5274Srgrimes/*0a*/ { "or", TRUE, BYTE, op2(E, R), 0 }, 5284Srgrimes/*0b*/ { "or", TRUE, LONG, op2(E, R), 0 }, 5294Srgrimes/*0c*/ { "or", FALSE, BYTE, op2(I, A), 0 }, 5304Srgrimes/*0d*/ { "or", FALSE, LONG, op2(I, A), 0 }, 5314Srgrimes/*0e*/ { "push", FALSE, NONE, op1(Si), 0 }, 5324Srgrimes/*0f*/ { "", FALSE, NONE, 0, 0 }, 5334Srgrimes 5344Srgrimes/*10*/ { "adc", TRUE, BYTE, op2(R, E), 0 }, 5354Srgrimes/*11*/ { "adc", TRUE, LONG, op2(R, E), 0 }, 5364Srgrimes/*12*/ { "adc", TRUE, BYTE, op2(E, R), 0 }, 5374Srgrimes/*13*/ { "adc", TRUE, LONG, op2(E, R), 0 }, 53821277Sbde/*14*/ { "adc", FALSE, BYTE, op2(I, A), 0 }, 5394Srgrimes/*15*/ { "adc", FALSE, LONG, op2(Is, A), 0 }, 5404Srgrimes/*16*/ { "push", FALSE, NONE, op1(Si), 0 }, 5414Srgrimes/*17*/ { "pop", FALSE, NONE, op1(Si), 0 }, 5424Srgrimes 5434Srgrimes/*18*/ { "sbb", TRUE, BYTE, op2(R, E), 0 }, 5444Srgrimes/*19*/ { "sbb", TRUE, LONG, op2(R, E), 0 }, 5454Srgrimes/*1a*/ { "sbb", TRUE, BYTE, op2(E, R), 0 }, 5464Srgrimes/*1b*/ { "sbb", TRUE, LONG, op2(E, R), 0 }, 54721277Sbde/*1c*/ { "sbb", FALSE, BYTE, op2(I, A), 0 }, 5484Srgrimes/*1d*/ { "sbb", FALSE, LONG, op2(Is, A), 0 }, 5494Srgrimes/*1e*/ { "push", FALSE, NONE, op1(Si), 0 }, 5504Srgrimes/*1f*/ { "pop", FALSE, NONE, op1(Si), 0 }, 5514Srgrimes 5524Srgrimes/*20*/ { "and", TRUE, BYTE, op2(R, E), 0 }, 5534Srgrimes/*21*/ { "and", TRUE, LONG, op2(R, E), 0 }, 5544Srgrimes/*22*/ { "and", TRUE, BYTE, op2(E, R), 0 }, 5554Srgrimes/*23*/ { "and", TRUE, LONG, op2(E, R), 0 }, 5564Srgrimes/*24*/ { "and", FALSE, BYTE, op2(I, A), 0 }, 5574Srgrimes/*25*/ { "and", FALSE, LONG, op2(I, A), 0 }, 5584Srgrimes/*26*/ { "", FALSE, NONE, 0, 0 }, 55921277Sbde/*27*/ { "daa", FALSE, NONE, 0, 0 }, 5604Srgrimes 5614Srgrimes/*28*/ { "sub", TRUE, BYTE, op2(R, E), 0 }, 5624Srgrimes/*29*/ { "sub", TRUE, LONG, op2(R, E), 0 }, 5634Srgrimes/*2a*/ { "sub", TRUE, BYTE, op2(E, R), 0 }, 5644Srgrimes/*2b*/ { "sub", TRUE, LONG, op2(E, R), 0 }, 56521277Sbde/*2c*/ { "sub", FALSE, BYTE, op2(I, A), 0 }, 5664Srgrimes/*2d*/ { "sub", FALSE, LONG, op2(Is, A), 0 }, 5674Srgrimes/*2e*/ { "", FALSE, NONE, 0, 0 }, 5684Srgrimes/*2f*/ { "das", FALSE, NONE, 0, 0 }, 5694Srgrimes 5704Srgrimes/*30*/ { "xor", TRUE, BYTE, op2(R, E), 0 }, 5714Srgrimes/*31*/ { "xor", TRUE, LONG, op2(R, E), 0 }, 5724Srgrimes/*32*/ { "xor", TRUE, BYTE, op2(E, R), 0 }, 5734Srgrimes/*33*/ { "xor", TRUE, LONG, op2(E, R), 0 }, 5744Srgrimes/*34*/ { "xor", FALSE, BYTE, op2(I, A), 0 }, 5754Srgrimes/*35*/ { "xor", FALSE, LONG, op2(I, A), 0 }, 5764Srgrimes/*36*/ { "", FALSE, NONE, 0, 0 }, 57721277Sbde/*37*/ { "aaa", FALSE, NONE, 0, 0 }, 5784Srgrimes 5794Srgrimes/*38*/ { "cmp", TRUE, BYTE, op2(R, E), 0 }, 5804Srgrimes/*39*/ { "cmp", TRUE, LONG, op2(R, E), 0 }, 5814Srgrimes/*3a*/ { "cmp", TRUE, BYTE, op2(E, R), 0 }, 5824Srgrimes/*3b*/ { "cmp", TRUE, LONG, op2(E, R), 0 }, 58321277Sbde/*3c*/ { "cmp", FALSE, BYTE, op2(I, A), 0 }, 5844Srgrimes/*3d*/ { "cmp", FALSE, LONG, op2(Is, A), 0 }, 5854Srgrimes/*3e*/ { "", FALSE, NONE, 0, 0 }, 5864Srgrimes/*3f*/ { "aas", FALSE, NONE, 0, 0 }, 5874Srgrimes 5884Srgrimes/*40*/ { "inc", FALSE, LONG, op1(Ri), 0 }, 5894Srgrimes/*41*/ { "inc", FALSE, LONG, op1(Ri), 0 }, 5904Srgrimes/*42*/ { "inc", FALSE, LONG, op1(Ri), 0 }, 5914Srgrimes/*43*/ { "inc", FALSE, LONG, op1(Ri), 0 }, 5924Srgrimes/*44*/ { "inc", FALSE, LONG, op1(Ri), 0 }, 5934Srgrimes/*45*/ { "inc", FALSE, LONG, op1(Ri), 0 }, 5944Srgrimes/*46*/ { "inc", FALSE, LONG, op1(Ri), 0 }, 5954Srgrimes/*47*/ { "inc", FALSE, LONG, op1(Ri), 0 }, 5964Srgrimes 5974Srgrimes/*48*/ { "dec", FALSE, LONG, op1(Ri), 0 }, 5984Srgrimes/*49*/ { "dec", FALSE, LONG, op1(Ri), 0 }, 5994Srgrimes/*4a*/ { "dec", FALSE, LONG, op1(Ri), 0 }, 6004Srgrimes/*4b*/ { "dec", FALSE, LONG, op1(Ri), 0 }, 6014Srgrimes/*4c*/ { "dec", FALSE, LONG, op1(Ri), 0 }, 6024Srgrimes/*4d*/ { "dec", FALSE, LONG, op1(Ri), 0 }, 6034Srgrimes/*4e*/ { "dec", FALSE, LONG, op1(Ri), 0 }, 6044Srgrimes/*4f*/ { "dec", FALSE, LONG, op1(Ri), 0 }, 6054Srgrimes 6064Srgrimes/*50*/ { "push", FALSE, LONG, op1(Ri), 0 }, 6074Srgrimes/*51*/ { "push", FALSE, LONG, op1(Ri), 0 }, 6084Srgrimes/*52*/ { "push", FALSE, LONG, op1(Ri), 0 }, 6094Srgrimes/*53*/ { "push", FALSE, LONG, op1(Ri), 0 }, 6104Srgrimes/*54*/ { "push", FALSE, LONG, op1(Ri), 0 }, 6114Srgrimes/*55*/ { "push", FALSE, LONG, op1(Ri), 0 }, 6124Srgrimes/*56*/ { "push", FALSE, LONG, op1(Ri), 0 }, 6134Srgrimes/*57*/ { "push", FALSE, LONG, op1(Ri), 0 }, 6144Srgrimes 6154Srgrimes/*58*/ { "pop", FALSE, LONG, op1(Ri), 0 }, 6164Srgrimes/*59*/ { "pop", FALSE, LONG, op1(Ri), 0 }, 6174Srgrimes/*5a*/ { "pop", FALSE, LONG, op1(Ri), 0 }, 6184Srgrimes/*5b*/ { "pop", FALSE, LONG, op1(Ri), 0 }, 6194Srgrimes/*5c*/ { "pop", FALSE, LONG, op1(Ri), 0 }, 6204Srgrimes/*5d*/ { "pop", FALSE, LONG, op1(Ri), 0 }, 6214Srgrimes/*5e*/ { "pop", FALSE, LONG, op1(Ri), 0 }, 6224Srgrimes/*5f*/ { "pop", FALSE, LONG, op1(Ri), 0 }, 6234Srgrimes 6244Srgrimes/*60*/ { "pusha", FALSE, LONG, 0, 0 }, 6254Srgrimes/*61*/ { "popa", FALSE, LONG, 0, 0 }, 6264Srgrimes/*62*/ { "bound", TRUE, LONG, op2(E, R), 0 }, 62721277Sbde/*63*/ { "arpl", TRUE, NONE, op2(Rw,Ew), 0 }, 6284Srgrimes 6294Srgrimes/*64*/ { "", FALSE, NONE, 0, 0 }, 6304Srgrimes/*65*/ { "", FALSE, NONE, 0, 0 }, 6314Srgrimes/*66*/ { "", FALSE, NONE, 0, 0 }, 6324Srgrimes/*67*/ { "", FALSE, NONE, 0, 0 }, 6334Srgrimes 6344Srgrimes/*68*/ { "push", FALSE, LONG, op1(I), 0 }, 6354Srgrimes/*69*/ { "imul", TRUE, LONG, op3(I,E,R), 0 }, 63621277Sbde/*6a*/ { "push", FALSE, LONG, op1(Ibs), 0 }, 6374Srgrimes/*6b*/ { "imul", TRUE, LONG, op3(Ibs,E,R),0 }, 6384Srgrimes/*6c*/ { "ins", FALSE, BYTE, op2(DX, DI), 0 }, 6394Srgrimes/*6d*/ { "ins", FALSE, LONG, op2(DX, DI), 0 }, 6404Srgrimes/*6e*/ { "outs", FALSE, BYTE, op2(SI, DX), 0 }, 6414Srgrimes/*6f*/ { "outs", FALSE, LONG, op2(SI, DX), 0 }, 6424Srgrimes 6434Srgrimes/*70*/ { "jo", FALSE, NONE, op1(Db), 0 }, 6444Srgrimes/*71*/ { "jno", FALSE, NONE, op1(Db), 0 }, 6454Srgrimes/*72*/ { "jb", FALSE, NONE, op1(Db), 0 }, 6464Srgrimes/*73*/ { "jnb", FALSE, NONE, op1(Db), 0 }, 6474Srgrimes/*74*/ { "jz", FALSE, NONE, op1(Db), 0 }, 6484Srgrimes/*75*/ { "jnz", FALSE, NONE, op1(Db), 0 }, 6494Srgrimes/*76*/ { "jbe", FALSE, NONE, op1(Db), 0 }, 6504Srgrimes/*77*/ { "jnbe", FALSE, NONE, op1(Db), 0 }, 6514Srgrimes 6524Srgrimes/*78*/ { "js", FALSE, NONE, op1(Db), 0 }, 6534Srgrimes/*79*/ { "jns", FALSE, NONE, op1(Db), 0 }, 6544Srgrimes/*7a*/ { "jp", FALSE, NONE, op1(Db), 0 }, 6554Srgrimes/*7b*/ { "jnp", FALSE, NONE, op1(Db), 0 }, 6564Srgrimes/*7c*/ { "jl", FALSE, NONE, op1(Db), 0 }, 6574Srgrimes/*7d*/ { "jnl", FALSE, NONE, op1(Db), 0 }, 6584Srgrimes/*7e*/ { "jle", FALSE, NONE, op1(Db), 0 }, 6594Srgrimes/*7f*/ { "jnle", FALSE, NONE, op1(Db), 0 }, 6604Srgrimes 66117109Sbde/*80*/ { "", TRUE, BYTE, op2(I, E), db_Grp1 }, 66217109Sbde/*81*/ { "", TRUE, LONG, op2(I, E), db_Grp1 }, 66321277Sbde/*82*/ { "", TRUE, BYTE, op2(I, E), db_Grp1 }, 66417109Sbde/*83*/ { "", TRUE, LONG, op2(Ibs,E), db_Grp1 }, 6654Srgrimes/*84*/ { "test", TRUE, BYTE, op2(R, E), 0 }, 6664Srgrimes/*85*/ { "test", TRUE, LONG, op2(R, E), 0 }, 6674Srgrimes/*86*/ { "xchg", TRUE, BYTE, op2(R, E), 0 }, 6684Srgrimes/*87*/ { "xchg", TRUE, LONG, op2(R, E), 0 }, 6694Srgrimes 6704Srgrimes/*88*/ { "mov", TRUE, BYTE, op2(R, E), 0 }, 6714Srgrimes/*89*/ { "mov", TRUE, LONG, op2(R, E), 0 }, 6724Srgrimes/*8a*/ { "mov", TRUE, BYTE, op2(E, R), 0 }, 6734Srgrimes/*8b*/ { "mov", TRUE, LONG, op2(E, R), 0 }, 6744Srgrimes/*8c*/ { "mov", TRUE, NONE, op2(S, Ew), 0 }, 6754Srgrimes/*8d*/ { "lea", TRUE, LONG, op2(E, R), 0 }, 6764Srgrimes/*8e*/ { "mov", TRUE, NONE, op2(Ew, S), 0 }, 6774Srgrimes/*8f*/ { "pop", TRUE, LONG, op1(E), 0 }, 6784Srgrimes 6794Srgrimes/*90*/ { "nop", FALSE, NONE, 0, 0 }, 6804Srgrimes/*91*/ { "xchg", FALSE, LONG, op2(A, Ri), 0 }, 6814Srgrimes/*92*/ { "xchg", FALSE, LONG, op2(A, Ri), 0 }, 6824Srgrimes/*93*/ { "xchg", FALSE, LONG, op2(A, Ri), 0 }, 6834Srgrimes/*94*/ { "xchg", FALSE, LONG, op2(A, Ri), 0 }, 6844Srgrimes/*95*/ { "xchg", FALSE, LONG, op2(A, Ri), 0 }, 6854Srgrimes/*96*/ { "xchg", FALSE, LONG, op2(A, Ri), 0 }, 6864Srgrimes/*97*/ { "xchg", FALSE, LONG, op2(A, Ri), 0 }, 6874Srgrimes 6884Srgrimes/*98*/ { "cbw", FALSE, SDEP, 0, "cwde" }, /* cbw/cwde */ 6894Srgrimes/*99*/ { "cwd", FALSE, SDEP, 0, "cdq" }, /* cwd/cdq */ 6904Srgrimes/*9a*/ { "lcall", FALSE, NONE, op1(OS), 0 }, 6914Srgrimes/*9b*/ { "wait", FALSE, NONE, 0, 0 }, 6924Srgrimes/*9c*/ { "pushf", FALSE, LONG, 0, 0 }, 6934Srgrimes/*9d*/ { "popf", FALSE, LONG, 0, 0 }, 6944Srgrimes/*9e*/ { "sahf", FALSE, NONE, 0, 0 }, 6954Srgrimes/*9f*/ { "lahf", FALSE, NONE, 0, 0 }, 6964Srgrimes 6974Srgrimes/*a0*/ { "mov", FALSE, BYTE, op2(O, A), 0 }, 6984Srgrimes/*a1*/ { "mov", FALSE, LONG, op2(O, A), 0 }, 6994Srgrimes/*a2*/ { "mov", FALSE, BYTE, op2(A, O), 0 }, 7004Srgrimes/*a3*/ { "mov", FALSE, LONG, op2(A, O), 0 }, 7014Srgrimes/*a4*/ { "movs", FALSE, BYTE, op2(SI,DI), 0 }, 7024Srgrimes/*a5*/ { "movs", FALSE, LONG, op2(SI,DI), 0 }, 7034Srgrimes/*a6*/ { "cmps", FALSE, BYTE, op2(SI,DI), 0 }, 7044Srgrimes/*a7*/ { "cmps", FALSE, LONG, op2(SI,DI), 0 }, 7054Srgrimes 7064Srgrimes/*a8*/ { "test", FALSE, BYTE, op2(I, A), 0 }, 7074Srgrimes/*a9*/ { "test", FALSE, LONG, op2(I, A), 0 }, 7084Srgrimes/*aa*/ { "stos", FALSE, BYTE, op1(DI), 0 }, 7094Srgrimes/*ab*/ { "stos", FALSE, LONG, op1(DI), 0 }, 710118Srgrimes/*ac*/ { "lods", FALSE, BYTE, op1(SI), 0 }, 711118Srgrimes/*ad*/ { "lods", FALSE, LONG, op1(SI), 0 }, 7124Srgrimes/*ae*/ { "scas", FALSE, BYTE, op1(SI), 0 }, 7134Srgrimes/*af*/ { "scas", FALSE, LONG, op1(SI), 0 }, 7144Srgrimes 7154Srgrimes/*b0*/ { "mov", FALSE, BYTE, op2(I, Ri), 0 }, 7164Srgrimes/*b1*/ { "mov", FALSE, BYTE, op2(I, Ri), 0 }, 7174Srgrimes/*b2*/ { "mov", FALSE, BYTE, op2(I, Ri), 0 }, 7184Srgrimes/*b3*/ { "mov", FALSE, BYTE, op2(I, Ri), 0 }, 7194Srgrimes/*b4*/ { "mov", FALSE, BYTE, op2(I, Ri), 0 }, 7204Srgrimes/*b5*/ { "mov", FALSE, BYTE, op2(I, Ri), 0 }, 7214Srgrimes/*b6*/ { "mov", FALSE, BYTE, op2(I, Ri), 0 }, 7224Srgrimes/*b7*/ { "mov", FALSE, BYTE, op2(I, Ri), 0 }, 7234Srgrimes 7244Srgrimes/*b8*/ { "mov", FALSE, LONG, op2(I, Ri), 0 }, 7254Srgrimes/*b9*/ { "mov", FALSE, LONG, op2(I, Ri), 0 }, 7264Srgrimes/*ba*/ { "mov", FALSE, LONG, op2(I, Ri), 0 }, 7274Srgrimes/*bb*/ { "mov", FALSE, LONG, op2(I, Ri), 0 }, 7284Srgrimes/*bc*/ { "mov", FALSE, LONG, op2(I, Ri), 0 }, 7294Srgrimes/*bd*/ { "mov", FALSE, LONG, op2(I, Ri), 0 }, 7304Srgrimes/*be*/ { "mov", FALSE, LONG, op2(I, Ri), 0 }, 7314Srgrimes/*bf*/ { "mov", FALSE, LONG, op2(I, Ri), 0 }, 7324Srgrimes 73317109Sbde/*c0*/ { "", TRUE, BYTE, op2(Ib, E), db_Grp2 }, 73417109Sbde/*c1*/ { "", TRUE, LONG, op2(Ib, E), db_Grp2 }, 7354Srgrimes/*c2*/ { "ret", FALSE, NONE, op1(Iw), 0 }, 7364Srgrimes/*c3*/ { "ret", FALSE, NONE, 0, 0 }, 7374Srgrimes/*c4*/ { "les", TRUE, LONG, op2(E, R), 0 }, 7384Srgrimes/*c5*/ { "lds", TRUE, LONG, op2(E, R), 0 }, 7394Srgrimes/*c6*/ { "mov", TRUE, BYTE, op2(I, E), 0 }, 7404Srgrimes/*c7*/ { "mov", TRUE, LONG, op2(I, E), 0 }, 7414Srgrimes 74221277Sbde/*c8*/ { "enter", FALSE, NONE, op2(Iw, Ib), 0 }, 7434Srgrimes/*c9*/ { "leave", FALSE, NONE, 0, 0 }, 7444Srgrimes/*ca*/ { "lret", FALSE, NONE, op1(Iw), 0 }, 7454Srgrimes/*cb*/ { "lret", FALSE, NONE, 0, 0 }, 7464Srgrimes/*cc*/ { "int", FALSE, NONE, op1(o3), 0 }, 7474Srgrimes/*cd*/ { "int", FALSE, NONE, op1(Ib), 0 }, 7484Srgrimes/*ce*/ { "into", FALSE, NONE, 0, 0 }, 7494Srgrimes/*cf*/ { "iret", FALSE, NONE, 0, 0 }, 7504Srgrimes 75117109Sbde/*d0*/ { "", TRUE, BYTE, op2(o1, E), db_Grp2 }, 75217109Sbde/*d1*/ { "", TRUE, LONG, op2(o1, E), db_Grp2 }, 75317109Sbde/*d2*/ { "", TRUE, BYTE, op2(CL, E), db_Grp2 }, 75417109Sbde/*d3*/ { "", TRUE, LONG, op2(CL, E), db_Grp2 }, 75521277Sbde/*d4*/ { "aam", FALSE, NONE, op1(Iba), 0 }, 75621277Sbde/*d5*/ { "aad", FALSE, NONE, op1(Iba), 0 }, 75721277Sbde/*d6*/ { ".byte\t0xd6", FALSE, NONE, 0, 0 }, 7584Srgrimes/*d7*/ { "xlat", FALSE, BYTE, op1(BX), 0 }, 7594Srgrimes 76017109Sbde/*d8*/ { "", TRUE, NONE, 0, db_Esc8 }, 76117109Sbde/*d9*/ { "", TRUE, NONE, 0, db_Esc9 }, 76217109Sbde/*da*/ { "", TRUE, NONE, 0, db_Esca }, 76317109Sbde/*db*/ { "", TRUE, NONE, 0, db_Escb }, 76417109Sbde/*dc*/ { "", TRUE, NONE, 0, db_Escc }, 76517109Sbde/*dd*/ { "", TRUE, NONE, 0, db_Escd }, 76617109Sbde/*de*/ { "", TRUE, NONE, 0, db_Esce }, 76717109Sbde/*df*/ { "", TRUE, NONE, 0, db_Escf }, 7684Srgrimes 7694Srgrimes/*e0*/ { "loopne",FALSE, NONE, op1(Db), 0 }, 7704Srgrimes/*e1*/ { "loope", FALSE, NONE, op1(Db), 0 }, 7714Srgrimes/*e2*/ { "loop", FALSE, NONE, op1(Db), 0 }, 7724Srgrimes/*e3*/ { "jcxz", FALSE, SDEP, op1(Db), "jecxz" }, 7734Srgrimes/*e4*/ { "in", FALSE, BYTE, op2(Ib, A), 0 }, 7744Srgrimes/*e5*/ { "in", FALSE, LONG, op2(Ib, A) , 0 }, 7754Srgrimes/*e6*/ { "out", FALSE, BYTE, op2(A, Ib), 0 }, 7764Srgrimes/*e7*/ { "out", FALSE, LONG, op2(A, Ib) , 0 }, 7774Srgrimes 7784Srgrimes/*e8*/ { "call", FALSE, NONE, op1(Dl), 0 }, 7794Srgrimes/*e9*/ { "jmp", FALSE, NONE, op1(Dl), 0 }, 7804Srgrimes/*ea*/ { "ljmp", FALSE, NONE, op1(OS), 0 }, 7814Srgrimes/*eb*/ { "jmp", FALSE, NONE, op1(Db), 0 }, 7824Srgrimes/*ec*/ { "in", FALSE, BYTE, op2(DX, A), 0 }, 7834Srgrimes/*ed*/ { "in", FALSE, LONG, op2(DX, A) , 0 }, 7844Srgrimes/*ee*/ { "out", FALSE, BYTE, op2(A, DX), 0 }, 7854Srgrimes/*ef*/ { "out", FALSE, LONG, op2(A, DX) , 0 }, 7864Srgrimes 7874Srgrimes/*f0*/ { "", FALSE, NONE, 0, 0 }, 78821277Sbde/*f1*/ { ".byte\t0xf1", FALSE, NONE, 0, 0 }, 7894Srgrimes/*f2*/ { "", FALSE, NONE, 0, 0 }, 7904Srgrimes/*f3*/ { "", FALSE, NONE, 0, 0 }, 7914Srgrimes/*f4*/ { "hlt", FALSE, NONE, 0, 0 }, 7924Srgrimes/*f5*/ { "cmc", FALSE, NONE, 0, 0 }, 79317109Sbde/*f6*/ { "", TRUE, BYTE, 0, db_Grp3 }, 79417109Sbde/*f7*/ { "", TRUE, LONG, 0, db_Grp3 }, 7954Srgrimes 7964Srgrimes/*f8*/ { "clc", FALSE, NONE, 0, 0 }, 7974Srgrimes/*f9*/ { "stc", FALSE, NONE, 0, 0 }, 7984Srgrimes/*fa*/ { "cli", FALSE, NONE, 0, 0 }, 7994Srgrimes/*fb*/ { "sti", FALSE, NONE, 0, 0 }, 8004Srgrimes/*fc*/ { "cld", FALSE, NONE, 0, 0 }, 8014Srgrimes/*fd*/ { "std", FALSE, NONE, 0, 0 }, 80217109Sbde/*fe*/ { "", TRUE, NONE, 0, db_Grp4 }, 80317109Sbde/*ff*/ { "", TRUE, NONE, 0, db_Grp5 }, 8044Srgrimes}; 8054Srgrimes 80617109Sbdestatic const struct inst db_bad_inst = 8074Srgrimes { "???", FALSE, NONE, 0, 0 } 8084Srgrimes; 8094Srgrimes 8104Srgrimes#define f_mod(byte) ((byte)>>6) 8114Srgrimes#define f_reg(byte) (((byte)>>3)&0x7) 8124Srgrimes#define f_rm(byte) ((byte)&0x7) 8134Srgrimes 8144Srgrimes#define sib_ss(byte) ((byte)>>6) 8154Srgrimes#define sib_index(byte) (((byte)>>3)&0x7) 8164Srgrimes#define sib_base(byte) ((byte)&0x7) 8174Srgrimes 81811940Sbdestruct i_addr { 8194Srgrimes int is_reg; /* if reg, reg number is in 'disp' */ 8204Srgrimes int disp; 82114887Swollman const char * base; 82214887Swollman const char * index; 8234Srgrimes int ss; 8244Srgrimes}; 8254Srgrimes 82614887Swollmanstatic const char * const db_index_reg_16[8] = { 8274Srgrimes "%bx,%si", 8284Srgrimes "%bx,%di", 8294Srgrimes "%bp,%si", 8304Srgrimes "%bp,%di", 8314Srgrimes "%si", 8324Srgrimes "%di", 8334Srgrimes "%bp", 8344Srgrimes "%bx" 8354Srgrimes}; 8364Srgrimes 83714887Swollmanstatic const char * const db_reg[3][8] = { 83843314Sdillon { "%al", "%cl", "%dl", "%bl", "%ah", "%ch", "%dh", "%bh" }, 83943314Sdillon { "%ax", "%cx", "%dx", "%bx", "%sp", "%bp", "%si", "%di" }, 84043314Sdillon { "%eax", "%ecx", "%edx", "%ebx", "%esp", "%ebp", "%esi", "%edi" } 8414Srgrimes}; 8424Srgrimes 84317109Sbdestatic const char * const db_seg_reg[8] = { 8444Srgrimes "%es", "%cs", "%ss", "%ds", "%fs", "%gs", "", "" 8454Srgrimes}; 8464Srgrimes 8474Srgrimes/* 8484Srgrimes * lengths for size attributes 8494Srgrimes */ 85014887Swollmanstatic const int db_lengths[] = { 8514Srgrimes 1, /* BYTE */ 8524Srgrimes 2, /* WORD */ 8534Srgrimes 4, /* LONG */ 8544Srgrimes 8, /* QUAD */ 8554Srgrimes 4, /* SNGL */ 8564Srgrimes 8, /* DBLR */ 8574Srgrimes 10, /* EXTR */ 8584Srgrimes}; 8594Srgrimes 8604Srgrimes#define get_value_inc(result, loc, size, is_signed) \ 8614Srgrimes result = db_get_value((loc), (size), (is_signed)); \ 8624Srgrimes (loc) += (size); 8634Srgrimes 86411940Sbdestatic db_addr_t 86592770Salfred db_disasm_esc(db_addr_t loc, int inst, int short_addr, 86693017Sbde int size, const char *seg); 86792770Salfredstatic void db_print_address(const char *seg, int size, 86893017Sbde struct i_addr *addrp); 86911940Sbdestatic db_addr_t 87093017Sbde db_read_address(db_addr_t loc, int short_addr, int regmodrm, 87193017Sbde struct i_addr *addrp); 87211940Sbde 8734Srgrimes/* 8744Srgrimes * Read address at location and return updated location. 8754Srgrimes */ 87611921Sphkstatic db_addr_t 8774Srgrimesdb_read_address(loc, short_addr, regmodrm, addrp) 8784Srgrimes db_addr_t loc; 8794Srgrimes int short_addr; 8804Srgrimes int regmodrm; 88117109Sbde struct i_addr * addrp; /* out */ 8824Srgrimes{ 8833436Sphk int mod, rm, sib, index, disp; 8844Srgrimes 8854Srgrimes mod = f_mod(regmodrm); 8864Srgrimes rm = f_rm(regmodrm); 8874Srgrimes 8884Srgrimes if (mod == 3) { 8894Srgrimes addrp->is_reg = TRUE; 8904Srgrimes addrp->disp = rm; 8914Srgrimes return (loc); 8924Srgrimes } 8934Srgrimes addrp->is_reg = FALSE; 8944Srgrimes addrp->index = 0; 8954Srgrimes 8964Srgrimes if (short_addr) { 8974Srgrimes addrp->index = 0; 8984Srgrimes addrp->ss = 0; 8994Srgrimes switch (mod) { 9004Srgrimes case 0: 9014Srgrimes if (rm == 6) { 90221277Sbde get_value_inc(disp, loc, 2, FALSE); 9034Srgrimes addrp->disp = disp; 9044Srgrimes addrp->base = 0; 9054Srgrimes } 9064Srgrimes else { 9074Srgrimes addrp->disp = 0; 9084Srgrimes addrp->base = db_index_reg_16[rm]; 9094Srgrimes } 9104Srgrimes break; 9114Srgrimes case 1: 9124Srgrimes get_value_inc(disp, loc, 1, TRUE); 91321277Sbde disp &= 0xFFFF; 9144Srgrimes addrp->disp = disp; 9154Srgrimes addrp->base = db_index_reg_16[rm]; 9164Srgrimes break; 9174Srgrimes case 2: 91821277Sbde get_value_inc(disp, loc, 2, FALSE); 9194Srgrimes addrp->disp = disp; 9204Srgrimes addrp->base = db_index_reg_16[rm]; 9214Srgrimes break; 9224Srgrimes } 9234Srgrimes } 9244Srgrimes else { 9254Srgrimes if (mod != 3 && rm == 4) { 9264Srgrimes get_value_inc(sib, loc, 1, FALSE); 9274Srgrimes rm = sib_base(sib); 9284Srgrimes index = sib_index(sib); 9294Srgrimes if (index != 4) 9304Srgrimes addrp->index = db_reg[LONG][index]; 9314Srgrimes addrp->ss = sib_ss(sib); 9324Srgrimes } 9334Srgrimes 9344Srgrimes switch (mod) { 9354Srgrimes case 0: 9364Srgrimes if (rm == 5) { 9374Srgrimes get_value_inc(addrp->disp, loc, 4, FALSE); 9384Srgrimes addrp->base = 0; 9394Srgrimes } 9404Srgrimes else { 9414Srgrimes addrp->disp = 0; 9424Srgrimes addrp->base = db_reg[LONG][rm]; 9434Srgrimes } 9444Srgrimes break; 9454Srgrimes 9464Srgrimes case 1: 9474Srgrimes get_value_inc(disp, loc, 1, TRUE); 9484Srgrimes addrp->disp = disp; 9494Srgrimes addrp->base = db_reg[LONG][rm]; 9504Srgrimes break; 9514Srgrimes 9524Srgrimes case 2: 9534Srgrimes get_value_inc(disp, loc, 4, FALSE); 9544Srgrimes addrp->disp = disp; 9554Srgrimes addrp->base = db_reg[LONG][rm]; 9564Srgrimes break; 9574Srgrimes } 9584Srgrimes } 9594Srgrimes return (loc); 9604Srgrimes} 9614Srgrimes 96211921Sphkstatic void 9634Srgrimesdb_print_address(seg, size, addrp) 96417109Sbde const char * seg; 9654Srgrimes int size; 96617109Sbde struct i_addr * addrp; 9674Srgrimes{ 9684Srgrimes if (addrp->is_reg) { 9694Srgrimes db_printf("%s", db_reg[size][addrp->disp]); 9704Srgrimes return; 9714Srgrimes } 9724Srgrimes 9734Srgrimes if (seg) { 9744Srgrimes db_printf("%s:", seg); 9754Srgrimes } 9764Srgrimes 9774Srgrimes db_printsym((db_addr_t)addrp->disp, DB_STGY_ANY); 9784Srgrimes if (addrp->base != 0 || addrp->index != 0) { 9794Srgrimes db_printf("("); 9804Srgrimes if (addrp->base) 9814Srgrimes db_printf("%s", addrp->base); 9824Srgrimes if (addrp->index) 9834Srgrimes db_printf(",%s,%d", addrp->index, 1<<addrp->ss); 9844Srgrimes db_printf(")"); 9854Srgrimes } 9864Srgrimes} 9874Srgrimes 9884Srgrimes/* 9894Srgrimes * Disassemble floating-point ("escape") instruction 9904Srgrimes * and return updated location. 9914Srgrimes */ 99211921Sphkstatic db_addr_t 9934Srgrimesdb_disasm_esc(loc, inst, short_addr, size, seg) 9944Srgrimes db_addr_t loc; 9954Srgrimes int inst; 9964Srgrimes int short_addr; 9974Srgrimes int size; 99817109Sbde const char * seg; 9994Srgrimes{ 10004Srgrimes int regmodrm; 100117109Sbde const struct finst * fp; 10024Srgrimes int mod; 10034Srgrimes struct i_addr address; 100417109Sbde const char * name; 10054Srgrimes 10064Srgrimes get_value_inc(regmodrm, loc, 1, FALSE); 10074Srgrimes fp = &db_Esc_inst[inst - 0xd8][f_reg(regmodrm)]; 10084Srgrimes mod = f_mod(regmodrm); 10094Srgrimes if (mod != 3) { 101021277Sbde if (*fp->f_name == '\0') { 101121277Sbde db_printf("<bad instruction>"); 101221277Sbde return (loc); 101321277Sbde } 10144Srgrimes /* 10154Srgrimes * Normal address modes. 10164Srgrimes */ 10174Srgrimes loc = db_read_address(loc, short_addr, regmodrm, &address); 101879885Skris db_printf("%s", fp->f_name); 10194Srgrimes switch(fp->f_size) { 10204Srgrimes case SNGL: 10214Srgrimes db_printf("s"); 10224Srgrimes break; 10234Srgrimes case DBLR: 10244Srgrimes db_printf("l"); 10254Srgrimes break; 10264Srgrimes case EXTR: 10274Srgrimes db_printf("t"); 10284Srgrimes break; 10294Srgrimes case WORD: 10304Srgrimes db_printf("s"); 10314Srgrimes break; 10324Srgrimes case LONG: 10334Srgrimes db_printf("l"); 10344Srgrimes break; 10354Srgrimes case QUAD: 10364Srgrimes db_printf("q"); 10374Srgrimes break; 10384Srgrimes default: 10394Srgrimes break; 10404Srgrimes } 10414Srgrimes db_printf("\t"); 10424Srgrimes db_print_address(seg, BYTE, &address); 10434Srgrimes } 10444Srgrimes else { 10454Srgrimes /* 10464Srgrimes * 'reg-reg' - special formats 10474Srgrimes */ 10484Srgrimes switch (fp->f_rrmode) { 10494Srgrimes case op2(ST,STI): 10504Srgrimes name = (fp->f_rrname) ? fp->f_rrname : fp->f_name; 10514Srgrimes db_printf("%s\t%%st,%%st(%d)",name,f_rm(regmodrm)); 10524Srgrimes break; 10534Srgrimes case op2(STI,ST): 10544Srgrimes name = (fp->f_rrname) ? fp->f_rrname : fp->f_name; 10554Srgrimes db_printf("%s\t%%st(%d),%%st",name, f_rm(regmodrm)); 10564Srgrimes break; 10574Srgrimes case op1(STI): 10584Srgrimes name = (fp->f_rrname) ? fp->f_rrname : fp->f_name; 10594Srgrimes db_printf("%s\t%%st(%d)",name, f_rm(regmodrm)); 10604Srgrimes break; 10614Srgrimes case op1(X): 106221277Sbde name = ((const char * const *)fp->f_rrname)[f_rm(regmodrm)]; 106321277Sbde if (*name == '\0') 106421277Sbde goto bad; 106521277Sbde db_printf("%s", name); 10664Srgrimes break; 10674Srgrimes case op1(XA): 106821277Sbde name = ((const char * const *)fp->f_rrname)[f_rm(regmodrm)]; 106921277Sbde if (*name == '\0') 107021277Sbde goto bad; 107121277Sbde db_printf("%s\t%%ax", name); 10724Srgrimes break; 10734Srgrimes default: 107421277Sbde bad: 10754Srgrimes db_printf("<bad instruction>"); 10764Srgrimes break; 10774Srgrimes } 10784Srgrimes } 10794Srgrimes 10804Srgrimes return (loc); 10814Srgrimes} 10824Srgrimes 10834Srgrimes/* 10844Srgrimes * Disassemble instruction at 'loc'. 'altfmt' specifies an 10854Srgrimes * (optional) alternate format. Return address of start of 10864Srgrimes * next instruction. 10874Srgrimes */ 10884Srgrimesdb_addr_t 10894Srgrimesdb_disasm(loc, altfmt) 10904Srgrimes db_addr_t loc; 10914Srgrimes boolean_t altfmt; 10924Srgrimes{ 10934Srgrimes int inst; 10944Srgrimes int size; 10954Srgrimes int short_addr; 109617109Sbde const char * seg; 109714887Swollman const struct inst * ip; 109814887Swollman const char * i_name; 10994Srgrimes int i_size; 11004Srgrimes int i_mode; 1101798Swollman int regmodrm = 0; 11024Srgrimes boolean_t first; 11034Srgrimes int displ; 11044Srgrimes int prefix; 11054Srgrimes int imm; 11064Srgrimes int imm2; 11074Srgrimes int len; 11084Srgrimes struct i_addr address; 11094Srgrimes 11104Srgrimes get_value_inc(inst, loc, 1, FALSE); 11114Srgrimes short_addr = FALSE; 11124Srgrimes size = LONG; 11134Srgrimes seg = 0; 11144Srgrimes 11154Srgrimes /* 11164Srgrimes * Get prefixes 11174Srgrimes */ 11184Srgrimes prefix = TRUE; 11194Srgrimes do { 11204Srgrimes switch (inst) { 11214Srgrimes case 0x66: /* data16 */ 11224Srgrimes size = WORD; 11234Srgrimes break; 11244Srgrimes case 0x67: 11254Srgrimes short_addr = TRUE; 11264Srgrimes break; 11274Srgrimes case 0x26: 11284Srgrimes seg = "%es"; 11294Srgrimes break; 11304Srgrimes case 0x36: 11314Srgrimes seg = "%ss"; 11324Srgrimes break; 11334Srgrimes case 0x2e: 11344Srgrimes seg = "%cs"; 11354Srgrimes break; 11364Srgrimes case 0x3e: 11374Srgrimes seg = "%ds"; 11384Srgrimes break; 11394Srgrimes case 0x64: 11404Srgrimes seg = "%fs"; 11414Srgrimes break; 11424Srgrimes case 0x65: 11434Srgrimes seg = "%gs"; 11444Srgrimes break; 11454Srgrimes case 0xf0: 11464Srgrimes db_printf("lock "); 11474Srgrimes break; 11484Srgrimes case 0xf2: 11494Srgrimes db_printf("repne "); 11504Srgrimes break; 11514Srgrimes case 0xf3: 11524Srgrimes db_printf("repe "); /* XXX repe VS rep */ 11534Srgrimes break; 11544Srgrimes default: 11554Srgrimes prefix = FALSE; 11564Srgrimes break; 11574Srgrimes } 11584Srgrimes if (prefix) { 11594Srgrimes get_value_inc(inst, loc, 1, FALSE); 11604Srgrimes } 11614Srgrimes } while (prefix); 11624Srgrimes 11634Srgrimes if (inst >= 0xd8 && inst <= 0xdf) { 11644Srgrimes loc = db_disasm_esc(loc, inst, short_addr, size, seg); 11654Srgrimes db_printf("\n"); 11664Srgrimes return (loc); 11674Srgrimes } 11684Srgrimes 11694Srgrimes if (inst == 0x0f) { 11704Srgrimes get_value_inc(inst, loc, 1, FALSE); 11714Srgrimes ip = db_inst_0f[inst>>4]; 11724Srgrimes if (ip == 0) { 11734Srgrimes ip = &db_bad_inst; 11744Srgrimes } 11754Srgrimes else { 11764Srgrimes ip = &ip[inst&0xf]; 11774Srgrimes } 11784Srgrimes } 11794Srgrimes else 11804Srgrimes ip = &db_inst_table[inst]; 11814Srgrimes 11824Srgrimes if (ip->i_has_modrm) { 11834Srgrimes get_value_inc(regmodrm, loc, 1, FALSE); 11844Srgrimes loc = db_read_address(loc, short_addr, regmodrm, &address); 11854Srgrimes } 11864Srgrimes 11874Srgrimes i_name = ip->i_name; 11884Srgrimes i_size = ip->i_size; 11894Srgrimes i_mode = ip->i_mode; 11904Srgrimes 119117109Sbde if (ip->i_extra == db_Grp1 || ip->i_extra == db_Grp2 || 119217109Sbde ip->i_extra == db_Grp6 || ip->i_extra == db_Grp7 || 119321277Sbde ip->i_extra == db_Grp8 || ip->i_extra == db_Grp9) { 119417109Sbde i_name = ((const char * const *)ip->i_extra)[f_reg(regmodrm)]; 11954Srgrimes } 119617109Sbde else if (ip->i_extra == db_Grp3) { 119717109Sbde ip = ip->i_extra; 11984Srgrimes ip = &ip[f_reg(regmodrm)]; 11994Srgrimes i_name = ip->i_name; 12004Srgrimes i_mode = ip->i_mode; 12014Srgrimes } 120217109Sbde else if (ip->i_extra == db_Grp4 || ip->i_extra == db_Grp5) { 120317109Sbde ip = ip->i_extra; 12044Srgrimes ip = &ip[f_reg(regmodrm)]; 12054Srgrimes i_name = ip->i_name; 12064Srgrimes i_mode = ip->i_mode; 12074Srgrimes i_size = ip->i_size; 12084Srgrimes } 12094Srgrimes 12104Srgrimes if (i_size == SDEP) { 12114Srgrimes if (size == WORD) 121279885Skris db_printf("%s", i_name); 12134Srgrimes else 121479885Skris db_printf("%s", (const char *)ip->i_extra); 12154Srgrimes } 12164Srgrimes else { 121779885Skris db_printf("%s", i_name); 12184Srgrimes if (i_size != NONE) { 12194Srgrimes if (i_size == BYTE) { 12204Srgrimes db_printf("b"); 12214Srgrimes size = BYTE; 12224Srgrimes } 12234Srgrimes else if (i_size == WORD) { 12244Srgrimes db_printf("w"); 12254Srgrimes size = WORD; 12264Srgrimes } 12274Srgrimes else if (size == WORD) 12284Srgrimes db_printf("w"); 12294Srgrimes else 12304Srgrimes db_printf("l"); 12314Srgrimes } 12324Srgrimes } 12334Srgrimes db_printf("\t"); 12344Srgrimes for (first = TRUE; 12354Srgrimes i_mode != 0; 12364Srgrimes i_mode >>= 8, first = FALSE) 12374Srgrimes { 12384Srgrimes if (!first) 12394Srgrimes db_printf(","); 12404Srgrimes 12414Srgrimes switch (i_mode & 0xFF) { 12424Srgrimes 12434Srgrimes case E: 12444Srgrimes db_print_address(seg, size, &address); 12454Srgrimes break; 12464Srgrimes 12474Srgrimes case Eind: 12484Srgrimes db_printf("*"); 12494Srgrimes db_print_address(seg, size, &address); 12504Srgrimes break; 12514Srgrimes 125221277Sbde case El: 125321277Sbde db_print_address(seg, LONG, &address); 125421277Sbde break; 125521277Sbde 12564Srgrimes case Ew: 12574Srgrimes db_print_address(seg, WORD, &address); 12584Srgrimes break; 12594Srgrimes 12604Srgrimes case Eb: 12614Srgrimes db_print_address(seg, BYTE, &address); 12624Srgrimes break; 12634Srgrimes 12644Srgrimes case R: 12654Srgrimes db_printf("%s", db_reg[size][f_reg(regmodrm)]); 12664Srgrimes break; 12674Srgrimes 12684Srgrimes case Rw: 12694Srgrimes db_printf("%s", db_reg[WORD][f_reg(regmodrm)]); 12704Srgrimes break; 12714Srgrimes 12724Srgrimes case Ri: 12734Srgrimes db_printf("%s", db_reg[size][f_rm(inst)]); 12744Srgrimes break; 12754Srgrimes 127621277Sbde case Ril: 127721277Sbde db_printf("%s", db_reg[LONG][f_rm(inst)]); 127821277Sbde break; 127921277Sbde 12804Srgrimes case S: 12814Srgrimes db_printf("%s", db_seg_reg[f_reg(regmodrm)]); 12824Srgrimes break; 12834Srgrimes 12844Srgrimes case Si: 12854Srgrimes db_printf("%s", db_seg_reg[f_reg(inst)]); 12864Srgrimes break; 12874Srgrimes 12884Srgrimes case A: 12894Srgrimes db_printf("%s", db_reg[size][0]); /* acc */ 12904Srgrimes break; 12914Srgrimes 12924Srgrimes case BX: 12934Srgrimes if (seg) 12944Srgrimes db_printf("%s:", seg); 12954Srgrimes db_printf("(%s)", short_addr ? "%bx" : "%ebx"); 12964Srgrimes break; 12974Srgrimes 12984Srgrimes case CL: 12994Srgrimes db_printf("%%cl"); 13004Srgrimes break; 13014Srgrimes 13024Srgrimes case DX: 13034Srgrimes db_printf("%%dx"); 13044Srgrimes break; 13054Srgrimes 13064Srgrimes case SI: 13074Srgrimes if (seg) 13084Srgrimes db_printf("%s:", seg); 13094Srgrimes db_printf("(%s)", short_addr ? "%si" : "%esi"); 13104Srgrimes break; 13114Srgrimes 13124Srgrimes case DI: 13134Srgrimes db_printf("%%es:(%s)", short_addr ? "%di" : "%edi"); 13144Srgrimes break; 13154Srgrimes 13164Srgrimes case CR: 13174Srgrimes db_printf("%%cr%d", f_reg(regmodrm)); 13184Srgrimes break; 13194Srgrimes 13204Srgrimes case DR: 13214Srgrimes db_printf("%%dr%d", f_reg(regmodrm)); 13224Srgrimes break; 13234Srgrimes 13244Srgrimes case TR: 13254Srgrimes db_printf("%%tr%d", f_reg(regmodrm)); 13264Srgrimes break; 13274Srgrimes 13284Srgrimes case I: 13294Srgrimes len = db_lengths[size]; 133021277Sbde get_value_inc(imm, loc, len, FALSE); 133137506Sbde db_printf("$%#r", imm); 13324Srgrimes break; 13334Srgrimes 13344Srgrimes case Is: 13354Srgrimes len = db_lengths[size]; 133621277Sbde get_value_inc(imm, loc, len, FALSE); 133737506Sbde db_printf("$%+#r", imm); 13384Srgrimes break; 13394Srgrimes 13404Srgrimes case Ib: 134121277Sbde get_value_inc(imm, loc, 1, FALSE); 134237506Sbde db_printf("$%#r", imm); 13434Srgrimes break; 13444Srgrimes 134521277Sbde case Iba: 134621277Sbde get_value_inc(imm, loc, 1, FALSE); 134721277Sbde if (imm != 0x0a) 134837506Sbde db_printf("$%#r", imm); 134921277Sbde break; 135021277Sbde 13514Srgrimes case Ibs: 135221277Sbde get_value_inc(imm, loc, 1, TRUE); 135321277Sbde if (size == WORD) 135421277Sbde imm &= 0xFFFF; 135537506Sbde db_printf("$%+#r", imm); 13564Srgrimes break; 13574Srgrimes 13584Srgrimes case Iw: 135921277Sbde get_value_inc(imm, loc, 2, FALSE); 136037506Sbde db_printf("$%#r", imm); 13614Srgrimes break; 13624Srgrimes 13634Srgrimes case O: 136421277Sbde len = (short_addr ? 2 : 4); 136521277Sbde get_value_inc(displ, loc, len, FALSE); 13664Srgrimes if (seg) 136737506Sbde db_printf("%s:%+#r",seg, displ); 13684Srgrimes else 13694Srgrimes db_printsym((db_addr_t)displ, DB_STGY_ANY); 13704Srgrimes break; 13714Srgrimes 13724Srgrimes case Db: 13734Srgrimes get_value_inc(displ, loc, 1, TRUE); 137421277Sbde displ += loc; 137521277Sbde if (size == WORD) 137621277Sbde displ &= 0xFFFF; 137721277Sbde db_printsym((db_addr_t)displ, DB_STGY_XTRN); 13784Srgrimes break; 13794Srgrimes 13804Srgrimes case Dl: 138121277Sbde len = db_lengths[size]; 138221277Sbde get_value_inc(displ, loc, len, FALSE); 138321277Sbde displ += loc; 138421277Sbde if (size == WORD) 138521277Sbde displ &= 0xFFFF; 138621277Sbde db_printsym((db_addr_t)displ, DB_STGY_XTRN); 13874Srgrimes break; 13884Srgrimes 13894Srgrimes case o1: 13904Srgrimes db_printf("$1"); 13914Srgrimes break; 13924Srgrimes 13934Srgrimes case o3: 13944Srgrimes db_printf("$3"); 13954Srgrimes break; 13964Srgrimes 13974Srgrimes case OS: 139821277Sbde len = db_lengths[size]; 139921277Sbde get_value_inc(imm, loc, len, FALSE); /* offset */ 14004Srgrimes get_value_inc(imm2, loc, 2, FALSE); /* segment */ 140137506Sbde db_printf("$%#r,%#r", imm2, imm); 14024Srgrimes break; 14034Srgrimes } 14044Srgrimes } 14054Srgrimes db_printf("\n"); 14064Srgrimes return (loc); 14074Srgrimes} 1408