In: Computer Science
The different pointers in stack-based implementation are given below :
1. Stack Origin :
This pointer is used to hold the memory address of the stack i.e first memory byte of the stack.
The stack origin is a fixed sie pointer whose size is defined on the basis of the type of bit machine.
The stack origin is used during memory allocation. All data is stored in a stack with their address relation to stack origin.
2.Stack Pointer :
This is another pointer used in the stack-based implementation.
This pointer is used to hold the memory address of the location which contains the top element of the stack.
This pointer is decremented every time when an element is pushed into the run-time stack and decrement when the element is popped from the stack.
Both the pointer is shown below using a diagram :
| STACK ORIGIN(100) |
| (99) |
| (98) |
| (97) |
| (96) |
| .. |
| (10) |
| STACK TOP(9) |
| (8) |
| .. |
| (1) |
| (0) |