Monday, February 11, 2013

Stack animation

A stack can be defined as a data structure in which the data that enters first gets out last,i.e. first in last out(FILO) or the the data that enters last gets out first, i.e. last in first out.(LIFO)

A stack is used in microprocessors generally to hold the return memory addresses while function calls. For example, if funcA calls funcB at the 10th line of its execution, and funcB calls funcC at its 20th line of execution,then after executing funcC, control should come back to the 21st line of funcB and after executng funcB control should come back to 11th line of funcA.

In the above case we can see that the first function call was made buy funcA, but its return address is being accessed at the last, which is a clear case of first in last out which indicates towards a stack.

The following is an animation of stack. The operation of putting data into a stack is called as the PUSH and the operation of removing hte data from the stack is called as the pop operation.

No comments:

Post a Comment

Follow by Email