answersLogoWhite

0


Best Answer

Stack pointer points to the topmost / most recently referenced location on the stack;

- Nutan

User Avatar

Wiki User

14y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

12y ago

stack pointer is used to find the address of the stack

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is the function of a stack pointer?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

How is the old stack pointer value recovered on a function return?

If your stack grows bottom-up, it's decremented when you leave a function; if the stack grows top-down, the stack pointer is incremented.


What is the function of the stack counter?

Its not a stack counter - its a stack pointer. The stack pointer is a register that points to the top of the stack. In the Intel configuration, it points to the next item to be popped off the stack. To push an item requires that the stack pointer be decremented first, and then the item is written. The inverse operation - the pop - requires read then increment.


What is the purpose of the program stack?

Its main use is to store local variables, arguments and return address each time a function is called.When your program calls a function the following happen :- The function arguments are put on the stack- The current instruction pointer is put on the stack- The program jumps to the start of the function- Space is allocated on the stack to hold local variables- The function executes- The space holding local variables is de-allocated- The instruction pointer is restored and removed from the stack (we are now leaving the function and resuming the calling procedure)- The arguments are removed from the stack


What is top pointer of stack?

top pointer of a stack is the pointer that refers to the top most element of the stack.


Can stack be as a pointer?

A stack is a data structure in which last item inserted is taken out first . That's why they are known as LIFO (last in first out). Inserting an item in stack is termed as push and taking an item out from stack I s termed as pop. Stack pointer is the pointer that points to the top of the stack or that points the item at the top of the stack and help in adding or deleting the item from the top of stack.


What function for stack pointer of the register?

A stack pointer is a register pointing to the top of a stack. It supports the fundamental stack manipulations (push and pop) in an efficient manner. Most micro processor hardware has build-in hardware support for stack pointers, typically both in form of dedicated stack pointer registers and in form of addressing modes which support the creation and maintenance of stacks through general-purpose pointer registers. In software, many programming languages feature constructs suited for implementation of stack pointers within the high-level language (such as post-increment and pre-decrement operators in C).


Situation where a stack pointer is used?

Accessing a stack.


Why stack data starts from one location less then stack pointer's register address?

Actually, stack data starts one location greater than the stack pointer. In the Intel design, the stack pointer always points to the next location to be used on a push, and pushes always decrement the pointer. It is more correct to say that the stack region to be used next is one location less than the stack pointer's register address.


How primitive variables are stored on Stack?

Call-stacks are fixed-length and are allocated on a per-thread basis as threads are instantiated. The stack pointer CPU register keeps track of the next available address in the current thread's stack. The compiler computes the length of a function according to the number and type of its local variables (including formal arguments) plus the return address. When the function is invoked, the current stack pointer is adjusted by this amount, creating a "stack frame" specific to that function. Given the start address of the stack frame, the local variables and formal arguments can be referred to via constant offsets within the stack frame. When the function returns, the stack pointer is readjusted, effectively freeing the memory without actually releasing it back to the system. In this way, memory can be allocated and released on the stack with minimum cost.


Why must the stack pointer be initialized at the beginning of every program?

Because the stack pointer marks the top of the stack. If it is not initialised, it is not possible to determine where the next stack frame will go.


How is the stack and stack pointer work?

A stack is a data structure in which last item inserted is taken out first . That's why they are known as LIFO (last in first out). Inserting an item in stack is termed as push and taking an item out from stack I s termed as pop. Stack pointer is the pointer that points to the top of the stack or that points the item at the top of the stack and help in adding or deleting the item from the top of stack.


How stack pointer registers are involved in the execution of push and pop instruction?

If the stack is empty assume the stack pointer has a value of P. when you push something on the stack you increment P. when you pull something from stack you decrement P.