summaryrefslogtreecommitdiff
path: root/includes/mipsdump.h
blob: a6c62885e93ccaca19a1a7af3d5ae2060fb55844 (plain)
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#ifndef __MIPSDUMP_H__
#define __MIPSDUMP_H__

#include <Exceptions.h>
#include <mipsdis.h>

enum arg_type {
    T_GPREGISTER,
    T_CPREGISTER,
    T_IMM8,
    T_IMM16,
    T_IMM32,
    T_OFB,
};

union arg {
    Uint32 v;
    struct {
	Uint32 o;
	int r;
	int w;
    } OfB;
};

template<class T1, class T2>
struct mypair {
    T1 left;
    T2 right;
};

typedef mypair<int, arg> pairarg;

class TDump : public TDis {
  public:
      TDump(mipsmem *);
    virtual void add_branch(Uint32);
    virtual void add_jump(Uint32);
    virtual void add_function(Uint32);
    virtual void SetTag(Uint32, int, bool);
    virtual void Name(const String &);
    virtual void PushGPReg(int);
    virtual void PushCPReg(int);
    virtual void PushImm(Uint32);
    virtual void PushTarget(Uint32);
    virtual void PushSa(Uint32);
    virtual void PushOfB(int reg, Uint32, int);
    virtual void PushOffset(Uint32);
    virtual void PushFull(Uint32);
    virtual void Invalid();
    virtual void Suspect();
    virtual void Comment(const String &);
    
    virtual void reset();
    
    String name;
    std::vector<pairarg> args;
    String comments;
    
    Uint32 tg;
    
    bool invalid, hasbr, hastg, hasfc;
};

class Dumper : public Base {
  public:
      Dumper(mipsmem *);
    void process();
  private:
    TDump * dump;
    mipsmem * mm;
};

#endif