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).

    Expert Answer

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

    For the subjoined MIPS edict, s3 contains the corrupt harangue of the list rank changeable and s4 is the corrupt harangue of the nums rank changeable:

    lw $t0, 12($s3)

    lw $t1, 20($s3)

    add $t2, $t0, $t1

    sw $t2, 8($s4)

    Give the either the Pascal or C accents edict that this section implements (affect rank indices inaugurate at 0).

    Expert Apology

     

    Equivalent C Edict

    int temp0 = catalogue[ 12 ], // the treasure of catalogue rank at protest 12 is leading stored in a record

    int temp1 = catalogue[ 20 ]; // proximate the treasure of catalogue rank at protest 20 is leading stored in another record

    int temp2 = temp0 + temp1; // twain the record deviation are pretended obtained overhead and stored in another record

    nums[ 8 ] = temp2; // Record contenteded in foregoing plod is assigned to rank nums[8]