cancel
Showing results for 
Search instead for 
Did you mean: 

Why do I see ARM (Non-Thumb) code commands in my dissassembly?

flyer31
Senior
Posted on August 24, 2012 at 09:28

As I understand the programming manual (DM00046982), a Cortex M4 processor as the STM32F4 can only work with Thumb mode (T2 I think).

But if I use the ST4Discovery with Keil uVision, in the Dissambly I see as well 32bit-ARMv7 code (32 bit commands), as Thumb code (16 bit commands). E. g. for LDR commands it seems to use the Thumb command for small offsets, and the ARM command for larger offsets.

This really puzzles me very much - how can I see 32bit-ARMv7 in the dissassembly listing, if the processor can only understand Thumb code?

...  I just recognized in the ARMv7 TRM, that Thumb commands can have 32 bits (if leading 5 bits are 0b11111, 0b11110 or 0b11101). Just in the command discription of the ARMv7 TechRefManual it is very disturbing, that the commands are named either ''All versions of the Thumb instruction set'' or ''ARMv7-M'' (I assume ''ARMv7-M'' also is some sort of subset of the ''Thumb instruction set''?)

Are all Encodings T1, T2, T3, T4 specified e. g. for the LDR command in the ARMv7 TechRefManual also available for STM32F4, or are there any restrictions?

2 REPLIES 2
Posted on August 24, 2012 at 13:20

The disassembler is likely trying to decode bytes that otherwise would make no sense, ie data in literal tables, etc. It is not particularly smart at separating code/data.

The processor should only recognize Thumb series instructions, which mostly take a single 16-bit word, with a couple taking two.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
flyer31
Senior
Posted on August 25, 2012 at 19:41

Hi Clive1,

thank you for answer.

I got the answer through the Keil Forum: Thumb-2 has also 32 bit commands, and Thumb-2 is equal to ''ARMv7-M''.

In the TechRefManual of ARMv7-M there are encodings named T1, T2, T3, T4, ... . (E. g. for the LDR command the 16bit-versions T1 and T2 have the remark ''All versions of Thumb instruction set'', and the 32bit-versions T3 and T4 have the remark ''ARMv7-M''  - this disturbed me quite a bit - I did not know that ARMv7-M in fact is equal to Thumb-2 - and ''T2'' has NOTHING to do with Thumb-2).

So as I understand it now, any command of the ARMv7-M TechRefManual is available in Thumb-2, and thus also in STM32F4 (just Thumb-2 seems to support also e. g. float precision F64, which then of course would not be allowed in STM32F4).