midterm_sol_v7

# midterm_sol_v7 - EE108B Digital Systems II Stanford...

This preview shows pages 1–3. Sign up to view the full content.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Problem 1: MIPS ISA (15 points) Consider the following C segment: while (save[i] == k) i = i + j; with i , j , and corresponding to registers \$s3 , \$s4 , and \$s5  and the base of the array saved in \$s6 . The assembly code corresponding to this C segment is given as: Loop: add \$t1, \$s3, \$s3 # Temp reg \$t1 = 2 * i add \$t1, \$t1, \$t1 # Temp reg \$t1 = 4 * i add \$t1, \$t1, \$s6 # \$t1 = address of save [i] lw \$t0, 0(\$t1) # Temp reg \$t0 = save[i] bne \$t0, \$s5, Exit # go to Exit if save[i] ¹ k add \$s3, \$s3, \$s4 # i = i + j j Loop # go to Loop Exit: a) [ 5 points ] How many instructions are executed if the number of iterations of the loop is 10?
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern