-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDataMemory.java
41 lines (30 loc) · 878 Bytes
/
DataMemory.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
package Components;
public class DataMemory {
private int[] dataMemory;
public DataMemory() {
dataMemory = new int[8];
}
// Data Memory Operations
public int readData(int address) {
return dataMemory[address];
}
public void writeData(int address, int value) {
dataMemory[address] = value;
}
public int[] readDataWord(int address) {
int[] word = new int[2];
word[0] = dataMemory[address];
word[1] = dataMemory[address + 1];
return word;
}
public void writeDataWord(int address, byte[] word) {
dataMemory[address] = word[0];
dataMemory[address + 1] = word[1];
}
public int[] dumpDataMemory() {
return dataMemory;
}
public int getDataMemorySize() {
return dataMemory.length;
}
}