Cirrus Logic CS485 Manual do Utilizador Página 30

  • Descarregar
  • Adicionar aos meus manuais
  • Imprimir
  • Página
    / 67
  • Índice
  • MARCADORES
  • Avaliado. / 5. Com base em avaliações de clientes
Vista de página 29
CS485G Spring 2015 30
3. The compiler knows all the offsets.
30 Linked lists
1. Example:
1 void set_val(struct rec
*
r, int val) {
2 while (r) {
3 int i = r->i;
4 r->y[i] = val;
5 r = r->n;
6 }
7 }
# assume d = r
# assume c = val
.L17: # loop:
movl 12(%edx), %eax # a = r->i
movl %ecx, (%edx,%eax,4) # r->y[r->i] = val
movl 16(%edx), %edx # r = r->n
testl %edx, %edx # Test r
jne .L17 # If != 0 goto loop
31 Alignment
1. Example:
1 struct S1 {
2 char c;
3 int y[2];
4 double v; // uses 8 bytes
5 }
*
p;
2. The character c uses only 1 byte, so the array y starts at offset 1, and
v at offset 9.
3. But the x86 advises that n-byte primitive data should start at an ad-
dress divisible by n, that is, it should be aligned to such an address.
(a) 1 byte (char): any address
Vista de página 29
1 2 ... 25 26 27 28 29 30 31 32 33 34 35 ... 66 67

Comentários a estes Manuais

Sem comentários