mirror of
https://github.com/simon987/Much-Assembly-Required.git
synced 2025-04-20 11:06:46 +00:00
Included an image to help understand the stack.
parent
6b637452f3
commit
913202c816
@ -441,6 +441,6 @@ To understand this example, we must first understand what is the **stack**. The
|
|||||||
We use the term *push* when we add a piece of data on top of the stack and *pop* when we remove a piece of data from the stack.
|
We use the term *push* when we add a piece of data on top of the stack and *pop* when we remove a piece of data from the stack.
|
||||||
|
|
||||||
Visual representation of the stack:
|
Visual representation of the stack:
|
||||||

|

|
||||||
|
|
||||||
We can notice that this implementation of the stack is actually upside-down compared to a real-world stack of items: the stack grows downwards in memory, towards lower addresses. The important thing to remember is that the bottom of the stack is at a fixed address and that the top of the stack changes when an item is *pushed* on the stack or *popped* out. In the game's CPU, the **stack pointer** (SP) register always points to the top of the stack and the **base pointer** always points to the base of the current **stack frame**.
|
We can notice that this implementation of the stack is actually upside-down compared to a real-world stack of items: the stack grows downwards in memory, towards lower addresses. The important thing to remember is that the bottom of the stack is at a fixed address and that the top of the stack changes when an item is *pushed* on the stack or *popped* out. In the game's CPU, the **stack pointer** (SP) register always points to the top of the stack and the **base pointer** always points to the base of the current **stack frame**.
|
Loading…
x
Reference in New Issue
Block a user