|
Array Access Problem Solution | |
|
| |
On the dope vector for
To find the L-value for a[i,j], you must skip down i rows, then
along j columns. We move along a row the distance past the
beginning, that is, the distance past 3. Each step is of size 4 bytes, so
we move along the row a distance of 4×(j−3).
To reach the row, we
must likewise skip down i rows from the start of the array.
The size of a row is 4×(8−3+1), and we need to pass
i−2 of them. Therefore, the L-value of
the a[i,j] is
i−2) + 4×(j−3)i + 4×j| V0 = 4940 |
| d1 = 24 |
| d2 = 4 |
The short way is to recall that the algebra has already been done. The d2 value is always the size of the array element type, and
The vector tells you that the location of a[5, 7], for instance, is
For the slice, b = a[*,6], you need to see that b[i] is just
another way to write a[i,6]. So the L-value of b[i] can be
given as:
i + 4×6
= 4964 + 24×i
| V0 = 4964 |
| d1 = 24 |