6.7.1. ARM and CODE32

The ARM directive and the CODE32 directive are synonyms. They instruct the assembler to interpret subsequent instructions as ARM instructions. If necessary, they also insert up to three bytes of padding to align to the next word boundary.

In this mode, the assembler accepts both the latest assembly language and the earlier version.

Syntax

ARM
CODE32

Usage

In files that contain a mixture of ARM and Thumb code:

  • Use ARM when changing from Thumb state to ARM state. ARM (or CODE32) must precede any ARM code.

  • Use THUMB when changing from ARM state to Thumb state, if the following code uses ARM syntax (see THUMB).

  • Use CODE16 when changing from ARM state to Thumb state, if the following code uses old Thumb syntax (see CODE16).

ARM and CODE32 do not assemble to instructions that change the state. They only instruct the assembler to assemble ARM instructions as appropriate, and insert padding if necessary.

Example

This example shows how ARM and CODE16 can be used to branch from ARM to 16-bit Thumb instructions.

        AREA    ChangeState, CODE, READONLY
        ARM
                             ; This section starts in ARM state
        LDR     r0,=start+1  ; Load the address and set the
                             ; least significant bit
        BX      r0           ; Branch and exchange instruction sets
                             
                             ; Not necessarily in same section
        CODE16               ; Following instructions are old Thumb
start   MOV     r1,#10       ; old Thumb instructions
Copyright © 2002-2005 ARM Limited. All rights reserved.ARM DUI 0204F
Non-Confidential