On 14/05/2022 16:37, Hairy Pixels via fpc-pascal wrote:
On May 14, 2022, at 4:04 PM, Jonas Maebe via
fpc-pascal<fpc-pascal@lists.freepascal.org> wrote:
No, because most modern OSes don't allow you to address memory below the stack
pointer (and for the ones that do to a limited extent, the compiler could be
using that memory already).
I thought the stack had a fixed size of memory that’s in every frame and it’s
just a matter of if it’s occupied by any local variables or not. Seems
conceptually simple to advance the pointer as if a local variable was declared
but maybe this needs to happen at compile time making alloca more of a compiler
intrinsic.
Only the part between the current address in the stack pointer register
and the base of the stack when the program started is valid to address
(barring some minor exceptions). The stack pointer register gets
adjusted by the compiler any time the stack needs to grow or shrink,
which indeed generally mostly happens on function entry/exit.
Jonas
_______________________________________________
fpc-pascal maillist - fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal