frame pointer



Hi,

I'm learning MIPS assembly programming. In couple of examples
I went through, the authors save the "frame pointer" with

sw $fp 8($sp) # sp is stack pointer

onto the stack.
However, after returning from a routine accessed by a jump instruction
(like JAL label, "JAL" = jump&link return address), they restore the
stored values using $fp like

lw $ra -4($fp).

What is the general purpose of a frame pointer and why is in the
aforementioned examples not the stack pointer "$sp" used for
saving and restoring context values?

Thank you.

Chris
.



Relevant Pages

  • Re: stack pointer and frame pointer
    ... code break wrote: ... A stack pointer is an index into a given stack frame. ... A frame pointer represents a boundary of a stack frame. ... This is architecture stuff, not C stuff. ...
    (comp.lang.c)
  • Re: frame pointer
    ... Christian Christmann wrote: ... What is the general purpose of a frame pointer and why is in the ... aforementioned examples not the stack pointer "$sp" used for ... point so that you have a predictable base to work with while still ...
    (alt.lang.asm)
  • Re: should program call stack grow upward or downwards?
    ... registers, such as the 88000, then growing upwards is more expensive ... than growing downwards. ... offsets relative to a frame pointer, but since the stack pointer ...
    (comp.arch)
  • trap number 12 :-(
    ... stack pointer = 0x10:0cxcdb0c918 ... frame pointer = 0x10:0cxdb0c91c ... current proces = ll (idle) ...
    (freebsd-newbies)