-
Notifications
You must be signed in to change notification settings - Fork 3
/
mipsCode.h
58 lines (51 loc) · 1.11 KB
/
mipsCode.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
#pragma once
#include <string>
using namespace std;
enum mipsOperation {
add,
addi,
sub,
mult,
mul,
divop,
mflo,
mfhi,
sll,
beq,
bne,
bgt, //扩展指令 相当于一条ALU类指令+一条branch指令
bge, //扩展指令 相当于一条ALU类指令+一条branch指令
blt, //扩展指令 相当于一条ALU类指令+一条branch指令
ble, //扩展指令 相当于一条ALU类指令+一条branch指令
blez, //一条branch
bgtz, //一条branch
bgez, //一条branch
bltz, //一条branch
j,
jal,
jr,
lw,
sw,
syscall,
li,
la,
moveop,
dataSeg, //.data
textSeg, //.text
asciizSeg, //.asciiz
globlSeg, //.globl
label, //产生标号
};
class mipsCode {
public:
mipsOperation op; // 操作
string z; // 结果
string x; // 左操作数
string y; // 右操作数
int imme; // 立即数
mipsCode(mipsOperation o, string zz, string xx, string yy, int i = 0) : op(o), z(zz), x(xx), y(yy), imme(i) {}
};
void genMips();
void outputMipsCode();
void loadValue(string& name, string& regName, bool gene, int& va, bool& get, bool assign);
void storeValue(string &name, string ®Name);