CBFalconer said:
Nonsense. I can fairly easily design a machine with no stack, no
call instruction, and have it execute C programs.
I suppose it depends on your definition of "stack". If you limit the
definition to a consecutively allocated region of memory which grows
or shrinks in a particular direction, whose top is denoted by a
machine register, then of course you can implement C on a machine with
no stack. (The above definition is admittedly sloppy; it's intended
to refer to what's usually called "the stack" in the context of a CPU
architecture.)
On the other hand, if you use a more abstract definition that refers
only to how the thing behaves, and not to how it's stored in memory,
then C's function call semantics do imply the existence of a stack.
The activation records (not a C term) for nested function invocations
needn't be allocated consecutively in memory. It needn't even be
meaningful to ask about the order in which they're stored, since you
can't necessarily compare their addresses. Some or all of them could
be allocated in advance and/or deallocated long after the function
terminates, if ever. But there is a last-in first-out stack-like
pattern to the way local variables begin and end their lifetimes.