Quote Originally Posted by Art View Post
I didn’t know you could mem allocate in PBP at run time at all.
How do you do that?
Oh, no... I'm not trying to allocate at runtime from PBP.
I'm using a lot of assembly (big part) but still using some part in PBP for easier/quicker implementation of not (time) critical stuff.

I allocate all "shared" (between PBP and assembly) variables in PBP as there is no way to tell PBP to "skip" some asm allocated RAM.
On the other hand... the assembly code have no idea of the "first free" RAM location available to be able to safely allocate anything.

Yes, "sort of" option is to allocate RAM from a given "high enough" RAM base address and hope to not overwrite anything from PBP (but this is not good as you may easily break that by later changing the PBP code with some more allocations... or, on the other hand, leave some (big) part of RAM unused...

As I mentioned, I need to allocate few variable sized arrays (buffers) which cannot be done at compile-time as the required sizes are not known. The buffers get allocated when the PIC receives some commands via USART containg the requested buffer sizes.

Assembly routines take care of all this "dynamic allocations" and "moving addresses" (as you cannot change the start address of a variable in PBP once allocated, so I cannot just allocate something in PBP and later change the allocations). But this buffers are used by PBP code too (via usercommand "xx").

All the mentioned options of "searching" for free RAM or just "blindly" using it are not possible as there are no way to know for sure where free ram is.