2015-05-03 19:09:25 +02:00
|
|
|
#pragma once
|
|
|
|
#ifndef _SCRIPTDISASSEMBLY_HPP_
|
|
|
|
#define _SCRIPTDISASSEMBLY_HPP_
|
|
|
|
#include <script/ScriptTypes.hpp>
|
|
|
|
|
|
|
|
class SCMFile;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Extracts instruction level information from a SCM file
|
|
|
|
*/
|
|
|
|
class ScriptDisassembly
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
2016-04-28 01:54:42 +02:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
/// The opcode's conditional is negated
|
|
|
|
OpcodeFlagNegatedConditional = 1
|
|
|
|
};
|
|
|
|
|
2015-05-03 19:09:25 +02:00
|
|
|
/**
|
|
|
|
* Information about a single call to a single opcode and
|
|
|
|
* it's parameters
|
|
|
|
*/
|
|
|
|
struct InstructionInfo
|
|
|
|
{
|
2016-04-28 01:54:42 +02:00
|
|
|
/// Numeric Opcode ID
|
2015-05-03 19:09:25 +02:00
|
|
|
SCMOpcode opcode;
|
2016-04-28 01:54:42 +02:00
|
|
|
/// Parameter information
|
2015-05-03 19:09:25 +02:00
|
|
|
SCMParams parameters;
|
2016-04-28 01:54:42 +02:00
|
|
|
uint8_t flags;
|
2015-05-03 19:09:25 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
ScriptDisassembly(SCMOpcodes* codes, SCMFile* scm);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Execute the disassembly routine.
|
|
|
|
*
|
|
|
|
* If there is an error during disassembly, an exeption will be
|
|
|
|
* thrown
|
|
|
|
*/
|
|
|
|
void disassemble(SCMAddress startAddress);
|
|
|
|
|
|
|
|
std::map<SCMAddress, InstructionInfo>& getInstructions() { return instructions; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
SCMOpcodes* codes;
|
|
|
|
SCMFile* scm;
|
|
|
|
|
|
|
|
std::map<SCMAddress, InstructionInfo> instructions;
|
|
|
|
};
|
|
|
|
|
2016-04-28 01:54:42 +02:00
|
|
|
#endif
|