<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><span style="font-family: monospace; white-space: pre-wrap;" class="">> </span><font face="monospace" class=""><span style="white-space: pre-wrap;" class="">I forgot to add that this approach of course invalidates
> the stack pointer (SP) itself. So one would need to find
> a different way in fact.

One option would be this: </span></font><div class=""><font face="monospace" class=""><span style="white-space: pre-wrap;" class=""><br class=""></span></font></div><div class=""><font face="monospace" class=""><span style="white-space: pre-wrap;" class="">For leaf procedures (i.e. </span></font><font face="monospace" class=""><span style="white-space: pre-wrap;" class="">procedures </span></font><span style="white-space: pre-wrap; font-family: monospace;" class="">which do not themselves</span></div><div class=""><span style="white-space: pre-wrap; font-family: monospace;" class="">call other procedures), </span><span style="font-family: monospace; white-space: pre-wrap;" class="">the procedure NEW(a, size) can freely</span></div><div class=""><span style="font-family: monospace; white-space: pre-wrap;" class="">use the unused stack space that </span><span style="white-space: pre-wrap; font-family: monospace;" class="">comes after current stack frame</span></div><div class=""><span style="white-space: pre-wrap; font-family: monospace;" class="">- it </span><span style="font-family: monospace; white-space: pre-wrap;" class="">is not used anyway, so it does no harm to place data there.</span></div><div class=""><div class=""><span style="font-family: monospace; white-space: pre-wrap;" class=""><br class=""></span></div><div class=""><span style="font-family: monospace; white-space: pre-wrap;" class="">For non-leaf procedures (i.e. procedures that *do* call other</span></div><div class=""><span style="font-family: monospace; white-space: pre-wrap;" class="">procedures), you insert an instruction that adjusts </span><span style="font-family: monospace; white-space: pre-wrap;" class="">the SP by</span></div><div class=""><span style="font-family: monospace; white-space: pre-wrap;" class="">the total amount of the allocations so far just before the</span></div><div class=""><span style="font-family: monospace; white-space: pre-wrap;" class="">other procedure is called, and </span><span style="font-family: monospace; white-space: pre-wrap;" class="">readjust it when it returns.</span></div><div class=""><span style="font-family: monospace; white-space: pre-wrap;" class=""><br class=""></span></div><div class=""><font face="monospace" class=""><span style="white-space: pre-wrap;" class="">But as I said, I haven’t thought more deeply about this..</span></font></div></div><div class=""><font face="monospace" class=""><span style="white-space: pre-wrap;" class=""><br class=""></span></font></div><div class=""><font face="monospace" class=""><span style="white-space: pre-wrap;" class=""><br class=""></span></font></div><div class=""><font face="monospace" class=""><span style="white-space: pre-wrap;" class=""><br class=""></span></font></div><div class=""><font face="monospace" class=""><span style="white-space: pre-wrap;" class=""><br class=""></span></font></div></body></html>