Unix Stack Frame Questions
John F Haugh II
jfh at rpp386.cactus.org
Thu Apr 4 15:53:15 AEST 1991
In article <3465 at unisoft.UUCP> greywolf at unisoft.UUCP (The Grey Wolf) writes:
>/* <GOEHRING.91Mar25113709 at gnu.ai.mit.edu> by goehring at gnu.ai.mit.edu
> * it is not right to assume that there is a stack frame, and some
> * compilers aren't going to put autos in the frame even if a frame
> * exists since they can be more cheaply handled with registers.
>
>If, of course, you have the registers (68K only have so many).
>If there's not a stack frame, how are parameters passed to the
>function...? And how would you return...?
BZZZT. Thank you for playing today's game, but your response is
incorrect ;-)
There are machines which have =no= registers, other that don't
even have stack pointers, some have no program counters, and so
on.
Your assumption is that every machine has a push-down stack of
some sort and a small (16 is "small") set of machine registers.
The bad news is that some RISC'y chips have 200+ registers,
some older microprocessors (and even certain popular mainframes)
ahve =0= machine registers, or perhaps a single register which
pointed to what you consider to be "registers". Still weirder
machines have registers which specify which register is the
PC, making the notion of "return" fuzzier still.
> * every cpu is going to have varying stack frame format(s), assuming the
> * cpu enforces one at all, and OS and compiler vendors are more than happy
> * to create oddball parameter passing and stack frame conventions.
>
>I didn't think that a CPU ever "enforced" a stack frame; ostensibly one
>could ignore the references to "4(fp)" in the manual and do it their own
>way.
Yes, there are CPU's which have notions about stack frame and
support the conventions in hardware. If you "ignore" the
convention, you go whirring off into space when you get around
to executing that "ret" instruction and the machine expects
the stack frame it pushed to still be of the right shape and
size.
>But a stack frame seems to be the most efficient way of dealing with
>calls and returns.
No, there are =many= better ways.
--
John F. Haugh II | Distribution to | UUCP: ...!cs.utexas.edu!rpp386!jfh
Ma Bell: (512) 832-8832 | GEnie PROHIBITED :-) | Domain: jfh at rpp386.cactus.org
"If liberals interpreted the 2nd Amendment the same way they interpret the
rest of the Constitution, gun ownership would be mandatory."
More information about the Comp.unix.internals
mailing list