csse232_hw2_soln

csse232_hw2_soln - Fall 2009-2010 CSSE 232 CSSE 232 –...

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

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Fall 2009-2010 CSSE 232 CSSE 232 – Computer Architecture I Rose-Hulman Institute of Technology Computer Science and Software Engineering Department Homework 2 Solutions 1. (10 points) Original: Loop: sll $t1, $s3, 2 # $t1 = 4*i add $t1, $t1, $s6 # $t1 = address of save[i] lw $t0, 0($t1) # $t0 = save[i] bne $t0, $s5, Exit # exit if save[i] != k addi $s3, $s3, 1 # i = i+1 j Loop # go to Loop Exit: #inst = 6 × # iterations + 4 = 64 Optimization 1: Loop: sll $t1, $s3, 2 # $t1 = 4*i add $t1, $t1, $s6 # $t1 = address of save[i] lw $t0, 0($t1) # $t0 = save[i] addi $s3, $s3, 1 # i = i+1 beq $t0, $s5, Loop # loop if save[i] == k addi $s3, $s3, -1 # fix i Exit: #inst = 5 × # iterations + 6 = 56 Optimization 2 sll $t1, $s3, 2 # $t1 = 4*i Loop: add $t1, $t1, $s6 # $t1 = address of save[i] lw $t0, 0($t1) # $t0 = save[i] addi $t1, $t1, 4 # $t1 = 4(i+1) beq $t0, $s5, Loop # loop if save[i] == k srl $s3, $t1, 2 # i = $t1/4 addi $s3, $s3, -1 # fix i Exit: #inst = 4 × # iterations + 7 = 47 20 October 2009 Page 1 Fall 2009-2010 CSSE 232 2. (10 points) Let add , addi and sll be type A instructions and lw and bne be type B instructions.be type B instructions....
View Full Document

This note was uploaded on 12/04/2009 for the course ECE 471 taught by Professor Someprofessor during the Spring '09 term at Cornell.

Page1 / 5

csse232_hw2_soln - Fall 2009-2010 CSSE 232 CSSE 232 –...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online