summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/cpu
diff options
context:
space:
mode:
author Nathan Woods <npwoods@mess.org>2016-11-17 19:52:23 -0500
committer Nathan Woods <npwoods@mess.org>2016-11-17 19:52:23 -0500
commit2ea1d7a4eed7251fd14b08643adade35418f5503 (patch)
tree10c429c7f782e28a6b35653e251fd6ec58d811cd /src/devices/cpu
parent1a9cdb5c7ab8895d168d55d6dfe1540917c8d9d3 (diff)
Changed the ssem disassembler to use 'std::ostream &' internally
Diffstat (limited to 'src/devices/cpu')
-rw-r--r--src/devices/cpu/ssem/ssemdasm.cpp42
1 files changed, 20 insertions, 22 deletions
diff --git a/src/devices/cpu/ssem/ssemdasm.cpp b/src/devices/cpu/ssem/ssemdasm.cpp
index efd9ba9715b..069d2ad9da3 100644
--- a/src/devices/cpu/ssem/ssemdasm.cpp
+++ b/src/devices/cpu/ssem/ssemdasm.cpp
@@ -8,17 +8,6 @@
#include "emu.h"
-static char *output;
-
-static void ATTR_PRINTF(1,2) print(const char *fmt, ...)
-{
- va_list vl;
-
- va_start(vl, fmt);
- output += vsprintf(output, fmt, vl);
- va_end(vl);
-}
-
static inline uint32_t reverse(uint32_t v)
{
// Taken from http://www-graphics.stanford.edu/~seander/bithacks.html#ReverseParallel
@@ -36,45 +25,54 @@ static inline uint32_t reverse(uint32_t v)
return v;
}
-offs_t ssem_dasm_one(char *buffer, offs_t pc, uint32_t op)
+static offs_t ssem_dasm_one(std::ostream &stream, offs_t pc, uint32_t op)
{
uint8_t instr = (reverse(op) >> 13) & 7;
uint8_t addr = reverse(op) & 0x1f;
- output = buffer;
-
switch (instr)
{
case 0: // JMP S
- print("JMP %d", addr);
+ util::stream_format(stream, "JMP %d", addr);
break;
case 1: // JRP S
- print("JRP %d", addr);
+ util::stream_format(stream, "JRP %d", addr);
break;
case 2: // LDN S
- print("LDN %d", addr);
+ util::stream_format(stream, "LDN %d", addr);
break;
case 3: // STO S
- print("STO %d", addr);
+ util::stream_format(stream, "STO %d", addr);
break;
case 4: // SUB S
case 5:
- print("SUB %d", addr);
+ util::stream_format(stream, "SUB %d", addr);
break;
case 6: // CMP
- print("CMP");
+ util::stream_format(stream, "CMP");
break;
case 7: // STP
- print("STP");
+ util::stream_format(stream, "STP");
break;
default:
- print("???");
+ util::stream_format(stream, "???");
break;
}
return 4 | DASMFLAG_SUPPORTED;
}
+
+static offs_t ssem_dasm_one(char *buffer, offs_t pc, uint32_t op)
+{
+ std::ostringstream stream;
+ offs_t result = ssem_dasm_one(stream, pc, op);
+ std::string stream_str = stream.str();
+ strcpy(buffer, stream_str.c_str());
+ return result;
+}
+
+
/*****************************************************************************/
CPU_DISASSEMBLE( ssem )