Removes all std::strings from the dsp56k cpu core. (Not worth mentioning)

This commit is contained in:
Andrew Gardner 2010-10-23 07:05:44 +00:00
parent 216a806fdb
commit 1b872c9b0b
8 changed files with 429 additions and 436 deletions

View File

@ -21,7 +21,7 @@ CPU_DISASSEMBLE( dsp56k )
// Decode and disassemble.
DSP56K::Opcode op(w0, w1);
sprintf(buffer, "%s", op.disassemble().c_str());
sprintf(buffer, "%s", op.disassemble().cstr());
const unsigned size = op.size();
return (size | DASMFLAG_SUPPORTED);

View File

@ -41,7 +41,7 @@ Instruction* Instruction::decodeInstruction(const Opcode* opc,
dynamic_cast<Sub*>(op) ||
dynamic_cast<Tfr*>(op) ||
dynamic_cast<Tst*>(op)
/* TODO: More? */)
/* TODO: More? */)
{
op->m_sizeIncrement = 1;
return op;

File diff suppressed because it is too large Load Diff

View File

@ -19,7 +19,7 @@ Opcode::~Opcode()
}
std::string Opcode::disassemble() const
astring Opcode::disassemble() const
{
// Duck out early if there isn't a valid op
if (!m_instruction)
@ -32,8 +32,8 @@ std::string Opcode::disassemble() const
return dcString();
// Disassemble what you can.
std::string opString = "";
std::string pmString = "";
astring opString = "";
astring pmString = "";
if (m_instruction) m_instruction->disassemble(opString);
if (m_parallelMove) m_parallelMove->disassemble(pmString);
@ -71,11 +71,11 @@ const reg_id& Opcode::instSource() const { return m_instruction->source(); }
const reg_id& Opcode::instDestination() const { return m_instruction->destination(); }
const size_t Opcode::instAccumulatorBitsModified() const { return m_instruction->accumulatorBitsModified(); }
std::string Opcode::dcString() const
astring Opcode::dcString() const
{
char tempStr[1024];
sprintf(tempStr, "dc $%x", m_word0);
return std::string(tempStr);
return astring(tempStr);
}
}

View File

@ -1,8 +1,6 @@
#ifndef __DSP56K_OPCODE_H__
#define __DSP56K_OPCODE_H__
#include <string>
#include "emu.h"
#include "inst.h"
#include "pmove.h"
@ -24,7 +22,7 @@ public:
Opcode(UINT16 w0, UINT16 w1);
virtual ~Opcode();
std::string disassemble() const;
astring disassemble() const;
void evaluate(dsp56k_core* cpustate) const;
size_t size() const;
size_t evalSize() const;
@ -41,7 +39,7 @@ private:
UINT16 m_word0;
UINT16 m_word1;
std::string dcString() const;
astring dcString() const;
};
}

View File

