ARM, THUMB, THUMBX, CODE16 and CODE32

The ARM directive and the CODE32 directive are synonyms. They instruct the assembler to interpret subsequent instructions as ARM instructions, using either the UAL or the pre-UAL ARM assembler language syntax.

The THUMB directive instructs the assembler to interpret subsequent instructions as Thumb instructions, using the UAL syntax.

The THUMBX directive instructs the assembler to interpret subsequent instructions as ThumbEE instructions, using the UAL syntax.

The CODE16 directive instructs the assembler to interpret subsequent instructions as Thumb instructions, using the pre-UAL assembly language syntax.

If necessary, these directives also insert up to three bytes of padding to align to the next word boundary for ARM, or up to one byte of padding to align to the next halfword boundary for Thumb or ThumbEE.

Show/hideSyntax

ARM
THUMB
THUMBX
CODE16
CODE32

Show/hideUsage

In files that contain code using different instruction sets:

  • ARM must precede any ARM code. CODE32 is a synonym for ARM.

  • THUMB must precede Thumb code written in UAL syntax.

  • THUMBX must precede ThumbEE code written in UAL syntax.

  • CODE16 must precede Thumb code written in pre-UAL syntax.

These directives do not assemble to any instructions. They also do not change the state. They only instruct the assembler to assemble ARM, Thumb, or ThumbEE instructions as appropriate, and insert padding if necessary.

Show/hideExample

This example shows how ARM and THUMB can be used to switch state and assemble both ARM and Thumb instructions in a single area.

        AREA ToThumb, CODE, READONLY    ; Name this block of code
        ENTRY                           ; Mark first instruction to execute
        ARM                             ; Subsequent instructions are ARM 
start
        ADR     r0, into_thumb + 1      ; Processor starts in ARM state 
        BX      r0                      ; Inline switch to Thumb state
        THUMB                           ; Subsequent instructions are Thumb
into_thumb
        MOVS    r0, #10                 ; New-style Thumb instructions
Copyright © 2011-2012 ARM. All rights reserved.ARM DUI 0588B
Non-ConfidentialID062912