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
2
votes
0 answers

Guaranteed-invalid ARM/Thumb2 M3 instruction

I would like to write a magic value into program memory on an ARM M3 embedded device. I can just define an arbitrary constant (other than 0xFFFFFFFF, which is blank flash!) and program that at some fixed address with the help of linker sections.…
Inductiveload
  • 6,094
  • 4
  • 29
  • 55
2
votes
2 answers

Compile-time register checks for Thumb-2 code

In Thumb-2 code, it is not possible to use registers 8-15 in most instructions, while this is possible in ARM code. Hence, the following assembly gives a runtime Illegal Instruction error: .syntax unified .fpu vfp .thumb …
user1544337
2
votes
1 answer

How to use thumb-2 instructions with GCC

I have written the following simplistic memcpy32 function, as a means of understanding how to write assembly code for the cortex-m4. .section .text .align 2 .global as_memcpy32 .type as_memcpy32, %function as_memcpy32: push …
2
votes
2 answers

Jump between Thumb and ARM

I am interested in the ARM and Thumb2 commands: LDR and LDR.W, PC, =ADDR for absolute jumping to a certain address. For example, when I jump from ARM code to ARM, the command LDR PC, =ADDR is performed. But what happens in the other scenarios? from…
Halastra
  • 41
  • 1
  • 7
2
votes
2 answers

How to generate the machine code of Thumb instructions?

I searched Google for generating machine code of ARM instructions, such as this one Converting very simple ARM instructions to binary/hex The answer referenced ARM7TDMI-S Data Sheet (ARM DDI 0084D). The diagram of data processing instructions is…
Papillon
  • 317
  • 2
  • 10
2
votes
0 answers

ELF Binary: why symbol value is different from actual symbol address?

Here is the situation. I am investigating ARM binary files. When using objdump -T to see the dynamic symbol table, the output shows me (excerpt from a real case): DYNAMIC SYMBOL TABLE: 00000000 DF *UND* 00000000 __cxa_finalenter .... 00002055…
Biniam
  • 56
  • 1
  • 5
2
votes
3 answers

Disable ARM 16-bit thumb instruction

Is there a way in the ARM world to use only 32-bit instructions (on a Cortex M3 for example) and to disable 16-bit thumb instructions ? I'm talking about the instruction itself, not about the load/store access mechanism. Sorry if this was already…
yacc
  • 21
  • 2
2
votes
0 answers

GCC ARM Cortex-M3/M4: SVC instruction puts CPU from Thumb to ARM state because of wrong value in Vector table

I'm porting real-time kernel TNeoKernel to the Cortex-Mx processors, it works when compiled with ARMCC, but doesn't work when compiled with GCC: just after calling SVC instruction, PC is updated to the SVC_Handler, and at the next (any) instruction,…
Dmitry Frank
  • 10,417
  • 10
  • 64
  • 114
2
votes
2 answers

Restoring Thumb state in user mode

I'm writing thread-switch code in which the kernel dumps relevant state to memory, but the actual thread switch occurs entirely in user mode. This works fine, except in the case where the preemption point occurs inside a Thumb If-Then (IT) block. In…
xac
  • 23
  • 3
2
votes
1 answer

Non-Thumb ARM code on Cortex M3

I've got some ARM code that I'm trying to run on the Cortex M3. The majority of my code in written in Thumb, compiled from C - but for some functions I'd like to be able to run normal ARM code (as I understand it, this is possible on the…
Gordon Williams
  • 1,856
  • 1
  • 17
  • 31
2
votes
1 answer

Writing data to absolute address

I'm currently playing around a bit with assembler on a Cortex-M3 microcontroller. I'm not sure if this is important, but here you go. I need to write a value into to a certain address in memory. Here is what I tried: LDR R4,…
Chris
  • 661
  • 2
  • 7
  • 23
2
votes
2 answers

Reversing bits in a register Thumb-2

So my problem is one I though was rather simple and I have an algorithm, but I can't seem to make it work using thumb-2 instructions. Amway, I need to reverse the bits of r0, and I thought the easiest way to do this would be to Logically shift the…
2
votes
1 answer

Compiling and Building a Slim version of avconv/ffmpeg for STM32F4-Discovery - an armv7 thumb 1/2 architecture

This is my first attempt at posting for help on Stack Overflow. My Project: Using an STM32F4-Discovery with the STM32F407VGT6 chip with the FPv4-SP and a camera/LCD peripheral setup, I need to record video at QVGA and output into a compressed MPEG-4…
2
votes
3 answers

ARM/Thumb interworking in assembly

I'm building a Windows Phone project with some bits of it in assembly. My assembly file is in ARM mode (CODE32), and it tries to jump to a C function that I know is compiled to Thumb. The code goes like this: ldr r12, [pFunc] mov pc,…
Seva Alekseyev
  • 59,826
  • 25
  • 160
  • 281
2
votes
1 answer

No qsort_r for Android (or how to disable force Thumb to use CLZ in Android ARM code)

What I want to do (high-level): use qsort_r on Android. There is no default implementation. So I've grabbed one from BSD. Unfortunately it needs fls functions which is also unavailable on Android. So I've grabbed Apple Open Source Libc library and…
Wojtek
  • 239
  • 1
  • 2
  • 12