hw1 - EE108B Winter 2003-2004 Handout#5 Homework#1 Due...

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

View Full Document Right Arrow Icon
EE108B Winter 2003-2004 Handout #5 Homework #1 Due Thurs. Jan 22, 5 PM in Gates 408 1. The following code fragment processes an array and produces two values in registers $v0 and $v1: add $a1, $a1, $a1 add $a1, $a1, $a1 add $v0, $zero, $zero add $t0, $zero, $zero outer: add $t4, $a0, $t0 lw $t4, 0($t4) add $t5, $zero, $zero add $t1, $zero, $zero inner: add $t3, $a0, $t1 lw $t3, 0($t3) bne $t3, $t4, skip addi $t5, $t5, 1 skip: addi $t1, $t1, 4 bne $t1, $a1, inner slt $t2, $t5, $v0 bne $t2, $zero, next add $v0, $t5, $zero add $v1, $t4, $zero next: addi $t0, $t0, 4 bne $t0, $a1, outer Assume that: The array consists of 5000 indexed 0 through 4999 Its base address is stored in $a0 Its size (5000) is stored in $a1 a. Describe in one sentence what this code does. Specifically, what will be returned in $v0 and $v1? b. What is the total number of instructions that are executed in this piece of code? Briefly explain the number of instructions executed in each loop (e.g. There are 5 instructions that are executed once before loop outer , there are 8 instructions in loop inner that are executed 10 times, etc.). c. Assume that the code fragment is run on a machine with a 500-MHz clock that requires the following number of cycles for each instruction: 1
Background image of page 1

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

View Full DocumentRight Arrow Icon
EE108B Winter 2003-2004 Handout #5
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 11/18/2011 for the course EE 108A taught by Professor Dally during the Winter '04 term at Stanford.

Page1 / 5

hw1 - EE108B Winter 2003-2004 Handout#5 Homework#1 Due...

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