diff options
author | 2016-11-20 06:59:19 +1100 | |
---|---|---|
committer | 2016-11-20 06:59:19 +1100 | |
commit | 8d233c0cc7a41337626305b5c3db26be7511549f (patch) | |
tree | 577d8257e8bba7ce11f6dc6020104b63e578f1bf /src/devices/cpu | |
parent | 0c5b4f7090c12c6b83108fa29f3941307d64935d (diff) | |
parent | b8110263af2bb0dbf5385fc83398026f30d46ca5 (diff) |
Merge pull request #1747 from npwoods/dasmstream_lc8670
Changed the lc8670 disassembler to use 'std::ostream &' internally
Diffstat (limited to 'src/devices/cpu')
-rw-r--r-- | src/devices/cpu/lc8670/lc8670.h | 2 | ||||
-rw-r--r-- | src/devices/cpu/lc8670/lc8670dsm.cpp | 25 |
2 files changed, 20 insertions, 7 deletions
diff --git a/src/devices/cpu/lc8670/lc8670.h b/src/devices/cpu/lc8670/lc8670.h index 51c78b602c9..525eecf1643 100644 --- a/src/devices/cpu/lc8670/lc8670.h +++ b/src/devices/cpu/lc8670/lc8670.h @@ -260,6 +260,8 @@ private: OP_RII8 }; + offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options); + // disasm table struct dasm_entry { diff --git a/src/devices/cpu/lc8670/lc8670dsm.cpp b/src/devices/cpu/lc8670/lc8670dsm.cpp index af2672a88bc..180cc54e16b 100644 --- a/src/devices/cpu/lc8670/lc8670dsm.cpp +++ b/src/devices/cpu/lc8670/lc8670dsm.cpp @@ -151,7 +151,7 @@ void lc8670_cpu_device::dasm_arg(uint8_t op, char *buffer, offs_t pc, int arg, c // helper function //------------------------------------------------- -offs_t lc8670_cpu_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +offs_t lc8670_cpu_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) { int pos = 0; char arg1[16], arg2[16]; @@ -161,18 +161,29 @@ offs_t lc8670_cpu_device::disasm_disassemble(char *buffer, offs_t pc, const uint int op_idx = decode_op(op); const dasm_entry *inst = &s_dasm_table[op_idx]; - buffer += sprintf(buffer,"%-8s", inst->str); + util::stream_format(stream, "%-8s", inst->str); dasm_arg(op, inst->inv ? arg2 : arg1, pc+0, inst->arg1, oprom, pos); dasm_arg(op, inst->inv ? arg1 : arg2, pc+1, inst->arg2, oprom, pos); - strcat(buffer, arg1); + stream << arg1; if (inst->arg2 != OP_NULL) - { - strcat(buffer, ","); - strcat(buffer, arg2); - } + stream << "," << arg2; return pos; } + +//------------------------------------------------- +// disasm_disassemble - call the disassembly +// helper function +//------------------------------------------------- + +offs_t lc8670_cpu_device::disasm_disassemble(char *buffer, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +{ + std::ostringstream stream; + offs_t result = disasm_disassemble(stream, pc, oprom, opram, options); + std::string stream_str = stream.str(); + strcpy(buffer, stream_str.c_str()); + return result; +} |