summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author Nathan Woods <npwoods@mess.org>2016-10-30 00:14:07 -0400
committer Nathan Woods <npwoods@mess.org>2016-10-30 00:14:07 -0400
commitfe09ebc47db87e1451a996cf9884a2be3aa80b70 (patch)
tree78024cc30f734d089ef1ef5e9e6d085ad892e34c
parent06613b3dd1ef4911e4f8be76e5f826cc77acaed5 (diff)
Changed the PPS4 disassembler to use 'std::ostream &' internally
-rw-r--r--src/devices/cpu/pps4/pps4dasm.cpp32
1 files changed, 20 insertions, 12 deletions
diff --git a/src/devices/cpu/pps4/pps4dasm.cpp b/src/devices/cpu/pps4/pps4dasm.cpp
index 410f7986a60..3dad2e7d1fd 100644
--- a/src/devices/cpu/pps4/pps4dasm.cpp
+++ b/src/devices/cpu/pps4/pps4dasm.cpp
@@ -367,49 +367,48 @@ static const uint16_t table[] = {
/* ff */ t_TM | t_I6i | t_OVER
};
-CPU_DISASSEMBLE( pps4 )
+static offs_t internal_disasm_pps4(cpu_device *device, std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, int options)
{
uint32_t flags = 0;
unsigned PC = pc;
uint8_t op = OP(pc++);
uint32_t tok = table[op];
- char *dst = nullptr;
if (0 == (tok & t_MASK)) {
- sprintf(buffer, "%s", token_str[tok & t_MASK]);
+ stream << token_str[tok & t_MASK];
} else {
- dst = buffer + sprintf(buffer, "%-7s", token_str[tok & t_MASK]);
+ util::stream_format(stream, "%-7s", token_str[tok & t_MASK]);
}
if (tok & t_I3c) {
// 3 bit immediate, complemented
uint8_t i = ~op & 7;
if (0 != i) // only print if non-zero
- dst += sprintf(dst, "%x", i);
+ util::stream_format(stream, "%x", i);
}
if (tok & t_I4) {
// 4 bit immediate
uint8_t i = op & 15;
- dst += sprintf(dst, "%x", i);
+ util::stream_format(stream, "%x", i);
}
if (tok & t_I4c) {
// 4 bit immediate, complemented
uint8_t i = ~op & 15;
- dst += sprintf(dst, "%x", i);
+ util::stream_format(stream, "%x", i);
}
if (tok & t_I4p) {
// 4 bit immediate offset into page 3
uint8_t i = op & 15;
- dst += sprintf(dst, "[%x]", 0x0c0 | i);
+ util::stream_format(stream, "[%x]", 0x0c0 | i);
}
if (tok & t_I6p) {
// 6 bit immediate offset into current page
uint8_t i = op & 63;
- dst += sprintf(dst, "%x", (PC & ~63) | i);
+ util::stream_format(stream, "%x", (PC & ~63) | i);
}
if (tok & t_I6i) {
@@ -418,19 +417,19 @@ CPU_DISASSEMBLE( pps4 )
// 8 bit absolute offset at 0x0100
uint16_t addr = (1 << 8) | 0; // ROM[ip3] can't be reached!?
(void)addr; // avoid unused variable warning
- dst += sprintf(dst, "[%x]", i6p3);
+ util::stream_format(stream, "[%x]", i6p3);
}
if (tok & t_I8) {
// 8 bit immediate I/O port address
uint8_t arg = ARG(pc++);
- dst += sprintf(dst, "%02x", arg);
+ util::stream_format(stream, "%02x", arg);
}
if (tok & t_I8c) {
// 8 bit immediate offset into page
uint16_t arg = ~ARG(pc++) & 255;
- dst += sprintf(dst, "%02x", arg);
+ util::stream_format(stream, "%02x", arg);
}
if (tok & t_OVER) // TL or TML
@@ -441,3 +440,12 @@ CPU_DISASSEMBLE( pps4 )
return (pc - PC) | flags | DASMFLAG_SUPPORTED;
}
+
+CPU_DISASSEMBLE(pps4)
+{
+ std::ostringstream stream;
+ offs_t result = internal_disasm_pps4(device, stream, pc, oprom, opram, options);
+ std::string stream_str = stream.str();
+ strcpy(buffer, stream_str.c_str());
+ return result;
+}