# Integers in Assembly

Video Activity
Join over 3 million cybersecurity professionals advancing their career
or Course
Time
13 hours 15 minutes
Difficulty
Beginner
CEU/CPE
14
Video Transcription
00:00
Hello. This is Dr Miller in this episode 14.16 of assembly.
00:07
Today we're gonna talk about standard types and those they're gonna include
00:11
imagers long shorts and bites NC. And then we'll see how they manifest themselves inside of assembly.
00:19
00:21
If we look inside the standard library, there is a standard imager library, and this is in standard and dot h.
00:28
And what this does is it provides us with specific with imagers. And so, for example, you will see some identifiers, so a you will mean this is unsigned. Um, it's not required, but you can have unsigned versus signed,
00:42
you can have int. And that means that this is an imager. And then we'll have ah specific set of bits. So 8 16 32 or there are other bit Ah,
00:52
this that we can use.
00:53
And at the end, we'll see an underscore tea and adult tell us that this is a,
00:58
um defined type that we can use. And so an example here is U N 16 underscore t.
01:03
So, as we go through these different types, you're going to see these different definitions.
01:10
So imagers so a standard energia is gonna be a d word size or it's going to be 32 bits.
01:15
And again we should know that they hold whole numbers and then we have a couple different types, so we have int
01:21
32 underscore T and U N 30 to underscore t.
01:25
So these are the universal types that you can use to guarantee that you're gonna have 32 bits for an imager, and then it's either signed or unsigned.
01:34
So we're here. We have some examples,
01:37
and we'll see that the manager here is gonna be the same as the U. N. And so when we look at the assignments were going to either to see d words,
01:44
right? And so that tells us that this is 32 bits in assembly,
01:49
and so we can see in here all these different types are different. The words and then how they get used will be determined by things. For example, the U versus the not and so we'll see some examples in in
02:00
the future where those air not used
02:05
and when you really see it is when you when you change the sizes, So here we're going to use an into eight for these different ones, and we look over here, we can see the sign versus the unsigned. When we copy the data out, it's either going to use a zero extend or a sign extent. So if it's
02:22
if it doesn't have a sign, you will use a zero extend. If it does have a sign that are you sign extending so you can know if this is
02:28
I'm stored in two's complement or if it's just a straight up imager.
02:31
And so we see here we have,
02:34
um C, which is an unsigned one. But see is going to be bigger than these eight bit ones. And so when it moves the data, it's gonna copy 32 bits, and then it will do. The zero extends. So then, when it saves into the register, it is cleared out all the junk that's at the top.
02:51
And so it'll save an entire D word, even though when you look up here, you can see that these air bites
02:55
parents. So the,
02:58
um, into eight or you end eight are gonna be bites. And so it's storing those using one bite.
03:04
But then, when we do, our 32 bit imagers. We see that it uses a D word
03:08
we also have short.
03:10
So short is a size that is 16 bits, and then we can use either again a zero extend or a sign extend a minute, uses the notation assembly of word.
03:23
And so when you're going to see a 16 or a short and so these air going to get treated,
03:28
um, similarly, you're going to see that it will use the key word word here. So it's a word pointer. So it's gonna copy,
03:35
um, 16 bits instead of copying 32 or eight or 64
03:42
and again, When we look here, we can see that we either have zero extend or sign extent, and that's based on
03:47
the input types of its air B. So a. We get zero extend b, we get sign extend, and that's because one assigned in one is unsigned.
03:58
All right, long.
04:00
So long provides either for a bites. And this actually depends on the architecture that you're looking at. So in the programming programming language, see, it's going to be 32 bits on 32 bit see and 64 bits on 64 bit see
04:14
So you have to understand what you're compiling for in order to understand how that's going to manifest itself.
04:18
But then we also have long, long which will guarantee that we are 64 bit
04:24
so in regular sea along versus an end are going to give us the same size. But on 64 bit we can we can use along to give us 64 bits and then we can use long, long in either case, if we want to guarantee that we have 64 bits.
04:40
So again we can see here that, um if we're in 32 bit see and we declare a long long,
04:46
we'll end up seeing that it's gonna end up taking two d word pointers, right? Cause generally you don't have the ability to access 64 bits. And so it has to use D word copies for that.
04:58
And then all the rest of them. We see these air long or in 60 fours, and we're going to see that those end up getting moved in there,
05:05
um, again, using a couple different operations.
05:11
But now we can see that if we use a long on a 64 bit
05:15
we end up eso. This is 64 bit. See, It uses a cue word. I'm in order to store that, and so we can see that each one of these only took one operation where we didn't have to use to to assign values to the long or the long long
05:31
so the character or imager slash bite.
05:35
So most times when you're programming and see your again going to use, um,
05:41
characters and so characters air signed and they are equivalent to the end. Eight Underscore T.
05:46
But if you want to have the ability to have unsigned, you can use U. N 28 underscore T. You can also use into eight underscore tea. If you want to be very specific that this is not a character, and so you shouldn't be assigning characters to it.
06:00
And so that's that's what characters are. And so if you need to do something with bites, then you end up using.
06:05
Most people would end up using a U. N. Eight for that because you don't want to accidentally lose some bits when we do signed operations.
06:15
So here again we can see that
06:16
we are seeing the bite in here. So that means that this is a character, and that's sort of a giveaway. If you see that something is storing in a bite, then that means it's generally a character, or it's going to use that u N 28 underscore tea or into eight underscore t in order to store it. And so we can see again the sign extensions
06:36
and then comparing,
06:38
Um, we'll see that we have a sign extent for both of these, so B and B one. So a character is an into eight underscore t
06:46
it gets treated the same.
06:50
So today we talked about some of the standard types,
06:54
um, the library that you can include in order to basically decide how long you want a variable to be.
07:00
And then we talked about imagers, longs shorts and then bites in C
07:04
and how they manifest themselves inside of your assembly code when you're looking at that.
07:11
So here's our quiz. How Maney bits are in a Long Long
07:15
and the answer is always 64 bits.
07:18
How many bits are on a U. N eight you int 16 underscore t
07:26
16 bits because we have, ah, number 16 there.
07:30
If you have questions, you can email me, Miller, MJ, you and Kate Ie to you, and you can find me on Twitter at no house 30.
Up Next