void Decode( HookParameter<ExtraOpDecoder, ExtraOpDecodeArgs>* param );
__asm__ (
".int 1<<26 \n\t"
);
class TestOp : public ExtraOpInfoIF
{
OpClass m_opClass;
public:
TestOp() : m_opClass(OpClassCode::syscall)
{
}
void Execute( OpStateIF* opState )
{
opState->SetDst( 0, opState->GetSrc(0) + 1 );
}
// 命令の種類
const OpClass& GetOpClass() const
{
return m_opClass;
}
// オペランド
int GetSrcOperand(const int index) const
{
return 1; // レジスタ番号1
}
int GetDstOperand(const int index) const
{
return 1; // レジスタ番号1
}
// オペランドの数
int GetSrcNum() const
{
return 1;
}
int GetDstNum() const
{
return 1;
}
// ニーモニック (dump等のため)
const char* GetMnemonic() const
{
return "TestOp";
}
};
class TestDecoder
{
struct MicroOps
{
ExtraOpInfoIF* ops[SimISAInfo::MAX_OP_INFO_COUNT_PER_PC];
int count;
};
vector<MicroOps> m_mops;
public:
TestDecoder()
{
ExtraOpDecoder::s_extraOpDecodeHook.Register( this, &TestDecoder::Decode, 0 );
};
~TestDecoder()
{
// Release ops
for( size_t i = 0; i < m_mops.size(); i++ ){
for( int j = 0; j < m_mops[i].count; j++ ){
delete m_mops[i].ops[j];
}
}
}
void Decode( HookParameter<ExtraOpDecoder, ExtraOpDecodeArgs>* param )
{
ExtraOpDecodeArgs* args = param->GetParameter();
args->decoded = false;
int opCode = (args->codeWord >> 26) & 63;
if( opCode == 1 ){
args->decoded = true;
MicroOps mops;
mops.count = 1;
mops.ops[0] = new TestOp;
m_mops.push_back( mops );
args->decodedOps->first = &mops.ops[0];
args->decodedOps->second = mops.count;
}
};
};