ARM VERSION 1.2 Guide de l'utilisateur Page 38

  • 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 37
Writing the multiply routine in C:
// long multiply routine in C
long long smull(int x, int y)
{
return (long long) x * (long long) y;
}
The compiler generates the following code:
MOV r2,r0
MOV r0,r1
MOV r1,r2
SMULL r12,r1,r0,r2
MOV r0,r12
MOV pc,lr
r12 is corrupted in this routine. This is allowed under ATPCS.
Example 4-5 Multiply in inline assembly language
Writing the same routine using inline assembly language:
long long smull(int x, int y)
{
long long res;
__asm { SMULL ((int*)&res)[0], ((int*)&res)[1], x, y }
return res;
}
The compiler generates the following code:
MOV r2,r0
SMULL r0,r1,r2,r1
MOV pc,lr
Mixing C, C++, and Assembly Language
Copyright ?1999 2001 ARM Limited 4-7
Vue de la page 37
1 2 ... 33 34 35 36 37 38 39 40 41 42 43 ... 132 133

Commentaires sur ces manuels

Pas de commentaire