Computer Organization and Design For More Practice Problem 2.28

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.

Like this article? Please support my writing! Flattr my blog (see my thoughts on Flattr), tip me via PayPal, or send me an item from my Amazon wish list.