Table of Contents |
# この機能は現在公開されているバージョンには,まだ実装されていません
はじめに †
- 鬼斬では,ユーザー定義の新しい命令をエミュレータに追加する機構を備えてる
- 具体的な手順は以下の通り
- デコードのフック・ポイントに対し,ユーザー定義のデコード・メソッドを登録
- ユーザー定義のデコード・メソッドが呼ばれた場合,コードのバイト列から必要に応じて命令を生成し,返す
手順 †
- デコードのフック・ポイントに対し,ユーザー定義のデコード・メソッドを登録
- デコードに必要な情報の取得
- Opコードのチェック
- 命令の生成
備考 †
- 簡単なテストの際は,gcc のインライン・アセンブラに直接数値を埋め込むと良い
__asm__ ( ".int 1<<26 \n\t" );
サンプル †
- 以下は ソースを1つ取り,インクリメントして返す命令の例
- 命令のOpコードは1<<26.
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; } }; };
ツールボックス
メニュー
最新の20件
最新の20件
2022-12-31
2022-09-24
2022-01-26
2019-09-17
2019-07-11
2018-07-12
2018-05-09
2018-02-07
2017-10-27
2017-10-15
2017-05-01
2017-03-27
2015-12-24