5.8.16. CODE16 directive

The CODE16 directive instructs the assembler to interpret subsequent instructions as 16-bit Thumb instructions.

Syntax

The syntax of CODE16 is:

CODE16

Usage

Use CODE16 when branching to Thumbstate with the BX instruction. CODE16 precedes code at the destination of the branch.

The assembler inserts a byte of padding, if necessary, to bring following Thumb code into halfword alignment. CODE16 does not assemble to an instruction that changes the mode. It only instructs the assembler to assemble Thumb instructions.

See also CODE32 directive.

Example

This example shows how CODE16 can be used to branch from ARM to Thumb instructions.

		AREA 		ThumbEx, CODE, READONLY
							; This area starts in ARM state
		ADR		r0,start+1			; Load the address and set the 
							; least significant bit	
		BX		r0			; Branch and exchange
							; instruction sets
							; Not necessarily in the same area
		CODE16					; Following instructions are Thumb
start		MOV		r1,#10			; Thumb instructions
Copyright © 1997, 1998 ARM Limited. All rights reserved.ARM DUI 0041C
Non-Confidential