University of California at Berkeley
College of Engineering
Department of Electrical Engineering and Computer Science
EECS
61C, Spring 2005
HW 4
TA In Charge
Andy
Goals
This assignment will check your understanding of MIPS and Instruction Execution
Submitting
Your Solution
Submit your
solution online by 11:59pm on February 23. Do this by creating a directory
named hw4 that contains a file
named hw4.txt. “hw4.txt” is a text file that you create
containing your answers to the following questions. (Note that capitalization matters in file names; the submission
program will not accept your submission if your file name differs at all from
those specified.) From within that directory, type “submit hw4”.
This is not a partnership assignment; hand in your own work.
sll $a2, $a2, 2 sll $a3, $a3, 2 add $v0, $zero, $zero add $t0, $zero, $zero outer: add $t4, $a0, $t0 lw $t4, 0($t4) add $t1, $zero, $zero inner: add $t3, $a1, $t1 lw $t3, 0($t3) bne $t3, $t4, skip addi $v0, $v0, 1 skip: addi $t1, $t1, 4 bne $t1, $a3, inner addi $t0, $t0, 4 bne $t0, $a2, outer
2
Assume that the code from problem 1 is run on a machine with a 2 GHz clock that requires the following number of cycles for each instruction:
add, addi, sll: 1 Cycle
lw, bne: 2 Cycles
In the worst case, how many seconds will it take to execute this code?
here: beq $s0, $s2, there ... there: add $s0, $s0, $s0
5
Compute the decimal byte values that form the null-terminated ASCII representation of the following string:
A byte is 8 bits
Problems adapted from P&H