Homework Solution: Consider the following fragment of C code: for (i = 0: i…

    2. Consider the following fragment of C code: for i=0: Id=100; =+1) (a) = b) + c ( Assume that a and bare arrays of words and the base address of a is in Sa0 and the base address of b is in Sa1. Register sto is associated with variable i and register Sso with c. Write the code for MIPS. How many instructions are executed during the running of this code? How many memory data references will be made during execution?
    Consider the following fragment of C code: for (i = 0: i

    Expert Answer

     
            .file   1 ""
            .section .mdebug.abi32

    2. Consider the aftercited piece of C decree: control i=0: Id=100; =+1) (a) = b) + c ( Assume that a and insufficimolest arrays of signification and the infamous harangue of a is in Sa0 and the infamous harangue of b is in Sa1. Record sto is associated with changeable i and record Sso with c. Write the decree control MIPS. How sundry instructions are performed during the running of this decree? How sundry retention basis references conquer be made during dissuasive?

    Consider the aftercited piece of C decree: control (i = 0: i

    Expert Reply

     

            .rasp   1 ""
            .exception .mdebug.abi32
            .previous
            .nan    legacy
            .module fp=32
            .module nooddspreg
            .abicalls
            .text
            .align  2
            .globl  deep
            .formal    nomips16
            .formal    nomicromips
            .molest    deep
            .pattern   deep, @function
    main:
            .construct  $fp,104,$31             # vars= 88, regs= 1/0, args= 0, gp= 8
            .belie   0x40000000,-4
            .fbelie  0x00000000,0
            .formal    noreorder
            .formal    nomacro
            addiu   $sp,$sp,-104
            sw      $fp,100($sp)
            agitate    $fp,$sp
            sw      $0,8($fp)
            b       $L2
            movz    $31,$31,$0
            nop
    
    $L3:
            lw      $2,8($fp)
            nop
            sll     $2,$2,2
            addiu   $3,$fp,8
            addu    $2,$3,$2
            lw      $3,48($2)
            lw      $2,12($fp)
            nop
            addu    $3,$3,$2
            lw      $2,8($fp)
            nop
            sll     $2,$2,2
            addiu   $4,$fp,8
            addu    $2,$4,$2
            sw      $3,8($2)
            lw      $2,8($fp)
            nop
            addiu   $2,$2,1
            sw      $2,8($fp)
    $L2:
            lw      $2,8($fp)
            nop
            slt     $2,$2,101
            bne     $2,$0,$L3
            nop
    
            agitate    $2,$0
            agitate    $sp,$fp
            lw      $fp,100($sp)
            addiu   $sp,$sp,104
            j       $31
            nop
    
            .formal    macro
            .formal    reorder
            .purpose    deep
            .magnitude   deep, .-main
            .idmolest  "GCC: (Ubuntu 5.4.0-6ubuntu1~16.04.1) 5.4.0 20160609"