ARM directive and the
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.
THUMB directive instructs the assembler to
interpret subsequent instructions as Thumb instructions, using the
THUMBX directive instructs the assembler
to interpret subsequent instructions as ThumbEE instructions, using
the UAL syntax.
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.
In files that contain code using different instruction sets:
ARMmust precede any ARM code.
CODE32is a synonym for
THUMBmust precede Thumb code written in UAL syntax.
THUMBXmust precede ThumbEE code written in UAL syntax.
CODE16must 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.
This example shows how you can use
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