Surprise Me!

x86-64 Assembly: Local Variables, Stack Frames & Alignment Explained

2026-03-16 1 Dailymotion

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. <br /><br />Great for anyone studying systems programming, computer architecture, or just trying to figure out why their assembly program randomly crashes on a library call. <br /><br />Like + subscribe if you want more clear, practical assembly tutorials! <br /><br />00:00 Introduction to Local Variables on the Stack <br />00:28 C++ Example of Function and Local Variables <br />01:06 Incoming Arguments in RDI vs Stack Variables <br />03:24 Pointers as Local Variables on Stack <br />04:34 Why the Stack ? Recursion and Multiple Calls <br />05:18 Visualizing Multiple Stack Frames <br />09:24 How Function Returns Adjust RSP <br />10:35 Stack Grows Downward in Memory <br />11:33 Program Setup ? Hybrid C++/Assembly <br />12:46 Assembly Module Overview <br />14:00 Function Prologue ? Register Push & Alignment <br />15:30 Allocating Stack Space for Local Array <br />17:45 Initializing Array in Loop <br />20:10 Printing Loop with printf <br />49:48 First Run ? Segfault Observed <br />51:00 16-Byte Stack Alignment Requirement <br />51:55 Fix 1 ? Extra Push/Pop in Prologue/Epilogue <br />53:15 Fix 2 ? Push/Pop Around Each printf Call <br />55:04 Testing Different Array Sizes <br />56:52 Debugging Alignment Behavior <br />58:54 Summary ? Creating Any Local Data on Stack <br />59:59 Closing Remarks & Subscribe Call <br /><br />x86-64 assembly, x86 assembly tutorial, local variables stack, stack frame assembly, yasm tutorial, nasm tutorial, stack alignment, 16 byte alignment, printf crash assembly, assembly stack allocation, sub rsp assembly, rbp rbp stack, assembly array on stack, low level programming, systems programming, computer architecture, reverse engineering, assembly language, x64 assembly, calling convention <br /><br />=-=-=-=-=-=-=-=-= <br /><br />Thanks for watching! <br /><br />Find us on other social media here: <br />- https://www.NeuralLantern.com/social <br />- Twitter / X: https://x.com/NeuralLantern <br />- Rumble: https://rumble.com/c/c-3696939 <br />- BitChute: https://www.bitchute.com/channel/pg1Pvv5dN4Gt <br />- Daily Motion: https://www.dailymotion.com/neurallantern <br />- Minds: https://www.minds.com/neurallantern/ <br />- Odysee: https://odysee.com/@NeuralLantern:5 <br /><br />Please show your support! <br /><br />- Buy me a coffee: https://ko-fi.com/neurallantern <br /><br />- Subscribe + Sharing on Social Media <br />- Leave a comment or suggestion <br />- Subscribe to the Blog: https://www.NeuralLantern.com <br />- Watch the main "pinned" video of this channel for offers and extras <br /><br />

Buy Now on CodeCanyon