ARM VERSION 1.2 Guia do Utilizador Página 38

  • Descarregar
  • Adicionar aos meus manuais
  • Imprimir
Vista de página 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
Vista de página 37
1 2 ... 33 34 35 36 37 38 39 40 41 42 43 ... 132 133

Comentários a estes Manuais

Sem comentários