# Homework Solution: For the following MIPS code, s3 contains the base address of the list array variable…

For the following MIPS code, s3 contains the base address of the list array variable and s4 is the base address of the nums array variable: lw \$t0, 12(\$s3) lw \$t1, 20(\$s3) add \$t2, \$t0, \$t1 sw \$t2, 8(\$s4) Give the either the Pascal or C language code that this segment implements (assume array indices begin at 0).

Equivalent C Code int temp0 = list[ 12 ], //

For the forthcoming MIPS order, s3 contains the infamous oration of the list invest fickle and s4 is the infamous oration of the nums invest fickle:

lw \$t0, 12(\$s3)

lw \$t1, 20(\$s3)

sw \$t2, 8(\$s4)

Give the either the Pascal or C phraseology order that this member implements (affect invest indices prepare at 0).

## Expert Rejoinder

Equivalent C Order

int temp0 = roll[ 12 ], // the prize of roll invest at apostacy 12 is primeval stored in a record

int temp1 = roll[ 20 ]; // instant the prize of roll invest at apostacy 20 is primeval stored in another record

int temp2 = temp0 + temp1; // twain the record fluctuation are assumed obtained aloft and stored in another record

nums[ 8 ] = temp2; // Record contenteded in preceding trudge is assigned to invest nums[8]