X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;f=net.mograsim.machine%2Fsrc%2Fnet%2Fmograsim%2Fmachine%2FMemory.java;h=77c0d48bb44c048207aadc5ba4c8edd0566432ba;hb=7b8035a065c7b64f38850907d519f9a7dfb67e24;hp=e421e470588da7c167cbf655e90786ac084e9b6b;hpb=4c9a2240352c246c76a056687a2d68208137b667;p=Mograsim.git diff --git a/net.mograsim.machine/src/net/mograsim/machine/Memory.java b/net.mograsim.machine/src/net/mograsim/machine/Memory.java index e421e470..77c0d48b 100644 --- a/net.mograsim.machine/src/net/mograsim/machine/Memory.java +++ b/net.mograsim.machine/src/net/mograsim/machine/Memory.java @@ -16,7 +16,11 @@ public interface Memory */ public void setCell(long address, T data); - public long size(); + public default long size() + { + MemoryDefinition def = getDefinition(); + return Long.max(0, def.getMaximalAddress() - def.getMinimalAddress() + 1); + } /** * Registers an observer to be notified when a memory cell is modified @@ -26,4 +30,6 @@ public interface Memory public void deregisterObserver(MemoryObserver ob); public void notifyObservers(long address); + + public MemoryDefinition getDefinition(); }