-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathobjectCode.h
62 lines (59 loc) · 905 Bytes
/
objectCode.h
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
#include <string>
#include "midCode.h"
#include <map>
#include <fstream>
using namespace std;
#define addrMap map < string, int>
#define STRING (string("string")+to_string(STRING_COUNT++))
extern int STRING_COUNT;
enum mipsCode {
nop,
li,
add,
addi,
sub,
sll,
mult,
divid,
mflo,
sw,
lw,
la,
beq,
bne,
bge,
bgt,
j,
jal,
jr,
lab,
syscall,
};
struct objectNode {
int mipsCode;
char rd_reg[1000];
char rs_reg[1000];
char rt_reg[1000];
int rd_num;
int rs_num;
int rt_num;
objectNode * next;
objectNode * prev;
};
class objectCode
{
public:
objectNode * head;
objectNode * now;
ofstream outfp;
objectCode();
void addNode(tetraCode midCode);
void printMips();
private:
int relative_address; //相对于当前函数指针的地址
int push_address; //压入函数参数的地址
bool begindef = false;
int end_golbal_address = 0;
objectNode * fp;
addrMap Map;
};