a
, b
, and c
are indexed from 1
to n
in each dimension. Decide whether you are going to
treat n
as a variable or as a name for a constant value.
State your decision. If you decide it is a constant, you can just
include n
in your code to indicate that constant, or an
arithmetic expression involving n
to indicate another
constant derived from it. You may use MIPS assembly language notation
in place of the book's three-address intermediate code notation, if
you are more comfortable with that. You should assume (in this case)
that scalar variables live in registers. Either give me a table
showing which register is used for which variable, or just use a
notation like $i
for the register containing the variable
i
. You can assume the existence of labels
a
, b
, and c
at the base of each
array, and use the notation (a-4)
to indicate the
(constant) address four bytes before the start of a
, etc.
If you use the book's three-address intermediate code format, I would
prefer that you not use the bracket notation, but rather did the
address addition explicitly. If you use MIPS assembly language
notation in place of the three-address intermediate code, again show
the address addition explicitly, always using an offset of 0 in the
lw
and sw
instructions (so that the base
register has to contain the actual address). If you use MIPS code,
you can skip parts b and h, which call for generating "target-machine
code." If, on the other hand, you use three-address intermediate
code, then go ahead and do parts b and h but using the MIPS as your
target machine, rather than the one defined in the book.
Also, briefly describe any major opportunities for optimizing this routine that are not covered by the exercise. Keep in mind that on contemporary machines, it is memory accesses that are generally the most time consuming operations.