   // Find the null terminator
            while (memoryArray[ptr + length] !== 0) {
                length++;
                if (length > 1000000) break; // Safety limit
            }
            
            const bytes = memoryArray.slice(ptr, ptr + length);
            return new TextDecoder().decode(bytes);
        }
        
        function performSearch() {
            const query = document.getElementById('searchInput').value.trim();
            const resultsDiv = document.getElementById('results'