Thread: contents stored in stack

  1. #1
    Registered User
    Join Date
    Jul 2012
    Posts
    4

    contents stored in stack

    what are the contents that a stack in a compiler usually contains ?...and i am sure that it contains local variables and function address... but my question is what more it contains... i got this during my technical interview...

  2. #2
    Registered User
    Join Date
    Mar 2010
    Posts
    583
    It depends on the architecture and calling convention. In general locals that won't fit in registers will be put on the stack.
    Function parameters that won't fit in registers will go on the stack
    I think variadic function arguments really always go on the stack.
    Any other state that needs to be saved and restored..... possibly extra bits of frame information if specified by the calling standard.

    I can't think of anything else off the top of my head, but I'm not really an x86 expert. Try googling the architectures you're interested in along with 'procedure calling standard' or 'calling convention'. Those documents will describe how the stack will be used.

    This page looks like it might be helpful - Intel x86 Function-call Conventions - Assembly View

  3. #3
    Registered User
    Join Date
    Aug 2005
    Location
    Austria
    Posts
    1,990
    Function call return addresses are stored on the stack as well.

    Kurt

  4. #4
    Registered User
    Join Date
    Jul 2012
    Posts
    4
    thank u....Lec-4 C Programming-III - YouTube.....this video explains still more clearly.... hav a look buddy!!

  5. #5
    Registered User
    Join Date
    Aug 2005
    Location
    Austria
    Posts
    1,990
    Quote Originally Posted by venkatsam View Post
    ... hav a look buddy!!
    guess I know enough about stacks
    Kurt

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Are C arrays stored in the stack or the heap?
    By butteflymentor in forum C Programming
    Replies: 17
    Last Post: 03-10-2012, 11:24 PM
  2. are methods stored in the heap or the stack?
    By y99q in forum C# Programming
    Replies: 2
    Last Post: 01-30-2012, 03:02 PM
  3. How objects are stored
    By MTK in forum C++ Programming
    Replies: 42
    Last Post: 12-01-2009, 05:29 PM
  4. decimal being stored as 0
    By scoketboy in forum C Programming
    Replies: 7
    Last Post: 11-05-2005, 02:31 AM
  5. displaying stack contents
    By threahdead in forum Linux Programming
    Replies: 3
    Last Post: 05-23-2003, 11:15 AM