pushing value in stack
popping value off stack

. . . . . . . . . .

heap grows ->

<- stack grows

Bottom of stack

---

High memory address

[0xFFFFFFFF]

Instructions

Low memory address

[ 0x000000000]

Bottom of Heap

Low memory address

[ 0x000000000]

Instructions

Bottom of Heap

heap grows ->

. . . . . . . . . .

<- stack grows

Heap

Bottom of stack

---

High memory address

[0xFFFFFFFF]

push 3;
push 4;

STACK

3

4

STACK

Heap

Low memory address

[ 0x000000000]

Instructions

Bottom of Heap

heap grows ->

. . . . . . . . . .

<- stack grows

STACK

3

Heap

Bottom of stack

---

High memory address

[0xFFFFFFFF]

pop;

Stack applies a certain method when importing or extracting data from its data structure. This method is called Last In First Out (LIFO). In this method, the data that enters the data structure last is removed from the stack in the first place.