Added support for outputting 64-bit target addresses.

This commit is contained in:
Aaron Giles 2008-01-10 18:14:50 +00:00
parent c09a3df1e9
commit 8240d56dd9
2 changed files with 22 additions and 8 deletions

View File

@ -1092,7 +1092,7 @@ static const char *const i386_sreg[8] = {"es", "cs", "ss", "ds", "fs", "gs", "??
static int address_size;
static int operand_size;
static UINT32 pc;
static UINT64 pc;
static UINT8 modrm;
static UINT32 segment;
static offs_t dasm_flags;
@ -1186,6 +1186,14 @@ static char *hexstring64(UINT32 lo, UINT32 hi)
return (buffer[1] >= '0' && buffer[1] <= '9') ? &buffer[1] : &buffer[0];
}
static char *hexstringpc(UINT64 pc)
{
if (curmode == 64)
return hexstring64((UINT32)pc, (UINT32)(pc >> 32));
else
return hexstring((UINT32)pc, 0);
}
static char *shexstring(UINT32 value, int digits, int always)
{
static char buffer[20];
@ -1531,17 +1539,17 @@ static char* handle_param(char* s, UINT32 param)
case PARAM_REL:
if( operand_size ) {
d32 = FETCHD32();
s += sprintf( s, "%s", hexstring(pc + d32, 0) );
s += sprintf( s, "%s", hexstringpc(pc + d32) );
} else {
/* make sure to keep the relative offset within the segment */
d16 = FETCHD16();
s += sprintf( s, "%s", hexstring((pc & 0xFFFF0000) | ((pc + d16) & 0x0000FFFF), 0) );
s += sprintf( s, "%s", hexstringpc((pc & 0xFFFF0000) | ((pc + d16) & 0x0000FFFF)) );
}
break;
case PARAM_REL8:
d8 = FETCHD();
s += sprintf( s, "%s", hexstring(pc + d8, 0) );
s += sprintf( s, "%s", hexstringpc(pc + d8) );
break;
case PARAM_MEM_OFFS_B:
@ -2104,7 +2112,7 @@ handle_unknown:
sprintf(s, "???");
}
int i386_dasm_one(char *buffer, UINT32 eip, const UINT8 *oprom, int mode)
int i386_dasm_one_ex(char *buffer, UINT64 eip, const UINT8 *oprom, int mode)
{
UINT8 op;
@ -2123,3 +2131,8 @@ int i386_dasm_one(char *buffer, UINT32 eip, const UINT8 *oprom, int mode)
decode_opcode( buffer, &i386_opcode_table1[op], op );
return (pc-eip) | dasm_flags | DASMFLAG_SUPPORTED;
}
int i386_dasm_one(char *buffer, offs_t eip, const UINT8 *oprom, int mode)
{
return i386_dasm_one_ex(buffer, eip, oprom, mode);
}

View File

@ -73,7 +73,7 @@ struct _x86log_context
***************************************************************************/
static void reset_log(x86log_context *log);
static int x86log_i386_dasm_one(char *buffer, UINT32 eip, const UINT8 *oprom, int mode);
static int x86log_i386_dasm_one_ex(char *buffer, UINT64 eip, const UINT8 *oprom, int mode);
@ -237,9 +237,9 @@ void x86log_disasm_code_range(x86log_context *log, const char *label, x86code *s
else
{
#ifdef PTR64
bytes = x86log_i386_dasm_one(buffer, (UINT32)(FPTR)cur, cur, 64) & DASMFLAG_LENGTHMASK;
bytes = x86log_i386_dasm_one_ex(buffer, (FPTR)cur, cur, 64) & DASMFLAG_LENGTHMASK;
#else
bytes = x86log_i386_dasm_one(buffer, (UINT32)(FPTR)cur, cur, 32) & DASMFLAG_LENGTHMASK;
bytes = x86log_i386_dasm_one_ex(buffer, (FPTR)cur, cur, 32) & DASMFLAG_LENGTHMASK;
#endif
}
@ -313,4 +313,5 @@ static void reset_log(x86log_context *log)
***************************************************************************/
#define i386_dasm_one x86log_i386_dasm_one
#define i386_dasm_one_ex x86log_i386_dasm_one_ex
#include "cpu/i386/i386dasm.c"