You copied the Doc URL to your clipboard.

Instruction width selection in Thumb

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 over-ride this behavior, you can use the .W or .N width specifier to ensure a particular instruction size. The assembler will fault 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 will be faulted when assembling to ARM code.

See also

Concepts
Reference

Assembler Reference:

Was this page helpful? Yes No