Surprise Me!

Complex If-ElseIf-Else in x86-64 YASM Assembly - Full Guide with Code Examples

2026-01-04 2 Dailymotion

In this in-depth x86-64 assembly tutorial using YASM, we dive deep into implementing complex if-else and if-elseif-else control structures from scratch. Starting with the fundamentals of conditional branching, we build up to full chained if-elseif-else blocks with multiple conditions - exactly how high-level languages handle them under the hood.<br /><br />You'll see real working code that:<br />- Takes user integer input<br />- Tests against specific values (5, 6, etc.)<br />- Handles greater-than/less-than comparisons<br />- Properly branches so only one block executes<br />- Uses labels, cmp, conditional jumps (je, jl), and unconditional jumps (jmp) correctly<br /><br />We cover the classic pattern: compare to conditional jump to true block to execute true code to jmp to end to false block falls through or jumps in. Everything is shown step-by-step with live compilation and runtime demos.<br /><br />Perfect for anyone learning low-level programming, reverse engineering, or wanting to understand how compilers translate if-else chains into machine code. Prerequisites: basic conditional jumps (see my earlier videos).<br /><br />Code shown works on Linux x86-64 with YASM/NASM syntax. Grab the concepts and apply them anywhere.<br /><br />Introduction to If-Else in Assembly 00:00:00<br />Explaining the If-Else Design Pattern 00:00:56<br />Drawing the Basic If-Else Flow 00:01:01<br />Comparison and Conditional Jumps 00:02:30<br />Labels for True and False Blocks 00:03:07<br />Unconditional Jump to End 00:04:50<br />Diagram of Execution Flow 00:05:51<br />Alternative Pattern with Inverted Jump 00:07:00<br />Recapping the If-Else Pattern 00:08:45<br />Starting the Code Example 00:09:16<br />Setting Up Input and Strings 00:09:40<br />Calling External Functions 00:10:57<br />Entry Point and Prologue 00:11:40<br />Asking User for Integer Input 00:13:09<br />Creating the if_test Function 00:14:56<br />Preserving Callee-Saved Registers 00:15:51<br />Printing Begin Message 00:17:03<br />Implementing Simple If Block 00:18:29<br />Comparison and je Jump 00:19:18<br />True Block: Equality Message 00:21:08<br />Testing Simple If Examples 00:23:48<br />Transition to If-Else Blocks 00:24:21<br />Creating if_else_test Function 00:24:47<br />Setting Up Complex If-Else 00:26:25<br />First If: Equal to 5 00:27:22<br />True Block for Equal 5 00:28:33<br />Else If: Equal to 6 00:30:29<br />Else If: Less Than 10 00:34:17<br />Final Else Block 00:37:33<br />Done Label and Goodbye 00:38:23<br />Recap of Full Flow 00:39:06<br />Live Demo of All Branches 00:40:54<br />Signed vs Unsigned Jumps Note 00:43:38<br />Recommended Assembly Book 00:44:12<br />Conditional Jump Families 00:45:05<br />Closing and Practice Advice 00:46:48<br /><br />Thanks for watching!<br /><br />Find us on other social media here:<br />- https://www.NeuralLantern.com/social<br /><br />Please help support us!<br /><br />- Subscribing + Sharing on Social Media<br />- Leaving a comment or suggestion<br />- Subscribing to our Blog<br />- Watching the main "pinned" video of this channel for offers and extras<br />

Buy Now on CodeCanyon