Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Consider the following C++ code and MIPS translation C++ while (a[i] == k) i++; MIPS Loop: sll $t1, $s3, 2 # $t1 = 4i add

Consider the following C++ code and MIPS translation C++ while (a[i] == k) i++; MIPS Loop: sll $t1, $s3, 2 # $t1 = 4i add $t1, $t1, $s6 # $t1 = address of a[i] lw $t0, 0($t1) # $t0 = a[i] bne $t0, $s5, Exit # exit loop if save[i] != k addi $s3, $s3, 1 # i++ j Loop Exit: ... (a) Assuming the first value where a[i] != k is when i=10, determine the number of MIPS instructions executed by the loop if i starts at 0. (b) In the above code two branch/jump instructions are executed for each loop iteration (except the last). This turns out not to be optimal. Rewrite the above code so that only 1 branch/jump instruction is executed for each loop. Determine the total number of instructions executed using the conditions stated in part (a).

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Fundamentals Of Database Management Systems

Authors: Mark L. Gillenson

3rd Edition

978-1119907466

More Books

Students also viewed these Databases questions

Question

Create S using np . sum and X , and Expand to S

Answered: 1 week ago