Cirrus Logic CS485 Manual de usuario Pagina 16

  • Descarga
  • Añadir a mis manuales
  • Imprimir
  • Pagina
    / 67
  • Tabla de contenidos
  • MARCADORES
  • Valorado. / 5. Basado en revisión del cliente
Vista de pagina 15
CS485G Spring 2015 16
1 int arith(int x, int y, int z)
2 {
3 int t1 = x+y;
4 int t2 = z+t1;
5 int t3 = x+4;
6 int t4 = y
*
48;
7 int t5 = t3 + t4;
8 int rval = t2
*
t5;
9 return rval;
10 }
7. Result of compilation
pushl %ebp # save base pointer
movl %esp,%ebp # new base pointer
movl 8(%ebp), %ecx # $c = x
movl 12(%ebp), %edx # $d = y
leal (%edx,%edx,2), %eax # $a = 3y
sall $4, %eax # $a = 48y [t4]
leal 4(%ecx,%eax), %eax # $a = x + 48y + 4 [t5]
addl %ecx, %edx # $d = x + y [t1]
addl 16(%ebp), %edx # $d = x + y + z [t2]
imull %edx, %eax # $a = (x+y+z)
*
(x+48y+4)
popl %ebp # restore base pointer
ret # return $a [rval]
8. Optimization converts multiple expressions to a single statement,
and a single expression might require multiple instructions.
9. The compiler generates the same code for (x+y+z)
*
(x+4+48
*
y).
10. Example
1 int logical(int x, int y)
2 {
3 int t1 = xˆy;
4 int t2 = t1 >> 17;
5 int mask = (1<<13) - 7; // 8185
6 int rval = t2 & mask;
7 return rval;
8 }
Vista de pagina 15
1 2 ... 11 12 13 14 15 16 17 18 19 20 21 ... 66 67

Comentarios a estos manuales

Sin comentarios