-
Notifications
You must be signed in to change notification settings - Fork 1
/
WriteBack.java
51 lines (45 loc) · 919 Bytes
/
WriteBack.java
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
public class WriteBack {
//registers and flags
private static int[] registers = new int[32];
private static int overflowFlag;
private static int negativeFlag;
private static int zeroFlag;
//CONSTRUCTOR
public WriteBack() {
for (int i=0; i<32; i++) {
registers[i] = 0;
}
}
//performs the writeback
public static void doWriteBack(int dest, int val) {
if (dest >= 1) {
registers[dest-1] = val;
}
}
// getters
public static int getOF(){
return overflowFlag;
}
public static int getNF(){
return negativeFlag;
}
public static int getZF(){
return zeroFlag;
}
public static int getRegister(int r) {
return registers[r-1];
}
public static int[] getRegisters() {
return registers;
}
// setters
public static void setOF(int num){
overflowFlag = num;
}
public static void setNF(int num){
negativeFlag = num;
}
public static void setZF(int num){
zeroFlag = num;
}
}