-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcomputer.h
51 lines (42 loc) · 893 Bytes
/
computer.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
#define MAXNUMINSTRS 1024 /* max # instrs in a program */
#define MAXNUMDATA 3072 /* max # data words */
struct SimulatedComputer {
int memory [MAXNUMINSTRS+MAXNUMDATA];
int registers [32];
int pc;
int printingRegisters, printingMemory, interactive, debugging;
};
typedef struct SimulatedComputer Computer;
typedef enum { R=0, I, J } InstrType;
typedef struct {
int rs;
int rt;
int rd;
int shamt;
int funct;
} RRegs;
typedef struct {
int rs;
int rt;
int addr_or_immed;
} IRegs;
typedef struct {
int target;
} JRegs;
typedef struct {
InstrType type;
int op;
union {
RRegs r;
IRegs i;
JRegs j;
} regs;
} DecodedInstr;
typedef struct {
int R_rs; /*Value in register rs*/
int R_rt;
int R_rd;
} RegVals;
void InitComputer (FILE*, int printingRegisters, int printingMemory,
int debugging, int interactive);
void Simulate ();