summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author Aaron Giles <aaron@aarongiles.com>2009-09-07 00:26:56 +0000
committer Aaron Giles <aaron@aarongiles.com>2009-09-07 00:26:56 +0000
commit03b5da1a5563c867808c6ac2ba98f5ad74066a39 (patch)
tree39944522fbfe4f04ffdd59228db3b1c3bc374498
parentf60bbef0707457417c73569c6f24851601692248 (diff)
Added 'options' parameter to the CPU_DISASSEMBLE prototype. For now, the
debugger always passes 0 for this. unidasm has been updated to accept a mode parameter, which is passed for the options.
-rw-r--r--src/emu/cpu/mc68hc11/hc11dasm.c2
-rw-r--r--src/emu/cpu/mc68hc11/mc68hc11.c2
-rw-r--r--src/emu/cpu/mc68hc11/mc68hc11.h2
-rw-r--r--src/emu/cpu/sharc/sharcops.c2
-rw-r--r--src/emu/cpu/tms57002/tms57002.c2
-rw-r--r--src/emu/cpuintrf.h8
-rw-r--r--src/emu/debug/debugcpu.c4
-rw-r--r--src/tools/unidasm.c31
8 files changed, 36 insertions, 17 deletions
diff --git a/src/emu/cpu/mc68hc11/hc11dasm.c b/src/emu/cpu/mc68hc11/hc11dasm.c
index d46c82e304c..98fd050a71d 100644
--- a/src/emu/cpu/mc68hc11/hc11dasm.c
+++ b/src/emu/cpu/mc68hc11/hc11dasm.c
@@ -1283,7 +1283,7 @@ static UINT32 decode_opcode(UINT32 pc, const M68HC11_OPCODE *op_table)
return flags;
}
-offs_t hc11_disasm(const device_config *device, char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram)
+CPU_DISASSEMBLE( hc11 )
{
UINT32 flags = 0;
UINT8 opcode;
diff --git a/src/emu/cpu/mc68hc11/mc68hc11.c b/src/emu/cpu/mc68hc11/mc68hc11.c
index 306e17ee7c7..f1f85420274 100644
--- a/src/emu/cpu/mc68hc11/mc68hc11.c
+++ b/src/emu/cpu/mc68hc11/mc68hc11.c
@@ -582,7 +582,7 @@ CPU_GET_INFO( mc68hc11 )
case CPUINFO_FCT_EXIT: info->exit = CPU_EXIT_NAME(hc11); break;
case CPUINFO_FCT_EXECUTE: info->execute = CPU_EXECUTE_NAME(hc11); break;
case CPUINFO_FCT_BURN: info->burn = NULL; break;
- case CPUINFO_FCT_DISASSEMBLE: info->disassemble = hc11_disasm; break;
+ case CPUINFO_FCT_DISASSEMBLE: info->disassemble = CPU_DISASSEMBLE_NAME(hc11); break;
case CPUINFO_PTR_INSTRUCTION_COUNTER: info->icount = &cpustate->icount; break;
/* --- the following bits of info are returned as NULL-terminated strings --- */
diff --git a/src/emu/cpu/mc68hc11/mc68hc11.h b/src/emu/cpu/mc68hc11/mc68hc11.h
index a2be9a4cb21..c8a3d9ff3dd 100644
--- a/src/emu/cpu/mc68hc11/mc68hc11.h
+++ b/src/emu/cpu/mc68hc11/mc68hc11.h
@@ -5,7 +5,7 @@
#include "cpuintrf.h"
-offs_t hc11_disasm(const device_config *device, char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram);
+CPU_DISASSEMBLE( hc11 );
CPU_GET_INFO( mc68hc11 );
#define CPU_MC68HC11 CPU_GET_INFO_NAME( mc68hc11 )
diff --git a/src/emu/cpu/sharc/sharcops.c b/src/emu/cpu/sharc/sharcops.c
index dbcc94548a2..3bc94801eab 100644
--- a/src/emu/cpu/sharc/sharcops.c
+++ b/src/emu/cpu/sharc/sharcops.c
@@ -2748,7 +2748,7 @@ static void sharcop_idle(SHARC_REGS *cpustate)
static void sharcop_unimplemented(SHARC_REGS *cpustate)
{
char dasm[1000];
- CPU_DISASSEMBLE_NAME(sharc)(NULL, dasm, cpustate->pc, NULL, NULL);
+ CPU_DISASSEMBLE_NAME(sharc)(NULL, dasm, cpustate->pc, NULL, NULL, 0);
mame_printf_debug("SHARC: %08X: %s\n", cpustate->pc, dasm);
fatalerror("SHARC: Unimplemented opcode %04X%08X at %08X", (UINT16)(cpustate->opcode >> 32), (UINT32)(cpustate->opcode), cpustate->pc);
}
diff --git a/src/emu/cpu/tms57002/tms57002.c b/src/emu/cpu/tms57002/tms57002.c
index b64bf7555a9..fb2308130ee 100644
--- a/src/emu/cpu/tms57002/tms57002.c
+++ b/src/emu/cpu/tms57002/tms57002.c
@@ -1104,7 +1104,7 @@ static void tms57002_decode_error(tms57002_t *s, UINT32 opcode)
opr[1] = opcode >> 8;
opr[2] = opcode >> 16;
- CPU_DISASSEMBLE_NAME(tms57002)(0, buf, s->pc, opr, opr);
+ CPU_DISASSEMBLE_NAME(tms57002)(0, buf, s->pc, opr, opr, 0);
popmessage("tms57002: %s - Contact Mamedev", buf);
}
diff --git a/src/emu/cpuintrf.h b/src/emu/cpuintrf.h
index 009b3bb89d3..442b23ac4eb 100644
--- a/src/emu/cpuintrf.h
+++ b/src/emu/cpuintrf.h
@@ -161,7 +161,7 @@ enum
CPUINFO_FCT_EXIT, /* R/O: void (*exit)(const device_config *device) */
CPUINFO_FCT_EXECUTE, /* R/O: int (*execute)(const device_config *device, int cycles) */
CPUINFO_FCT_BURN, /* R/O: void (*burn)(const device_config *device, int cycles) */
- CPUINFO_FCT_DISASSEMBLE, /* R/O: offs_t (*disassemble)(const device_config *device, char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram) */
+ CPUINFO_FCT_DISASSEMBLE, /* R/O: offs_t (*disassemble)(const device_config *device, char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, int options) */
CPUINFO_FCT_TRANSLATE, /* R/O: int (*translate)(const device_config *device, int space, int intention, offs_t *address) */
CPUINFO_FCT_READ, /* R/O: int (*read)(const device_config *device, int space, UINT32 offset, int size, UINT64 *value) */
CPUINFO_FCT_WRITE, /* R/O: int (*write)(const device_config *device, int space, UINT32 offset, int size, UINT64 value) */
@@ -286,8 +286,8 @@ enum
#define CPU_DEBUG_INIT_CALL(name) CPU_DEBUG_INIT_NAME(name)(device)
#define CPU_DISASSEMBLE_NAME(name) cpu_disassemble_##name
-#define CPU_DISASSEMBLE(name) offs_t CPU_DISASSEMBLE_NAME(name)(const device_config *device, char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram)
-#define CPU_DISASSEMBLE_CALL(name) CPU_DISASSEMBLE_NAME(name)(device, buffer, pc, oprom, opram)
+#define CPU_DISASSEMBLE(name) offs_t CPU_DISASSEMBLE_NAME(name)(const device_config *device, char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, int options)
+#define CPU_DISASSEMBLE_CALL(name) CPU_DISASSEMBLE_NAME(name)(device, buffer, pc, oprom, opram, options)
#define CPU_VALIDITY_CHECK_NAME(name) cpu_validity_check_##name
#define CPU_VALIDITY_CHECK(name) int CPU_VALIDITY_CHECK_NAME(name)(const game_driver *driver, const void *config)
@@ -379,7 +379,7 @@ typedef int (*cpu_read_func)(const device_config *device, int space, UINT32 offs
typedef int (*cpu_write_func)(const device_config *device, int space, UINT32 offset, int size, UINT64 value);
typedef int (*cpu_readop_func)(const device_config *device, UINT32 offset, int size, UINT64 *value);
typedef void (*cpu_debug_init_func)(const device_config *device);
-typedef offs_t (*cpu_disassemble_func)(const device_config *device, char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram);
+typedef offs_t (*cpu_disassemble_func)(const device_config *device, char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, int options);
typedef int (*cpu_validity_check_func)(const game_driver *driver, const void *config);
typedef void (*cpu_state_io_func)(const device_config *device, void *baseptr, const cpu_state_entry *entry);
typedef void (*cpu_string_io_func)(const device_config *device, void *baseptr, const cpu_state_entry *entry, char *string);
diff --git a/src/emu/debug/debugcpu.c b/src/emu/debug/debugcpu.c
index 5137e6bac2c..d8a6c659a75 100644
--- a/src/emu/debug/debugcpu.c
+++ b/src/emu/debug/debugcpu.c
@@ -391,11 +391,11 @@ offs_t debug_cpu_disassemble(const device_config *device, char *buffer, offs_t p
/* check for disassembler override */
if (info->dasm_override != NULL)
- result = (*info->dasm_override)(device, buffer, pc, oprom, opram);
+ result = (*info->dasm_override)(device, buffer, pc, oprom, opram, 0);
/* if we have a disassembler, run it */
if (result == 0 && info->disassemble != NULL)
- result = (*info->disassemble)(device, buffer, pc, oprom, opram);
+ result = (*info->disassemble)(device, buffer, pc, oprom, opram, 0);
/* if we still have nothing, output vanilla bytes */
if (result == 0)
diff --git a/src/tools/unidasm.c b/src/tools/unidasm.c
index 1326266c4de..8884d664d96 100644
--- a/src/tools/unidasm.c
+++ b/src/tools/unidasm.c
@@ -53,6 +53,7 @@ struct _options
UINT8 norawbytes;
UINT8 lower;
UINT8 upper;
+ int mode;
const dasm_table_entry *dasm;
};
@@ -329,6 +330,7 @@ int parse_options(int argc, char *argv[], options *opts)
{
int pending_base = FALSE;
int pending_arch = FALSE;
+ int pending_mode = FALSE;
int curarch;
int numrows;
int arg;
@@ -343,7 +345,7 @@ int parse_options(int argc, char *argv[], options *opts)
// is it a switch?
if (curarg[0] == '-')
{
- if (pending_base || pending_arch)
+ if (pending_base || pending_arch || pending_mode)
goto usage;
if (tolower((UINT8)curarg[1]) == 'a')
@@ -352,6 +354,8 @@ int parse_options(int argc, char *argv[], options *opts)
pending_base = TRUE;
else if (tolower((UINT8)curarg[1]) == 'l')
opts->lower = TRUE;
+ else if (tolower((UINT8)curarg[1]) == 'm')
+ pending_mode = TRUE;
else if (tolower((UINT8)curarg[1]) == 'n')
opts->norawbytes = TRUE;
else if (tolower((UINT8)curarg[1]) == 'u')
@@ -363,15 +367,26 @@ int parse_options(int argc, char *argv[], options *opts)
// base PC
else if (pending_base)
{
+ int result;
if (curarg[0] == '0' && curarg[1] == 'x')
- sscanf(&curarg[2], "%x", &opts->basepc);
+ result = sscanf(&curarg[2], "%x", &opts->basepc);
else if (curarg[0] == '$')
- sscanf(&curarg[1], "%x", &opts->basepc);
+ result = sscanf(&curarg[1], "%x", &opts->basepc);
else
- sscanf(&curarg[0], "%x", &opts->basepc);
+ result = sscanf(&curarg[0], "%x", &opts->basepc);
+ if (result != 1)
+ goto usage;
pending_base = FALSE;
}
+ // mode
+ else if (pending_mode)
+ {
+ if (sscanf(curarg, "%d", &opts->mode) != 1)
+ goto usage;
+ pending_mode = FALSE;
+ }
+
// architecture
else if (pending_arch)
{
@@ -393,13 +408,17 @@ int parse_options(int argc, char *argv[], options *opts)
goto usage;
}
+ // if we have a dangling option, error
+ if (pending_base || pending_arch || pending_mode)
+ goto usage;
+
// if no file or no architecture, fail
if (opts->filename == NULL || opts->dasm == NULL)
goto usage;
return 0;
usage:
- printf("Usage: %s <filename> -arch <architecture> [-basepc <pc>] [-norawbytes] [-upper] [-lower]\n", argv[0]);
+ printf("Usage: %s <filename> -arch <architecture> [-basepc <pc>] [-mode <n>] [-norawbytes] [-upper] [-lower]\n", argv[0]);
printf("\n");
printf("Supported architectures:");
numrows = (ARRAY_LENGTH(dasm_table) + 6) / 7;
@@ -463,7 +482,7 @@ int main(int argc, char *argv[])
int numchunks;
// disassemble
- pcdelta = (*opts.dasm->func)(NULL, buffer, curpc, oprom, oprom) & DASMFLAG_LENGTHMASK;
+ pcdelta = (*opts.dasm->func)(NULL, buffer, curpc, oprom, oprom, opts.mode) & DASMFLAG_LENGTHMASK;
if (opts.dasm->pcshift < 0)
numbytes = pcdelta << -opts.dasm->pcshift;
else