disasm_next += PR_snprintf(disasm_next, disasm_end - disasm_next, "$%#r,%#r", imm2, imm);
disasm_next += PR_snprintf(disasm_next, disasm_end - disasm_next, "$%x,%x", imm2, imm);
db_disasm(db_addr_t loc){	int	inst;	int	size;	int	short_addr;	const char *	seg;	const struct inst *	ip;	const char *	i_name;	int	i_size;	int	i_mode;	int	regmodrm = 0;	boolean_t	first;	int	displ;	int	prefix;	int	imm;	int	imm2;	int	len;	struct i_addr	address;        /* Point to first character in static disassembly buffer */        disasm_next = &disasm_buff[0];	get_value_inc(inst, loc, 1, FALSE);	short_addr = FALSE;	size = LONG;	seg = 0;	/*	 * Get prefixes	 */	prefix = TRUE;	do {	    switch (inst) {		case 0x66:		/* data16 */		    size = WORD;		    break;		case 0x67:		    short_addr = TRUE;		    break;		case 0x26:		    seg = "%es";		    break;		case 0x36:		    seg = "%ss";		    break;		case 0x2e:		    seg = "%cs";		    break;		case 0x3e:		    seg = "%ds";		    break;		case 0x64:		    seg = "%fs";		    break;		case 0x65:		    seg = "%gs";		    break;		case 0xf0:		    disasm_next += PR_snprintf(disasm_next, disasm_end - disasm_next, "lock ");		    break;		case 0xf2:		    disasm_next += PR_snprintf(disasm_next, disasm_end - disasm_next, "repne ");		    break;		case 0xf3:		    disasm_next += PR_snprintf(disasm_next, disasm_end - disasm_next, "repe ");	/* XXX repe VS rep */		    break;		default:		    prefix = FALSE;		    break;	    }	    if (prefix) {		get_value_inc(inst, loc, 1, FALSE);	    }	} while (prefix);	if (inst >= 0xd8 && inst <= 0xdf) {	    loc = db_disasm_esc(loc, inst, short_addr, size, seg);	    disasm_next += PR_snprintf(disasm_next, disasm_end - disasm_next, "\n");	    return (loc);	}	if (inst == 0x0f) {	    get_value_inc(inst, loc, 1, FALSE);	    ip = db_inst_0f[inst>>4];	    if (ip == 0) {		ip = &db_bad_inst;	    }	    else {		ip = &ip[inst&0xf];	    }	}	else	    ip = &db_inst_table[inst];	if (ip->i_has_modrm) {	    get_value_inc(regmodrm, loc, 1, FALSE);	    loc = db_read_address(loc, short_addr, regmodrm, &address);	}	i_name = ip->i_name;	i_size = ip->i_size;	i_mode = ip->i_mode;	if (ip->i_extra == db_Grp1 || ip->i_extra == db_Grp2 ||	    ip->i_extra == db_Grp6 || ip->i_extra == db_Grp7 ||	    ip->i_extra == db_Grp8 || ip->i_extra == db_Grp9) {	    i_name = ((const char * const *)ip->i_extra)[f_reg(regmodrm)];	}	else if (ip->i_extra == db_Grp3) {	    ip = ip->i_extra;	    ip = &ip[f_reg(regmodrm)];	    i_name = ip->i_name;	    i_mode = ip->i_mode;	}	else if (ip->i_extra == db_Grp4 || ip->i_extra == db_Grp5) {	    ip = ip->i_extra;	    ip = &ip[f_reg(regmodrm)];	    i_name = ip->i_name;	    i_mode = ip->i_mode;	    i_size = ip->i_size;	}	if (i_size == SDEP) {	    if (size == WORD)		disasm_next += PR_snprintf(disasm_next, disasm_end - disasm_next, i_name);	    else		disasm_next += PR_snprintf(disasm_next, disasm_end - disasm_next, (const char *)ip->i_extra);	}	else {	    disasm_next += PR_snprintf(disasm_next, disasm_end - disasm_next, i_name);	    if (i_size != NONE) {		if (i_size == BYTE) {		    disasm_next += PR_snprintf(disasm_next, disasm_end - disasm_next, "b");		    size = BYTE;		}		else if (i_size == WORD) {		    disasm_next += PR_snprintf(disasm_next, disasm_end - disasm_next, "w");		    size = WORD;		}		else if (size == WORD)		    disasm_next += PR_snprintf(disasm_next, disasm_end - disasm_next, "w");		else		    disasm_next += PR_snprintf(disasm_next, disasm_end - disasm_next, "l");	    }	}	disasm_next += PR_snprintf(disasm_next, disasm_end - disasm_next, "\t");	for (first = TRUE;	     i_mode != 0;	     i_mode >>= 8, first = FALSE)	{	    if (!first)		disasm_next += PR_snprintf(disasm_next, disasm_end - disasm_next, ",");	    switch (i_mode & 0xFF) {		case E:		    db_print_address(seg, size, &address);		    break;		case Eind:		    disasm_next += PR_snprintf(disasm_next, disasm_end - disasm_next, "*");		    db_print_address(seg, size, &address);		    break;		case El:		    db_print_address(seg, LONG, &address);		    break;		case Ew:		    db_print_address(seg, WORD, &address);		    break;		case Eb:		    db_print_address(seg, BYTE, &address);		    break;		case R:		    disasm_next += PR_snprintf(disasm_next, disasm_end - disasm_next, "%s", db_reg[size][f_reg(regmodrm)]);		    break;		case Rw:		    disasm_next += PR_snprintf(disasm_next, disasm_end - disasm_next, "%s", db_reg[WORD][f_reg(regmodrm)]);		    break;		case Ri:		    disasm_next += PR_snprintf(disasm_next, disasm_end - disasm_next, "%s", db_reg[size][f_rm(inst)]);		    break;		case Ril:		    disasm_next += PR_snprintf(disasm_next, disasm_end - disasm_next, "%s", db_reg[LONG][f_rm(inst)]);		    break;		case S:		    disasm_next += PR_snprintf(disasm_next, disasm_end - disasm_next, "%s", db_seg_reg[f_reg(regmodrm)]);		    break;		case Si:		    disasm_next += PR_snprintf(disasm_next, disasm_end - disasm_next, "%s", db_seg_reg[f_reg(inst)]);		    break;		case A:		    disasm_next += PR_snprintf(disasm_next, disasm_end - disasm_next, "%s", db_reg[size][0]);	/* acc */		    break;		case BX:		    if (seg)			disasm_next += PR_snprintf(disasm_next, disasm_end - disasm_next, "%s:", seg);		    disasm_next += PR_snprintf(disasm_next, disasm_end - disasm_next, "(%s)", short_addr ? "%bx" : "%ebx");		    break;		case CL:		    disasm_next += PR_snprintf(disasm_next, disasm_end - disasm_next, "%%cl");		    break;		case DX:		    disasm_next += PR_snprintf(disasm_next, disasm_end - disasm_next, "%%dx");		    break;		case SI:		    if (seg)			disasm_next += PR_snprintf(disasm_next, disasm_end - disasm_next, "%s:", seg);		    disasm_next += PR_snprintf(disasm_next, disasm_end - disasm_next, "(%s)", short_addr ? "%si" : "%esi");		    break;		case DI:		    disasm_next += PR_snprintf(disasm_next, disasm_end - disasm_next, "%%es:(%s)", short_addr ? "%di" : "%edi");		    break;		case CR:		    disasm_next += PR_snprintf(disasm_next, disasm_end - disasm_next, "%%cr%d", f_reg(regmodrm));		    break;		case DR:		    disasm_next += PR_snprintf(disasm_next, disasm_end - disasm_next, "%%dr%d", f_reg(regmodrm));		    break;		case TR:		    disasm_next += PR_snprintf(disasm_next, disasm_end - disasm_next, "%%tr%d", f_reg(regmodrm));		    break;		case I:		    len = db_lengths[size];		    get_value_inc(imm, loc, len, FALSE);		    disasm_next += PR_snprintf(disasm_next, disasm_end - disasm_next, "$%#r", imm);		    break;		case Is:		    len = db_lengths[size];		    get_value_inc(imm, loc, len, FALSE);		    disasm_next += PR_snprintf(disasm_next, disasm_end - disasm_next, "$%+#r", imm);		    break;		case Ib:		    get_value_inc(imm, loc, 1, FALSE);		    disasm_next += PR_snprintf(disasm_next, disasm_end - disasm_next, "$%#r", imm);		    break;		case Iba:		    get_value_inc(imm, loc, 1, FALSE);		    if (imm != 0x0a)			disasm_next += PR_snprintf(disasm_next, disasm_end - disasm_next, "$%#r", imm);		    break;		case Ibs:		    get_value_inc(imm, loc, 1, TRUE);		    if (size == WORD)			imm &= 0xFFFF;		    disasm_next += PR_snprintf(disasm_next, disasm_end - disasm_next, "$%+#r", imm);		    break;		case Iw:		    get_value_inc(imm, loc, 2, FALSE);		    disasm_next += PR_snprintf(disasm_next, disasm_end - disasm_next, "$%#r", imm);		    break;		case O:		    len = (short_addr ? 2 : 4);		    get_value_inc(displ, loc, len, FALSE);		    if (seg)			disasm_next += PR_snprintf(disasm_next, disasm_end - disasm_next, "%s:%+#r",seg, displ);		    else			db_printsym((db_addr_t)displ, DB_STGY_ANY);		    break;		case Db:		    get_value_inc(displ, loc, 1, TRUE);		    displ += loc;		    if (size == WORD)			displ &= 0xFFFF;		    db_printsym((db_addr_t)displ, DB_STGY_XTRN);		    break;		case Dl:		    len = db_lengths[size];		    get_value_inc(displ, loc, len, FALSE);		    displ += loc;		    if (size == WORD)			displ &= 0xFFFF;		    db_printsym((db_addr_t)displ, DB_STGY_XTRN);		    break;		case o1:		    disasm_next += PR_snprintf(disasm_next, disasm_end - disasm_next, "$1");		    break;		case o3:		    disasm_next += PR_snprintf(disasm_next, disasm_end - disasm_next, "$3");		    break;		case OS:		    len = db_lengths[size];		    get_value_inc(imm, loc, len, FALSE);	/* offset */		    get_value_inc(imm2, loc, 2, FALSE);	/* segment */		    disasm_next += PR_snprintf(disasm_next, disasm_end - disasm_next, "$%#r,%#r", imm2, imm);		    break;	    }	}	return (loc);}