PM Florian Klämpfl wrote 15 lines
Am 23.03.2019 um 11:52 schrieb Dimitrios Chr. Ioannidis via fpc-devel:
> Hi,
>
> I'm using the heapmgr unit and, for the atmega328p, AFAIU the default
heap size is 80 bytes. Cause it's too small for
> my needs, I changed to 512 bytes ( -Ch512 ). But now I'm worrying for
the stack and heap collision.
>
> Can anybody know any resources, docs regarding FPC stack and heap
management for the AVR platform ? Any hints, tools ?
The sources ;) For the embedded targets, the stack grows downward from the
highest ram address. So set a suitable stack
size so you do not exceed total memory, test with stack checking on, then
you should be fine.
Out of interest I tried to see how stack checking worked. One of the puzzles is that function Sptr is empty, so it will return whatever values happen to be in r24-r25. Is this correct behaviour? I would have thought (based on how Sptr is implemented for other architectures) that it should return the value of the SP io register, something like this: function Sptr : pointer; assembler; nostackframe;
asm
in r24, 0x3d // SPL
in r25, 0x3e // SPH
end;
Any thoughts?