Jump to content
  • Advertisement
Sign in to follow this  
mag

the stack

This topic is 4949 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

could some on explain how the stack work's in function calls? a little confused about how it works.

Share this post


Link to post
Share on other sites
Advertisement
Playing with the stack has some good information about functions and the stack (specifically the section How the stack is used?), assuming you know the basic functionality of a stack.

Share this post


Link to post
Share on other sites
What I am understanding with how the stack work's, is when your program is running,it executes line by line,when it run's into a function call, it break's off to the address where the function is stored,and put's it on the stack, and when the function is ready to return, every thing that was on the stack that was for that function is thrown away or off the stack,it then return's back to main, to continue on the next line where it left off.Does it go somthing like that?

Share this post


Link to post
Share on other sites
Quote:
Original post by mag
Does it go somthing like that?


Yes, except that what is put on the stack isn't the function itself, only its data (parameters, local variables, return address, old stack pointer). There is no need to actually copy the function's code.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!