Skip to playerSkip to main content
In this video, I walk through how to perform signed integer division in x86-64 assembly language using Yasm on Ubuntu/Linux.

We focus on 64-bit signed integers and the IDIV instruction. I explain the setup: loading the dividend into RAX, using CQO for proper sign extension into RDX, loading the divisor, and executing IDIV. After division, the quotient ends up in RAX and the remainder in RDX.

I reference the excellent free book "x86-64 Assembly Language Programming with Ubuntu" and show practical code examples, including a complete working program that prints both the quotient and remainder.

We test with small numbers (256 / 233) and larger ones to see it in action. I also touch on the difference between signed (IDIV) and unsigned (DIV) division, and why CQO is needed for correct sign handling.

Perfect for anyone learning low-level programming, assembly language, or wanting to understand how integer division really works under the hood.

Introduction to Signed Division 00:00:00
Referencing the Assembly Book 00:00:28
IDIV Instruction Overview 00:01:16
Dividend and Divisor Setup 00:01:24
Sign Extension and CQO 00:04:18
Quotient and Remainder Results 00:04:40
Setting Up the Program 00:05:13
Data Section and Strings 00:06:22
Function Prologue and Preservation 00:09:20
Loading the Dividend into RAX 00:10:00
Sign Extension with CQO 00:11:24
Loading the Divisor 00:12:36
Performing IDIV 00:14:19
Saving Quotient and Remainder 00:16:48
Printing the Results 00:17:20
Running and Testing the Program 00:18:51
Testing Larger Numbers 00:19:48
Returning the Remainder 00:21:42
Signed vs Unsigned Division 00:23:48
Conclusion and Thanks 00:25:02

Thanks for watching!

Find us on other social media here:
- https://www.NeuralLantern.com/social

Please help support us!

- Subscribing + Sharing on Social Media
- Leaving a comment or suggestion
- Subscribing to our Blog
- Watching the main "pinned" video of this channel for offers and extras

#AssemblyLanguage, #x86_64, #LowLevelProgramming, #AssemblyTutorial, #IDIV, #Yasm, #UbuntuProgramming, #ComputerArchitecture, #ProgrammingTutorial, #SystemsProgramming

Be the first to comment
Add your comment

Recommended