ReePrime
The Call Stack Explained: Call Frames, Return Addresses, Local Variables

Hosted by Dailymotion. For legal issues report at the Copyright Center, report us on DMC, or use the Instant Removal tool.

The Call Stack Explained: Call Frames, Return Addresses, Local Variables

N
Neural Lantern

16 Views • Mar 07, 2026

Description

Ever wonder how your program remembers where to return after calling a function? That's the call stack's job.

In this clear, whiteboard-style explanation we cover:
- What the call stack actually is
- How call frames are built and what they contain
- Return addresses, function arguments, local variables
- Why recursion works (until you overflow the stack)
- Stack vs heap memory differences
- Why too much recursion = crash

Great for beginners to intermediate programmers who want to understand what's happening under the hood. References Ed Jorgensen's excellent (and free) x86-64 assembly book.

00:00 Introduction to the Call Stack
00:16 Prerequisites - Understanding Basic Stacks
00:41 Simple Example Program with Function Calls
01:24 Function Call Chain and Recursion Example
02:20 Visualizing the Call Sequence
03:06 Local Variables and Return Values
03:55 Quick Recap - How Generic Stacks Work
04:34 Stacks Can Hold Any Data Type
05:36 Introducing the Call Frame Concept
06:22 What Belongs Inside a Call Frame
07:00 Return Address Explained
07:44 How the CALL Instruction Works
08:32 Function Arguments on the Stack
09:57 Extra Arguments Beyond Registers
10:19 Preserving Registers (Callee-Saved)
11:12 Local Variables on the Stack
11:40 Multiple Call Frames Example
12:54 Tracing Function Calls Step by Step
13:21 Starting with Main's Call Frame
15:00 Pushing Frames for Nested Calls
16:30 Returning - Popping Frames
18:10 Why the Stack is Perfect for Returns
19:45 Recursion and Multiple Instances
21:30 Stack Grows Downward in Memory
23:10 Stack vs Heap Memory Comparison
25:12 Local Variables vs Dynamically Allocated Memory
26:16 Pointers on Stack Pointing to Heap
27:32 Automatic Cleanup of Stack Variables
28:00 Memory Leaks with Heap Allocations
28:56 Recommended Reading - Ed Jorgensen Book
29:56 Call Frame Layout in x86-64 Assembly
31:16 Process Memory Layout Overview
32:22 Stack Grows Down, Heap Grows Up
33:52 Stack Overflow from Deep Recursion
35:09 Summary - Why the Call Stack Matters
35:28 Closing Remarks and Call to Subscribe

=-=-=-=-=-=-=-=-=

Thanks for watching!

Find us on other social media here:
- https://www.NeuralLantern.com/social
- Twitter / X: https://x.com/NeuralLantern
- Rumble: https://rumble.com/c/c-3696939
- BitChute: https://www.bitchute.com/channel/pg1Pvv5dN4Gt
- Daily Motion: https://www.dailymotion.com/neurallantern
- Minds: https://www.minds.com/neurallantern/
- Odysee: https://odysee.com/@NeuralLantern:5

Please show your support!

- Buy me a coffee: https://ko-fi.com/neurallantern

- Subscribe + Sharing on Social Media
- Leave a comment or suggestion
- Subscribe to the Blog: https://www.NeuralLantern.com
- Watch the main "pinned" video of this channel for offers and extras