Join over 3 million cybersecurity professionals advancing their career
Sign up with
Required fields are marked with an *
Already have an account? Sign In »
13 hours 15 minutes
Hello, This is Dr Miller in this is episode 12.8 of Assembly.
Today we're gonna talk about thumb mode, changing modes and then thumb instructions
So we have a difference between our mode and thumb mode. So in our mode, each of our instructions are 32 bits wide or four bites,
and in thumb mode, we have instructions that are only 16 bits wide or two bites.
So what is the benefit of some mode, while one code is more compact, so if you have eight bites, I could fit to arm instructions or get fit four thumb instructions,
and then when we're touching in executing instructions, it's more official in memory is slow. And so, basically,
if you have to load data in, if you load the same amount of data, you can get Maurin instructions. So if you have slow memory than that will make a difference.
And then the original thumb mode had a limited instruction set, meaning not all. In all, instructions could be encoded using thumb mood
where thumb to we have full instruction encoding, and so we have additional sort of wide instructions in order to allow the processor to accommodate the fact that maybe an instruction takes more space than you would think.
So here's an example. So
if we look in here, we can see that in the middle is showing the actual bites that air for our instruction. So we gotta move R five R zero number five, and that's E three, a 00005
And that instruction is the same.
And this is just, ah, dump using object don't.
And so when we have these two different instructions, so in thumb mode, we can see that these instructions are encoded using,
um, less bites. Right. So we got two bites here, whereas for each one of these instructions, we've got
Now, when we're going to change modes, we can use a couple different instructions. So we got branch with Link Exchange in Branch in exchange.
I mean, we'll talk about those in depth
when we exchange the instructions that if the address is odd, then we're gonna switch the thumb mode and then thumb to adds the ability to have variable with instructions either two or four bites for our encoding.
So changing mode.
So we got are two different instructions. So we got branch with Lincoln Exchange.
So exchange is going to change the instruction set, and then the link is going to set the link register
and again we can see that we have things like conditions and wide instructions. Um, we have a label on then where we want to go,
and then we have branch in exchange.
And so this we're just going to switch instruction sets will go from thumb, toe arm or from armed a thumb.
Now some instructions.
So do have the notion of having unified assembler language or u A. L. And this allows us to have one syntax for any instruction that's either arm or thumb mode.
And then if we have a possible different in multiple on coatings, we can use the dot w for white instructions or 32 bits, or the dot end for narrow instructions.
And then if one of these is not available and you try and do it, it will generate a compile time air.
So here's an example that we can see we have the same instruction and
we will we have the same function. But we have different instructions, so we have maybe a wide instruction versus a narrow instruction, and they both do the same thing.
Um, just depending on if you added the dot w or not, and it would generate the different
I'm in coatings for that.
And then when we talk about thumb, there are two different sets of registers that we care about. And so that's the low registers in the high registers. And so, for a lot of instructions that may only use the low registers. But you can get access to the high registers again, using some of those wide instructions.
So, for example, if we have add with Kerry,
we can see down here that it says where our media has to be from 0 to 7 and then R D and r n must both be low registers.
And so that means that we can't use, you know, higher registers in that for that some instruction.
So today we talked about some mode changing modes and then thumb instructions.
So in the future, we're gonna look at a film example and then conditional execution.
So how many bites are in arm instructions?
Answers four bites
and how many bites? Aaron Thumb instructions
2 to 4 bites again, we can have variable with ones.
So if you have questions, you can email me, Miller MJ at you and Kate, I e t you and you can find me on Twitter at Millhouse third.