You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
658 B
35 lines
658 B
package processor.memorysystem;
|
|
|
|
public class MainMemory {
|
|
int[] memory;
|
|
|
|
public MainMemory()
|
|
{
|
|
memory = new int[65536];
|
|
}
|
|
|
|
public int getWord(int address)
|
|
{
|
|
return memory[address];
|
|
}
|
|
|
|
public void setWord(int address, int value)
|
|
{
|
|
memory[address] = value;
|
|
}
|
|
|
|
public String getContentsAsString(int startingAddress, int endingAddress)
|
|
{
|
|
if(startingAddress == endingAddress)
|
|
return "";
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
sb.append("\nMain Memory Contents:\n\n");
|
|
for(int i = startingAddress; i <= endingAddress; i++)
|
|
{
|
|
sb.append(i + "\t\t: " + memory[i] + "\n");
|
|
}
|
|
sb.append("\n");
|
|
return sb.toString();
|
|
}
|
|
}
|
|
|