ARM VERSION 1.2 Guide de l'utilisateur Page 22

  • Télécharger
  • Ajouter à mon manuel
  • Imprimer
  • Page
    / 133
  • Table des matières
  • DEPANNAGE
  • MARQUE LIVRES
  • Noté. / 5. Basé sur avis des utilisateurs
Vue de la page 21
3 Interworking ARM and Thumb
This chapter explains how to change between ARM state and Thumb state when writing code for processors that
implement the Thumb instruction set. It contains the following sections:
About interworking
Assembly language interworking
C and C++ interworking and veneers
Assembly language interworking using veneers.
3.1 About interworking
You can mix ARM and Thumb code as you wish, provided that the code conforms to the requirements of the
ARM/Thumb Procedure Call Standard. The ARM compilers always create code that conforms to this standard. If you
are writing ARM assembly language modules you must ensure that your code conforms.
The ARM linker detects when an ARM function is being called from Thumb state, or a Thumb function is being called
from ARM state. The ARM linker alters call and return instructions, or inserts small code sections called veneers, to
change processor state as necessary.
ARM architecture v5T provides methods of changing processor state without using any extra instructions. There is
normally no cost associated with interworking on ARM architecture v5T processors.
If you are linking several source files together, all your files must use compatible ATPCS options. If incompatible
options are detected, the linker will produce an error message.
3.1.1 When to use interworking
When you write code for a Thumb-capable ARM processor, you will probably write most of your application to run in
Thumb state. This gives the best code density. With 8-bit or 16-bit wide memory, it also gives the best performance.
However, you might want parts of your application to run in ARM state for reasons such as:
Speed
Some parts of an application might be speed critical. These sections might be more efficient
running in ARM state than in Thumb state. In some circumstances, a single ARM instruction can
do more than the equivalent Thumb instruction.
Some systems include a small amount of fast 32-bit memory. ARM code can be run from this
without the overhead of fetching each instruction from 8-bit or 16-bit memory.
Functionality
Thumb instructions are less flexible than their ARM equivalents. Some operations are not possible
in Thumb state. For example, you cannot enable or disable interrupts, or access coprocessors. A
state change is required in order to carry out these operations.
Exception handling
The processor automatically enters ARM state when a processor exception occurs. This means
that the first part of an exception handler must be coded with ARM instructions, even if it re-enters
Thumb state to carry out the main processing of the exception. At the end of such processing, the
processor must be returned to ARM state to return from the handler to the main application.
Standalone Thumb programs
A Thumb-capable ARM processor always starts in ARM state. To run simple Thumb assembly
language programs under the debugger, add an ARM header that carries out a state change to
Thumb state and then calls the main Thumb routine. See Example ARM header for an example.
3.1.2 Using the /interwork option
The option -apcs /interwork is available for all compilers and assemblers. If you set this option:
The compiler or assembler records an interworking attribute in the object file.
The linker provides interworking veneers for subroutine entry.
In assembly language, you must write function exit code that returns to the instruction set state of the caller, for
example BX LR.
In C or C++, the compiler creates function exit code that returns to the instruction set state of the caller
In C or C++, the compiler uses BX instructions for indirect or virtual calls.
Use the /interwork option if your object file contains:
Thumb subroutines that might need to return to ARM code
ARM subroutines that might need to return to Thumb code
Interworking ARM and Thumb
Copyright ?1999 2001 ARM Limited 3-1
Vue de la page 21
1 2 ... 17 18 19 20 21 22 23 24 25 26 27 ... 132 133

Commentaires sur ces manuels

Pas de commentaire