Computer Organization and Design For More Practice Problem 2.28

Tags: •  • 

I’m using Computer Organization and Design, 3rd ed (David Patterson and John Hennessy) for an electrical engineering course (that I have to take to graduate) in computer systems architecture. Assigned as homework, from the For More Practice section, is problem 2.28:

Here is some stylized MIPS code associated with procedure call:

r:... # R/W $s0,$v0,$t0,$a0,$sp,$ra,mem
... ### PUSH REGISTER(S) TO STACK?
jal e # Call e
... # R/W $s0,$v0,$t0,$a0,$sp,$ra,mem
jr $ra # Retur to call of r?

e:... # R/W $s0,$v0,$t0,$a0,$sp,$ra,mem
jr $ra # Return to r

What does r have to push on the stack before jal e?

A: Nothing
B: 1 of ($s0,$sp,$v0,$t0,$a0,$ra)
C: 2 of ($s0,$sp,$v0,$t0,$a0,$ra)
D: 3 of ($s0,$sp,$v0,$t0,$a0,$ra)
E: 4 of ($s0,$sp,$v0,$t0,$a0,$ra)
F: 5 of ($s0,$sp,$v0,$t0,$a0,$ra)

It took me a good solid hour of thinking to understand this question. It’s asking, of the list given in the options, how many of those registers should be saved?

Talk about horrible question.

If you want the answer, by convention, you’d need to save $s0, $v0, $a0, and $ra. Four registers, so the correct answer is E.

This book has a ridiculous amount of errors… Were their proofreaders doing anything? It’s useful to have the publisher’s list of errata handy as a bookmark.


Reply

The content of this field is kept private and will not be shown publicly.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • You can use Markdown syntax to format and style the text.
  • Images can be added to this post.
  • You may use [inline:xx] tags to display uploaded files or images inline.
More information about formatting options