Detect array declaration, e.g. DIM test (5) = 1,2,3,4,5 ---
If you allocate to a location, the compiler will not overwrite. So, should be safe. DMA setup. See the demos, The have the basics.
DMA is the most efficient. Zero code to execute, just the setup. What you describe is the purpose of DMA on these microcontrollers.
I had to understand what you are trying to achieve... then, the answer comes out.
I would use DMA. It will move an Alloc chunk to wherever you want. Fast and robust.
You dont use PEEK, just use the array element handler. I do understand what you are trying to achieve so very hard to answer as PEEKing will be the same result.
Just treat as an array/string element. Like, myAlloc(1 .. size_of_alloc-1) = value or `value = MyAlloc(1 .. size_of_alloc-1)'
You if you want to make this extremely complex... I just use the array element address handler.