4 Sept 2012

Why stack is used in a program?

The stack is used to store information temporarily during the execution of a program. Also the stack is used in subroutine calls to store the return address.
As an example, data generated at a certain point in a program may be needed later in the program. This data is stored in the stack and retrieved when needed. Because the number of general purpose registers (GPRs) in a microprocessor is limited–hence not all the temporary data can be stored in them and this is where the stack plays its part.

No comments:

Post a Comment