ARM VERSION 1.2 Guide de l'utilisateur Page 29

  • 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 28
3.4 Assembly language interworking using veneers
The assembly language ARM/Thumb interworking method described in Assembly language interworking carried out
all the necessary intermediate processing. There was no requirement for the linker to insert interworking veneers.
This section describes how you can make use of interworking veneers to:
interwork between assembly language modules
interwork between assembly language and C or C++ modules.
3.4.1 Assembly-only interworking using veneers
You can write assembly language ARM/Thumb interworking code to make use of interworking veneers generated by
the linker. To do this, you write:
A caller routine just as any non-interworking routine, using a BL instruction to make the call. A caller routine may
be assembled /interwork or /nointerwork.
A callee routine using a BX instruction to return. A callee routine must be assembled /interwork.
This is generally only necessary in ARM architecture v4T, or if the caller and callee are widely separated or in
different areas. In ARM architecture v5T, if the caller and callee are sufficiently close together, no veneers are
necessary.
Example of assembly language interworking using veneers
Example 3-5 shows the code to set registers r0 to r2 to the values 1, 2, and 3 respectively. Registers r0 and r2 are
set by the ARM code. r1 is set by the Thumb code. Observe that:
the code must be assembled with the option -apcs /interwork
a BX lr instruction is used to return from the subroutine, instead of the usual MOV pc,lr.
Example 3-5
; *****
; arm.s
; *****
AREA Arm,CODE,READONLY ; Name this block of code.
IMPORT ThumbProg
ENTRY ; Mark 1st instruction to call.
ARMProg
MOV r0,#1 ; Set r0 to show in ARM code.
BL ThumbProg ; Call Thumb subroutine.
MOV r2,#3 ; Set r2 to show returned to ARM.
; Terminate execution.
MOV r0, #0x18 ; angel_SWIreason_ReportException
LDR r1, =0x20026 ; ADP_Stopped_ApplicationExit
SWI 0x123456 ; ARM semihosting SWI
END
; *******
; thumb.s
; *******
AREA Thumb,CODE,READONLY
; Name this block of code.
CODE16 ; Subsequent instructions are Thumb.
EXPORT ThumbProg
ThumbProg
MOV r1, #2 ; Set r1 to show reached Thumb code.
BX lr ; Return to ARM subroutine.
END ; Mark end of this file.
Follow these steps to build and link the modules, and examine the interworking veneers:
1. Type armasm arm.s to assemble the ARM code.
2. Type armasm -16 -apcs /interwork thumb.s to assemble the Thumb code.
3. Type armlink arm.o thumb.o -o count to link the two object files.
4. Type armsd count to load the code into the debugger.
5. Type list 0x8000 at the armsd command prompt to list the code. Example 3-6 shows the output.
Example 3-6
Interworking ARM and Thumb
Copyright ?1999 2001 ARM Limited 3-8
Vue de la page 28
1 2 ... 24 25 26 27 28 29 30 31 32 33 34 ... 132 133

Commentaires sur ces manuels

Pas de commentaire