-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgencode.h
More file actions
36 lines (30 loc) · 677 Bytes
/
gencode.h
File metadata and controls
36 lines (30 loc) · 677 Bytes
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
#ifndef CODEGEN_H
#define CODEGEN_H 1
using namespace std;
#define MAX_LOOP 20
typedef enum codes {
literl, load, store, call, ret, incmnt, jmp, jpc,
neg, add, sub, mul, divide,
equals, ls, gr, neq, lseq, greq,
wrt, wrtln, wrtsp,
nop, e_nd, dummy
} OpCode;
class Instruction {
public:
OpCode opCode;
int param1;
int param2;
Instruction(OpCode opcode = nop, int p1 = 0, int p2 = 0) {
opCode = opcode;
param1 = p1;
param2 = p2;
}
};
int genObjCode(OpCode op, int v);
int genObjCode(OpCode op);
int genRetCode();
void backPatch(int indx);
int getNextCodeAddrs();
void listCode();
int outputObjectCode();
#endif