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
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
Category
🤖
TechTranscript
00:00Hello there.
00:01In this video, I'd like to talk to you about dividing signed integers in an x86-64 YASM
00:09assembly program.
00:16I'm going to be focusing on 64-bit integers and I'm going to use an instruction called
00:22iDiv.
00:23Okay, so for starters, I just want to give you an overview of the process.
00:27I'm going to use an awesome book that I love to reference.
00:29I did not write this book.
00:31The book is titled x86-64 assembly language programming with Ubuntu.
00:35I mentioned it in a lot of other videos.
00:37The author here is a genius and this book is open source and freely available.
00:43So go look it up, get yourself a copy and become an assembly expert too.
00:49Anyway, so what I'm going to do is go into this book and I'm going to go into section
00:54seven, which is called the instruction set overview.
00:58And then inside of that, I'm going to click on 7.5 integer arithmetic instructions or arithmetic,
01:05I don't know, whatever you prefer to say it as.
01:09And then I'm going to go inside of there and I'm going to click on 754 integer division.
01:14So, you know, the basic idea for dividing integers in a YASM assembly program on x86-64 is just
01:21to load up your dividend, you know, the top portion, I guess that is the numerator and
01:28then the divisor, which would be the denominator with separate registers.
01:33So load up the dividend with a register or put the dividend into a register and then put
01:39the divisor into another register.
01:40They're going to be special registers.
01:42We're going to be using the A and D registers.
01:44You can kind of see that at the bottom already.
01:47And then once that's set up properly, you just sort of use the idea function or instruction.
01:54And there's another instruction we can use to make things a little bit more simple because
01:57if you kind of notice what this is saying here, it's saying that the dividend usually
02:04needs to be stacked between two other registers at the same time.
02:10And that's a little bit confusing, especially if these registers right here, notice how DX colon
02:15AX, that means it wants you to represent a 32-bit number using 16-bit versions of two different
02:22registers just sort of like pushed up against each other.
02:25So obviously if you know how to manipulate bits, which I'm going to do other videos for
02:30in the future, then you could do that with any size, but just, I'm going to make the easiest
02:34example that I can here.
02:36I love this line.
02:37I just found it today.
02:39As always division by zero will crash the program and damage the space time continuum.
02:43So try not to divide by zero.
02:45I love it.
02:47But so here's like a nifty little table inside of the book that sort of shows you how you're
02:51supposed to set up the numerator and denominator or the divisor.
02:54What was the other word that they used?
02:56Dividend and divisor.
02:57I usually say numerator and denominator.
03:00Anyway, so remember if you watched my previous videos, then you'll know that we have smaller
03:08versions of our registers.
03:10Like for example, this EAX right here, that's actually the RAX register, but it's only about
03:15half of it.
03:17Half of those bytes are being ignored, so all of these different versions that you're seeing
03:21are just different sizes of the A and D registers.
03:26So I'm going to go to the simplest example here and just kind of show you that basically
03:30what they're trying to do is force you to have a numerator that is bigger than the denominator.
03:35That way it's guaranteed you'll have some kind of a quotient or, you know, more likely that
03:40you have some kind of a quotient and a remainder that kind of makes sense because if you divide
03:46a number that's much smaller than the denominator, then you'll just end up with zero remainder
03:52of the original number pretty much in integer division.
03:56This video is not about float division.
03:58Float division is more precise.
04:00So, in other words, if I want to divide something by a 64-bit integer, then I need to first set
04:09up a 128-bit integer.
04:13And that means I have to take two 64-bit integers, the D register and the A register, I have to
04:18load both of those registers up with 64 bits each so that when you imagine them being combined,
04:24it's a 128-bit register or 128-bit value.
04:30Once I have something that is sufficiently large, then I can divide it by something else.
04:35Then the result will show up in the A and D registers.
04:38Also, you'll get one register that gives you the actual quotient, you know, the actual result
04:43of dividing without a fractional part at the end, just, you know, truncated data.
04:50Then the remainder will be in the D register, the RDX register.
04:54So at least for this form, I just want you to know you can do it with all these other
04:58forms if you want to.
04:59But in this example, I'm just going to take 128 bits, divide it by 64 bits, and then I'll
05:05get the answer and the remainder.
05:08So that's the basic idea.
05:09Here's some sample code in the book.
05:10I love it.
05:11It's wonderful.
05:12But I'm going to go ahead and start writing my own program now.
05:13Okay.
05:14So I got a solution up here.
05:15I'm going to just copy paste my data section and explain it briefly.
05:21Okay.
05:22So here is, oh, maybe I should first say, here's a sample program that I'm using.
05:27You don't have to worry too much about what's actually inside of it.
05:31The C module and the make file, they're standard stuff that I usually use in all of my videos.
05:36This is not a make file video.
05:38See my other videos.
05:39If you want to learn how to make your own make files, but long story short, I'm just
05:42going to type, you know, make run in order to just get this program to run.
05:45And then for the C program, I'm compiling a hybrid program.
05:50So, I mean, it's just easier for me to just kind of get started this way.
05:54So I have my main entry point sitting inside of a C source code file that gets compiled
06:01and linked into my main program.
06:03And it just calls on a function called math right here, which is just going to be, you
06:07know, this source code right here.
06:09So if you want to make hybrid programs, you want to learn the basics of assembly.
06:12You want to learn anything that I'm not really talking about in this video.
06:15See my other videos for today or for this video, it's just going to be integer division.
06:20Anyway, I'm going to paste in some starter code here for my math module.
06:25I've got a data section and I've got some strings.
06:30So again, this is not a video explaining C strings or anything, but just keep in mind, I'm going
06:34to eventually print the division result quotient is, and then I'm going to actually print it.
06:40And then I'm going to print the division remainder is, and then actually print it.
06:46So I'm just, I'm just setting up strings to make my results look a little bit prettier.
06:50That's all I'm really doing CRLF.
06:52That's just new line stuff, system calls.
06:55Here's the system service code for writing to something, writing to a file or standard
07:00output.
07:00Again, that's in another video file descriptor one, another video, and then a return value.
07:06I'm just choosing to return the number seven from this module.
07:09I don't know why I just, I like to reuse code and I'm not going to change it.
07:14And then we're going to take two different integers here.
07:17And, uh, I think in my starter code, I actually hard coded those numbers instead of using those
07:26globals.
07:27Okay.
07:28Maybe I'll fix that after everything is working.
07:30So, um, I'm going to start my text section here by just copy pasting a little thing that
07:36says, okay, here's where my code is going to go.
07:38Now all my instructions.
07:40And then, uh, here's my entry point, which is just my function called math.
07:47You want to write functions, see my other videos, but this is basically it.
07:50You just kind of have something enter and then return from it when you're done.
07:55And if you mess up any registers, you have to preserve them with push and pop pairs.
08:00Another thing that I'm going to add that I'm not going to explain in this video is I'm
08:03going to do calls to one of my own personal libraries.
08:07And basically I'm just going to, I'm just going to mark two functions as external.
08:11They're sitting in a shared object that I made.
08:13Don't worry about that.
08:14This video is not about printing.
08:16It's just about dividing, but I want to be able to easily print.
08:19So I'm just going to use that library.
08:21So don't worry about that.
08:22What's really important for this video is my function called divide test because notice
08:28how in the entry point of math, remember the C module, the driver, it calls on this
08:34math function, the math function eventually or immediately calls on divide test.
08:40And so here's the prototype basically from my divide test function.
08:43I'm just going to say it's void, takes no arguments.
08:45That way it can just do everything by itself as a little demo and it's a little bit easier.
08:49So that means I don't really need to preserve any registers unless I am using them.
08:54And if you see here, well, I guess if it was going to take arguments, you don't need to
08:59preserve the argument registers.
09:01So I should have just said, yeah, we are going to use some registers and therefore we're going
09:05to preserve them.
09:06So R12, 14, and 15, Oh, why am I not using 13?
09:10I must've erased that at an earlier date, but whatever.
09:14We're going to use these three registers.
09:16I'm going to say return, uh, to just kind of make this an official function.
09:21And because I know I'm going to use R12, 14, and 15, I'm just going to preserve them with
09:26a push pop pair.
09:27So I'm going to say this is the prologue, oops, and I'm going to push, uh, R12, push
09:35R14, push R15, respect the ABI.
09:39If you don't, other pro other parts of the program will probably crash epilogue is just
09:45hopping all those in reverse order so that I can basically preserve them for the caller.
09:51Um, okay.
09:53So now we're good with all our registers.
09:55First thing I want to do is I want to load up, let's see, I want to load up RAX with a
10:04number.
10:05Now, maybe I'll, maybe I'll fix this right now.
10:07What was 256?
10:08It was the, my integer B, so I'm going to hit main memory, which is a little slower than
10:15using an immediate, but Hey, it's more flexible.
10:17And so basically I'm going to set up RAX, which is the numerator.
10:21If we go back to the book real fast, if our intention is to divide a 128 bit.
10:25Uh, uh, like combined register, uh, by a 64 bit something then, uh, well, RAX is the
10:35lower 64 bit.
10:36So that's why I'm loading that up first.
10:37I'm just saying, well, I've got 64 bits worth of stuff, a quad word worth of stuff sitting
10:42in integer B as my global.
10:44So I'm just going to load that into RAX.
10:46Then I just have to somehow take care of, uh, RDX.
10:50So obviously, uh, if you wanted to, you could just, you know, take RDX and just set a bunch
10:56of zeros to it.
10:57But that would probably only work if, uh, you were guaranteed that RAX was, uh, a positive
11:04number so that it's signed bit was zero at the very left.
11:07Um, if it was a negative number, it's signed bit would be a one at the very left.
11:11And that wouldn't be very good if RDX plus, uh, RAX, you know, lined up are supposed to
11:17be a negative number because, uh, you would want, uh, ones all the way through, uh, to
11:22RDX.
11:24So there's a special instruction we can use called CQO.
11:29I'm just going to paste that in here just to make things a little bit easier because I'm
11:33really trying to divide a 64 bit number, uh, uh, integer by something.
11:36The system wants a 128 bit integer.
11:39So basically this instruction right here, CQO, whoops, what happened?
11:43How come it's not lined up?
11:45CQO basically just takes RAX, whatever is in there and stretches it onto the 128 bit
11:51combination of RDX colon RAX.
11:55So remember when you see this kind of thing, remember when you see RDX colon RAX, or just
11:59like a register colon, another register, that's usually telling you that, um, the system will
12:05think of those two different registers in a combined way as one longer register.
12:11So that's really what it is.
12:12CQO is going to say, let's look at RAX and let's, uh, you know, fix it up and then also
12:18fix up, uh, RDX so that when they're combined, they make sense as just one number.
12:25Um, and you know, that, that, that would work pretty easily.
12:27Like I said before, if it was a positive number, but not necessarily in all cases.
12:31So we'll just use that instruction to be safe.
12:34The next thing I'm going to do is, uh, let's see, set up the denominator.
12:41So let's see here.
12:44I'm going to say set up denominator and you know, we can hard code the 233 there, but I
12:49think I've already decided let's just use variables.
12:52So the A I think has 233 where the heck is my A?
12:56There we go.
12:57So I'm going to say my integer A and, uh, here I'm going to put, uh, the pointer to the
13:04A variable and then I'm going to dereference it.
13:07And, um, Oh, one thing that we have to remember is, uh, when the system is using your registers
13:14like RAX here, it knows RAX is the 64 bit form of the A register.
13:18So if you use different forms of your register, then it knows how many bits you want.
13:23Like for example, here, we just kind of go back up, uh, this EAX, that's still the A register,
13:30but the E kind of tells the system that it's, uh, you know, 32 bits instead of 64 bits, but
13:36there's no, there's no way for the system to really know that that memory location is 64
13:41bits.
13:41How does it, how does it know if I'm, if I'm trying to load from memory, a one byte integer
13:47or a two byte integer or four bytes or eight bytes, it doesn't really know.
13:50So I kind of have to specify what the data size is of the integer at, uh, at that place
13:55in memory, keyword.
13:58So if I didn't put this, I think this probably wouldn't even compile.
14:02Um, but if it did compile, you, you probably should be nervous that it would compile and
14:07do something wrong.
14:08Um, so I'm just going to specify exactly what the data size is for that.
14:13So now we've set up our numerator and also set up our denominator.
14:17And the next step is to just actually divide.
14:21Let me copy paste that real fast.
14:23So now we actually divide.
14:26Why is my, oh, I know what's going on.
14:31I have the tab size set up differently between my two editors.
14:34I got to fix that.
14:35Or how about never fix it so I can always complain and you can laugh at me.
14:39That's okay.
14:41Um, so on line 85, we're going to, uh, divide the numerator by the denominator.
14:48And we'll say the numerator is, uh, you know, RAX, uh, with RDX in front of it.
14:55And then the denominator is just one register, which is, uh, what have I done wrong here?
15:04Oh, no, no, no.
15:05I'm okay.
15:05I'm okay.
15:07R12.
15:08So if you look back at the, I got a little confused here because, uh, the book, you know,
15:12it wants, uh, the D and the A registers as the numerator, but then it says OP64 as the
15:17denominator, you can just kind of use a bunch of different stuff for that, but, uh, I'm
15:21choosing to divide by another register.
15:23So basically I'm taking the denominator and loading it up into R12.
15:28And then when I call my, uh, I div instruction, I'm just saying integer division.
15:35And I want you to divide whatever's in the RDX, RAX set as, uh, I want you to divide it by
15:41R12.
15:42At that point, RAX and RDX will be overwritten.
15:45So that data is now destroyed, but, uh, they contain the answer.
15:49So RAX now contains the answer.
15:52I'm just gonna say quotient.
15:55And, uh, the, uh, RAX register contains the remainder.
16:00So for example, if you are familiar with the, uh, let me pull this up real fast.
16:05Is that the calculator?
16:06No, there it is.
16:06If you're familiar with the modulo instruction, like if we said, uh, let's see, what was it
16:12again?
16:13233.
16:14Okay.
16:14So let's do 256 divided by 233.
16:20This gives us the number one.
16:22And then some sort of like a fractional remainder with integer division.
16:25We're not going to get the fractional remainder.
16:26It's just literally going to be the number one, uh, sitting in RAX.
16:30And then in RDX, it's going to give us the result of using the, uh, modulo operator, which
16:35is going to be 23.
16:36So it's going to be one remainder 23 is what we should see, uh, unless I'm totally wrong.
16:41So then right away, I'm just going to save the result of our division, which is a good
16:50practice, you know, like the, uh, RAX and RDX, those are registers that could be quickly
16:55destroyed, uh, especially if you called another function or a system call or something.
16:59So I'm just going to save them right away.
17:01So that's why we, uh, saved 14 and 15 in addition to R12.
17:07So R12, we were using for the, uh, denominator, and then we're using 14 and 15 to store the
17:11answer.
17:12So I'm just going to save them real fast.
17:17And now I'm just going to do easy stuff that I've talked about in other videos, uh, just
17:21to sort of print out an answer.
17:23So I'm just going to, I'm just going to write this up real fast, copy paste this, and then
17:28just kind of briefly talk about, Oh, look, I'm using a system call explained in another
17:33video to print out that little prefix message.
17:36You know, the result of your division, here's the quotient and then a colon, and then I can
17:40actually print the number.
17:41And then down here, uh, I'm just using my own personal library to print a 64 bit integer.
17:47And, um, so that way it's easy for me and notice how I'm printing, uh, R14, I'm giving it to
17:52the call to the function as the first argument, which is RDI.
17:56What is R14?
17:57Again, that's just the, uh, quotient.
17:59So here I'm printing the quotient and then I do the same thing for the remainder.
18:03And then we're going to do a paste here.
18:08And I'm just going to print my prefix of the remainder, you know, here's your remainder,
18:12and then I'm going to actually print it.
18:13And the remainder was in R15.
18:14So 14 and 15 had the answer.
18:17And then the other register just kind of had, or the, uh, the R12 just kind of had the denominator.
18:22So I think that's pretty much all I need.
18:24Oh, there's one more function that I forgot to put in there.
18:27Yes.
18:28I'm fond of writing a little CRLF function.
18:31This is not part of the video really, but it's just a special function that I can call
18:35on to do a carriage return line feed.
18:38And I'm just, I just can never stop using this.
18:41I know I could just prefix or suffix my strings, you know, with like a CRLF, but I like to be
18:47able to call every time I want to see all that.
18:50Okay.
18:51So we have the program now.
18:52Let's see if it actually works.
18:55Is that my terminal?
18:56Yeah.
18:57I'm going to go clear and make, hopefully it actually works.
19:03So yeah, there we are.
19:04Okay.
19:05So everything seemed to work.
19:06It compiled, um, it printed hello from the driver.
19:10And then when we went inside of the assembly module, this is really what we're interested
19:13in.
19:14It said the division results, uh, the quotient is the number one and the division remainder
19:19is the number 23.
19:21That's what we said before, right?
19:22So it's going to be 23 is the remainder.
19:24If you just do the modular operator or if you're dividing, whoops.
19:27If you're dividing, then you'll just get a one.
19:30Uh, remember like the quotient is just going to, you know, truncate or remove or throw away
19:36all the extra data.
19:37It's not going to round up or down or anything.
19:38It's just going to say anything past the decimal point is gone.
19:41And that's why the, uh, the remainder is pretty important.
19:44And then of course, you know, just for fun, we could, I don't know, put like some other
19:47numbers in here if we wanted to, maybe I'll copy paste this.
19:50Just put some other numbers.
19:52Let's put like a giant number and see what happens because these are 64 bit numbers.
19:55We can do it.
19:58Um, I probably should have switched a and b, right?
20:01Cause doesn't it kind of feel like a's on top?
20:04So it should be the numerator or whatever.
20:06So I'm just going to hit a bunch of stuff here and then divide that by some other stuff.
20:12See if this comes up with a more fun answer.
20:15So one more time, clear and make, and it's telling me that, uh, whoa, that's the results.
20:19I guess probably should have printed out the original numbers, but let me just put that
20:23into the calculator just for fun.
20:25We'll say this divided by, um, that and then, um, just sort of go back to the calculator.
20:34Hit enter.
20:35So, uh, Oh, the squiggly lines.
20:40That means that's not exactly the result.
20:41I got to figure out how to change the mode on this calculator so I can get precise.
20:45Let's see.
20:46Can I do that right here?
20:48Hmm.
20:49Hmm.
20:50Exact?
20:51No.
20:52Can I try it again with exact?
20:55All right.
20:56This is not a tutorial on the, uh, co-alculate calculator.
20:59So I guess I'll just leave it as is.
21:01Maybe I'll do, can I do a slightly smaller number?
21:06Yeah.
21:07There we go.
21:08Okay.
21:09I'll take off three digits so that the calculator will at least show me something.
21:14Okay.
21:15Run it one more time.
21:17And then, so now we have smaller stuff.
21:20The answer should have been three, eight, six, seven, seven, seven, six, six, two, three,
21:24eight, six, seven, seven, six, six, two.
21:25Yeah.
21:26That looks good.
21:27We killed everything after the decimal point.
21:28So the point six is not on there.
21:30And then we run the modulo to see what the remainder is.
21:33And it should say one, two, eight, six, three.
21:37Yeah.
21:38Okay.
21:39And then, uh, the seven is getting returned.
21:41I don't know.
21:42I'm going to return the remainder for some reason.
21:45We could do it.
21:46Let's just return the remainder.
21:48Might as well make this video a little bit more fun.
21:51So recall that in order to return something, uh, if the return value is an integer and not
21:55a float, or if it's a pointer, then, um, you'll just use RAX as the return register.
22:01So I'm just going to do move, return the remainder to the collar.
22:10Okay.
22:11I'm going to move, uh, something into RAX.
22:13It's going to be R15.
22:15Nice.
22:16Now this is a function with a return type.
22:18I'm going to say long here.
22:20And then, um, up here, uh, I guess RAX is already going to be pre-filled now after that
22:30call, but you could imagine if you were doing more stuff between the call and the return,
22:35you would probably want to save the return value from RAX in some other register like
22:39R12.
22:40And then that means you got to add a push pop pair to preserve it.
22:42And then, uh, we'll definitely just, uh, well, maybe I'll say move RAX into RAX, uh,
22:53totally useless.
22:54That's why I'm commenting it out.
22:55So we'll do one less instruction.
22:57So basically after we get back from divide test, RAX is going to have the, uh, return
23:02value and math, uh, this function would also use RAX for its return value.
23:08So if we just sort of don't do anything, we should now see that the driver receives,
23:13uh, the remainder as its return value.
23:16Yeah.
23:17So the driver got the following value from math.
23:19One, two, eight, six, three.
23:22Let me open that up again real fast, just to make sure we understand what's going on with
23:25the driver, even though this is not a driver video, it says external long math.
23:30It names that as a long function.
23:33And then when we call the function, we just kind of grab a long result, 64 bit int.
23:38And then we print it with print F cause this is a C program, not C plus plus.
23:44Okay.
23:45All right.
23:46Uh, those are the basics of just dividing integers, uh, signed integers.
23:51Let's see.
23:52In, uh, assembly.
23:53Let's see.
23:54Where's that?
23:55Yeah, there we go.
23:57So, uh, just keep in mind what I've been showing you is I div, which is a assigned integer,
24:01which is what you probably want.
24:03Um, which means the integer can be positive or negative.
24:07And, um, you know, if you know for sure that you're going to be dividing two positive numbers
24:14and there's no chance that the numerator or denominator or, um, the quotient or, you know,
24:20any of those things are going to be negative, then you could, you could divide unsigned integers.
24:26And then you can use larger values because remember when we have signed values, we basically lose
24:33half of the, I guess, maximum possible value that we can represent because we lose one bit
24:38to the fact that the integer is signed.
24:41So I div is for signed and div is for signed.
24:45Sorry.
24:46I div is for signed and regular div is for unsigned.
24:49And then, yeah, I guess that's basically all I really needed to show you.
24:55There's a bunch of nice code in this book.
24:57I'm not going to, I'm not going to look at it right now.
24:59So, okay.
25:00Thank you so much for watching this video.
25:02I hope you learned a little bit of stuff and had a little bit of fun.
25:05I'll see you in the next video.
25:12Hey everybody.
25:13Thanks for watching this video again from the bottom of my heart.
25:15I really appreciate it.
25:16I do hope you did learn something and have some fun.
25:19Uh, if you could do me a please, a small little favor, could you please subscribe and follow me?
25:24Uh, this channel or these videos or whatever it is you do on the current social media website that you're looking at right now.
25:31Um, it would really mean the world to me and it'll help make more videos and grow this community.
25:36So we'll be able to do more videos, longer videos, better videos, or just, I'll be able to keep making videos in general.
25:42So please do, do me a kindness and, uh, and subscribe.
25:46You know, sometimes I'm sleeping in the middle of the night and I just wake up because I know somebody subscribed or followed.
25:51It just wakes me up and I get filled with joy.
25:53That's exactly what happens every single time.
25:55So you could do it as a nice favor to me or you could, you could troll me if you want to just wake me up in the middle of the night, just subscribe.
26:01And then I'll, I'll just wake up.
26:03Uh, I promise that's what will happen.
26:05Also, uh, if you look at the middle of the screen right now, you should see a QR code, which you can scan in order to go to the website, which I think is also named somewhere at the bottom of this video.
26:14And it'll take you to my main website where you can just kind of like, see all the videos I published and the services and tutorials and things that I offer and all that good stuff.
26:23And, uh, if you have a suggestion for, uh, uh, clarifications or errata or just future videos that you want to see, please leave a comment.
26:34Or if you just want to say, Hey, what's up, what's going on?
26:36You know, just send me a comment, whatever.
26:38I also wake up for those in the middle of the night.
26:40I get, I wake up in a cold sweat and I'm like, it would really, it really mean the world to me.
26:46I would really appreciate it.
26:47So again, thank you so much for watching this video and, um, enjoy the cool music as, as I fade into the darkness, which is coming for us all.
27:11Before I begin, thank you as, as you come back.
27:13Oop, thank you for doing that.
27:14Thank you very much.
27:15This is my experience.
27:16Thank you very much.
27:18I have a pleasure.
27:19Eh, my pleasure.
27:20I am.
27:21Two other things.
27:22I love you.
27:23Um, again, congratulations.
27:24I love you guys.
27:26Please write stories.
27:29Please write.
27:31I gef.
Be the first to comment