@ -1,8 +1,6 @@
#ifndef __DSP56K_PARALLEL_MOVE_H__
#define __DSP56K_PARALLEL_MOVE_H__
#include <string>
#include "emu.h"
#include "opcode.h"
#include "tables.h"
@ -22,7 +20,7 @@ public:
virtual ~ParallelMove() {}
virtual bool decode(const UINT16 word0, const UINT16 word1) = 0;
virtual void disassemble(std::string& retString) const = 0;
virtual void disassemble(astring& retString) const = 0;
virtual void evaluate() = 0;
static ParallelMove* decodeParallelMove(const Opcode* opc, const UINT16 word0, const UINT16 word1);
@ -60,7 +58,7 @@ public:
reg_id SD;
decode_HHH_table(BITSn(word0,0x0e00), SD);
std::string ea;
astring ea;
assemble_ea_from_m_table(BITSn(word0,0x4000), regIDAsNum(r), ea);
assemble_arguments_from_W_table(BITSn(word0,0x0100), 'X', SD, ea,
@ -72,15 +70,15 @@ public:
return true;
}
void disassemble(std::string& retString) const
void disassemble(astring& retString) const
{
retString = m_source + "," + m_destination;
}
void evaluate() {}
private:
std::string m_source;
std::string m_destination;
astring m_source;
astring m_destination;
};
@ -94,7 +92,7 @@ public:
}
bool decode(const UINT16 word0, const UINT16 word1)
{
std::string ea;
astring ea;
if (opDestination() == iB)
ea = "(A1)";
else if (opDestination() == iA)
@ -114,15 +112,15 @@ public:
return true;
}
void disassemble(std::string& retString) const
void disassemble(astring& retString) const
{
retString = m_source + "," + m_destination;
}
void evaluate() {}
private:
std::string m_source;
std::string m_destination;
astring m_source;
astring m_destination;
};
@ -139,8 +137,8 @@ public:
reg_id r;
reg_id D1;
reg_id D2;
std::string ea1 = "";
std::string ea2 = "";
astring ea1 = "";
astring ea2 = "";
decode_rr_table(BITSn(word0,0x0060), r);
decode_KKK_table(BITSn(word0,0x0700), D1, D2);
@ -161,22 +159,22 @@ public:
if (r == iR3) return false;
char temp[32];
sprintf(temp, "X:%s,%s", ea1.c_str(), regIdAsString(D1).c_str());
sprintf(temp, "X:%s,%s", ea1.cstr(), regIdAsString(D1).cstr());
parallelMove = temp;
sprintf(temp, "X:%s,%s", ea2.c_str(), regIdAsString(D2).c_str());
sprintf(temp, "X:%s,%s", ea2.cstr(), regIdAsString(D2).cstr());
parallelMove2 = temp;
return true;
}
void disassemble(std::string& retString) const
void disassemble(astring& retString) const
{
retString = parallelMove + " " + parallelMove2;
}
void evaluate() {}
private:
std::string parallelMove;
std::string parallelMove2;
astring parallelMove;
astring parallelMove2;
};
@ -215,7 +213,7 @@ public:
return true;
}
void disassemble(std::string& retString) const
void disassemble(astring& retString) const
{
// (?,?) is a parallel nop
if (m_source == iWEIRD && m_destination == iWEIRD)
@ -256,21 +254,21 @@ public:
decode_RR_table(BITSn(word0,0x00c0), r);
decode_DD_table(BITSn(word0,0x0030), S);
sprintf(parallel_move_str, "%s,X:(R%d)+N%d", regIdAsString(Dnot).c_str(), regIDAsNum(r), regIDAsNum(r));
sprintf(parallel_move_str2, "%s,%s", regIdAsString(S).c_str(), regIdAsString(Dnot).c_str());
sprintf(parallel_move_str, "%s,X:(R%d)+N%d", regIdAsString(Dnot).cstr(), regIDAsNum(r), regIDAsNum(r));
sprintf(parallel_move_str2, "%s,%s", regIdAsString(S).cstr(), regIdAsString(Dnot).cstr());
pms = parallel_move_str;
pms2 = parallel_move_str2;
return true;
}
void disassemble(std::string& retString) const
void disassemble(astring& retString) const
{
retString = pms + " " + pms2;
}
void evaluate() {}
private:
std::string pms; // TODO
std::string pms2;
astring pms; // TODO
astring pms2;
};
@ -291,14 +289,14 @@ public:
return true;
}
void disassemble(std::string& retString) const
void disassemble(astring& retString) const
{
retString = m_ea;
}
void evaluate() {}
private:
std::string m_ea;
astring m_ea;
};
@ -316,7 +314,7 @@ public:
{
INT8 b;
reg_id SD;
std::string args;
astring args;
b = (char)(word0 & 0x00ff);
decode_HHH_table(BITSn(word1,0x0e00), SD);
@ -324,15 +322,15 @@ public:
return true;
}
void disassemble(std::string& retString) const
void disassemble(astring& retString) const
{
retString = m_source + "," + m_destination;
}
void evaluate() {}
private:
std::string m_source;
std::string m_destination;
astring m_source;
astring m_destination;
};
}

View File

