Create Device.size()
This commit is contained in:
1 parent
1c9c742477
commit
d8deca227f
2 files changed
+9
-1
No files matched your search
@@ -35,6 +35,9 @@ public abstract class Device implements Comparable<Device> {
|
|||||||
/** The memory range for this device. */
|
/** The memory range for this device. */
|
||||||
private MemoryRange memoryRange;
|
private MemoryRange memoryRange;
|
||||||
|
|
||||||
|
/** Size of the device in memory **/
|
||||||
|
int size;
|
||||||
|
|
||||||
/** The name of the device. */
|
/** The name of the device. */
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
@@ -44,6 +47,7 @@ public abstract class Device implements Comparable<Device> {
|
|||||||
public Device(int startAddress, int endAddress, String name)
|
public Device(int startAddress, int endAddress, String name)
|
||||||
throws MemoryRangeException {
|
throws MemoryRangeException {
|
||||||
this.memoryRange = new MemoryRange(startAddress, endAddress);
|
this.memoryRange = new MemoryRange(startAddress, endAddress);
|
||||||
|
this.size = endAddress - startAddress + 1;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -80,6 +84,10 @@ public abstract class Device implements Comparable<Device> {
|
|||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getSize(){
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
public void setName(String name) {
|
public void setName(String name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ public class Memory extends Device {
|
|||||||
throws MemoryRangeException {
|
throws MemoryRangeException {
|
||||||
super(startAddress, endAddress, (readOnly ? "RO Memory" : "RW Memory"));
|
super(startAddress, endAddress, (readOnly ? "RO Memory" : "RW Memory"));
|
||||||
this.readOnly = readOnly;
|
this.readOnly = readOnly;
|
||||||
this.mem = new int[endAddress - startAddress + 1];
|
this.mem = new int[this.size];
|
||||||
this.fill(DEFAULT_FILL);
|
this.fill(DEFAULT_FILL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user