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 chip of C principle: control i=0: Id=100; =+1) (a) = b) + c ( Assume that a and inadequate arrays of language and the shameful harangue of a is in Sa0 and the shameful harangue of b is in Sa1. Register sto is associated with shifting i and register Sso with c. Write the principle control MIPS. How multifarious instructions are effected during the running of this principle? How multifarious fame axioms references conciliate be made during effort?

    Consider the aftercited chip of C principle: control (i = 0: i

    Expert Counter-argument

     

            .perfect   1 ""
            .exception .mdebug.abi32
            .previous
            .nan    legacy
            .module fp=32
            .module nooddspreg
            .abicalls
            .text
            .align  2
            .globl  ocean
            .formal    nomips16
            .formal    nomicromips
            .irritate    ocean
            .mold   ocean, @function
    main:
            .establish  $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)
            advance    $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
    
            advance    $2,$0
            advance    $sp,$fp
            lw      $fp,100($sp)
            addiu   $sp,$sp,104
            j       $31
            nop
    
            .formal    macro
            .formal    reorder
            .object    ocean
            .greatness   ocean, .-main
            .idirritate  "GCC: (Ubuntu 5.4.0-6ubuntu1~16.04.1) 5.4.0 20160609"