Difference between revisions of "Stack"

From CDOT Wiki
Jump to: navigation, search
Line 1: Line 1:
 
[[Category:Computer Architecture]]
 
[[Category:Computer Architecture]]
A ''stack'' is an array where values are added (pushed) or removed (pulled) to/from the end of the array only. Most CPU designs incorporate one or more hardware-managed stacks which are used to store and restore state information during subroutine calls, exceptions, and interrupts.
+
A ''stack'' is an area of memory where values are added (pushed) or removed (pulled) to/from the end of the array only. Most CPU designs incorporate one or more hardware-managed stacks which are used to store and restore state information during subroutine calls, exceptions, and interrupts.
  
Hardware stacks are implemented through the use of a [[Register#Stack Pointer|stack pointer]] register, which is used for indirect read/writes, with the stack pointer automatically incremented or decremented on each access. On some architectures, the stack grows downward in memory; in others, it grows upward.
+
On some architectures, the stack grows downward in memory; in others, it grows upward. Hardware stacks are implemented through the use of a [[Register#Stack Pointer|stack pointer]] register, which is used for indirect read/writes, with the stack pointer automatically incremented or decremented on each access.
  
 
In a few historical cases (e.g., old Intel 4004 and 8008 processors) the stack was implemented in registers internal to the CPU rather than in general address space.
 
In a few historical cases (e.g., old Intel 4004 and 8008 processors) the stack was implemented in registers internal to the CPU rather than in general address space.

Revision as of 23:55, 20 February 2018

A stack is an area of memory where values are added (pushed) or removed (pulled) to/from the end of the array only. Most CPU designs incorporate one or more hardware-managed stacks which are used to store and restore state information during subroutine calls, exceptions, and interrupts.

On some architectures, the stack grows downward in memory; in others, it grows upward. Hardware stacks are implemented through the use of a stack pointer register, which is used for indirect read/writes, with the stack pointer automatically incremented or decremented on each access.

In a few historical cases (e.g., old Intel 4004 and 8008 processors) the stack was implemented in registers internal to the CPU rather than in general address space.