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

Understanding Cortex-M assembly LDR with pc offset

I'm looking at the disassembly code for this piece of C code: #define GPIO_PORTF_DATA_R (*((volatile unsigned long *)0x400253FC)) int main(void){ // Initialization code while(1) { SW1 = GPIO_PORTF_DATA_R&0x10; // Read PF4…
Nicholas Humphrey
  • 1,220
  • 1
  • 16
  • 33
0
votes
1 answer

clang links wrong ARM builtins in thumb mode

I am trying to build Cortex-M0 (ARMv6, thumb) firmware with clang 13.0. Everything seems fine except for builtin functions like __udivsi3, __udivmoddi4 that are in ARM mode. Of course the CPU only supports thumb and delivers a fault when trying to…
filo
  • 223
  • 3
  • 14
0
votes
1 answer

ARM Assembly - "Expression too complex" or "lo register required" with stmfd sp!, [lr]

I am learning assembly, in particular for ARM processors. This is my very simple assembly code: .data integer: .long 25 .text .global main main: stmfd sp!, [lr] ldr r0, =integer ldr r1, [r0] …
Martin Chekurov
  • 733
  • 4
  • 15
0
votes
1 answer

Error: Thumb does not support conditional execution

I'm writing Assembly using Thumb for a Cortex-M7. it eq eoreq r1, r0, r7 pop {r0} I'm using arm-gcc to and it throws two errors. Error: Thumb does not support conditional execution Error: instruction not allowed in IT…
DiogoJDO
  • 19
  • 6
0
votes
0 answers

Force ARM GCC to BL directly to address

I'm using GCC to compile some Thumb code. In my linker script, I have my function set up like: foo = ABSOLUTE(0xc026cc9c); And in my C file, I have: foo(50); This generates something like this: mov r0, #50 bl foo foo: .long 0xc026cc9c I want it to…
user15417885
0
votes
1 answer

Why is the THUMB instruction "mov r0, #0" not allowed?

I'm attempting to figure out some ARM assembly for an STM32 microcontroller. When I try to assemble the instruction mov r0, #0, I get: core.S:27: Error: cannot honor width suffix -- `mov r0,#0' yet it works when I use movs r0, #0. Here, it says…
puritii
  • 1,069
  • 1
  • 7
  • 18
0
votes
1 answer

Why there is a dead loop in the generated assembly for a Cortex-M interrupt handler?

I am learning the Cortex-M with the MDK uVision IDE. I wrote a simple SysTick_Handler() to replace the WEAK default SysTick_Handler() which is a simple dead loop. My SysTick_Handler(): The disassembly: I am confused by the the highlighted assembly…
smwikipedia
  • 61,609
  • 92
  • 309
  • 482
0
votes
3 answers

Why can't 16-bit instructions access the high registers of the general purpose registers

So right now I read the "Definitive Guide to ARM Cortex-M3/M4" book and can't understand why the 16-bit instructions cannot access the high general purpose registers R8-R12. It says that very few of them actually can access these registers but…
0
votes
0 answers

How do you bitwise invert all the values if a register in Thumb - 2 assembly?

The question above^ How do you bitwise invert all the values in a register in Thumb - 2 assembly? I havent been able to find the instruction for this anywhere
vivekh99
  • 31
  • 7
0
votes
1 answer

Why does changing to a low register in thumb2 increase the cycle count?

I've changed in my thumb2 assembly code all r10 into r4. As expected the size did shrunk a bit. But the cycles executed increased. Though there are still the same instructions, just a few now in narrow instead of wide. Why did that happen? There are…
txnull
  • 1
0
votes
0 answers

Setting Breakpoints on ARM Thumb Instructions in GDB

I'm practicing reversing a stripped arm binary (that I wrote) and found that when I set a breakpoint at say 0x010451, and run the program, gdb spins forever until I hit ctrl+c. When I do, the current pc is at the address, but I can't continue the…
Caustic
  • 475
  • 3
  • 14
0
votes
2 answers

Cortex M, gcc - faster bounding in C

I am trying to bound a difference between 2 integers in c; essentially absolute value ( a- b) < bound. Does anyone know, for the Arm Cortex gcc compiler if I am better off taking the absolute value of a difference: if (abs( a - b) < bound) …
nbxmike
  • 16
  • 1
0
votes
0 answers

Why are unknown instuctions there in a file generated by objdump?

I dumped an object file using 'objdump', and found wierd instructions (unknown instructions). The following shows that wierd part. The object file is built with thumb-2 compile option. So, you can find normal 16-bit and 32-bit instructions from…
0
votes
1 answer

How to count number of bytes between instructions

There's this piece of Keil assembly code in Valvano's book (3.3.3 Memory Access Instruction): ; Keil Syntax LDR R5, PAaddr MOV R6, #0x55 STR R6, [R5] ;outside of execution PAaddr DCD 0x400043FC The first line LDR R5, PAaddr gets translated by the…
KMC
  • 19,548
  • 58
  • 164
  • 253
0
votes
1 answer

inquiry in designing my Arm simulator function representing format 1

The following function represents format 1 in ARM Thumb. I don't understand the part of using AND(&) after shifting in each declaration of the fields of the formats and why did we use these numbers after AND? format 1 representation in ARM…
Nisback
  • 11
  • 1
  • 6