Skip to content

Latest commit

 

History

History
39 lines (23 loc) · 905 Bytes

File metadata and controls

39 lines (23 loc) · 905 Bytes

Question 4

What is the hardware stack?

Answer

The first part of the answer is: what is a stack?

If we are talking about data structures in general, a stack is a data structure, a container with two operations:

  • A new element can be placed on top of the stack (push)
  • The top element can be taken away from the stack (pop)

What is the hardware stack? It is an emulation of stack in the existing memory, where every byte has its address.
There is no a separate stack memory.

The emulation is implemented with help of:

  • rsp register, the stack pointer, which points at the last element that was put into stack.
  • Machine instructions, that use rsp to identify the top of the stack. They are pushing and popping elements from the stack and changing rsp accordingly. Examples of such instructions are:
  • push
  • pop
  • call
  • ret
  • int

prev +++ next