ref:http://kmittal82.wordpress.com/2012/02/17/armthumbthumb-2/
A few months ago I gave a presentation titled “Introduction to the ARM architecture”. One of the most well received sections of that was a bit where I explained the difference between the various types of instruction sets that can be run on the ARM architecture, i.e. ARM (32 bit), Thumb (16 bit) and Thumb-2 (16/32 bit). I will try and explain the difference between the three in this post.
Before we begin, let’s look at a very simple test case which we will build for all three architectures (Thanks for my friend and colleague Stephen Wade for coming up with this test case)
typedef unsigned char uint8;
typedef unsigned short uint16;
/* r0 = x , r1 = a, r2 = b, r3 = c */uint8 foo(uint8 x, uint8 a, uint16 b, uint16 c){ if (a==2)
{
x += (b >> 8);
}
else
{
x += (c >> 8);
}
return x;
}