ARM Technical Support Knowledge Articles

WHY DO MOST KEIL EXAMPLES USE THUMB MODE?

Applies to: ARM Development Tools

Answer


Information in this article applies to:


QUESTION

I would like to understand why most (if not all) examples that are provided by Keil are for Thumb mode?

One key feature of ARM devices is execution speed. The Flash ROM size is typically not that important since you can get devices with more on-chip Flash ROM.

Is perhaps Thumb mode better than ARM mode in both size and performance?

ANSWER

There are several contrary statements in various ARM users manuals. Here are just two examples from Philips LPC2000 datasheets:

You need to keep in mind: fetching instructions is slower than executing instructions.

For the same program, more Thumb mode instructions are required than in ARM mode, but less code size is required since all Thumb instructions are just 16-bit (32-bit in ARM mode). Since less code size is required, more instructions can be fetched from code memory.

When Philips LPC2000 devices execute code from on-chip Flash at maximum clock (= 60MHz) the Flash sub-system delivers 128 bits (4 ARM or 8 Thumb instructions) at a rate of 20MHz. ARM code that executes sequentially requires no stalls (= waitstates for code fetching). But in real programs branches occur (conditional or sub-routine calls). For Thumb code more instructions can be fetched at the same time which requires less stalls. We do not have speed comparisons for Thumb vs. ARM, however Philips told us to focus on Thumb mode.

In reality there is minimal speed penalty in Thumb mode (compared to 35% size reduction). High-speed interrupts may be coded in ARM mode and the program may be stored in RAM using the CARM compiler attribute __ram. In this way, time-critical program parts use highest ARM execution speed whereas the majority of the code uses Thumb mode which gives the best code efficiency with minimal speed penalty.

Article last edited on: 2005-07-10 14:36:41

Rate this article

[Bad]
|
|
[Good]
Disagree? Move your mouse over the bar and click

Did you find this article helpful? Yes No

How can we improve this article?

Link to this article
Copyright © 2011 ARM Limited. All rights reserved. External (Open), Non-Confidential