Questions tagged [thumb]

A reduced instruction set for ARM processors (based on a 16-bit encoding, instead of 32 bits in standard ARM mode), originally intended for embedded systems with a small amount of RAM. Also for question with the later Thumb2 mixed 16 and 32 bit instruction modes. Consider the tags 'slider' and 'thumbnails' for other meanings of 'thumb'.

This tag is for questions concerning the ARM CPU's operating mode called thumb. Questions about thumb assembly language, interworking between thumb and ARM mode as well as operating system issue in dealing with thumb mode are on topic.

The Thumb instruction set (16 bit only) with restricted use of r8-r15 was later extended to include a mix of 16 and 32 bit instructions. This was called Thumb-2. Thumb-2 is a marketing term. Different CPU families and even specific devices have different instructions. Thumb-2 is fairly meaningless in a technical sense (except it means variable length instructions (always two halfwords) are available along with 16 bit thumb instructions). Thumb-2 at wikipedia

On modern ARM CPUs, Thumb-2 is as rich as the traditional 32-bit mode and much more memory efficient.

For questions related to the scrollbar thumbs consider one of,

For questions about thumbnails, use the tag .

See also:

The paper Profile guided selection of ARM and thumb instructions gives some benchmarking of legacy thumb versus 32 bit modes. Different algorithms are faster in one mode versus the other. The paper is somewhat obsolete as Thumb-2 will be more efficient in modern (2014+) CPUs. Although some deeply embedded devices may only support Thumb.

252 questions
74
votes
6 answers

What is the difference between the ARM, Thumb and Thumb 2 instruction encodings?

I am a bit confused about instruction sets. There are Thumb, ARM and Thumb 2. From what I have read Thumb instructions are all 16-bit but inside the ARMv7M user manual (page vi) there are Thumb 16-bit and Thumb 32-bit instructions mentioned. Now I…
71GA
  • 1,132
  • 6
  • 36
  • 69
68
votes
1 answer

What is the ARM Thumb Instruction set?

under "The Thumb instruction set" in section 1-34 of "ARM11TechnicalRefManual" it said that: "The Thumb instruction set is a subset of the most commonly used 32-bit ARM instructions.Thumb instructions are 16 bits long,and have a corresponding…
Soroush
  • 989
  • 2
  • 10
  • 16
46
votes
4 answers

Is the `if` statement redundant before modulo and before assign operations?

Consider next code: unsigned idx; //.. some work with idx if( idx >= idx_max ) idx %= idx_max; Could be simplified to only second line: idx %= idx_max; and will achieve the same result. Several times I met next code: unsigned x; //... some…
kyb
  • 7,233
  • 5
  • 52
  • 105
25
votes
3 answers

ARM vs Thumb performance on iPhone 3GS, non floating point code

I was wondering if anyone had any hard numbers on ARM vs Thumb code performance on iPhone 3GS. Specifically for non-floating point (VFP or NEON) code - I'm aware of the issues with floating point performance in Thumb mode. Is there a point where the…
Justicle
  • 14,761
  • 17
  • 70
  • 94
22
votes
3 answers

When are GAS ELF the directives .type, .thumb, .size and .section needed?

I'm working on an assembly program for an ARM Cortex-M3 based microcontroller (Thumb 2 instruction set), using GNU as. In some example code I find directives like .size, .section and .type which I understand are ELF directives. As an example: …
user1481860
19
votes
4 answers

itte in arm assembly

What does the following line do in arm assembly: 000031e6 2916 cmp r1, #22 000031e8 bf1a itte ne I get the first line (comparing r1 to 22) but what about the second line (I've never seen the itte command before and googling…
Johnathon
  • 253
  • 1
  • 3
  • 6
18
votes
1 answer

Using BX in Thumb code to call a Thumb function, or to jump to a Thumb instruction in another function

I'm trying to learn skills useful in firmware modding (for which i don't have source code) These questions concern use of BX from thumb code to jump or call other existing thumb code. How do i use BX to JUMP to existing firmware THUMB code, from my…
vmanta
  • 346
  • 2
  • 3
  • 12
17
votes
1 answer

how to compile and link rust code into an android apk packed application

I'm trying to add Rust code to an android NDK sample (native-activity); Whenever I link Rust code (compiled as a .a) into the .so , it fails to run. I went on information from here to get an android aware rust compiler and 'standalone…
centaurian_slug
  • 3,129
  • 1
  • 17
  • 16
10
votes
2 answers

objdump and ARM vs Thumb

I'm trying to disassemble an object built for ARM with gcc. Unfortunately, objdump is trying to guess whether the code is ARM and Thumb, and is getting it wrong: it thinks my code is Thumb when it's actually ARM. I see that objdump has an option to…
David Given
  • 13,277
  • 9
  • 76
  • 123
9
votes
3 answers

ARM assembly cannot use immediate values and ADDS/ADCS together

I am currently trying to speed up some of my C functions on a Cortex-M0 (Freescale KL25Z) using assembly. I get a problem with this minimal test program: @.syntax unified .cpu cortex-m0 .text .global test .code 16 test: mov r0, #0 adds r0,…
xGentx
  • 93
  • 1
  • 4
9
votes
3 answers

ARM Cortex M0/M3/M4:Why PC is always Even number in Thumb State

As far as I understand it, ARM Cortex-M CPUs are always in Thumb state, which means: Thumb state indicated by program counter being odd (LSB = 1). Branching to an even address will cause an exception, since switching back to ARM state is not…
CodeFarmer
  • 364
  • 1
  • 3
  • 12
8
votes
4 answers

Calling ARM assembly from C, GCC (bare metal)

I am trying to do some bare-metal programming in ARM with GCC and testing on QEMU. Whenever I call into an ARM label from C, my program hangs. I have a simple example of code that shows the problem at https://gist.github.com/1654392 -- when I call…
singpolyma
  • 10,999
  • 5
  • 47
  • 71
8
votes
3 answers

GCC --gc-sections and finding symbol dependencies

I'm trying to reduce the size of my elf executable. I'm compiling with -ffunction-sections -fdata-sections and linking with -gc-sections, but it appears some of the symbols that I believe are unused are not being discarded. Is there some command in…
Verax
  • 2,409
  • 5
  • 27
  • 42
8
votes
2 answers

What do we mean by instruction size?

I am really confused and the question may sound dumb but I'm really not sure what it means when we say an instruction size is 32-bit or 16-bit. Is it if operand size is 32-bit then we say it's an 32-bit instruction and if operand size is 16-bit…
Amit Singh Tomar
  • 8,380
  • 27
  • 120
  • 199
8
votes
2 answers

arm thumb mode 4byte instructions

Thumb mode instructions are 2 bytes and ARM mode instructions are 4 bytes. the screenshot is a disassembly of thumb mode instructions. why do I see 4 byte instructions mixed with 2byte instructions?? can someone explain this? thank you in advance.
daehee
  • 5,047
  • 7
  • 44
  • 70
1
2 3
16 17