Thumb Mode

Video Activity
Join over 3 million cybersecurity professionals advancing their career
Sign up with
or

Already have an account? Sign In »

Course
Time
13 hours 15 minutes
Difficulty
Beginner
CEU/CPE
14
Video Transcription
00:02
Hello, This is Dr Miller in this is episode 12.8 of Assembly.
00:07
Today we're gonna talk about thumb mode, changing modes and then thumb instructions
00:12
thumb mode.
00:14
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,
00:22
and in thumb mode, we have instructions that are only 16 bits wide or two bites.
00:29
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,
00:39
and then when we're touching in executing instructions, it's more official in memory is slow. And so, basically,
00:45
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.
00:54
And then the original thumb mode had a limited instruction set, meaning not all. In all, instructions could be encoded using thumb mood
01:00
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.
01:14
So here's an example. So
01:15
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
01:30
And that instruction is the same.
01:33
And this is just, ah, dump using object don't.
01:36
And so when we have these two different instructions, so in thumb mode, we can see that these instructions are encoded using,
01:42
um, less bites. Right. So we got two bites here, whereas for each one of these instructions, we've got
01:48
four bites.
01:52
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.
02:00
I mean, we'll talk about those in depth
02:02
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.
02:15
So changing mode.
02:16
So we got are two different instructions. So we got branch with Lincoln Exchange.
02:21
So exchange is going to change the instruction set, and then the link is going to set the link register
02:28
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,
02:37
and then we have branch in exchange.
02:38
And so this we're just going to switch instruction sets will go from thumb, toe arm or from armed a thumb.
02:46
Now some instructions.
02:50
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.
03:00
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.
03:10
And then if one of these is not available and you try and do it, it will generate a compile time air.
03:17
So here's an example that we can see we have the same instruction and
03:23
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.
03:31
Um, just depending on if you added the dot w or not, and it would generate the different
03:38
I'm in coatings for that.
03:40
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.
04:00
So, for example, if we have add with Kerry,
04:02
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.
04:11
And so that means that we can't use, you know, higher registers in that for that some instruction.
04:19
So today we talked about some mode changing modes and then thumb instructions.
04:26
So in the future, we're gonna look at a film example and then conditional execution.
04:31
So how many bites are in arm instructions?
04:36
Answers four bites
04:39
and how many bites? Aaron Thumb instructions
04:43
2 to 4 bites again, we can have variable with ones.
04:47
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.
Up Next
Assembly

This Assembly language course will provide background and information related to programming in Assembly: the lowest level programming language which is useful in reverse engineering and malware analysis.

Instructed By