6.17 Instruction width selection in Thumb

If the assembler can select either a 16-bit or a 32-bit encoding for a Thumb instruction, in general it selects the 16-bit encoding. You can override this by specifying a .W or .N mnemonic qualifier.

If you are writing Thumb code for ARMv6T2 or later processors, some instructions can have either a 16-bit encoding or a 32-bit encoding.

If you do not specify the instruction size, by default:

  • For forward reference LDR, ADR, and B instructions, the assembler always generates a 16-bit instruction, even if that results in failure for a target that could be reached using a 32-bit instruction.

  • For external reference LDR and B instructions, the assembler always generates a 32-bit instruction.

  • In all other cases, the assembler generates the smallest size encoding that can be output.

If you want to override this behavior, you can use the .W or .N width specifier to ensure a particular instruction size. The assembler faults if it cannot generate an instruction with the specified width.

The .W specifier is ignored when assembling to ARM code, so you can safely use this specifier in code that might assemble to either ARM or Thumb code. However, the .N specifier is faulted when assembling to ARM code.

Non-ConfidentialPDF file icon PDF versionARM DUI0473M
Copyright © 2010-2016 ARM Limited or its affiliates. All rights reserved.