-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathgamnemonic.h
More file actions
80 lines (65 loc) · 2.33 KB
/
gamnemonic.h
File metadata and controls
80 lines (65 loc) · 2.33 KB
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
74
75
76
77
78
79
80
#ifndef GAMNEMONIC_H
#define GAMNEMONIC_H
#include <QString>
#include <QVector>
#include "gaparameter.h"
#include "gaparser.h"
/* This represents both a potential instruction's definition in both
* machine and assembly language. You won't find the parameters in this
* header, but rather in the GAParameterGroup definition.
*
* If we do our job right, we can translate in both directions.
*
*
* For most languages, the length is the accurate length of the
* whole instruction. 8086 and friends are bonkers, so for those,
* see the instructions to understand how the MODRM byte region
* expands.
*/
class GAInstruction;
class GAParameter;
class GALanguage;
class GAMnemonic : public GAParameterGroup
{
public:
//Simple constructor.
GAMnemonic(QString mnemonic, uint32_t length,
const char *opcode,
//Optional arguments default to null.
const char *opcodemask=0,
const char *invertmask=0);
//Even simpler, just a mnemonic for a byte.
GAMnemonic(QString mnemonic, const char *opcode);
//Prioritize this over other mnemonics in disassembly.
GAMnemonic* prioritize(int priority=1);
int priority=0;
//Short help string for the cheat sheet.
GAMnemonic* help(QString help);
//Short example string for self testing.
GAMnemonic* example(QString example);
//Mask of bits for which you don't care.
void dontcare(const char *mask=0);
//Does the Mnemonic match bytes? If so, decode it.
virtual int match(GAInstruction &ins, uint64_t adr, uint32_t &len,
const char *bytes);
//Does the Mnemonic match parameters? If so, encode it.
virtual int match(GAInstruction &ins, uint64_t adr, QString verb,
QList<GAParserOperand> ops);
//Unique name.
QString name="undefined";
//Cheat sheet string.
QString helpstr="";
//Example instruction. Will be used for self testing.
QString examplestr="";
//Pointer to the language.
GALanguage *lang=0;
//These used to be private.
uint32_t length=0;
char opcode[GAMAXLEN]; //Opcode bytes.
char dcmask[GAMAXLEN]; //Don't-care mask.
private:
void config(QString mnemonic, uint32_t length,
const char *opcode,
const char *opcodemask, const char *invertmask);
};
#endif // GAMNEMONIC_H