Instruction output functionality.

This commit is contained in:
Marcel Keller
2021-11-20 18:01:26 +11:00
parent 0603e43375
commit ab63751788
3 changed files with 140 additions and 16 deletions

View File

@@ -7,6 +7,7 @@
#include "instructions.h"
#include "Processor.h"
#include "Math/gf2n.h"
#include "GC/instructions.h"
#include <iomanip>
@@ -89,6 +90,37 @@ void Instruction::bitdecint(ArithmeticProcessor& Proc) const
}
}
ostream& operator<<(ostream& s, const Instruction& instr)
{
switch (instr.get_opcode())
{
#define X(NAME, PRE, CODE) \
case NAME: s << #NAME; break;
ALL_INSTRUCTIONS
#undef X
#define X(NAME, CODE) \
case NAME: s << #NAME; break;
COMBI_INSTRUCTIONS
}
s << " size=" << instr.get_size();
s << " n=" << instr.get_n();
s << " r=(";
for (int i = 0; i < 3; i++)
s << instr.get_r(i) << ", ";
s << instr.get_r(3);
s << ")";
if (not instr.get_start().empty())
{
s << " args=(";
for (unsigned i = 0; i < instr.get_start().size() - 1; i++)
s << instr.get_start()[i] << ", ";
s << instr.get_start().back();
s << ")";
}
return s;
}
template void Instruction::execute_clear_gf2n(vector<gf2n_short>& registers,
vector<gf2n_short>& memory, ArithmeticProcessor& Proc) const;
template void Instruction::execute_clear_gf2n(vector<gf2n_long>& registers,

View File

@@ -805,22 +805,6 @@ bool BaseInstruction::is_direct_memory_access() const
}
inline
ostream& operator<<(ostream& s,const Instruction& instr)
{
s << instr.opcode << " : ";
for (int i=0; i<3; i++)
{ s << instr.r[i] << " "; }
s << " : " << instr.n;
if (instr.start.size()!=0)
{ s << " : " << instr.start.size() << " : ";
for (unsigned int i=0; i<instr.start.size(); i++)
{ s << instr.start[i] << " "; }
}
return s;
}
template<class sint, class sgf2n>
inline void Instruction::execute(Processor<sint, sgf2n>& Proc) const
{
@@ -1287,6 +1271,10 @@ void Program::execute(Processor<sint, sgf2n>& Proc) const
Proc.stats[p[Proc.PC].get_opcode()]++;
#endif
#ifdef OUTPUT_INSTRUCTIONS
cerr << instruction << endl;
#endif
Proc.PC++;
switch(instruction.get_opcode())

View File

@@ -280,4 +280,108 @@
X(GRAWOUTPUT, auto source = &C2[r[0]], \
(*source++).output(Proc.public_output, false)) \
#define REMAINING_INSTRUCTIONS \
X(CONVMODP, throw not_implemented(),) \
X(LDMC, throw not_implemented(),) \
X(LDMCI, throw not_implemented(),) \
X(STMC, throw not_implemented(),) \
X(STMCI, throw not_implemented(),) \
X(MOVC, throw not_implemented(),) \
X(DIVC, throw not_implemented(),) \
X(GDIVC, throw not_implemented(),) \
X(FLOORDIVC, throw not_implemented(),) \
X(MODC, throw not_implemented(),) \
X(LEGENDREC, throw not_implemented(),) \
X(DIGESTC, throw not_implemented(),) \
X(DIVCI, throw not_implemented(),) \
X(GDIVCI, throw not_implemented(),) \
X(INV2M, throw not_implemented(),) \
X(MODCI, throw not_implemented(),) \
X(SQUARE, throw not_implemented(),) \
X(GSQUARE, throw not_implemented(),) \
X(INV, throw not_implemented(),) \
X(GINV, throw not_implemented(),) \
X(RANDOMS, throw not_implemented(),) \
X(INPUTMASKREG, throw not_implemented(),) \
X(INPUTMASK, throw not_implemented(),) \
X(GINPUTMASK, throw not_implemented(),) \
X(INPUT, throw not_implemented(),) \
X(GINPUT, throw not_implemented(),) \
X(INPUTFIX, throw not_implemented(),) \
X(INPUTFLOAT, throw not_implemented(),) \
X(INPUTMIXED, throw not_implemented(),) \
X(INPUTMIXEDREG, throw not_implemented(),) \
X(RAWINPUT, throw not_implemented(),) \
X(GRAWINPUT, throw not_implemented(),) \
X(INPUTPERSONAL, throw not_implemented(),) \
X(NOTC, throw not_implemented(),) \
X(SHRSI, throw not_implemented(),) \
X(OPEN, throw not_implemented(),) \
X(GOPEN, throw not_implemented(),) \
X(MULS, throw not_implemented(),) \
X(GMULS, throw not_implemented(),) \
X(MULRS, throw not_implemented(),) \
X(GMULRS, throw not_implemented(),) \
X(DOTPRODS, throw not_implemented(),) \
X(GDOTPRODS, throw not_implemented(),) \
X(MATMULS, throw not_implemented(),) \
X(MATMULSM, throw not_implemented(),) \
X(CONV2DS, throw not_implemented(),) \
X(TRUNC_PR, throw not_implemented(),) \
X(CHECK, throw not_implemented(),) \
X(JMP, throw not_implemented(),) \
X(JMPI, throw not_implemented(),) \
X(JMPNZ, throw not_implemented(),) \
X(JMPEQZ, throw not_implemented(),) \
X(PRINTREG, throw not_implemented(),) \
X(PRINTREGPLAIN, throw not_implemented(),) \
X(CONDPRINTPLAIN, throw not_implemented(),) \
X(PRINTFLOATPLAIN, throw not_implemented(),) \
X(CONDPRINTSTR, throw not_implemented(),) \
X(REQBL, throw not_implemented(),) \
X(GREQBL, throw not_implemented(),) \
X(USE, throw not_implemented(),) \
X(USE_INP, throw not_implemented(),) \
X(USE_EDABIT, throw not_implemented(),) \
X(USE_MATMUL, throw not_implemented(),) \
X(USE_PREP, throw not_implemented(),) \
X(GUSE_PREP, throw not_implemented(),) \
X(TIME, throw not_implemented(),) \
X(START, throw not_implemented(),) \
X(STOP, throw not_implemented(),) \
X(RUN_TAPE, throw not_implemented(),) \
X(JOIN_TAPE, throw not_implemented(),) \
X(CRASH, throw not_implemented(),) \
X(STARTGRIND, throw not_implemented(),) \
X(STOPGRIND, throw not_implemented(),) \
X(NPLAYERS, throw not_implemented(),) \
X(THRESHOLD, throw not_implemented(),) \
X(PLAYERID, throw not_implemented(),) \
X(LISTEN, throw not_implemented(),) \
X(ACCEPTCLIENTCONNECTION, throw not_implemented(),) \
X(CLOSECLIENTCONNECTION, throw not_implemented(),) \
X(READSOCKETINT, throw not_implemented(),) \
X(READSOCKETC, throw not_implemented(),) \
X(READSOCKETS, throw not_implemented(),) \
X(WRITESOCKETINT, throw not_implemented(),) \
X(WRITESOCKETC, throw not_implemented(),) \
X(WRITESOCKETS, throw not_implemented(),) \
X(WRITESOCKETSHARE, throw not_implemented(),) \
X(WRITEFILESHARE, throw not_implemented(),) \
X(READFILESHARE, throw not_implemented(),) \
X(PUBINPUT, throw not_implemented(),) \
X(RAWOUTPUT, throw not_implemented(),) \
X(INTOUTPUT, throw not_implemented(),) \
X(FLOATOUTPUT, throw not_implemented(),) \
X(STARTPRIVATEOUTPUT, throw not_implemented(),) \
X(GSTARTPRIVATEOUTPUT, throw not_implemented(),) \
X(STOPPRIVATEOUTPUT, throw not_implemented(),) \
X(GSTOPPRIVATEOUTPUT, throw not_implemented(),) \
X(PREP, throw not_implemented(),) \
X(GPREP, throw not_implemented(),) \
X(CISC, throw not_implemented(),) \
#define ALL_INSTRUCTIONS ARITHMETIC_INSTRUCTIONS REGINT_INSTRUCTIONS \
CLEAR_GF2N_INSTRUCTIONS REMAINING_INSTRUCTIONS
#endif /* PROCESSOR_INSTRUCTIONS_H_ */