MIPS Frame and Stack Pointers
MIPS ISA I and II, running in 32-bit mode, mandates that the stack pointer and frame pointer addresses align on 4-byte boundaries. MIPS ISA III and up, running in 64-bit mode, mandates that the stack pointer and frame pointer addresses align on 8-byte boundaries.
If a routine has alloca locals or dynamically allocates stack frame space for any other reason, a separate frame pointer register is required to access the incoming arguments and locals. A leaf routine may use any free integer register as the frame pointer. A non-leaf routine must use a permanent register. The routine must not modify the frame pointer register between the prolog and epilog.
In a routine that uses alloca(), everything in the frame below — that is, at a lower address than — the alloca() area is referenced relative to sp and never contains a defined value at the time of an alloca() call. Thus, the alloca() operation never has to copy this part of the stack frame, and no data relocation problems arise. Everything in the frame above — at an address higher than — the alloca() area is referenced relative to the frame pointer.
If a routine establishes no frame pointer, sp must remain unchanged between the end of prolog and the beginning of the epilog.
See Also
MIPS Stack Frame and Argument Registers | MIPS I, II Argument Registers | MIPS IV Argument Registers | MIPS Leaf Routines
Last updated on Thursday, April 08, 2004
© 1992-2003 Microsoft Corporation. All rights reserved.