@ -1,4 +1,3 @@
#include <string>
#include <cstdio>
#include <cstring>
#include <cstdlib>
@ -285,7 +284,7 @@ void decode_JF_table(const UINT16 J, const UINT16 F, reg_id& S, reg_id& D)
// NEW // }
// NEW // }
void decode_kSign_table(const UINT16 k, std::string& plusMinus)
void decode_kSign_table(const UINT16 k, astring& plusMinus)
{
switch(k)
{
@ -433,7 +432,7 @@ void decode_ss_table(const UINT16 ss, op_mnem& arithmetic)
}
}
void decode_uuuuF_table(const UINT16 uuuu, const UINT16 F, std::string& arg, reg_id& S, reg_id& D)
void decode_uuuuF_table(const UINT16 uuuu, const UINT16 F, astring& arg, reg_id& S, reg_id& D)
{
const UINT16 switchVal = (uuuu << 1) | F;
@ -475,7 +474,7 @@ void decode_uuuuF_table(const UINT16 uuuu, const UINT16 F, std::string& arg, reg
}
}
void decode_Z_table(const UINT16 Z, std::string& ea)
void decode_Z_table(const UINT16 Z, astring& ea)
{
/* This is fixed as per the Family Manual errata addendum */
switch(Z)
@ -485,7 +484,7 @@ void decode_Z_table(const UINT16 Z, std::string& ea)
}
}
void assemble_ea_from_m_table(const UINT16 m, const int n, std::string& ea)
void assemble_ea_from_m_table(const UINT16 m, const int n, astring& ea)
{
char temp[32];
switch(m)
@ -496,7 +495,7 @@ void assemble_ea_from_m_table(const UINT16 m, const int n, std::string& ea)
ea = temp;
}
void assemble_eas_from_mm_table(UINT16 mm, int n1, int n2, std::string& ea1, std::string& ea2)
void assemble_eas_from_mm_table(UINT16 mm, int n1, int n2, astring& ea1, astring& ea2)
{
char temp1[32];
char temp2[32];
@ -515,7 +514,7 @@ void assemble_eas_from_mm_table(UINT16 mm, int n1, int n2, std::string& ea1, std
ea2 = temp2;
}
void assemble_ea_from_MM_table(UINT16 MM, int n, std::string& ea)
void assemble_ea_from_MM_table(UINT16 MM, int n, astring& ea)
{
char temp[32];
switch(MM)
@ -528,7 +527,7 @@ void assemble_ea_from_MM_table(UINT16 MM, int n, std::string& ea)
ea = temp;
}
void assemble_ea_from_q_table(UINT16 q, int n, std::string& ea)
void assemble_ea_from_q_table(UINT16 q, int n, astring& ea)
{
char temp[32];
switch(q)
@ -539,7 +538,7 @@ void assemble_ea_from_q_table(UINT16 q, int n, std::string& ea)
ea = temp;
}
void assemble_ea_from_t_table(UINT16 t, UINT16 val, std::string& ea)
void assemble_ea_from_t_table(UINT16 t, UINT16 val, astring& ea)
{
char temp[32];
switch(t)
@ -552,7 +551,7 @@ void assemble_ea_from_t_table(UINT16 t, UINT16 val, std::string& ea)
ea = temp;
}
void assemble_ea_from_z_table(UINT16 z, int n, std::string& ea)
void assemble_ea_from_z_table(UINT16 z, int n, astring& ea)
{
char temp[32];
switch(z)
@ -563,10 +562,10 @@ void assemble_ea_from_z_table(UINT16 z, int n, std::string& ea)
ea = temp;
}
void assemble_D_from_P_table(UINT16 P, UINT16 ppppp, std::string& D)
void assemble_D_from_P_table(UINT16 P, UINT16 ppppp, astring& D)
{
char temp[32];
std::string fullAddy; /* Convert Short Absolute Address to full 16-bit */
astring fullAddy; /* Convert Short Absolute Address to full 16-bit */
switch(P)
{
@ -576,18 +575,18 @@ void assemble_D_from_P_table(UINT16 P, UINT16 ppppp, std::string& D)
break;
case 0x1:
assemble_address_from_IO_short_address(ppppp, fullAddy);
sprintf(temp, "X:<<$%s", fullAddy.c_str());
// NEW // sprintf(temp, "X:$%s", fullAddy.c_str());
sprintf(temp, "X:<<$%s", fullAddy.cstr());
// NEW // sprintf(temp, "X:$%s", fullAddy.cstr());
break;
}
D = temp;
}
void assemble_arguments_from_W_table(UINT16 W, char ma, const reg_id& SD, const std::string& ea,
std::string& source, std::string& destination)
void assemble_arguments_from_W_table(UINT16 W, char ma, const reg_id& SD, const astring& ea,
astring& source, astring& destination)
{
char temp[32];
sprintf(temp, "%c:%s", ma, ea.c_str());
sprintf(temp, "%c:%s", ma, ea.cstr());
switch(W)
{
case 0x0: source = regIdAsString(SD); destination = temp; break;
@ -595,11 +594,11 @@ void assemble_arguments_from_W_table(UINT16 W, char ma, const reg_id& SD, const
}
}
void assemble_arguments_from_W_table(UINT16 W, char ma, const std::string& SD, const std::string& ea,
std::string& source, std::string& destination)
void assemble_arguments_from_W_table(UINT16 W, char ma, const astring& SD, const astring& ea,
astring& source, astring& destination)
{
char temp[32];
sprintf(temp, "%c:%s", ma, ea.c_str());
sprintf(temp, "%c:%s", ma, ea.cstr());
switch(W)
{
case 0x0: source = SD; destination = temp; break;
@ -607,7 +606,7 @@ void assemble_arguments_from_W_table(UINT16 W, char ma, const std::string& SD, c
}
}
void assemble_reg_from_W_table(UINT16 W, char ma, const reg_id& SD, const INT8 xx, std::string& S, std::string& D)
void assemble_reg_from_W_table(UINT16 W, char ma, const reg_id& SD, const INT8 xx, astring& S, astring& D)
{
UINT8 abs_xx;
char temp[32];
@ -629,7 +628,7 @@ void assemble_reg_from_W_table(UINT16 W, char ma, const reg_id& SD, const INT8 x
}
}
void assemble_address_from_IO_short_address(UINT16 pp, std::string& ea)
void assemble_address_from_IO_short_address(UINT16 pp, astring& ea)
{
char temp[32];
@ -753,7 +752,7 @@ void setReg16(dsp56k_core* cpustate, const UINT16& value, const reg_id& reg)
if (reg == iM3) M3 = value;
}
std::string regIdAsString(const reg_id& regId)
astring regIdAsString(const reg_id& regId)
{
switch(regId)
{
@ -801,7 +800,7 @@ std::string regIdAsString(const reg_id& regId)
return "INVALID_REG_ID";
}
std::string opMnemonicAsString(const op_mnem& mnem)
astring opMnemonicAsString(const op_mnem& mnem)
{
switch(mnem)
{
@ -831,7 +830,7 @@ std::string opMnemonicAsString(const op_mnem& mnem)
return "INVALID_OPCODE_MNEMONIC";
}
reg_id stringAsRegID(const std::string& str)
reg_id stringAsRegID(const astring& str)
{
if (str == "X") return iX;
if (str == "X0") return iX0;

View File

@ -1,7 +1,6 @@
#ifndef __DSP56K_OPS_H__
#define __DSP56K_OPS_H__
#include <string>
#include <cstdio>
#include <cstdlib>
@ -48,7 +47,7 @@ void decode_IIIIx_table(const UINT16 IIII, const UINT16 x, reg_id& S, reg_id& D)
void decode_JJJF_table(const UINT16 JJJ, const UINT16 F, reg_id& S, reg_id& D);
void decode_JJF_table(const UINT16 JJ, const UINT16 F, reg_id& S, reg_id& D);
void decode_JF_table(const UINT16 J, const UINT16 F, reg_id& S, reg_id& D);
void decode_kSign_table(const UINT16 k, std::string& plusMinus);
void decode_kSign_table(const UINT16 k, astring& plusMinus);
void decode_KKK_table(const UINT16 KKK, reg_id& D1, reg_id& D2);
void decode_NN_table(UINT16 NN, reg_id& ret);
void decode_TT_table(UINT16 TT, reg_id& ret);
@ -59,20 +58,20 @@ void decode_RR_table(UINT16 RR, reg_id& ret);
void decode_rr_table(UINT16 rr, reg_id& ret);
void decode_s_table(const UINT16 s, op_mnem& arithmetic);
void decode_ss_table(const UINT16 ss, op_mnem& arithmetic);
void decode_uuuuF_table(const UINT16 uuuu, const UINT16 F, std::string& arg, reg_id& S, reg_id& D);
void decode_Z_table(const UINT16 Z, std::string& ea);
void decode_uuuuF_table(const UINT16 uuuu, const UINT16 F, astring& arg, reg_id& S, reg_id& D);
void decode_Z_table(const UINT16 Z, astring& ea);
void assemble_ea_from_m_table(const UINT16 m, const int n, std::string& ea);
void assemble_eas_from_mm_table(UINT16 mm, int n1, int n2, std::string& ea1, std::string& ea2);
void assemble_ea_from_MM_table(UINT16 MM, int n, std::string& ea);
void assemble_ea_from_q_table(UINT16 q, int n, std::string& ea);
void assemble_ea_from_t_table(UINT16 t, UINT16 val, std::string& ea);
void assemble_ea_from_z_table(UINT16 z, int n, std::string& ea);
void assemble_D_from_P_table(UINT16 P, UINT16 ppppp, std::string& D);
void assemble_arguments_from_W_table(UINT16 W, char ma, const reg_id& SD, const std::string& ea, std::string& S, std::string& D);
void assemble_arguments_from_W_table(UINT16 W, char ma, const std::string& SD, const std::string& ea, std::string& S, std::string& D);
void assemble_reg_from_W_table(UINT16 W, char ma, const reg_id& SD, const INT8 xx, std::string& S, std::string& D);
void assemble_address_from_IO_short_address(UINT16 pp, std::string& ea);
void assemble_ea_from_m_table(const UINT16 m, const int n, astring& ea);
void assemble_eas_from_mm_table(UINT16 mm, int n1, int n2, astring& ea1, astring& ea2);
void assemble_ea_from_MM_table(UINT16 MM, int n, astring& ea);
void assemble_ea_from_q_table(UINT16 q, int n, astring& ea);
void assemble_ea_from_t_table(UINT16 t, UINT16 val, astring& ea);
void assemble_ea_from_z_table(UINT16 z, int n, astring& ea);
void assemble_D_from_P_table(UINT16 P, UINT16 ppppp, astring& D);
void assemble_arguments_from_W_table(UINT16 W, char ma, const reg_id& SD, const astring& ea, astring& S, astring& D);
void assemble_arguments_from_W_table(UINT16 W, char ma, const astring& SD, const astring& ea, astring& S, astring& D);
void assemble_reg_from_W_table(UINT16 W, char ma, const reg_id& SD, const INT8 xx, astring& S, astring& D);
void assemble_address_from_IO_short_address(UINT16 pp, astring& ea);
INT8 get_6_bit_signed_value(UINT16 bits);
@ -84,9 +83,9 @@ bool registerOverlap(const reg_id& r0, const size_t bmd, const reg_id& r1);
UINT16 regValue16(dsp56k_core* cpustate, const reg_id& reg);
void setReg16(dsp56k_core* cpustate, const UINT16& value, const reg_id& reg);
std::string regIdAsString(const reg_id& regId);
std::string opMnemonicAsString(const op_mnem& mnem);
reg_id stringAsRegID(const std::string& str);
astring regIdAsString(const reg_id& regId);
astring opMnemonicAsString(const op_mnem& mnem);
reg_id stringAsRegID(const astring& str);
UINT8 regIDAsNum(const reg_id& regId);