Share via


Mode Switching

The instruction that accomplishes the mode switch is the branch and exchange (BX) instruction. The calling sequence required to call a function compiled by CLTHUMB from within a function compiled by CLARM and vice-versa must include a BX instruction, both on the caller side and on the callee side.

The BX instruction is of the form BX Rx where Rx is a register containing an address. If the low bit of the BX target address is set, BX causes a switch into THUMB mode. If the low bit of the BX target address is not set, BX causes a switch into ARM mode. The linker is responsible for setting the low bit of THUMB function addresses at link time.

An interworking call is a call made from an ARM function to a THUMB function, or vice versa. The ARM C/C++ compiler provides several facilities supporting interworking function calls and interworking returns. The following list shows the facilities that support interworking.

  • Compiler flags
  • Language extensions by way of interworking declspecs
  • Link-time generation of thunking routines.

The use of an interworking calling sequence allows a mode switch to occur but does not require a mode switch to occur. A THUMB function may call another THUMB function — and an ARM function may call another ARM function — through an interworking calling sequence.

See Also

THUMB-enabled ARM Implementation | ARM Compiler Flags | Declspecs | Linker-Generated Thunking Routines

 Last updated on Thursday, April 08, 2004

© 1992-2003 Microsoft Corporation. All rights reserved.