protected void invoke() {
        // Reads the memory address register
        int address = Integer.parseInt(registerStore.readFrom(Register.MAR));
            
        try {        
            // Finds what memory operation should be performed
            switch(Integer.parseInt(registerStore.readFrom(Register.MRW))) {
                case 0 : //read
                    String value = get(address);

                    // Informs listeners
                    for(MemoryListener listener : getMemoryListeners()) {
                        listener.memoryReadFrom(this, address, value);
                    }
                
                    // Writes the value to the Memory data register
                    registerStore.writeTo(Register.MDR, value);
                
                    break;
            
                case 1 : //write
                    String data = registerStore.readFrom(Register.MDR);
                
                    // Writes the vaue from the Memory data register to memory
                    put(address, data);
                
                    // Informs listeners
                    for(MemoryListener listener : getMemoryListeners()) {
                        listener.memoryWroteTo(this, address, data);
                    }
                
                    break;
            }
        }catch (Exception e) {
            // Inform listeners of error
            for(MemoryListener listener : getMemoryListeners()) {
                listener.memoryError(this, new Exception("Invalid memory address " + address));
            }
        }
    }