Contents    Page-10    Prev    Next    Page+10    Index   

Array References

An array is a data area consisting of a linear sequence of items, each of which is of the same size and type. Items are addressed by numeric index.

The address of an array reference must be calculated by the compiler. We assume that the array is declared as:
A: ARRAY[ L1 .. U1 , L2 .. U2 , ... , Ln .. Un ] OF Type

The address of a reference A[ S1 , S2 , ... , Sn ] is given by the formula: Address = Base( A ) + ∑i=1n (Si - Li) · Di where for row-major order (C, Pascal), Dn = length of one datum of Type Di-1 = Di · (Ui - Li + 1) or for column-major order (Fortran), D1 = length of one datum of Type Di+1 = Di · (Ui - Li + 1)