mirror of
https://github.com/citra-emu/citra.git
synced 2025-07-06 17:50:09 +00:00
43 lines
1.1 KiB
C++
43 lines
1.1 KiB
C++
#include "common/common_types.h"
|
|
#include <memory>
|
|
|
|
class Instruction;
|
|
|
|
class Disassembler
|
|
{
|
|
public:
|
|
/*
|
|
* Returns the instruction at address or null if unknown or not translatable
|
|
* address is used for PC relative operations
|
|
*/
|
|
static std::unique_ptr<Instruction> Disassemble(u32 instruction, u32 address);
|
|
};
|
|
|
|
class RegisterInstructionBase
|
|
{
|
|
public:
|
|
typedef Instruction *(*CreateFunctionType)(u32 instruction, u32 address);
|
|
|
|
RegisterInstructionBase(CreateFunctionType create_function);
|
|
};
|
|
|
|
/*
|
|
* Instantiate this class in a source file to register instruction in the disassembler
|
|
*/
|
|
template<typename DerivedInstruction>
|
|
class RegisterInstruction : RegisterInstructionBase
|
|
{
|
|
public:
|
|
RegisterInstruction() : RegisterInstructionBase(&RegisterInstruction::Create) {}
|
|
private:
|
|
static Instruction *Create(u32 instruction, u32 address)
|
|
{
|
|
auto result = new DerivedInstruction();
|
|
if (!result->Read(instruction, address))
|
|
{
|
|
delete result;
|
|
return nullptr;
|
|
}
|
|
return result;
|
|
}
|
|
}; |