Unit 6.4

This  example doesn't bring in any new concepts.  It  simply
shows  the use of a do-loop with the template to obtain  and
use the address of A[I} we discussed in Unit 18.
The  example simply sets the four elements A[1], A[2],  A[3]
and  A[4]  to 1,2,3 and 4 respectively--in other words  A[i]
will be set to i for i=1 to 4.

Then  we simply go through the elements from 1 to 4 and  sum
the elements.

The  PASCAL  code  can  be  found in  the  comments  of  the
ASSEMBLER Example.

The first FOR LOOP is implemented in lines 15 to 32.

The second FOR LOOP can be found in lines 35 to 53.

Lines 15 to 16 set I to 1 for the beginning of the first for
loop.  The rest of the beginning of the FORLOOP can be found
in lines 18 through 20.  We now implement the template to do
a  ST into A[I].  You should look at the template on 112  as
well  as the sample program on page 121.  regA is two.  regB
is  3.   regC is 4.  Line 28 to 30 does the increment  of  I
associated with the FOR LOOP and lines 31 to 32 is the  rest
of the while tmeplate.

Lines  33  to  34 initialize SUM to zero.   Line  35  to  36
stoarts  I back at 1 for the second loop.  Lines  37  to  40
does  the rest of the FOR-LOOP stuff.  Lines 41 to 47 is  an
implementation of the template to retrieve something from  a
given array element found on page 112.  Again, regA is  two.
regB  is  3.  regC is 4.  Note that we do an "A" instead  of
the "L" that appears in the template.  We deposit in the SUM
in  line 48.  Lines 49 to 51 do the "I=I+1" implied  by  the
FOR LOOP and lines 52 to 54 end the WHILE LOOP.