• Home
  • Tutorials
  • Interviews
  • Info Seed
  • Forums
  • Projects
  • Links
  • Contact Us
C Language
C POINTERS
MEMORY MANAGEMENT
INTRODUCTION
FIXED MEMORY
STACK MEMORY
HEAP MEMORY
Illustration with simple program
Functions to manage HEAP MEMORY
MEMORY ALLOCATION
MEMORY ALLOCATION-II
MEMORY ALLOCATION-III
MEMORY ALLOCATION-IV
Illustrations of MEMORY ALLOCATION
Illustration I
Illustration-I Contd..
Illustration-I Contd..
Illustration-I Contd..
Illustration II
Illustration-II Contd..
Illustration-II Contd..
Illustration III
Illustration IV
FRAME POINTER

 

 

FRAME POINTER:

Q- How are variables accessed within a frame in the stack?

Ans: Well as there is a pointer known as stack pointer to manage different operations on stack, the same way there is a frame pointer to access different variables with a frame. The stack pointer points to the top of the stack while the frame pointer points to the starting of the topmost frame as shown:

www.exploreroots.com

Now when the new function is called, the new frame is added in the stack and the frame pointer of the previous frame is saved in this new frame and the frame pointer now contains the starting address of the new frame as shown:

NOTE: We have represented this frame pointer as part of OTHER REGISTERS.

www.exploreroots.com

Similarly if now we have a new function call, then new frame is added in stack and frame pointer of frame ‘abc’ is stored in this new frame and the frame pointer now contains the address of this new function.

How ever when the function returns, the frame address stored in the frame is re-loaded in the Frame Pointer.

Hence Frame Pointer always contains the starting address of the active frame and active frame always contains the frame address of the lower frame.

 

  

previous next
| Copyright © 2009 exploreroots- All Rights Reserved | Disclaimer |