answersLogoWhite

0


Best Answer

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).

User Avatar

Wiki User

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

Wiki User

13y ago

stack pointer is also a pointer. which point the value or content in that register to accumulator to execute. and also the stack pointer used to locate the memory address in the registers to save content in the accumulator.

This answer is:
User Avatar

User Avatar

Wiki User

9y ago

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.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What function for stack pointer of the register?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

What is Usage of stack register?

The stack register points to the top of the stack for the currently executing thread. The stack is a fixed-length memory allocation at the bottom of addressable memory (highest available address). The stack extends upwards into lower addresses. To keep track of the stack's usage, the stack pointer marks the top of the stack where a new frame will be pushed, decrementing the stack pointer by the required amount. When a frame is popped, the stack pointer is incremented by the frame length. The stack is typically used to call and return from functions by storing the return address of the caller, but can also be used to store a function's arguments (the values passed to it by its caller), its local variables and its exception handlers. Since the memory is allocated as soon as the thread becomes active, moving a pointer to activate and release stack frames is much quicker than requesting heap memory via the operating system.


Which are the various 16-bit registers in Intel 8085?

The various 16-bit registers on the 8085 are BC, DE, HL, SP, PC.


What is top pointer of stack?

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


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 the SP pointing register's default memory segment?

The default segment for SP (Stack Pointer) relative memory accesses in the 8086/8088 is SS (Stack Segment).

Related questions

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 function of a stack pointer?

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


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.


Size of stack memory and stack pointer register in 8051 microprocessor?

8 bit


What is the 16 bit register in the 8051?

pc and stack pointer


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.


Which CPU register holds address for memory?

The program counter (PC) and the stack pointer (SP).


What is Difference between index register and stack pointer?

An index register contains an address that can be used during effective address generation, often along with an offset in the instruction or in another register. This is most useful when accessing elements of arrays or structures. A stack pointer is a specialized index register that points to a region of memory that can store temporary elements, in a last-in-first-out structure, such as return addresses, parameters, and local storage for function calls.


What is Usage of stack register?

The stack register points to the top of the stack for the currently executing thread. The stack is a fixed-length memory allocation at the bottom of addressable memory (highest available address). The stack extends upwards into lower addresses. To keep track of the stack's usage, the stack pointer marks the top of the stack where a new frame will be pushed, decrementing the stack pointer by the required amount. When a frame is popped, the stack pointer is incremented by the frame length. The stack is typically used to call and return from functions by storing the return address of the caller, but can also be used to store a function's arguments (the values passed to it by its caller), its local variables and its exception handlers. Since the memory is allocated as soon as the thread becomes active, moving a pointer to activate and release stack frames is much quicker than requesting heap memory via the operating system.


How does push work on registers and variables?

The PUSH instruction decrements the stack pointer by the size of the operand and then stores its operand at the memory address pointed to by the stack pointer. This leaves the stack pointer always pointing to the last element pushed onto the stack.The POP instruction reverses the sequence, retrieving the operand first, and then incrementing the stack pointer by the size of the operand.Also, PUSH and POP do not work on variables - they only work on register values. You can pop/push a variable, however, by using a register and then storing/retrieving the register to/from memory.


Which are the various 16-bit registers in Intel 8085?

The various 16-bit registers on the 8085 are BC, DE, HL, SP, PC.


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.