Xref: utzoo comp.unix.questions:30063 comp.unix.internals:2481 comp.unix.programmer:1488 comp.lang.c:37918 Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!uakari.primate.wisc.edu!dali.cs.montana.edu!ogicse!intelhf!ichips!iwarp.intel.com!inews!pinkas From: pinkas@st860.intel.com (Israel Pinkas) Newsgroups: comp.unix.questions,comp.unix.internals,comp.unix.programmer,comp.lang.c Subject: Re: Unix Stack Frame Questions Message-ID: Date: 3 Apr 91 22:08:56 GMT References: <125@epic.epic.com> <3465@unisoft.UUCP> Sender: news@inews.intel.com Distribution: na Organization: Software Technologies, INTeL Corporation, Santa Clara, CA Lines: 60 In-reply-to: greywolf@unisoft.UUCP's message of 3 Apr 91 01:23:59 GMT In article <3465@unisoft.UUCP> greywolf@unisoft.UUCP (The Grey Wolf) writes: > /* by goehring@gnu.ai.mit.edu > * In article <125@epic.epic.com> tan@epic.epic.com (Andy Tan) writes: > * > * 1. Is it right to assume that the address of the last automatic > * variable is the bottom of stack frame ? > * > * 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...? The Intel i860 passes most parameters in registers. The processor has a total of 15 integer and 15 float (32 bit) registers (actually 16, but r0 and f0 are hardwired 0). The float registers can be combined to form 64 bit doubles and 128 bit long doubles. r16-r27 are used to pass scalar parameters. f8-f15 are used to pass up to 4 double parameters (all compilers promote floats to doubles). If a struct, more than 12 scalar arguments, or more than 4 doubles are passed, a block of memory is reserved on the "stack" and r28 is set to point to this block. varargs/stdargs routines receive their parameters in this block as well. Scalar return values are returned in f16, double return values are returned in f16/f17. The i860 does not have a real stack, although one of the integer registers is used to point to a software stack. The return address for a call is kept in r1. If the callee make a call, it is responsible for saving r1 on the "stack". > * 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. > But a stack frame seems to be the most efficient way of dealing with > calls and returns. We discovered that having a frame pointer and a true stack was more expensive, CPU wise. A large percentage of CPU is spent in leaf routines, where having the parameters in registers speeds things up. -Israel Pinkas Intel Corp -- -------------------------------------- Disclaimer: The above are my personal opinions, and in no way represent the opinions of Intel Corporation. In no way should the above be taken to be a statement of Intel. UUCP: {amdcad,decwrl,hplabs,oliveb,pur-ee,qantel}!intelca!mipos3!st860!pinkas ARPA: pinkas%st860.intel.com@relay.cs.net CSNET: pinkas@st860.intel.com