3
\$\begingroup\$

I am trying to enter into the world of ARM and one thing I come across very often is that ARM processors support ARM and Thumb instruction set. So it means compiler will use Thumb Instructions which are 16-bit to improve code density and it will use ARM instructions only when absolutely necessary. AM I right? But now there are newer processors which support Thumb 2 which has 16 bit as well as 32 bit instructions. But then what makes these newer processors with Thumb 2 superior to the ones which use ARM and THUMB. I mean basically both the families will have 16 bit as well as 32 bit instructions at their disposal or is there some benefit of having Thumb 2 as compared to having Arm and Thumb instruction sets. I bought Atmel SAMD21 Kit to develop our new products but before that I am just trying to understand some architecture concepts before I actually start with the hardware.

\$\endgroup\$
6
\$\begingroup\$

An ARM processor can not execute arbitrary sequences of interleaved ARM and Thumb instructions. It has to be switched from one instruction set to another, e.g. through a branch instruction. So most of the time you tell the compiler to use either ARM or Thumb instructions throughout your project. The best the compiler can probably do is to decide on a function-by-function basis which instruction set fits best. The Thumb2 instruction set is supposed to combine the advantages of ARM and Thumb without the drawbacks.

Edit:

The answer to the question @Kynit linked to basically also states the above.

\$\endgroup\$
  • \$\begingroup\$ There are some kinds of code where 32-bit ARM code could outperform the newer alternatives. The newer alternatives, for example, don't allow one of the registers in a memory operand to be shifted right. Further, some code that makes very heavy use of conditionals could benefit from having the 4-bit conditional field present in every instruction, rather than having to use a special "if/then" instruction. \$\endgroup\$ – supercat Jan 21 '15 at 17:38
4
\$\begingroup\$

Thumb2 gives you a few extra instructions that let you take advantage of the ARM feature set in ways that that Thumb couldn't. Thumb2 also supports 16-bit Thumb instructions, so there isn't a huge disadvantage in code size with the new 32-bit instructions. Overall, it looks like you've got the right idea.

See this question for more info.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.