-->

Header Ads

Stack Organization

To organize data we need some data structure like array stack link list etc. Program have different type of data , it can be stored in computer memory or cpu registers. data type who support different type of data and as well as easy manipulation.Stack fulfill these requirement.   So we need  stack.

What is Stack:

1.      A stack is a list of data elements, usually words or bytes, with the accessing restriction that the element can be added or removed at one end of the list only. This end is  called the top of the stack and the other end is called the bottom of the stack.

2.      Stack work on LIFO concept.

3.      Placing new data element called PUSH

4.      Removing the top data element called POP.

How computer uses stack?

1.      Stack can be part of register unit or memory unit with a register that holds the address for the stack.

2.      Part of register array or memory used for stack is called stack area.

3.      Register which used to hold the address of stack is called stack pointer.

4.      The value in the stack pointer always points at the top data element in the stack.

Register stack::

1.      Four element store in stack.

2.      The data element 50 is top of stack, therefore the content Of SP is now 4.

3.      The stack pointer is a 5 bit register, because 2^5=32.

4.      Initialy it is clear to 0 and stack is said to be empty.

5.      When data element is pushed on the stack,SP incremented.

 
register stack

Memory stack ::

1.      Operation of memory stack is exactly similar to register stack. However it is implemented using computer memory instead of CPU register array.

2.      Memory stack has an advantage of large size but the operation on it is slower than that of register stack.

3.      This is because register stack is internal to the CPU and does not need any memory access.

memory stack


Sharing of computer memory by program, data and stack area

No comments

Powered by Blogger.