更多参考:http://www.embeddedrelated.com/usenet/embedded/show/31646-1.php
一:
The calling convention described in this section is the one used by gcc, not the native MIPS compiler, which uses a more complex convention that is slightly faster.
Figure 6: Layout of a stack frame. The frame pointer points just below the last argument passed on the stack. The stack pointer points to the first word after the frame.
Figure 6 shows a diagram of a stack frame. A frame consists of the memory between the frame pointer ($fp), which points to the word immediately after the last argument passed on the stack, and the stack pointer ($sp), which points to the first free word on the stack. As typical of Unix systems, the stack grows down from higher memory addresses, so the frame pointer is above stack pointer.
The following steps are necessary to effect a call:
Within the called routine, the following steps are necessary:
Finally, to return from a call, a function places the returned value into $v0 and executes the following steps:
二:
Here's how I diagram the conventional PDP-11 stack layout. | | higher addresses +---------------+ | argN | | ... | | arg0 | <- FP+4 +---------------+ | link reg | <- FP+2 = SP after JSR +===============+ | saved FP | <- FP after prologue +---------------+ / | locals | <- FP-2 framesize \ | ... | +---------------+ | saved regs | | ... | <- SP after prologue +---------------+ | | lower addresses Note that local function arguments are at positive offsets from FP, local variables are at negative offsets. Also note that the frame pointer itself is among the callee-saved registers. See here for a survey of subroutine linkage conventions: http://www.cs.clemson.edu/~mark/subroutines.html http://www.cs.clemson.edu/~mark/subroutines/pdp11.html (PDP-11 specific) and here http://cm.bell-labs.com/cm/cs/who/dmr/clcs.html (original PDP-11 C)