May 3, 2025

STM32H743 Nucleo board -- Interesting aspects of Thumb instructions

The basic idea with thumb instructions is to save space. They are encoded in 16 bits rather than the usual 32 bits for ARM instructions.

The Cortex-M7 in the H743 only runs in thumb mode.

There are some interesting issues with the low bit in addresses. In certain cases, the low bit is copied into the "T" flag in the PSR to tell the processor to run in thumb mode. A problem arises in these cases if that low bit is zero. It will tell the processor to not run in Thumb mode (which it cannot do). Apparently the processor with either throw an exception or crash unpredictably.

The special cases are:

The PC itself never gets loaded with an odd address, the low bit is forced to zero.

Explicit 32 bit instructions

Consider:
0802c404:   f3af 8000   nop.w
080126ba:   bf00        nop
If you want a 32 bit "nop" instruction, you just append ".w" to the instruction. I see a lot of this (and mostly not for "nop") in the disassembled code.
08013746:   f8da 0000   ldr.w   r0, [sl]
0801271a:   f800 3b01   strb.w  r3, [r0], #1
Perhaps there is just no way to encode these instructions in 16 bits. This is interesting and makes me curious, but it works and is not hard to understand. The important thing is that the ".w" doesn't say anything about the width of data being moved.
Feedback? Questions? Drop me a line!

Tom's Computer Info / tom@mmto.org