Merge pull request #1629 from npwoods/dasmstream_tms7000

Changed the TMS7000 disassembler to use 'std::ostream &' internally
This commit is contained in:
R. Belmont 2016-11-03 14:24:39 -04:00 committed by GitHub
commit 1097a25e13

View File

@ -367,7 +367,7 @@ static const tms7000_opcodeinfo opcodes[] = {
{0x00, "NOP", 23, 0 } {0x00, "NOP", 23, 0 }
}; };
CPU_DISASSEMBLE( tms7000 ) static offs_t internal_disasm_tms7000(cpu_device *device, std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, int options)
{ {
int opcode, i/*, size = 1*/; int opcode, i/*, size = 1*/;
int pos = 0; int pos = 0;
@ -387,7 +387,7 @@ CPU_DISASSEMBLE( tms7000 )
uint16_t c; uint16_t c;
int16_t d; int16_t d;
buffer += sprintf (buffer, "%s", opcodes[i].name); util::stream_format(stream, "%s", opcodes[i].name);
j=opcodes[i].operand; j=opcodes[i].operand;
@ -398,39 +398,39 @@ CPU_DISASSEMBLE( tms7000 )
case DONE: case DONE:
break; break;
case NONE: case NONE:
buffer += sprintf (buffer, "%s", of[j].opstr[k]); util::stream_format(stream, "%s", of[j].opstr[k]);
break; break;
case UI8: case UI8:
a = (uint8_t)opram[pos++]; a = (uint8_t)opram[pos++];
buffer += sprintf(buffer, of[j].opstr[k], (unsigned int)a); util::stream_format(stream, of[j].opstr[k], (unsigned int)a);
break; break;
case I8: case I8:
b = (int8_t)opram[pos++]; b = (int8_t)opram[pos++];
buffer += sprintf (buffer, of[j].opstr[k], (int8_t)b); util::stream_format(stream, of[j].opstr[k], (int8_t)b);
break; break;
case UI16: case UI16:
c = (uint16_t)opram[pos++]; c = (uint16_t)opram[pos++];
c <<= 8; c <<= 8;
c += opram[pos++]; c += opram[pos++];
buffer += sprintf (buffer, of[j].opstr[k], (unsigned int)c); util::stream_format(stream, of[j].opstr[k], (unsigned int)c);
break; break;
case I16: case I16:
d = (int16_t)opram[pos++]; d = (int16_t)opram[pos++];
d <<= 8; d <<= 8;
d += opram[pos++]; d += opram[pos++];
buffer += sprintf (buffer, of[j].opstr[k], (signed int)d); util::stream_format(stream, of[j].opstr[k], (signed int)d);
break; break;
case PCREL: case PCREL:
b = (int8_t)opram[pos++]; b = (int8_t)opram[pos++];
sprintf(tmpbuf, "$%04X", pc+2+k+b); sprintf(tmpbuf, "$%04X", pc+2+k+b);
buffer += sprintf (buffer, of[j].opstr[k], tmpbuf); util::stream_format(stream, of[j].opstr[k], tmpbuf);
break; break;
case PCABS: case PCABS:
c = (uint16_t)opram[pos++]; c = (uint16_t)opram[pos++];
c <<= 8; c <<= 8;
c += opram[pos++]; c += opram[pos++];
sprintf(tmpbuf, "$%04X", c); sprintf(tmpbuf, "$%04X", c);
buffer += sprintf (buffer, of[j].opstr[k], tmpbuf); util::stream_format(stream, of[j].opstr[k], tmpbuf);
break; break;
case TRAP: case TRAP:
vector = 0xffff - ((0xff - opcode) * 2); vector = 0xffff - ((0xff - opcode) * 2);
@ -443,6 +443,16 @@ CPU_DISASSEMBLE( tms7000 )
} }
/* No Match */ /* No Match */
strcpy (buffer, "Illegal Opcode"); stream << "Illegal Opcode";
return pos | DASMFLAG_SUPPORTED; return pos | DASMFLAG_SUPPORTED;
} }
CPU_DISASSEMBLE(tms7000)
{
std::ostringstream stream;
offs_t result = internal_disasm_tms7000(device, stream, pc, oprom, opram, options);
std::string stream_str = stream.str();
strcpy(buffer, stream_str.c_str());
return result;
}