Section 8.5: How Indirect Addressing Works (Frame 12)                     [prev][home][next]

Finally, let us look at how the elements of an array would be summed up, without looking at the CSC-1 assembler program that does it. This will be shown in Chapter 9.

The picture below shows a 5-element array of small integers, in locations 2500 through 2504. A pointer variable is in location 1000, and it currently points to the first element of the array by having 2500 in it. A sum variable in location 1500 currently contains 0. When we are done, it will contain 8+2+1+4+6, or 21, which is the sum of elements of this array.