-
Notifications
You must be signed in to change notification settings - Fork 0
/
MIPS.h
90 lines (79 loc) · 2.52 KB
/
MIPS.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#ifndef __mips_h__
#define __mips_h__
#include "ast.h"
#include "symbol_table.h"
#include "stack.h"
struct _MipsInstr {
enum {
E_R,
E_T,
E_I,
E_J,
E_FR,
E_FI,
E_BEQZ,
E_M,
E_SYSCALL
} kind;
char Op[12];
union {
char addrs[5][50];
struct {
char addrs[5][50];
int val;
} IntInstr;
int label;
struct {
char addrs[5][50];
float val;
} FloatInstr;
} vars;
};
struct _MipsInstr_list {
struct _MipsInstr* instruction;
struct _MipsInstr_list* next;
};
typedef struct _MipsInstr MipsInstr;
typedef struct _MipsInstr_list MipsInstr_list;
MipsInstr* headMipsList(MipsInstr_list* l);
MipsInstr_list* tailMipsList(MipsInstr_list* l);
MipsInstr_list* mkMipsList(MipsInstr* code, MipsInstr_list* l);
MipsInstr_list* appendMipsList(MipsInstr_list* l1, MipsInstr_list* l2);
MipsInstr* mkMipsInstrE_M(char op[6], char *r1);
MipsInstr* mkMipsInstrE_R(char op[6], char r1[3], char r2[3], char r3[3]);
MipsInstr* mkMipsInstrE_I(char op[6], char r1[3], char r2[3], int val);
MipsInstr* mkMipsInstrE_J(char op[6], int label);
MipsInstr* mkMipsInstrE_FR(char op[6], char r1[3], char r2[3], char r3[3]);
MipsInstr* mkMipsInstrE_FI(char op[6], char r1[3], char r2[3], float val);
MipsInstr* mkMipsInstrE_BEQZ(char op[6], char r1[3], char r2[3]);
MipsInstr* mkMipsInstrE_SYSCALL();
MipsInstr* compileAlocateStack(int space);
MipsInstr_list* compileLDCInt(int vali);
MipsInstr_list* compileLDCFloat(float valf);
MipsInstr_list* compileADI();
MipsInstr_list* compileSBI();
MipsInstr_list* compileMPI();
MipsInstr_list* compileDVI();
MipsInstr_list* compileMOD();
MipsInstr_list* compileEQUc();
MipsInstr_list* compileNEQc();
MipsInstr_list* compileLESc();
MipsInstr_list* compileLEQc();
MipsInstr_list* compileGETc();
MipsInstr_list* compileGEQc();
MipsInstr_list* compileBEQZ(int label);
MipsInstr_list* compileIOR();
MipsInstr_list* compileAND();
MipsInstr_list* compileLOD(char *name);
MipsInstr_list* compileSTO();
MipsInstr_list* compileUJP(int label);
MipsInstr_list* compileLABEL(int label);
MipsInstr_list* compileLDA(char *name);
MipsInstr_list* compileWRI(char *name); //ESTE TAMBEM
MipsInstr_list* compileSCANF(char *name);
MipsInstr_list* compilePCode(Instr* instr);
MipsInstr_list* compileInstrList(Instr_List* instrList);
void printMipsInstr(MipsInstr* instr, FILE* file);
void printMipsInstrList(MipsInstr_list* list, FILE* file);
void printfData(FILE* file);
#endif