Changed the sc61860 disassembler to use 'std::ostream &' internally

This commit is contained in:
Nathan Woods 2016-11-03 06:36:30 -04:00
parent 3ee5564b78
commit 87672cf2d3

View File

@ -152,7 +152,7 @@ static const struct { const char *mnemonic; Adr adr; } table[]={
{ nullptr }, { nullptr }, { nullptr }, { nullptr }, { nullptr }, { nullptr }, { nullptr }, { nullptr }, { nullptr }, { nullptr }, { nullptr }, { nullptr }, { nullptr }, { nullptr }, { nullptr }, { nullptr },
}; };
CPU_DISASSEMBLE( sc61860 ) static offs_t internal_disasm_sc61860(cpu_device *device, std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, int options)
{ {
const uint8_t *base_oprom = oprom; const uint8_t *base_oprom = oprom;
int oper=*(oprom++); int oper=*(oprom++);
@ -161,42 +161,42 @@ CPU_DISASSEMBLE( sc61860 )
switch(oper&0xc0) { switch(oper&0xc0) {
case 0x80: case 0x80:
sprintf(buffer,"%-6s%.2x",table[oper&0x80].mnemonic, oper&0x3f); util::stream_format(stream,"%-6s%02x",table[oper&0x80].mnemonic, oper&0x3f);
break; break;
default: default:
switch(oper&0xe0) { switch(oper&0xe0) {
case 0xe0: case 0xe0:
sprintf(buffer,"%-6s%.4x",table[oper&0xe0].mnemonic, util::stream_format(stream,"%-6s%04x",table[oper&0xe0].mnemonic,
*(oprom++)|((oper&0x1f)<<8)); *(oprom++)|((oper&0x1f)<<8));
break; break;
default: default:
switch (table[oper].adr) { switch (table[oper].adr) {
case Ill: sprintf(buffer,"?%.2x",oper);break; case Ill: util::stream_format(stream,"?%02x",oper);break;
case Imp: sprintf(buffer,"%s",table[oper].mnemonic); break; case Imp: util::stream_format(stream,"%s",table[oper].mnemonic); break;
case Imm: sprintf(buffer,"%-6s%.2x",table[oper].mnemonic, *(oprom++)); break; case Imm: util::stream_format(stream,"%-6s%02x",table[oper].mnemonic, *(oprom++)); break;
case ImmW: case ImmW:
adr=(oprom[0]<<8)|oprom[1];oprom+=2; adr=(oprom[0]<<8)|oprom[1];oprom+=2;
sprintf(buffer,"%-6s%.4x",table[oper].mnemonic, adr); util::stream_format(stream,"%-6s%04x",table[oper].mnemonic, adr);
break; break;
case Abs: case Abs:
adr=(oprom[0]<<8)|oprom[1];oprom+=2; adr=(oprom[0]<<8)|oprom[1];oprom+=2;
sprintf(buffer,"%-6s%.4x",table[oper].mnemonic, adr); util::stream_format(stream,"%-6s%04x",table[oper].mnemonic, adr);
break; break;
case RelM: case RelM:
adr=pc-*(oprom++); adr=pc-*(oprom++);
sprintf(buffer,"%-6s%.4x",table[oper].mnemonic, adr&0xffff); util::stream_format(stream,"%-6s%04x",table[oper].mnemonic, adr&0xffff);
break; break;
case RelP: case RelP:
adr=pc+*(oprom++); adr=pc+*(oprom++);
sprintf(buffer,"%-6s%.4x",table[oper].mnemonic, adr&0xffff); util::stream_format(stream,"%-6s%04x",table[oper].mnemonic, adr&0xffff);
break; break;
case Ptc: case Ptc:
t=*(oprom++); t=*(oprom++);
adr=(oprom[0]<<8)|oprom[1];oprom+=2; adr=(oprom[0]<<8)|oprom[1];oprom+=2;
sprintf(buffer,"%-6s%.2x,%.4x",table[oper].mnemonic,t, adr); util::stream_format(stream,"%-6s%02x,%04x",table[oper].mnemonic,t, adr);
break; break;
case Etc: case Etc:
sprintf(buffer,"%-6s",table[oper].mnemonic); util::stream_format(stream,"%-6s",table[oper].mnemonic);
/*H imm, abs */ /*H imm, abs */
/* abs */ /* abs */
break; break;
@ -208,3 +208,13 @@ CPU_DISASSEMBLE( sc61860 )
} }
return oprom - base_oprom; return oprom - base_oprom;
} }
CPU_DISASSEMBLE(sc61860)
{
std::ostringstream stream;
offs_t result = internal_disasm_sc61860(device, stream, pc, oprom, opram, options);
std::string stream_str = stream.str();
strcpy(buffer, stream_str.c_str());
return result;
}