Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!mit-eddie!snorkelwacker!apple!mips!fred From: fred@mips.COM (Fred Chow) Newsgroups: comp.sys.mips Subject: Re: Can some one explain this compiler output? Message-ID: <31346@batman.mips.COM> Date: 14 Nov 89 00:56:25 GMT References: Reply-To: fred@mips.COM (Fred Chow) Distribution: comp Organization: MIPS Computer Systems, Sunnyvale, CA Lines: 27 In article ham@Neon.Stanford.EDU (Peter R. Ham) writes: >Question: Why does cc allocate 24 bytes of stack for a non-leaf procedure >with no local variables when calling another procedure that accepts no >arguments? > >Given this C code: > >extern void bar(); > >void >foo() >{ > bar(); >} For a non-leaf, 4 words are always allocated as argument build area for callees. This is done even if the callee has 0 parameter because we always pass the first four parameters in registers 4 thru 7. And "bar" can be a function with variable number of parameters (vararg). Such functions will always home registers 4 thru 7 to the incoming argument build area and then access the parameters thru a pointer. So the space for 4 parameters is always allocated. As you can see in the code, another word is allocated to store the return address in r31. Altogether 6 words are allocated because the stack pointer always points to a double word boundary. --------- Fred Chow (fred@mips.com)