diff --git a/src/main/java/com/loomcom/symon/devices/Device.java b/src/main/java/com/loomcom/symon/devices/Device.java index 7ded396..86089b4 100644 --- a/src/main/java/com/loomcom/symon/devices/Device.java +++ b/src/main/java/com/loomcom/symon/devices/Device.java @@ -35,6 +35,9 @@ public abstract class Device implements Comparable { /** The memory range for this device. */ private MemoryRange memoryRange; + /** Size of the device in memory **/ + int size; + /** The name of the device. */ private String name; @@ -44,6 +47,7 @@ public abstract class Device implements Comparable { public Device(int startAddress, int endAddress, String name) throws MemoryRangeException { this.memoryRange = new MemoryRange(startAddress, endAddress); + this.size = endAddress - startAddress + 1; this.name = name; } @@ -80,6 +84,10 @@ public abstract class Device implements Comparable { return name; } + public int getSize(){ + return size; + } + public void setName(String name) { this.name = name; } diff --git a/src/main/java/com/loomcom/symon/devices/Memory.java b/src/main/java/com/loomcom/symon/devices/Memory.java index f62b558..c7c971a 100644 --- a/src/main/java/com/loomcom/symon/devices/Memory.java +++ b/src/main/java/com/loomcom/symon/devices/Memory.java @@ -42,7 +42,7 @@ public class Memory extends Device { throws MemoryRangeException { super(startAddress, endAddress, (readOnly ? "RO Memory" : "RW Memory")); this.readOnly = readOnly; - this.mem = new int[endAddress - startAddress + 1]; + this.mem = new int[this.size]; this.fill(DEFAULT_FILL); }