, , , ; , .
:
int main(void)
{
int arr[3][4] = {{0,1,2,3},{4,5,6,7},{8,9,10,11}};
int *p = *arr; // == arr[0] == &arr[0][0]
int x;
x = arr[2][3]; // Straightforward array access
x = *(*(arr+2)+3); // Ugly pointer arithmetic
x = *(ptr + 11); // Slightly less ugly pointer arithmetic
return 0;
}
gcc -c -g -Wa,-a,-ad > foo.lst, .
x = arr[2][3];:
movl -16(%ebp), %eax
movl %eax, -8(%ebp)
x = *(*(arr+2)+3);:
leal -60(%ebp), %eax
addl $44, %eax
movl (%eax), %eax
movl %eax, -8(%ebp)
, , x = *(ptr + 11);:
movl -12(%ebp), %eax
addl $44, %eax
movl (%eax), %eax
movl %eax, -8(%ebp)
. 1970-. gcc , , .
, , (FWIW, -O1 ), - ( ). , , . , .
, 2 3 , . *(ptr + offset); . . , .