-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathSynthesizer.hpp
62 lines (43 loc) · 1.31 KB
/
Synthesizer.hpp
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
#ifndef SoftWire_Synthesizer_hpp
#define SoftWire_Synthesizer_hpp
#include "Encoding.hpp"
#include "Operand.hpp"
namespace SoftWire
{
class Instruction;
class Synthesizer
{
public:
Synthesizer(bool x64);
virtual ~Synthesizer();
void reset();
void defineLabel(const char *label);
void encodeFirstOperand(const Operand &firstOperand);
void encodeSecondOperand(const Operand &secondOperand);
void encodeThirdOperand(const Operand &thirdOperand);
void encodeImmediate(int i);
void encodeLiteral(const char *string);
const Encoding &encodeInstruction(const Instruction *instruction);
private:
const bool x64;
Encoding encoding;
Operand::Type firstType;
Operand::Type secondType;
int firstReg;
int secondReg;
int baseReg;
int indexReg;
int scale;
void encodeBase(const Operand &base);
void encodeIndex(const Operand &index);
void setScale(int scale);
void setDisplacement(int displacement);
void referenceLabel(const char *label);
void encodeRexByte(const Instruction *instruction);
void encodeModField();
void encodeR_MField(const Instruction *instruction);
void encodeRegField(const Instruction *instruction);
void encodeSibByte(const Instruction *instruction);
};
}
#endif // SoftWire_Synthesizer_hpp