Forum
where can I find free memory for data on the spectrum 48k if - Printable Version

+- Forum (https://www.boriel.com/forum)
+-- Forum: Compilers and Computer Languages (https://www.boriel.com/forum/forumdisplay.php?fid=12)
+--- Forum: ZX Basic Compiler (https://www.boriel.com/forum/forumdisplay.php?fid=11)
+---- Forum: How-To & Tutorials (https://www.boriel.com/forum/forumdisplay.php?fid=13)
+---- Thread: where can I find free memory for data on the spectrum 48k if (/showthread.php?tid=2568)



where can I find free memory for data on the spectrum 48k if - funkheld - 11-13-2024

hello, good day.
where can I find free memory for data on the spectrum 48k if
I have made a program with zxbasic?

I want to move data with memcopy.

thanks.
best regards


RE: where can I find free memory for data on the spectrum 48k if - boriel - 11-13-2024

I'm not sure I did understand.
What are you trying to do?

You can declare DATA (READ, DATA, RESTORE are supported).
You can use alloc.bas library to allocate memory from the heap. And also configure the heap-size with compiling with --heap-size=NNNN being NNNN the size in bytes (the default is a bit more than 4Kb).
It is not recommended to shrink the HEAP below 1K.


RE: where can I find free memory for data on the spectrum 48k if - funkheld - 11-13-2024

hello, thanks for the info.

where is the address of the free storage please?

greetings


RE: where can I find free memory for data on the spectrum 48k if - boriel - 11-13-2024

I don´t understand what do you mean by "address of the free storage".
ZX Spectrum is a very limited machine, it does not have an storage drive or disk.

If what you´re trying to do is to allocate a free block of memory (in the HEAP, dynamically) and get its address, you can do that with the alloc.bas library:

Code:
#include <alloc.bas>

Dim block As Uinteger
block = malloc(1024) : REM allocates 1k of mem, address in block

POKE block + 3, 5  : REM stores byte 5 at Block + 3