From 20801e7a3bdaf5f11941b4f4c1f318503efe6ab4 Mon Sep 17 00:00:00 2001 From: Nathan Woods Date: Sun, 23 Oct 2016 16:56:13 -0400 Subject: [PATCH] Changed the ARC disassembler to use std::ostream internally --- src/devices/cpu/arc/arcdasm.cpp | 34 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 19 deletions(-) diff --git a/src/devices/cpu/arc/arcdasm.cpp b/src/devices/cpu/arc/arcdasm.cpp index 872f821d560..abf36e83027 100644 --- a/src/devices/cpu/arc/arcdasm.cpp +++ b/src/devices/cpu/arc/arcdasm.cpp @@ -9,17 +9,6 @@ #include "emu.h" #include -static char *output; - -static void ATTR_PRINTF(1,2) print(const char *fmt, ...) -{ - va_list vl; - - va_start(vl, fmt); - vsprintf(output, fmt, vl); - va_end(vl); -} - /*****************************************************************************/ @@ -191,34 +180,41 @@ static const char *regnames[0x40] = #define ARC_REGOP_SHIMM ((op & 0x000001ff) >> 0 ) // aka D -CPU_DISASSEMBLE(arc) +static offs_t internal_disasm_arc(cpu_device *device, std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, int options) { uint32_t op = oprom[0] | (oprom[1] << 8) | (oprom[2] << 16) | (oprom[3] << 24); op = big_endianize_int32(op); - output = buffer; - uint8_t opcode = ARC_OPERATION; switch (opcode) { case 0x04: // B case 0x05: // BL - print("%s(%s)(%s) %08x", basic[opcode], conditions[ARC_CONDITION], delaytype[ARC_BRANCH_DELAY], (ARC_BRANCH_ADDR<<2)+pc+4); + util::stream_format(stream, "%s(%s)(%s) %08x", basic[opcode], conditions[ARC_CONDITION], delaytype[ARC_BRANCH_DELAY], (ARC_BRANCH_ADDR<<2)+pc+4); break; case 0x08: // ADD // todo, short / long immediate formats - print("%s %s , %s , %s (%08x)", basic[opcode], regnames[ARC_REGOP_DEST], regnames[ARC_REGOP_OP1], regnames[ARC_REGOP_OP2], op &~ 0xfffffe00); + util::stream_format(stream, "%s %s , %s , %s (%08x)", basic[opcode], regnames[ARC_REGOP_DEST], regnames[ARC_REGOP_OP1], regnames[ARC_REGOP_OP2], op &~ 0xfffffe00); break; default: - print("%s (%08x)", basic[opcode], op &~ 0xf8000000); + util::stream_format(stream, "%s (%08x)", basic[opcode], op &~ 0xf8000000); break; } - - return 4 | DASMFLAG_SUPPORTED; } + + +CPU_DISASSEMBLE(arc) +{ + std::ostringstream stream; + offs_t result = internal_disasm_arc(device, stream, pc, oprom, opram, options); + std::string stream_str = stream.str(); + strcpy(buffer, stream_str.c_str()); + return result; +} +