Forum
ZXBASIC_USER_DATA relocation? - 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: Help & Support (https://www.boriel.com/forum/forumdisplay.php?fid=16)
+---- Thread: ZXBASIC_USER_DATA relocation? (/showthread.php?tid=787)



ZXBASIC_USER_DATA relocation? - Haplo - 02-07-2017

Hi,

in my project I use a lot of memory, indeed I use all the banks of RAM available. But my main code has grown beyond the 49151 position and now I have a serious problem by switching pages of RAM: ZXbasic stores some vitality data in the end of the generated code, like ZXBASIC_USER_DATA, so if the label overcome 49152, I can't switch pages without risky consequences Sad

My question is, it's posible to move/relocate these labels to another area more secure?
Of course I could do it manuallyby editing the .asm generated but I hope that exists an easy way to avoid this.


Re: ZXBASIC_USER_DATA relocation? - LCD - 02-08-2017

You can use Assembler to switch bank and copy memory chunks from banks to a buffer in lower memory, then switch bank back (Disable interrupts!). Something like:
Code:
ASM
DI
LD BC,32765
LD A,17
OUT (C),A
LD HL,49152
LD DE,16384
LD BC,2048
LDIR
LD BC,32765
LD A,16
OUT (C),A
EI
END ASM



Re: ZXBASIC_USER_DATA relocation? - britlion - 03-15-2017

Yes - like LCD says - write a small routine that's designed to copy data out of the upper memory banks to a low down buffer. (worst case scenario, make teh screen attributes all the same, and you can use the 6k of screen temporarily). Then change bank back and return - the new data is accessible. It's a bit like a ram load option, really.

You may have to write this separately, and call it with a smidge of assembly language, rather than make it part of your main compiled program.