Cirrus Logic CS485 Manual de usuario Pagina 28

  • Descarga
  • Añadir a mis manuales
  • Imprimir
  • Pagina
    / 67
  • Tabla de contenidos
  • MARCADORES
  • Valorado. / 5. Basado en revisión del cliente
Vista de pagina 27
CS485G Spring 2015 28
8. Loop example
1 void zincr(myArrayType z) {
2 int i;
3 for (i = 0; i < ZLEN; i+=1)
4 z[i] += 1;
5 }
# assume d = z
movl $0, %eax # a = 0
.L4: # loop:
addl $1, (%edx,%eax,4) # z[i] += 1
addl $1, %eax # i+=1
cmpl $5, %eax # i:5
jl .L4 # if < goto loop
28 Nested arrays
1.
1 #define PCOUNT 4
2 myArrayType pgh[PCOUNT] =
3 {{1, 5, 2, 0, 6 },
4 {1, 5, 2, 1, 3 },
5 {1, 5, 2, 1, 7 },
6 {1, 5, 2, 2, 1 }};
2. The values are placed contiguously from some location x to x +
4*PCOUNT*ZLEN - 1 = x + 79. This ordering is guaranteed.
3. pgh is an array of 4 elements.
4. Each of those elements is an array of 5 sub-elements.
5. Each of those sub-elements is an integer occupying 4 bytes.
6. Equivalent declaration: int pgh[PCOUNT][ZLEN];
7. C code: return pgh[index] (the return type is int *)
# assume a = index
leal (%eax,%eax,4),%eax # a = 5
*
index
leal pgh(,%eax,4),%eax # a = pgh + (20
*
index)
Vista de pagina 27
1 2 ... 23 24 25 26 27 28 29 30 31 32 33 ... 66 67

Comentarios a estos manuales

Sin comentarios