Premium Only Content
Signed Integer Division in x86-64 Assembly with IDIV and CQO
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
-
1:00:18
Dialogue works
2 days ago $6.68 earnedLarry C. Johnson: Russia Launches Largest Missile & Drone Attack Yet
18.1K6 -
12:02
Actual Justice Warrior
1 day agoChicago Mayor Says ONLY Black Businesses Get Licensed
18.5K27 -
4:21
SethDrums
4 days ago50 Cent - In Da Club if it was 1950s
18.1K3 -
1:48:49
Badlands Media
16 hours agoDevolution Power Hour Ep. 416: The Rug Pull Cycle, False Signals & Narrative Discipline
376K44 -
1:06:11
Inverted World Live
15 hours agoA Ghost Ship in Washington, A Fire in Roswell | Ep. 155
83.3K16 -
3:06:55
TimcastIRL
11 hours agoDan Bongino To RESIGN, Trump Addresses The Nation
376K584 -
2:14:08
Barry Cunningham
11 hours agoLIVE BREAKING NEWS: President Trump Addresses The Nation! And More News!
72.6K32 -
5:15:27
ThatStarWarsGirl
13 hours agoTSWG LIVE: Discussing STAR WARS News with Special Guest Star Wars Theory!
58K5 -
2:42:40
Laura Loomer
11 hours agoEP162: LIVE: President Trump Addresses The Nation
71.2K33 -
1:32:05
Adam Does Movies
16 hours ago $13.34 earnedRob Reiner Films + Movie News + AMA - Live!
50.3K2