Devices use start/end address

This commit is contained in:
Max840 committed 2013-12-23 23:31:51 -05:00
1 parent a5af522c5c
commit d1a05aeb2b
5 files changed
+20 -20

No files matched your search

@@ -38,26 +38,26 @@ public class Memory extends Device {
/* Initialize all locations to 0x00 (BRK) */
private static final int DEFAULT_FILL = 0x00;
public Memory(int address, int size, boolean readOnly)
public Memory(int startAddress, int endAddress, boolean readOnly)
throws MemoryRangeException {
super(address, size, (readOnly ? "RO Memory" : "RW Memory"));
super(startAddress, endAddress, (readOnly ? "RO Memory" : "RW Memory"));
this.readOnly = readOnly;
this.mem = new int[size];
this.mem = new int[endAddress - startAddress + 1];
this.fill(DEFAULT_FILL);
}
public Memory(int address, int size) throws MemoryRangeException {
this(address, size, false);
public Memory(int startAddress, int endAddress) throws MemoryRangeException {
this(startAddress, endAddress, false);
}
public static Memory makeROM(int address, int size, File f) throws MemoryRangeException, IOException {
Memory memory = new Memory(address, size, true);
public static Memory makeROM(int startAddress, int endAddress, File f) throws MemoryRangeException, IOException {
Memory memory = new Memory(startAddress, endAddress, true);
memory.loadFromFile(f);
return memory;
}
public static Memory makeRAM(int address, int size) throws MemoryRangeException {
Memory memory = new Memory(address, size, false);
public static Memory makeRAM(int startAddress, int endAddress) throws MemoryRangeException {
Memory memory = new Memory(startAddress, endAddress, false);
return memory;
}
@@ -109,4 +109,4 @@ public class Memory extends Device {
return "Memory: " + getMemoryRange().toString();
}
}
}