|
CSE Home | About Us | Search | Contact Info |
Due: Thursday, April 30, at 11 pm. This is an absolute deadline. No late assignments will be accepted after this time, even if you have unused late days. That will allow us to distribute sample solutions on Friday and discuss these problems in class then as part of reviewing for the midterm exam that is scheduled for the following Monday.
The purpose of this assignment is to explore some of the issues involved in pipelining and instruction execution.
x=a+b-c
,
assuming that a
, b
, c
, and x
are
all local variables in the current procedure's stack frame, and the variable
offsets are a
20, b
24, c
28, and x
32.
The instructions are numbered to make it easier to reference them in your answers
below.
lw $t0, 20($sp) # (1) load a lw $t1, 24($sp) # (2) load b add $t0, $t0, $t1 # (3) $t0 = a+b lw $t1, 28($sp) # (4) load c sub $t0, $t0, $t1 # (5) $t0 = a+b-c sw $t0, 32($(sp) # (6) store x
x=a+b-c
. You still need
to load the data from memory and store the result back, but you may rearrange
the order
of the instructions and use different registers if you wish. You should
assume that the pipeline has internal forwarding as in part (b). Draw the
pipeline timing diagram for your rewritten code. How many total cycles
does it take
to execute the instructions now? while (i!=n && a[i]!=0)
i++;
.
Assume that variable i
is in $s0
, n
is in $s1
, and the address of a[i]
is in
$s2
.
loop: beq $s0, $s1, done # (1) if i == n then exit lw $t0, 0($s2) # (2) load a[i] beq $t0, $zero, done # (3) if a[i] == 0 then exit add $s0, $s0, 1 # (4) i++ add $s2, $s2, 4 # (5) increment pointer to a[i] b loop # (6) repeat (beq $zero, $zero, loop) done:
Turn-in Instructions: Use the turn-in drop box link on the main course web page to submit a file containing your solutions. You can use any common file format, including plain text, word, or pdf. If you wish, you could also scan in a hand-written solution and submit that, but if you do that, please be sure your handwriting is neat and legible. Please be sure to include your name at the top of your answers.
Computer Science & Engineering University of Washington Box 352350 Seattle, WA 98195-2350 (206) 543-1695 voice, (206) 543-2969 FAX [comments to Hal Perkins] |