Arm VERSION 1.2 Manuel d'utilisateur Page 34

  • Télécharger
  • Ajouter à mon manuel
  • Imprimer
  • Page
    / 360
  • Table des matières
  • MARQUE LIVRES
  • Noté. / 5. Basé sur avis des utilisateurs
Vue de la page 33
Writing ARM and Thumb Assembly Language
2-22 Copyright © 2000, 2001 ARM Limited. All rights reserved. ARM DUI 0068B
2.5.3 Using conditional execution in ARM state
You can use conditional execution of ARM instructions to reduce the number of branch
instructions in your code. This improves code density.
Branch instructions are also expensive in processor cycles. On ARM processors without
branch prediction hardware, it typically takes three processor cycles to refill the
processor pipeline each time a branch is taken.
Some ARM processors, for example ARM10
and StrongARM
®
, have branch
prediction hardware. In systems using these processors, the pipeline only needs to be
flushed and refilled when there is a misprediction.
2.5.4 Example of the use of conditional execution
This example uses two implementations of Euclids Greatest Common Divisor (gcd)
algorithm. It demonstrates how you can use conditional execution to improve code
density and execution speed. The detailed analysis of execution speed only applies to
an ARM7
processor. The code density calculations apply to all ARM processors.
In C the algorithm can be expressed as:
int gcd(int a, int b)
{
while (a != b) do
{
if (a > b)
a = a - b;
else
b = b - a;
}
return a;
}
You can implement the gcd function with conditional execution of branches only, in the
following way:
gcd CMP r0, r1
BEQ end
BLT less
SUB r0, r0, r1
B gcd
less
SUB r1, r1, r0
B gcd
end
Vue de la page 33
1 2 ... 29 30 31 32 33 34 35 36 37 38 39 ... 359 360

Commentaires sur ces manuels

Pas de commentaire