x86-64 Assembly: Local Variables, Stack Frames & Alignment Explained
Quick but deep look at local variables on the stack in x86-64 assembly (YASM). We cover allocation with sub rsp, accessing via offsets, why the stack must be 16-byte aligned when calling libc functions like printf, and two practical ways to fix alignment crashes. Includes live segfault debugging and a full working example with a local array. Great for anyone studying systems programming, computer architecture, or just trying to figure out why their assembly program randomly crashes on a library call. Like + subscribe if you want more clear, practical assembly tutorials! 00:00 Introduction to Local Variables on the Stack 00:28 C++ Example of Function and Local Variables 01:06 Incoming Arguments in RDI vs Stack Variables 03:24 Pointers as Local Variables on Stack 04:34 Why the Stack ? Recursion and Multiple Calls 05:18 Visualizing Multiple Stack Frames 09:24 How Function Returns Adjust RSP 10:35 Stack Grows Downward in Memory 11:33 Program Setup ? Hybrid C++/Assembly 12:46 Assembly Module Overview 14:00 Function Prologue ? Register Push & Alignment 15:30 Allocating Stack Space for Local Array 17:45 Initializing Array in Loop 20:10 Printing Loop with printf 49:48 First Run ? Segfault Observed 51:00 16-Byte Stack Alignment Requirement 51:55 Fix 1 ? Extra Push/Pop in Prologue/Epilogue 53:15 Fix 2 ? Push/Pop Around Each printf Call 55:04 Testing Different Array Sizes 56:52 Debugging Alignment Behavior 58:54 Summary ? Creating Any Local Data on Stack 59:59 Closing Remarks & Subscribe Call =-=-=-=-=-=-=-=-= 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/pg1P... Daily Motion: https://www.dailymotion.com/neurallan... 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

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

x86-64 Assembly While Loops Explained Step by Step in YASM - From Concept to Working Program

YASM x86-64 Assembly Functions Tutorial - Integers, Floats, Pointers, ABI, C++ Interoperability

C++ vs Python vs Golang | How Code Reaches CPU

Understanding File Descriptors in Unix/Linux

Creator of C++: Bell Labs, Negative Overhead Abstraction, Mistakes | Bjarne Stroustrup

2026 SC INBRE Biostatistics Summer Courses Week 2, Day 2 (June 9)

Co-Creator of Haskell: Functional Programming, Thinking in Types, Useless Languages | Simon Jones

x86-64 Assembly Pointers & Dereferencing Explained - Hybrid C++/YASM Example

The Basics of Stack Frames: A Visual Guide for Programmers

Turing Award Winner: Disagreeing with Google, Postgres, Future Problems | Mike Stonebraker

ASMR Addictive Fast Tapping Collection For Deep Sleep & Anxiety Relief (No Talking) — 2.5 Hours

How to Crack any Software

Ep 081: Introduction to the Stack Pointer

Billionaire's WARNING: I'm SELLING. The Crash Is Already Here!

How to Actually Learn C (2027 Edition)

How Assembly Functions Work - The Stack Explained

One Formula That Demystifies 3D Graphics

Stackmaxxing for a recursion world record

