ARM VERSION 1.2 Guide de l'utilisateur Page 30

  • 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 29
armsd: list 0x8000
ARMProg
0x00008000: 0xe3a00001 .... : > mov r0,#1
0x00008004: 0xeb000005 .... : bl $Ven$AT$$ThumbProg
0x00008008: 0xe3a02003 . .. : mov r2,#3
0x0000800c: 0xe3a00018 .... : mov r0,#0x18
0x00008010: 0xe59f1000 .... : ldr r1,0x00008018 ; = #0x00020026
0x00008014: 0xef123456 V4.. : swi 0x123456
0x00008018: 0x00020026 &... : dcd 0x00020026 &...
ThumbProg
+0000 0x0000801c: 0x2102 .! : mov r1,#2
+0002 0x0000801e: 0x4770 pG : bx r14
$Ven$AT$$ThumbProg
+0000 0x00008020: 0xe59fc000 .... : ldr r12,0x00008028 ; = #0x0000801d
+0004 0x00008024: 0xe12fff1c ../. : bx r12
+0008 0x00008028: 0x0000801d .... : dcd 0x0000801d ....
+000c 0x0000802c: 0xe800e800 .... : dcd 0xe800e800 ....
+0010 0x00008030: 0xe7ff0010 .... : dcd 0xe7ff0010 ....
+0014 0x00008034: 0xe800e800 .... : dcd 0xe800e800 ....
+0018 0x00008038: 0xe7ff0010 .... : dcd 0xe7ff0010 ....
You can see that the linker has added the required ARM-to-Thumb interworking veneer. This is contained in
locations 0x8020 to 0x8028. Location 0x8028 contains the address of the routine being branch-exchanged to,
with bit 0 set, 0x801D.
3.4.2 C, C++, and assembly language interworking using veneers
C and C++ code compiled to run in one state can call assembly language code designed to run in the other state,
and vice versa. To do this, write the caller routine as any non-interworking routine and, if calling from assembly
language, use a BL instruction to make the call (see Example 3-7). Then:
if the callee routine is in C, compile it using -apcs /interwork
if the callee routine is in assembly language, assemble with the -apcs /interwork option and return using
BX lr.
Note
Any assembly language code or user library code used in this manner must conform to the ATPCS where
appropriate.
Example 3-7
/**********************
* thumb.c *
**********************/
#include <stdio.h>
extern int arm_function(int);
int main(void)
{
int i = 1;
printf("i = %d\n", i);
printf("And now i = %d\n", arm_function(i));
return (0);
}
; *****
; arm.s
; *****
AREA Arm,CODE,READONLY ; Name this block of code.
EXPORT arm_function
arm_function
ADD r0,r0,#4 ; Add 4 to first parameter.
BX LR ; Return
END
Follow these steps to build and link the modules:
1. Type tcc -c -apcs /interwork thumb.c to compile the Thumb code.
2. Type armasm -apcs /interwork arm.s to assemble the ARM code.
3. Type armlink arm.o thumb.o -o add to link the two object files.
Interworking ARM and Thumb
Copyright ?1999 2001 ARM Limited 3-9
Vue de la page 29
1 2 ... 25 26 27 28 29 30 31 32 33 34 35 ... 132 133

Commentaires sur ces manuels

Pas de commentaire