On 6/27/2012 8:50 AM, Ben Bacarisse wrote:
> jacob navia <> writes:
> <snip>
>> lcc-win was ported to a 16 bit Analog Devices chip with something like
>> 40K RAM available.
>>
>> There was no stack, and the stack was created by the compiler using
>> a memory array: this implied a static analaysis.
>>
>> Recursion was forbidden (coudln't be analyzed well) and indirect
>> recursion was detected: function A calls B that calls C that calls A.
>
> If recursion is forbidden, would it not be worthwhile having a single
> static area for each function? This is what some IBM compilers used to
> do (and they may still do for all I know).
A shared stack would use less memory, unless there was some
execution path in which all functions were active simultaneously.
Per-function (or per-block) static storage might be attractive
on machines where stack-relative addressing is cumbersome. I recall
that Turbo Pascal on the Z80 used this technique. It allowed
recursive functions and procedures, though: You told the compiler
which could be called recursively, it generated prologue and
epilogue code to swap the static data out to a stack and back, and
each invocation re-used the same static area. This wouldn't work
for C, of course, since you wouldn't want an auto variable to be
moved after you'd formed a pointer to it ...
--
Eric Sosman
d