| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
#pragma once |
| 35 |
|
| 36 |
#include <string> |
| 37 |
#include <string_view> |
| 38 |
|
| 39 |
#include "Common/CommonTypes.h" |
| 40 |
|
| 41 |
namespace Common |
| 42 |
{ |
| 43 |
class GekkoDisassembler final |
| 44 |
{ |
| 45 |
public: |
| 46 |
static std::string Disassemble(u32 opcode, u32 current_instruction_address, |
| 47 |
bool big_endian = true); |
| 48 |
static const char* GetGPRName(u32 index); |
| 49 |
static const char* GetFPRName(u32 index); |
| 50 |
|
| 51 |
private: |
| 52 |
GekkoDisassembler() = delete; |
| 53 |
|
| 54 |
static void ill(u32 in); |
| 55 |
static std::string imm(u32 in, int uimm, int type, bool hex); |
| 56 |
|
| 57 |
static std::string ra_rb(u32 in); |
| 58 |
static std::string rd_ra_rb(u32 in, int mask); |
| 59 |
static std::string fd_ra_rb(u32 in); |
| 60 |
|
| 61 |
static void trapi(u32 in, unsigned char dmode); |
| 62 |
static void cmpi(u32 in, int uimm); |
| 63 |
static void addi(u32 in, std::string_view ext); |
| 64 |
static size_t branch(u32 in, std::string_view bname, int aform, int bdisp); |
| 65 |
static void bc(u32 in); |
| 66 |
static void bli(u32 in); |
| 67 |
static void mcrf(u32 in, std::string_view suffix); |
| 68 |
static void crop(u32 in, std::string_view n1, std::string_view n2); |
| 69 |
static void nooper(u32 in, std::string_view name); |
| 70 |
static void rlw(u32 in, std::string_view name, int i); |
| 71 |
static void ori(u32 in, std::string_view name); |
| 72 |
static void rld(u32 in, std::string_view name, int i); |
| 73 |
static void cmp(u32 in); |
| 74 |
static void trap(u32 in, unsigned char dmode); |
| 75 |
static void dab(u32 in, std::string_view name, int mask, int smode, int chkoe, int chkrc); |
| 76 |
static void rrn(u32 in, std::string_view name, int smode, int chkoe, int chkrc); |
| 77 |
static void mtcr(u32 in); |
| 78 |
static void msr(u32 in, int smode); |
| 79 |
static void mspr(u32 in, int smode); |
| 80 |
static void mtb(u32 in); |
| 81 |
static void sradi(u32 in); |
| 82 |
static void ldst(u32 in, std::string_view name, char reg); |
| 83 |
static void fdabc(u32 in, std::string_view name, int mask); |
| 84 |
static void fmr(u32 in); |
| 85 |
static void fdab(u32 in, std::string_view name); |
| 86 |
static void fcmp(u32 in, char c); |
| 87 |
static void mtfsb(u32 in, int n); |
| 88 |
static void ps(u32 inst); |
| 89 |
static void ps_mem(u32 inst); |
| 90 |
|
| 91 |
static u32* DoDisassembly(bool big_endian); |
| 92 |
|
| 93 |
enum Flags |
| 94 |
{ |
| 95 |
PPCF_ILLEGAL = (1 << 0), |
| 96 |
PPCF_UNSIGNED = (1 << 1), |
| 97 |
PPCF_SUPER = (1 << 2), |
| 98 |
PPCF_64 = (1 << 3), |
| 99 |
}; |
| 100 |
|
| 101 |
static u32* m_instr; |
| 102 |
static u32* m_iaddr; |
| 103 |
static std::string m_opcode; |
| 104 |
static std::string m_operands; |
| 105 |
}; |
| 106 |
} |