Xref: utzoo comp.unix.questions:30068 comp.unix.internals:2482 comp.unix.programmer:1489 comp.lang.c:37925 Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!cs.utexas.edu!chinacat!sequoia!rpp386!jfh From: jfh@rpp386.cactus.org (John F Haugh II) Newsgroups: comp.unix.questions,comp.unix.internals,comp.unix.programmer,comp.lang.c Subject: Re: Unix Stack Frame Questions Message-ID: <19157@rpp386.cactus.org> Date: 4 Apr 91 05:53:15 GMT References: <125@epic.epic.com> <3465@unisoft.UUCP> Reply-To: jfh@rpp386.cactus.org (John F Haugh II) Distribution: na Organization: Lone Star Cafe and BBS Service Lines: 50 X-Clever-Slogan: Recycle or Die. In article <3465@unisoft.UUCP> greywolf@unisoft.UUCP (The Grey Wolf) writes: >/* by goehring@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@rpp386.cactus.org "If liberals interpreted the 2nd Amendment the same way they interpret the rest of the Constitution, gun ownership would be mandatory."