1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-21 11:13:30 +00:00

Minor fixes for 160-bit disassembly:

(1) Print the default segment %ss before adresses relative to %bp.
    This is too cluttered for me, but so is printing some other default
    prefixes, and this is a reasonable reminder that %ss is quite
    likely to be different from %ds in 16-bit mode.

    db_disasm still handles prefixes poorly, by trying to discard
    redundant ones.  This loses information, and sometimes the result
    is wrong or misleading.

    Clean up nearby initializations and dead code.

(2) Fix decoding of operand and address size prefixes in 16-bit mode.
    They reverse the default in all modes.

Obtained from:            (1) is partly from r1.4 (2003/11/08) in DFlyBSD (?)
This commit is contained in:
Bruce Evans 2016-09-25 18:39:24 +00:00
parent 81d7ca7761
commit 9eeaa0ea1f
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=306319

View File

@ -884,6 +884,7 @@ struct i_addr {
const char * base;
const char * index;
int ss;
bool defss; /* set if %ss is the default segment */
};
static const char * const db_index_reg_16[8] = {
@ -955,10 +956,12 @@ db_read_address(loc, short_addr, regmodrm, addrp)
}
addrp->is_reg = FALSE;
addrp->index = NULL;
addrp->ss = 0;
addrp->defss = FALSE;
if (short_addr) {
addrp->index = NULL;
addrp->ss = 0;
if (rm == 2 || rm == 3 || (rm == 6 && mod != 0))
addrp->defss = TRUE;
switch (mod) {
case 0:
if (rm == 6) {
@ -985,7 +988,7 @@ db_read_address(loc, short_addr, regmodrm, addrp)
}
}
else {
if (mod != 3 && rm == 4) {
if (rm == 4) {
get_value_inc(sib, loc, 1, FALSE);
rm = sib_base(sib);
index = sib_index(sib);
@ -1036,6 +1039,9 @@ db_print_address(seg, size, addrp)
if (seg) {
db_printf("%s:", seg);
}
else if (addrp->defss) {
db_printf("%%ss:");
}
db_printsym((db_addr_t)addrp->disp, DB_STGY_ANY);
if (addrp->base != NULL || addrp->index != NULL) {
@ -1189,11 +1195,11 @@ db_disasm(db_addr_t loc, bool altfmt)
prefix = TRUE;
do {
switch (inst) {
case 0x66: /* data16 */
size = WORD;
case 0x66:
size = (altfmt ? LONG : WORD);
break;
case 0x67:
short_addr = TRUE;
short_addr = !altfmt;
break;
case 0x26:
seg = "%es";