X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;f=net.mograsim.machine%2Fsrc%2Fnet%2Fmograsim%2Fmachine%2FMemory.java;h=0ff9bb41fdcd80ab036ef26de56ba5d4e701623c;hb=4ba119cab03498736851e6f3f32eec1957839a2e;hp=58798c396fa1d519fed96591d849c0826175df59;hpb=976f7f2be00457b5cda2489545635ccd076c9afd;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 58798c39..0ff9bb41 100644 --- a/net.mograsim.machine/src/net/mograsim/machine/Memory.java +++ b/net.mograsim.machine/src/net/mograsim/machine/Memory.java @@ -9,27 +9,28 @@ public interface Memory * @throws IndexOutOfBoundsException */ public T getCell(long address); - + /** * Sets the data at the supplied address + * * @throws IndexOutOfBoundsException */ public void setCell(long address, T data); - + public default long size() { MemoryDefinition def = getDefinition(); - return Long.max(0, def.getMaximalAddress() - def.getMinimalAddress()); + return Long.max(0, def.getMaximalAddress() - def.getMinimalAddress() + 1); } - + /** * Registers an observer to be notified when a memory cell is modified */ public void registerObserver(MemoryObserver ob); - + public void deregisterObserver(MemoryObserver ob); - + public void notifyObservers(long address); - + public MemoryDefinition getDefinition(); }