Hosted by Dailymotion. For legal issues report at the Copyright Center, report us on DMC, or use the Instant Removal tool.
Signed Integer Division
12 Views • Dec 14, 2025
Description
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
Keywords & Tags
More from User
AVL Tree Tutorial: Balance Factors and Why They Fix Slow BSTs
Neural Lantern
Binary Search Tree Removals - Delete Nodes with 0, 1, or 2 Children
Neural Lantern
How to Search in a Binary Search Tree (BST) - Step by Step Explanation with Examples
Neural Lantern
Binary Search Tree Insertion Tutorial: Building a BST from Scratch Step by Step
Neural Lantern
Building a Binary Search Tree - Insertion Tutorial
Neural Lantern
BST Terminology: Root, Leaves, Subtrees, Depth, Height, Ancestors & More
Neural Lantern
Related Videos
x86-64 Assembly: Signed Integer Multiplication and Addition with IMUL & ADD (YASM on Ubuntu Linux)
Neural Lantern
ARM Programming Tutorial 1 - ARM Assembly Programming and Architecture & Instruction Sets
Roxanne Morton
Mastering System Services in x86-64 Assembly Programming
Neural Lantern
Mixed Function Arguments in x86-64 Assembly - Integers & Floats Explained
Neural Lantern
x86-64 Assembly: Integer Data Movement, Pointers, and Dereferencing Explained (YASM on Ubuntu)
Neural Lantern
YASM x86-64 Assembly Functions Tutorial - Integers, Floats, Pointers, ABI, C++ Interoperability
Neural Lantern